akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "
#define all(x) 			x.begin(), x.end()
#define loop(i,a,n)		for (int i = a; i < (n); ++i)
#define rloop(i,a,n)	for (int i = n; i >= (a); --i)
#define in(n)			long long n ; scanf("%lli",&n);
#define yes				cout << "Yes"<<endl
#define no				cout << "No"<<endl

int main()
{
	ll n, d;
	cin >> n >> d;
	ll x[n], y[n], c = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i] >> y[i];
		ll val = x[i] * x[i] + y[i] * y[i];
		if (val <= d * d) c++;
	}
	cout << c;
	return 0;
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<int,int> ct;
	for (int i=0; i<n; i++) {
		int a; cin>>a;
		for (int j=-1; j<=1; j++)
			ct[a+j]++;
	}
	int ret=0;
	for (const auto &it : ct)
		ret=max(ret,it.second);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 4736
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	if len(res)==0:
		res = [n]
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	#data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	#ans = data[:]
	return ans

n = readInt()
a = readInts()
a.sort()

max_a = 10**6
ans = [0]*(max_a+1)

for i in a:
	ans[i]+=1
for i in set(a):
	if ans[i]>0:
		for j in range(i*2,len(ans),i):
			ans[j]+=2

count = 0


print(ans.count(1))

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

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

    int X, A;

    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else
        cout << 10 << endl;

    return 0;
}


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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double o1 = 0.5 * w * h;
  int o2;
  if (2 * x == w && 2 * y == h) o2 = 1;
  else o2 = 0;
  printf("%.1f %d\n", o1, o2);
  return 0;
}

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

const long INF = 1e9;

using namespace std;

int main() {
    int n, t, a;
    vector<long> h;

    long temp;
    double evaluate = INF;
    int index = -1;


    cin >> n >> t >> a;

    for (int i = 0; i < n; i++){
        cin >> temp;
        h.push_back(temp);
    }

    for (int i = 0; i < n; i++){
        double this_temp = (double)t - double(h.at(i)) * 0.006;
        double this_diff = abs(this_temp - a);
        if (this_diff < evaluate){
            evaluate = this_diff;
            index = i + 1;
        }
    }
    cout << index << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    string s;
    cin >> s;
    int out = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') out++;
    }
    cout << out << endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u) {
        a -= 1;
    }
    if(t == u) {
        b -= 1;
    }
    cout << a << ' ' << b;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
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 INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N,K; cin >> N >> K;
	vector<int> x(N);
	rep(i,N) cin >> x[i];
	int ans = 0;
	rep(i,N){
		ans += min(x[i]*2,(K-x[i])*2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<pair<ll, int>> primeFac(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			int cnt = 0;
			while (n % i == 0) {
				cnt++;
				n /= i;
			}
			res.push_back(make_pair(i, cnt));
		}
	}
	if (n != 1) {
		res.push_back(make_pair(n, 1));
	}
	return res;
}
int gcd(int x, int y) {
	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int lcm(int x, int y) {
	return (x / gcd(x, y) * y);
}
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int allGcd = a[0];
	for (int i = 0; i < n; i++) {
		allGcd = gcd(allGcd, a[i]);
	}
	if (allGcd != 1) {
		cout << "not coprime" << endl;
		return 0;
	}
	vector<int> primeCnt(1000010, 0);
	for (int i = 0; i < n; i++) {
		vector<pair<ll, int>> f = primeFac(a[i]);
		for (auto v : f) {
			primeCnt[v.first]++;
		}
	}
	for (int i = 0; i <= 1000010; i++) {
		if (primeCnt[i] >= 2) {
			cout << "setwise coprime" << endl;
			return 0;
		}
	}
	cout << "pairwise coprime" << endl;
	return 0;
}

Measured memory_bytes: 11104
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100],dp[100][100];

int main(){
  int a,b;
  cin >> n >> m >> a >> b;
  if(n + m == a + b)puts("Balanced");
  else if(n + m > a + b)puts("Left");
  else puts("Right");
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define MAXN 400
#define LL long long int
#define INF (1LL << 60)

int N, a[MAXN + 3];
LL dp[MAXN + 3][MAXN + 3], sum[MAXN + 3];

LL solve(int l, int r) {
    if (l == r)
        return 0;
    
    if (dp[l][r] != -1)
        return dp[l][r];

    LL mini = INF;
    for (int m = l; m < r; m++)
        mini = min(mini, solve(l, m) + solve(m + 1, r) + sum[r] - sum[l - 1]);

    return dp[l][r] = mini;
}

int main() {
    cin >> N;

    sum[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    memset(dp, -1, sizeof(dp));
    cout << solve(1, N) << endl;
}


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

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    int nOdd = 0, nEven = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        
        if (x % 2 == 1)
            nOdd++;
        else
            nEven++;
    }
    
    nEven += nOdd / 2;
    nOdd %= 2;
    
    nEven = min(nEven, 1);
    
    printf("%s\n", nOdd + nEven == 1 ? "YES" : "NO");
    
    return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    ll A, B, N;
    cin >> A >> B >> N;

    ll x1 = N;
    ll v1 = ((A * x1) / B) - A * (x1 / B);

    ll x2 = (N / B) * B - 1;
    ll v2 = ((A * x2) / B) - A * (x2 / B);

    cout << max(v1, v2) << endl;

    return 0;
}

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


int main(){
	
	int x;cin>>x;
	
	int ans=1;
	
	for(int i=2;i<=sqrt(x);++i){
		int j=i;
		while(j<=x){
			if(j>ans)ans=j;
			j=j*i;
		}
	}
	printf("%d\n",ans);	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
#define int long long

int dp[101][101][401];
int w[200], v[200];
signed main() {
	int n, W; scanf("%lld%lld", &n, &W);
	rep(i, n)scanf("%lld%lld", &w[i], &v[i]);
	rep(i, n)rep(j, n)rep(k, 3 * n + 1) {
		dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
		dp[i + 1][j + 1][k + w[i] - w[0]] = max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i]);
	}
	int Max = 0;
	rep(i, n + 1) {
		if (W < w[0] * i)continue;
		Max = max(Max, *max_element(dp[n][i], dp[n][i] + min(401LL, W - w[0] * i + 1)));
	}
	printf("%lld\n", Max);
}

Measured memory_bytes: 31872
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=2005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int h,w;
char a[max_n][max_n];
int l[max_n][max_n],r[max_n][max_n],u[max_n][max_n],d[max_n][max_n];
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)scanf(" %s",a[i]+1);
    for(int i=1;i<=h;i++)
    {
        l[i][0]=0,r[i][w+1]=w+1;
        for(int j=1;j<=w;j++)
        {
            if(a[i][j]=='#')l[i][j]=j;
            else l[i][j]=l[i][j-1];
        }
        for(int j=w;j>=1;j--)
        {
            if(a[i][j]=='#')r[i][j]=j;
            else r[i][j]=r[i][j+1];
        }
    }
    for(int j=1;j<=w;j++)
    {
        u[0][j]=0,d[h+1][j]=h+1;
        for(int i=1;i<=h;i++)
        {
            if(a[i][j]=='#')u[i][j]=i;
            else u[i][j]=u[i-1][j];
        }
        for(int i=h;i>=1;i--)
        {
            if(a[i][j]=='#')d[i][j]=i;
            else d[i][j]=d[i+1][j];
        }
    }
    int ans=0;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            ans=max(ans,r[i][j]-l[i][j]-1+d[i][j]-u[i][j]-1-1);
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int comper(void *a, void *b)
{
	return (*(int *)a - *(int * )b);
}

int main(void)
{
	int n;
	scanf("%d", &n);

	int *a = malloc(n * sizeof(int));

	for (int i = 0; i < n; i++) {
		scanf("%d", a+i);
	}

	qsort(a, n, sizeof(int), comper);

	int i;

	for (i = 0; i < n - 1; i++) {
      if (bsearch(a+i, a+i+1, n-i-1, sizeof(int), comper)) {
        printf("NO\n");
        return 0;
      }
    }

  printf("YES\n");
	return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
  for (int i = 0;i<3;i++) {
    scanf("%d",&a[i]);
  }
  sort(a,a+3);
  printf("%d", a[1]-a[0]+a[2]-a[1]);
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {

  def getMax(i:Int,r:Int, minv:Int,maxv:Int):Int = {
    val m = r-minv
    if(i==1) {
      if(m>maxv) m else maxv
    }
    else {
      getMax(i-1,readInt,if(m<0) r else minv,if(m>maxv) m else maxv)
    }
  }

  def main(args:Array[String]) {
    val n = readInt
    val minv = readInt
    val maxv = Int.MinValue
    println(getMax(n-1,readInt,minv,maxv))
  }
}

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

using namespace std;

const int ATOZ = 26;

int satisfaction(int d, int prev_v, const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t, map<int, int>& last) {
    int v = prev_v + s[d][t[d]];
    last[t[d]] = d;
    for (int i = 0; i < ATOZ; ++i) {
        v -= c[i] * (d - last[i]);
    }
    return v;
}

void reset(map<int, int>& last) {
    last.clear();
    for (int i = 0; i < ATOZ; ++i) {
        last[i] = -1;
    }
}

int finalSatisfaction(const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t) {
    map<int, int> last;
    reset(last);
    int v = 0;
    for (int d = 0; d < s.size(); ++d) {
        v = satisfaction(d, v, c, s, t, last);
    }
    return v;
}

void Main() {
    int D;
    cin >> D;
    vector<int> c(ATOZ, 0);
    for (int i = 0; i < ATOZ; ++i) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>(ATOZ, 0));
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < ATOZ; ++j) {
            cin >> s[i][j];
        }
    }
    //vector<vector<int> > s_index(D, vector<int>(ATOZ, 0));
    //for (int d = 0; d < D; ++d) {
    //    vector<int> stemp = s[d];
    //    for (int i = 0; i < ATOZ; ++i) {
    //        s_index[d][i] = distance(stemp.begin(), max_element(stemp.begin(), stemp.end()));
    //    }
    //}

    vector<int> t(D, 0);
    for (int d = 0; d < D; ++d) {
        //auto maxIt = max_element(s[d].begin(), s[d].end());
        //t[d] = 1 + distance(s[d].begin(), maxIt);
        //cout << t[d] << endl;
        cout << (1 + d % ATOZ) << endl;
    }

    //for (int i = 0; i < 10; ++i) {
    //    t[d]
    //    finalSatisfaction
    //}
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;
char str[100][100];
int a[100][3000];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i++) scanf("%s",str[i] + 1);
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= strlen(str[i] + 1) ; j++){
			a[i][str[i][j] - 'a']++;
		}
	}
	int b[30];
	for(int i = 0 ; i < 26 ; i++) b[i] = 100000;
	for(int i = 0 ; i < 26 ; i++){
		for(int j = 1 ; j <= n ; j++) b[i] = min(b[i] , a[j][i]);
	}
	for(int i = 0 ; i < 26 ; i++){
		for(int j = 1 ; j <= b[i] ; j++) printf("%c",i + 'a');
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    B.append(input())
ans = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            if all([A[i+h][j:j+M] == B[h] for h in range(M)]):
                ans = True
                break
print("Yes") if ans else print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    while(h!=0)
    {
        int i,j;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


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

int main(){
    while(1){
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '?') break;
    
    int ans;
    if(op == '+' ) ans = a+b;
    else if(op == '-') ans = a-b;
    else if(op == '*') ans = a*b;
    else if(op == '/') ans = a/b;
    
    cout << ans <<endl;
    }
}


Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		try{ checked{
		
		long[] sum = new long[N+1];
		for(int i=0;i<N;i++) sum[i + 1] = sum[i] + A[i];
		
		int NN = (int) 2e5 + 10;
		long[] coef = new long[NN];
		coef[1] = coef[2] = 5;
		for(int i=3;i<NN;i++) coef[i] = coef[i-1] + 2;
		
		long min = long.MaxValue;
		for(int i=N;i>=1;i--){
			long sc = N * X + i * X;
			
			int rest = N % i;
			int len0 = N / i;
//Console.WriteLine("i:{0},rest:{1}, len0:{2}",i, rest, len0);			
			int tot = 0;
			
			sc += coef[len0 + 1] * sum[rest];
			tot += rest;
			
			for(int j=len0;j>=1;j--){
				sc += coef[j] *(sum[tot + i] - sum[tot]);
				tot += i;
			}
			if(min >= sc){
				min = sc;
				continue;
			} else {
				break;
			}
		}
		Console.WriteLine(min);
		return;
		
		
		}} catch {
			throw new Exception("kkk");
		}
	}
	int N;
	long X;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; X = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

string s[9];
int dx[] = {0,0,1,-1,1,1-1,-1};
int dy[] = {1,-1,0,0,-1,1,-1,1};
int k;

bool solve(char c, int p, int y, int x){
  if(y < 0 || x < 0 || y == 3 || x == 3) return false;
  if(c != s[y][x] || c == '+') return false;
  if(p == 3) return true;
  solve(c, p+1, y+dy[k], x+dx[k]);
}

int main(){

  while(true){
    cin >> s[0];
    if(s[0] == "0") break;
    cin >> s[1] >> s[2];

    char c = '@';
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	for(k=0;k<8;k++) if(solve(s[i][j], 1, i, j)) c = s[i][j];
      }
    }
    
    if(c == '@') cout << "NA" << endl;
    else cout << c << endl;
    
  }
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(n%2==0){
        int count=0;
        for(int i=0;i<n;i+=2){
            if(a[i]==a[i+1]&&a[i]==i+1){
                count++;
            }
        }
        if(count==n/2){
            ll ans=1;
            for(int i=0;i<n/2;i++){
                ans*=2;
                ans%=1000000007;
            }
            cout<<ans<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
    else{//奇数
        int count=-1;
        if(a[0]==0){
            count++;
        }
        for(int i=1;i<n-1;i+=2){
            if(a[i]==a[i+1]&&a[i]==i+1){

                count++;
            }
        }
        if(count==(n-1)/2){
            int x=(n-1)/2;
            ll ans=1;
            for(int i=0;i<x;i++){
                ans*=2;
                ans%=1000000007;
            }
            cout<<ans<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
vector<pair<int,int> > g[N];
int vis[N],d[N];
set<pair<int,int> > s;
void dfs(int u){
    vis[u] = 1;
    for(auto i : g[u]){
        int v = i.first;
        if(vis[v]==0) dfs(v), d[u] ^= d[v];
    }
}
void solve(int u){
    vis[u] = 1;
    for(auto i : g[u]){
        int v = i.first;
        if(vis[v]) continue;
        if(i.second==d[v]) cout<<u<<' '<<v<<endl;
        else cout<<v<<' '<<u<<endl;
        if(i.second==0) s.erase(make_pair(u,v));
        else s.erase(make_pair(v,u));
        solve(v);
    }
}
int main(){
    int n,m; cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(make_pair(v,0));
        g[v].push_back(make_pair(u,1));
        s.insert(make_pair(u,v));
        d[u] ^= 1;
    }
    if(m&1) cout<<-1<<endl;
    else{
        dfs(1);
        memset(vis,0,sizeof(vis));
        solve(1);
        for(auto x : s){
            cout<<x.first<<' '<<x.second<<endl;
        }
    }
}


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

int main() {
  int a;
  for (int i = 0; i < 5; i++) {
    cin >> a;
    if (a == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	} else {
		int A, B; cin >> A >> B;
		cout << A + B << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<vector<int> > a(H, vector<int>(W));
  for (int i = 0; i < B; i++) {
    for (int j = 0; j < A; j++) {
      a[i][j] = 1;
    }
  }
  for (int i = B; i < H; i++) {
    for (int j = A; j < W; j++) {
      a[i][j] = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 5248
#include<iostream>
#include<cmath>
#define eps 1e9
using namespace std;

int main(){
  int n;
  while(cin>>n,n){
    int ans=0;
    for(int i=1;i*i<=n;i++){
      if(i*i == n){
	ans++;
      }
      for(int j=i;i*i+j*j<=n;j++){
	if(i*i + j*j == n){
	  ans++;
	}
	for(int k=j;i*i+j*j+k*k<=n;k++){
	  double tmp=sqrt(n -(i*i + j*j + k*k));
	  if(i*i + j*j + k*k == n){
	    ans++;
	  }else if(tmp == (int)tmp && n-(i*i + j*j + k*k) >= k*k){
	    ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll
#define F first
#define S second

const int MOD = 1e9 + 7;
void add(int &a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int mult(int a, int b) {
	return (a * 1ll * b) % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

const int N = 5010;
int calc[N][N], calc2[N][N], pw[N];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
	int n;
	cin >> n;
	pw[0] = 1;
	for (int i = 1; i <= n; i++) {
		pw[i] = mult(pw[i - 1], 2);
	}
	string s;
	cin >> s;
	calc[0][0] = 1;
	calc2[0][0] = 1;	
	for (int i = 0; i < n; i++) {
		for (int balance = 0; balance <= i; balance++) {
			add(calc[i + 1][balance + 1], calc[i][balance]);
			if (balance > 1) {
				add(calc[i + 1][balance - 1], calc[i][balance]);
			}

			add(calc2[i + 1][balance + 1], mult(calc2[i][balance], 2));
			add(calc2[i + 1][max(0, balance - 1)], calc2[i][balance]);
		}
	}
	//cout << calc2[2][0] << '\n';
	int ans = 0;
	for (int pref = 0; pref <= n; pref++) {
		if (n - pref >= SZ(s) && (n - pref) % 2 == SZ(s) % 2) {
			int cur = mult(calc[n - pref][SZ(s)], pw[(n - pref - SZ(s)) / 2]);
			//cout << pref << ' ' << cur << '\n';
			add(ans, mult(cur, calc2[pref][0]));
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 194688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b;char op;cin>>a>>op>>b;
  int ans=0;
  if(op=='+'){
    ans=a+b;
  }else{
    ans=a-b;
  }
  cout<<ans<<endl;
  return 0;
}


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

xl = [list(map(int,input().split())) for i in range(N)]

# 区間の座標に変換
robot_range = []
for i in xl:
    robot_range.append([i[0]+i[1], i[0]-i[1]])

robot_range = sorted(robot_range)

tail = robot_range[0][0]
ans = 1

for rl in robot_range:
    if rl[1] < tail:
        continue
    else:
        ans += 1
        tail = rl[0]

print(ans)

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	vector<pair<int, string> > v;
	string s;
	getline(cin, s);
	string ret = "";
	while(s.size() != 0){
		int n = 0;
		while(n < s.size() && s[n] != ' ') n++;
		string t = s.substr(0, n);
		bool b = false;
		for(int i=0; i < v.size(); i++) if(v[i].second == t){b = true; v[i].first++; break;}
		if(!b) v.push_back(make_pair(1, t));
		if(t.size() > ret.size()) ret = t;
		if(n == s.size()) break;
		s = s.substr(n+1);
	}
	sort(v.begin(), v.end(), greater<pair<int, string> >());
	cout << v[0].second << " ";
	cout << ret << endl;
}

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

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  if not x in p:
    print(x)
  else:
    i = p.index(x)
    j = 0
    while True:
      j += 1
      if j % 2 == 0:
        k = j
      else:
        k = -j
      i += k
      x += k
      if i < 0 or i >= n:
        print(x)
        break
      if p[i] != x:
        print(x)
        break

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >>d >> e;
  ll x=min(min(min(a,b),min(c,d)),e);
  if(n%x)
    cout << n/x+5 << endl;
  else
    cout << n/x+4 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N,u,v;
  cin>>N>>u>>v;
  u--;v--;
  vector<vector<ll>> T(N,vector<ll>());
  FOR(i,N-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  vector<ll> A(N),B(N,-1);
  vector<vector<ll>> stack{vector<ll>{v,0,-1}};
  while(!stack.empty()){
    vector<ll> t = stack.back();
    stack.pop_back();
    A[t[0]]=t[1];
    for(ll r:T[t[0]]){
      if(r==t[2])continue;
      stack.push_back(vector<ll>{r,t[1]+1,t[0]});
    }
  }
  stack.push_back(vector<ll>{u,0,-1});
  ll max_=0;
  while(!stack.empty()){
    vector<ll> t = stack.back();
    stack.pop_back();
    B[t[0]]=t[1];
    //if(T[t[0]].size()!=1){//&&T[t[0]][0]==t[2]){
      if(max_<A[t[0]])max_=A[t[0]];
    //}
    for(ll r:T[t[0]]){
      if(r==t[2])continue;
      if(A[r]-1<t[1])continue;
      stack.push_back(vector<ll>{r,t[1]+1,t[0]});
    }
  }
  /*
  for(auto a:A){
    cout<<a<<endl;
  }
  cout<<endl;
  for(auto a:B){
    cout<<a<<endl;
  }
  cout<<endl;
  */
  cout<<max(max_-1,0ll)<<endl;
  return 0;
}


Measured memory_bytes: 11632
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12:
    if 1 <= b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= b <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
H,W = map(int,input().split())
s = []
for _ in range(H):
    s.append(input())

shift = [[1,0],[-1,0],[0,-1],[0,1]]

flag = True
for j in range(H):
    for i in range(W):
        if s[j][i] == ".":
            continue
        else:
            flag = False
            for dx,dy in shift:
                nx = i + dx
                ny = j + dy
                
                if nx >= 0 and nx < W and ny >= 0 and ny < H:
                    if s[ny][nx] == "#":
                        flag = True
            if not flag:
                print("No")
                exit(0)

print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
	int b,c,d,e,f,g,h;
	char a;
	cin >> a ;
	if(a=='A')
		cout << "T" << endl;
	else if(a=='T')
		cout << "A" << endl;
	
	else if(a=='G')
		cout << "C" << endl;
		else
		cout << "G" << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

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

int main(){
	int n, Q;
	cin >> n >> Q;
	vector<int> c(n);
	rep(i, n) cin >> c[i];
	c.push_back(0);
	sort(all(c));
	int MAX = c[c.size()-1];

	while(Q--){
		int q;
		cin >> q;

		int ans = 0;
		for(int i = q; i <= 300000; i+=q){
			ans = max(ans, *(lower_bound(all(c), i)-1)%q);
			if(MAX <= i) break;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3380
s = input()
s2 = s[::-1]

stock = 0
answer = [0 for i in range(len(s))]
for i, s_i in enumerate(s):
    if s_i == "L":
        answer[i-1] += stock // 2
        answer[i] += stock // 2
        if stock % 2 == 1:
            answer[i-1] += 1
        stock = 0
    else:
        stock += 1

#print(answer)
for i, s2_i in enumerate(s2):
    if s2_i == "R":
        answer[-i] += stock // 2
        answer[-i-1] += stock // 2
        if stock % 2 == 1:
            answer[-i] += 1
        stock = 0
    else:
        stock += 1

print(*answer)

Measured memory_bytes: 6516
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int L = 8;

int main() {
  string v[10];
  v[0] = "* = ****";
  v[1] = "* =* ***";
  v[2] = "* =** **";
  v[3] = "* =*** *";
  v[4] = "* =**** ";
  v[5] = " *= ****";
  v[6] = " *=* ***";
  v[7] = " *=** **";
  v[8] = " *=*** *";
  v[9] = " *=**** ";
  string s;
  bool f = false;
  while(cin >>s){
    if(f) cout <<endl;
    f = true;
    stringstream ss[L];
    while(s.length() < 5) s = "0" + s;
    REP(i, s.length()) REP(j, v[s[i] - '0'].length()) ss[j] << v[s[i] - '0'][j];
    REP(i, L) cout <<ss[i].str() <<endl;
  }
  return 0;
}

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


int main(){
  string A, B, C;
  cin >> A >> B >> C;
  int top_A = 0;
  int top_B = 0;
  int top_C = 0;
  char turn = 'a';
  while(true){
    if(turn == 'a'){
      if(top_A == A.size()){
        cout << 'A' << endl;
        return 0;
      }
      turn = A[top_A];
      top_A++;
      continue;
    }
    if(turn == 'b'){
       if(top_B == B.size()){
        cout << 'B' << endl;
        return 0;
       }
      turn = B[top_B];
      top_B++;
      continue;
    }
    if(turn == 'c'){
       if(top_C == C.size()){
        cout << 'C' << endl;
        return 0;
       }
      turn = C[top_C];
      top_C++;
      continue;
    }
  }
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<(T)>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b){int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)

itn main() {
	ios::sync_with_stdio(false);

	int n;
	string s;

	cin >> n >> s;

	if (s.substr(0, n / 2) == s.substr(n / 2)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
const int inf=10000000;
int n;
string s;
int rights[100005];
int lefts[100005];
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
int rans=0;
int lans=0;
int main(int argc,char const* argv[])
{
  cin >> n;
  cin >> s;
  bool right=false;
  bool left=false;
  for(int i=0;i<int(s.size());i++)
    {
      if(s[i]=='>' && !right)
	{
	  rans++;
	  right=true;
	}
      else if(right)
	{
	  rans++;
	}
    }
  for(int i=int(s.size()-1);i>=0;i--)
    {
      if(s[i]=='<' && !left)
	{
	  lans++;
	  left=true;
	}
      else if(left)
	{
	  lans++;
	}
    }
  cout << max(lans,rans) << endl;
  return 0;
}



Measured memory_bytes: 3340
#pragma GCC optimize("O2")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	//cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	//cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    cout << x * x * x << endl;
    
    return 0;
}



Measured memory_bytes: 3124
import math
#X=int(input())
A,B,N=map(int,input().split())
if B<=N:
    print(math.floor(A*(B-1)/B)-A*math.floor((B-1)/B))
    exit()

else:
    print(math.floor(A*(N)/B)-A*math.floor((N)/B))
    exit()




Measured memory_bytes: 62052
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(lint i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(Range(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LLONG_MAX)
# define LINT_MIN (LLONG_MIN)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class T> void Print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void Print(vector<vector<T>> &df) { for (auto& vec : df) { Print(vec); } }

template <class Type> inline constexpr Type Pow5(Type x)
{ 
    return x * x * x * x * x;
}

int main()
{
    lint X; cin >> X;
    range_for (A, -1000, 1000) range_for (B, -1000, 1000)
    {
        if (Pow5(A) - Pow5(B) == X)
        {
            Print(A, B);
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int H,W;
    cin >> H >> W;
    while(H!=0&&W!=0){
        for(int a=1;a<=H;a++){
            for(int b=1;b<=W;b++){
                cout << '#' ;
            }
            cout << endl;
        }
        cout << endl;

        cin >> H >> W;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int H,W, d[50][50];
char grid[50][50];

int BFS(void){
	queue<P> Q;	Q.push( {0,0} );
	d[0][0]=1;

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

	while(Q.size()){
		P u = Q.front();	Q.pop();
		int y=u.first, x=u.second;

		for(int i=0;i<4;i++){
			int nY=y+dy[i], nX=x+dx[i];
			if(nY<0||nX<0||nY>=H||nX>=W)continue;		// 範囲外
			else if(grid[nY][nX]=='#')continue;			// 白マスじゃない
			else if(d[nY][nX]!=0)continue;				// すでに踏破している

			d[nY][nX]=d[y][x]+1;
			Q.push( {nY,nX} );
		}
	}


	return d[H-1][W-1];
}

int main(){
	cin>>H>>W;

	int whiteSum=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>grid[i][j];
			if(grid[i][j]=='.')whiteSum++;
		}
	}

	int step=BFS();
	if(step==0){
		cout<<"-1"<<endl;
	}else{
		cout<<whiteSum-step<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import Data.Foldable (foldl')
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread i v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite i a v = accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uswap :: VUM.Unbox a => Int -> Int -> VUM.IOVector a -> VUM.IOVector a
uswap i j v = accursedUnutterablePerformIO $ VUM.unsafeSwap v i j >> return v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw v = accursedUnutterablePerformIO $ VU.unsafeThaw v

newtype UnionFind = UnionFind (VUM.IOVector Int, VUM.IOVector Int)

findUF :: UnionFind -> Int -> Int
findUF (UnionFind (elems, _)) k = fix
  ( \f (elems, k, path) -> case uread k elems of
    n | n == k -> foldl' (\acc p -> uwrite p n acc) elems path `seq` n
    n          -> f (elems, n, n : path)
  )
  (elems, k, [k])

sizeUF :: UnionFind -> Int -> Int
sizeUF (UnionFind (_, sizes)) i = uread i sizes

unionUF :: UnionFind -> Int -> Int -> (UnionFind, Int)
unionUF uf@(UnionFind (elems, sizes)) i j =
  let pi = findUF uf i
      pj = findUF uf j
      si = sizeUF uf pi
      sj = sizeUF uf pj
  in  if pi == pj
        then (uf, 0)
        else
          let sij = si + sj
          in  ( UnionFind
                ( if si < sj then uwrite pi pj elems else uwrite pj pi elems
                , if si < sj
                  then uwrite pi 0 (uwrite pj sij sizes)
                  else uwrite pj 0 (uwrite pi sij sizes)
                )
              , si * sj
              )

comb2 k = k * (k - 1) `div` 2

solve :: Int -> Int -> VU.Vector (Int, Int) -> VU.Vector Int
solve n m abs = ufreeze $ (\(_, _, acc) -> acc) $ VU.foldr
  go
  (group, 0, accursedUnutterablePerformIO $ VUM.replicate m 0)
  abs
 where
  go (a, b) (uf, k, acc) =
    let (uf'@(UnionFind (!elems, !sizes)), d) = unionUF uf a b
    in  let prev = if k == 0 then 0 else uread (k - 1) acc
        in  (uf', k + 1, uwrite k (prev + d) acc)

  nC2 = comb2 n

  group :: UnionFind
  group = UnionFind
    (uthaw $ VU.enumFromN 0 n, accursedUnutterablePerformIO $ VUM.replicate n 1)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nm  <- VU.unfoldrN 2 readInt <$> B.getLine
  abs <- VU.replicateM
    (nm VU.! 1)
    (   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine
    )

  let solutions = solve (nm VU.! 0) (nm VU.! 1) abs
  let nC2       = comb2 $ nm VU.! 0

  mapM_ (print . (nC2 -) . (solutions VU.!)) [nm VU.! 1 - 2, nm VU.! 1 - 3 .. 0]
  print nC2


Measured memory_bytes: 38012