akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
void solve(long long N, long long L, long long T, vector<long long> X, vector<long long> W){
	vector<pll> v;
	ll sumtimes=0;
	for (ll i=1;i<N;i++) {
		if (W[i]!=W[0]) {
			ll diff;
			if (W[0]==1) {diff=(X[i]-X[0]+L)%L;}
			else {diff=(X[0]-X[i]+L)%L;}
			if (diff<0) diff+=L;
			ll times=(max(0ll,(2*T+L-diff+(W[0]==1?-1:0))/L))%N;
			//printf("diff:%lld times:%lld i:%lld\n",diff,times,i);
			if (W[0]!=1) times=N-times;
			assert(times>=0);
			sumtimes+=times;
			sumtimes%=N;
		}
	}
	for (ll i=0;i<N;i++) {
		ll dir=W[i]==1?1:-1;
		v.PB(MP(((X[i]+dir*T)%L+L)%L,i));
	}
	sort(v.begin(),v.end());
	ll antForLineZero=sumtimes;
	//printf("aflz:%lld\n",antForLineZero);
	ll newZeroIdx=-1;
	for (ll i=0;i<N;i++) {
		if (v[i].snd==0) {newZeroIdx=i; break;}
	}
	if (W[antForLineZero]==1) {
		if (newZeroIdx!=0&&v[newZeroIdx]==v[(newZeroIdx-1)]) {
			newZeroIdx=(newZeroIdx-1);
		}
	}
	else if (W[antForLineZero]==2) {
		if (newZeroIdx!=N&&v[newZeroIdx]==v[(newZeroIdx+1)]) {
			newZeroIdx=(newZeroIdx+1);
		}
	}
	vector<ll> vans;
	vans.resize(N);
	for (ll i=0;i<N;i++) {
		vans[(antForLineZero+i)%N]=v[(newZeroIdx+i)%N].fst;
	}
	for (ll i=0;i<N;i++) {
		printf("%lld\n",vans[i]);
	}
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long T;
	long long N;
	long long L;
	scanf("%lld",&N);
	vector<long long> W(N-1+1);
	vector<long long> X(N-1+1);
	scanf("%lld",&L);
	scanf("%lld",&T);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&X[i]);
		scanf("%lld",&W[i]);
	}
	solve(N, L, T, X, W);
	return 0;
}



Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;

int main(void){
  long long K;
  int N;
  cin >> K >> N;
  long long sum = 0;
  vector<int> diff(N);
  int temp, before; 
  cin >> temp;
  sum += temp;
  diff[0] = temp;
  before  = temp;
  for(int i = 1; i < N; i++){
    cin >> temp;
    diff[i] = temp - before;
   
    sum += diff[i];
    before = temp;
  }
  diff[0] += K - before;
  sum += K - before;
  sort(diff.begin(), diff.end());
  cout << sum - diff[N - 1];

  return 0;
}

Measured memory_bytes: 1024
#define rep(i, n) for(ll i = 0; i < n; i++)
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> cnt(26,50);
	rep(i,n) {
		string s;
		vector<int> w_cnt(26,0);
		cin >> s;
		for (char w: s) {
			w_cnt[w - 'a']++;
		}
		rep(j,26) {
			cnt[j] = min(cnt[j], w_cnt[j]);
		}
	}
	rep(i,26) {
		rep(j,cnt[i]) cout << char(i+'a');
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  ll x,ans;
  cin>>x;
  ans=x/11*2;
  if(x%11==0) ;
  else if(x%11<=6) ans++;
  else ans+=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

int main()
{
	int N;
	scanf("%d", &N);
	long long sum{};
	for (int i{}; i < N; i++)
	{
		int a;
		scanf("%d", &a);
		sum += a - 1;
	}
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
   int cnt = 0;
   char s[100000];
   scanf("%s",s);
   for(int i = 1;i <= strlen(s)-1;i++){
      if(s[i] == s[i-1]){
         if(s[i] == '0'){
            s[i] = '1';
            cnt ++;
         }else if(s[i] == '1'){
            s[i] = '0';
            cnt ++;
         }
      }
   }
   printf("%d",cnt);
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N,K;
int h[100001];
int dp[100001];

int main(){
    cin>>N>>K;
    repn(i,N) cin>>h[i];

    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=N;i++){
        int res=1001001001;
        repn(j,min(K,i-1)){
            res=min(res,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=res;
    }

    cout<<dp[N]<<endl;
} 

Measured memory_bytes: 1024
n, a, b = gets.split(' ').map(&:to_i)
ans = 0

def sum_of_digits(n)
  sum = 0
  loop do
    sum += n % 10
    n /= 10
    break if n.zero?
  end
  sum
end

(1..n).each do |item|
  sum = sum_of_digits(item)
  ans += item if a <= sum && sum <= b
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int n,d,cnt=0,i;
    scanf("%d %d",&n,&d);
    double a[n],b[n];
    for(i=0;i<n;i++)
    {
        scanf("%lf %lf",&a[i],&b[i]);
        if(sqrt(a[i]*a[i]+b[i]*b[i])<=d)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 5256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;


int main() {
  char s;
  cin  >> s;
  if (s == 'a') cout << "vowel" << endl;
  else if (s == 'i') cout << "vowel" << endl;
  else if (s == 'u') cout << "vowel" << endl;
  else if (s == 'e') cout << "vowel" << endl;
  else if (s == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2005;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, m; cin >> n >> m;
	ll ans = 0;
	vector<int>a(n<<1, 0);//储存至少的2n个数
	vector<pair<int, int>>x(m);
	_for(i, 0, n)cin >> a[i];
	_sfor(it, x)cin >> it.second >> it.first;
	sort(x.begin(), x.end(), greater<pair<int,int>>());
	int j = n;
	_sfor(it, x) {
		for (int i = 0; i < it.second && j < (n << 1); ++i, ++j)a[j] = it.first;
	}
	sort(a.begin(), a.end(), greater<int>());
	_for(i, 0, n)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;
string s1, s2, s;

void solve()
{
	cin >> s1 >> s2;
	cin >> n >> m;
	cin >> s;

	if (s == s1)
		n--;
	else
		m--;

	cout << n << " " << m;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T x, T y) {
        return (((fact[x+y]*ifact[x])%M)*ifact[y])%M;
    }
};
 
ModFact<2000000, ll, MOD> fact;

int main() {
    fastio();
    ll r1, c1, r2, c2, ans;
	cin >> r1 >> c1 >> r2 >> c2;
    ans = fact.comb(r1, c1);
    for(ll x=r1+1; x<=r2; x++)
        ans += fact.comb(x, c2);
    for(ll y=c1+1; y<=c2; y++)
        ans += fact.comb(r2, y);
    cout << ans % MOD << "\n";
	return 0;
}


Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int a, p;
    cin >> a >> p;
    OP((3 * a + p) / 2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel";
  }
  else {
    cout << "consonant";
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include <unordered_set>
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<string> s(4);
	s[0] = "##";
	s[1] = "#.";
	s[2] = ".#";
	s[3] = "..";
	bool right = false;
	string r = "F";
	int cnt = 0;
	string s1, s2;
	while (r != "end") {
		if (r == "T") {
			if (!right) {
				s1 += s[cnt][0];
				s2 += s[cnt][1];
			}
			else {
				s1 = s[cnt][0] + s1;
				s2 = s[cnt][1] + s2;
			}
			cnt = 0;
		}
		else {
			cnt++;
			if (cnt == 4) {
				right = true;
				cnt = 0;
			}
		}
		if (!right) {
			cout << s1 << s[cnt][0] << endl;
			cout << s2 << s[cnt][1] << endl;
			fflush(stdout);
		}
		else {
			cout << s[cnt][0] << s1 << endl;
			cout << s[cnt][1] << s2 << endl;
			fflush(stdout);
		}
		cin >> r;
		if (r == "end") {
			return 0;
		}
	}
}

Measured memory_bytes: 724
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
void in_out()
{
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
}
int main()
{
	fast();
	long long n, m;
	cin >> n >> m;
	for (long long i = 0; i <= n; i++)
	{
		for (long long j = 0; j <= n; j++)
		{
			if (i * 10000 + j * 5000 + (n - (i + j)) * 1000 == m&&n-i-j>=0)
			{
				cout << i << " " << j << " " << n - (i + j) << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

a.each do |i|
  if i == 0
    puts 0
    return
  end
end


s = 1
a.each do |i|
  s = s * i

  if s > 10**18
    puts -1
    return
  end
end

puts s



Measured memory_bytes: 21524
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n, sum = 0;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n - 1) cin >> c[i];
  REP(i, n) {
    sum += b[i];
    if (i < n - 1 && a[i] == a[i + 1] - 1) {
      sum += c[a[i] - 1];
    }
  }
  cout << sum << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    long double area = w;
    area /= 2;
    area *= h;
    cout << fixed << setprecision(12) << area << " ";

    if (w == x + x && h  == y + y) cout << 1;
    else cout << 0;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
  int n; scanf("%d", &n);
  int cnt = 0, even = 0;
  for (int i = 1; i <= n; i++) {
    int x;  scanf("%d", &x);
    if (x % 4 == 0) {
      cnt++;
    } else if (x & 1) {
      cnt--;
    } else {
      even++;
    }
  }
  puts((cnt >= 0) || (cnt == -1 && even == 0) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
const int maxn=2e5+7;
ll x,y;
ll n,k;
int main()
{
	scanf("%d%d",&n,&k);
	ll ans=0;
	ll num=n/k;
	ans+=num*num*num;
	if(k%2==0){
		ll kk=k/2;
		ll num2=n/kk-num;
		ans+=num2*num2*num2;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const long long inf = 1e15;
const int mod = 1e6;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 
const long long N = 4000 * 100 + 10;

ll a[N], b[N];
ll dp[N];
pii p[N];

int main()
{
	faster();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].first;
		p[i].second = i;
	}
	sort(p, p + n);
	ll ans = 0;
	for (int i = 0; i < n; i+=2)
	{
		if(0 != p[i].second % 2)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;

  if (A == B) {
    cout << "Draw" << endl;
    return 0;
  }
  if (A == 1) {
    cout << "Alice" << endl;
    return 0;
  } else if (B == 1) {
    cout << "Bob" << endl;
  } else if (A > B) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N;
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      N = Integer.parseInt(List[0]);
 
  // System.out.println(N);
     
      calc(N);
        scan.close();
    }
  
  public static void calc(int n){
    int chage = 10000;
    chage = chage - n;
     while(chage >= 1000){
       chage = chage -1000;
     }
    System.out.println(chage);
    return;
    }
}

Measured memory_bytes: 35636
#include<bits/stdc++.h>
 using namespace std;
 int main(){
 	int n,a[100010],maxa=0,mina=1e9,num1=0;
 	cin>>n;
 	for(int i=1;i<=n;i++){
 		cin>>a[i];
 		if(a[i]>maxa) maxa=a[i];
 		if(a[i]<mina) mina=a[i];
	 }
	if(maxa-mina>1){
		cout<<"No";
		return 0;
	}
	for(int i=1;i<=n;i++)
	  if(a[i]==mina) num1++;
	if(maxa-mina==0){
		if(maxa==n-1||maxa*2<=n) cout<<"Yes";
		else cout<<"No";
	}
	else{
		if(num1<maxa&&n-num1>=2*(maxa-num1)) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
 }

Measured memory_bytes: 640
data = raw_input().strip().split()

stat = {}

for w in data:
    if w in stat:
        stat[w][0] += 1
    else:
        stat[w] = [1, len(w)]

count_list = sorted(stat.items(), key=lambda x: x[1][0], reverse=True)
length_list = sorted(stat.items(), key=lambda x: x[1][1], reverse=True)

print count_list[0][0] + " " + length_list[0][0]

Measured memory_bytes: 4228
#include <iostream>
using namespace std;

int main() {
    int a, b, c, d, e;
    cin>>a>>b>>c>>d>>e;
    if (a==0)
    {
        cout<<1;
    }
    else if (b==0)
    {
        cout<<2;
    }
    else if (c==0)
    {
        cout<<3;
    }
    else if (d==0)
    {
        cout<<4;
    }
    else if (e==0)
    {
        cout<<5;
    }   
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool debug = false;

int main() {
  int N; cin >> N;  // 頂点の数
  int X,Y; cin >> X >> Y; // 短縮線
  X--;Y--;  // 座標は 0 から N-1 で処理します。

  map<int,int>  M;  // 距離ごとの組数
  int wk_d=0; // ２点間の距離
  rep(i,N-1){
    for(int j=i+1;j<N;j++){
      wk_d = min((j-i),(abs(X-i)+1+abs(Y-j)));
      M[wk_d]++;
//      cout << "i:" << i << " j:" << j << " wk_d:" << wk_d << endl;
    }
  }
  rep(i,N-1){
    cout << M[i+1] << endl;
  }

}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

bool isprime(long n)
{
    if (n == 2) return true;
    if (n < 2 || n % 2 == 0) return false;
    double root_n = std::sqrt((double) n);
    for (int i = 3; i <= root_n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, a, cnt = 0;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a;
        if (isprime(a))
            ++cnt;
    }
    std::cout << cnt << std::endl;
}



Measured memory_bytes: 3204
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	// (dp[i][j]=i個目までを使ってAの和がjの時の最小コスト)
	// (dp[i+1][j] = min(dp[i][j], dp[i+1][j-Ai]+Bi))
	// dp[j] = min(dp[j], dp[j-a]+b)
	dp := make([]int, h+1)
	// コストを最大に初期化
	for i := 0; i < len(dp); i++ {
		dp[i] = math.MaxInt32
	}
	// 漸化式の初期値を設定
	// 攻撃の総和が0の時はコスト0
	dp[0] = 0
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		for j := 0; j < h; j++ {
			// j+a: i番目の魔法を使った場合のAの総和
			// h: モンスターの体力
			nj := intMin(j+a, h)
			// dp[nj]: i番目の魔法を使わない場合→変わらず
			// dp[j]+b: i番目の魔法を使う場合→コストがbだけ増える
			dp[nj] = intMin(dp[nj], dp[j]+b)
		}
	}
	fmt.Println(dp[h])
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 640
#include <bits/stdc++.h>

int main() {
    int n;
    std::cin >> n;
    std::vector<std::pair<int,int>> xs(n);
    for(int i = 0; i < n; ++i) {
        std::cin >> xs[i].first >> xs[i].second;
    }
    std::vector<int> ys(200000);
    for(int i = 0; i < n; ++i) {
        ys[xs[i].first] += 1;
        ys[xs[i].second+1] -= 1;
    }
    int t = 0;
    std::vector<int> zs;
    for(int i = 0; i < 150000; ++i) {
        t += ys[i];
        zs.push_back(t);
    }
    int res = 0;
    for(int i = 0; i < 150000; ++i) {
        if (zs[i] >= i - 1) {
            res = i - 1;
        }
    }
    printf("%d\n", res);
}



Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
#define maxn 6020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

char ch[maxn],ans[maxn],tmp[maxn],cur[maxn];
int n,a[maxn],b[maxn],tota,totb,tot,len,len2,clen[maxn],tag[maxn],flen[maxn];
char vec[maxn / 2][maxn],f[maxn / 2][maxn];

void getmx1(int x,int l,int r){
	vec[x][++clen[x]] = 'a' , vec[x][++clen[x]] = 'b';
	int lastb = b[l];
	rep(i,l + 1,r){
		if ( a[i] > lastb ){
			vec[x][++clen[x]] = 'a' , vec[x][++clen[x]] = 'b';
			lastb = b[i];
		}
	}
}
inline int cmp(char s[],int l1,char t[],int l2){
	rep(i,1,min(l1,l2)){
		if ( s[i] != t[i] ) return s[i] > t[i];
	}
	return l1 >= l2;
}
void getmx2(int x,int l,int r){
	len = 2;
	tmp[1] = 'b' , tmp[2] = 'a';
	rep(i,l,r - 1){
		len2 = 0;
		int pa = i , pb = i;
		while ( pa <= r && pb <= r ){
			if ( a[pa] < b[pb] ) cur[++len2] = 'a' , pa++;
			else cur[++len2] = 'b' , pb++;
		}
		while ( pa <= r ) cur[++len2] = 'a' , pa++;
		while ( pb <= r ) cur[++len2] = 'b' , pb++;
		if ( !cmp(tmp,len,cur,len2) ){
			rep(j,1,len2) tmp[j] = cur[j];
			len = len2;
		}
	}
	rep(i,1,len) vec[x][i] = tmp[i];
	clen[x] = len;
}
void getans(){
	len = 0;
	repd(i,tot,1){
		rep(j,1,clen[i]) f[i][j] = vec[i][j];
		rep(j,1,len) f[i][j + clen[i]] = tmp[j];
		flen[i] = clen[i] + len;	
		if ( cmp(f[i],flen[i],tmp,len) ){
			rep(j,1,flen[i]) tmp[j] = f[i][j];
			len = flen[i];
		}
	}
	rep(i,1,len) putchar(tmp[i]);
	puts("");
}
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d",&n);
	scanf("%s",ch + 1);
	rep(i,1,n * 2){
		if ( ch[i] == 'a' ) a[++tota] = i;
		else b[++totb] = i;
	}
	int last = 1 , mx = 0;
	rep(i,1,n){
		mx = max(mx,max(a[i],b[i]));
		if ( mx == i * 2 ){
			++tot;
			if ( a[i] < b[i] ) getmx1(tot,last,i);
			else getmx2(tot,last,i);
			last = i + 1 , mx = 0;
		}
	}
	getans();
}



Measured memory_bytes: 35200
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;

int ans;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;


	if (N%2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	rep(i, N/2) {
		if (S[i] != S[N / 2 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  cnt=0
  for i in range(n):
    cnt += 1
    crt = A[crt-1]
    if crt == 2:
      print(cnt)
      break
  else:
    print(-1)
main()

Measured memory_bytes: 80180
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,a,m=2000000000,M=0;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a;
        m=min(m,a);
        M=max(M,a);
    }
    cout<<M-m<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int res = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return EXIT_SUCCESS;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  while(n --> 0){
    int x,y;
    int cnt[16][16] = {{1}};
    bool f[16][16][16][16] = {{{{false}}}};
    cin>>x>>y;

    int m;
    cin>>m;
    while(m --> 0){
      int mx, my, mmx, mmy;
      cin>>mx>>my>>mmx>>mmy;
      if(mx > mmx) swap(mx, mmx);
      if(my > mmy) swap(my, mmy);
      f[my][mx][mmy][mmx] = true;
    }

    REP(i,y+1) REP(j,x+1){
      if(j > 0 && !f[i][j-1][i][j])
        cnt[i][j] += cnt[i][j-1];
      if(i > 0 && !f[i-1][j][i][j])
        cnt[i][j] += cnt[i-1][j];
    }

    if(cnt[y][x] == 0)
      cout << "Miserable Hokusai!" << endl;
    else
      cout << cnt[y][x] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,x,w;
    ll u,ans=0;
    cin>>n>>x;
    
    vector<ll> s(x+1,-1);
    s[0]=0;
    
    rep(i,n){
        cin>>w>>u;
        
        for(int j=x-w;j>=0;j--)
        if(s[j]!=-1)
        s[w+j]=max(s[j+w],s[j]+u);
    }
    for(auto i:s)
        ans=max(ans,i);
    cout<<ans<<endl;
        
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int GCD(int a, int b) {if(b==0)return a; return GCD(b, a%b);}
int main() {
    int N; cin >> N;
    long long X; cin >> X;
    long long x[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }
    long long res = abs(x[0] - X);

    for (int i = 1; i < N; ++i) {
        res = GCD(res, abs(x[i] - X));
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    int cnt = 1;
    reps(i,n){
        cnt *= i;
        cnt %= (1000000000 + 7); 
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				if (i + j > n) {
					break;
				}
				if ((n - i - j) * 10000 + j * 5000 + i * 1000 == y) {
					System.out.println((n - i - j) + " " + j + " " + i);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}


Measured memory_bytes: 23632
import Control.Monad

main :: IO ()
main = do
  [n, m] <- map (read :: String -> Int) . words <$> getLine
  strs <- replicateM n getLine
  mapM_ putStrLn $ solve n strs

solve :: Int -> [String] -> [String]
solve n ss = foldr (\a b -> a : a: b) [] ss

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,k,s=1;
  cin >> n >> k;
  while(k>s){
    s = s * 2;
    n = n - 1;
    if(n==0)break;
  }
  while(n!=0){
    s = s + k;
    n = n - 1;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s, t;
    cin >> s >> t;
    for(ll i = 0; i < t.size(); i++){
        if(s == t) ANS("Yes");
        char x = s[t.size()-1];
        s.erase(s.end()-1);
        s.insert(s.begin(), x); //cout << s << " ";
    }
    ANS("No");
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int n,W,w[1000005],v[1000005],possible[1000005];

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin >> n >> W ;
    for(int i=1;i<=n;i++) cin >> w[i] >> v[i];
    possible[0] = 1;
    for (int k = 1; k <= n; k++) {
        for (int x = W; x >= 0; x--) {
            if (possible[x]) possible[x+w[k]] = max(possible[x]+v[k],possible[x+w[k]]);
        }
    }
    int ans=0;
    for(int i=W;i>=0;i--){
        ans=max(ans,possible[i]-1);
    }
    cout<<ans;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;

	vector<vector<int>> a(h, vector<int>(w, 0));
	rep (i, 0, h)
		rep (j, 0, w)
		cin >> a[i][j];

	vector<pair<int, int>> src;
	vector<pair<int, int>> dst;
	int x = 0;
	int y = 0;
	while (y < h) {
		int next_y, next_x;
		if (y & 1) {
			if (x == 0) {
				next_x = 0;
				next_y = y + 1;
			} else {
				next_x = x - 1;
				next_y = y;
			}
		} else {
			if (x == w - 1) {
				next_x = w - 1;
				next_y = y + 1;
			} else {
				next_x = x + 1;
				next_y = y;
			}
		}

		if (a[y][x] & 1 && next_y < h && next_x < w) {
			a[y][x]--;
			a[next_y][next_x] += 1;

			src.push_back(make_pair(y + 1, x + 1));
			dst.push_back(make_pair(next_y + 1, next_x + 1));
		}
		y = next_y;
		x = next_x;
	}

	cout << src.size() << endl;
	rep (i, 0, src.size()) {
		cout << src[i].first << " " << src[i].second << " "
				 << dst[i].first << " " << dst[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 5356
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        Point p1 = new Point();
        Point p2 = new Point();
 
        p1.setX(scanner.nextDouble());
        p1.setY(scanner.nextDouble());
        p2.setX(scanner.nextDouble());
        p2.setY(scanner.nextDouble());
 
        System.out.printf("%.10f\n", calcDistance(p1,p2));
    }
 
    public static double calcDistance(Point p1,Point p2){
        return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
    }
}
 
class Point{
 
    private double x;
    private double y;
 
    Point(){
        x = 0;
        y = 0;
    }
 
    public double getX() {
        return x;
    }
    public void setX(double x) {
        this.x = x;
    }
    public double getY() {
        return y;
    }
    public void setY(double y) {
        this.y = y;
    }
}


Measured memory_bytes: 28296
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}

const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

bool check(string x){
    int tot = 0,fo = 1;
    FOR(i,0,sz(x)){
        if(x[i] == '(')tot++;
        else tot--;
        if(tot < 0)return 0;
    }
    if(tot != 0)return 0;
    return 1; 
}

void solve(){
    int n;
    cin >> n;
    string s[n+5];
    vector<pii>pos,neg;
    string ans = "";
    FOR(i,0,n){
        cin >> s[i];
        int mi = mod,tot = 0;
        FOR(j,0,sz(s[i])){
            if(s[i][j] == '(')++tot;
            else tot--;
            mi = min(tot,mi);
        }   
        if(mi >= 0)ans += s[i];
        else if(tot >= 0)pos.pb({-mi,i});
        else neg.pb({mi-tot,i});
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    for(auto &x:pos)ans += s[x.se];
    for(auto &x:neg)ans += s[x.se];
    if(check(ans))cout << "Yes";
    else cout << "No";
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
       solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 45204
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var acum = new long[S.Length];

            var whiteCount = 0L;
            for (var i = S.Length - 1; i >= 0; i--)
            {
                if (S[i] == 'W')
                    whiteCount++;
                else
                    acum[i] = whiteCount;
            }

            Console.WriteLine(acum.Sum());
        }
    }
}


Measured memory_bytes: 13408
/*****************************
*  Author :: Prasanna Kumar  *
*****************************/

/***********************************
* Unus pro omnibus, omnes pro uno  *
***********************************/
#include<bits/stdc++.h>
using namespace std;

// #define __AnAkLuSmOs freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define __AcHiLlEs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define i_64 long long

void solve() {
    int x, n;
    cin >> x >> n;
    int a[n];
    std::map<int, int> m;
    for (int&i : a)cin >> i, m[i]++;
    int res;
    for (int i = 0; i < 200; i++) {
        if (!m[x - i]) {
            res = x - i;
            break;
        }
        if (!m[x + i]) {
            res = x + i;
            break;
        }
    }
    cout << res << "\n";
}

signed main() {
    // #ifndef ONLINE_JUDGE 
    //     __AnAkLuSmOs    
    // #endif

    __AcHiLlEs

    i_64 t(1);
    // cin >> t;
    for (i_64 i = 1; i <= t; /*cout << "Case " << i << ": ",*/ solve(), i++);
    return 0;
}
    

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pa pair
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    int N,M,K;cin>>N>>M>>K;
    rep(i,M+1) rep(j,N+1){
        int a = 0;
        a += N*i;
        a += (M-i)*j;
        a -= i*j;
        if(a == K){out("Yes");return 0;}
    }
    out("No");
    
    
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

int dp[1001][1001];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s1, s2;
	cin >> s1 >> s2;

	for (int i = 0; i < (s1.size() + 1); i++)
	{
		dp[i][0] = i;
	}
	for (int i = 0; i < (s2.size() + 1); i++)
	{
		dp[0][i] = i;
	}
	for (int i = 1; i < (s1.size() + 1); i++)for (int j = 1; j < (s2.size() + 1); j++)
	{
		dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1), dp[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 0 : 1));
	}

	cout << dp[s1.size()][s2.size()] << endl;
	
	return 0;
}


Measured memory_bytes: 7160
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      k: usize,
      a: [usize; n]
   }
   let ans = 1
      + if (n - k) % (k - 1) == 0 {
         (n - k) / (k - 1)
      } else {
         (n - k) / (k - 1) + 1
      };
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, c, d;
    int ans;
    
    scanf("%d%d%d%d", &a, &b, &c, &d);
    
    ans=fmin(a, b)+fmin(c, d);
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 2112
import sys
sys.setrecursionlimit(10 ** 9)

def solve(cur, visited):
    if len(visited) == n:
        ans.append(1)
        return
    for i in graph[cur]:
        if not i in visited:
            solve(i, visited + [i])


n, m = map(int, input().split())
graph = [[] for i in range(n)]
ans = []

for i in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

solve(0, [0])
print(len(ans))


Measured memory_bytes: 3064
import datetime

H_1, M_1, H_2, M_2, K = map(int, input().split())

end_time = datetime.time(H_2, M_2, 00)

limit_time = datetime.datetime.combine(datetime.date(year=2017, month=10, day=10), end_time) - datetime.timedelta(minutes=K)

start_time = datetime.time(H_1, M_1, 00)

dif = limit_time - datetime.datetime.combine(datetime.date(year=2017, month=10, day=10), start_time)

print(dif.seconds//60)

Measured memory_bytes: 9412
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto A = aryread();
    PQueue pq;
    foreach (a; A)
        pq.insert(a);
    foreach (_; 0 .. M)
    {
        long m = pq.front;
        pq.removeFront();
        pq.insert(m / 2);
    }
    pq.sum().writeln();
}


Measured memory_bytes: 5800
#include<stdio.h>
int main(void){
  char s[99],t[99];
  scanf("%s\n",s);
  for(int i=0;i<100;i++){
    if(s[i]!=0){
      s[i]='x';
    }
  }
  printf("%s\n",s);
  return 0;
}

Measured memory_bytes: 128
n,p=map(int,input().split())
 
if n==1:
    print(p)
elif n>45:
        print(1)

else:
    x=round((p**(1/n)+1))+1
    for i in range(x,0,-1):        
                if p%(i**n)==0:
                    print(i)
                    break
 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main(){
    int n, m, k;
    cin >> n >> m;
    set<int> drop;
    rep(i, m){ cin >> k; drop.insert(k);}
    vector<int> dp(n+2);
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--){
        if (drop.count(i)) dp[i] = 0;
        else dp[i] = (dp[i+1] + dp[i+2]) % 1000000007;
    }
    cout << dp[0] << endl;
}   

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
int main()
{
    int n,k,a[100000]={1};
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    	a[i]=min(a[i-1]+k,a[i-1]*2);
    cout<<a[n];
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;

int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=m/n; i>=0; i--){
        if (m%i==0){
            printf("%d\n",i);
            break;
        }
    }
	return 0 ;
}

Measured memory_bytes: 128