problem_id stringlengths 6 6 | language stringclasses 2 values | original_status stringclasses 3 values | original_src stringlengths 19 243k | changed_src stringlengths 19 243k | change stringclasses 3 values | i1 int64 0 8.44k | i2 int64 0 8.44k | j1 int64 0 8.44k | j2 int64 0 8.44k | error stringclasses 270 values | stderr stringlengths 0 226k |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02723 | C++ | Time Limit Exceeded | #include <stdio.h>
int main(void) {
char moji[100];
do {
scanf("%s", moji);
} while (sizeof(moji) != 6);
if (moji[2] == moji[3] && moji[4] == moji[5])
puts("Yes");
else
puts("No");
return 0;
} | #include <stdio.h>
int main(void) {
char moji[100];
scanf("%s", moji);
if (moji[2] == moji[3] && moji[4] == moji[5])
puts("Yes");
else
puts("No");
return 0;
} | replace | 5 | 8 | 5 | 6 | TLE | |
p02723 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
if (str.at(3) == str.at(4) && str.at(5) == str.at(6)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
if (str.at(2) == str.at(3) && str.at(4) == str.at(5)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02723 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
if (S.at(3) == S.at(4) && S.at(5) == S.at(6)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02723 | C++ | Runtime Error | // fahadmd16(IIEST Shibpur)
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i, a, b) for (ll i = a; i < b; i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x) cout << #x << ": " << x << endl
#define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) \
cout << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \
<< z << endl
#define trace4(a, b, c, d) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \
<< #f << ": " << f << endl
#define trace(v) \
for (auto it = v.begin(); it != v.end(); it++) \
cout << *it << " "; \
cout << endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9 + 7;
typedef vector<ll> VL;
typedef vector<pll> VLL;
typedef vector<vector<ll>> VVL;
ll power(ll n, ll k, ll m) {
ll ans = 1;
while (k) {
if (k & 1)
ans = (ans * n) % m;
k /= 2;
n = (n * n) % m;
}
return ans;
}
int main() {
IOS;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll T = 1; // cin>>T;
while (T--) {
string s;
cin >> s;
ll n = s.length();
if (s.length() < 6) {
cout << "No\n";
continue;
}
if (s[2] == s[3] and s[4] == s[5])
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
| // fahadmd16(IIEST Shibpur)
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i, a, b) for (ll i = a; i < b; i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x) cout << #x << ": " << x << endl
#define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) \
cout << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \
<< z << endl
#define trace4(a, b, c, d) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \
<< #f << ": " << f << endl
#define trace(v) \
for (auto it = v.begin(); it != v.end(); it++) \
cout << *it << " "; \
cout << endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9 + 7;
typedef vector<ll> VL;
typedef vector<pll> VLL;
typedef vector<vector<ll>> VVL;
ll power(ll n, ll k, ll m) {
ll ans = 1;
while (k) {
if (k & 1)
ans = (ans * n) % m;
k /= 2;
n = (n * n) % m;
}
return ans;
}
int main() {
IOS;
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
ll T = 1; // cin>>T;
while (T--) {
string s;
cin >> s;
ll n = s.length();
if (s.length() < 6) {
cout << "No\n";
continue;
}
if (s[2] == s[3] and s[4] == s[5])
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
| replace | 65 | 69 | 65 | 69 | 0 | |
p02723 | Python | Runtime Error | s = input()
if s[3] == s[4] and s[5] == s[6]:
print("Yes")
else:
print("No")
| s = input()
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
| replace | 1 | 2 | 1 | 2 | 0 | |
p02723 | Python | Runtime Error | s = input()
if s[3] == s[4] and s[5] == s[6]:
print("Yes")
else:
print("No")
| s = input()
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
| replace | 1 | 2 | 1 | 2 | 0 | |
p02723 | Python | Runtime Error | S = input()
print("Yes" if S[3] == S[4] and S[5] == S[6] else "No")
| S = input()
print("Yes" if S[2] == S[3] and S[4] == S[5] else "No")
| replace | 1 | 2 | 1 | 2 | 0 | |
p02723 | Python | Runtime Error | s = input().split()
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
| s = input()
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
| replace | 0 | 1 | 0 | 1 | IndexError: list index out of range | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02723/Python/s530567045.py", line 2, in <module>
if s[2] == s[3] and s[4] == s[5]:
IndexError: list index out of range
|
p02723 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x, ll n, ll M) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return modularExponentiation((x * x) % M, n / 2, M);
return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
ll binaryExponentiation(ll x, ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return binaryExponentiation(x * x, n / 2);
else
return x * binaryExponentiation(x * x, (n - 1) / 2);
}
ll GCD(ll A, ll B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
ll extended_GCD(ll a, ll b, ll &x, ll &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
ll x1, y1;
ll gcd = extended_GCD(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return gcd;
}
ll modinv(ll a, ll mod) {
ll x, y;
extended_GCD(a, mod, x, y);
if (x < 0)
x += mod;
return x;
}
ll modPrimeInverse(ll A, ll M) { return modularExponentiation(A, M - 2, M); }
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin >> s;
if (s.length() < 6) {
cout << "No\n";
} else {
if (s[2] == s[3] && s[4] == s[5]) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
// #ifndef ONLINE_JUDGE
// cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
// #endif
return 0;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x, ll n, ll M) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return modularExponentiation((x * x) % M, n / 2, M);
return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
ll binaryExponentiation(ll x, ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return binaryExponentiation(x * x, n / 2);
else
return x * binaryExponentiation(x * x, (n - 1) / 2);
}
ll GCD(ll A, ll B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
ll extended_GCD(ll a, ll b, ll &x, ll &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
ll x1, y1;
ll gcd = extended_GCD(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return gcd;
}
ll modinv(ll a, ll mod) {
ll x, y;
extended_GCD(a, mod, x, y);
if (x < 0)
x += mod;
return x;
}
ll modPrimeInverse(ll A, ll M) { return modularExponentiation(A, M - 2, M); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin >> s;
if (s.length() < 6) {
cout << "No\n";
} else {
if (s[2] == s[3] && s[4] == s[5]) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
// #ifndef ONLINE_JUDGE
// cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
// #endif
return 0;
}
| delete | 45 | 49 | 45 | 45 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define repeq(i, n) for (int(i) = 0; (i) <= (int)(n); (i)++)
#define rep1(i, x, n) for (int(i) = (x); (i) < (int)(n); (i)++)
#define rep1eq(i, x, n) for (int(i) = (x); (i) <= (int)(n); (i)++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
using namespace std;
using ll = long long;
using Int = long long;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int, int> P;
// 少数点表示
// cout << std::fixed << std::setprecision(14) << 値
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin >> x;
int amari = 0;
int happy = 0;
if (x == 0) {
cout << 0;
return 0;
}
int z = x / 500;
happy += (1000 * z);
int y = (x % (500 * z)) / 5;
happy += (5 * y);
cout << happy;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define repeq(i, n) for (int(i) = 0; (i) <= (int)(n); (i)++)
#define rep1(i, x, n) for (int(i) = (x); (i) < (int)(n); (i)++)
#define rep1eq(i, x, n) for (int(i) = (x); (i) <= (int)(n); (i)++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
using namespace std;
using ll = long long;
using Int = long long;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int, int> P;
// 少数点表示
// cout << std::fixed << std::setprecision(14) << 値
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin >> x;
int amari = 0;
int happy = 0;
if (x == 0) {
cout << 0;
return 0;
}
int z = x / 500;
happy += (1000 * z);
int y;
if (z != 0) {
y = (x % (500 * z)) / 5;
} else {
y = x / 5;
}
happy += (5 * y);
cout << happy;
} | replace | 31 | 32 | 31 | 37 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define fi first
#define se second
#define int long long
#define pb push_back
#define emp emplace_back
#define vv(x) vector<x>
#define mp(x, y) map<x, y>
#define dq(x) deque<x>
#define pql(x) priority_queue<x>
#define pqs(x) priority_queue<x, vv(x), greater<x>>
#define mod 1000000007
#define forf(i, a, b) for (int i = a; i < b; i++)
#define it(x) x::iterator
#define ll long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
for (long blockTime = 0; \
(blockTime == 0 ? (blockTime = clock()) != 0 : false); \
debug("%s time : %.4fs", d, \
(double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii vector<int>
#define big 2e18
#define sm -1e9
#define mkr make_pair
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define rng 500005
#define sz(x) (int)x.size()
#define rv(x) reverse(x.begin(), x.end())
#define out(x) cout << x.fi << " " << x.se << endl;
#define ordered_set \
tree<pii, null_type, less<pii>, rb_tree_tag, \
tree_order_statistics_node_update>
void pr_init() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
void solve() {
int x;
cin >> x;
int an = (x / 500) * 1000 + ((x % 500) / 5) * 5;
cout << an << endl;
}
int32_t main() {
pr_init();
fastio;
auto start = high_resolution_clock::now();
solve();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
// cout << "Time taken by function: "
// << duration.count() << " microseconds" << endl;
}
| #include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define fi first
#define se second
#define int long long
#define pb push_back
#define emp emplace_back
#define vv(x) vector<x>
#define mp(x, y) map<x, y>
#define dq(x) deque<x>
#define pql(x) priority_queue<x>
#define pqs(x) priority_queue<x, vv(x), greater<x>>
#define mod 1000000007
#define forf(i, a, b) for (int i = a; i < b; i++)
#define it(x) x::iterator
#define ll long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
for (long blockTime = 0; \
(blockTime == 0 ? (blockTime = clock()) != 0 : false); \
debug("%s time : %.4fs", d, \
(double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii vector<int>
#define big 2e18
#define sm -1e9
#define mkr make_pair
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define rng 500005
#define sz(x) (int)x.size()
#define rv(x) reverse(x.begin(), x.end())
#define out(x) cout << x.fi << " " << x.se << endl;
#define ordered_set \
tree<pii, null_type, less<pii>, rb_tree_tag, \
tree_order_statistics_node_update>
void pr_init() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
void solve() {
int x;
cin >> x;
int an = (x / 500) * 1000 + ((x % 500) / 5) * 5;
cout << an << endl;
}
int32_t main() {
// pr_init();
// fastio;
auto start = high_resolution_clock::now();
solve();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
// cout << "Time taken by function: "
// << duration.count() << " microseconds" << endl;
}
| replace | 64 | 66 | 64 | 66 | 0 | |
p02724 | C++ | Runtime Error | /*Author SHUBH AGRAWAL */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push // adds the value to the last of the queue
#define lld long long int
#define ins insert /// used in set to insert the values
#define adv advance /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(), c.end()
#define PI 3.1415926
// a power n mod p
#define vl vector<long long int>
#define vpl vector<pair<lld, lld>>
#define vvl vector<vector<lld>>
long long int modp(lld a, lld p, lld n) {
int d[100];
int i, j, k, l;
if (n == 0)
return 1;
for (i = 0; n >= 1; i++) {
d[i] = n % 2;
n /= 2;
}
l = i;
long long int e = 1;
if (d[0] == 1)
e *= (a % p);
for (i = 1; i < l; i++) {
a *= a;
a = a % p;
if (d[i] == 1) {
e *= a;
e = e % p;
}
}
return e % p;
}
lld modInverse(lld n, lld p) { return modp(n, p, p - 2); }
long long int nCrModPFermat(lld n, lld r, lld p) {
// Base case
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
lld fac[n + 1];
fac[0] = 1;
for (lld i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
p;
}
long long int gcd(lld b, lld a) {
if (a < b)
return gcd(a, b);
if (a % b == 0)
return b;
return gcd(a % b, b);
}
lld l, r, mid, ans;
lld n, m, i, j, k, x;
char c;
void solve() {
cin >> n;
ans = (n / 500) * 1000;
n -= (n / 500) * 500;
ans += (n / 5) * 5;
cout << ans;
// cout<<"\n";
}
int main() {
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lld t = 1;
// cin>>t;
while (t--) {
solve();
}
return 0;
} | /*Author SHUBH AGRAWAL */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push // adds the value to the last of the queue
#define lld long long int
#define ins insert /// used in set to insert the values
#define adv advance /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(), c.end()
#define PI 3.1415926
// a power n mod p
#define vl vector<long long int>
#define vpl vector<pair<lld, lld>>
#define vvl vector<vector<lld>>
long long int modp(lld a, lld p, lld n) {
int d[100];
int i, j, k, l;
if (n == 0)
return 1;
for (i = 0; n >= 1; i++) {
d[i] = n % 2;
n /= 2;
}
l = i;
long long int e = 1;
if (d[0] == 1)
e *= (a % p);
for (i = 1; i < l; i++) {
a *= a;
a = a % p;
if (d[i] == 1) {
e *= a;
e = e % p;
}
}
return e % p;
}
lld modInverse(lld n, lld p) { return modp(n, p, p - 2); }
long long int nCrModPFermat(lld n, lld r, lld p) {
// Base case
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
lld fac[n + 1];
fac[0] = 1;
for (lld i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
p;
}
long long int gcd(lld b, lld a) {
if (a < b)
return gcd(a, b);
if (a % b == 0)
return b;
return gcd(a % b, b);
}
lld l, r, mid, ans;
lld n, m, i, j, k, x;
char c;
void solve() {
cin >> n;
ans = (n / 500) * 1000;
n -= (n / 500) * 500;
ans += (n / 5) * 5;
cout << ans;
// cout<<"\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lld t = 1;
// cin>>t;
while (t--) {
solve();
}
return 0;
} | delete | 84 | 90 | 84 | 84 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 998244353
#define INF 1e9
ll power(ll x, ll y, ll m) {
if (y == 0)
return 1;
ll p = power(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
<< "ms\n";
ll n;
cin >> n;
ll ans = (n / 500) * 1000;
ans += ((n % 500) / 5) * 5;
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 998244353
#define INF 1e9
ll power(ll x, ll y, ll m) {
if (y == 0)
return 1;
ll p = power(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
<< "ms\n";
ll n;
cin >> n;
ll ans = (n / 500) * 1000;
ans += ((n % 500) / 5) * 5;
cout << ans;
return 0;
}
| replace | 20 | 24 | 20 | 24 | 0 | Time : 26.83ms
|
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
ll res = 1;
while(b > 0)
{
if(b & 1)
res = (res*a)%M;
a = (a*a)%M;
b = b >> 1;
}
return res;
}*/
/*ll modinv(ll a)
{
return power(a,M - 2);
}*/
/*vector<ll> primes(ll n)
{
bool *sieve = new bool[n + 1];
ll i,j;
vector<ll> v;
for(i = 3; i <= n; i+=2)
sieve[i] = true;
sieve[2] = true;
for(i = 3; i*i <= n; i+=2)
{
if(sieve[i])
for(j = i*i; j <= n; j+=i)
sieve[j] = false;
}
if(n >= 2)
{
v.pb(2);
for(i = 3; i <= n; i+=2)
{
if(sieve[i])
v.pb(i);
}
}
return v;
}*/
/*class graph{
public:
vector<ll> *g;
ll n;
graph(ll v)
{
n = v + 1;
g = new vector<ll> [n];
}
void addegde(ll f,ll s)
{
g[f].pb(s);
g[s].pb(f);
}
void dfs(bool *visited,ll sv)
{
visited[sv] = true;
for(auto x: g[sv])
{
if(!visited[x])
{
dfs(visited,x);
}
}
}
void bfs(ll sv){
queue<ll> q;
bool visited[n] = {};
q.push(sv);
visited[sv] = true;
while(!q.empty())
{
ll node = q.front();
q.pop();
for(auto x : g[node])
{
if(!visited[x])
{
visited[x] = true;
q.push(x);
}
}
}
}
};*/
int main() {
fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll i, j, t;
cin >> t;
i = t / 500;
j = (t - i * 500) / 5;
cout << (i * 1000 + j * 5) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
ll res = 1;
while(b > 0)
{
if(b & 1)
res = (res*a)%M;
a = (a*a)%M;
b = b >> 1;
}
return res;
}*/
/*ll modinv(ll a)
{
return power(a,M - 2);
}*/
/*vector<ll> primes(ll n)
{
bool *sieve = new bool[n + 1];
ll i,j;
vector<ll> v;
for(i = 3; i <= n; i+=2)
sieve[i] = true;
sieve[2] = true;
for(i = 3; i*i <= n; i+=2)
{
if(sieve[i])
for(j = i*i; j <= n; j+=i)
sieve[j] = false;
}
if(n >= 2)
{
v.pb(2);
for(i = 3; i <= n; i+=2)
{
if(sieve[i])
v.pb(i);
}
}
return v;
}*/
/*class graph{
public:
vector<ll> *g;
ll n;
graph(ll v)
{
n = v + 1;
g = new vector<ll> [n];
}
void addegde(ll f,ll s)
{
g[f].pb(s);
g[s].pb(f);
}
void dfs(bool *visited,ll sv)
{
visited[sv] = true;
for(auto x: g[sv])
{
if(!visited[x])
{
dfs(visited,x);
}
}
}
void bfs(ll sv){
queue<ll> q;
bool visited[n] = {};
q.push(sv);
visited[sv] = true;
while(!q.empty())
{
ll node = q.front();
q.pop();
for(auto x : g[node])
{
if(!visited[x])
{
visited[x] = true;
q.push(x);
}
}
}
}
};*/
int main() {
fast;
ll i, j, t;
cin >> t;
i = t / 500;
j = (t - i * 500) / 5;
cout << (i * 1000 + j * 5) << endl;
return 0;
}
| delete | 101 | 105 | 101 | 101 | 0 | |
p02724 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// setbase - cout << setbase (16); cout << 100 << endl; Prints 64
// setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints
// xxx77 setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
// cout.precision(x) cout<<fixed<<val; // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;
#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue<ll>
// #define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout << "Case #" << x << ": ";
#define debug(x) cout << #x << " :" << x << endl;
#define rep(i, n) for (long long i = 0; i < n; i++)
#define f(i, a, b) for (long long i = a; i < b; i++)
#define fd(i, a, b) for (long long i = a; i >= b; i--)
#define sync \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// Handle:cyber_rajat
int main(int argc, char const *argv[]) {
sync;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n;
cin >> n;
ll q = n / 500;
ll rem = n % 500;
ll q1 = rem / 5;
ll rem1 = rem % 5;
cout << q * 1000 + q1 * 5 << endl;
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// setbase - cout << setbase (16); cout << 100 << endl; Prints 64
// setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints
// xxx77 setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
// cout.precision(x) cout<<fixed<<val; // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;
#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue<ll>
// #define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout << "Case #" << x << ": ";
#define debug(x) cout << #x << " :" << x << endl;
#define rep(i, n) for (long long i = 0; i < n; i++)
#define f(i, a, b) for (long long i = a; i < b; i++)
#define fd(i, a, b) for (long long i = a; i >= b; i--)
#define sync \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// Handle:cyber_rajat
int main(int argc, char const *argv[]) {
sync;
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
ll n;
cin >> n;
ll q = n / 500;
ll rem = n % 500;
ll q1 = rem / 5;
ll rem1 = rem % 5;
cout << q * 1000 + q1 * 5 << endl;
return 0;
}
| replace | 58 | 62 | 58 | 62 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long k, n;
cin >> k >> n;
vector<long long> data(n);
for (long long i = 0; i < n; i++) {
cin >> data.at(i);
}
long long a = data.at(n - 1) - data.at(0);
vector<long long> table(1000000, 0);
table.at(a) = 1;
for (long long i = 0; i < n - 1; i++) {
long long sum = k - data.at(i + 1) + data.at(i);
table.at(sum) = 1;
}
for (long long i = 0; i < 1000000; i++) {
if (table.at(i) == 1) {
cout << i << endl;
break;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
int c500 = x / 500;
x = x % 500;
int c5 = x / 5;
cout << c500 * 1000 + c5 * 5 << endl;
}
| replace | 4 | 24 | 4 | 10 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p02724 | C++ | Runtime Error | #include <iostream>
#include <string>
int main(int argc, char *argv[]) {
std::string line;
std::cin >> line;
int money = std::stoi(line);
int moneyTable[6] = {500, 100, 50, 5, 1};
int scoreTable[6] = {1000, 0, 0, 5, 0};
int result = 0;
for (int i = 0; i < 6; i++) {
int div = money / moneyTable[i];
result += div * moneyTable[i];
money -= div * moneyTable[i];
}
std::cout << std::to_string(money) << std::endl;
return 0;
} | #include <iostream>
#include <string>
int main(int argc, char *argv[]) {
std::string line;
std::cin >> line;
int money = std::stoi(line);
int div500 = money / 500;
money -= div500 * 500;
int div5 = money / 5;
money -= div5 * 5;
std::cout << std::to_string((div500 * 1000) + (div5 * 5)) << std::endl;
return 0;
} | replace | 7 | 16 | 7 | 12 | -8 | |
p02724 | C++ | Runtime Error | /*Given an array of n numbers find the largest difference in the
starting and ending indexes of the elements of the all possible
strictly decreasing sub-sequences in the array.
Input: 21, 13, 18, 10, 7, 3, 1
Output : 4
Input: 1, 18, 17, 14, 15, 32, 16
Output: 2 */
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define M 100001
#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define lp(i, a, b) for (i = a; i < b; i++)
#define lpr(i, a, b) for (i = a; i >= b; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
fast;
int i, n;
cin >> n;
int r = 1000 * floor(n / 500);
n -= 500 * (n / 500);
r += 5 * (n / 5);
cout << r << endl;
return 0;
}
| /*Given an array of n numbers find the largest difference in the
starting and ending indexes of the elements of the all possible
strictly decreasing sub-sequences in the array.
Input: 21, 13, 18, 10, 7, 3, 1
Output : 4
Input: 1, 18, 17, 14, 15, 32, 16
Output: 2 */
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define M 100001
#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define lp(i, a, b) for (i = a; i < b; i++)
#define lpr(i, a, b) for (i = a; i >= b; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
int main() {
/*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif*/
fast;
int i, n;
cin >> n;
int r = 1000 * floor(n / 500);
n -= 500 * (n / 500);
r += 5 * (n / 5);
cout << r << endl;
return 0;
}
| replace | 35 | 39 | 35 | 39 | 0 | |
p02724 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int X;
cin >> X;
int A = 0;
while (X -= 500 > 500) {
A += 1000;
}
while (X -= 5 > 0) {
A += 5;
}
cout << A << endl;
} | #include <iostream>
using namespace std;
int main() {
int X;
cin >> X;
int A = 0;
int c = X / 500;
int d = (X % 500) / 5;
A += c * 1000;
A += d * 5;
cout << A << endl;
} | replace | 6 | 13 | 6 | 10 | TLE | |
p02724 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int x;
cin >> x;
int count500 = x / 500;
int count5 = (x % (500 * count500)) / 5;
int result = count500 * 1000 + count5 * 5;
cout << result << endl;
} | #include <iostream>
using namespace std;
int main() {
int x;
cin >> x;
int count500 = x / 500;
int count5 = (x % 500) / 5;
int result = count500 * 1000 + count5 * 5;
cout << result << endl;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n;
cin >> n;
ll x = n / 500;
n -= x * 500;
ll y = n / 5;
ll ans = 0;
ans += x * 500 * 2;
ans += y * 5;
return ans;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n;
cin >> n;
ll x = n / 500;
n -= x * 500;
ll y = n / 5;
ll ans = 0;
ans += x * 500 * 2;
ans += y * 5;
cout << ans;
return 0;
} | replace | 13 | 14 | 13 | 15 | 228 | |
p02724 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void solve() {
ll ans = 0;
ll n;
cin >> n;
while (n > 0) {
if (n >= 500) {
ans += 1000;
n -= 500;
} else if (n >= 5) {
ans += 5;
n -= 5;
}
}
cout << ans << endl;
}
int main() {
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void solve() {
ll ans = 0;
ll n;
cin >> n;
ans = (1ll * 1000 * (n / 500)) + (1ll * 5 * ((n % 500) / 5));
cout << ans << endl;
}
int main() {
solve();
return 0;
}
| replace | 10 | 19 | 10 | 11 | TLE | |
p02724 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, h = 0;
cin >> x;
if (x < 5) {
cout << h << endl;
} else {
while (x >= 5) {
if (x > 500) {
h = h + (x / 500) * 1000;
} else if (x > 5) {
h = h + (x / 5) * 5;
}
}
cout << h << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, h = 0;
cin >> x;
if (x < 5) {
cout << h << endl;
} else {
h = h + (x / 500) * 1000;
x = x % 500;
h = h + (x / 5) * 5;
cout << h << endl;
}
return 0;
} | replace | 8 | 17 | 8 | 11 | TLE | |
p02724 | C++ | Runtime Error | /*
NO
TIME
TO
DIE
--007
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod = 998244353;
#define OS // single input use oeis
lli INF = 1e17;
lli eps = 1e-8;
#define IO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n) // no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n) // no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n) // no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n) // index of first one bit!!
typedef pair<lli, lli> ll;
#define mem1(a, x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a, x) fill(&a[0][0], &a[0][0] + sizeof(a) / sizeof(a[0][0]), x)
#define mem3(a, x) \
fill(&a[0][0][0], &a[0][0][0] + sizeof(a) / sizeof(a[0][0][0]), x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y - x) >> (31)) & (x ^ y)) ^ y; }
int fmi(int x, int y) { return (((y - x) >> (31)) & (x ^ y)) ^ x; }
typedef tree<lli, null_type, less<lli>, rb_tree_tag,
tree_order_statistics_node_update>
ost;
lli n, z, k, x, m, d, y, q, b, c;
const double pi = 3.14159265358979323846;
// double dp[100005];
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
IO;
OS;
cin >> n;
lli val = n / 500ll;
n = n - val * 500;
val = val * 1000ll;
val += (n / 5) * 5;
cout << val;
} | /*
NO
TIME
TO
DIE
--007
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod = 998244353;
#define OS // single input use oeis
lli INF = 1e17;
lli eps = 1e-8;
#define IO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n) // no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n) // no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n) // no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n) // index of first one bit!!
typedef pair<lli, lli> ll;
#define mem1(a, x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a, x) fill(&a[0][0], &a[0][0] + sizeof(a) / sizeof(a[0][0]), x)
#define mem3(a, x) \
fill(&a[0][0][0], &a[0][0][0] + sizeof(a) / sizeof(a[0][0][0]), x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y - x) >> (31)) & (x ^ y)) ^ y; }
int fmi(int x, int y) { return (((y - x) >> (31)) & (x ^ y)) ^ x; }
typedef tree<lli, null_type, less<lli>, rb_tree_tag,
tree_order_statistics_node_update>
ost;
lli n, z, k, x, m, d, y, q, b, c;
const double pi = 3.14159265358979323846;
// double dp[100005];
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main() {
IO;
OS;
cin >> n;
lli val = n / 500ll;
n = n - val * 500;
val = val * 1000ll;
val += (n / 5) * 5;
cout << val;
} | replace | 48 | 52 | 48 | 49 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define mod 1000000007
// int max(int a, int b, int c){ if(a>b){if(a>c) return a; else return
// c;}else{if(b>c)return b;else return c;}}
int power(int a, int b) {
int res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
}
return res;
}
int32_t main() {
IOS;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
int ans = 0;
while (n >= 500) {
n -= 500;
ans += 1000;
}
while (n >= 5) {
n -= 5;
ans += 5;
}
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ans = 0;
while (n >= 500) {
n -= 500;
ans += 1000;
}
while (n >= 5) {
n -= 5;
ans += 5;
}
cout << ans;
return 0;
} | replace | 2 | 32 | 2 | 3 | TLE | |
p02724 | C++ | Runtime Error | /**
* ATCODER 160 B
* Kartikeya (doomsday861)
**/
#include <bits/stdc++.h>
#include <time.h>
#define ll long long
#define testcase \
ll t; \
cin >> t; \
while (t--)
#define timeb auto start = high_resolution_clock::now();
#define timee \
auto stop = high_resolution_clock::now(); \
auto duration = duration_cast<seconds>(stop - start); \
cout << "Time taken by function: " << duration.count() << "seconds" << endl;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("output.ans", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
using namespace std::chrono;
// timeb
ll x;
cin >> x;
ll h = 0;
ll n = x / 500;
h += n * 1000;
x %= 500;
// cout<<x<<endl;
while (x > 5) {
ll d = x / 5;
h += d * 5;
x %= 5;
}
cout << h << endl;
// timee
return 0;
} | /**
* ATCODER 160 B
* Kartikeya (doomsday861)
**/
#include <bits/stdc++.h>
#include <time.h>
#define ll long long
#define testcase \
ll t; \
cin >> t; \
while (t--)
#define timeb auto start = high_resolution_clock::now();
#define timee \
auto stop = high_resolution_clock::now(); \
auto duration = duration_cast<seconds>(stop - start); \
cout << "Time taken by function: " << duration.count() << "seconds" << endl;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
using namespace std::chrono;
// timeb
ll x;
cin >> x;
ll h = 0;
ll n = x / 500;
h += n * 1000;
x %= 500;
// cout<<x<<endl;
while (x > 5) {
ll d = x / 5;
h += d * 5;
x %= 5;
}
cout << h << endl;
// timee
return 0;
} | delete | 18 | 22 | 18 | 18 | 0 | |
p02724 | C++ | Runtime Error | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define test(t) \
ll int t; \
cin >> t; \
while (t--)
#define F(i, L, R) for (ll int i = L; i < R; i++)
#define F2(i, L, R) for (ll int i = L; i >= R; i--)
#define get1(a) \
ll int a; \
cin >> a;
#define get2(a, b) \
ll int a, b; \
cin >> a >> b;
#define get3(a, b, c) \
ll int a, b, c; \
cin >> a >> b >> c;
#define pb push_back
#define mp make_pair
#define MAX 1000000001
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
get1(a);
cout << (1000 * (a / 500) + 5 * ((a % 500) / 5));
return 0;
} | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define test(t) \
ll int t; \
cin >> t; \
while (t--)
#define F(i, L, R) for (ll int i = L; i < R; i++)
#define F2(i, L, R) for (ll int i = L; i >= R; i--)
#define get1(a) \
ll int a; \
cin >> a;
#define get2(a, b) \
ll int a, b; \
cin >> a >> b;
#define get3(a, b, c) \
ll int a, b, c; \
cin >> a >> b >> c;
#define pb push_back
#define mp make_pair
#define MAX 1000000001
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
get1(a);
cout << (1000 * (a / 500) + 5 * ((a % 500) / 5));
return 0;
}
| delete | 29 | 34 | 29 | 29 | 0 | |
p02724 | C++ | Time Limit Exceeded | #include <stdio.h>
int main(void) {
int money;
int kind = 0;
do {
scanf("%d", &money);
} while (money <= 0 || money >= 1000000000);
while (money >= 500) {
kind += 1000;
money -= 500;
}
while (money >= 5) {
kind += 5;
money -= 5;
}
printf("%d\n", kind);
return 0;
} | #include <stdio.h>
int main(void) {
int money;
int kind = 0;
do {
scanf("%d", &money);
} while (money < 0 || money > 1000000000);
while (money >= 500) {
kind += 1000;
money -= 500;
}
while (money >= 5) {
kind += 5;
money -= 5;
}
printf("%d\n", kind);
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p02724 | C++ | Runtime Error | /*
KUNAL RAUT (ZUKONIT14) :- "DO WHAT YOU LIKE!"
-PICT,PUNE! :)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 100005
#define N 1000001
#define MAX2N 1 * 1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed << setprecision(n)
#define forci(p, n) for (ll i = p; i < (ll)n; i++)
#define forcj(p, n) for (ll j = p; j < (ll)n; j++)
#define bolt \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test \
ll t; \
cin >> t; \
for (ll testi = 1; testi <= t; testi++)
ll zero = 0;
ll one = 1;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b) * b); }
ll expo(ll x, ll y) {
ll res = 1;
x = x % mod;
while (y > 0) {
if (y & 1)
res = (1ll * res * x) % mod;
y = y >> 1;
x = (1ll * x * x) % mod;
}
return res;
}
ll ncr(ll n, ll r) {
ll res = 1;
if (r > n - r)
r = n - r;
for (ll i = 0; i < r; i++) {
res *= n - i;
res /= i + 1;
}
return res;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }
bool prime(ll n) {
ll i;
for (i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return true;
}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) {
if (a.second == b.second)
return a.first < b.first;
return (a.second < b.second);
}
// https://www.youtube.com/watch?v=WTJSt4wP2ME
ll rr[] = {
0, 1, 1, 1, 0, -1, -1, -1,
};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll a[MAXN], ans[MAXN];
signed main() {
bolt;
#ifndef ONLINE_JUDGE
freopen("input00.txt", "r", stdin);
freopen("output00.txt", "w", stdout);
#endif
ll x;
cin >> x;
ll ans = 0;
ans += 1000 * (x / 500);
x %= 500;
ans += (5 * (x / 5));
cout << ans;
}
| /*
KUNAL RAUT (ZUKONIT14) :- "DO WHAT YOU LIKE!"
-PICT,PUNE! :)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 100005
#define N 1000001
#define MAX2N 1 * 1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed << setprecision(n)
#define forci(p, n) for (ll i = p; i < (ll)n; i++)
#define forcj(p, n) for (ll j = p; j < (ll)n; j++)
#define bolt \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test \
ll t; \
cin >> t; \
for (ll testi = 1; testi <= t; testi++)
ll zero = 0;
ll one = 1;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b) * b); }
ll expo(ll x, ll y) {
ll res = 1;
x = x % mod;
while (y > 0) {
if (y & 1)
res = (1ll * res * x) % mod;
y = y >> 1;
x = (1ll * x * x) % mod;
}
return res;
}
ll ncr(ll n, ll r) {
ll res = 1;
if (r > n - r)
r = n - r;
for (ll i = 0; i < r; i++) {
res *= n - i;
res /= i + 1;
}
return res;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }
bool prime(ll n) {
ll i;
for (i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return true;
}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) {
if (a.second == b.second)
return a.first < b.first;
return (a.second < b.second);
}
// https://www.youtube.com/watch?v=WTJSt4wP2ME
ll rr[] = {
0, 1, 1, 1, 0, -1, -1, -1,
};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll a[MAXN], ans[MAXN];
signed main() {
bolt;
// #ifndef ONLINE_JUDGE
// freopen("input00.txt", "r", stdin);
// freopen("output00.txt", "w", stdout);
// #endif
ll x;
cin >> x;
ll ans = 0;
ans += 1000 * (x / 500);
x %= 500;
ans += (5 * (x / 5));
cout << ans;
}
| replace | 87 | 91 | 87 | 91 | 0 | |
p02724 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
int y = 0;
y = 1000 * (x / 500) + 5 * ((x % 500) / 5);
cout << y << endl;
return y;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
int y = 0;
y = 1000 * (x / 500) + 5 * ((x % 500) / 5);
cout << y << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 228 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
int A[22000];
cin >> K >> N;
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int rightRes = 0;
int leftRes = 0;
int leftMax = 0;
int rightMax = 0;
for (int i = 0; i < N; ++i) {
if (i == N - 1) {
rightRes += K - A[i] + A[0];
if (K - A[i] + A[0] > rightMax) {
rightMax = K - A[i] + A[0];
}
} else {
rightRes += A[i + 1] - A[i];
if (A[i + 1] - A[i] > rightMax) {
rightMax = A[i + 1] - A[i];
}
}
}
for (int i = 0; i < N; ++i) {
if (i == 0) {
leftRes += K - A[N - 1] + A[0];
if (K - A[N - 1] + A[0] > leftMax) {
leftMax = K - A[N - 1] + A[0];
}
} else {
leftRes += A[i] - A[i - 1];
if (A[i] - A[i - 1] > leftMax) {
leftMax = A[i + 1] - A[i];
}
}
}
rightRes -= rightMax;
leftRes -= leftMax;
if (rightRes > leftRes)
cout << leftRes << endl;
else
cout << rightRes << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
int A[220000];
cin >> K >> N;
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int rightRes = 0;
int leftRes = 0;
int leftMax = 0;
int rightMax = 0;
for (int i = 0; i < N; ++i) {
if (i == N - 1) {
rightRes += K - A[i] + A[0];
if (K - A[i] + A[0] > rightMax) {
rightMax = K - A[i] + A[0];
}
} else {
rightRes += A[i + 1] - A[i];
if (A[i + 1] - A[i] > rightMax) {
rightMax = A[i + 1] - A[i];
}
}
}
for (int i = 0; i < N; ++i) {
if (i == 0) {
leftRes += K - A[N - 1] + A[0];
if (K - A[N - 1] + A[0] > leftMax) {
leftMax = K - A[N - 1] + A[0];
}
} else {
leftRes += A[i] - A[i - 1];
if (A[i] - A[i - 1] > leftMax) {
leftMax = A[i + 1] - A[i];
}
}
}
rightRes -= rightMax;
leftRes -= leftMax;
if (rightRes > leftRes)
cout << leftRes << endl;
else
cout << rightRes << endl;
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for (ll i = 0; i < n; i++)
#define rep2(n) for (ll j = 0; j < n; ++j)
#define repd(n) for (ll i = n - 1; i >= 0; i--)
#define MOD 1000000007
#define pii pair<ll, ll>
#define vll vector<ll>
#define ff first
#define ss second
typedef vector<vector<ll>> mat;
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size()
void solve() {
ll n, k;
cin >> n >> k;
vll a(k);
rep(k) cin >> a[i];
sort(a.begin(), a.end());
rep(k) {
if (a[i] > n / 2 + a[0])
a[i] -= n;
}
sort(a.begin(), a.end());
ll mid = a[k / 2];
ll s = 0;
for (ll i = mid; i < k - 1; ++i)
s = s + a[i + 1] - a[i];
for (ll i = mid; i > 0; --i)
s = s + a[i] - a[i - 1];
cout << s;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t = 1;
// cin>>t;
rep(t) { solve(); }
return 0;
} | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for (ll i = 0; i < n; i++)
#define rep2(n) for (ll j = 0; j < n; ++j)
#define repd(n) for (ll i = n - 1; i >= 0; i--)
#define MOD 1000000007
#define pii pair<ll, ll>
#define vll vector<ll>
#define ff first
#define ss second
typedef vector<vector<ll>> mat;
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size()
void solve() {
ll n, k;
cin >> k >> n;
ll a[n];
rep(n) cin >> a[i];
sort(a, a + n);
ll mx = -1;
rep(n - 1) { mx = max(mx, a[i + 1] - a[i]); }
cout << k - max(mx, a[0] - a[n - 1] + k);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t = 1;
// cin>>t;
rep(t) { solve(); }
return 0;
} | replace | 25 | 41 | 25 | 32 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e5 + 5;
ll a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen(".INP", "r")) {
freopen(".INP", "r", stdin);
freopen(".OUT", "w", stdout);
}
ll k, n;
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
a[0] = a[n] - k;
ll ans = k;
for (int i = 1; i <= n; i++) {
ans = min(ans, k - (a[i] - a[i - 1]));
}
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen(".INP", "r")) {
freopen(".INP", "r", stdin);
freopen(".OUT", "w", stdout);
}
ll k, n;
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
a[0] = a[n] - k;
ll ans = k;
for (int i = 1; i <= n; i++) {
ans = min(ans, k - (a[i] - a[i - 1]));
}
cout << ans;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Runtime Error | /*
* @Author: Kaizyn
* @Date: 2020-03-28 21:12:21
* @LastEditTime: 2020-03-28 21:16:53
*/
#include <bits/stdc++.h>
// #define DEBUG
using namespace std;
const int N = 1e5 + 7;
const int MOD = 998244353;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;
int n, k;
int a[N];
inline void solve() {
cin >> k >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
int res = a[1] - a[n] + k;
for (int i = 1; i < n; ++i)
res = max(res, a[i + 1] - a[i]);
cout << k - res << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int testcase = 1;
// cin >> testcase;
for (int i = 1; i <= testcase; ++i) {
solve();
}
return 0;
} | /*
* @Author: Kaizyn
* @Date: 2020-03-28 21:12:21
* @LastEditTime: 2020-03-28 21:16:53
*/
#include <bits/stdc++.h>
// #define DEBUG
using namespace std;
const int N = 2e5 + 7;
const int MOD = 998244353;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;
int n, k;
int a[N];
inline void solve() {
cin >> k >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
int res = a[1] - a[n] + k;
for (int i = 1; i < n; ++i)
res = max(res, a[i + 1] - a[i]);
cout << k - res << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int testcase = 1;
// cin >> testcase;
for (int i = 1; i <= testcase; ++i) {
solve();
}
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02725 | C++ | Runtime Error | // Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) \
{ \
cerr << "\033[32;1m" << #x << " -> "; \
err(x); \
}
void err() { cerr << "\033[39;0m" << endl; }
template <typename T, typename... A> void err(T a, A... x) {
cerr << a << ' ';
err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) ((int)x.size())
typedef long long LL;
const int N = 1e5 + 50;
int n, a[N], k;
int main(int argc, char const *argv[]) {
// code
scanf("%d%d", &n, &k);
for (int i = 0; i < k; ++i) {
scanf("%d", &a[i]);
}
int mx = 0;
a[k] = n + a[0];
for (int i = 0; i < k; ++i)
mx = max(mx, a[i + 1] - a[i]);
cout << n - mx << endl;
return 0;
}
| // Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) \
{ \
cerr << "\033[32;1m" << #x << " -> "; \
err(x); \
}
void err() { cerr << "\033[39;0m" << endl; }
template <typename T, typename... A> void err(T a, A... x) {
cerr << a << ' ';
err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) ((int)x.size())
typedef long long LL;
const int N = 2e5 + 50;
int n, a[N], k;
int main(int argc, char const *argv[]) {
// code
scanf("%d%d", &n, &k);
for (int i = 0; i < k; ++i) {
scanf("%d", &a[i]);
}
int mx = 0;
a[k] = n + a[0];
for (int i = 0; i < k; ++i)
mx = max(mx, a[i + 1] - a[i]);
cout << n - mx << endl;
return 0;
}
| replace | 23 | 24 | 23 | 24 | 0 | |
p02725 | C++ | Runtime Error | /*
Hey there stalker....
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
Like what you see?
*/
#include <algorithm>
#include <bits/stdc++.h>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb push_back
#define pii pair<ll, ll>
#define vi vector<ll>
#define present(container, element) \
(container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) \
(find(all(container), element) != container.end()) /* For vectors */
#define all(a) (a).begin(), (a).end()
#define invect(data, n, commands) \
for (int i = 0; i < n; i++) { \
int tmp; \
cin >> tmp; \
data.pb(tmp); \
commands \
}
#define inset(data, n, commands) \
for (int i = 0; i < n; i++) { \
int tmp; \
cin >> tmp; \
data.I(tmp); \
commands \
}
#define F first
#define S second
#define I insert
#define sz(x) (ll) x.size()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define trav(a, x) for (auto &a : x)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define mp make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/* For Debugging */
#define DEBUG cerr << "\n>>>I'm Here<<<\n" << endl;
#define display(x) \
trav(a, x) cout << a << " "; \
cout << endl;
#define what_is(x) cerr << #x << " is " << x << endl;
int32_t main() {
IOS
int TESTS;
cin >> TESTS;
while (TESTS--) {
ll k, n;
cin >> k >> n;
vi v(n);
rep(i, 0, n) { cin >> v[i]; }
ll ans = v[n - 1] - v[0];
for (int i = 0; i < n - 1; i++) {
ans = min(ans, k - (v[i + 1] - v[i]));
}
cout << ans << endl;
}
return 0;
}
| /*
Hey there stalker....
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
Like what you see?
*/
#include <algorithm>
#include <bits/stdc++.h>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb push_back
#define pii pair<ll, ll>
#define vi vector<ll>
#define present(container, element) \
(container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) \
(find(all(container), element) != container.end()) /* For vectors */
#define all(a) (a).begin(), (a).end()
#define invect(data, n, commands) \
for (int i = 0; i < n; i++) { \
int tmp; \
cin >> tmp; \
data.pb(tmp); \
commands \
}
#define inset(data, n, commands) \
for (int i = 0; i < n; i++) { \
int tmp; \
cin >> tmp; \
data.I(tmp); \
commands \
}
#define F first
#define S second
#define I insert
#define sz(x) (ll) x.size()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define trav(a, x) for (auto &a : x)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define mp make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/* For Debugging */
#define DEBUG cerr << "\n>>>I'm Here<<<\n" << endl;
#define display(x) \
trav(a, x) cout << a << " "; \
cout << endl;
#define what_is(x) cerr << #x << " is " << x << endl;
int32_t main() {
IOS
int TESTS = 1;
// cin >> TESTS;
while (TESTS--) {
ll k, n;
cin >> k >> n;
vi v(n);
rep(i, 0, n) { cin >> v[i]; }
ll ans = v[n - 1] - v[0];
for (int i = 0; i < n - 1; i++) {
ans = min(ans, k - (v[i + 1] - v[i]));
}
cout << ans << endl;
}
return 0;
}
| replace | 83 | 85 | 83 | 85 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define lb long double
const int N = 1e4 + 10;
const int mod = 10086;
const int mod2 = 19260811;
void read(int &a) {
a = 0;
int d = 1;
char ch;
while (ch = getchar(), ch > '9' || ch < '0')
if (ch == '-')
d = -1;
a = ch ^ 48;
while (ch = getchar(), ch >= '0' && ch <= '9')
a = (a << 3) + (a << 1) + (ch ^ 48);
a *= d;
}
int a[N];
int main() {
int k, n;
read(k), read(n);
for (re int i = 1; i <= n; i++)
read(a[i]);
int maxn = a[1] + k - a[n];
for (re int i = 2; i <= n; i++)
maxn = max(maxn, a[i] - a[i - 1]);
printf("%d\n", k - maxn);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define lb long double
const int N = 1e6 + 10;
const int mod = 10086;
const int mod2 = 19260811;
void read(int &a) {
a = 0;
int d = 1;
char ch;
while (ch = getchar(), ch > '9' || ch < '0')
if (ch == '-')
d = -1;
a = ch ^ 48;
while (ch = getchar(), ch >= '0' && ch <= '9')
a = (a << 3) + (a << 1) + (ch ^ 48);
a *= d;
}
int a[N];
int main() {
int k, n;
read(k), read(n);
for (re int i = 1; i <= n; i++)
read(a[i]);
int maxn = a[1] + k - a[n];
for (re int i = 2; i <= n; i++)
maxn = max(maxn, a[i] - a[i - 1]);
printf("%d\n", k - maxn);
return 0;
} | replace | 10 | 11 | 10 | 11 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 0x3f3f3f3f;
const int N = 100000 + 5;
int a[N], b[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int k, n;
cin >> k >> n;
int maxn = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (maxn < a[i] - a[i - 1])
maxn = a[i] - a[i - 1];
}
int z = k + a[1] - a[n];
if (z > maxn)
maxn = z;
cout << k - maxn << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 0x3f3f3f3f;
const int N = 200000 + 5;
int a[N], b[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int k, n;
cin >> k >> n;
int maxn = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (maxn < a[i] - a[i - 1])
maxn = a[i] - a[i - 1];
}
int z = k + a[1] - a[n];
if (z > maxn)
maxn = z;
cout << k - maxn << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define fo(i, N) for (i = 0; i < N; ++i)
#define fos(i, b, N) for (i = b; i < N; ++i)
#define forr(i, N) for (i = N - 1; i >= 0; --i)
#define disp(n) cout << n << endl;
#define M 10000007
#define ll long long
#define vll vector<long long int>
#define min(x, y) (x < y ? x : y)
#define max(x, y) (x > y ? x : y)
using namespace std;
int main() {
long a, n;
cin >> a >> n;
long N[1000], max = 0;
int i;
for (i = 0; i < n; ++i)
cin >> N[i];
for (i = 1; i < n; ++i) {
if (N[i] - N[i - 1] > max)
max = N[i] - N[i - 1];
}
if (a - N[n - 1] + N[0] > max)
max = a - N[n - 1] + N[0];
cout << a - max;
return 0;
} | #include <bits/stdc++.h>
#define fo(i, N) for (i = 0; i < N; ++i)
#define fos(i, b, N) for (i = b; i < N; ++i)
#define forr(i, N) for (i = N - 1; i >= 0; --i)
#define disp(n) cout << n << endl;
#define M 10000007
#define ll long long
#define vll vector<long long int>
#define min(x, y) (x < y ? x : y)
#define max(x, y) (x > y ? x : y)
using namespace std;
int main() {
long a, n;
cin >> a >> n;
long N[n], max = 0;
int i;
for (i = 0; i < n; ++i)
cin >> N[i];
for (i = 1; i < n; ++i) {
if (N[i] - N[i - 1] > max)
max = N[i] - N[i - 1];
}
if (a - N[n - 1] + N[0] > max)
max = a - N[n - 1] + N[0];
cout << a - max;
return 0;
} | replace | 14 | 15 | 14 | 15 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int k, n, i, saidai = 0;
cin >> k >> n;
int a[i];
cin >> a[0];
for (i = 1; i < n; i++) {
cin >> a[i];
saidai = max(saidai, a[i] - a[i - 1]);
}
saidai = max(saidai, a[0] + k - a[n - 1]);
k -= saidai;
cout << k;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int k, n, i, saidai = 0;
cin >> k >> n;
int a[n];
cin >> a[0];
for (i = 1; i < n; i++) {
cin >> a[i];
saidai = max(saidai, a[i] - a[i - 1]);
}
saidai = max(saidai, a[0] + k - a[n - 1]);
k -= saidai;
cout << k;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Runtime Error | // fahadmd16(IIEST Shibpur)
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i, a, b) for (ll i = a; i < b; i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x) cout << #x << ": " << x << endl
#define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) \
cout << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \
<< z << endl
#define trace4(a, b, c, d) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \
<< #f << ": " << f << endl
#define trace(v) \
for (auto it = v.begin(); it != v.end(); it++) \
cout << *it << " "; \
cout << endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9 + 7;
typedef vector<ll> VL;
typedef vector<pll> VLL;
typedef vector<vector<ll>> VVL;
ll power(ll n, ll k, ll m) {
ll ans = 1;
while (k) {
if (k & 1)
ans = (ans * n) % m;
k /= 2;
n = (n * n) % m;
}
return ans;
}
int main() {
IOS;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll T = 1; // cin>>T;
while (T--) {
ll k, n;
cin >> k >> n;
ll a[n];
forn(i, n) cin >> a[i];
sort(a, a + n);
vector<ll> v;
forn1(i, n) { v.pb(a[i] - a[i - 1]); }
v.pb(a[0] + k - a[n - 1]);
sort(ALL(v));
ll ans = 0;
forn(i, n - 1) ans += v[i];
cout << ans << endl;
}
return 0;
}
| // fahadmd16(IIEST Shibpur)
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i, a, b) for (ll i = a; i < b; i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x) cout << #x << ": " << x << endl
#define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) \
cout << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \
<< z << endl
#define trace4(a, b, c, d) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) \
cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \
<< c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \
<< #f << ": " << f << endl
#define trace(v) \
for (auto it = v.begin(); it != v.end(); it++) \
cout << *it << " "; \
cout << endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9 + 7;
typedef vector<ll> VL;
typedef vector<pll> VLL;
typedef vector<vector<ll>> VVL;
ll power(ll n, ll k, ll m) {
ll ans = 1;
while (k) {
if (k & 1)
ans = (ans * n) % m;
k /= 2;
n = (n * n) % m;
}
return ans;
}
int main() {
IOS;
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
ll T = 1; // cin>>T;
while (T--) {
ll k, n;
cin >> k >> n;
ll a[n];
forn(i, n) cin >> a[i];
sort(a, a + n);
vector<ll> v;
forn1(i, n) { v.pb(a[i] - a[i - 1]); }
v.pb(a[0] + k - a[n - 1]);
sort(ALL(v));
ll ans = 0;
forn(i, n - 1) ans += v[i];
cout << ans << endl;
}
return 0;
}
| replace | 65 | 69 | 65 | 69 | -11 | |
p02725 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int k, n;
cin >> k >> n;
vector<int> vec(n);
for (int i = 0; i < n; i++)
cin >> vec.at(i);
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (vec.at(i) < vec.at(j))
swap(vec.at(i), vec.at(j));
}
}
int longer = max(vec.at(1) - vec.at(0), k + vec.at(0) - vec.at(n - 1));
for (int i = 1; i < n - 1; i++)
longer = max(longer, vec.at(i + 1) - vec.at(i));
cout << k - longer;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int k, n;
cin >> k >> n;
vector<int> vec(n);
for (int i = 0; i < n; i++)
cin >> vec.at(i);
sort(vec.begin(), vec.end());
// for(int i=0;i<n;i++)cout<<vec.at(i)<<" ";
/*
for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
if(vec.at(i)<vec.at(j))swap(vec.at(i), vec.at(j));
}
}
*/
int longer = max(vec.at(1) - vec.at(0), k + vec.at(0) - vec.at(n - 1));
for (int i = 1; i < n - 1; i++)
longer = max(longer, vec.at(i + 1) - vec.at(i));
cout << k - longer;
}
| replace | 9 | 16 | 9 | 18 | TLE | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll x = 1e9 + 7;
int main() {
int k, n;
int x = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i == 0)
continue;
x = max(x, a[i] - a[i - 1]);
}
x = max(x, k - a[n - 1] + a[0]);
cout << k - x << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll x = 1e9 + 7;
int main() {
int k, n;
cin >> k >> n;
int x = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i == 0)
continue;
x = max(x, a[i] - a[i - 1]);
}
x = max(x, k - a[n - 1] + a[0]);
cout << k - x << endl;
return 0;
} | insert | 10 | 10 | 10 | 11 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
cin >> K, N;
vector<int> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
int l = 0;
for (int i = 0; i < N - 1; i++)
l = max(l, A.at(i + 1) - A.at(i));
cout << min(K - l, A.at(N - 1) - A.at(0)) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
cin >> K >> N;
vector<int> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
int l = 0;
for (int i = 0; i < N - 1; i++)
l = max(l, A.at(i + 1) - A.at(i));
cout << min(K - l, A.at(N - 1) - A.at(0)) << endl;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <array>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <random>
#include <memory>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
// typedef unsigned __int128 HASH;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<double, int> pdi;
typedef pair<long double, int> pdbi;
typedef pair<int, pii> pipii;
typedef pair<ll, pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define rrep2(i, a, b) for (int i = (a); i > b; i--)
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template <class T>
using MINPQ = std::priority_queue<T, vector<T>, greater<T>>; // MINPQ<pii> pq;
template <class T> using MAXPQ = std::priority_queue<T>;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1 << 30;
const ll INFLL = 1LL << 62;
const double EPS = 1e-12;
// const ll mod = 1000000000 + 7;
const ll mod = 998244353;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) \
(0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false
#define stand(B, i) \
(((B >> i) & 1) == 1) ? true : false // Bのi番目のbitが1ならtrue, 0ならfalse
// debug
#define DEBUG
#define DUMPOUT cerr
#ifdef DEBUG
#define dump(...) \
DUMPOUT << #__VA_ARGS__ << " :[" << __FUNCTION__ << ":" << __LINE__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
void dump_func() { DUMPOUT << endl; };
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0)
DUMPOUT << " ";
else
DUMPOUT << ", ";
dump_func(std::move(tail)...);
}
// ostream
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "[";
for (int i = 0; i < vec.size(); i++)
os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
os << "[";
for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
os << "(" << itr->first << ", " << itr->second << ")";
itr++;
if (itr != map_var.end())
os << ", ";
itr--;
}
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
os << "[";
for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
os << *itr;
++itr;
if (itr != set_var.end())
os << ", ";
itr--;
}
os << "]";
return os;
}
int k, n;
int a[100000 + 5];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> k >> n;
rep(i, n) cin >> a[i];
a[n] = k + a[0];
int mx = 0;
rep(i, n) { mx = max(mx, a[i + 1] - a[i]); }
cout << k - mx << endl;
}
| #include <algorithm>
#include <iostream>
#include <array>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <random>
#include <memory>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
// typedef unsigned __int128 HASH;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<double, int> pdi;
typedef pair<long double, int> pdbi;
typedef pair<int, pii> pipii;
typedef pair<ll, pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define rrep2(i, a, b) for (int i = (a); i > b; i--)
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template <class T>
using MINPQ = std::priority_queue<T, vector<T>, greater<T>>; // MINPQ<pii> pq;
template <class T> using MAXPQ = std::priority_queue<T>;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1 << 30;
const ll INFLL = 1LL << 62;
const double EPS = 1e-12;
// const ll mod = 1000000000 + 7;
const ll mod = 998244353;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) \
(0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false
#define stand(B, i) \
(((B >> i) & 1) == 1) ? true : false // Bのi番目のbitが1ならtrue, 0ならfalse
// debug
#define DEBUG
#define DUMPOUT cerr
#ifdef DEBUG
#define dump(...) \
DUMPOUT << #__VA_ARGS__ << " :[" << __FUNCTION__ << ":" << __LINE__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
void dump_func() { DUMPOUT << endl; };
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0)
DUMPOUT << " ";
else
DUMPOUT << ", ";
dump_func(std::move(tail)...);
}
// ostream
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "[";
for (int i = 0; i < vec.size(); i++)
os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
os << "[";
for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
os << "(" << itr->first << ", " << itr->second << ")";
itr++;
if (itr != map_var.end())
os << ", ";
itr--;
}
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
os << "[";
for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
os << *itr;
++itr;
if (itr != set_var.end())
os << ", ";
itr--;
}
os << "]";
return os;
}
int k, n;
int a[200000 + 5];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> k >> n;
rep(i, n) cin >> a[i];
a[n] = k + a[0];
int mx = 0;
rep(i, n) { mx = max(mx, a[i + 1] - a[i]); }
cout << k - mx << endl;
}
| replace | 152 | 153 | 152 | 153 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char, int> mpci;
typedef map<int, int> mpii;
typedef map<string, int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(), (s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, p, n) for (int i = p; i <= n; i++)
#define ford(i, p, n) for (int i = n; i >= p; i--)
#define foreach(i, c) \
for (__typeof(c.begin()) i = (c.begin()); i != (c).end(); ++i)
#define zero(a) memset(a, 0, sizeof(a))
#define number(a, num) memeset(a, num, sizeof(a))
#define INF 1e9
/*=====================================================================*/
inline void read(int &x) {
short negative = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
negative = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x *= negative;
}
inline void write(long long x) {
static long long sta[35];
long long top = 0;
do {
sta[top++] = x % 10, x /= 10;
} while (x);
while (top)
putchar(sta[--top] + 48);
puts("");
}
void finish(string s) {
cout << s << endl;
exit(0);
}
string int_to_string(int n) {
string s = "";
while (n) {
int now = n % 10;
s += now + '0';
n /= 10;
}
reverse(s.begin(), s.end());
return s;
}
int string_to_int(string s) {
int n = 0;
rep(i, s.size()) {
n *= 10;
n += s[i] - '0';
}
return n;
}
/*======================================================================*/
ll lcm(int a, int b) { return a / __gcd(a, b) * b; }
bool prime(int n) {
if (n == 0 || n == 1)
return false;
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
const ll power(int n, int k) {
ll t = 1;
rep(i, k) t *= n;
return t;
}
const string turn2(int n) {
string s = "";
while (n != 0) {
s += (char)(n % 2 + '0');
n /= 2;
}
reverse(s.begin(), s.end());
return s;
}
string turn(int n, int k) {
string s = "";
while (n) {
s += (char)(n % k + '0');
n /= k;
}
reverse(s.begin(), s.end());
return s;
}
const string turn16(int n) {
string s = "";
while (n != 0) {
if (n % 16 > 9)
s += (char)('A' + n % 16 - 10);
else
s += (char)('0' + n % 16);
n /= 16;
}
reverse(s.begin(), s.end());
return s;
}
const ll quickpower(int n, int k) {
if (k == 1)
return n;
if (k % 2 == 1)
return n * quickpower(n, k / 2) * quickpower(n, k / 2);
else
return quickpower(n, k / 2) * (quickpower(n, k / 2));
}
/*
void merge(int a[],int left,int mid,int right)
{
int n1=mid-left;
int n2=right-mid;
for(int i=0;i<n1;i++)
{
l[i]=a[i+left];
}
for(int i=0;i<n2;i++)
{
r[i]=a[mid+i];
}
r[n2]=l[n1]=INF;
int i=0;
int j=0;
for(int k=left;k<right;k++)
{
if(l[i]<=r[j])
{
a[k]=l[i++];
}
else
{
a[k]=r[j++];
}
}
}
void mergesort(int a[],int left,int right)
{
if(left+1<right)
{
int mid=(left+right)/2;
mergesort(a,left,mid);
mergesort(a,mid,right);
merge(a,left,mid,right);
}
}
int binsearch(int x,int v[],int n)
{
int low=0,high=n-1;
int mid;
while(low<=high)
{
mid=(low+high)/2;
if(x<v[mid])
high=mid-1;
else
if(x>v[mid])
low=mid+1;
else
return mid+1;
}
return -1;
}
int partition(int a[],int left,int right)
{
int p=a[left];
int i=left;
int j=right+1;
for(;;)
{
while(a[++i]<p)
if(i>=right)
break;
while(a[j--]>p)
if(j<=left)
break;
if(i>=j)
break;
else
swap(a[i],a[j]);
}
if(j>=left)
return j;
swap(a[left],a[j]);
return j;
}
void quicksort(int a[],int left,int right)
{
int q;
while(right>left)
{
q=partition(a,left,right);
if(n-q+1==k)
{
cout<<a[q];
exit(0);
}
quicksort(a,left,q-1);
quicksort(a,q+1,right);
}
}
void dfs(int n)
{
if(use[n])
return;
use[n]=true;
cout<<n<<endl;
for(int i=0;i<v[n].size();i++)
dfs(v[n][i]);
}*/
/*======================================================================*/
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int month[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
int a[200010];
/*======================================================================*/
int main() {
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/
/*====================================================================*/
int n, m;
cin >> n >> m;
rep(i, m) { cin >> a[i]; }
sort(a, a + m);
ll now, maxn = 0, ans = 0;
rep(i, m) {
if (i) {
now = abs(a[i] - a[i - 1]);
ans += now;
maxn = max(maxn, now);
} else {
now = abs(n - a[n - 1] + a[0]);
ans += now;
maxn = max(maxn, now);
}
}
// cout<<ans<<" "<<maxn<<endl;
cout << ans - maxn << endl;
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char, int> mpci;
typedef map<int, int> mpii;
typedef map<string, int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(), (s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, p, n) for (int i = p; i <= n; i++)
#define ford(i, p, n) for (int i = n; i >= p; i--)
#define foreach(i, c) \
for (__typeof(c.begin()) i = (c.begin()); i != (c).end(); ++i)
#define zero(a) memset(a, 0, sizeof(a))
#define number(a, num) memeset(a, num, sizeof(a))
#define INF 1e9
/*=====================================================================*/
inline void read(int &x) {
short negative = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
negative = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x *= negative;
}
inline void write(long long x) {
static long long sta[35];
long long top = 0;
do {
sta[top++] = x % 10, x /= 10;
} while (x);
while (top)
putchar(sta[--top] + 48);
puts("");
}
void finish(string s) {
cout << s << endl;
exit(0);
}
string int_to_string(int n) {
string s = "";
while (n) {
int now = n % 10;
s += now + '0';
n /= 10;
}
reverse(s.begin(), s.end());
return s;
}
int string_to_int(string s) {
int n = 0;
rep(i, s.size()) {
n *= 10;
n += s[i] - '0';
}
return n;
}
/*======================================================================*/
ll lcm(int a, int b) { return a / __gcd(a, b) * b; }
bool prime(int n) {
if (n == 0 || n == 1)
return false;
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
const ll power(int n, int k) {
ll t = 1;
rep(i, k) t *= n;
return t;
}
const string turn2(int n) {
string s = "";
while (n != 0) {
s += (char)(n % 2 + '0');
n /= 2;
}
reverse(s.begin(), s.end());
return s;
}
string turn(int n, int k) {
string s = "";
while (n) {
s += (char)(n % k + '0');
n /= k;
}
reverse(s.begin(), s.end());
return s;
}
const string turn16(int n) {
string s = "";
while (n != 0) {
if (n % 16 > 9)
s += (char)('A' + n % 16 - 10);
else
s += (char)('0' + n % 16);
n /= 16;
}
reverse(s.begin(), s.end());
return s;
}
const ll quickpower(int n, int k) {
if (k == 1)
return n;
if (k % 2 == 1)
return n * quickpower(n, k / 2) * quickpower(n, k / 2);
else
return quickpower(n, k / 2) * (quickpower(n, k / 2));
}
/*
void merge(int a[],int left,int mid,int right)
{
int n1=mid-left;
int n2=right-mid;
for(int i=0;i<n1;i++)
{
l[i]=a[i+left];
}
for(int i=0;i<n2;i++)
{
r[i]=a[mid+i];
}
r[n2]=l[n1]=INF;
int i=0;
int j=0;
for(int k=left;k<right;k++)
{
if(l[i]<=r[j])
{
a[k]=l[i++];
}
else
{
a[k]=r[j++];
}
}
}
void mergesort(int a[],int left,int right)
{
if(left+1<right)
{
int mid=(left+right)/2;
mergesort(a,left,mid);
mergesort(a,mid,right);
merge(a,left,mid,right);
}
}
int binsearch(int x,int v[],int n)
{
int low=0,high=n-1;
int mid;
while(low<=high)
{
mid=(low+high)/2;
if(x<v[mid])
high=mid-1;
else
if(x>v[mid])
low=mid+1;
else
return mid+1;
}
return -1;
}
int partition(int a[],int left,int right)
{
int p=a[left];
int i=left;
int j=right+1;
for(;;)
{
while(a[++i]<p)
if(i>=right)
break;
while(a[j--]>p)
if(j<=left)
break;
if(i>=j)
break;
else
swap(a[i],a[j]);
}
if(j>=left)
return j;
swap(a[left],a[j]);
return j;
}
void quicksort(int a[],int left,int right)
{
int q;
while(right>left)
{
q=partition(a,left,right);
if(n-q+1==k)
{
cout<<a[q];
exit(0);
}
quicksort(a,left,q-1);
quicksort(a,q+1,right);
}
}
void dfs(int n)
{
if(use[n])
return;
use[n]=true;
cout<<n<<endl;
for(int i=0;i<v[n].size();i++)
dfs(v[n][i]);
}*/
/*======================================================================*/
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int month[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
int a[200010];
/*======================================================================*/
int main() {
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/
/*====================================================================*/
int n, m;
cin >> n >> m;
rep(i, m) { cin >> a[i]; }
sort(a, a + m);
ll now, maxn = 0, ans = 0;
rep(i, m) {
if (i) {
now = abs(a[i] - a[i - 1]);
ans += now;
maxn = max(maxn, now);
} else {
now = abs(n - a[m - 1] + a[0]);
ans += now;
maxn = max(maxn, now);
}
}
// cout<<ans<<" "<<maxn<<endl;
cout << ans - maxn << endl;
return 0;
}
| replace | 298 | 299 | 298 | 299 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
#define S second
#define F first
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= i;
res %= mod;
}
return res;
}
int mod_pow(int x, int y, int m) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int k, n, a[100010];
int ma;
signed main() {
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i)
ma = max(ma, a[i] - a[i - 1]);
}
ma = max(ma, k + a[0] - a[n - 1]);
cout << k - ma << endl;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
#define S second
#define F first
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= i;
res %= mod;
}
return res;
}
int mod_pow(int x, int y, int m) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int k, n, a[200010];
int ma;
signed main() {
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i)
ma = max(ma, a[i] - a[i - 1]);
}
ma = max(ma, k + a[0] - a[n - 1]);
cout << k - ma << endl;
}
| replace | 61 | 62 | 61 | 62 | 0 | |
p02725 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
long long int K, N, max, ans;
max = 0;
ans = 0;
cin >> K >> N;
long long int A[20000], B[20001];
for (int i = 0; i < N; i++) {
cin >> A[i];
}
A[N] = A[0] + K;
for (int j = 0; j < N + 1; j++) {
B[j] = A[j + 1] - A[j];
}
for (int k = 0; k < N; k++) {
if (B[k] > max) {
max = B[k];
}
}
for (int l = 0; l < N; l++) {
ans = ans + B[l];
}
ans = ans - max;
cout << ans << endl;
} | #include <iostream>
using namespace std;
int main() {
long long int K, N, max, ans;
max = 0;
ans = 0;
cin >> K >> N;
long long int A[200000], B[200001];
for (int i = 0; i < N; i++) {
cin >> A[i];
}
A[N] = A[0] + K;
for (int j = 0; j < N + 1; j++) {
B[j] = A[j + 1] - A[j];
}
for (int k = 0; k < N; k++) {
if (B[k] > max) {
max = B[k];
}
}
for (int l = 0; l < N; l++) {
ans = ans + B[l];
}
ans = ans - max;
cout << ans << endl;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);
void yes() { printf("yes\n"); }
void no() { printf("no\n"); }
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }
ll K, N, A[int(1e5 + 5)];
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
ll ans = A[0] + K - A[N - 1];
for (int i = 0; i < N; i++) {
ans = max(ans, A[i + 1] - A[i]);
}
cout << K - ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);
void yes() { printf("yes\n"); }
void no() { printf("no\n"); }
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }
ll K, N, A[int(2e5 + 5)];
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
ll ans = A[0] + K - A[N - 1];
for (int i = 0; i < N; i++) {
ans = max(ans, A[i + 1] - A[i]);
}
cout << K - ans << endl;
return 0;
}
| replace | 27 | 28 | 27 | 28 | 0 | |
p02725 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int k, n, a[100005], max, f;
cin >> k >> n;
max = 0;
if (n == 0) {
cout << 0;
return 0;
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i == 1) {
f = a[i];
continue;
}
if (a[i] - a[i - 1] > max)
max = a[i] - a[i - 1];
}
if (a[1] + k - a[n] > max)
max = a[1] + k - a[n];
cout << k - max;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int k, n, a[2000005] = {0}, max, f;
cin >> k >> n;
max = 0;
if (n == 0) {
cout << 0;
return 0;
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i == 1) {
f = a[i];
continue;
}
if (a[i] - a[i - 1] > max)
max = a[i] - a[i - 1];
}
if (a[1] + k - a[n] > max)
max = a[1] + k - a[n];
cout << k - max;
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FOR(a, b, c) for (int a = b; a <= c; ++a)
#define FORW(a, b, c) for (int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
const int N = 3e3 + 100;
const int oo = 1e8;
const int mod = 1e9 + 7;
int n, k, ans;
int a[N];
signed main() {
// freopen("test.inp", "r", stdin);
// freopen("test.out", "w", stdout);
ios_base::sync_with_stdio(false);
cout.tie(0);
cin >> k >> n;
int cur = 0;
FOR(i, 1, n) {
cin >> a[i];
if (i > 1)
cur += a[i] - a[i - 1];
}
ans = cur;
FOR(i, 2, n) {
cur -= (a[i] - a[i - 1]);
if (i == 2)
cur += k - a[n] + a[1];
else
cur += a[i - 1] - a[i - 2];
ans = min(ans, cur);
}
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(a, b, c) for (int a = b; a <= c; ++a)
#define FORW(a, b, c) for (int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
const int N = 2e5 + 100;
const int oo = 1e8;
const int mod = 1e9 + 7;
int n, k, ans;
int a[N];
signed main() {
// freopen("test.inp", "r", stdin);
// freopen("test.out", "w", stdout);
ios_base::sync_with_stdio(false);
cout.tie(0);
cin >> k >> n;
int cur = 0;
FOR(i, 1, n) {
cin >> a[i];
if (i > 1)
cur += a[i] - a[i - 1];
}
ans = cur;
FOR(i, 2, n) {
cur -= (a[i] - a[i - 1]);
if (i == 2)
cur += k - a[n] + a[1];
else
cur += a[i - 1] - a[i - 2];
ans = min(ans, cur);
}
cout << ans;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (ll i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (ll i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)
#define MN 100005
int n, k;
int a[MN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> k >> n;
F0R(i, n) { cin >> a[i]; }
int mxd = 0;
F0R(i, n - 1) { mxd = max(mxd, a[i + 1] - a[i]); }
mxd = max(mxd, a[0] + k - a[n - 1]);
cout << k - mxd << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (ll i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (ll i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)
#define MN 200005
int n, k;
int a[MN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> k >> n;
F0R(i, n) { cin >> a[i]; }
int mxd = 0;
F0R(i, n - 1) { mxd = max(mxd, a[i + 1] - a[i]); }
mxd = max(mxd, a[0] + k - a[n - 1]);
cout << k - mxd << "\n";
return 0;
}
| replace | 21 | 22 | 21 | 22 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
int main() {
int K, N;
cin >> K >> N;
vector<int> A(N);
rep(i, N) { cin >> A[i]; }
vector<int> d(N);
rep(i, N) {
if (i == N - 1) {
d[N - 1] = A[0] + (K - A[N - 1]);
break;
}
d[i] = A[i + i] - A[i];
}
int max = 0;
rep(i, N) {
if (max < d[i])
max = d[i];
}
cout << K - max << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
int main() {
int K, N;
cin >> K >> N;
vector<int> A(N);
rep(i, N) { cin >> A[i]; }
vector<int> d(N);
rep(i, N) {
if (i == N - 1) {
d[N - 1] = A[0] + (K - A[N - 1]);
break;
}
d[i] = A[i + 1] - A[i];
}
int max = 0;
rep(i, N) {
if (max < d[i])
max = d[i];
}
cout << K - max << endl;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, k, i, a[200005], mi, x;
int main() {
scanf("%lld%lld", &k, &n);
for (i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
a[n + i] = a[i] + k;
}
sort(a + 1, a + n * 2 + 1);
mi = k;
for (i = n; i < 2 * n; i++) {
x = a[i] - a[i - n + 1];
if (x < mi)
mi = x;
}
printf("%lld\n", mi);
} | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, k, i, a[500005], mi, x;
int main() {
scanf("%lld%lld", &k, &n);
for (i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
a[n + i] = a[i] + k;
}
sort(a + 1, a + n * 2 + 1);
mi = k;
for (i = n; i < 2 * n; i++) {
x = a[i] - a[i - n + 1];
if (x < mi)
mi = x;
}
printf("%lld\n", mi);
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
int b;
cin >> K, N;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
b = (K - a.at(N - 1)) + a.at(0);
for (int i = 0; i < N - 1; i++) {
b = max(a.at(i + 1) - a.at(i), b);
}
cout << K - b << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
int b;
cin >> K >> N;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
b = (K - a.at(N - 1)) + a.at(0);
for (int i = 0; i < N - 1; i++) {
b = max(a.at(i + 1) - a.at(i), b);
}
cout << K - b << endl;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a, b, c, n, i, j, k, m, t, arr[200005], ar[200005];
int main() {
string s;
cin >> n >> m;
for (i = 0; i < m; i++)
cin >> arr[i];
a = arr[m - 1] - arr[0];
ll minn = arr[0];
for (i = 1; i < n; i++) {
minn = minn > arr[i] - arr[i - 1] ? minn : (arr[i] - arr[i - 1]);
}
a = a < a + arr[0] - minn + n - arr[m - 1]
? a
: (a + arr[0] - minn + n - arr[m - 1]);
cout << a;
}
| #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a, b, c, n, i, j, k, m, t, arr[200005], ar[200005];
int main() {
string s;
cin >> n >> m;
for (i = 0; i < m; i++)
cin >> arr[i];
a = arr[m - 1] - arr[0];
ll minn = arr[0];
for (i = 1; i < m; i++) {
minn = minn > arr[i] - arr[i - 1] ? minn : (arr[i] - arr[i - 1]);
}
a = a < a + arr[0] - minn + n - arr[m - 1]
? a
: (a + arr[0] - minn + n - arr[m - 1]);
cout << a;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/
#ifdef LOCAL
#define dbg(x) cout << #x << " : " << x << endl;
#else
#define dbg(x)
#endif
#define int long long
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto &x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
template <typename T1, typename T2> inline void mine(T1 &x, T2 y) {
if (x > y)
x = y;
}
template <typename T1, typename T2> inline void maxe(T1 &x, T2 y) {
if (x < y)
x = y;
}
ostream &operator<<(ostream &a, const vector<int> &b) {
for (auto k : b)
cout << k << ' ';
return a;
}
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;
const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[MX];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int k, n;
cin >> k >> n;
fi(0, n) {
cin >> a[i];
a[i + n] = a[i] + k;
}
int mn = INF;
fi(0, n) { mine(mn, a[i + n - 1] - a[i]); }
cout << mn << '\n';
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/
#ifdef LOCAL
#define dbg(x) cout << #x << " : " << x << endl;
#else
#define dbg(x)
#endif
#define int long long
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto &x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
template <typename T1, typename T2> inline void mine(T1 &x, T2 y) {
if (x > y)
x = y;
}
template <typename T1, typename T2> inline void maxe(T1 &x, T2 y) {
if (x < y)
x = y;
}
ostream &operator<<(ostream &a, const vector<int> &b) {
for (auto k : b)
cout << k << ' ';
return a;
}
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;
const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 400010;
const double EPS = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[MX];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int k, n;
cin >> k >> n;
fi(0, n) {
cin >> a[i];
a[i + n] = a[i] + k;
}
int mn = INF;
fi(0, n) { mine(mn, a[i + n - 1] - a[i]); }
cout << mn << '\n';
} | replace | 84 | 85 | 84 | 85 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 1e5 + 100;
int a[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
int mx = a[0] - a[n - 1] + k;
for (int i = 0; i < n - 1; i++)
mx = max(mx, a[i + 1] - a[i]);
cout << k - mx;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 2e5 + 100;
int a[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
int mx = a[0] - a[n - 1] + k;
for (int i = 0; i < n - 1; i++)
mx = max(mx, a[i + 1] - a[i]);
cout << k - mx;
}
| replace | 12 | 13 | 12 | 13 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define print(n) cout << n << endl
#define all(n) n.begin(), n.end()
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll k, n;
cin >> k >> n;
vector<ll> a(n + 1);
rep(i, n) cin >> a[i];
a[n] = k + a[0];
vector<ll> b(n);
rep(i, n + 1) b[i] = a[i + 1] - a[i];
sort(all(b));
print(accumulate(all(b), 0LL) - b[n - 1]);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define print(n) cout << n << endl
#define all(n) n.begin(), n.end()
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll k, n;
cin >> k >> n;
vector<ll> a(n + 1);
rep(i, n) cin >> a[i];
a[n] = k + a[0];
vector<ll> b(n);
rep(i, n) b[i] = a[i + 1] - a[i];
sort(all(b));
print(accumulate(all(b), 0LL) - b[n - 1]);
return 0;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; ++i) {
cin >> a[i];
}
int ans = n;
for (int i = 2; i <= k; ++i) {
ans = min(ans, n - a[i] + a[i - 1]);
}
ans = min(ans, a[k] - a[1]);
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; ++i) {
cin >> a[i];
}
int ans = n;
for (int i = 2; i <= k; ++i) {
ans = min(ans, n - a[i] + a[i - 1]);
}
ans = min(ans, a[k] - a[1]);
cout << ans << '\n';
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int k, n, a[20000], min;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
min = a[n - 1] - a[0];
for (int i = 0; i < n - 1; i++) {
if (k - (a[i + 1] - a[i]) < min) {
min = k - (a[i + 1] - a[i]);
}
}
cout << min << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int k, n, a[200000], min;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
min = a[n - 1] - a[0];
for (int i = 0; i < n - 1; i++) {
if (k - (a[i + 1] - a[i]) < min) {
min = k - (a[i + 1] - a[i]);
}
}
cout << min << endl;
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
ll K, N;
cin >> K >> N;
vector<ll> vec(N);
for (ll i = 0; i < N; i++) {
ll a;
cin >> a;
vec.at(i) = a;
}
vector<ll> len(3);
for (ll i = 0; i < N - 1; i++) {
len.at(i) = vec.at(i + 1) - vec.at(i);
}
len.at(N - 1) = K - vec.at(N - 1) + vec.at(0);
sort(len.begin(), len.end());
ll ans = 0;
for (ll i = 0; i < N - 1; i++) {
ans += len.at(i);
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
ll K, N;
cin >> K >> N;
vector<ll> vec(N);
for (ll i = 0; i < N; i++) {
ll a;
cin >> a;
vec.at(i) = a;
}
vector<ll> len(N);
for (ll i = 0; i < N - 1; i++) {
len.at(i) = vec.at(i + 1) - vec.at(i);
}
len.at(N - 1) = K - vec.at(N - 1) + vec.at(0);
sort(len.begin(), len.end());
ll ans = 0;
for (ll i = 0; i < N - 1; i++) {
ans += len.at(i);
}
cout << ans << endl;
} | replace | 32 | 33 | 32 | 33 | 0 | |
p02725 | C++ | Runtime Error | // #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int n, m;
int a[200001];
int main() {
cin >> n >> m;
int mx = 0;
for (int i = 0; i < m; i++) {
scanf("%d", &a[i]);
}
a[m] = n + a[0];
for (int i = 1; i <= n; i++)
mx = max(a[i] - a[i - 1], mx);
cout << n - mx;
}
| // #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int n, m;
int a[200001];
int main() {
cin >> n >> m;
int mx = 0;
for (int i = 0; i < m; i++) {
scanf("%d", &a[i]);
}
a[m] = n + a[0];
for (int i = 1; i <= m; i++)
mx = max(a[i] - a[i - 1], mx);
cout << n - mx;
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
vector<int> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
int maximumDistance = 0, previous = 0;
for (int i = 0; i < N; i++) {
maximumDistance = max(maximumDistance, abs(v[i] - previous));
previous = v[i];
}
maximumDistance = max(maximumDistance, K - v.back() + v[0]);
cout << K - maximumDistance << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
cin >> K >> N;
vector<int> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
int maximumDistance = 0, previous = 0;
for (int i = 0; i < N; i++) {
maximumDistance = max(maximumDistance, abs(v[i] - previous));
previous = v[i];
}
maximumDistance = max(maximumDistance, K - v.back() + v[0]);
cout << K - maximumDistance << endl;
} | insert | 4 | 4 | 4 | 5 | -6 | terminate called after throwing an instance of 'std::length_error'
what(): cannot create std::vector larger than max_size()
|
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(x) (ll) x.size()
#define F first
#define S second
#define FOR(i, a, b) for (ll i = a; i <= b; ++i)
#define ROF(i, a, b) for (ll i = a; i >= b; --i)
#define trace(x) cerr << #x << ": " << x << '\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set \
tree<TEMP, null_type, less<TEMP>, rb_tree_tag, \
tree_order_statistics_node_update>
auto clk = clock();
ll mexp(ll a, ll b, ll m) {
ll ans = 1;
a %= m;
while (b) {
if (b & 1)
ans = ans * a % m;
b >>= 1;
a = a * a % m;
}
return ans;
}
const int N = 200005;
ll a[N];
int main() {
IOS srand(chrono::high_resolution_clock::now().time_since_epoch().count());
int k, n;
cin >> k >> n;
FOR(i, 1, n) { cin >> a[i]; }
FOR(i, n + 1, 2 * n) { a[i] = k + a[i - n]; }
ll ans = 1e18;
FOR(i, n, 2 * n) { ans = min(ans, a[i] - a[i - n + 1]); }
cout << ans;
cerr << endl
<< endl
<< "Time: " << fixed << setprecision(12)
<< (long double)(clock() - clk) / CLOCKS_PER_SEC << " ms" << endl
<< endl;
return 0;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(x) (ll) x.size()
#define F first
#define S second
#define FOR(i, a, b) for (ll i = a; i <= b; ++i)
#define ROF(i, a, b) for (ll i = a; i >= b; --i)
#define trace(x) cerr << #x << ": " << x << '\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set \
tree<TEMP, null_type, less<TEMP>, rb_tree_tag, \
tree_order_statistics_node_update>
auto clk = clock();
ll mexp(ll a, ll b, ll m) {
ll ans = 1;
a %= m;
while (b) {
if (b & 1)
ans = ans * a % m;
b >>= 1;
a = a * a % m;
}
return ans;
}
const int N = 400005;
ll a[N];
int main() {
IOS srand(chrono::high_resolution_clock::now().time_since_epoch().count());
int k, n;
cin >> k >> n;
FOR(i, 1, n) { cin >> a[i]; }
FOR(i, n + 1, 2 * n) { a[i] = k + a[i - n]; }
ll ans = 1e18;
FOR(i, n, 2 * n) { ans = min(ans, a[i] - a[i - n + 1]); }
cout << ans;
cerr << endl
<< endl
<< "Time: " << fixed << setprecision(12)
<< (long double)(clock() - clk) / CLOCKS_PER_SEC << " ms" << endl
<< endl;
return 0;
} | replace | 39 | 40 | 39 | 40 | 0 |
Time: 0.000180000000 ms
|
p02725 | C++ | Runtime Error | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
int K = 0, N = 0;
int *A = NULL;
int d = 0, D = 0;
cin >> K;
cin >> N;
A = (int *)calloc(N + 1, N);
for (int i = 1; i <= N; i++) {
cin >> A[i];
if (i == 1) {
d = 0;
} else if (i > 1) {
d = A[i] - A[i - 1];
}
if (d > D) {
D = d;
}
}
if (D < K - A[N] + A[1]) {
D = K - A[N] + A[1];
}
printf("%d\n", K - D);
return 0;
} | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
int K = 0, N = 0;
int *A = NULL;
int d = 0, D = 0;
cin >> K;
cin >> N;
A = (int *)calloc(N + 1, sizeof(int));
for (int i = 1; i <= N; i++) {
cin >> A[i];
if (i == 1) {
d = 0;
} else if (i > 1) {
d = A[i] - A[i - 1];
}
if (d > D) {
D = d;
}
}
if (D < K - A[N] + A[1]) {
D = K - A[N] + A[1];
}
printf("%d\n", K - D);
return 0;
} | replace | 16 | 17 | 16 | 17 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
ll a[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll k;
int n;
cin >> k >> n;
rep(i, 1, n) { cin >> a[i]; }
ll Max = 0;
rep(i, 2, n) Max = max(Max, a[i] - a[i - 1]);
Max = max(Max, a[1] + k - a[n]);
cout << k - Max << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
ll a[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll k;
int n;
cin >> k >> n;
rep(i, 1, n) { cin >> a[i]; }
ll Max = 0;
rep(i, 2, n) Max = max(Max, a[i] - a[i - 1]);
Max = max(Max, a[1] + k - a[n]);
cout << k - Max << '\n';
return 0;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02725 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define gcd(m, n) __gcd(m, n)
#define lcm(m, n) m *(n / gcd(m, n))
#define fast \
std::ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << " " << x << endl;
ll power(ll base, ll exp) {
ll res = 1;
while (exp > 0) {
if (exp % 2 == 1)
res = (res * base);
base = (base * base);
exp /= 2;
}
return res;
}
ll mod(ll a, ll b) { return (a % b + b) % b; }
using namespace std;
int main() {
fast;
ll k, n;
cin >> k >> n;
ll arr[n];
for (ll i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
ll fans = LLONG_MAX, ans1, ans2;
for (ll i = 0; i < n; i++) {
ans1 = 0;
ll j = (i + 1) % n;
while (arr[j] != arr[i]) {
ans1 += min(abs(arr[(j) % n] - arr[(j - 1 + n) % n]),
k - abs(arr[(j) % n] - arr[(j - 1 + n) % n]));
j = (j + 1) % n;
}
ans2 = 0;
j = (i - 1 + n) % n;
while (arr[j] != arr[i]) {
ans2 += min(abs(arr[(j) % n] - arr[(j + 1) % n]),
k - abs(arr[(j) % n] - arr[(j + 1) % n]));
j = (j - 1 + n) % n;
}
fans = min(ans1, ans2);
}
cout << fans << endl;
return 0;
} | #include <bits/stdc++.h>
#define gcd(m, n) __gcd(m, n)
#define lcm(m, n) m *(n / gcd(m, n))
#define fast \
std::ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << " " << x << endl;
ll power(ll base, ll exp) {
ll res = 1;
while (exp > 0) {
if (exp % 2 == 1)
res = (res * base);
base = (base * base);
exp /= 2;
}
return res;
}
ll mod(ll a, ll b) { return (a % b + b) % b; }
using namespace std;
int main() {
fast;
ll k, n;
cin >> k >> n;
ll arr[n];
for (ll i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
ll ans = LLONG_MIN;
for (ll i = 1; i < n; i++)
ans = max(ans, arr[i] - arr[i - 1]);
ans = max(ans, (k - arr[n - 1]) + arr[0]);
cout << k - ans << endl;
return 0;
} | replace | 38 | 58 | 38 | 43 | TLE | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
int a[1005], maxn = -1;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n - 1; i++) {
maxn = max(a[i + 1] - a[i], maxn);
}
maxn = max(m + a[0] - a[n - 1], maxn);
cout << m - maxn;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
int a[1000005], maxn = -1;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n - 1; i++) {
maxn = max(a[i + 1] - a[i], maxn);
}
maxn = max(m + a[0] - a[n - 1], maxn);
cout << m - maxn;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int a[100000];
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int x = (k + a[0]) - a[n - 1];
for (int i = 0; i < n - 1; i++) {
x = max(x, a[i + 1] - a[i]);
}
cout << k - x << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a[200000];
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int x = (k + a[0]) - a[n - 1];
for (int i = 0; i < n - 1; i++) {
x = max(x, a[i + 1] - a[i]);
}
cout << k - x << endl;
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int k, n;
int a[N];
int solve() {
scanf("%d %d", &k, &n);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
int ans = a[n - 1] - a[0];
for (int i = 1; i < n; ++i)
ans = min(ans, k - (a[i] - a[i - 1]));
printf("%d\n", ans);
return 0;
}
int main() {
int t = 1;
// scanf("%d", &t);
while (t--)
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int k, n;
int a[N];
int solve() {
scanf("%d %d", &k, &n);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
int ans = a[n - 1] - a[0];
for (int i = 1; i < n; ++i)
ans = min(ans, k - (a[i] - a[i - 1]));
printf("%d\n", ans);
return 0;
}
int main() {
int t = 1;
// scanf("%d", &t);
while (t--)
solve();
return 0;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long k, n, ans = 2000000;
cin >> k >> n;
long long a[300000];
for (int i = 0; i < n; i++) {
int l;
cin >> l;
a[i] = l;
}
for (int i = 0; i < n; i++) {
a[i + n] = a[i] + k;
}
for (int i = 0; i < n; i++) {
ans = min(ans, a[i + n - 1] - a[i]);
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long k, n, ans = 2000000;
cin >> k >> n;
long long a[500000];
for (int i = 0; i < n; i++) {
int l;
cin >> l;
a[i] = l;
}
for (int i = 0; i < n; i++) {
a[i + n] = a[i] + k;
}
for (int i = 0; i < n; i++) {
ans = min(ans, a[i + n - 1] - a[i]);
}
cout << ans << endl;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cerrno>
#include <cfenv>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int K, N;
vector<int> A(2 * 10 ^ 5);
int tmp = 0;
int ans = 0;
int tmpMaxDist = 0;
int edgeDist = 0;
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++) {
cin >> tmp;
A[i] = tmp;
}
for (int i = 1; i < N; i++) {
if (A[i] - A[i - 1] > tmpMaxDist) {
tmpMaxDist = A[i] - A[i - 1];
}
}
edgeDist = (K - A[N - 1]) + A[0];
if (edgeDist > tmpMaxDist) {
ans = K - edgeDist;
} else {
ans = K - tmpMaxDist;
}
cout << ans;
}
| #include <algorithm>
#include <bitset>
#include <cerrno>
#include <cfenv>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int K, N;
vector<int> A(2 * 10 * 10 * 10 * 10 * 10);
int tmp = 0;
int ans = 0;
int tmpMaxDist = 0;
int edgeDist = 0;
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++) {
cin >> tmp;
A[i] = tmp;
}
for (int i = 1; i < N; i++) {
if (A[i] - A[i - 1] > tmpMaxDist) {
tmpMaxDist = A[i] - A[i - 1];
}
}
edgeDist = (K - A[N - 1]) + A[0];
if (edgeDist > tmpMaxDist) {
ans = K - edgeDist;
} else {
ans = K - tmpMaxDist;
}
cout << ans;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 40;
long long a[N], k, mn = 1e18, n;
int main() {
cin >> k >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
if (i == n) {
mn = min(mn, a[n] - a[1]);
} else {
mn = min(mn, k - (a[i + 1] - a[i]));
}
}
cout << mn;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 40;
long long a[N], k, mn = 1e18, n;
int main() {
cin >> k >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
if (i == n) {
mn = min(mn, a[n] - a[1]);
} else {
mn = min(mn, k - (a[i + 1] - a[i]));
}
}
cout << mn;
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int k, n, arr[100005], mini;
int main() {
cin >> k >> n;
for (int i = 0; i < n; ++i)
cin >> arr[i];
mini = arr[n - 1] - arr[0];
for (int i = 1; i < n; ++i) {
int tmp;
tmp = k - arr[i] + arr[i - 1];
mini = min(mini, tmp);
}
cout << mini << "\n";
} | #include <bits/stdc++.h>
using namespace std;
int k, n, arr[200005], mini;
int main() {
cin >> k >> n;
for (int i = 0; i < n; ++i)
cin >> arr[i];
mini = arr[n - 1] - arr[0];
for (int i = 1; i < n; ++i) {
int tmp;
tmp = k - arr[i] + arr[i - 1];
mini = min(mini, tmp);
}
cout << mini << "\n";
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int k, n, a[N], maxn = -1;
int main() {
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
a[n + 1] = k + a[1];
for (int i = 2; i <= n + 1; i++)
maxn = max(maxn, a[i] - a[i - 1]);
cout << k - maxn << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int k, n, a[N], maxn = -1;
int main() {
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
a[n + 1] = k + a[1];
for (int i = 2; i <= n + 1; i++)
maxn = max(maxn, a[i] - a[i - 1]);
cout << k - maxn << endl;
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;
int c[N];
int main() {
int k, n;
scanf("%d %d", &k, &n);
for (int i = 1; i <= n; i++)
scanf("%d", &c[i]);
int ans = c[n] - c[1];
for (int i = 2; i <= n; i++) {
ans = min(ans, k - c[i] + c[i - 1]);
}
printf("%d", ans);
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
int c[N];
int main() {
int k, n;
scanf("%d %d", &k, &n);
for (int i = 1; i <= n; i++)
scanf("%d", &c[i]);
int ans = c[n] - c[1];
for (int i = 2; i <= n; i++) {
ans = min(ans, k - c[i] + c[i - 1]);
}
printf("%d", ans);
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;
int A[100010];
int main() {
int K, N;
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
int ans = mod;
for (int i = 0; i < N; i++) {
if (i == 0) {
ans = min(ans, K - (K - (A[N - 1] - A[i])));
ans = min(ans, K - (A[i + 1] - A[i]));
} else if (i == N - 1) {
ans = min(ans, K - (A[i] - A[i - 1]));
ans = min(ans, K - (K - (A[N - 1] - A[0])));
} else {
ans = min(ans, K - (A[i] - A[i - 1]));
ans = min(ans, K - (A[i + 1] - A[i]));
}
}
cout << ans << endl;
} | #include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;
int A[200010];
int main() {
int K, N;
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
int ans = mod;
for (int i = 0; i < N; i++) {
if (i == 0) {
ans = min(ans, K - (K - (A[N - 1] - A[i])));
ans = min(ans, K - (A[i + 1] - A[i]));
} else if (i == N - 1) {
ans = min(ans, K - (A[i] - A[i - 1]));
ans = min(ans, K - (K - (A[N - 1] - A[0])));
} else {
ans = min(ans, K - (A[i] - A[i - 1]));
ans = min(ans, K - (A[i + 1] - A[i]));
}
}
cout << ans << endl;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(), a.end()
#define mid(a, b) (a + b) / 2
#define pii pair<int, int>
using namespace std;
int k, n, a[N], d[N], mx;
int main() {
scanf("%d%d", &k, &n);
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
d[i] = a[i] - a[i - 1];
mx = max(mx, d[i]);
}
mx = max(mx, k - a[n] + a[1]);
cout << k - mx;
}
| #include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define N 200005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(), a.end()
#define mid(a, b) (a + b) / 2
#define pii pair<int, int>
using namespace std;
int k, n, a[N], d[N], mx;
int main() {
scanf("%d%d", &k, &n);
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
d[i] = a[i] - a[i - 1];
mx = max(mx, d[i]);
}
mx = max(mx, k - a[n] + a[1]);
cout << k - mx;
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, s, f) for (int i = s; i < f; i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int mod_pow(int n, int p, int m) {
if (p == 0)
return 1;
if (p % 2 == 0) {
int t = mod_pow(n, p / 2, m);
return (t * t) % m;
}
return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
int modinv(int a, int m) {
int b = m, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int digit(int x) {
int cnt = 0;
while (x > 0) {
cnt += x % 10;
x /= 10;
}
return cnt;
}
int read() {
int tmp;
cin >> tmp;
return tmp;
}
int xor128() {
static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
int t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
map<int, int> ans;
int now = 2;
while (now * now <= x) {
if (x % now == 0) {
x /= now;
ans[now]++;
} else
now++;
}
if (x != 1)
ans[x]++;
return ans;
}
int comb(int n, int k) {
k = min(k, n - k);
int x = 1, y = 1;
rep(i, k) {
y *= i + 1;
y %= MOD;
}
for (int i = n - k + 1; i <= n; i++) {
x *= i;
x %= MOD;
}
return x * modinv(y, MOD) % MOD;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int k, n;
int a[100005];
int ans = INF;
cin >> k >> n;
rep(i, n) cin >> a[i];
a[n] = k + a[0];
rep(i, n) { chmin(ans, k - (a[i + 1] - a[i])); }
cout << ans << endl;
return 0;
}
| #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, s, f) for (int i = s; i < f; i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int mod_pow(int n, int p, int m) {
if (p == 0)
return 1;
if (p % 2 == 0) {
int t = mod_pow(n, p / 2, m);
return (t * t) % m;
}
return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
int modinv(int a, int m) {
int b = m, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int digit(int x) {
int cnt = 0;
while (x > 0) {
cnt += x % 10;
x /= 10;
}
return cnt;
}
int read() {
int tmp;
cin >> tmp;
return tmp;
}
int xor128() {
static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
int t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
map<int, int> ans;
int now = 2;
while (now * now <= x) {
if (x % now == 0) {
x /= now;
ans[now]++;
} else
now++;
}
if (x != 1)
ans[x]++;
return ans;
}
int comb(int n, int k) {
k = min(k, n - k);
int x = 1, y = 1;
rep(i, k) {
y *= i + 1;
y %= MOD;
}
for (int i = n - k + 1; i <= n; i++) {
x *= i;
x %= MOD;
}
return x * modinv(y, MOD) % MOD;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int k, n;
int a[200005];
int ans = INF;
cin >> k >> n;
rep(i, n) cin >> a[i];
a[n] = k + a[0];
rep(i, n) { chmin(ans, k - (a[i + 1] - a[i])); }
cout << ans << endl;
return 0;
}
| replace | 130 | 131 | 130 | 131 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int a[maxn];
ll t[maxn];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
#ifdef acm
freopen("a.in", "r", stdin);
#endif // acm
int n, k;
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], a[i + n] = a[i];
for (int i = 2; i <= 2 * n; i++) {
t[i] = t[i - 1] + (a[i] - a[i - 1] + k) % k;
}
ll sol = 1LL << 60;
for (int i = n; i <= 2 * n; i++)
sol = min(sol, t[i] - t[i - n + 1]);
cout << sol << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int a[2 * maxn];
ll t[2 * maxn];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
#ifdef acm
freopen("a.in", "r", stdin);
#endif // acm
int n, k;
cin >> k >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], a[i + n] = a[i];
for (int i = 2; i <= 2 * n; i++) {
t[i] = t[i - 1] + (a[i] - a[i - 1] + k) % k;
}
ll sol = 1LL << 60;
for (int i = n; i <= 2 * n; i++)
sol = min(sol, t[i] - t[i - n + 1]);
cout << sol << "\n";
return 0;
}
| replace | 7 | 9 | 7 | 9 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
using namespace std;
lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2) {
return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a) { return (a * (a + 1LL)) / 2; }
char vow[] = {'a', 'e', 'i', 'o', 'u'};
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const int N = 3010;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 74e-9;
lli bp(lli a, lli b = -2LL) {
lli ret = 1;
while (b) {
if (b & 1)
ret *= a, ret %= mod;
a *= a;
a %= mod;
b >>= 1;
}
return ret;
}
int k, n, pat;
int a[N];
int main() {
fastio;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
pat = a[n - 1] - a[0];
for (int i = 1; i < n; i++) {
pat = min(pat, k - a[i] + a[i - 1]);
}
cout << pat << endl;
return 0;
}
/*
__
*(><)*
\/ /
||/
--||
||
/\
/ \
/ \
*/
| #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
using namespace std;
lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2) {
return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a) { return (a * (a + 1LL)) / 2; }
char vow[] = {'a', 'e', 'i', 'o', 'u'};
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const int N = 1e6 + 30;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 74e-9;
lli bp(lli a, lli b = -2LL) {
lli ret = 1;
while (b) {
if (b & 1)
ret *= a, ret %= mod;
a *= a;
a %= mod;
b >>= 1;
}
return ret;
}
int k, n, pat;
int a[N];
int main() {
fastio;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
pat = a[n - 1] - a[0];
for (int i = 1; i < n; i++) {
pat = min(pat, k - a[i] + a[i - 1]);
}
cout << pat << endl;
return 0;
}
/*
__
*(><)*
\/ /
||/
--||
||
/\
/ \
/ \
*/ | replace | 43 | 44 | 43 | 44 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define MAX_N 400
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const long long INF = 1LL << 60;
// Input
int K, N;
int A[MAX_N];
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
int max_diff = 0;
int tmp = A[N - 1];
for (int i = N - 1; i > 0; i--) {
A[i] -= A[i - 1];
}
A[0] = A[0] + K - tmp;
for (int i = 0; i < N; i++) {
chmax(max_diff, A[i]);
}
cout << K - max_diff << endl;
}
| #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define MAX_N 200000
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const long long INF = 1LL << 60;
// Input
int K, N;
int A[MAX_N];
int main() {
cin >> K >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
int max_diff = 0;
int tmp = A[N - 1];
for (int i = N - 1; i > 0; i--) {
A[i] -= A[i - 1];
}
A[0] = A[0] + K - tmp;
for (int i = 0; i < N; i++) {
chmax(max_diff, A[i]);
}
cout << K - max_diff << endl;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define MOD1 1000000007
#define MOD2 998244353
#define BOOST \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
using namespace std;
ll k, n;
vector<ll> h;
void solve() {
cin >> k >> n;
h.resize(n);
for (auto &i : h)
cin >> i;
ll ans = k - h[n - 1] + h[0];
for (int i = 1; i < n; i++)
ans = max(ans, h[i] - h[i - 1]);
cout << k - ans;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll t = 1;
// cin >> t;
while (t--)
solve();
return 0;
} | #include <bits/stdc++.h>
#define ll long long int
#define MOD1 1000000007
#define MOD2 998244353
#define BOOST \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
using namespace std;
ll k, n;
vector<ll> h;
void solve() {
cin >> k >> n;
h.resize(n);
for (auto &i : h)
cin >> i;
ll ans = k - h[n - 1] + h[0];
for (int i = 1; i < n; i++)
ans = max(ans, h[i] - h[i - 1]);
cout << k - ans;
}
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ll t = 1;
// cin >> t;
while (t--)
solve();
return 0;
} | replace | 24 | 28 | 24 | 28 | -11 | |
p02725 | C++ | Runtime Error | #define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair
void fast() {
ios::sync_with_stdio(NULL);
cout.tie(NULL);
cin.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
/*freopen("output.txt", "w", stdout);
freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
fast();
File();
int n, m;
cin >> m >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i];
sort(all(arr));
ll sum = 0;
vector<int> res;
for (int i = 0; i < n - 1; i++) {
res.push_back(arr[i + 1] - arr[i]);
}
res.push_back(m - arr[n - 1] + arr[0]);
sort(all(res));
for (int i = 0; i < n - 1; i++)
sum += res[i];
cout << sum << endl;
return 0;
} | #define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair
void fast() {
ios::sync_with_stdio(NULL);
cout.tie(NULL);
cin.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
/*freopen("output.txt", "w", stdout);
freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
fast();
// File();
int n, m;
cin >> m >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i];
sort(all(arr));
ll sum = 0;
vector<int> res;
for (int i = 0; i < n - 1; i++) {
res.push_back(arr[i + 1] - arr[i]);
}
res.push_back(m - arr[n - 1] + arr[0]);
sort(all(res));
for (int i = 0; i < n - 1; i++)
sum += res[i];
cout << sum << endl;
return 0;
} | replace | 42 | 43 | 42 | 43 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int mod = 1007050321;
const int base = 521;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;
int n, K, a[N];
int main() {
ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> K >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
a[i + n] = a[i] + K;
}
int ans = inf;
for (int i = 1; i <= n; ++i)
ans = min(ans, a[i + n - 1] - a[i]);
cout << ans;
return 0;
}
/// a[i] -> a[n] -> a[i] -> a[1]
/// a[n] - a[i-1] + a[n] - a[i-1] + a[i] - a[1]
/// a[i] -> a[n] -> a[1] -> a[i-1]
/// a[n] - a[i-1] + K - a[n] + a[1] + a[i-1] - a[1]
| #include <bits/stdc++.h>
using namespace std;
const int mod = 1007050321;
const int base = 521;
const int N = 4e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;
int n, K, a[N];
int main() {
ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> K >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
a[i + n] = a[i] + K;
}
int ans = inf;
for (int i = 1; i <= n; ++i)
ans = min(ans, a[i + n - 1] - a[i]);
cout << ans;
return 0;
}
/// a[i] -> a[n] -> a[i] -> a[1]
/// a[n] - a[i-1] + a[n] - a[i-1] + a[i] - a[1]
/// a[i] -> a[n] -> a[1] -> a[i-1]
/// a[n] - a[i-1] + K - a[n] + a[1] + a[i-1] - a[1]
| replace | 6 | 7 | 6 | 7 | 0 | |
p02725 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char *argv[]) {
uint64_t K, N;
cin >> K;
cin >> N;
vector<uint64_t> A;
for (uint64_t i = 0; i < N; i++) {
uint64_t tmp;
cin >> tmp;
A.push_back(tmp);
}
uint64_t i = 0;
uint64_t ans = UINT64_MAX;
const uint64_t max_idx = A.size() - 1;
do {
uint64_t tmp = 0;
uint64_t count;
uint64_t idx0;
uint64_t idx1;
// 時計回り。
count = 0;
idx0 = (i <= max_idx) ? i : 0;
idx1 = (idx0 + 1 <= max_idx) ? idx0 + 1 : 0;
while (count < A.size() - 1) {
int64_t a0 = (int64_t)A[idx0];
int64_t a1 = (int64_t)A[idx1];
uint64_t t = (a1 - a0 >= 0) ? a1 - a0 : K + a1 - a0;
tmp += t;
idx0 = (idx0 + 1 <= max_idx) ? idx0 + 1 : 0;
idx1 = (idx0 + 1 <= max_idx) ? idx0 + 1 : 0;
count++;
}
ans = min(ans, tmp);
#if 0
// 反時計回り。
count = 0;
idx0 = (i <= 0) ? i : max_idx;
idx1 = (idx0 - 1 <= 0) ? idx0 - 1 : max_idx;
while(count < A.size()-1) {
int64_t a0 = (int64_t)A[idx0];
int64_t a1 = (int64_t)A[idx1];
uint64_t t = (a1 - a0 >= 0) ? a1 - a0 : K + a1 - a0;
tmp += t;
idx0 = (idx0 - 1 <= 0) ? idx0 - 1 : max_idx;
idx1 = (idx0 - 1 <= 0) ? idx0 - 1 : max_idx;
count++;
}
ans = min(ans, tmp);
#endif
i++;
} while (i < A.size());
cout << ans;
return 0;
}
| #include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char *argv[]) {
uint64_t K, N;
cin >> K;
cin >> N;
vector<uint64_t> A;
for (uint64_t i = 0; i < N; i++) {
uint64_t tmp;
cin >> tmp;
A.push_back(tmp);
}
uint64_t max_dist = 0;
for (uint64_t i = 0; i < N - 1; i++) {
uint64_t dist = A[i + 1] - A[i];
max_dist = max(max_dist, dist);
}
max_dist = max(max_dist, A[0] - A[N - 1] + K);
uint64_t ans = K - max_dist;
cout << ans;
return 0;
} | replace | 16 | 60 | 16 | 23 | TLE | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
int k, n;
cin >> k >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
rep(i, n) a[i + n] = a[i] + k;
int answer = k;
rep(i, n) {
if (a[i + n - 1] - a[i] < answer)
answer = a[i + n - 1] - a[i];
}
cout << answer << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
int k, n;
cin >> k >> n;
vector<int> a(2 * n);
rep(i, n) cin >> a[i];
rep(i, n) a[i + n] = a[i] + k;
int answer = k;
rep(i, n) {
if (a[i + n - 1] - a[i] < answer)
answer = a[i + n - 1] - a[i];
}
cout << answer << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02725 | C++ | Runtime Error | /******************************************
/@Author: LeafBelief
/@Date: 2020-04-07
/@Remark:
/@FileName: minumdistance
******************************************/
#include <bits/stdc++.h>
#define CSE(x, y) memset(x, y, sizeof(x))
#define lowbit(x) (x & (-x))
#define INF 0x3f3f3f3f
#define FAST \
ios::sync_with_stdio(false); \
cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 111111;
ll dis[maxn];
int main() {
FAST;
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> dis[i];
}
ll all = 0, mxdis = 0;
for (int i = 1; i < n; i++) {
all += dis[i] - dis[i - 1];
mxdis = max(mxdis, dis[i] - dis[i - 1]);
}
all += k - dis[n - 1] + dis[0] - 0;
mxdis = max(mxdis, k - dis[n - 1] + dis[0] - 0);
cout << all - mxdis << endl;
return 0;
} | /******************************************
/@Author: LeafBelief
/@Date: 2020-04-07
/@Remark:
/@FileName: minumdistance
******************************************/
#include <bits/stdc++.h>
#define CSE(x, y) memset(x, y, sizeof(x))
#define lowbit(x) (x & (-x))
#define INF 0x3f3f3f3f
#define FAST \
ios::sync_with_stdio(false); \
cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 211111;
ll dis[maxn];
int main() {
FAST;
int k, n;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> dis[i];
}
ll all = 0, mxdis = 0;
for (int i = 1; i < n; i++) {
all += dis[i] - dis[i - 1];
mxdis = max(mxdis, dis[i] - dis[i - 1]);
}
all += k - dis[n - 1] + dis[0] - 0;
mxdis = max(mxdis, k - dis[n - 1] + dis[0] - 0);
cout << all - mxdis << endl;
return 0;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p02725 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int k, n, i, max = 0;
int a[2000];
cin >> k >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n - 1; i++) {
if (a[i + 1] - a[i] > max)
max = a[i + 1] - a[i];
}
if (k + a[0] - a[n - 1] > max)
max = k + a[0] - a[n - 1];
cout << k - max << endl;
} | #include <iostream>
using namespace std;
int main() {
int k, n, i, max = 0;
int a[200000];
cin >> k >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n - 1; i++) {
if (a[i + 1] - a[i] > max)
max = a[i + 1] - a[i];
}
if (k + a[0] - a[n - 1] > max)
max = k + a[0] - a[n - 1];
cout << k - max << endl;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 110;
int n, a[N], k;
int main() {
cin >> k >> n;
int ans = 0x3f3f3f3f;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
int pre = (i - 1 + n) % n;
int nex = (i + 1) % n;
int x = (a[pre] - a[i] + k) % k;
ans = min(ans, x);
x = (a[i] - a[nex] + k) % k;
ans = min(ans, x);
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 2e5 + 100;
int n, a[N], k;
int main() {
cin >> k >> n;
int ans = 0x3f3f3f3f;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
int pre = (i - 1 + n) % n;
int nex = (i + 1) % n;
int x = (a[pre] - a[i] + k) % k;
ans = min(ans, x);
x = (a[i] - a[nex] + k) % k;
ans = min(ans, x);
}
cout << ans << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02725 | Python | Runtime Error | K, N = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])
result = []
for i in range(N):
if i == N - 1:
result.append(K - A[i] + A[0])
else:
result.appnd(A[i + 1] - A[i])
result.sort()
print(sum(result[:-1]))
| K, N = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])
result = []
for i in range(N):
if i == N - 1:
result.append(K - A[i] + A[0])
else:
result.append(A[i + 1] - A[i])
result.sort()
print(sum(result[:-1]))
| replace | 9 | 10 | 9 | 10 | AttributeError: 'list' object has no attribute 'appnd'. Did you mean: 'append'? | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02725/Python/s465874099.py", line 10, in <module>
result.appnd(A[i + 1] - A[i])
AttributeError: 'list' object has no attribute 'appnd'. Did you mean: 'append'?
|
p02725 | Python | Runtime Error | K, N = map(int, input().split())
A = [int(e) for e in input().split()]
ans = 0
for i in range(N - 1):
S = [A[i + 1] - A[i]]
S.append((K - A[N - 1]) + A[0])
m = sorted(S)
for n in range(N - 1):
ans += m[n]
print(ans)
| K, N = map(int, input().split())
A = [int(e) for e in input().split()]
ans = 0
S = [(A[i + 1] - A[i]) for i in range(N - 1)]
S.append((K - A[N - 1]) + A[0])
S.sort
m = sorted(S)
for n in range(N - 1):
ans += m[n]
print(ans)
| replace | 4 | 10 | 4 | 10 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int t = 1e6, a[20005];
int main() {
int i, k, n, p;
scanf("%d %d", &k, &n);
scanf("%d", &a[0]);
for (i = 1; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
for (i = 1; i < n; i++) {
p = k - a[i] + a[i - 1];
if (p < t)
t = p;
}
p = a[n - 1] - a[0];
if (p < t)
t = p;
printf("%d", t);
} | #include <bits/stdc++.h>
using namespace std;
int t = 1e6, a[200005];
int main() {
int i, k, n, p;
scanf("%d %d", &k, &n);
scanf("%d", &a[0]);
for (i = 1; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
for (i = 1; i < n; i++) {
p = k - a[i] + a[i - 1];
if (p < t)
t = p;
}
p = a[n - 1] - a[0];
if (p < t)
t = p;
printf("%d", t);
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02725 | C++ | Runtime Error | #pragma GCC optimize( \
"Ofast") // Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fastio \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0); \
cout << fixed; \
cout << setprecision(10);
#define randomINIT \
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define foo(i, a, n) for (ll i = (a); i <= n; i++)
#define frr(i, a, n) for (ll i = (a); i >= n; i--)
#define fo(i, n) for (ll i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define mset(x, val) memset(x, val, sizeof(x))
#define newl cout << "\n"
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define dline cerr << "///REACHED///\n";
#define deb1(x) cerr << #x << " = " << x << '\n';
#define deb2(x, y) \
cerr << '[' << #x << ',' << #y << "] = " << '[' << x << ',' << y << ']' \
<< '\n';
#define deb3(x, y, z) \
cerr << '[' << #x << ',' << #y << ',' << #z << "] = " << '[' << x << ',' \
<< y << ',' << z << ']' << '\n';
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll MOD = 1e+9 + 7;
const ll INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const ll MAXN = 1e+5 + 7;
vll adj[MAXN];
ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
//<<-----Declare Variable Here------->>//
int t = 1;
string s;
ll k, n, x;
ll v1[500005];
//<<-----Implement Functions Here---->>//
//<<-----Start of Main--------------->>//
void MAIN() {
cin >> k >> n;
for (ll i = 0; i < n; i++)
cin >> v1[i];
sort(v1, v1 + n);
ll max1 = -1;
for (ll i = 0; i < n - 1; i++)
max1 = max(max1, v1[i + 1] - v1[i]);
max1 = max(max1, k - (v1[n - 1] - v1[0]));
cout << k - max1;
}
int main() {
fastio;
randomINIT;
// cin>>t;
while (t--) {
MAIN();
}
} |
#include <bits/stdc++.h>
using namespace std;
#define fastio \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0); \
cout << fixed; \
cout << setprecision(10);
#define randomINIT \
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define foo(i, a, n) for (ll i = (a); i <= n; i++)
#define frr(i, a, n) for (ll i = (a); i >= n; i--)
#define fo(i, n) for (ll i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define mset(x, val) memset(x, val, sizeof(x))
#define newl cout << "\n"
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define dline cerr << "///REACHED///\n";
#define deb1(x) cerr << #x << " = " << x << '\n';
#define deb2(x, y) \
cerr << '[' << #x << ',' << #y << "] = " << '[' << x << ',' << y << ']' \
<< '\n';
#define deb3(x, y, z) \
cerr << '[' << #x << ',' << #y << ',' << #z << "] = " << '[' << x << ',' \
<< y << ',' << z << ']' << '\n';
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll MOD = 1e+9 + 7;
const ll INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const ll MAXN = 1e+5 + 7;
vll adj[MAXN];
ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
//<<-----Declare Variable Here------->>//
int t = 1;
string s;
ll k, n, x;
ll v1[500005];
//<<-----Implement Functions Here---->>//
//<<-----Start of Main--------------->>//
void MAIN() {
cin >> k >> n;
for (ll i = 0; i < n; i++)
cin >> v1[i];
sort(v1, v1 + n);
ll max1 = -1;
for (ll i = 0; i < n - 1; i++)
max1 = max(max1, v1[i + 1] - v1[i]);
max1 = max(max1, k - (v1[n - 1] - v1[0]));
cout << k - max1;
}
int main() {
fastio;
randomINIT;
// cin>>t;
while (t--) {
MAIN();
}
} | replace | 0 | 4 | 0 | 1 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
int k, n;
int sum = 0;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> d(n);
for (int i = 1; i < n; i++) {
d[i] = a[i] - a[i - 1];
}
d[0] = k + a[0] - a[n - 1];
sort(d.begin(), d.end());
rep(i, n - 1) sum += d[i];
cout << sum << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
int k, n;
int sum = 0;
cin >> k >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> d(n);
for (int i = 1; i < n; i++) {
d[i] = a[i] - a[i - 1];
}
d[0] = k + a[0] - a[n - 1];
sort(d.begin(), d.end());
rep(i, n - 1) sum += d[i];
cout << sum << endl;
} | insert | 10 | 10 | 10 | 11 | -6 | terminate called after throwing an instance of 'std::length_error'
what(): cannot create std::vector larger than max_size()
|
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
#define FIO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define T() \
int tt; \
cin >> tt; \
rep1(qq, 1, tt)
#define rep(i, start, lim) for (int i = start; i < lim; i++)
#define rep1(i, start, lim) for (int i = start; i <= lim; ++i)
#define repd(i, start, lim) for (int i = start; i >= lim; i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout << "\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12
#define lnode (2 * node + 1)
#define rnode (2 * node + 2)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
int k, n;
int a[N];
int32_t main() {
FIO
// cout << fixed << setprecision(10);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
cin >>
k >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
int res = k - a[n - 1] + a[0];
for (int i = 1; i < n; ++i) {
res = max(res, a[i] - a[i - 1]);
}
cout << k - res << '\n';
return 0;
} | #include <bits/stdc++.h>
#define FIO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define T() \
int tt; \
cin >> tt; \
rep1(qq, 1, tt)
#define rep(i, start, lim) for (int i = start; i < lim; i++)
#define rep1(i, start, lim) for (int i = start; i <= lim; ++i)
#define repd(i, start, lim) for (int i = start; i >= lim; i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout << "\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12
#define lnode (2 * node + 1)
#define rnode (2 * node + 2)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 200005;
int k, n;
int a[N];
int32_t main() {
FIO
// cout << fixed << setprecision(10);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
cin >>
k >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
int res = k - a[n - 1] + a[0];
for (int i = 1; i < n; ++i) {
res = max(res, a[i] - a[i - 1]);
}
cout << k - res << '\n';
return 0;
} | replace | 35 | 36 | 35 | 36 | 0 | |
p02725 | C++ | Runtime Error | #include <iostream>
using namespace std;
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <string.h>
int lst[110];
int main() {
int k;
int n;
int ans;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> lst[i];
}
ans = -lst[n - 1] + lst[0] + k;
for (int i = 0; i < n - 1; i++) {
if (lst[i + 1] - lst[i] > ans)
ans = lst[i + 1] - lst[i];
}
cout << k - ans << endl;
return 0;
} | #include <iostream>
using namespace std;
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <string.h>
int lst[200010];
int main() {
int k;
int n;
int ans;
cin >> k >> n;
for (int i = 0; i < n; i++) {
cin >> lst[i];
}
ans = -lst[n - 1] + lst[0] + k;
for (int i = 0; i < n - 1; i++) {
if (lst[i + 1] - lst[i] > ans)
ans = lst[i + 1] - lst[i];
}
cout << k - ans << endl;
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02725 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int arr[100005];
int main() {
int n, k;
scanf("%d", &k);
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int x = arr[n - 1] - arr[0];
int y = arr[0] + (k - arr[1]);
x = min(x, y);
int d = (k - arr[n - 1]) + arr[n - 2];
int mini = min(x, d);
for (int i = 1; i < n - 1; i++) {
int p = (k - arr[i]) + arr[i - 1];
int q = arr[i] + (k - arr[i + 1]);
int mini2 = min(p, q);
mini = min(mini, mini2);
}
cout << mini;
}
| #include <bits/stdc++.h>
using namespace std;
int arr[200005];
int main() {
int n, k;
scanf("%d", &k);
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int x = arr[n - 1] - arr[0];
int y = arr[0] + (k - arr[1]);
x = min(x, y);
int d = (k - arr[n - 1]) + arr[n - 2];
int mini = min(x, d);
for (int i = 1; i < n - 1; i++) {
int p = (k - arr[i]) + arr[i - 1];
int q = arr[i] + (k - arr[i + 1]);
int mini2 = min(p, q);
mini = min(mini, mini2);
}
cout << mini;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02725 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long long int, long long int> iil;
typedef long long ll;
typedef vector<ll> vl;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (auto i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define edl '\n'
#define ll long long int
#define forn(i, n) for (int i = 0; i < n; i++)
#define fornl(i, n) for (ll i = 0; i < n; i++)
#define forni(i, j, n) for (int i = j; i < n; i++)
#define filecode \
ifstream cin("input.txt"); \
ofstream cout("output.txt");
#define IOFAST \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define setPrecision(n) cout << std::setprecision(n) << std::fixed;
#define MOD 998244353
#define PI 3.14159265
#define DEBUG 0
#define g(a, b) a > b ? a : b
#define l(a, b) a < b ? a : b
bool comp(ii a, ii b) {
return (a.first == b.first) ? a.second < b.second : a.first < b.first;
}
ll modInverse(ll a) {
ll m = MOD;
ll y = 0, x = 1;
while (a > 1) {
ll q = a / m;
ll t = m;
m = a % m, a = t;
t = y;
y = x - q * y;
x = t;
}
if (x < 0)
x += MOD;
return x;
}
int main() {
ll k, n;
cin >> k >> n;
vl A(n);
forn(i, n) { cin >> A[i]; }
int m = 1e7;
forn(i, n) {
m = l(((A[(i + n - 1) % n] - A[i] + k) % k),
((A[i] - A[(i - n + 1) % n] + k) % k));
}
cout << m << endl;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long long int, long long int> iil;
typedef long long ll;
typedef vector<ll> vl;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (auto i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define edl '\n'
#define ll long long int
#define forn(i, n) for (int i = 0; i < n; i++)
#define fornl(i, n) for (ll i = 0; i < n; i++)
#define forni(i, j, n) for (int i = j; i < n; i++)
#define filecode \
ifstream cin("input.txt"); \
ofstream cout("output.txt");
#define IOFAST \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define setPrecision(n) cout << std::setprecision(n) << std::fixed;
#define MOD 998244353
#define PI 3.14159265
#define DEBUG 0
#define g(a, b) a > b ? a : b
#define l(a, b) a < b ? a : b
bool comp(ii a, ii b) {
return (a.first == b.first) ? a.second < b.second : a.first < b.first;
}
ll modInverse(ll a) {
ll m = MOD;
ll y = 0, x = 1;
while (a > 1) {
ll q = a / m;
ll t = m;
m = a % m, a = t;
t = y;
y = x - q * y;
x = t;
}
if (x < 0)
x += MOD;
return x;
}
int main() {
ll k, n;
cin >> k >> n;
vl A(n);
forn(i, n) { cin >> A[i]; }
int m = 1e7;
forn(i, n) {
if (i == 0) {
m = l(m, (k - abs(A[1] - A[0])));
m = l(m, (A[n - 1] - A[0]));
} else if (i == n - 1) {
m = l(m, (k - abs(A[n - 1] - A[n - 2])));
m = l(m, (A[n - 1] - A[0]));
} else {
m = l(m, (k - abs(A[(i + 1)] - A[i])));
m = l(m, (k - abs(A[i] - A[(i - 1)])));
}
}
cout << m << endl;
}
| replace | 65 | 67 | 65 | 76 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.