akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main() {
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }else if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int>P;
int w[4][100005];
signed main() {
	int n; cin >> n;
	string s; cin >> s;

	for (int i = 0; i < 4; i++)
		for (int j = 0; j < n; j++)w[i][j] --;

	w[0][0] = 0, w[0][1] = 0;
	w[1][0] = 0, w[1][1] = 1;
	w[2][0] = 1, w[2][1] = 0;
	w[3][0] = 1, w[3][1] = 1;
	int fl = 0,ans=4;
	//0=sheep,1=wolf
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j <= n; j++) {
			int m = j%n, l = (j + n - 1) % n, r = (j + 1) % n;
			if (w[i][m]) {//.wolf
				if (s[m] == 'o') {
					int a;
					if (w[i][l])a = 0;
					else a = 1;
					if (w[i][r] ==-1)w[i][r] = a;
					else if (w[i][r] != a)fl++;
				}
				else {
					int a;
					if (w[i][l])a = 1;
					else a = 0;
					if (w[i][r] == -1)w[i][r] = a;
					else if (w[i][r] != a)fl++;
				}
			}
			else {
				if (s[m] == 'x') {
					int a;
					if (w[i][l])a = 0;
					else a = 1;
					if (w[i][r] == -1)w[i][r] = a;
					else if (w[i][r] != a)fl++;
				}
				else {
					int a;
					if (w[i][l])a = 1;
					else a = 0;
					if (w[i][r] == -1)w[i][r] = a;
					else if (w[i][r] != a)fl++;
				}
			}
		}
		if (!fl)ans = i;
		fl = 0;
	}
	if (ans == 4)puts("-1");
	else {
		for (int i = 0; i < n; i++) {
			if (w[ans][i])cout << 'W';
			else cout << 'S';
		}
		cout << endl;
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#ifdef TOPOLOGY
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;

vector<int> idx[27];
int n, dp[200003][27];
char a[200003];

int main() {
	scanf("%s", a);
	n = (int)strlen(a);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		idx[a[i] - 'a'].push_back(i);
	}
	for (int i = 0; i < 26; i++) {
		sort(idx[i].begin(), idx[i].end());
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			if (!i) {
				if (idx[j].empty()) {
					putchar(j + 'a');
					return 0;
				}
				dp[i][j] = idx[j].front();
			} else {
				for (int k = 0; k < 26; k++) {
					auto it = upper_bound(idx[j].begin(), idx[j].end(), dp[i - 1][k]);
					if (it == idx[j].end()) {
						putchar('a' + j);
						int cur = *(--idx[j].end());
						for (int l = i - 1; l >= 0; l--) {
							for (int m = 0; m < 26; m++) {
								auto it = lower_bound(idx[m].begin(), idx[m].end(), cur);
								if (it == idx[m].begin()) {
									putchar('a' + m);
									return 0;
								} else if (*(--it) < dp[l][m]) {
									putchar('a' + m);
									cur = *it;
									break;
								}
							}
						}
						return 0;
					}
					dp[i][j] = max(dp[i][j], *it);
	//				debug("%d\n", dp[i][j]);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2176
N = int(input())

N -= 1
tmp = []
while N > -1:
    tmp.append(N % 26)
    N //= 26
    N -= 1
    if N == 0:
        tmp.append(0)
        break

res = ""
for t in tmp:
    res += chr(ord('a') + t)

print(res[::-1])

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int n;
	cin>>n;
	int kg=0;
	for (int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		if (a%2==0 && a%3 && a%5)  kg=1;
	}
	if (kg==0)  cout<<"APPROVED";
	else  cout<<"DENIED";
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> st;
    rep(i, 1, k + 1) {
        rep(j, 0, (int)s.size() - i + 1) {
            st.insert(s.substr(j, i));
        }
    }
    int cnt = 0;
    for (auto i : st) {
        cnt++;
        if (cnt == k) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll n, W;
	cin >> n >> W;
	vl v(n), w(n);
	ll s = 0;
	rep(i, n) {
		cin >> w[i] >> v[i];
		s += v[i];
	}

	vvl dp(2, vl(s + 1, inf));
	dp[0][0] = dp[1][0] = 0;

	FOR(i, 1, n)
		FOR(j, 1, s) {
			if (j >= v[i-1])
				dp[i%2][j] = min(dp[(i+1)%2][j], dp[(i+1)%2][j-v[i-1]] + w[i-1]);
			else 
				dp[i%2][j] = dp[(i+1)%2][j];
		}

	ll ans = 0;
	NFOR(i, s, 1)
		if (dp[n%2][i] <= W) {
			ans = i; 
			break;
		}

	cout << ans << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 99999997;
const ll cons = 100000000000;
const double pi = 3.141592653589793;



int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;

	int cur = 0;
	int passed = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'a')
		{
			if (passed < a + b)
			{
				passed++;
				puts("Yes");
			}
			else
			{
				puts("No");
			}
		}
		else if (s[i] == 'b')
		{
			cur++;

			if (cur <= b && passed < a + b)
			{
				passed++;
				puts("Yes");
			}
			else
			{
				puts("No");
			}
		}
		else
		{
			puts("No");
		}
	}


	return 0;
}

Measured memory_bytes: 896
/************************************
 TEMPLATE FOR PROGRAM COMPETITION
 ***********************************/
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>


long long int infty = 1e9;

int main(){
  
  // read problem
  long long int N, M, tmp1, tmp2, tmp_b;
  std::vector<long long int> a, key;
  
  scanf("%lld%lld", &N, &M);
  for(long long int i = 0; i < M; i++){
    scanf("%lld%lld", &tmp1, &tmp_b);
    a.push_back(tmp1);
    tmp2 = 0;
    for(long long int j = 0; j < tmp_b; j++){
      scanf("%lld", &tmp1);
      tmp2 += (1<<(tmp1-1));
    }
    key.push_back(tmp2);
  }
  
  // solve problem
  // dp[s][j] = the minimum cost to open the set of box "s" using the keys 1,2,..., j
  std::vector<std::vector<long long int> > dp(1<<N);
  for(long long int s = 0; s < (1<<N); s++){
    //dp[s].push_back(0);
    for(long long int i = 0; i < M+1; i++){
      dp[s].push_back(infty);
    }
  }
  
  for(long long int i = 0; i < M+1; i++){
    dp[0][i] = 0;
  }
  for(long long int i = 1; i <= M; i++){
    for(long long int s = 0; s < (1<<N); s++){
      dp[s][i] = std::min(dp[s][i-1], dp[s-(s&key[i-1])][i-1]+a[i-1]);
    }
  }
  
  /*for(long long int s = 0; s < (1<<N); s++){
    for(long long int i = 0; i <= M; i++){
      std::cerr << dp[s][i] << " ";
    }std::cerr << std::endl;
  }*/
  
  std::cerr << "Answer:" << std::endl;
  if(dp[(1<<N)-1][M] == infty){
    std::cout << -1 << std::endl;
  }
  else{
    std::cout << dp[(1<<N)-1][M];
  }
  
  return 0;
}


Measured memory_bytes: 33152
import collections
mod=10**9+7
p=int(input())
a=[int(i) for i in input().split()]
diff=collections.Counter(a)
def modpower(n):
    ret=1
    for k in range(n):
        ret=(2*ret)%mod
    return(ret)
if p==1:#one
    ans=1-bool(a[0])
elif p%2:#odd
    if all([diff[i]==2 for i in range(2,p,2)]) and diff[0]==1:
        ans=modpower(p//2)
    else:ans=0
else:#even
    if all([diff[i]==2 for i in range(1,p+1,2)]):
        ans=modpower(p//2)
    else:ans=0
print(ans)

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

#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define endl "\n"

#define for0(i, n) for (int i = 0; i < n; i++)
#define loop(i, a, b) for(int i = a;i <= b; i++)
#define forrev(i, n) for(int i = n; i >= 0; i--)
#define test_case(t) int t; cin >> t; while (t--)
#define debug(x) cout<< #x << "=" << x <<"\n";
#define debug(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n";

typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define prec(n) fixed<<setprecision(n)
#define inf (int)(1e18)
#define MAX 1000002
#define MOD 1e9 + 7

long long int max(long long int a,long long int b){if(a>b) return a; else return b;}
long long int min(long long int a,long long int b){if(a<b) return a; else return b;}
bool isPrime(int N){
    for(int i=2;i*i<=N;++i){
        if(N%i==0) return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin>>n;

    vi h(n);

    for(int &x : h)
        cin>>x;

    vi dp(n+1);

    dp[1] = 0;
    dp[2] = abs(h[1] - h[0]);

    for(int i = 3;i<=n;i++)
    {
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i-2]), dp[i-2] + abs(h[i-1] - h[i-3]));
    }

    cout<<dp[n]<<endl;

    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -O2 -Wno-unused-result



Measured memory_bytes: 3928
N,M = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
count = 0
judge = sumA / (4*M)
for i in range(len(A)):
  if A[i] >= judge:
    count += 1
if count < M:
  ans = "No"
else:
  ans = "Yes"
print(ans)

Measured memory_bytes: 9168
#include <algorithm>
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define repeat(n) for (int i = 0; i < n; i++)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) begin(a), end(a)
#define mp make_pair
#define pb push_back

template <typename T>
void debug0(const T &value) {
    cerr << value << endl;
}

template <typename T, typename... Args>
void debug0(const T &value, const Args &... args) {
    cerr << value << ' ';
    debug0(args...);
}

#ifdef LOCAL
#define debug(...) debug0(__VA_ARGS__)
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int n;
    cin >> n;
    auto a = vi(n);
    loop(a) {
        cin >> x;
    }

    bool finding_min = true;
    int min_price = a[0];
    int max_price = -1;
    ll money = 1000;
    rep(i, 1, n) {
        if (finding_min) {
            if (i > 0 && a[i] > a[i - 1]) {
                finding_min = false;
                max_price = a[i];
            } else {
                min_price = min(min_price, a[i]);
            }
        } else {
            if (i > 0 && a[i] < a[i - 1]) {
                debug("min", min_price, "max", max_price);
                auto stock = money / min_price;
                money += stock * (max_price - min_price);
                debug("money", money);

                finding_min = true;
                min_price = a[i];
                max_price = -1;
            } else {
                max_price = max(max_price, a[i]);
            }
        }
    }
    if (max_price > 0) {
        debug("min", min_price, "max", max_price);
        auto stock = money / min_price;
        money += stock * (max_price - min_price);
        debug("money", money);
    }
    cout << money << el;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;



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

  ll n, p;
  cin >> n >> p;

  map<ll, ll> mp;

  for(ll i = 2; i * i <= p; i++){
    while(p % i == 0){
      p /= i;
      mp[i]++;
    }
  }

  if(p != 1) mp[p]++;

  ll ans = 1;

  for(auto v : mp) ans *= pow(v.first, v.second / n);

  cout << ans << endl;

  return 0;
}


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

int main() {
  string s;
  cin>>s;
  int a=0;
  string t="CODEFESTIVAL2016";
  for(int i=0;i<16;i++)if(s[i]!=t[i])a++;
  cout<<a<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) rec(T[u].r, p);
	if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) r = i;
	}

	rec(r, 0);

	for (i = 0; i < n; i++) print(i);

	return 0;
}


Measured memory_bytes: 7724
#include <iostream>
#include <string.h>
using namespace std;

typedef struct {
	int top;
	int S;
	int E;
	int W;
	int N;
	int down;
} stDICEINFO;


#define MAX 110
#define DICEMAX 6
#define INPUTMAX 2

char* input(char *str, int size)
{
	char *c;
	fgets(str, size, stdin);
	if ((c=strchr(str,'\n')) != NULL) {
		*c = '\0';
	}

	return str;
}

int main(void)
{
	stDICEINFO stDice = {0,1,2,3,4,5};
	char str[MAX];
	long lInput[DICEMAX];
	long tmp;
	long num;
	char *c;
	int i,j;
	long lIn[INPUTMAX];
	int flg;

	(void)input(str, MAX);
	for (i=0; i<DICEMAX; i++) {
		if (i==0) {
			c = strtok(str," ");
		}
		else {
			c = strtok(NULL," ");
		}
		lInput[i] = strtol(c,NULL, 10);
	}
	num = strtol(input(str, MAX), NULL , 10);

	for (i=0; i<num; i++) {
		(void)input(str, MAX);
		for (j=0; j<2; j++) {
			if (j==0) {
				c = strtok(str," ");
			}
			else {
				c = strtok(NULL," ");
			}
			lIn[j] = strtol(c,NULL,10);
		}
		flg = 0;
		while (1) {
			if (flg == 1) {
				tmp			= stDice.S;
				stDice.S	= stDice.W;
				stDice.W 	= stDice.N;
				stDice.N 	= stDice.E;
				stDice.E 	= tmp;
			}
			else {
				if (flg == 0) {
					j = rand()%4;
				}
				else if (flg == 2) {
					j = 1;
				}
				switch(j) {
				case 0:
					tmp			= stDice.top;
					stDice.top	= stDice.N;
					stDice.N	= stDice.down;
					stDice.down	= stDice.S;
					stDice.S	= tmp;
					break;
				case 1:
					tmp			= stDice.top;
					stDice.top	= stDice.E;
					stDice.E	= stDice.down;
					stDice.down	= stDice.W;
					stDice.W	= tmp;
					break;
				case 2:
					tmp			= stDice.top;
					stDice.top	= stDice.S;
					stDice.S	= stDice.down;
					stDice.down	= stDice.N;
					stDice.N	= tmp;
					break;
				case 3:
					tmp			= stDice.top;
					stDice.top	= stDice.W;
					stDice.W	= stDice.down;
					stDice.down	= stDice.E;
					stDice.E	= tmp;
					break;
				default:
					break;
				}
			}
			if (lInput[stDice.top] == lIn[0]) {
				flg = 1;
				if (lInput[stDice.S] == lIn[1]) {
					flg = -1;
				}
			}
			else if (lInput[stDice.S] == lIn[1]) {
				flg = 2;
				if (lInput[stDice.top] == lIn[0]) {
					flg = -1;
				}
			}
			if (flg == -1) {
				break;
			}
		}
		printf("%ld\n", lInput[stDice.E]);
	}

	return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    int n;
    bool flag = false;
    cin >> n;

    rep(i,10){
        rep(j,10){
            if(n==i*j){
                flag = true;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long int calc(long long int n){
    if(n < 0){
        return 0;
    }
    n++;
    long long int dst = 0;
    for(long long int i=40; i>=0; i--){
        long long int t = 1LL << (i+1);
        long long cnt = (n/t)*(t/2);
        if(n%t - t/2 > 0){
            cnt += n%t - t/2;
        }
        if(cnt%2){
            dst += 1LL << i;
        }
    }
    return dst;
}

int main(){
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    long long int ans = calc(b) ^ calc(a-1);
    printf("%lld", ans);
    //printf(" %lld %lld", calc(b), calc(a-1));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	set<string> s;
	cin >> n;
	REP(i, n) {
		string a;
		cin >> a;
		s.insert(a);
	}
	cout << (ll)s.size() << endl;
}


Measured memory_bytes: 19200
# -*- coding: utf-8 -*-

N = int(input())
An = list(map(int, input().split()))

def sunuke(An,b):
    ret = 0
    for i,Ai in enumerate(An):
        ret += abs(Ai - (b + i + 1))

    return ret

sAn = []
for i,Ai in enumerate(An):
     sAn.append(Ai - (i+1))

sAn.sort()

if N % 2 == 0:
    #偶数の場合
    center_idx1 = N // 2 - 1
    b1 = sAn[center_idx1]
    center_idx2 = center_idx1 + 1
    b2 = sAn[center_idx2]
    # print(b1,b2)
    print(min([sunuke(An,b1),sunuke(An,b2)]))
else:
    #奇数の場合
    center_idx = (N+1) // 2 - 1
    b = sAn[center_idx]
    # print(b)
    print(sunuke(An,b))


Measured memory_bytes: 25744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int w[123]={};

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", w+i+1);
	REP(i, n) w[i+1]+=w[i];
	int ans = INT_MAX;
	FOR(i, 1, n+1){
		SML(ans, abs((w[n]-w[i])-(w[i]-w[0])));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, m;
	cin >> n >> m;
	if(n > m) swap(n, m);
	if(n == 1){
		if(m == 1) cout << 1 << endl;
		else cout << m - 2 << endl;
	} else {
		cout << (n - 2) * (m - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	
	double mx = 0;
	int ans1 = 100 * a, ans2 = 0;
	for (int i = 0; i <= 30; i += a) {
		for (int j = 0; j <= 30; j += b) {
			for (int k = 0; k <= 3000; k += c) {
				for (int l = 0; l <= 3000; l += d) {
					int w = 100 * (i + j);
					int s = k + l;
					if (w + s > f || s > w * e / 100.0 || w + s == 0)
						continue;
					double noud = s * 100.0 / (w + s);
					if (mx < noud) {
						mx = noud;
						ans1 = w + s;
						ans2 = s;
					}
				}
			}
		}
	}

	cout << ans1 << " " << ans2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
 
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}
 
void skip(int k) { while (k--) gc(); }
 
void out(int n)
{
	int i;
	char ob[20];
 
	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}
 
int que[1500005]; int top, end;
 
int main()
{
	int n, i, t;
	char op;
 
	n = in(); top = 0, end = 1;
	while (n--) {
		if (gc() == 'i') {
			skip(6);
			que[end++] = in();
		} else {
			skip(5);
			op = gc();
			if (op == 'L') {
				skip(4);
				top++;
			} else if (op == 'F') {
				skip(5);
				end--;
			} else {
				que[top] = t = in();
				i = end; while (que[--i] != t);
				if (i > top) {
					if (end - i < i - top) {
						while (++i < end) que[i-1] = que[i];
						end--;
					} else {
						while (--i > top) que[i+1] = que[i];
						top++;
					}
				}
			}
		}
	}
	i = end-1; out(que[i--]);
	while (i > top) pc(' '), out(que[i--]);
	pc('\n');
	return 0;
}



Measured memory_bytes: 5476
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    station = input.split("");
    if (station[0] == station[1] && station[1] == station[2]) {
        console.log("No");
    } else {
        console.log("Yes");
    }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
s = input()
s = s[::-1]
part = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
i = 0
while(1):
    ok = False
    for p in part:
        if s[i:i+len(p)] == p:
            i += len(p)
            ok = True
            break
    if ok == False or i == len(s):
        break
print('YES' if ok else 'NO')  
    

Measured memory_bytes: 3188
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val (n, x) = longList()
    val a = longList()
    var p = 0L
    var e = 0L
    repeat(n.toInt()) { i ->
        val aa = a[i]
        if (aa + p > x) {
            val d = aa + p - x
            e += d
            p = aa - d
        } else {
            p = aa
        }
    }
    println(e.toString())
}


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

typedef long long ll;

int main() {
    int N, A, B, ans = 0;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        int t = 0;
        rep(j, s.size()) {
            t += s[j] - '0';
        }
        if (A <= t && t <= B) ans += i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    print(NO if S[0] == S[1] and S[1] == S[2] else YES)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define e1 first
#define e2 second
#define int int_fast32_t
#define uint uint_fast64_t
#define ll int_fast64_t
#define ull uint_fast64_t
#define int16 int_fast16_t
#define uint16 uint_fast16_t
#define int32 int_fast32_t
#define uint32 uint_fast32_t
#define int64 int_fast64_t
#define uint64 uint_fast64_t
#define ld long double
#define float long double
#define size(x) (int)x.size()
#define satori int testCases; cin>>testCases; while(testCases--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(r) begin(r),end(r)
#define rall(r) rbegin(r),rend(r)
#define time chrono::high_resolution_clock().now().time_since_epoch().count()
#define elapsed(__begin,__end) (__end-__begin)/CLOCKS_PER_SEC
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
float pi=3.14159265358979323846;

const int MAXN=4e2+10;
const ll inf=1e18+2137;

ll dp[MAXN][MAXN],w[MAXN][MAXN];

int32_t main()
{
	fastio;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>w[i][i];
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			w[i][j]=w[i][j-1]+w[j][j];
	for(int l=2;l<=n;l++)
		for(int i=1;i+l-1<=n;i++)
		{
			dp[i][i+l-1]=inf;
			for(int m=i;m<i+l-1;m++)
				dp[i][i+l-1]=min(dp[i][i+l-1],dp[i][m]+dp[m+1][i+l-1]+w[i][m]+w[m+1][i+l-1]);			
		}
	cout<<dp[1][n]<<'\n';
}

Measured memory_bytes: 6208
n = int(input())
s = input()
alp = [chr(ord('A') + i) for i in range(26)]
res = ''
for si in s:
    index = 0
    for i in range(len(alp)):
        if si == alp[i]:
            index = i
    res += alp[(index + n) % len(alp)]
print(res)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
int arr[401], dp[401][401];
int n;
int prefix[401];

int util(int s, int e){

	if(s>=e) return 0;

	if(dp[s][e]!=-1) return dp[s][e]; 

	int ans=INF;
	loop(i, s, e){
		ans = min(ans, util(s, i) + util(i+1, e) + (prefix[e]-(s==0?0:prefix[s-1])));
	}

	return dp[s][e] = ans;
}

void alpha()
{	
	memset(dp, -1, sizeof(dp));

	cin>>n;

	loop(i,0,n) cin>>arr[i];

	prefix[0] = arr[0];
	loop(i,1,n){
		prefix[i] = prefix[i-1]+arr[i];
	}

	cout<<util(0, n-1)<<endl;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
       int N = std.nextInt();
       int[] V = IntStream.range(0, N).map(it -> std.nextInt()).toArray();
       int[] C = IntStream.range(0, N).map(it -> std.nextInt()).toArray();
       Integer ans = 0;
       for (int i = 0; i < N; i++) {
           Integer v = V[i];
           Integer c = C[i];
           Integer res = v - c;
           if (res > 0) {
               ans += res;
           }
       }

       System.out.println(ans);
    }
}


Measured memory_bytes: 26832
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}


int main(){
  int p,q,r;cin>>p>>q>>r;
  cout<< p+q+r-max({p,q,r})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
int gcd(int a,int b){
  while(true){
    if(a<b) swap(a,b);
    if(!b) break;
    a%=b;
  }
  return a;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  itn n,sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      int q=gcd(i,j);
      for(int k=1;k<=n;k++){
        sum+=gcd(q,k);
      }
    }
  }
  cout<<sum<<"\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n/gcd(n,m)){
        int ma = 0,mi = INF;
        rep(j,m){
            ma = max(ma, a[(i*m+j)%n]);
            mi = min(mi, a[(i*m+j)%n]);
        }
        ans += ma-mi;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3112
#include<stdio.h>
#include<string.h>

int main(){
  int h,w,i,j,b[111]={},t;
  char a[111][111];
  scanf("%d%d",&h,&w);
  t=h;
  for(i=0;i<h;i++) {
    scanf("%s",a[i]);
    if(strchr(a[i],'#')==0){
      i--;
      h--;
    }
    for(j=0;j<w;j++){
      if(a[i][j]=='#') b[j]++;
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(b[j]!=0) printf("%c",a[i][j]);
    }
    printf("\n");
  }
}

Measured memory_bytes: 128
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int[] array = new int[n+1];
      int[] freq = new int[n+1];
      
      for(int k = 2; k <= n; k++){
         array[k] = Integer.parseInt(st.nextToken());
         freq[array[k]] ++;
      }
      
      
      for(int k = 1; k <= n; k++){
         out.println(freq[k]);
      }
      
      
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 55984
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli arr[100000] = {};


int main(void) {

	lli n, k, q;
	cin >> n >> k >> q;

	for (int i = 0; i < q; i++) {
		lli a;
		cin >> a;

		arr[a - 1]++;
	}


	for (int i = 0; i < n; i++) {
		if (k + arr[i] - q > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int n,a,b;
  cin >>n>>a>>b;
  
  cout << min(a*n,b) << endl;
  
  
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/
int powm(int a, long long n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return mul(a, powm(a, n - 1));
	}
	else {
		return powm(mul(a, a), n / 2);
	}
}

void solve() {
    int x;
    cin >> x;
    if (x == 1) {cout << 0; return;}
    if (x == 2) {cout << 2; return;}
    int ans = powm(10, x);
    ans = sub(ans, powm(9, x));
    ans = sub(ans, powm(9, x));
    ans = add(ans, powm(8, x));
    cout << ans << endl;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(10);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3604
A, B, C = map(int, input().split())

cnt = 0
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print(cnt)
elif A == B == C:
        cnt = -1
        print(cnt)
else:
    while True:
        a, b, c = A, B, C
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            break
        A, B, C = (b + c) / 2, (a + c) / 2, (a + b) / 2
        cnt += 1
    
    print(cnt)

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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int a,b,c,d;
bool A,B;
int ans=0;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>a>>b>>c>>d;
    rep(i,0,101){
        if(i==a)A=true;
        if(i==b)A=false;
        if(i==c)B=true;
        if(i==d)B=false;
        if(A&&B)ans++;
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int a=0;
  a=N/1000;
  int b;
  b=(a+1)*1000-N;
  if(N%1000==0)
  {cout<<0;}
  else{cout<<b;}
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 24;
int h, w;
string s[maxn];
int dist[maxn][maxn][maxn][maxn];

int main() {
#ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int p = 0; p < h; p++) {
        for (int q = 0; q < w; q++) {
          int d = abs(i - p) + abs(j - q);
          if (d == 0) dist[i][j][p][q] = 0;
          else if (d == 1) {
            if (s[i][j] == '#' || s[p][q] == '#') {
              dist[i][j][p][q] = 1e9;
            } else {
              dist[i][j][p][q] = 1;
            }
          } else {
            dist[i][j][p][q] = 1e9;
          }
        }
      }
    }
  }

  for (int ki = 0; ki < h; ki++) {
    for (int kj = 0; kj < w; kj++) {
      for (int ai = 0; ai < h; ai++) {
        for (int aj = 0; aj < w; aj++) {
          for (int bi = 0; bi < h; bi++) {
            for (int bj = 0; bj < w; bj++) {
              dist[ai][aj][bi][bj] = min(dist[ai][aj][bi][bj], dist[ai][aj][ki][kj] + dist[ki][kj][bi][bj]);
            }
          }
        }
      }
    }
  }

  int ans = 0;
  for (int ai = 0; ai < h; ai++) {
    for (int aj = 0; aj < w; aj++) {
      for (int bi = 0; bi < h; bi++) {
        for (int bj = 0; bj < w; bj++) {
          int d = dist[ai][aj][bi][bj];
          if (d != 1e9) ans = max(ans, d);
        }
      }
    }
  }
  cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    a.emplace(a.begin(), 0);
    a.emplace(a.end(), 0);
    n += 2;
    auto d = [&](int i, int j) {
        return abs(a[i] - a[j]);
    };
    int sum = 0;
    for (int i = 0; i + 1 < n; i++) sum += d(i, i + 1);
    for (int i = 1; i + 1 < n; i++) {
        cout << sum - d(i - 1, i) - d(i, i + 1) + d(i - 1, i + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 1656
n,x,y = map(int, input().split())

count = [0]*(n-1)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        d_min = min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        count[d_min-1] += 1

for i in count:
    print(i)

Measured memory_bytes: 3444
#if 0 

#endif
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll N, K;
ll X[100000+10], A[100000+10];
ll solve() {
    sort(A, A + N - 1);
    ll ans = 0;
    if (N - K > 0) {
        for (int i = 0; i < N - K; ++i) {
            ans += A[i];
        }
    }

    return ans;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    #define ll int;

    int t;
    cin >> t;
    for (t; t > 0; --t) {
        cin >> N >> K;
        for (int i = 0; i < N; ++i) cin >> X[i];
        for (int i = 0; i + 1 < N; ++i) A[i] = X[i + 1] - X[i];
        cout << solve() << endl;
    }

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m; const int MOD=1e9+7;
ll f[3333][3333][2];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;++i) f[0][i][0]=1;
	for(int i=1;i<=m;++i)
	{
		for(int j=0;j<=n;++j)
		{
			for(int s=0;s<2;++s)
			{
				for(int k=0;k<2;++k)
				{
					for(int p=0;p<2;++p)
					{
						int ss=s;
						int a[2]={j,n-j};
						if(!a[k]) continue;
						--a[k]; if(!a[0]) ss=1;
						++a[0]; ++a[1];
						--a[p]; if(!a[0]) ss=1;
						(f[i][a[0]][ss]+=f[i-1][j][s])%=MOD; 
					}
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<=n;++i)
		ans+=f[m][i][1];
	cout<<ans%MOD<<"\n";
}


Measured memory_bytes: 157952
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

int n,a,b;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    if (n==1) cout << "Hello World";
    else
    {
        cin >> a >> b;
        cout << a+b;
    }
}


Measured memory_bytes: 256
n,m = map(int,input().split())

py = [[] for _ in range(m)]
"""
for i in range(m):
    py.append(input().split())
"""    
for i in range(m):
    a, b = map(lambda x: int(x), input().split())
    py[i].append([a,b,i])
#py = [ [ int(i) for i in input().split() ]  for j in range(m)]
#table = [[int(i) for i in input().split()] for m in range(m)]


#print(py)

py.sort()

#print(py)

ken = 1
city = 1

for i in range(m):
    if py[i][0][0] == ken:
        py[i][0][1] = city
        city += 1
    else:
        ken = py[i][0][0]
        city = 1
        py[i][0][1] = city
        city += 1
        
#print(py)

py.sort(key=lambda x: x[0][2])

#print(py)

for i in range(m):
    print('{:0=6}{:0=6}'.format(py[i][0][0],py[i][0][1]))

Measured memory_bytes: 35708