akhauriyash/Code-Regression huggingface dataset:
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

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

void solve() {
    long long N, M;
    cin >> N >> M;
    vector<long long>a(N);
    for (int i = 0; i < N; i++)cin >> a[i];

    long long lscm = 1;//Least Semi Common Multiple
    for (int i = 0; i < N; i++)lscm = lcm(lscm, a[i]/2);

    for (int i = 0; i < N; i++) { if ((lscm / (a[i] / 2)) % 2 == 0) { cout << 0; return; } }

    if (lscm > M)cout << 0;
    else cout << (M - lscm) / (2 * lscm) + 1;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;

const int max_n = 100003;


int main(){
    long long N, inp;
    long long max_n=0, min_n = 10000000000;
    cin >> N;

    rep(i, N){
        cin >> inp;
        max_n = max(max_n, inp);
        min_n = min(min_n, inp);
    }

    if(max_n - min_n >= 0) cout << (max_n - min_n) << endl;
    else cout << -1*(max_n - min_n) << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.Unboxed
import Data.Array.IO
import Data.IORef

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    ans <- newArray (1, n) False :: IO (IOUArray Int Bool)
    fals <- newArray (1, n) 0 :: IO (IOUArray Int Int)
    cs <- newIORef (0 :: Int)
    fs <- newIORef (0 :: Int)

    let
        solve :: IO () 
        solve =
            replicateM_ m $ do
                [p, s] <- words <$> getLine
                let pi = read p :: Int
                a <- readArray ans pi
                f <- readArray fals pi
                if (not a) && (s == "WA") 
                    then writeArray fals pi (f+1)
                else if (not a) && (s == "AC")
                    then writeArray ans pi True
                else return ()

        res :: IO ()
        res = 
            forM_ [1..n] $ \i -> do
                a <- readArray ans i
                f <- readArray fals i
                when a $ do
                    modifyIORef cs (+1) 
                    modifyIORef fs (+f) 

    solve
    res
    readIORef cs >>= \c -> putStr $ show c
    putStr " "
    readIORef fs >>= \f -> putStrLn $ show f


Measured memory_bytes: 15484
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    int l[n];
    
    for (int i = 0; i < n; i++) cin >> l[i];
    
    sort(l, l + n, greater<int>());
    
    int length = 0;
    for (int i = 0; i < k; i++){
        length += l[i];
    }
    cout << length << endl;
}



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

using namespace std;
typedef long long ll;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int n) : par(n, -1) {}
	
	int root(int i) {
		if(par[i] < 0) {
			return i;
		}
		
		return par[i] = root(par[i]);
	}
	
	bool same(int i, int j) {
		return root(i)==root(j);
	}
	
	bool merge(int i, int j) {
		i = root(i);
		j = root(j);
		
		if(i == j) return false;
		
		if(par[i] > par[j]) swap(i, j);
		par[i] += par[j];
		par[j] = i;
		return true;
	}
	
	int size(int i) {
		return -par[root(i)];
	}
};

int main() {
	ll n,m;
	cin >> n >> m;
	
	vector<pair<int, int>> edges(m);
	ll inconv = n * (n-1)/2;
	
	for(int i=0; i < m; i++) {
		cin >> edges[i].first >> edges[i].second;
		edges[i].first--;
		edges[i].second--;
	}
	
	reverse(edges.begin(), edges.end());
	
	UnionFind uf(n);
	vector<ll> ans;
	
	for(int i = 0; i < m; i++) {
		ans.push_back(inconv);
		int x = uf.root(edges[i].first);
		int y = uf.root(edges[i].second);
		
		if(x == y) continue;
		
		inconv -= (ll)uf.size(x) * (ll)uf.size(y);
		uf.merge(x,y);
	}
	
	reverse(ans.begin(), ans.end());
	for(ll val : ans) cout << val << endl;
	
	return 0;
}

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

const double pi = acos(-1);
int n, m;
const int maxn = 1e5 + 5;
int a[maxn];
int son[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 2;i <= n;i++){
        int fa;
        cin >> fa;
        son[fa]++;
    }
    for(int i = 1;i <= n;i++){
        cout << son[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4432
#Snuke vs Fennec
N = int(input())
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
 
 
def dist(n, lis):
    lis[n] = 0
    node = [n]
    while node:
        s = node.pop()
        d = lis[s]
        for t in tree[s]:
            if lis[t] != -1:
                continue
            lis[t] = d + 1
            node.append(t)
    return lis
 
 
from_feneck = dist(0, [-1]*N)
from_Snuke = dist(N-1, [-1]*N)
 
feneck = 0
for i,j in zip(from_feneck, from_Snuke):
    if i<=j:
        feneck += 1
    else:
        feneck -= 1
    
if feneck <= 0:
    print("Snuke")
else:
    print("Fennec")


Measured memory_bytes: 28976
N = int(raw_input())
T = list(map(int, raw_input().split(' ')))
M = int(raw_input())

x_p = []
for i in range(M):
    x_p.append(map(int, raw_input().split(' ')))

sum = sum(T)

for i in range(M):
    print(sum-T[x_p[i][0]-1]+x_p[i][1])


Measured memory_bytes: 2568
#include <iostream>

using namespace std;
string t;
int main()
{
    string a;
    cin >> a;
    string t = "";
    bool f = 0;
    for (int i = 0; i < a.size() - 4; i++) {
        f = 0;
        if (a.size() - 6 > 0) {
        if (a[i] == 'd' && a[i + 1] == 'r' && a[i + 2] == 'e' && a[i + 3] == 'a' && a[i + 4] == 'm' && a[i + 5] == 'e' && a[i + 6] == 'r' && f == 0 ) {
            if (a[i + 7] != 'a'){
                t += "dreamer";
                f = 1;
        }
        }
        }
        if (a.size() - 5 > 0) {
        if (a[i] == 'e' && a[i + 1] == 'r' && a[i + 2] == 'a' && a[i + 3] == 's' && a[i + 4] == 'e' && a[i + 5] == 'r' && f == 0) {
            t += "eraser";
            f = 1;
        }
        }
        if (a[i] == 'e' && a[i + 1] == 'r' && a[i + 2] == 'a' && a[i + 3] == 's' && a[i + 4] == 'e' && f == 0) {
            t += "erase";
            f = 1;
        }
        if (a[i] == 'd' && a[i + 1] == 'r' && a[i + 2] == 'e' && a[i + 3] == 'a' && a[i + 4] == 'm' && f == 0) {
            t += "dream";
            f = 1;
    }
    }
    if (t == a) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int n, t[1010], a[1010]; 
int main() {
	cin >> n;
	rep(i,n) cin >> t[i] >> a[i];

	ll x=t[0],y=a[0];
	rep(i,n) {
		ll r = max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
		x = r*t[i];
		y = r*a[i];
	}
	cout << x+y << endl;

	return 0;
}

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

const int MAX = 101;

// faces are numbered 0:top, 1:front, 2:right, 3:left, 4:back, 5:bottom
using pii = pair<int, int>;

struct dice {
	vector<pii> x;
	dice(int x_[6] = (int[]) { 1, 2, 3, 4, 5, 6 }) : x(3) {
		x[0] = pii(x_[0], x_[5]);
		x[1] = pii(x_[1], x_[4]);
		x[2] = pii(x_[2], x_[3]);
	}
	dice(const dice& d) : x(d.x) {}
	// copy dice
	dice& operator=(dice d) {
		x = d.x;
		return *this;
	}
	// get value on n-th face
	int X(int n) {
		return n < 3 ? x[n].first : x[5 - n].second;
	}
	// get value on side face to dir
	int Xside(int dir) {
		return dir / 2 ? x[2 - (dir & 1)].second : x[2 - (dir & 1)].first;
	}
	// roll to the north
	void N() {
		swap(x[0], x[1]);
		swap(x[1].first, x[1].second);
	}
	// roll to the east
	void E() {
		swap(x[0], x[2]);
		swap(x[2].first, x[2].second);
	}
	// roll to the west
	void W() {
		swap(x[0], x[2]);
		swap(x[0].first, x[0].second);
	}
	// roll to the south
	void S() {
		swap(x[0], x[1]);
		swap(x[0].first, x[0].second);
	}
	// roll
	void roll(int dir) {
		switch (dir)
		{
		case 0: W(); break;
		case 1: S(); break;
		case 2: E(); break;
		case 3: N(); break;
		default:
			break;
		}
	}
	// roll clockwise
	void C() {
		swap(x[1], x[2]);
		swap(x[2].first, x[2].second);
	}
	// roll counterclockwise
	void RC() {
		swap(x[1], x[2]);
		swap(x[1].first, x[1].second);
	}
	// roll so that val is on the top
	void top(int val) {
		if (x[0].first == val) {
			return;
		}
		if (x[1].first == val) {
			N();
		}
		else if (x[2].first == val) {
			E();
		}
		else if (x[2].second == val) {
			W();
		}
		else if (x[1].second == val) {
			S();
		}
		else {
			N(); N();
		}
	}
	// roll clockwise or counterclockwise so that val is on the front
	void front(int val) {
		if (x[1].first == val) {
			return;
		}
		if (x[2].first == val) {
			C();
		}
		else if (x[2].second == val) {
			RC();
		}
		else {
			swap(x[1].first, x[1].second);
			swap(x[2].first, x[2].second);
		}
	}
};

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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<vector<int>> cnt(MAX * 2 + 1, vector<int>(MAX * 2 + 1, 0));
		vector<vector<int>> top(MAX * 2 + 1, vector<int>(MAX * 2 + 1, 0));
		for (int i = 0; i < n; i++) {
			int px = MAX, py = MAX;
			dice die;
			int t, f;
			cin >> t >> f;
			die.top(t);
			die.front(f);
			bool flag;
			do {
				flag = false;
				int face = 3, dir = 0;
				for (int d = 0; d < 4; d++) {
					int tx = px + dx[d], ty = py + dy[d];
					if (cnt[tx][ty] < cnt[px][py] && die.Xside(d) > face) {
						flag = true;
						face = die.Xside(d);
						dir = d;
					}
				}
				if (flag) {
					die.roll(dir);
					px += dx[dir];
					py += dy[dir];
				}
			} while (flag);
			cnt[px][py]++;
			top[px][py] = die.X(0);
		}
		vector<int> res(6);
		for (int i = 0; i <= MAX * 2; i++) {
			for (int j = 0; j <= MAX * 2; j++) {
				if (top[i][j]) res[top[i][j] - 1]++;
			}
		}
		for (int i = 0; i < 6; i++) {
			cout << res[i] << " \n"[i + 1 == 6];
		}
	}
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
  ll n,a,x;
    cin >> n >> a;
    vector<ll> cnt(5005,0);
    rep0(i, n){
        cin >> x;
        x -= a;
        if(x < 0){
            rep0(j, 5000){
                if(cnt[j] != 0)cnt[j + x] += cnt[j];
            }
        }else{
            rrep0(j, 5000){
                if(cnt[j] != 0)cnt[j + x] += cnt[j];
            }
        }
        ++cnt[x + 2500];
    }
    cout << cnt[2500] << endl;
}


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

int main(void) {

	int n;
	int ans = 0;
	int count = 0;
	cin >> n;

	for (int i = 1; i <= n; i += 2) {
		count = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				count++;

			}
		}
		if (count == 8) {
			ans++;
		}
	}
	cout << ans;

}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int n,a,b;
  cin >> n >> a >> b;
  for(int i=n;i<=b;i+=n){
    if(i>=a && i<=b){
      cout << "OK" << endl;
      return 0;
    }
  }  
  cout << "NG" << endl;

return 0;
}
///....


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

const int mod=1e9+7;
const int mask=(1<<17)-1;
int add(int st,int x){
	return ((st<<x)|(1<<x-1))&mask;
}

int f[45][mask+5];
int n,x,y,z;

int main(){
	int s=0;
	scanf("%d%d%d%d",&n,&x,&y,&z);
//	s=add(add(add(s,x),y),z);
	s=add(s,x);
	s=add(s,y);
	s=add(s,z);
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=mask;j++){
			for(int k=1;k<=10;k++){
				int newst=add(j,k);
				if((newst&s)==s)continue;
				(f[i][newst]+=f[i-1][j])%=mod;
			}
		}
	}
	int ans=1;
	for(int i=1;i<=n;i++)
	ans=ans*10ll%mod;
	for(int i=0;i<=mask;i++)
	(ans-=f[n][i])%=mod;
	printf("%d\n",(ans+mod)%mod);
}

		
	

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N, 0);
  rep(i, N)
  {
    int in;
    cin >> in;
    a[i] = in;
  }

  int ans = 1;
  int push = a[0];
  bool is_ok = false;
  rep(i, N - 1)
  {
    if (push == 2)
    {
      is_ok = true;
      break;
    }
    push = a[push - 1];
    ans++;
  }

  if (!is_ok)
    ans = -1;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

*/

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rfor(i, st, en) for(ll i=st; i>=en; i--)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define printv(x) For(i, 0, x.size()){cout<<x[i]<<" ";} cout<<endl;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pair<int, int> > vpi;
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007


signed main(){
	fast
	int n;
	cin>>n;
	double temp;
	vector<double> v;
	For(i, 0, n){
		cin>>temp;
		v.pb(temp);
	}
	sort(all(v));

	temp = v[0];
	For(i, 1, n){
		temp = (temp+v[i])/2;
	}
	cout<<fixed<<setprecision(10);
	cout<<temp<<endl;
    return 0;
}
    



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

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

    long long A, B, K;
    cin >> A >> B >> K;
    long long rem = min(A, K);
    A -= rem;
    K -= rem;
    if (K > 0)
        B -= min(B, K);
    cout << A << ' ' << B << '\n';

    return 0;
}

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

int main() {
	int n, a, b, seisu, v, w, x, y, z;
	cin >> n >> a >> b;
	seisu = 0;
	while (n > 0) {
    	v = n / 10000;
		w = n / 1000 - 10 * v;
		x = n / 100 - 10 * w - 100 * v;
		y = n / 10 - 10 * x - 100 * w - 1000 * v;
		z = n - 10 * y - 100 * x - 1000 * w - 10000 * v;
	    if (a <= v + w + x + y + z && v + w + x + y + z <= b) {
	        seisu = seisu + n;
	    }
	    n--;
	}
	cout << seisu;
	return 0;
}


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

int main(void){
	ios::sync_with_stdio(false);
	int N, Y, i, j, k, l[3];
	cin >> N >> Y;
	Y /= 1000;
	i = 0;
	j = 0;
	l[1] = -1;
	l[2] = -1;
	l[3] = -1;
	for (i = 0; i <=N; i++) {
		for (j = 0; j <= N-i; j++) {
			if (Y == j * 5 + i * 10 + N - i - j && N - i - j >= 0) {
				l[1] = i;
				l[2] = j;
				l[3] = N - i - j;
			}
		}
	}
	cout << l[1] <<' ' << l[2] <<' ' << l[3];
	return 0;
}


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


int main()
{
    
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int counter=0;
    for(int r=0;r<=N/R;r++){
        for(int b=0;b<=(N-r*R)/B;b++){
            if((N-r*R-b*B)%G==0){
                counter+=1;
            }
        }
    }
    cout<<counter<<endl;
    
    }



Measured memory_bytes: 384
#include <iostream>

using namespace std;

long long f(int n){
    return (long long)n*n*n*n*n;
}
int search(int a, long long n){
    int l = -200,r = 200;
    for(int i=0;i<20;++i){
        int mid = (l+r)>>1;
        if(f(a) - f(mid) == n){
            return mid;
        }
        if(f(a) - f(mid) < n){
            r = mid;
        }
        else l = mid;
    }
    return 1000;
}

int main()
{
   long long n; cin>>n;
   for(int a = 0; a <= 250; ++a){
       int b = search(a, n);
       if(b !=1000){
           cout<<a<<" "<<b<<"\n";
           return 0;
       }
   }
   
   return 0;
}

Measured memory_bytes: 3632
a, b, x = map(int, input().split())

import math
S = a * b
x /= a

if S < 2*x :
    tanT = 2 * (a * b - x) / (a**2)
else :
    tanT = b ** 2 / (2 * x)

T = math.degrees(math.atan(tanT))
print(T)


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

#define MAX 100010

using namespace std;

typedef pair<int,int> P;

int main() {
    int n, c;
    cin >> n >> c;
    vector<P> G[c];
    for (int i=0; i<n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        G[c-1].push_back({s, t});
    }
    int total[MAX] = {0};
    for (auto &row:G) {
        int chan[MAX] = {0};
        for (auto p:row)
            for (int i=p.first; i<=p.second; i++) 
                chan[i] = 1;
        for (int i=0; i<MAX; i++) 
            total[i] += chan[i];
    }
    int x = 0;
    for (auto t:total) x = max(x, t);
    cout << x << '\n';
    return 0;
}

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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    int A, B, N;
    cin >> A >> B >> N;
    YES(A <= N && N <= A + B);
}


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

int main(){
    int n;
    cin >> n;
    vector<ll>vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    
    int sum = 0;
    bool cont = true;
    while(true){
        for(int i=0;i<n;i++){
            if(vec[i]%2 == 0){
                vec[i] /=2;
                continue;
            }
            cont = false;
            break;
        }
        if(cont){
            sum++;
            continue;
        }break;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
unsigned long long int countDivisibles(unsigned long long int A, unsigned long long int B, unsigned long long int M)
{
    if (A % M == 0)
        return (B / M) - (A / M) + 1;
    return (B / M) - (A / M);
}
int main() {
    unsigned long long int a,b,x;
    scanf("%llu%llu%llu",&a,&b,&x);
    if(a>=0&&a<=b&&b<=pow(10,18)&&x>=1&&x<=pow(10,18)){
        cout << countDivisibles(a, b, x) << endl;
    }
   return 0;
}

Measured memory_bytes: 256
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())

a1=0
a2=(c12-c11,c22-c21,c32-c31)
a3=(c13-c11,c23-c21,c33-c31)

if len(set(a2))==1 and len(set(a3))==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve(){
	int n; cin >> n;
	int arr[n][3];

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

	int dp[n][3];
	for(int i=0;i<n; i++){
		for(int j=0; j<3; j++){
			dp[i][j] = 0;
		}
	}

	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];

	for(int i=1; i<n; i++){
		dp[i][0] += arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] += arr[i][1] +max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] += arr[i][2] +max(dp[i-1][0], dp[i-1][1]);
	}

	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;

}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

#define MAX 7368800

signed main() {
	static bool a[MAX] = {};
	for (int m, n; cin >> m >> n&&m;) {
		fill(a, a + MAX, false);
		int cnt = 0;
		for (int h = m; h < MAX; h++) {
			if (a[h])continue;
			cnt++;
			for (int i = h; i < MAX; i += h)a[i] = true;
			if (cnt == n)break;
		}
		for (int i = m; i < MAX; i++) {
			if (!a[i]) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 10292
using System;
using System.Linq;

namespace lineAralgebra
{


	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var d = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var ans = 0;
			for (var i = 0; i < N; i++)
			{
				for (var j = i + 1; j < N; j++)
				{
					ans += d[i] * d[j];
				}
			}
			System.Console.WriteLine(ans);
		}
	}
}
//                            0       2      4

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

using namespace std;




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

vector<int> a(n,k-q);
for(int i = 0;i < q;i++){
	int p;
cin >> p;
a[p-1]++;
}

for(int i = 0;i < n;i++){
	if(a[i] > 0)cout << "Yes" <<endl;
	else cout << "No" <<endl;
}
return 0;
}

Measured memory_bytes: 1024
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,c = map(int, input().split())
    if b//a >= c:
        print(c)
    else:
        print(b//a)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9600
AB = input()
S = input()

A = int(AB.split(" ")[0])
B = int(AB.split(" ")[1])

ints = "0123456789"


flag = True

if len(S) != A + B + 1:
    flag = False

if flag:
    for i in range(len(S)):
        if i != A:
            if not(S[i] in ints):
                flag = False
        else:
            if S[i] != "-":
                flag = False

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
sign = [-1] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
D = deque([0])
visited = [False]*n
visited[0] = True
while D:
    v=D.popleft()
    for j in graph[v]:
        if visited[j]:
            continue
        visited[j] = True
        sign[j] = v
        D.append(j)

print("Yes")
for k in range(1, n):
    print(sign[k]+1)

Measured memory_bytes: 34816
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int count = 0;
    string s;
    string t;
    cin >> s >> t;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == t[i])
        {
            count++;
        }
    }
    cout << count;

    return 0;
}


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define in freopen(".in", "r", stdin)
#define out freopen(".out", "r", stdout)

using namespace std;

const long long INF = (int)1e17 + 7;

int a[51];

ll dp[51][51][50*51];

int n, i, s, j, k;

ll sum = 0;

int main()
{

    cin >> n >> s;
    memset(dp, 0, sizeof(dp));

    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    dp[0][0][0] = 1;
    for (i = 1; i <= n; i++)
        for (j = 0; j <= i; j++)
            for (k = 0; k <= 2500; k++) {
                dp[i][j][k] += dp[i - 1][j][k];
                if (k >= a[i] && j > 0)
                dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];
            }

    for (i = 1; i <= n; i++) {
        sum += dp[n][i][s * i];
    }

    cout << sum;

}




Measured memory_bytes: 52096
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#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> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;const ll N=1e5+5;
vector<ll> adj[N];bool visited[N]={0};ll parent[N];queue<ll> q;
void bfs(ll x)
{
	visited[x] = true;
	q.push(x);
	while (!q.empty()) {
	int s = q.front(); q.pop();
	// process node s
	for (auto u : adj[s]) {
	if (visited[u]) continue;
	visited[u] = true;
	parent[u] = s;
	q.push(u);
	}
}
}
int main()
{
	ll n,m;cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		ll u,v;
		cin>>u>>v;u--;v--;adj[u].push_back(v);adj[v].push_back(u);
	}
	for(ll i=0;i<n;i++)parent[i]=-1;
	bfs(0);
	for(ll i=1;i<n;i++)if(parent[i]==-1){cout<<"No";return 0;}
	cout<<"Yes\n";
	for(ll i=1;i<n;i++)cout<<parent[i]+1<<"\n";
}


Measured memory_bytes: 13144
n = int(input())
wlt = input().split()

for i in range(0, len(wlt)):
    wlt[i] = int(wlt[i])

ans_sum = 1000
for i in range(0, len(wlt)):
    migi = sum(wlt[:i+1])
    hidari = sum(wlt[i+1:])
    if ans_sum > abs(migi - hidari):
        ans_sum = abs(migi - hidari)

print(ans_sum)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int n, m, a[10001];
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		n = n - a[i];
	}

	if (n<0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << n << endl;
	}
}


Measured memory_bytes: 3208
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int R, C;
	cin >> R >> C;
	int n;
	cin >> n;

	int N = R + C;
	vector<vector<P>> e(N);
	rep(i, n) {
		int r, c, a;
		cin >> r >> c >> a;
		r--; c--;
		e[r].push_back(P(c + R, a));
		e[c + R].push_back(P(r, a));
	}
	vector<int> g(N, INF);
	function<P(int, int)> dfs = [&](int i, int t) {
		P rt(INF, INF);
		each(j, e[i]) {
			int to = j.first;
			int a = j.second;
			if (g[to] == INF) {
				g[to] = a - g[i];
				auto r = dfs(to, 1 - t);
				rt.first = min(rt.first, r.first);
				rt.second = min(rt.second, r.second);
			}else
			if(g[to] + g[i] != a){
				cout << "No" << endl; exit(0);
			}
		}
		if (t == 0)rt.first = min(rt.first, g[i]);
		else rt.second = min(rt.second, g[i]);
		return rt;
	};

	rep(i, N) {
		if (g[i] == INF) {
			g[i] = 0;
			auto p = dfs(i, 0);
			if (p.first + p.second < 0) {
				cout << "No" << endl; exit(0);
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 21120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s)
{
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


void solve(long long n, long long m, long long s, long long t, vector<long long> u, vector<long long> v, vector<long long> a, vector<long long> b){
  WeightedGraph<long long> su;
  WeightedGraph<long long> ye;
  for (int i = 0; i < n; i++) {
    su.push_back(Edges<long long>());
    ye.push_back(Edges<long long>());
  }
  for (int i = 0; i < m; i++) {
    su[u[i]-1].push_back(edge<long long>(u[i]-1, v[i]-1, b[i]));
    su[v[i]-1].push_back(edge<long long>(v[i]-1, u[i]-1, b[i]));
    ye[u[i]-1].push_back(edge<long long>(u[i]-1, v[i]-1, a[i]));
    ye[v[i]-1].push_back(edge<long long>(v[i]-1, u[i]-1, a[i]));
  }
  vector<long long> dfs = dijkstra(ye, s-1);
  vector<long long> dft = dijkstra(su, t-1);
  vector<long long> r(n);
  vector<long long> re(n);
  for (int i = 0; i < n; i++) {
    r[i] = dfs[i] + dft[i];
  }
  re[n-1] = r[n-1];
  for (int i = n-2; i >= 0; i--) {
    re[i] = min(re[i+1], r[i]);
  }
  for (int i = 0; i < n; i++) {
    std::cout << 1000000000000000 - re[i] << std::endl;
  }
}

int main(){
  long long m;
  long long n;
  long long s;
  long long t;
  scanf("%lld",&n);
  scanf("%lld",&m);
  vector<long long> a(m);
  vector<long long> v(m);
  vector<long long> b(m);
  vector<long long> u(m);
  scanf("%lld",&s);
  scanf("%lld",&t);
  for(int i = 0 ; i < m ; i++){
    scanf("%lld",&u[i]);
    scanf("%lld",&v[i]);
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  solve(n, m, s, t, u, v, a, b);
  return 0;
}


Measured memory_bytes: 26532
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static class Index{
		TreeSet<Integer> lst;
		public Index() {
			lst = new TreeSet<Integer>();
		}
		void add(int ind){
			lst.add(ind);
		}
		int next(int ind){
			if(lst.higher(ind) == null){
				return -1;
			}
			return lst.higher(ind);
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		Index inds[] = new Index[10];
		for(int i = 0 ; i < inds.length ; ++i){
			inds[i] = new Index();
		}
		for(int i = 0 ; i < S.length() ; ++i){
			char c = S.charAt(i);
			int v = c - '0';
			inds[v].add(i);
		}
		int cnt = 0;
		for(int i = 0 ; i <= 999 ; ++i){
			int i0 = (i / 100);
			int i1 = (i /10) % 10;
			int i2 = i % 10;
			int n0 = inds[i0].next(-1);
			if(n0 < 0){
				continue;
			}
			int n1 = inds[i1].next(n0);
			if(n1 < 0){
				continue;
			}		
			int n2 = inds[i2].next(n1);
			if(n2 < 0){
				continue;
			}	
			++cnt;
//			System.out.println(i);
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 27460
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    c = input().rstrip()

    s = 'aeiou'

    if c in s:
        print('vowel')
    else:
        print('consonant')



main()


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

ll xp(ll b, ll e) {
	if (e == 0) return 1;
	ll c = xp(b, e >> 1);
	c *= c;
	c %= mod;
	if (e & 1) c *= b, c %= mod;
	return c;
}

pair<ll, ll> eucl(ll a, ll b) {
	if (b == 0) return {1, 0};
	ll x, y;
	tie(x, y) = eucl(b, a % b);
	return {y, x - a / b * y};
}

ll inv(ll x) {
	if (x == 0) return 1;
	ll n = eucl(mod, x).second;
	return ((n % mod) + mod) % mod;
}

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

	int k;
	string s;
	cin >> k >> s;
	int l = s.length();
	ll y = 1, ans = 0;
	loop(k + 1) {
		ll x = xp(26, k - i);
		ll z = xp(25, i) * y % mod;
		ans += x * z % mod;
		y = (y * (i + l) % mod) * inv(i + 1) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4280
#include<iostream>
using namespace std;
int main()
{
     int k,ans[10]={0},i,j,n=0,p;
    cin >> k;
    for(i=0;i<k;i++){
        ans[0]++;
        j=0;
        while(ans[j]==10){
            ans[j+1]++;
            ans[j]=0;
            n=max(n,j+1);
            j++;
        }
        p=j;
        for(;p>0;p--) ans[p-1]=max(0,ans[p]-1);
        for(;j<n;j++){
            if(abs(ans[j+1]-ans[j])<2) break;
            ans[j+1]++;
            p=j+1;
            while(ans[p]==10){
                ans[p+1]++;
                ans[p]=0;
                n=max(n,p+1);
                p++;
            }
        }
        for(;j>0;j--) ans[j-1]=max(0,ans[j]-1);
    }
    for(i=n;i>=0;i--) cout << ans[i];
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
class alds14a
{
    static void Main()
    {
        Console.ReadLine();
        List<int> S = read();
        Console.ReadLine();
        List<int> T = read();
        int ct = 0;
        foreach (int tgt in T)
        {
            if (S.BinarySearch(tgt)>-1) ct++;
        }
        Console.WriteLine(ct);
    }
    static List<int> read()
    {
        List<int> ret = new List<int>();
        string[] input = Console.ReadLine().Split(' ');
        foreach (string data in input)
        {
            int num;
            if (int.TryParse(data, out num))
            {
                ret.Add(num);
            }
        }
        return ret;
    }
}

Measured memory_bytes: 15552
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))






def main():
    n = ii()
    a = li()
    s = sum(a)

    stmp = 0
    point = 0
    for i in range(len(a)):
        stmp += a[i]
        if stmp*2 >= s:
            point = i
            break
    
    stmptmp = stmp-a[i]

    ans=0
    #if stmptmp+stmp>s:
    ans = min(abs(stmptmp*2-s),abs(stmp*2-s))
    print(ans)


    





main()


Measured memory_bytes: 26024
import sys

def is_prime(x):
    if(x <= 3 and x > 1):
        return 1
    elif(x == 5):
        return 1
    elif(x % 2 == 0 or x < 2):
        return 0
    a = 3
    while(a * a <= x):
        if(x % a == 0):
            return 0
        a += 2
    return 1

def generate_prime(x):
    list = []
    list.append(2)
    for i in range(3,x+1,2):
        if(is_prime(i) == 1):
            list.append(i)
    return list

def count_list(x,list):
    count = 0
    for i in range(0,len(list)):
        if(list[i] > x):
            break
        elif(list[i] <= x):
            count += 1
    return count

l = []
for input in sys.stdin:
    l.append(int(input))

prime = generate_prime(max(l))
for i in range(0,len(l)):
    print count_list(l[i],prime)



Measured memory_bytes: 21180
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int n, q;
	cin >> n >> q;
	string S;
	cin >> S;

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

	vector<int> ans(q);
	for (int i = 0; i < q; ++i)
	{
		int L, R;
		cin >> L >> R;
		ans[i] = AC[R-1] - AC[L-1];
	}
	for (int i = 0; i < q; ++i)
		cout << ans[i] << endl;
}



Measured memory_bytes: 4308
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

def main():
    n, m = na()
    if n > 1:
        n -= 2
    if m > 1:
        m -= 2
    print(n * m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n,ans; 
int s;
int main(){
    cin>>n;
    for(int i=sqrt(n);i>0;--i) 
    {
    	if(n%i==0)
		{
            ans=n/i;
            break;
        }
    }
    while(ans>0)
	{ 
        ++s;
        ans/=10;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, m;
string s;
vector<int> v;
vector<int> sol;

int main () {

	cin >> n >> m >> s;
	int naj = n;
	for (int i = n-1; i >= 0; i--) {
		if (s[i] == '0') {
			if (naj-i > m) {
				cout << -1;
				return 0;
			}
			
			v.push_back(naj-i);
			naj = i;
		}
	}
	
	int zbr = 0;
	for (int i = 0; i < v.size(); i++) {
		if (zbr+v[i] <= m) {
			zbr += v[i];
		}
		else {
			sol.push_back(zbr);
			zbr = v[i];
		}
	}
	
	if (zbr > 0) sol.push_back(zbr);
	for (int i = sol.size()-1; i >= 0; i--) cout << sol[i] << " ";

	return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int a[n];
    
    rep(i, n){
        cin >> a[i];
    }
    
    int alice_sum = 0;
    int bob_sum = 0;
    sort(a, a + n);
    if(n % 2){
        //nが奇数の場合
        for(int i = 0; i < n; i += 2)   alice_sum += a[i];
        for(int i = 1; i < n; i += 2)   bob_sum += a[i];
    }else{
        for(int i = 0; i < n; i += 2)   bob_sum += a[i];
        for(int i = 1; i < n; i += 2)   alice_sum += a[i];
    }

    cout << alice_sum - bob_sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define F first
#define S second
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int main(){
  int n, m;
  int dp[2000];
  P doll[2000];
  while(cin >> n && n){
    fill(doll, doll+2000, P(0, 0));
    fill(dp, dp + 2000, INF);
    for (int i = 0; i < n; i++){
      int a, b;
      cin >> a >> b;
      doll[i] = P(-a, b);
    }
    cin >> m;
    for (int i = n; i < n + m; i++){
      int a, b;
      cin >> a >> b;
      doll[i] = P(-a, b);
    }
    sort(doll, doll + n + m, greater<P>());
    for (int i = 0; i < n + m; i++){
	*lower_bound(dp, dp + 2000, doll[i].S) = doll[i].S;
    }
     int ans;
        for(int i=n+m-1; i>=0; --i){
            if(dp[i] != INF){
                ans = i + 1;
                break;
            }
        }
	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    double a[n];
    rep(i, n){
        cin >> a[i];
        a[i] += 1e-3;
    }

    priority_queue<double> que;
    rep(i, n){
        que.push(a[i]);
    }

    rep(i, m){
        double x = que.top();
        que.pop();
        que.push(x/2.0);
    }
    
    ll sum = 0;
    while(!que.empty()){
        sum += (ll)que.top();
        que.pop();
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if(x <= 3){
		ans += (4-x);
	}
	if(y <= 3){
		ans += (4-y);
	}
	if(x == 1 && y == 1){
		ans += 4;
	}
	cout << ans * 100000 << '\n';
}

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

map<int, int> prime_factor(int n){
    map<int, int> res;
    for(int i = 2; i*i <= n; i++){
        while(n%i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

map<int, int> cnt;

int num(int m){
    int res = 0;
    for(auto p : cnt){
        if(p.second >= m-1) res++;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        map<int, int> p = prime_factor(i);
        for(auto q : p){
            cnt[q.first] += q.second;
        }
    }
    int ans = num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
        + num(5) * (num(5) - 1) * (num(3) - 2) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] balls = new int[N + 1];

		HashSet<Integer> disballs = new HashSet<Integer>();
		for (int i = 0; i < N; i++) {
			int b = sc.nextInt();
			disballs.add(b);
			balls[b]++;
		}

		int sabun = disballs.size() - K;
		if (sabun <= 0) {
			System.out.println(0);
			return;
		}

		Arrays.parallelSort(balls);
		int sum = 0;
		int c = 0;
		for (int i = 0; i < balls.length; i++) {
			if (balls[i] > 0) {
				sum += balls[i];
				c++;
			}
			if (c >= sabun)
				break;
		}
		System.out.println(sum);

	}
}



Measured memory_bytes: 100276