akhauriyash/Code-Regression huggingface dataset:
n,m = [int(x) for x in input().strip().split()]
par = list(range(n))
rank = [0]*n

def find(x):
  if par[x]==x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x,y):
  x,y = map(find, (x,y))
  if x==y:
    return
  if rank[x]<rank[y]:
    par[x] = y
  else:
    par[y] = x
    if rank[x]==rank[y]:
      rank[x]+=1

def same(x,y):
  return find(x)==find(y)

p = [int(x) for x in input().strip().split()]
for _ in range(m):
  x,y = [int(z)-1 for z in input().strip().split()]
  unite(x,y)

p = sorted([(z,i) for i,z in enumerate(p)], reverse=True)
print(sum([same(val-1,idx) for val,idx in p]))

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int n;
	cin >> n;
	n%=10;
	string ans;
	if(n == 6 || n == 0 || n == 1 || n == 8){
		ans = "pon";
	}
	else if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
		ans = "hon";
	} else {
		ans = "bon";
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for ( int i = 0; i < (n); ++i )
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long int;
const long long int INF = 1001001001001001LL;
const int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;


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

    string s;
    cin >> s;
    rep(i, s.size()) cout << 'x';
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
f = 0
if l <= 9:
    for i in range(1 << l + 1):
        ans = ""
        for j in range(l + 1):
            if i >> j & 1: ans += 'A'
            if j < l: ans += s[j]
        if ans == "AKIHABARA":
            f = 1
else: f = 0

if f: print("YES")
else: print("NO")


Measured memory_bytes: 9100
#include <iostream>
#include <functional>
#include <map>

using namespace std;
typedef long long ll;
const int MAXN = 100010;
int n;

map<ll, int, greater<ll> > m;

void solve() {
  ll first = 0;
  ll second = 0;
  for (auto& p : m) {
    if (p.second > 3) {
      if (first != 0) {
        second = p.first;
      } else {
        first = second = p.first;
      }
      break;
    }
    if (p.second > 1) {
      if (first == 0) {
        first = p.first;
      } else {
        second = p.first;
        break;
      }
    }
  }
  cout << (first * second) << endl;
}

int main() {
  ll a;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a;
    m[a]++;
  }
  solve();
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int n,k;cin>>n>>k;
    vector<ll> vec(k,0);
    for(int i=1;i<=n;i++){
        vec[i%k]++;
    }
    ll ans=0;
    ans+=vec[0]*vec[0]*vec[0];


    if(k%2==0){
        ans+=vec[k/2]*vec[k/2]*vec[k/2];
    }

    cout<<ans<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    string S;
    cin >> N >> S;

    ll ans = 0;
    Rep (i, N) {
        if (S.substr(i, 3) == "ABC") {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	set<string> s;
	while(n--)
	{
		string g;
		cin >> g;
		s.insert(g);
	}

	cout << s.size();

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 19204
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int n, m, cnt[200100], a[200100], b[200100], ans, x, y;

int main() {
	scanf("%d%d", &n, &m);
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		cnt[x]++;
		if(x - cnt[x] + 1 > 0) {
			if(b[x - cnt[x] + 1]) ans++;
			b[x - cnt[x] + 1]++;
		} else ans++;
		a[i] = x;
	}
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &x, &y);
		if(a[x] - cnt[a[x]] + 1 > 0) {
			if(b[a[x] - cnt[a[x]] + 1] == 1) ans++;
			b[a[x] - cnt[a[x]] + 1]--;
		}
		cnt[a[x]]--;
		a[x] = y;
		cnt[y]++;
		if(y - cnt[y] + 1 > 0) {
			if(!b[y - cnt[y] + 1]) ans--;
			b[y - cnt[y] + 1]++;
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B,C,D;
 cin >> A >> B >> C >> D;
 if(A + B > C + D){
 cout << "Left" << endl;
 }
 else if(A + B < C + D){
 cout << "Right" << endl;
 }
 else{
 cout << "Balanced" << endl;
 }  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC144 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for i in range(1,10):
    for j in range(1,10):
        if i*j == n:
            print('Yes')
            quit()
print('No')

Measured memory_bytes: 38256
N, M = list(map(int, input().split()))

C = []
for i in range(M):
    P, Y = list(map(int, input().split()))
    C.append((i, P, Y))
C = sorted(C, key=lambda x:x[1])

K, L = [], []
p = C[0][1]
for c in C:
    if c[1]!=p:
        p = c[1]
        L += [ (k[0], k[1], i+1) for i, k in enumerate(sorted(K, key=lambda x:x[2]))]
        K = []

    K.append(c)

L += [ (k[0], k[1], i+1) for i, k in enumerate(sorted(K, key=lambda x:x[2]))]

for l in sorted(L, key=lambda x:x[0]):
    print('{:06d}{:06d}'.format(l[1],l[2]))

Measured memory_bytes: 36024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n, m;
	cin >> n >> m;
	int a, b;
	vPi t;
	vi x, y;
	rep(i, m) {
		cin >> a >> b;
		//t.push_back(mp(a, b));
		if (a == 1) {
			x.push_back(b);
		}
		if (b == n) {
			y.push_back(a);
		}
	}
	sort(all(x));
	sort(all(y));
	rep(i, x.size()) {
		if (binary_search(all(y), x[i])) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	//sort(all(t));
	/*
	rep(i, m) {
		if (t[i].first == 1) {
			repr(j, i, m) {
				if (t[i].second == t[j].first && t[j].second == n) {
					cout << "POSSIBLE" << endl;
					return 0;
				}
			}
		}
	}
	//*/
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template<int MOD>
struct ModInt {
  ll x;
  ModInt():x(0){}
  ModInt(ll x):x((x%MOD+MOD)%MOD){}
  int getMod() { return MOD; }
  ModInt operator-() const { return ModInt(0) - *this;}
  ModInt& operator+=(const ModInt& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator-=(const ModInt& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator*=(const ModInt& a){ (x*=a.x)%=MOD; return *this;}
  ModInt operator+(const ModInt& a)const{ return ModInt(*this) += a;}
  ModInt operator-(const ModInt& a)const{ return ModInt(*this) -= a;}
  ModInt operator*(const ModInt& a)const{ return ModInt(*this) *= a;}
  bool operator<(const ModInt& a)const{ return x < a.x;}
  bool operator==(const ModInt& a)const{ return x == a.x;}
  ModInt pow(ll t) const {
    if (!t) return 1;
    ModInt a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  friend istream & operator >> (istream & in, ModInt & v) {
    ll x;
    in >> x;
    v.x = x;
    return in;
  }
  friend ostream & operator << (ostream & out, ModInt<MOD> const & v) {
    out << v.x;
    return out;
  }
};
const int MOD = 1000000007;
using mint = ModInt<MOD>;

typedef pair<ll, ll> P;

int main() {
  int n; cin >> n;
  map<P, int> M;
  int zero2 = 0, a_zero = 0, b_zero = 0;
  loop(i,0,n) {
    ll a, b; cin >> a >> b;
    if (a == 0 and b == 0) {
      M[make_pair(0, 0)]++;
      continue;
    }

    if (a == 0) {
      M[make_pair(0, 1)]++;
      continue;
    }

    if (b == 0) {
      M[make_pair(1, 0)]++;
      continue;
    }

    ll gc = __gcd(abs(a), abs(b));
    a /= gc, b /= gc;
    if (b < 0) a *= -1, b *= -1;
    M[make_pair(a, b)]++;
  }

  mint ans = mint(2).pow(M[make_pair(0, 1)]) + mint(2).pow(M[make_pair(1, 0)]) - 1;
  set<P> S;
  for (auto &&m: M) {
    if (m.first.first == 0 or m.first.second == 0) continue;
    if (S.count(m.first)) continue;
    ll count = m.second;
    ll a = m.first.first, b = m.first.second;
    ll a2 = -b, b2 = a;
    if (b2 < 0) a2 *= -1, b2 *= -1;
    ll count2 = M[make_pair(a2, b2)];
    if (count2 > 0) {
      ans *= mint(2).pow(count) + mint(2).pow(count2) - mint(1);
    } else {
      ans *= mint(2).pow(count);
    }
    S.insert(make_pair(a2, b2));
  }

  ans += M[make_pair(0, 0)];
  ans -= 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 41036
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#define mod 1000000007

using namespace std;

int main()
{
    int N, i, K, total;

    scanf("%d%d", &N, &K);

    total = 0;
    for(i = K; i <= N + 1; ++i){
        total += (N + 1 - i) * 1LL * i % mod + 1;
        total %= mod;
    }

    printf("%d", total);

    return 0;
}


Measured memory_bytes: 1712
import sys
sys.setrecursionlimit(10 ** 6)
n, m =map(int,input().split())
lis={0:1,1:1}
for _ in range(m):
  lis[int(input())]=0 
def saiki(x):
  if x not in lis:
        d=saiki(x-1)+saiki(x-2)
        if d >10**9+7:
          lis[x]= d % (10**9+7)
          return lis[x]
        else:
          lis[x]=d
          return d
  else:
    return lis[x]
      
print(saiki(n))



Measured memory_bytes: 98284
import math
from collections import defaultdict

def isPrime(num):
    prime = True
    save = num
    save2 = None
    for i in range(2, int(math.sqrt(num))+1):
        if num % i == 0:
            prime = False
            save = i
            save2 = num // i
            break
    return prime, save, save2

store = defaultdict(int)

def solve(num):
    check, num1, num2 = isPrime(num)
    if check == True:
        global store
        store[num1] += 1
    if check == False:
        solve(num1)
        solve(num2)

n = int(input())
if n <= 1:
    print(0)
else:
    count = 0
    solve(n)
    for key, v in store.items():
        for i in range(1, v+1):
            if store[key] >= i:
                store[key] -= i
                count += 1
            else:
                break
    print(count)


Measured memory_bytes: 9484
#include<stdio.h>
char dp[5][1<<15][182];
int main(){
	dp[0][0][0]=1;
	for(int i=0;i<(1<<15)-1;i++){
		for(int j=0;j<182;j++){
			for(int k=0;k<4;k++){
				//printf("%d %d %d %d\n",i,j,k,dp[k][i][j]);
				if(dp[k][i][j]){
					for(int l=j;;l++){
						if(i+l*l<(1<<15))dp[k+1][i+l*l][l]+=dp[k][i][j];
						else break;
					}
				}
			}
		}
	}
	int a;
	while(scanf("%d",&a),a){
		int ret=0;
	//	for(int i=0;i<5;i++){
			for(int j=0;j<182;j++)
				ret+=(int)dp[4][a][j];
		//}
		printf("%d\n",ret);
	}
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;
static const long long mod = 1000000007;

ll test(ll h, ll w){
  ll ret = INF;
  repLRE(i, 1, h-1){
    ll s1 = i*w;
    ll s2 = (h - i)/2*w;
    ll s3 = h*w - s1 - s2;
    ll Mv = max({s1, s2, s3});
    ll mv = min({s1, s2, s3});
    chmin(ret, Mv - mv);
  }
  repLRE(i, 1, h-1){
    ll s1 = i*w;
    ll s2 = (h - i)*(w/2);
    ll s3 = h*w - s1 - s2;
    ll Mv = max({s1, s2, s3});
    ll mv = min({s1, s2, s3});
    chmin(ret, Mv - mv);
  }
  return ret;  
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;

  ll ans = INF;
  chmin(ans, test(h, w));
  chmin(ans, test(w, h));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

int main() {
    ll N;
    cin >> N;
    ll d[N][N] ={};
    for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        if(i ==j){
            continue;
        }
        d[i][j] = INF;
    }
    vector<string> S;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        S.push_back(s);
        for(int j=0;j<N;j++){
            if(s[j] == '1'){
                d[i][j] = 1;
            }
            
        }
    }

    for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
    }

    
    for(int i=1;i<N;i++)for(int j=1;j<N;j++){
        if(d[0][i] == d[0][j] && S[i][j] =='1'){
            // cerr <<"i="<<i <<"j=" <<j << "d=" << d[0][i] << endl;
            cout << -1 << endl;
            return 0;
        }
    }

    ll maxDist = -1;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        maxDist = max(maxDist,d[i][j]);
    }
    cout << maxDist +1<< endl;



    return 0;
}

Measured memory_bytes: 4008
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int xor_sum = 0;
    REP(i, n) xor_sum ^= a[i];
    vector<int> ans(n);
    REP(i, n) {
        REP(j, 32) {
            if (a[i] & (1 << j) && xor_sum & (1 << j)) ans[i] &= ~(1 << j);
            else if (a[i] & (1 << j) && !(xor_sum & (1 << j))) ans[i] |= (1 << j);
            else if (!(a[i] & (1 << j)) && xor_sum & (1 << j)) ans[i] |= (1 << j);
            else ans[i] &= ~(1 << j);
        }
    }
    cout << ans[0];
    for (int i = 1; i < n; i++) cout << " " << ans[i];
    cout << endl;
}

Measured memory_bytes: 4820
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static long GCD(long x,long y){
    if (y == 0){return x;
    } else{
       return GCD(y, x % y);
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long temp=0;
      for(long a=1;a<=N;a++){
        for (long b=1;b<=N ;b++) {
           for(long c=1;c<=N;c++){

            Sum+=GCD(GCD(a,b),c);
          }
        }
      }





    System.out.println(Sum);

  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;    
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (n == i*j) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
N = int(input())
graph = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
# これによって木が定義できた
# print(graph)

flag = [None for _ in range(N)]  # まだどの頂点も探索していない


def k(v, distance):  # distanceは0or1
    flag[v] = distance  # 最初は0

    for next_v, w in graph[v]:
        if flag[next_v] == 1 or flag[next_v] == 0:  # 到達済み（親）であればcontinue
            continue
        if (w % 2) == 0:  # そのノードへの距離が偶数であればそのまま（最初は0なので）
            k(next_v, distance)
        else:
            k(next_v, 1-distance)


k(0, 0)  # 親を強制的に決めてよい, この場合は0のノードを親にしている
for i in range(N):
    print(int(flag[i]))


Measured memory_bytes: 79488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++)
      par[i] = i;
    sz.resize(n, 1);
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  if (m == n-1) {
    cout << 0 << endl;
    return 0;
  }
  UnionFind uf(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }
  map<int, vector<int>> mp;
  rep(i, n)
    mp[uf.root(i)].push_back(a[i]);
  for (auto& e : mp)
    sort(e.second.begin(), e.second.end());
  ll ans = 0;
  vector<int> node;
  for (auto e : mp) {
    ans += e.second[0];
    for (int i = 1; i < (int)e.second.size(); i++)
      node.push_back(e.second[i]);
  }
  if (node.size() < (n-1)*2-m*2-(int)mp.size()) {
    cout << "Impossible" << endl;
    return 0;
  }
  sort(node.begin(), node.end());
  rep(i, (n-1)*2-m*2-(int)mp.size())
    ans += node[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15336
// think twice code once
// Start:
// End  :
#include <bits/stdc++.h>
using namespace std;

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); T f = 1; a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}

template <class T> void write(T a) {
	static int stk[60]; 
	int tp = 0;
	if(a < 0) putchar('-'), a = -a;
	do {
		stk[++ tp] = a % 10;
		a /= 10;
	}while(a);
	
	while(tp) putchar(stk[tp--] + '0');
}

const int maxN = 2e5 + 5;

typedef pair<int, int> pii;

int fa1[maxN];
int fa2[maxN];
int sz[maxN];
int N;
int M;
vector<int> lala[maxN];

int get_f1(int x) { return fa1[x] == x ? x : fa1[x] = get_f1(fa1[x]); }
int get_f2(int x) { return fa2[x] == x ? x : fa2[x] = get_f2(fa2[x]); }

bool cmp(const int& a, const int& b) {
	return get_f2(a) < get_f2(b);
}

int main() {
#ifdef Leeson
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	int K;
	read(N);
	read(M);
	read(K);
	rep(i, 1, N) {
		fa1[i] = fa2[i] = i;
	}
	rep(i, 1, M) {
		int u, v;
		read(u); read(v);
		
		fa1[get_f1(u)] = get_f1(v);
	}

	rep(i, 1, K) {
		int u, v;
		read(u), read(v);

		fa2[get_f2(u)] = get_f2(v);
	}

	rep(i, 1, N) {
		lala[get_f1(i)].push_back(i);
//		disp(i), disp(get_f1(i)), puts("");
	}

	rep(i, 1, N) if(lala[i].size()) {
		sort(lala[i].begin(), lala[i].end(), cmp);
		int last = 0;
//		rep(j, 0, lala[i].size() - 1)
//			printf("%d ", lala[i][j]); puts("");
		rep(j, 1, lala[i].size() - 1) {
			if(get_f2(lala[i][j]) != get_f2(lala[i][j - 1])) {
				int haha = j - 1 - last + 1;
				rep(k, last, j - 1)
					sz[lala[i][k]] = haha;

				last = j;
			}

		}

		int haha = lala[i].size() - 1 - last + 1;
		rep(j, last, lala[i].size() - 1) {
			sz[lala[i][j]] = haha;
		}
	}

	rep(i, 1, N) printf("%d ", sz[i]);

	puts("");
	return 0;
}


Measured memory_bytes: 13312
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug() << imie(x) imie(y)
//debugging ends
typedef long long ll;

int solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(k < x/d){
      cout<<abs(x-d*k);
      return 0;
    }
    k-=x/d;
    x%=d;
    if(x>=d){
      if(x%d>0){
      cout<<x%d;
      }else{
        if(k%2==0){
          cout<<x%d;
        }else{
          cout<<min(x,d);
        }
      }
    }else{
      if(k%2==0){
          cout<<x%d;
        }else{
          cout<<d-x;
        }
    }
    
    
    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}


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

int main() {
    int ans = 0;
    int N, M;
    cin >> N >> M;
    vector<int> v(N, 0);
    int p;
    string s;
    for(int i = 0; i < M; i++) {
        cin >> p >> s;
        p--;
        if(s == "AC" && v.at(p) != -1) {
            ans += v.at(p);
            v.at(p) = -1;
        } else {
            if(v.at(p) != -1)
                v.at(p)++;
        }
    }
    cout << count(v.begin(), v.end(), -1) << " " << ans << endl;
}

Measured memory_bytes: 640
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function upper_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<=e?a=c:b=c;return d[a]<=e?b:a};

console.log(main());
function main(){
  var n = o.a();
  var q = o.a();
  var s= o.a(1);
  var b = Array(n+1).fill(0), a = 0;
  for(var i = 0; i < n; i++){
    b[i+1] = b[i];
    if(a && s[i] === "C")b[i+1]++;
    if(s[i] === "A")a = 1;
    else a = 0;
  }
  var ans = Array(q);
  for(i = 0; i < q; i++){
    var t = o.l(), l = t[0], r = t[1];
    ans[i] = b[r] - b[l];
  }
  return ans.join("\n");
}

Measured memory_bytes: 35492
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll h, w; cin >> h >> w;
	if(h>w)swap(h,w);
	if(h==1){
		cout << 1 << endl;
	}
	else if(h%2==0){
		cout << (h/2)*w << endl;
	}
	else{
		if(w%2==0){
			cout << h*(w/2) << endl;
		}
		else{
			cout << h*(w/2)+((h+1)/2) << endl;
		}
	}
	return 0;
}

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

int main()
{
  int N,X;
  cin >> N >> X;
  
  vector<int> m(N);
  for(int i = 0; i < N; i++){
    cin >> m.at(i);
  }
  
  int kindsum = 0;
  for(int i = 0; i < N; i++){
    kindsum += m.at(i);
  }
  X -= kindsum;
  
  sort(m.begin(),m.end());
  int count = X / m.at(0);
  
  cout << count + m.size() << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int ABS(int n){
    if (n < 0){
        n = -1 * n;
    }
    return n;
}

int main(){
    int N; cin >> N;
    vector <int> A(N+2);

    int sum = 0;
    for (int i = 1; i <= N; i++){
        cin >> A[i];
        sum += ABS(A[i] - A[i-1]);
    }
    sum += ABS(A[N]);
    
    for (int i = 1; i <= N; i++){
        int deg = ABS(A[i - 1] - A[i + 1]) - ABS(A[i - 1] - A[i]) - ABS(A[i] - A[i + 1]);
        cout << sum + deg << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, q;
	cin >> n >> q;

	string in;
	cin >> in;

	vector<int> cnt(n);
	cnt[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		if (in[i] == 'A' && in[i + 1] == 'C') {
			cnt[i+1] = cnt[i] + 1;
		}
		else cnt[i+1] = cnt[i];
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;

		cout << (cnt[r] - cnt[l]) << endl; 
	}

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
class trans {
	public:
	string str;
	void print(int a, int b) {
		for (int i = a; i < b + 1; i++){
			cout << str[i];
		}
		cout << endl;
	}
	void reverse(int a, int b){
		string s;
		for (int i = 0; i < b + 1 - a; i++){
			s += str[i + a];
		}
		for (int i = 0; i < b + 1 - a; i++) {
			str[i + a] = s[s.size() - i - 1];
		}
	}
	void replace(int a, int b, string s) {
		for (int i = 0; i < b + 1 - a; i++){
			str[i + a] = s[i];
		}
	}
};
int main() {
	trans t;
	cin >> t.str;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		string s;
		cin >> s >> a >> b;
		if (s == "print")
			t.print(a, b);
		else if (s == "reverse")
			t.reverse(a, b);
		else if (s == "replace"){
			cin >> s;
			t.replace(a, b, s);
		}
	}
	char c; cin >> c;
	return 0;
}

Measured memory_bytes: 3216
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int q,l,r,dp[nmax],pr[nmax],i;
bool ip(int number)
{

    if(number < 2) return false;
    if(number == 2) return true;
    if(number % 2 == 0) return false;
    for(int i=3; (i*i)<=number; i+=2)if(number % i == 0 ) return false;
    return true;
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	for(i=1;i<=100000;i++)
	{
		dp[i]=dp[i-1];
	    if(ip(i))pr[i]=1;
	    if(pr[i] && pr[(i+1)/2])dp[i]++;
	}
	cin>>q;
	while(q--)
	{
		cin>>l>>r;
		cout<<dp[r]-dp[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <decimal/decimal>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll n; cin>>n;
    ll mod=998244353;
    vector<ll> d(n);
    rep(i,n) cin>>d[i];
    if(d[0]!=0) {cout<<0<<endl; return 0;}
    sort(d.begin(),d.end());
    ll num=1, tmp=0, pretmp=1, ans=1;
    rep(i,n){
        if(i==0) continue;
        if(d[i]==num) tmp++;
        else if(d[i]==num+1){
            rep(j,tmp) {ans*=pretmp; ans%=mod;}
            pretmp=tmp;
            tmp=1;
            num++;
        }
        else ans=0;
        ans%=mod;
    }
    rep(j,tmp) {ans*=pretmp; ans%=mod;}
    cout<<ans%mod<<endl;
}


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

typedef long long LL;
typedef long int LI;
typedef long long int LLI;
typedef unsigned long long int LLLI;

int main(int argc, char const *argv[])
{
	
	LL a, b, c;
	cin >> a >> b >> c;

	if(b+c > a){
		cout <<min(b,c) <<" "<<(b+c)-a<<'\n';
	}
	else{
		cout << min(b,c)<<" "<<0 <<'\n';
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * D_Carousel
 */
public class Main {
    public static void main(String[] args) {
        InputReader ir = new InputReader();
        OutputWriter ow = new OutputWriter();

        solve(ir, ow);

        ow.flush();
    }

    private static void solve(InputReader ir, OutputWriter ow) {
        int x = ir.nextInt(), y = ir.nextInt(), z = ir.nextInt();

        ow.print(z + " " + x + " " + y);
    }
}
        

////////////////// IO //////////////////////

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }
}

class OutputWriter {
    private BufferedWriter bw;

    OutputWriter() {
        bw = new BufferedWriter(new OutputStreamWriter(System.out));
    }

    void print(String s) {
        try {
            bw.write(s, 0, s.length());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println() {
        try {
            bw.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println(String s) {
        print(s);
        println();
    }

    void print(int x) {
        print(Integer.toString(x));
    }

    void println(int x) {
        println(Integer.toString(x));
    }

    void print(long l) {
        print(Long.toString(l));
    }

    void println(long l) {
        println(Long.toString(l));
    }

    void print(Object o) {
        print(o.toString());
    }

    void println(Object o) {
        println(o.toString());
    }

    void flush() {
        try {
            bw.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 23508
#include<stdio.h>
#include<stdlib.h>

int main(void){
  long long N,*A,*B;
  long long i,j;
  long long k=0;

  scanf("%d",&N);
  A=(long long *)calloc(N,sizeof(long long));
  B=(long long *)calloc(N,sizeof(long long));
  for(i=0;i<N;i++) scanf("%lld%lld",A+i,B+i);

  k=0;
  for(i=N-1;i>=0;i--){
    A[i]+=k;
    if(A[i]%B[i]==0) continue;
    k+=B[i]-A[i]%B[i];
  }
  printf("%lld\n",k);
  free(A);
  free(B);
  return 0;  
}


Measured memory_bytes: 1664
r, c = map(int, input().split())
rc_t = [[0 for _ in range(c+1)] for _ in range(r+1)]

for i in range(r):
    l = list(map(int, input().split()))
    for j in range(c):
        rc_t[i][j] = l[j]
        rc_t[i][c]+=l[j]
        rc_t[r][j]+=l[j]
        rc_t[r][c]+=l[j]
for i in rc_t:
    for x,j in enumerate(i):
        print(f'{j}', end='')
        if x != c:
            print(' ', end='')
    print()


Measured memory_bytes: 6752
#include <stdio.h>

int main(){

  int h,i,j,v,N;
  int A[1000];

  scanf("%d",&N);
  
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }

  for(i = 0; i < N; i++){
    printf("%d",A[i]);
    if(i == N-1)printf("\n");
    else printf(" ");
  }
  
  for(i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
 
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;      
    }
    A[j+1] = v;
    for(h = 0; h < N; h++){
      printf("%d",A[h]);
      if(h == N-1)printf("\n");
      else printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

ll bcd(ll a, ll b)
{
	if (b == 0)
		return a;

	return bcd(b, a % b);
}
   
	

int main(int argc, char *argv[])
{
	ll i, a, b, c, d;
	ll div_c, div_d, div_lcm;
	ll lcm;
	ll count = 0;
	ll sum;

	cin >> a >> b >> c >> d;
	sum = b - a + 1;
    div_c = b / c - a / c;
	if (a % c == 0)
		div_c++;
	div_d = b / d - a / d;
	if (a % d == 0)
		div_d++;

	lcm = c * d / bcd(c, d);
	div_lcm = b / lcm - a / lcm;
	if (a % lcm == 0)
		div_lcm++;

	sum = sum - div_c - div_d + div_lcm;

	cout << sum << endl;
   
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
std::vector <int>a,b;
int n,can,ans;

int main(){
	std::cin>>n;
	for(int i=0;i<n;i++){
		int t;
		std::cin>>t;
		a.push_back(t);
	}
	for(int i=0;i<n;i++){
		int t;
		std::cin>>t;
		b.push_back(t);
		can+=t;
	}
	can+=a[0];
	ans=can;
	for(int i=1;i<n;i++){
		can+=a[i];
		can-=b[i-1];
		ans=std::max(can,ans);
	}
	std::cout<<ans<<std::endl;
	return 0;
}

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

int main(){
  int n, m, N, keta,j,k;
  cin >> n;
  m = n;
  N=1;
  j=0;
  for (int i=0; i<8; i++) {
    N *= 10;
    if (n/N == 0){
      keta = i+1;
      break;
    }
  }
  
  while (keta>0){
    int l=1;
    for (int i=0; i<keta-1; i++){
      l *= 10;
    }
    k = m/l;
    j += k;
    m -= l*k;
    keta--;
  }
  
  if (n%j == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  
}

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


int main()
{
	auto& in = cin;

	long long X, K, D;
	in >> X >> K >> D;

	long long toZero = abs(X) / D;
	if (K < toZero)
		toZero = K;
	K -= toZero;
	if (X < 0)
		X += toZero * D;
	else
		X -= toZero * D;
	if (K % 2) {
		if (X < 0)
			X += D;
		else
			X -= D;
	}
	cout << abs(X);

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
char s[N];
int ma[2020];
int main() {
    scanf("%s", s);
    ll ans = 0;
    int res = 0, t = 1, n = strlen(s);
    for(int i = n - 1; i >= 0; i--) {
        ma[res]++;
        res = (res + (s[i] - '0') * t) % 2019;
        ans += ma[res];
        t = t * 10 % 2019;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3960
#include <stdio.h>
 
#define S(num)  ((num) * (num))
#define H(n)    ((5.0) * (n) - (5.0))
 
int main(void)
{
    float in_data;
    float time;
    float high;
    int i;
     
    while (scanf("%f", &in_data) != EOF){
        high = S(in_data)/19.6;
        i = 0;
        while (1)if (H(++i) >= high)break;
         
        printf("%d\n", i);
    }
     
    return (0);
}

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

int main(){
    string S;
    cin >> S;
    int ans_0 = int(S.size());
    int ans_1 = int(S.size());
    for(int i = 0; i < S.size(); i++){
        if(S[i] - '0'){
            ans_1 = min(ans_1, max(i, int(S.size() - i - 1)));
        }else{
            ans_0 = min(ans_0, max(i, int(S.size() - i - 1)));
        }
    }
    cout << max(ans_0, ans_1) << endl;
}


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

int main() {
  int N ;
  int layer = 1;
  cin >> N ;
  vector<int>mochi(N) ;
  
  for(int i = 0 ; i<N ; i++){
  	cin >> mochi.at(i) ;
  }
  
  sort(mochi.begin(),mochi.end());
  
    for(int i = 1 ; i<N ; i++){	
  	  if(mochi.at(i) > mochi.at(i - 1)){
     	 layer++ ;
      } 
  	}

  	cout << layer << endl;

}


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

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

	long long r = c - a - b;

	if (r < 0) {
		cout << "No" << endl;
	} else {
		r *= r;
		long long l = 4*a*b;
		if (l < r) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
  return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
s_l = [input() for _ in range(H)]
dist = [(1, 0), (-1, 0), (0, 1), (0, -1)]
queue = deque()
results = []
for y, s in enumerate(s_l):
    result = []
    for x, p in enumerate(s):
        result.append(False if p == "." else True)
        if p == "#":
            queue.append((y, x))
    results.append(result)

count = 0
while queue:
    starts = []
    while queue:
        starts.append(queue.popleft())
    for y, x in starts:
        for dy, dx in dist:
            ny = y + dy
            nx = x + dx
            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue
            if s_l[ny][nx] == "." and not results[ny][nx]:
                queue.append((ny, nx))
                results[ny][nx] = True
    if queue:
        count += 1

print(count)


Measured memory_bytes: 163404
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[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
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(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto A = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1,
        15, 2, 2, 5, 4, 1, 4, 1, 51
    ];
    long K = lread();
    writeln(A[K - 1]);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+9;

void solve(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<string,string>,ll> m1,m2;
    for(ll mask = 0;mask < (1ll<<n);mask++){
        string r,b;
        for(int i =0;i<n;i++){
            if(mask&(1ll<<i))
                r += s[i];
        }
        for(int j = n-1;j>=0;j--){
            if(!(mask&(1ll<<j)))
                b += s[j];
        }
        m1[mp(r,b)]++;
    }
    for(ll mask = 0;mask < (1ll<<n);mask++){
        string r,b;
        for(int i =0;i<n;i++){
            if(mask&(1ll<<i))
                r += s[i+n];
        }
        for(int j = n-1;j>=0;j--){
            if(!(mask&(1ll<<j)))
                b += s[j+n];
        }
        m2[mp(b,r)]++;
    }
    ll ans = 0;
    for(auto p:m1){
        ans += m2[p.f]*p.s;
    }
    cout << ans;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

 
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 89716
#include<bits/stdc++.h>
using namespace std;
char a[101];
int l=-1,r=-1,flag;
int main(){
    cin>>a;
    for(int i=0;i<=strlen(a)-1;i++){
    	if(a[i]=='C'&&flag==0){
    		flag=1;
    		l=i;
		}
    	if(a[i]=='F')
			r=i;	
	}
	if(l<r&&l!=-1&&r!=-1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256