akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}


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

    int n;
    cin >> n;
    vector<int> a(n),cum_l(n),cum_r(n);
    rep(i,n){
        cin >> a[i];
    }

    cum_l[0] = a[0];
    cum_r[n-1] = a[n-1];

    for(int i = 1;i < n;++i){
        cum_l[i] = gcd(cum_l[i-1],a[i]);
    }

    for(int i = n-2;i >= 0;--i){
        cum_r[i] = gcd(cum_r[i+1],a[i]);
    }

    int maxv = 0;

    rep(i,n){
        if(i == 0) chmax(maxv,cum_r[1]);
        else if(i == n-1) chmax(maxv,cum_l[n-2]);
        else chmax(maxv,gcd(cum_l[i-1],cum_r[i+1]));
    }

    cout << maxv << '\n';    

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < k; ++i)
    {
    	ans += a[i];
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
void fun1();
void fun2(int len1,int len2,int j);
char str1[1024],str2[1024],Ans2[82];
int Ans1[1024];
int main(void)
{
	int len1,len2,i,j,n,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		fun1();
		scanf("%s",str1);
		scanf(" %s",str2);
		len1=strlen(str1);
		len2=strlen(str2);
		if(len1>80 || len2>80) puts("overflow");
		else{
			len1--;
			len2--;
			for(j=0;len1>=0 || len2>=0;j++,len1--,len2--){
				fun2(len1,len2,j);
			}
			if(Ans1[j]==0) j--;
			for(k=0;j>=0;k++,j--){
				Ans2[k]=Ans1[j]+48;
			}
			if(strlen(Ans2)>80)	puts("overflow");
			else				printf("%s\n",Ans2);
		}
	}
	return 0;
}


void fun1()
{
	int i;
	for(i=0;i<1024;i++){
	str1[i]='\0';
	str2[i]='\0';
	Ans1[i]=0;
	Ans2[i]='\0';
	}
	return ;
}

void fun2(int len1,int len2,int j)
{
	if(len1>=0 && len2>=0){
		Ans1[j]+=(str1[len1]-'0')+(str2[len2]-'0');
		Ans1[j+1]+=Ans1[j]/10;
		Ans1[j]=Ans1[j]%10;
		}
	else if(len1>=0 && len2<0){
		Ans1[j]+=str1[len1]-'0';
		Ans1[j+1]+=Ans1[j]/10;
		Ans1[j]=Ans1[j]%10;
		}
	else if(len1<0 && len2>=0){
		Ans1[j]+=str2[len2]-'0';
		Ans1[j+1]=Ans1[j]/10;
		Ans1[j]=Ans1[j]%10;
		}
		
	return ;
}

Measured memory_bytes: 588
/** Author: Nicklaus **/
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
#define PI 3.14159265358979324

int main(){
	ld x, t;
	cin>>t>>x;
	printf("%.9Lf", t/x);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a_list = list([int(input())-1 for _ in range(N)])
    pushed_a = set([0])
    i = 0
    ans = 0
    while True:
        ans += 1
        next_a = a_list[i]
        if next_a == 1:
            break
        elif next_a in pushed_a:
            ans = -1
            break
        else:
            pushed_a.add(a_list[i])
            i = next_a
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 50140
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=2e6+5,M=1e7+50,mo=1e9+7;
int fail[N],n,i,per;
ll len1,len2,d,prt[30],l,r,f[305][26],g[305][26],sf[305],sg[305];
char s[N];
void kmp()
{
	int i,j;
	j=0;
	n=strlen(s+1)/2;
	fo(i,2,n)
	{
		while (j&&s[i]!=s[j+1]) j=fail[j];
		if (s[i]==s[j+1]) j++;
		fail[i]=j;
	}
}
void fib()
{
	int i,j;
	fo(i,2,300)
	{
		fo(j,0,25)  g[i][j]=g[i-1][j]+g[i-2][j];
		sg[i]=sg[i-1]+sg[i-2];
		if (sg[i]*2>r) break;
	}
	fo(i,0,300)
	{
		fo(j,0,25) f[i][j]=g[i][j]*2;
		sf[i]=sg[i]*2;
		if (sf[i]>r) break;
	}
}
void calc(ll x,ll xs)
{
	int pos;
	fo(pos,0,300)
		if (sg[pos]>x) break;
	while (pos>=0)
	{
		if (sg[pos]<=x)
		{
			fo(i,0,25) prt[i]+=xs*g[pos][i];
			x-=sg[pos];
			pos--;
		}else
		pos--;
	}
	fo(i,1,x) prt[s[i]-'a']+=xs; 
}
int main()
{
	scanf("%s %lld %lld",s+1,&l,&r);
	kmp();
	fo(i,1,n) g[0][s[i]-'a']++,sg[0]++;
	per=n-fail[n];
	fo(i,0,25) g[1][i]=g[0][i];
	sg[1]=sg[0];
	fo(i,1,per) g[1][s[i]-'a']++,sg[1]++;
	fib();
	calc(r,1);
	calc(l-1,-1);
	fo(i,0,25) printf("%lld ",prt[i]);
}

Measured memory_bytes: 2432
N = int(input())
A = 0
B = 0
AB = 0
BtoA = 0
for i in range(N):
    s = input()
    AB += s.count('AB')
    if s[-1] == 'A':
        A += 1
    if s[0] == 'B':
        B += 1
    if s[0] == 'B' and s[-1] == 'A':
        BtoA += 1
if A == B == BtoA:
    A -= 1
answer = AB + max(0, min(N-1, min(A, B)))
print(answer)

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int left = 0, right = 0;
	for (auto c : S) {
		if (c == '(')
			right++;
		if (c == ')')
			right--;
		if (right < 0) {
			left++;
			right++;
		}
	}
	for (int i; i < left; i++) cout << '(';
	cout << S;
	for (int i; i < right; i++) cout << ')';
	cout << endl;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

#define F first
#define S second

map<int, queue<pair<int, string>>> msgs;

bool dfs(int tar, int depth){
    if(msgs[tar].empty()) return false;

    pair<int, string> cur_msg = msgs[tar].front();
    msgs[tar].pop();

    rep(i, depth) cout << ".";
    cout << cur_msg.S << endl;
    
    while(dfs(cur_msg.F, depth + 1));

    return true;
}

int main(void){
    for(int n; cin >> n;){
        int idx = 0;
        msgs.clear();

        rep(i, n){
            int k;
            string m;
            cin >> k >> m;

            msgs[k].push(mp(++idx, m));
        }

        dfs(0, 0);
    }

	return 0;
}

Measured memory_bytes: 2136
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    (a + b + 1 >= c ? cout << b + c << endl : cout << b + a + b + 1 << endl);
}

Measured memory_bytes: 3640
# Problem A: Disjoint Set: Union Find Tree

_input = '''5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0'''


class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)


N, Q = map(int, input().split())


uf = UnionFind(N)

for _ in range(Q):
    P, A, B = map(int, input().split())

    # 連結クエリ
    if P == 0:
        uf.union(A, B)
    # 判定クエリ
    else:
        if uf.is_same(A, B):
            print(1)
        else:
            print(0)


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

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define ll long long
const ll mod =   1000000007;
const int N = 100000 + 100;
const int M = 3e6 + 1005;
ll mulit(ll a,ll b,ll m)
{
    ll ans=0;
    while(b)
    {
        if(b&1)
            ans=(ans+a)%m;
        a=(a<<1)%m;
        b>>=1;
    }
    return ans;
}
ll quick_mod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=mulit(ans,a,m);
        a=mulit(a,a,m);
        b>>=1;
    }
    return ans;
}
ll comp(ll a,ll b,ll m)
{
    if(a<b)
        return 0;
    if(a==b)
        return 1;
    if(b>a-b)
        b=a-b;
    ll ans=1,ca=1,cb=1;
    for(int i=0; i<b; i++)
    {
        ca=ca*(a-i)%m;
        cb=cb*(b-i)%m;
    }
    ans=ca*quick_mod(cb,m-2,m)%m;
    return ans;
}
ll lucas(ll a,ll b,ll m)
{
    ll ans=1;
    while(a&&b)
    {
        ans=(ans*comp(a%m,b%m,m))%m;
        a/=m;
        b/=m;
    }
    return ans;
}
int main()
{
    ll x,y;
    cin>>x>>y;
    if((x + y) % 3) return cout<<0,0;
    ll m = (2 * x - y)/3;
    ll n = (y - m)/2;
    if(n < 0||m < 0) return cout<<0,0;
    cout<<lucas(n + m,n,mod);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200];

void solve(){
    ll N;
    cin >> N;
    rep(i, N) cin >> A[i];
    string S;
    cin >> S;

    vl B(61);
    repr(i,N){
        if(S[i]=='0'){
            repr(j,61){
                if(A[i]>>j&1){
                    if(!B[j]){
                        B[j] = A[i];
                        break;
                    }
                    A[i] ^= B[j];
                }
            }
        }
        else{
            repr(j,61){
                if (A[i] >> j & 1) A[i] ^= B[j];
            }
            if(A[i]){
                cout << 1 << endl;
                return;
            }
        }
    }
    cout << 0 << endl;
}
int main() {
    init();
    ll T;
    cin >> T;
    while (T--) solve();
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll m,k;
    cin>>m>>k;
    vector<ll> v(m);
    ll indx = 0;
    rep(i, m){
        cin>>v[i];
        if(v[i] == 1) indx = i;
    }
    ll mae = indx+1;
    ll ato = m -mae +1;
//    if( k <=mae && k<= ato ) pr(<#X test#>)
    m -=k;
    pr(1+m/(k-1) + min((ll)1,m%(k-1)));
    
}



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

using namespace std;

typedef long long ll;

const int N = 55;

ll dp[N][N*N];

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

	dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		for(int j = n-1; j >= 0; j--) {
			for(int k = N*N-20; k >= 0 ; k--) {
				if(dp[j][k] != 0) {
					dp[j+1][k+x]+=dp[j][k];
				}
			}
		}
	}

	/*for(int i = 0; i <= n; i++) {
		cout << "i=" << i << ": ";
		for(int j = 0; j < 50; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < N*N-10; j++) {
			if(dp[i][j] && j==a*i) ans += dp[i][j];
		}
	}

	cout << ans;
}

Measured memory_bytes: 4084
<?php
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%s", $s);

$max = 0;
for ($i = 1; $i <= $d; ++$i) {
    list($a, $b) = explode(',', substr_replace($s, ',', $i, 0));
    $max = max(count(array_unique(array_intersect(str_split($a), str_split($b)))), $max);
};

echo $max;

Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int X;
int A;

int main(void) {
  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++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong X,Y,ans=0;
  cin >> X >> Y;
  
  while(X<=Y){
    X *= 2;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split();
            var r = int.Parse(inputs[0]);
            var c = int.Parse(inputs[1]);
            var table = new int[r][];
            var rowSums = new int[r];
            var colSums = new int[c];
            for (int i = 0; i < r; i++)
            {
                table[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                int temp = 0;
                Array.ForEach(table[i], x => temp += x);
                rowSums[i] = temp;
            }

            for (int x = 0; x < c; x++)
            {
                var temp = 0;
                for (int y = 0; y < r; y++)
                {
                    temp += table[y][x];
                }
                colSums[x] = temp;
            }

            for (int y = 0; y < r; y++)
            {
                for (int x = 0; x < c; x++)
                {
                    Console.Write("{0} ", table[y][x]);
                    if (x == (c - 1))
                    {
                        Console.Write(rowSums[y]);
                    }
                }
                Console.WriteLine();
            }
            for (int x = 0; x < c; x++)
            {
                Console.Write("{0} ", colSums[x]);
                if (x == (c - 1))
                {
                    var temp = 0;
                    Array.ForEach(rowSums, z => temp += z);
                    Console.Write(temp);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5920
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
#define int long long
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf = 1e9+9;
const int mod = 924844033;
const int N = (1 << 20);
const int lg = 20;
int rev[N];

inline ll potmod(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1) res = (res * a)%mod;
		a = (a * a)%mod;
		b >>= 1;
	}
	return res;
}

void compute(int bit = lg - 1, int x = 0, int y = 0)
{
	if (bit == -1)
	{
		rev[y] = x;
		return;
	}
	compute(bit - 1, x, y);
	compute(bit - 1, x + (1 << bit), y + (1 << (lg - bit - 1)));
}

void NTT(int a[], bool inverse)
{
	FOR(i, 0, N-1)
		if (rev[i] > i) swap(a[rev[i]], a[i]);
	
	for (int len = 2; len <= N; len *= 2)
	{
		int wn = potmod(3, (mod -1)/len/2);
		if (inverse) wn = potmod(wn, mod - 2);
		for (int j=0; j<N; j+=len)
		{
			int w = 1;
			for (int x = j, y = j + len / 2; y < j + len; ++x, ++y) 
			{
				int u = a[x], v = (ll)a[y] * w % mod;
				a[x] = u + v;
				a[y] = u - v + mod;
				while (a[x] >= mod) a[x] -= mod;
				while (a[y] >= mod) a[y] -= mod;
				w = (ll)w * wn % mod;
			}
		}
	}	
	
	if (inverse)
	{
		ll w = potmod(N, mod - 2);
		FOR(i, 0, N-1) a[i] = (ll)a[i] * w % mod;
	}
}

ll fac[N], invfac[N];
int n, a[N], b[N], c[N], sz[N], res[N];
vector <int> adj[N];
void dfs(int x, int p = 0)
{
	sz[x] = 1;
	for (auto u : adj[x])
		if (u != p)
		{
			dfs(u, x);
			sz[x] += sz[u];
		}
	a[sz[x]]++;
	a[n - sz[x]]++;
}
int32_t main()
{
	boost;
	compute();
	fac[0] = 1, invfac[0] = 1;
	FOR(i, 1, N-1) fac[i] = (fac[i-1] * i)%mod;
	invfac[N-1] = potmod(fac[N-1], mod - 2);
	for (int i=N-2; i>0; --i) invfac[i] = invfac[i + 1] * (i + 1)%mod;
	cin >> n;
	FOR(i, 2, n)
	{
		int aa, bb;
		cin >> aa >> bb;
		adj[aa].pb(bb);
		adj[bb].pb(aa);
	}
	dfs(1);
	FOR(i, 0, N-1) a[i] = (ll)a[i] * fac[i] % mod;
	int maxn = (1 << 18);
	for (int i=maxn; i>=0; --i) b[i] = invfac[maxn - i];
	NTT(a, false);
	NTT(b, false);
	FOR(i, 0, N-1) c[i] = (ll)a[i] * b[i] % mod;
	NTT(c, true);
	FOR(i, 0, maxn-1) res[i] = c[i + maxn];
	FOR(i, 1, n) cout << invfac[i] * ((fac[n] * (n + 1) % mod * invfac[n - i] %mod -res[i] + mod) % mod)%mod << "\n";
}


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

int main() {
    long long n,a,b,v[50],m=0,c=0,f[51],e=0;
    cin>>n>>a>>b;
    long double d=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n,greater<long long>());
    for(int i=0;i<n;i++){
        if(i<a){
            d+=v[i];
        }
        if(v[i]>v[a-1]){
            m++;
        }else if(v[i]==v[a-1]){
            c++;
        }
    }
    d/=a;
    f[0]=1;
    for(int i=1;i<=c;i++){
        f[i]=f[i-1]*(c-i+1)/i;
    }
    if(m==0){
        for(int i=a-m;i<=min(b-m,c);i++){
            e+=f[i];
        }
    }else{
        e=f[a-m];
    }
    
    cout<<setprecision(20)<<d<<endl;
    cout<<e<<endl;
	return 0;
}

Measured memory_bytes: 256
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]
cnt=30000
for i in range(2**d):
    cntd=0
    div=i
    score=0
    allsolved=[False]*d
    for j in range(d)[::-1]:
        if div//(2**j):
            allsolved[j]=True
            cntd+=l[j][0]
            score+=100*(j+1)*l[j][0]+l[j][1]
        div%=(2**j)
    rem=max(0,g-score)
    for h in range(d)[::-1]:
        if allsolved[h]:continue
        if rem<=100*(h+1)*(l[h][0]-1):
            cntd+=(rem+100*(h+1)-1)//(100*(h+1))
            rem=0
            break
        else:
            cntd+=l[h][0]-1
            rem-=100*(h+1)*(l[h][0]-1)
    if rem<=0 and cntd < cnt:cnt=cntd
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int count=0;
  int s = 1;
  for(int i=0; i<N; i++){
    if(s!=a[i]){
      count++;
      continue;
    }
    s++;
  }
  if(count==N) cout << "-1";
  else cout  << count;
}


Measured memory_bytes: 1024
def build_cumsum_invs(ub, mod):
    ret = [0]
    t = 0
    for i in range(1, ub + 1):
        t = (t + pow(i, mod - 2, mod)) % mod
        ret.append(t)
    return ret


def main():
    from functools import reduce

    MOD = 10 ** 9 + 7

    n = int(input())
    *x, = map(int, input().split())

    coef = build_cumsum_invs(ub=n, mod=MOD)
    # <---><---><---><---><--->
    # x1/1  1/2  1/3  1/4  1/5
    #      x1/1  1/2  1/3  1/4
    #           x1/1  1/2  1/3
    # x点から移動開始したスライムが区間を通過する確率
    # 縦に和をとると、逆数の累積和coefになっている

    prob = reduce(
        lambda a, b: (a + b) % MOD,
        (
            (x[i] - x[i - 1]) * coef[i]
            for i in range(1, n)
        )
    )

    f = reduce(
        lambda a, b: a * b % MOD,
        range(1, n)
    )

    print((prob * f) % MOD)


if __name__ == '__main__':
    main()

# prob = 0
# for i in range(1, n):
#     prob = (prob + (x[i] - x[i - 1]) * coef[i]) % MOD
# ret = (prob * reduce(lambda a, b: a * b % MOD, range(1, n))) % MOD
# print(ret)


Measured memory_bytes: 66328
def main():
    from fractions import gcd
    from functools import reduce
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    
    def cnt_2(n):
        cnt=0
        while n>0:
            if n%2==0:
                cnt+=1
                n//=2
            else:
                return cnt
    
    def lcm(x,y):
      return x*y//gcd(x,y)
    
    before=cnt_2(a[0])    
    for i in range(1,n):
        after=cnt_2(a[i])
        if after!=before:
            print(0)
            exit()
        before=after
    
    
    a=[num//(2**before) for num in a]
    before-=1
    G=reduce(lcm,a)*(2**before)
    ans=(m//G+1)//2
    print(ans) 
  
if __name__=='__main__':
    main()

Measured memory_bytes: 16292
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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

fn solve() {
    input! {
        n: i64,
        k: i64
    }

    if n < k {
        if k - n < n {
            println!("{}", k - n);
        } else {
            println!("{}", n);
        }
    } else {
        let modulo = n % k;
        let div = ((n + (k - 1)) / k) * k - n;

        println!("{}", cmp::min(modulo, div));
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  map<char,ll> mp;rep(i,4) mp[s[i]]++;
  print((mp.size()==2&&mp[s[0]]==2)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
bool comp(pii a, pii b)
{
    if (a.first == 0 && b.first != 0) return false;
    if (a.first != 0 && b.first == 0) return true;
    if (a.second == 0 && b.second != 0) return true;
    if (a.second != 0 && b.second == 0) return false;
            return a.first-a.second>b.first-b.second;
    
}
void solve()
{
    vector < pii > v;
    ll n;cin>>n;
     ll open = 0;ll close=0;
    for(ll i=0;i<n;i++)
    {
        ll pos=0,neg=0;
        string s;cin>>s;
        ll tim=0;
        for(auto c : s)
        {
            if(c == '(')tim++;
            else
            {
                if(tim==0) neg++;
                else tim--;
            }
           
            
        }
        v.pb(mp(max(0LL,tim),neg));
        
    }

    sort(v.begin(),v.end(),comp);

 
   
    for(ll i=0;i<n;i++)
    {
       
      if(open<v[i].y )
      {
          cout<<"No"<<endl;return;
      }
        open+= v[i].x-v[i].y;
    }
    if(!open)
    {
        cout<<"Yes"<<endl;return;
    }
    
    cout<<"No"<<endl;
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}



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

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long left[n],right[n];
  left[0] = labs(a[0]);
  for (long i = 1; i < n; i++) {
    left[i] = left[i-1];
    left[i] += labs(a[i]-a[i-1]);
  }
  right[n-1] = labs(a[n-1]);
  for (long i = n-2; i >= 0; i--) {
    right[i] = right[i+1];
    right[i] += labs(a[i]-a[i+1]);
  }
  printf("%ld\n", labs(a[1])+right[1]);
  for (long i = 1; i < n-1; i++) {
    printf("%ld\n", left[i-1]+right[i+1]+labs(a[i+1]-a[i-1]));
  }
  printf("%ld\n", left[n-2]+labs(a[n-2]));

  return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

void func(int N,int M,int K){
	int table[N*M+1],pre[N*M+1],limit = N*M;
	for(int i = 1; i <=limit;i++){
		pre[i] = 0;
	}

	for(int a = 1; a <= M; a++)pre[a] = 1;

	if(N == 1)for(int i = 1; i <= limit; i++){
		table[i] = pre[i];
	}else{
		for(int i = 2; i <= N; i++){
			for(int a =1; a <= limit; a++)table[a] = 0;
			for(int a = limit; a >= 1; a--){
				if(pre[a] > 0){
					for(int b = 1; b <= M; b++)table[a+b] += pre[a];
				}
			}
			for(int a =1; a <= limit; a++)pre[a] = table[a];
		}
	}

	int cut_back = 0;

	for(int i = 1; i <= K+1;i++){
		cut_back += table[i];
	}

	double bunbo = (double)pow(M,N);
	double ans = (double)cut_back/bunbo;

	for(int i = K+2; i <= limit; i++){
		ans += (double)(i-K)*((double)table[i]/bunbo);
	}

	printf("%.8lf\n",ans);

}

int main(){

	int N,M,K;

	while(true){
		scanf("%d %d %d",&N,&M,&K);
		if(N == 0 && M == 0 && K == 0)break;

		func(N,M,K);
	}

	return 0;
}

Measured memory_bytes: 2844
#include<iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h1, m1, h2, m2, r;

    cin >> h1 >> m1 >> h2 >> m2 >> r;

    int t1 = 60 * h1 + m1;
    int t2 = 60 * h2 + m2;

    int d = t2 - t1 - r;
    cout << d << endl;

    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>
using namespace std;
int main(void){
    string S;
    cin >> S;
    stack<char> stacks;
    int ans=0;
    stacks.push(S[0]);
    for(int i=1;i<S.length();i++){
        if(!stacks.empty() && stacks.top() != S[i]){
            ans += 2;
            stacks.pop();
        }
        else{
            stacks.push(S[i]);
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3352
#include <stdio.h>
#include <math.h>

int main(){
    int tanka[] = {0};
    int suryo[] = {0};
    int sum = 0;
    int save = 0;
    int ave = 0;
    double aave;
    int i = 0;
    while (scanf("%d, %d",&tanka[i],&suryo[i])!=EOF) {
        sum += tanka [i] * suryo[i];
        save += suryo[i];
        i++;
    }
    aave = (double) save / (double) i;
    ave = round(aave);
    printf("%d\n%d\n",sum,ave);
    return 0;
}

Measured memory_bytes: 604
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int[] dp = null;
    private static final int INF = 1000000005;

    //https://atcoder.jp/contests/dp/tasks/dp_b
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dp = new int[n + 1];
        //Arrays.fill(dp, -1);

        int val1 = solveBottomUp(arr, k);
        System.out.println(val1);
    }

     private static int solveBottomUp( int[] arr, int k ) {

        //INF : bcz we are comparing Math.min(dp[j] here..
        Arrays.fill(dp, INF);

        //this indicate to reach first stone cost is zero..
        dp[0] = 0;

        for (int i = 0; i < arr.length; i++) {

            //from each stone : frog can jump to next k stones.
            for (int j = i + 1; j <= i + k; j++) {

                if (j < arr.length) {
                    dp[j] = Math.min(dp[j]
                            , dp[i] + Math.abs(arr[i] - arr[j]));
                }
            }
        }

        return dp[arr.length - 1];
    }
}

Measured memory_bytes: 50548
#include <bits/stdc++.h>
using namespace std;
 
const int Maxb = 31;
 
int n;
map <int, int> M;
int res;
 
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        M[a]++;
    }
    for (int i = Maxb - 1; i >= 0; i--)
        for (map <int, int>::iterator it = M.begin(); it != M.end() && 2 * it->first <= (1 << i); it++) {
            if (it->second == 0) continue;
            int nd = (1 << i) - it->first;
            if (nd == it->first) {
                int tk = it->second / 2;
                it->second -= 2 * tk;
                res += tk;
            } else {
                map <int, int>::iterator it2 = M.find(nd);
                if (it2 != M.end()) {
                    int tk = min(it->second, it2->second);
                    it->second -= tk; it2->second -= tk;
                    res += tk;
                }
            }
        }
    printf("%d\n", res);
    return 0;
}

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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  int answer = 0;
  while (true) {
    if (A % 2 || B % 2 || C % 2) break;
    int newA = B / 2 + C / 2;
    int newB = A / 2 + C / 2;
    int newC = A / 2 + B / 2;
    if (A == newA && B == newB && C == newC) {
      answer = -1;
      break;
    }
    A = newA;
    B = newB;
    C = newC;
    ++answer;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

q = int(input())
a = deque()

for i in range(q):
    inp = input()
    # push
    if inp[0] == "0":
        operation, d, x = list(map(int, inp.split()))
        if d == 0:
            a.appendleft(x)
        else:
            a.append(x)

    # randomAccess
    elif inp[0] == "1":
        operation, p = list(map(int, inp.split()))
        print(a[p])

    # pop
    else:
        operation, d = list(map(int, inp.split()))
        if d == 0:
            a.popleft()
        else:
            a.pop()


Measured memory_bytes: 21984
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    stack<ll> s;
    ll a, b;
    string str;
    while(cin >> str) {
        if(str == "+") { 
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(b + a);
        }
        else if(str == "-") {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(b - a);
        }
        else if(str == "*") {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(b * a);
        }
        else {
            a = atoi(str.c_str());
            s.push(a);
        }
    }
    cout << s.top() << endl;
    return 0;
}


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

// lib/signum.hpp
#ifndef SIGNUM_HPP
#define SIGNUM_HPP


/*
usage:

tools::signum(-5) // => -1
*/

namespace tools {
  template <typename T>
  constexpr int signum(const T x, const std::false_type) noexcept {
    return T(0) < x;
  }

  template <typename T>
  constexpr int signum(const T x, const std::true_type) noexcept {
    return (T(0) < x) - (x < T(0));
  }

  template <typename T>
  constexpr int signum(const T x) noexcept {
    return signum(x, std::is_signed<T>());
  }
}

#endif

// main.cpp

int main() {
  static std::array<std::string, 3> answers = {"Right", "Balanced", "Left"};

  std::int_fast64_t a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << answers[tools::signum((a + b) - (c + d)) + 1] << std::endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  int n, i; cin>>n;
  i=0;
  for(int j=0; j<=n; j++){
    i=i+j;
  }
  cout<<i<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      br.lines()
        .filter(s -> !s.equals("0") && !s.isEmpty())
        .mapToInt(s -> IntStream.range(0,s.length())
          .parallel()
          .map(i -> Character.getNumericValue(s.charAt(i)))
          .sum() )
        .forEach(System.out::println);
    }
  }
}


Measured memory_bytes: 32952
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll A[200010], ma;

bool C( double x ) {
  ll cnt = 0;

  rep( i, N ) {
    if( A[i] <= x )
      continue;

    cnt += (A[i]+x-1)/x-1;
  }

  return cnt <= K;
}

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> A[i], chmax( ma, A[i] );

  ll ng = 0, ok = ma+1;

  while( ok-ng > 1 ) {
    ll mid = (ng+ok)/2;

    (C(mid) ? ok : ng) = mid;
  }

  std::cout << ok << std::endl;

  return 0;
}

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

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    int n , k;
    cin >> n >> k;
    int hash[N] = {};

    int arr[n] ;
    for (int i = 0; i < n; ++i) {
        cin  >>  arr[i];
        
    }


    for(int i = 1 ; i<= k; i ++) {
        for(int j = 0 ; j < n ; j ++) {
            if(i - arr[j] >= 0) {
                if(hash[i - arr[j]] == 0)
                    hash[i] = 1;
            }
        }
    }

    if(hash[k] == 1)
        cout << "First";
    else
        cout << "Second";

}

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

using namespace std;

//#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  if(n == 1) {
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << 1 << " " << 1 << endl;
    cout << 1 << " " << 1 << endl;
    return 0;
  }
  if(n == 2) {
    cout << "No" << endl;
    return 0;
  }
  int tmp = n;
  int i=1;
  while(tmp > 0) {
    tmp -= i;
    i++;
  }
  if(tmp != 0) {
    cout << "No" << endl;
    return 0;
  }
  vector<vector<int>> a(i);
  a[0].pb(1);
  a[1].pb(1);
  int now = 2;
  FOR(j, 2, i) {
    REP(k, j) {
      a[k].pb(now);
      a[j].pb(now);
      now++;
    }
  }
  // REP(j, i) {
  //   REP(k, a[j].size()) {
  //     cout << a[j][k] << " ";
  //   }
  //   cout << endl;
  // }

  cout << "Yes" << endl;
  cout << a.size() << endl;
  REP(i, a.size()) {
    cout << a[i].size() << " ";
    REP(j, a[i].size()) {
      if(j != a[i].size()-1) cout << a[i][j] << " ";
      else cout << a[i][j] << endl;
    }
  }
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100000
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
int main()
{
    int n;
    cin>>n;
    if(n&1)
        cout<<(n/2)+1<<"\n";
    else
        cout<<n/2<<"\n";
    return 0;
}



Measured memory_bytes: 256
import numpy as np
from functools import reduce

def euclid(m,n):
    while n:
        m,n=n,m%n
    return m

N,X=map(int,input().split(" "))
x=np.array(list(map(int, input().split(' '))))
y=abs(x-X)
print(reduce(euclid,y))

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

int main(){
  int n;
  cin>>n;
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec,vec+n);
  int p=0;
  for(int i=0;i<n-1;i++){
    if(vec[i]!=vec[i+1]){
      p++;
    }
  }
  if(p==0){
    if(vec[0]==0){
      cout<<"Yes"<<endl;
      return 0;
    }
    cout<<"No"<<endl;
    return 0;
  }
  if(p==1){
    for(int i=0;i<n-1;i++){
      if(vec[i]!=vec[i+1]){
        if(3*(i+1)==n){
          cout<<"Yes"<<endl;
          return 0;
        }
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  if(p==2){
    for(int i=0;i<n-1;i++){
      if(vec[i]!=vec[i+1]){
        if(3*(i+1)!=n&&3*(i+1)!=2*n){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
    int x=vec[0],y=vec[n/3],z=vec[n-1];
    int p=x^y^z;
    if(p==0){
      cout<<"Yes"<<endl;
      return 0;
    }
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3948
from collections import defaultdict
def main():
    N = int( input())
    A = list( map( int, input().split()))
    d = defaultdict( int)
    for a in A:
        d[a] += 1
    ans = 0
    for key, value in d.items():
        if key > value:
            ans += value
        elif key < value:
            ans += value - key
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 22324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 1;
    forn(i, 1, n){
        if(s[i]!=s[i-1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3724