akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define inf 1e18+1
#define pb push_back
// #define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)
#define shaktimaan ios_base ::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
 
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
 
typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;
 
lli recpow(lli x, lli n, lli mod)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % mod, n / 2, mod);
    else //n is odd
        return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}
 
lli mem[5001][5001], n, a[5001];
 
lli dp(lli i, lli j)
{
    if(mem[i][j]!=-1)
    return mem[i][j];
    if(i==j)
    return mem[i][j]=a[i];
    if(j-i==1)
    return mem[i][j]=max(a[i],a[j]);
    return mem[i][j] = max(a[i]+min(dp(i+1,j-1),dp(i+2,j)), a[j]+min(dp(i+1,j-1),dp(i,j-2)));
}
 
//code begins here
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    shaktimaan
    //sieve();
    cin>>n;
  	lli sum=0;
    forz(i,0,n)
    cin>>a[i], sum+=a[i];
    forz(i,0,n+1)
    forz(j,0,n+1)
    mem[i][j]=-1;
    cout<<2*dp(0,n-1)-sum;
    return 0;
}

Measured memory_bytes: 86084
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
bool ckeck(int x)
{if(x%2==0)
 return true;
 return false;
} 
int a,b,c,d,e,f,g,h,ii,j,k,l,m,n,o,p,q,r,s,t,u,v,w1,x,y,z;
int main()
{string w;
 cin>>w;
 fo(i,0,w.size()){
 if(w[i]=='a')
 a++; 
 if(w[i]=='b')
 b++;
 if(w[i]=='c')
 c++;
 if(w[i]=='d')
 d++;
 if(w[i]=='e')
 e++;
 if(w[i]=='f')
 f++;
 if(w[i]=='g')
 g++;
 if(w[i]=='h')
 h++;
 if(w[i]=='i')
 ii++;
 if(w[i]=='j')
 j++;
 if(w[i]=='k')
 k++;
 if(w[i]=='l')
 l++;
 if(w[i]=='m')
 m++;
 if(w[i]=='n')
 n++;
 if(w[i]=='o')
 o++;
 if(w[i]=='p')
 p++;
 if(w[i]=='q')
 q++;
 if(w[i]=='r')
 r++;
 if(w[i]=='s')
 s++;
 if(w[i]=='t')
 t++;
 if(w[i]=='u')
 u++;
 if(w[i]=='v')
 v++;
 if(w[i]=='w')
 w1++;
 if(w[i]=='x')
 x++;
 if(w[i]=='y')
 y++;
 if(w[i]=='z')
 z++;}
 if(ckeck(a) &&ckeck(b) &&ckeck(c) &&ckeck(d) &&ckeck(e) &&ckeck(f) &&ckeck(g) &&ckeck(h) &&ckeck(ii) &&ckeck(j) &&ckeck(k) &&ckeck(l) &&ckeck(m) &&ckeck(n) &&ckeck(o) &&ckeck(p) &&ckeck(q) &&ckeck(r) &&ckeck(s) &&ckeck(t) &&ckeck(u) &&ckeck(v) &&ckeck(w1) &&ckeck(x) &&ckeck(y) &&ckeck(z))
 cout<<"Yes";
 else
 cout<<"No";
 system("pause");
 return 0;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int H, W; cin >> H >> W;
	vector<string> S(H);
	rep(i, H) {
		cin >> S[i];
	}

	rep(i, H)rep(j, W) {
		if (S[i][j] == '#')continue;

		S[i][j] = '0';
		for (int k = i - 1; k <= i + 1; k++)for (int l = j - 1; l <= j + 1; l++) {
			if (k < 0 || H <= k || l < 0 || W <= l)continue;
			if (S[k][l] == '#')S[i][j]++;
		}
	}

	for (auto x : S) {
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int ans=0;
	vi dp(n,0);
	dp[0]=0;
	if(n>=1)
		dp[1]=abs(a[1]-a[0]);
	if(n>=2){
		for (int i = 2; i < n; ++i)
		{
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}	
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << dp[i] << " ";
	// }
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

const int _M=3005;

int dp[_M][_M];
int pre[_M][_M];

int32_t main(){
 	fastIO;
 	
 	int n,s,ans;
 	cin >> n >> s;	
 	int a[n+1];
 	for(int i = 1; i <= n; i++)
 		cin >> a[i];
 	
 	for(int i = 1; i <= n; i++){
 		dp[i][a[i]] = i;

 		for(int j = a[i]+1; j < _M; j++){
 			dp[i][j] = pre[i-1][j-a[i]];
 		}

 		for(int j = 1; j < _M; j++){
 			pre[i][j] = pre[i-1][j] + dp[i][j];
 			pre[i][j] %= mod2;
 		}
 	}
 	
 	ans = 0;

 	for(int i = 1; i <= n; i++){
 		ans += (n-i+1)*dp[i][s];
 		ans %= mod2;
 	}
 	cout << ans << endl;
} 	

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

int main() {
  string s,t;
  cin >> s >> t;
  int n=s.size(),m=t.size();
  long long dp[m+1],M=1000000007;
  memset(dp,0,sizeof(dp));
  dp[0]=1;
  for(int i=0; i<n; i++) {
    for(int j=m-1; j>=0; j--) {
      if(s[i]==t[j]) dp[j+1]=(dp[j+1]+dp[j])%M;
    }
  }
  cout << dp[m] << endl;
  return 0;
}


Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class DisjointSet {
		
		int[] p, w, r;
		int size;
		
		public DisjointSet(int n) {
			size = n;
			p = new int[size];
			r = new int[size];
			w = new int[size];
			for (int i = 0; i < size; i++) makeSet(i);
		}

		private void makeSet(int x) {
			p[x] = x;
			w[x] = r[x] = 0;
		}
		
		private int findSet(int x) {
			if (p[x] != x) {
				int tmp = findSet(p[x]);
				w[x] += w[p[x]];
				p[x] = tmp;
			}
			return p[x];
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void relate(int x, int y, int z) {
			link(findSet(x), findSet(y), z - w[x] + w[y]);
		}

		private void link(int x, int y, int cost) {
			if (r[x] > r[y]) {
				p[y] = x;
				w[y] -= cost;
			} else {
				p[x] = y;
				w[x] += cost;
				if (r[x] == r[y]) {
					r[y]++;
				}
			}
		}
		
		public int sum(int x) {
			int sum = 0;
			int cur = x;
			while (cur != p[cur]) {
				sum += w[cur];
				cur = p[cur];
			}
			return sum;
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				int z = Integer.parseInt(st.nextToken());
				ds.relate(x, y, z);
			} else {
				if (ds.same(x, y)) {
					System.out.println(ds.sum(x) - ds.sum(y));
				} else {
					System.out.println("?");
				}
			}
		}
		reader.close();
	}
}



Measured memory_bytes: 78660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<char> v;
pair<int,int> p;
map<int,int> m;
deque<int> d;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int t = ceil(n/1.08);
int y = floor(t*1.08);
if(y==n)
    cout<<t<<endl;
else
    cout<<":("<<endl;
return 0;
}


Measured memory_bytes: 3576
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    if (a < b) {
        console.log('a < b');
    } else if (a > b) {
        console.log('a > b');
    } else {
        console.log('a == b');
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[200020][30][2] = {};
int main() {
	long long int n;
	cin >> n;
	vector<long long int >s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	for (int i = n-1; i >= 0; i--) {
		long long int bit  = s[i];
		long long int keta = 0;
		while (bit > 0) {
			dp[i][keta][0] = bit % 2;
			bit = bit / 2;
			keta++;
		}
	}
	int point[22] = {};
	for (int i = 0; i <= 21; i++) {
		point[i] = n;
	}
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j <= 21; j++) {
			dp[i][j][1] = point[j];
			if (dp[i][j][0] == 1) {
				point[j] = i;
			}
		}
	}
/*	for (int i = 0; i < n;i++) {
		for (int j = 0; j <= 21; j++) {
			cout << dp[i][j][1] <<" ";
		}
		cout << endl;
	}
	cout << endl;
*/
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		long long int end = n;
		for (int j = 0; j <= 21; j++) {
			if (dp[i][j][0] == 1) {
				end = min(end, dp[i][j][1]-1);
			}
			else {
				end = min(end, dp[dp[i][j][1]][j][1]-1);
			}
		}
		ans = ans + end - i + 1;
/*		cout << ans<<" "<<end  << endl;*/
	}
	cout << ans;
}


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

X = sorted(X)
Sub = []

for i in range(0,M-1):
    s = X[i+1]-X[i]
    Sub.append(s)

Sub = sorted(Sub, reverse = True )

answer = X[-1] - X[0]

for x in Sub[:N-1] :
    answer -= x

print(answer)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

ll n, a, b;

const int MAX = 200010;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll mpow(ll a, ll b) {
    ll res = 1;
    if (b > 0) {
    res = mpow(a, b/2);
    if (b % 2 == 0) res = (res * res) % MOD;
    else res = (((res * res) % MOD) * a) % MOD;
    }
    return res;
}

ll comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cin >> n >> a >> b;
    COMinit();

    ll ans = mpow(2, n) - 1;
    if (ans < 0) ans += MOD;

    ll nCa = 1, nCb = 1;;
    for (int i = 1; i <= a; i++) {
        nCa *= n - i + 1;
        nCa %= MOD;
    }
    nCa *= finv[a];
    nCa %= MOD;

    ans -= nCa;
    if (ans < 0) ans += MOD;

    for (int i = 1; i <= b; i++) {
        nCb *= n - i + 1;
        nCb %= MOD;
    }
    nCb *= finv[b];
    nCb %= MOD;
    ans -= nCb;
    if (ans < 0) ans += MOD;

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
    long a,b,c,k;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&k);
    if(a>=k){
        printf("%ld\n",k);
        return 0;
    }
    else if(a+b>=k){
        printf("%ld\n",a);
        return 0;
    }
    else{
        printf("%ld\n",a-(k-a-b));
        return 0;
    }


    return 0;
}


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

using PP = pair<int, int>;
int n, m;
vector<PP> G[50];
int p[50], q[50];
long ps[50][50];

void rec(int st, int from, int prev, long path) {
  ps[st][from] = path;
  for (PP e : G[from]) {
    int to = e.first;
    int id = e.second;
    if (to == prev) continue;
    path ^= 1l << id;
    rec(st, to, from, path);
    path ^= 1l << id;
  }
}

long sub(int s) {
  long cons = 0;
  for (int k = 0; k < m; ++k) {
    if ((s >> k) & 1) {
      cons |= ps[p[k]][q[k]];
    }
  }
  
  int cnt = __builtin_popcountll(cons);
  return 1l << (n - 1 - cnt);
}

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(PP(b, i));
    G[b].push_back(PP(a, i));
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> p[i] >> q[i];
    --p[i]; --q[i];
  }
  
  for (int i = 0; i < n; ++i) {
    rec(i, i, -1, 0l);
  }
  
  long sum = 0;
  for (int s = 0; s < (1 << m); ++s) {
    int sgn = __builtin_popcountll(s) % 2 == 0 ? 1 : -1;
    sum += sgn * sub(s);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import math
 
def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)

N,A,B = map(int,input().split())

V = list(map(int,input().split()))

v_count = {}

for v in V:
    if v not in v_count:
        v_count[v] = 1
    else:
        v_count[v] += 1

v_count = sorted(v_count.items(), key=lambda x:-x[0])

tmp_count = [0]
ans = 0
for val,count in v_count:
    tmp_count.append(tmp_count[-1]+count)
    if tmp_count[-1] < A:
        ans += val*count
    else:
        ans += val*(A-tmp_count[-2])
        print(ans/A)
        break
#print(tmp_count, ans)
if v_count[0][1] < A:
    comb = A-tmp_count[-2]
    root = combination(v_count[len(tmp_count)-2][1],comb)
else:
    root = 0
    for i in range(A, min(v_count[0][1],B)+1):
        root += combination(v_count[0][1],i)

print(root)

Measured memory_bytes: 64212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a,b; cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(a+b-n,0)<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <stdlib.h>
#include <algorithm>

#define L 1
#define A 0

using namespace std;

int main(void)
{
	int n;
	string s,a;
	int i1;
	int max;
	int count;
	


	while(1){

		vector<int> v;

		cin >> n;
		if (n == 0) break;


		vector< pair<string,int> > t;


		for(i1=0;i1<n;i1++){
			cin >> s;
			cin >> a;

			t.push_back(make_pair(s,L));
			t.push_back(make_pair(a,A));

		}

		sort(t.begin(),t.end());

		
		v.push_back(t[0].second);
		max=v.size();
		vector<int>::iterator it;

//	for(i1=0;i1<2*n;i1++) cout<<t[i1].second<<endl;


		for(i1=1;i1<2*n;i1++){
//			it = find(v.begin(),v.end(),t[i1].second);

			if(t[i1].second == L) {
				v.push_back(L);
			}
			else {
				v.pop_back();
			}

			if(max < v.size()) max = v.size();
		}

		cout << max << endl;

	}

	return 0;
}

Measured memory_bytes: 2464
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: Vec<usize> = (0..4).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let ans = if a[0] != a[2] {1} else {0};
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 22 16:27:11 2018

@author: maezawa
"""
from collections import deque
import copy

n = int(input())
adj = [[] for _ in range(n+1)]
for i in range(n-1):
    ai, bi = list(map(int, input().split()))
    adj[ai].append(bi)
    adj[bi].append(ai)
    
#print(adj)

node = [0]*(n+1)
f = 1
s = n
node[f] = 1
node[s] = -1

stack1 = deque([f])
stack2 = deque([s])
nextstack1 = deque([])
nextstack2 = deque([])
cnt1 = 0
cnt2 = 0

turn = 1

while stack1 or stack2:
    turn += 1
    while stack1:
        f = stack1.pop()
        for m1 in adj[f]:
            if node[m1] != 0:
                continue
            else:
                node[m1] = turn
                nextstack1.append(m1)
    stack1 = copy.deepcopy(nextstack1)
    nextstack1 = deque([])

    while stack2:
        s = stack2.pop()
        for m2 in adj[s]:
            if node[m2] != 0:
                continue
            else:
                node[m2] = -turn
                nextstack2.append(m2)
    stack2 = copy.deepcopy(nextstack2)
    nextstack2 = deque([])

cnt = 0
for i in node:
    if i>0:
        cnt += 1
    elif i<0:
        cnt -= 1
if cnt > 0:
    print('Fennec')
else:
    print('Snuke')
            
            
        

Measured memory_bytes: 31780
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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; }

#define MAX_N 1000
#define MAX_M 100

const long long INF = 1LL << 60;

//境界値に注意！！！

// DP テーブル
ll dp[100010];

int main() {
    ll n,k;
    cin >> n >> k;
    ll h[100010];
    for (ll i=0;i<n;++i)cin >> h[i];
    for (ll i=0;i<n;++i)dp[i]=INF;
    dp[0]=0;
    for (ll i=1;i<n;++i){
        for(ll j=1;j<=i && j<=k;++j){
            if (i>=j){
                chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int s , w;
  cin >> s >> w;
  if(s <= w)cout << "unsafe" << endl;
  else cout << "safe" << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
bool sortdes(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasc(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;} 
int gcd(int x,int y){return __gcd(x,y);}

void test_case(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        test("unsafe");
    }
    else{
        test("safe");
    }
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

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

int r, c, a[101][101] = { 0 };

int main(){
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
	}
	for (int i = 0; i < c; i++) {
		a[r][c] += a[r][i];
	}
	for (int i = 0; i <= r; i++) {
		cout << a[i][0];
		for (int j = 1; j <= c; j++) {
			cout << " " << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char a[3*maxn];
int b[3*maxn]={0};
int c[3*maxn]={0};
int main()
{
    int n,k=0,p=0;
    scanf("%d",&n);
    scanf("%s",a+1);
    int ans=3*maxn;
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='W') p++;
        b[i]=p;
    }
    for(int i=n;i>=1;i--)
    {
        if(a[i]=='E') k++;
        c[i]=k;
    }
    for(int i=1;i<=n;i++)
    {
        p=b[i],k=c[i];
        ans=min(ans,p+k-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2944
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n,t = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    #ab.sort(key=lambda x: x[1])
    ab.sort(key=lambda x: x[0])
    dp = [-1]*(t+1)
    dp[0] = 0
    for a, b in ab:
        for j in range(t-1, -1, -1):
            if dp[j] >= 0:
                if j+a<=t:
                    dp[j+a] = max(dp[j+a], dp[j]+b)
                else:
                    dp[-1] = max(dp[-1], dp[j]+b)
    print(max(dp))

if __name__ == '__main__':
    main()

Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
long INF=10000000000;

//関数


//main関数
int main() {
    
    
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> X(M);
    for(int i=0;i<M;i++){
        cin>>X.at(i);
    }
    
    //計算
    sort(X.begin(),X.end());
    vector<long> interval(M-1);
    for(int i=0;i<M-1;i++){
        interval.at(i)=X.at(i+1)-X.at(i);
    }
    sort(interval.begin(),interval.end());
    long ans=0;
    for(int i=0;i<M-N;i++){
        ans+=interval.at(i);
    }
    
 
    //出力
    cout<<ans<<endl;
}

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

long long stone[100005];
long long dp[100005];
long long n;
long long k;
int frog(long long pos){
	if(dp[pos]!=-1)return dp[pos];
	
	if(pos==n-1)return 0;
	long long mini=4000000000;
	for(long long i=1;i<=k;i++){
		if(pos+i<n){
			long long a=abs(stone[pos]-stone[pos+i])+frog(pos+i);
			if(mini>a)mini=a;
		}
	}
	
	dp[pos]=mini;
	return dp[pos];
}

int main() {	
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(long long i=0;i<n;i++){
		cin>>stone[i];
	}
	cout<<frog(0);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>

using ll = long long;

void print(){ std::cout << std::endl; }
template< typename H > void print(H head){std::cout << head << std::endl;}
template< typename H, typename... T > void print(H head, T... tail) {std::cout << head << " ", print(tail...); }

int main()
{
  std::string s;
  std::cin >> s;

  for (auto& x : s) {
    x = 'x';
  }

  print(s);

  return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ez(i,x) for(int i = h[x]; i; i = e[i].next)
using namespace std;
const int N = 2005;
int h[N], dis[N], vis[N];
int fa[N];
int n, cnt, k;
int ans;
struct edge{
	int from,to, next;
}e[N<<1];

void add(int u, int v) {
	e[++cnt] = (edge){u, v, h[u]}; h[u] = cnt;
	e[++cnt] = (edge){v, u, h[v]}; h[v] = cnt;
}

void dfs(int x){
	ez(i,x) {
		int v = e[i].to;
		if (dis[v]) continue;
		dis[v] = dis[x] + 1;
		dfs(v);
	}
}
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		add(u, v);
	}
	ans = 0x7fffffff;
	if (k & 1){
		for (int i = 1; i <= n; i += 2) {
			int u = e[i].from, v = e[i].to;
			memset(dis, 0, sizeof(dis));
			dis[v] = 1; dis[u] = 1;
			dfs(v); dfs(u);
			cnt = 0;
			for (int i = 1; i <= n; i++) if (dis[i] > (k + 1) / 2) ++cnt;
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 1; i <= n; i++) {
			memset(dis, 0, sizeof(dis));
			dis[i] = 1;
			dfs(i);
			cnt = 0;
			for (int i = 1; i <= n; i++) if (dis[i] > k / 2 + 1) ++cnt ;
			ans = min(ans, cnt);
		}

	}
	cout << ans << endl;


}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from copy import deepcopy

h, w = map(int, readline().split())
s = [input() for _ in range(h)]
cnt_x = [[0] * w for _ in range(h)]
cnt_y = deepcopy(cnt_x)
for i in range(h):
    memo = 0
    for j in range(w):
        if s[i][j] == '.':
            memo += 1
            cnt_x[i][j] = memo
        else:
            memo = 0
    for j in range(w - 1, 0, -1):
        if s[i][j - 1] == '.':
            if cnt_x[i][j - 1] < cnt_x[i][j]:
                cnt_x[i][j - 1] = cnt_x[i][j]
for i in range(w):
    memo = 0
    for j in range(h):
        if s[j][i] == '.':
            memo += 1
            cnt_y[j][i] = memo
        else:
            memo = 0
    for j in range(h - 1, 0, -1):
        if s[j - 1][i] == '.':
            cnt_y[j - 1][i] = max(cnt_y[j - 1][i], cnt_y[j][i])
            if cnt_y[j - 1][i] < cnt_y[j][i]:
                cnt_y[j - 1][i] = cnt_y[j][i]
ans = 0
for i in range(h):
    for j in range(w):
        v = cnt_x[i][j] + cnt_y[i][j] - 1
        if ans < v:
            ans = v
print(ans)


Measured memory_bytes: 122584
#include <stdio.h>
int main(){
    int a[5],b[5],top,pos;
    while(true){
        for(int i=0;i<5;i++){
            scanf("%d%d",&a[i],&b[i]);
            if(i==0&&a[i]==0&&b[i]==0)return 0;
            a[i]+=b[i];
            if(i==0){
                pos=0;
                top=a[i];
            }
            else if(a[i]>top){
                top=a[i];
                pos=i;
            }
        }
        printf("%c %d\n",'A'+pos,top);
        
    }
}


Measured memory_bytes: 2696
n, m = io.read('n'), io.read('n')
e = {}
for i = 1, n do e[i] = {} end
for i = 1, m do
    local u, v = io.read('n'), io.read('n')
    e[u][#e[u] + 1] = v
    e[v][#e[v] + 1] = u
end

dfn, low = {}, {}
tot = 0
bridge_count = 0

dfs = function (u, p)
    tot = tot + 1
    dfn[u] = tot
    low[u] = tot
    for _, v in ipairs(e[u]) do if v ~= p then
        if dfn[v] == nil then
            dfs(v, u)
            low[u] = math.min(low[u], low[v])
        else
            low[u] = math.min(low[u], dfn[v])
        end
    end end
    if p ~= -1 and low[u] > dfn[p] then
        bridge_count = bridge_count + 1
    end
end

for i = 1, n do if dfn[i] == nil then dfs(i, -1) end end

print(bridge_count)


Measured memory_bytes: 760
n = int(input())
a = list(map(int, input().split())) 

arr = [0] * 9
ans = [0] * 2

for i in a:
    if i//400 < 8:
        arr[i//400] = 1
    else:
        arr[8] += 1

left = sum(arr[:8])
right = arr[8]

ans[0] = left

if left == 0:
    ans[0] = 1

ans[1] = left + right

print(*ans)

Measured memory_bytes: 9064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int team[101],ans[101],dou[101],home,away,play,get1,get2,maxe;
    cin>>play;
    for(int i=1;i<=play;i++){
            team[i]=0;
            ans[i]=0;
            dou[i]=0;
    }
    maxe=play*(play-1)/2;
    for(int i=0;i<maxe;i++){
        cin>>home>>away>>get1>>get2;
        if(get1>get2)team[home]+=3;
        else if(get2>get1)team[away]+=3;
        else{
            team[home]++;
            team[away]++;
        }
    }
    home=-1;
    for(int i=1;i<=play;i++){
        for(int j=1;j<=play;j++){
            if(home<team[j]){
                    away=0;
                    home=team[j];
                    dou[away]=j;
                    away++;
            }
            else if(home==team[j]){
                dou[away]=j;
                away++;
            }
        }
        for(int j=0;j<away;j++){
               // cout<<dou[j]<<endl;
                ans[dou[j]]=i;
                team[dou[j]]=-1;
        }
        if(away!=1)i+=away-1;
        home=0;
    }
    for(int i=1;i<=play;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int H[]= new int[N];
		double Max = Integer.MAX_VALUE;
		int answer = 0;
		for(int i=0; i<N; i++) {
			H[i] = sc.nextInt(); //N個の標高の入力
			double ave = T - H[i] * 0.006; //平均気温
			if(Max>Math.abs(A-ave)) {
				Max = Math.abs(A-ave);
				answer = i+1;
			}
		}
		System.out.println(answer);
		
	}
}

Measured memory_bytes: 30092
import sys
sys.setrecursionlimit(10**7)

dice = [[6,3,1,4],
        [2,0,2,0],
        [1,3,6,4],
        [5,0,5,0]]
H,W = map(int,input().split())
s = list(input() for _ in range(H))
board = [[0]*W for _ in range(H)]

def dfs(x,y):
    board[x][y] = 1
    for dx,dy in [[0,-1],[0,1],[1,0],[-1,0]]:
        if not(0 <= dx+x < H and 0 <= dy+y < W):
            continue
        if(board[x+dx][y+dy] == 1):
            continue

        if s[x+dx][y+dy] == str(dice[(x+dx)%4][(y+dy)%4]):
            dfs(dx+x,dy+y)

dfs(0,0)
print(["NO","YES"][board[-1][-1]])


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

const long long MOD = (long long) 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = k; i <= n + 1; i++) {
    ans = (ans + i * (n - i + 1) + 1) % MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)2e5+5;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    //IN;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int count = 0;
    while(a <= b)
    {
        bool flag = true;
        string s = to_string(a);
        for(int i = 0;i < s.size() / 2;i++)
        {
            if(s[i] != s[s.size() - 1 - i])
            {
                flag = false;
                break;
            }
        }
        if(flag)
        {
            count++;
        }
        a += 1;
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <string>

#include <boost/multiprecision/cpp_dec_float.hpp>

namespace mp = boost::multiprecision;
using namespace std;
using lf=mp::cpp_dec_float_100;
int main()
{
  long long a,b,c;cin>>a>>b>>c;
  cout <<( (mp::sqrt((lf)a)+mp::sqrt((lf)b)<mp::sqrt((lf)c)) ? "Yes"s : "No"s) <<endl;
  }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
    string s;
    cin>>s;
    string s1="es";
    if(s[s.size()-1]!='s') s+='s';
    else s+=s1;
    cout<<s;
}



Measured memory_bytes: 3624
n, k = map(int, input().split())
S = input()
for i, s in enumerate(S):
    if k - 1 == i:
        if s == 'A':
            print('a', end='')
        elif s == 'B':
            print('b', end='')
        if s == 'C':
            print('c', end='')
    else:
        print(s, end='')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main () {
	int a, b, area, sur;

	cin >> a >> b;

	if ( ((a >= 1) && (a <= 100)) && ((b >= 1) && (b <= 100)) ) {
		area = a * b;
		sur = 2*a + 2*b;
	    cout << area << " " << sur << "\n";
	} else {
		cout << "Input number is invalid.\n";
	}
	return 0;
}

Measured memory_bytes: 1164
k,n=map(int,input().split())
a=list(map(int,input().split()))

ans=0
if max(a)<=(k/2.0) or min(a)>=(k/2.0):
  for i in range(n-1):
    ans+=abs(a[i+1]-a[i])
else:
  max_=0
  for i in range(n-1):
    max_=max(max_,abs(a[i+1]-a[i]))
  max_=max(max_,abs(a[0]-(a[n-1]-k)))
  ans=k-max_
print(ans)

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

int main(void) {
    
    string str;   //今回は15文字入力と予めわかっている
    int N[15],sum=0;
    cin >> str;
    int n=stoi(str);
    
    for (int i = 0; i < str.length(); ++i) {
        
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
        
        sum+=N[i];  //確認のため表示
        
    }
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import itertools
H, W, K = list(map(int, input().split()))
C = [['' for i in range(W)] for j in range(H)]
for j in range(H):
  C[j] = input()
  

def count(C0, H, W, hl, wl):
    T = [['' for i in range(W)] for j in range(H)]
    for i in range(H):
        for j in range(W):
            T[i][j] = C[i][j]       

    for j in hl:
        for i in range(W):
            T[j][i] = 'R'
    for i in wl:
        for j in range(H):
            T[j][i] = 'R'

    c = 0
    for i in range(H):
        for j in range(W):
            if T[i][j] == '#':
                c += 1
    return c
            

ans = 0
for j in range(W+1):
    for w in itertools.combinations(list(range(W)), j):
        for i in range(H+1):
            for v in itertools.combinations(list(range(H)), i):
                r = count(C, H, W, list(v), list(w))
                if r == K:
                    ans += 1
print(ans)
                


Measured memory_bytes: 9208
import io, os
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
R = lambda : map(int, input().split())
a, b, c, k = R()
ans = min(a, k)
if a > ans or k <= a + b:
    print(ans)
else :
    print(ans - min(c, k - a - b))


Measured memory_bytes: 9164
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	var (
		o = nextString()
		e = nextString()
		n = len(o)
		m = len(e)
	)

	for i := 0; i < max(n, m); i++ {
		if i < n {
			fmt.Print(string(o[i]))
		}
		if i < m {
			fmt.Print(string(e[i]))
		}
	}
	fmt.Println()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


map<char, int> mp;
map<int, char> mp2;
void solve() {
    array<ll, 9> v;
    for (int i = 0; i < 9; i++) {
        string s; cin >> s;
        ll t = 0;
        for (int i = 0; i < s.size(); i++) {
            t = t * 16 + mp[s[i]];
        }
        v[i] = t;
    }
    ll c = 0;
    ll res = 0;
    for (int i = 0; i < 32; i++) {
        ll x = 0;
        for (int j = 0; j < 8; j++) {
            x ^= (v[j] >> i & 1);
        }
        x ^= (c >> i & 1);
        ll y = v[8] >> i & 1;
        ll s = 0;
        if (x != y) {
            res += (1LL << i);
            for (int j = 0; j < 8; j++) {
                ll t = (v[j] >> i & 1) ^ 1;
                if (t) s += (1LL << i);
            }
        }
        else {
            for (int j = 0; j < 8; j++) {
                ll t = (v[j] >> i & 1);
                if (t) s += (1LL << i);
            }
        }
        c += s;
    }
    string s;
    while (res > 0) {
        int r = res % 16;
        s += mp2[r];
        res /= 16;
    }
    reverse(s.begin(), s.end());
    if (s.empty()) s = "0";
    cout << s << "\n";
}

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

    for (int i = 0; i < 10; i++) mp[(char)(i + '0')] = i;
    for (char c = 'a'; c <= 'f'; c++) mp[c] = (c - 'a') + 10;
    for (auto p : mp) {
        mp2[p.second] = p.first;
    }
    int kkt; cin >> kkt;
	while (kkt--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3248
import math
a,b,c,d,e=[int(input()) for i in range(5)]
x=[]
y=[]
def ceil(src, range):
  return ((int)(src / range) + 1 ) * range
for s in [a,b,c,d,e]:
  if s%10 != 0:
    x.append(s%10)
    t=min(x)
  if s<10:
    y.append(10)
  elif s%10==0:
    y.append(s)
  else:
    y.append(ceil(s,10))
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
  print(a+b+c+d+e)
else:
  ans = sum(y)
  ans= ans-10+t
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h, w; 
	cin>>h>>w;
	vector<vector<int>> v(h, vector<int>(w));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;
			cin>>c;
			if(c == '#')
				v[i][j] = 1;
		}
	}
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	dist[0][0] = v[0][0];
	queue<pair<int, int>> q;
	q.push({0, 0});
	while(!q.empty()){
		auto cur = q.front();q.pop();
		int i, j;
		i = cur.first; j = cur.second;
		int costup; 
		if(i < h-1){
			costup = v[i+1][j];
			if(v[i][j] == 1 && costup){
				costup = 0;
			}
		}
		int costdw;
		if(j < w-1){
			costdw = v[i][j+1];
			if(v[i][j] && costdw){
				costdw = 0;
			}
		}
		if(i < h-1 && dist[i][j] + costup < dist[i+1][j]){
			q.push({i+1, j});
			dist[i+1][j] = dist[i][j] + costup;
		}
		if(j < w-1 && dist[i][j] + costdw < dist[i][j+1]){
			q.push({i, j+1});
			dist[i][j+1] = dist[i][j] + costdw;
		}
	}
	cout << dist[h-1][w-1];
}


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

int main() {


int x,y;
cin >> x >> y;
long long ans = 0;
int a[3] = {300000, 200000, 100000};
if(x <= 3) ans+=a[x-1];
if(y <= 3) ans+=a[y-1];
if(x == 1 && y == 1) ans += 400000;
cout << ans; 
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	scanf ("%d", &n);
	int uang;
	while(uang<n){
		uang=uang+1000;
	}	
	if(uang==n){
		puts("0");
	}
	else if(uang>=n){
		printf("%d", uang-n);
	}
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N; cin>>N;
    vector<long long> v(N, 0);
    for (int i=0; i<N; i++) cin>>v.at(i);
    sort(v.begin(), v.end());
    cout<<v.at(N-1)-v.at(0)<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
	int m,f,r,x;
	while(1){
	cin>>m>>f>>r;
	if(m==-1 && f==-1 && r==-1){
		break;
	}
	x=m+f;
	if( x<30 || m==-1 || f==-1){
		cout<<"F"<<endl;
	}
	else if(x>=30 && x<50 && m!=-1 && f!=-1 && r<50){
		cout<<"D"<<endl;
	}
	else if(x>=50 && x<65 && m!=-1 && f!=-1 || x>=30 && x<50 && m!=-1 && f!=-1 && r>=50){
		cout<<"C"<<endl;
	}
	else if(x>=65 && x<80 && m!=-1 && f!=-1){
		cout<<"B"<<endl;
	}
	else if(x>=80 && m!=-1 && f!=-1){
		cout<<"A"<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 3008
def dice(N):
    for i in range(len(N)-2):
        if N[i][0]==N[i][1] and N[i+1][0]==N[i+1][1] and N[i+2][0]==N[i+2][1]:
            return "Yes"
    return "No"

Number=int(input())
N=[]
for i in range(Number):
    x,y=input().split()
    N.append([int(x), int(y)])
print(dice(N))


Measured memory_bytes: 9184
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;
ll dp[105][100005];

int main()
{
    ll n,W;
    cin >> n >> W;
    vector<ll> v(n);
    vector<ll> w(n);
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
} 


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    printf("%.12f\n",n*2*(3.141592));
    return 0;
}

Measured memory_bytes: 3748
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll INF=1e18;
int n;
ll a[100000+5];
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>n;
	ll ans=1;
	bool f=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			f=1;
		}
	}
	if(f)
	{
		cout<<0<<endl;
		return 0;
	}
	//sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
	{
		if(a[i]<=INF/ans)
		{
			ans=ans*a[i];
		}
		else 
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4380
fun main (args: Array<String>) {
	val num = readLine()
	val count : Int = num!!.toInt()
	
	var num2 : String?
	var count2 : Int
	
	var num3 : Int
	var result : Int = 1
	
	var list : MutableList<Int> = mutableListOf()
	
	for (i in 1..count) {
		num2 = readLine()
		count2 = num2!!.toInt()
		list.add(count2)
		
	}
	
	list.sort()
	list.reverse()
	
	num3 = list[0]
	
	for (i in 0..count - 1) {
		if (list[i] < num3) {
			result++
			num3 = list[i]
		}
		
	}
	
	println("${result}")
	
}

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

int main() {
    int k;
    cin >> k;
    vector<long long> a(k + 1);
    for (int i = 0; i < k; i++) {
        cin >> a.at(i + 1);
    }
    a.at(0) = 1;
    vector<long long> min_n(k + 1), max_n(k + 1);
    min_n.at(k) = max_n.at(k) = 2;
    for (int i = k - 1; i >= 0; i--) {
        min_n.at(i) = ceil((double)min_n.at(i + 1) / a.at(i + 1)) * a.at(i + 1);
        max_n.at(i) = floor((double)max_n.at(i + 1) / a.at(i + 1)) * a.at(i + 1) + a.at(i + 1) - 1;

        if (floor((double)max_n.at(i) / a.at(i)) < ceil((double)min_n.at(i) / a.at(i))) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << min_n.at(0) << " " << max_n.at(0) << endl;
}

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

using namespace std;
int main(){
   int n,m,sum=0,a;
   scanf("%d%d",&n,&m);
  for(int i=0; i<m ; i++){

      scanf("%d",&a);
        sum=sum+a;
}
      if(n>=sum){
   printf("%d\n",n-sum);
}
     else{

    printf("-1\n");
}
    return 0;
}






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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long r = (n / (a + b)) * a;
	if ((n % (a + b)) > a) {
		r += a;
	} else {
		r += (n % (a + b));
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256