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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int n;
    vector<T> dat;
    BIT(int n) : n(n), dat(n+1,0){}
    void add(int x, T val){
        for(int i = x+1; i <= n; i += (i & -i)) dat[i] += val;
    }
    T sum(int x){
        T ret = 0;
        for(int i = x+1; i > 0; i -= (i & -i)) ret += dat[i];
        return ret;
    }
    T sum(int a, int b){
        return sum(b) - sum(a-1);
    }
};


int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,k; cin >> n >> k;
    vi p(n);
    rep(i,n) cin >> p[i];

    ll ans = n-k+1;
    vi s(n);
    ll mx = -1, cnt = 0;
    rep(i,n){
        if(mx < p[i]){
            cnt++;
            mx = p[i];
        }else{
            cnt = 1;
            mx = p[i];
        }
        if(cnt >= k) s[i-k+1] = 1;
    }
    REP(i,1,n) s[i] += s[i-1];

    multiset<ll> st;
    rep(i,k+1) st.insert(p[i]);
    rep(i,n-k){
        if((p[i] == *st.begin() && p[i+k] == *st.rbegin()) || (s[i] < s[i+1] && s[i+1] >= 2)){
            ans--;
        }
        st.erase(p[i]);
        st.insert(p[k+i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14188
#!/usr/bin/env python
# coding: utf-8

# In[24]:


N, T = map(int, input().split())
t = list(map(int, input().split()))


# In[25]:


ans = 0
mylist = [t[i+1] - t[i] for i in range(len(t)-1)]
for x in mylist:
    if x > T:
        ans += T
    else:
        ans += x
print(ans+T)


# In[ ]:






Measured memory_bytes: 25200
#include <iostream>
using namespace std;
using Num = long long;
typedef long long Num;

Num gcd(Num m,Num n){
	Num temp;
	while(m % n != 0){
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
Num lcm(Num m,Num n){
	return m / gcd(m,n) * n;
}
int main(){
	int n;
	Num ans = 1;
	cin >> n;
	for(int i=0;i<n;i++){
		Num t;
		cin >> t;
		ans = lcm(ans,t);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n,0);
    for(int i=0;i<n;i++){cin>>a[i];}
    vector<ll> K;
    vector<ll> dp(n+1,0);
    ll sum=0;
    for(int i=0;i<n;i++){sum+=a[i]; dp[i+1]=sum;}
    for(int i=0;i<n;i++){
        for(int t=i+1;t<=n;t++){
            K.push_back(dp[t]-dp[i]);
        }
    }
    ll x=0;
    sort(K.begin(),K.end());
    for(int i=50;i>=0;i--){
        ll X=(x|(1LL<<i));
        auto I=lower_bound(K.begin(),K.end(),X);
        ll count=K.end()-I;
        if(count>=k){
            x=X;
        }
        else{
            for(int t=0;t<K.size();t++){
                if(K[t]>>i&1){
                    K[t]^=(1LL<<i);
                }
            }
            sort(K.begin(),K.end());
        }
    }
    cout<<x<<endl;
    
    
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> v(n);
  REP(i, n) {
    ll t, d; cin >> t >> d; t--;
    v[t].push_back(d);
  }
  vector<ll> x, y;
  REP(i, n) {
    if(v[i].size() == 0) continue;
    sort(ALL(v[i]), greater<>());
    x.push_back(v[i][0]);
    FOR(j, 1, v[i].size()) y.push_back(v[i][j]);
  }
  sort(ALL(x), greater<>());
  sort(ALL(y), greater<>());
  FOR(i, 1, x.size()) x[i] += x[i-1];
  FOR(i, 1, y.size()) y[i] += y[i-1];
//  cout << x << endl << y << endl;

  ll ret = 0;
  REP(i, min((ll)x.size(), k)) {
    if(IN(0LL, (ll)y.size(), k-i-2)) {
//      cout << x[i] << " " << y[k-i-2] << endl;
      chmax(ret, x[i] + y[k - i - 2] + (i + 1) * (i + 1));
    } else {
      chmax(ret, x[i] + (i+1) * (i+1));
    }
  }
  cout << ret << endl;

  return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = 998244353L;

struct segtree{
    int n;
    vector<int> d;
    function<int(int, int)> f;
    segtree(int mx, int mode){
        n = 1;
        while(n < mx) n <<= 1;
        d = vector<int>(n << 1);
        switch (mode){
            case 0:
                f = [](int a, int b){return a + b;};
                break;
            case 1:
                f = [](int a, int b){return (a >= b? a : b);};
                break;
            case 2:
                f = [](int a, int b){return (a <= b? a : b);};
                break;
        }
    }
    int query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r == -1) r = n;
        if(a <= l && r <= b) return d[i];
        int res = 0;
        int c = (l + r) >> 1;
        if(a < c) res = f(res, query(a, b, i << 1, l, c));
        if(c < b) res = f(res, query(a, b, i << 1 | 1, c, r));
        return res;
    }
    void update(int i, int x){
        i += n;
        d[i] = x;
        while(i){
            i >>= 1;
            d[i] = f(d[2 * i], d[2 * i + 1]);
        }
    }
};

int main(){
    int n, ans = 1;
    cin >> n;
    vector<pair<ll, ll>> x(n);
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        x[i] = make_pair(a, b);
    }
    sort(begin(x), end(x));
    x.emplace_back(LINF, LINF);
    vector<int> to(n);
    segtree st(n, 1);
    for(int i = n - 1; i >= 0; i--){
        int p;
        p = lower_bound(begin(x), end(x), make_pair(x[i].first + x[i].second, -LINF)) - begin(x);
        to[i] = max(p, st.query(i, p));
        st.update(i, to[i]);
    }
    to.back() = n;
    vector<ll> dp(n + 1);
    dp[n] = 1;
    for(int i = n - 1; i >= 0; i--){
        dp[i] = (dp[to[i]] + dp[i + 1]) % MOD;
    }
    ans = dp[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9544
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
    public static void main(String args[]){

        String input[] = new String[2];

        try{
            Scanner scanner = new Scanner(System.in);
            input = scanner.nextLine().split(" ");
        } catch(InputMismatchException e){
            System.out.println(e);
        }

        int buttons[] = new int[2];
        for(int i = 0; i < input.length; i++){
            buttons[i] = Integer.parseInt(input[i]);
        }

        if(Math.abs(buttons[0] - buttons[1]) <= 1){
            System.out.println(buttons[0] + buttons[1]);
        }
        else{
            if(buttons[0] > buttons[1]){
                System.out.println(buttons[0] * 2 - 1);
            }
            else{
                System.out.println(buttons[1] * 2 - 1);
            }
        }
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h> 
using namespace std; 
 
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < int(n); ++i)
typedef pair<int, int> pii;

const int MAXN = 200000+5;
const int INF = 1000000000;
int t[4*MAXN][2];

void build(int a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v][0] = a[tl]; t[v][1] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v][0] = min(t[v*2][0] , t[v*2+1][0]);
        t[v][1] = max(t[v*2][1] , t[v*2+1][1]);
    }
}
int mini(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return INF;
    if (l == tl && r == tr) {
        return t[v][0];
    }
    int tm = (tl + tr) / 2;
    return min(mini(v*2, tl, tm, l, min(r, tm)), mini(v*2+1, tm+1, tr, max(l, tm+1), r));
}
int maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return -INF;
    if (l == tl && r == tr) {
        return t[v][1];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)), maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v][0] = new_val;
        t[v][1] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v][0] = min(t[v*2][0] , t[v*2+1][0]);
        t[v][1] = max(t[v*2][1] , t[v*2+1][1]);
    }
}
int N,k;
int num[MAXN];
int dp[MAXN];
int pos[MAXN];
void solve(){
	cin>>N>>k;
	forn(i,N){
		cin>>num[i];
		pos[num[i]] = i;
	}
	build(num, 1, 0, N-1);
	dp[0] = 1;
	for(int i = 1 ;i<N;i++){
		if(num[i]>num[i-1]){
			dp[i] = dp[i-1]+1;
		}
		else{
			dp[i] = 1;
		}
	}
	int numks = 0;
	
	if(dp[k-1]>=k){
		numks++;
	}
	int tot = 1-numks;
	for(int i = k;i<N;i++){
	//cout<<i<<" ii "<<dp[i]<<endl;
		if(dp[i]>=k && numks == 0){
			numks++;
		}
		int m1 = maxi(1, 0, N-1, i-k, i);
		int m2 = mini(1, 0, N-1, i-k, i);
		//cout<<m1<<" "<<m2<<endl;
		if(dp[i]<k && (pos[m1] != i || pos[m2] != i-k)){
		//	cout<<"Here"<<endl;
			tot++;
		}
		//cout<<"Tot "<<tot<<endl;
	}
	cout<<tot+numks<<endl;
}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	solve();
	
	return 0;	
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;

int N, D, A;
pair<int, int> M[200200];

int main()
{
	scanf ("%d %d %d", &N, &D, &A);
	for (int i = 0; i < N; i++){
		int x, h; scanf ("%d %d", &x, &h);
		x -= D;
		M[i] = { x,h };
	}
	sort(M, M + N);

	long long drops = 0, have = 0;
	queue<pair<int, long long> > Q;
	for (int i = 0; i < N; i++){
		while (!Q.empty() && Q.front().first < M[i].first){
			have -= Q.front().second;
			Q.pop();
		}
		
		long long nh = M[i].second - have * A;
		if (nh > 0){
			long long d = (nh + A - 1) / A;
			Q.push({ M[i].first + 2 * D, d });
			drops += d;  have += d;
		}
	}

	printf ("%lld\n", drops);

	return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a = s.next();
		String b = s.next();
		String answer = "";

		int naa = a.length();
		int nab = b.length();
		int i = 0;

		if (naa == nab) {

			if (a.equals(b)) {
				answer = "EQUAL";
			} else {
				for (i = 0; i < naa; i++) {
					int q=a.charAt(i)+0;

					int l=b.charAt(i)-0;

					if(q>l) {
						answer = "GREATER";
						break;
					}else if(q<l) {
						answer = "LESS";
						break;
					}

				}
			}

		} else if (naa > nab) {
			answer = "GREATER";
		} else if (naa < nab) {
			answer = "LESS";
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 21972
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]): Unit = {

    val Array(n, k) = readLine().split(' ').map(_.toInt)
    val hs: Vector[Long] = (1 to n).map(_ => readLine().toLong).toVector.sorted
    println(solve(n, k, hs))

  }

  def solve(n: Int, k: Int, hs: Vector[Long]): Long = {

    (0 to (n - k)).foldLeft(hs(n - 1) - hs(0))((acc, i) =>
      acc min (hs(i + k - 1) - hs(i)))

  }

}


Measured memory_bytes: 38604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int q[N],n,jb,rt,dep[N],fa[N],vis[N];
poly v[N];
void GG(){
	puts("-1"); exit(0);
}
poly solve(int *q,int m){
	int cnt=0;
	poly ans;
	For(i,1,m){
		int jj=++cnt;
		For(j,1,q[i])ans.pb(++cnt);
		ans.pb(jj);
	}
	if(cnt<n)GG(); return ans;
}
void dfs(int p){
	dep[p]=dep[fa[p]]+1; if(dep[p]>dep[rt])rt=p;
	for(auto i:v[p])if(i!=fa[p]){fa[i]=p; dfs(i);}
}
int main(){
	n=read();
	For(i,1,n-1){
		int s=read(),t=read();
		v[s].pb(t); v[t].pb(s);
	}
	dfs(1);
	fa[rt]=0; int zs=rt; rt=0; dfs(zs);
	for(int i=rt;i;i=fa[i])vis[i]=1;
	for(int i=rt;i;i=fa[i]){
		jb++;
		for(auto j:v[i])if(!vis[j])q[jb]++;
	}
	poly ans=solve(q,jb);
	reverse(q+1,q+jb+1);
	ans=min(ans,solve(q,jb));
	for(auto i:ans)wri(i);
}

Measured memory_bytes: 13176
n, m = map(int, input().split())
a = list()
for i in range(n):
	a.append(list(map(int, input().split())))
b = list()
for i in range(m):
	b.append(int(input()))
for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j] * b[j]
	print(ans)



Measured memory_bytes: 6008
#include<iostream>
using namespace std;
int main(){
    long long A,B,K;
    cin>>A>>B>>K;
    if(A>=K){
      cout<<A-K<<" "<<B<<endl;
    }
    else if(A+B>=K){
      cout<<0<<" "<<B+A-K<<endl;
    }
    else cout<<0<<" "<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 55;
int n;
pa a[N];
map<pa,int>f;

int main(){
	n=read();
	For(i,1,n) a[i].fi=read(),a[i].se=read(),f[a[i]]=1;
	int ans=n;
	For(i,1,n){
		For(j,i+1,n){
			int x=a[i].fi-a[j].fi,y=a[i].se-a[j].se;
			int ret=0;
			For(k,1,n) if (!f[mp(a[k].fi+x,a[k].se+y)]) ++ret;
			ans=min(ans,ret);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6292
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
 
SP = []
for i in range(N):
  s,p = input().split()
  SP.append((s,-int(p),i+1))
  
SP.sort()
 
for s,p,i in SP:
  print(i)

Measured memory_bytes: 9136
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate
    n = int(readline())
    a = list(map(int, readline().split()))
    cum = list(accumulate(a))

    left_lim = 1
    right_lim = n - 2
    first = 0
    second = 1
    third = 2
    ans = INF

    for second in range(left_lim, right_lim + 1):
        if third == second:
            third += 1

        p = cum[first]
        q = cum[second] - cum[first]
        r = cum[third] - cum[second]
        s = cum[n - 1] - cum[third]

        while first < second:
            if abs(p - q) > abs((p + a[first + 1]) - (q - a[first + 1])):
                first += 1
                p += a[first]
                q -= a[first]
            else:
                break

        while third < n - 1:
            if abs(r - s) > abs((r + a[third + 1]) - (s - a[third + 1])):
                third += 1
                r += a[third]
                s -= a[third]
            else:
                break

        val = abs(max(p, q, r, s) - min(p, q, r, s))
        ans = min(val, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll k;
    cin>>k;
    ll ans=0;
    rep(1,a,k+1){
        rep(1,b,k+1){
            rep(1,c,k+1)ans+=gcd(a,gcd(b,c));
        }
    }
    cout<<ans;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

  auto g = make_vec<ll>(n, n);
  auto g2 = make_vec<ll>(n, n);
  REP(i, n) REP(j, n) {
    cin >> g[i][j];
    g2[i][j] = g[i][j];
  }

  REP(k, n) REP(i, n) REP(j, n) chmin(g[i][j], g[i][k] + g[k][j]);

  bool flg = true;
  ll ans = 0;
  REP(i, n) for(int j = i + 1;j < n; j++) {
    if(g[i][j] != g2[i][j]) flg = false;
    
    bool ok = true;
    REP(k, n) {
      if(i == k || j == k) continue;
      if(g[i][j] == g[i][k]+g[k][j]) {
        ok = false;
        break;
      }
    }
    if(ok) ans += g[i][j];
  }

  cout << (flg ? ans : -1) << endl;

  return 0;
}


Measured memory_bytes: 1664
import collections
N =int(input())
V =list(map(int,input().split()))
ev_col = collections.Counter(V[::2]).most_common()
od_col = collections.Counter(V[1::2]).most_common()
 
if ev_col[0][0] != od_col[0][0]:
    ans = N - od_col[0][1] - ev_col[0][1]
else:
    if len(ev_col) >= 2 and len(od_col)  >= 2:
        if ev_col[1][1] >= od_col[1][1]:
            ans = N - ev_col[1][1] - od_col[0][1]
        else:
            ans = N - od_col[1][1] - ev_col[0][1]
    else:
        ans = N - ev_col[0][1]
print(ans)

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

int main(){
  int a, b, c, d, e, f, g, h, i, j;
  cin >> a;
  b = a / 1000; // 1000 made shou
  c = a % 1000; // 100 to 10 to 1 no kurai
  d = a / 100; // 100 made shou
  e = a % 100; //10 to 1 no kurai
  f = a / 10; // 10 made shou
  g = a % 10; // 1 no kurai
  h = (e - g) / 10; // 10 no kurai
  i = (c - e) / 100; // 100 no kurai
  j = (a - c) / 1000; // 1000 no kurai
  if(j == i && i == h)
    cout << "Yes" << endl;
  else if(i == h && h == g)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        c: char,
    }
    println!(
        "{}",
        match c {
            'a' | 'i' | 'u' | 'e' | 'o' => "vowel",
            _ => "consonant",
        }
    );
}


Measured memory_bytes: 2128
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[100005];
    //bool flag=false;
    int x,n,k=0,r,p,tmp_i=0,tmp_j,tmp,cnt=0;
    //ll m,ans=0;
    char s[100];
   
    cin >> n >> s;
    //for(int i=0;i<n;i++) cin >> a[i];
    //for(int i=0;i<n;i++) cin >> t[i];

    for(int i=0;i<n;i++){
      if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        cnt++;
    }
    
    
    //cout << ((500*k >= x) ? "Yes" : "No");
    cout << cnt;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


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

#define STACK_MAX 1000
#define STACK_INIT 0
#define FORM_MAX 100
#define FORM_INIT 0
#define VER_INIT 0
#define FIRST_ITEM 0
#define SECOND_ITEM 1
#define EXIT_SUCCESS 0
#define NEXT_ITEM( x ) ( ( x ) + 1 )

signed long aslG_Dstack[ STACK_MAX ] = { STACK_INIT };
unsigned long pulG_Dstack_p = VER_INIT;

static void push( signed long slW_Dpush_calc ){
	pulG_Dstack_p++;
	aslG_Dstack[ pulG_Dstack_p ] = slW_Dpush_calc;
}

static signed long pop( void ){
	pulG_Dstack_p--;
	return aslG_Dstack[ NEXT_ITEM( pulG_Dstack_p ) ];
}

static void plus( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_second = pop();
	slW_Dcalc_first = pop();
	slW_Dver_throw = slW_Dcalc_first + slW_Dcalc_second;
	push( slW_Dver_throw );
}

static void minus( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_second = pop();
	slW_Dcalc_first = pop();
	slW_Dver_throw = slW_Dcalc_first - slW_Dcalc_second;
	push( slW_Dver_throw );
}

static void multi( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_second = pop();
	slW_Dcalc_first = pop();
	slW_Dver_throw = slW_Dcalc_first * slW_Dcalc_second;
	push( slW_Dver_throw );
}

int main( void ){
	unsigned char aulW_Dform[ FORM_MAX ] = { FORM_INIT };
	signed long slW_Dcalc = VER_INIT;

	while( scanf( "%s", aulW_Dform ) != EOF ){
		if( aulW_Dform[ FIRST_ITEM ] == '+' ){
			plus();
		}
		else if( aulW_Dform[ FIRST_ITEM ] == '-' ){
			minus();
		}
		else if( aulW_Dform[ FIRST_ITEM ] == '*' ){
			multi();
		}
		else{
			slW_Dcalc = atoi( aulW_Dform );
			push( slW_Dcalc );
		}
	}
	printf( "%d\n", aslG_Dstack[ SECOND_ITEM ] );
	return EXIT_SUCCESS;
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int R,G,B,N; cin>>R>>G>>B>>N;
  
  int ans=0;

  for(int r=0;r*R<=N;r++){
    for(int g=0;g*G+r*R<=N;g++){
      if((N-r*R-g*G)%B==0){
        ans++;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    int64 x;
    cin>>x;
    for (int64 i = 1; ; i++)
    {
        if (x*i%360==0)
        {
            cout<<i<<endl;
            return 0;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3620
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n, k, s, ans;
vll a;

bool check(ll g) {
    vll b(a);
    for_each(b.begin(), b.end(), [&](ll &x) { x %= g; });
    sort(b.begin(), b.end());
    ll l = 0, r = n - 1, r_sum = 0, moves = 0;
    while (l <= r) {
        if (r_sum <= 0) {
            r_sum += b[l];
            moves += b[l];
            l++;
        } else {
            r_sum -= g - b[r];
            moves += g - b[r];
            r--;
        }
    }
    return r_sum == 0 && moves <= 2 * k;
}

int main() {
    fast_io; cout_precision;
    cin >> n >> k;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    ans = 1;
    for (ll i = 1; i * i <= s; i++) {
        if (s % i != 0) {
            continue;
        }
        if (check(i)) {
            ans = max(ans, i);
        }
        if (check(s / i)) {
            ans = max(ans, s / i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
def CutandCount(n , s):

    ans = 0

    for i in range(1 , n + 1):
        count = 0
        for w in range(ord('a'), ord('z') + 1):
            if chr(w) in s[:i] and chr(w) in s[i:]:
                count += 1

        ans = max(ans , count)

    return ans

def main():
    n = int(input())
    s = str(input())
    print(CutandCount(n , s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
while ( True ):
    n = int(input())
    if n == 0 : break
    ki = list(map(int, input().split()))
    less1Cnt = 0
    zeroCnt = 0
    for k in ki:
        if k <= 1 : less1Cnt += 1
        if k == 0 : zeroCnt += 1

    if n == less1Cnt : print("NA")
    else : print(n - zeroCnt + 1)



Measured memory_bytes: 7204
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c << endl;
  if(b == c) cout << a << endl;
  if(c == a) cout << b << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
x, n = list(map(int, input().split()))
if not n:
  print(x) 
else:
  l = list(map(int, input().split()))
  dic = {} 
  for ll in l: dic[ll] = 1
  i = 0
  while True:
    if not dic.get(x-i,0):
      print(x-i)
      break
    elif not dic.get(x+i, 0):
      print(x+i) 
      break
    i+=1

Measured memory_bytes: 9196
#include <cstdio>
#include <cstdlib>

int main(){
    int N, K;
    char* S;
    scanf("%d%d", &N, &K);
    S = (char*)malloc(sizeof(char)*(N+1));
    scanf("%s", S);
    S[K-1] = (char)((int)S[K-1] + (int)'a' - (int)'A');
    printf("%s\n", S);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N;
	vector<ll> A, B, O;
	scanf("%d", &N);
	A.resize(N);
	O.resize(N);

	rep(i, N) scanf("%lld", &A[i]);


	ll ans = 0;

	rep(t, 2) {

		sort(A.begin(), A.end());
		if (t) reverse(A.begin(), A.end());

		B.push_back(A[0]);

		for (ll M = N - 1, m = 1;;) {
			B.push_back(A[M]);
			if (M == m) break;
			--M;
			B.push_back(A[M]);
			if (M == m) break;
			--M;
			B.push_back(A[m]);
			if (M == m) break;
			++m;
			B.push_back(A[m]);
			if (M == m) break;
			++m;
		}

		reverse(B.begin(), B.end());
		O[(N - 1) / 2] = *(B.end() - 1);
		B.pop_back();
		for (int i = 1; B.size(); ++i) {
			O[(N - 1) / 2 + i] = *(B.end() - 1);
			B.pop_back();
			if (!B.size()) break;
			O[(N - 1) / 2 - i] = *(B.end() - 1);
			B.pop_back();
		}

		ll sum = 0;

		rep(i, N - 1) sum += abs(O[i + 1] - O[i]);

		ans = max(ans, sum);

	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;


int main() {
    int x; cin >> x;
    int a,b;
    a = x/500;
    x %= 500;
    b = max(0,x/5);
    cout << 1000 * a + b * 5 << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var qur = Input.num;
        const int NUM = (int)1e5 + 1;
        var bo = new bool[NUM];
        for (var i = 2; i < NUM; i++)
            if (!bo[i])
                for (var j = 2 * i; j < NUM; j += i)
                    bo[j] = true;
        var ct = new int[NUM];
        for (var i = 3; i < NUM; i += 2)
            ct[i] = ct[i - 2] + ToInt32(!bo[i] && !bo[(i + 1) / 2]);
        var res = new int[qur];
        for(var i = 0; i < qur; i++)
        {
            var lr = Input.ar;
            res[i] = lr[0] != 1 ? ct[lr[1]] - ct[lr[0] - 2] : ct[lr[1]];
        }
        WriteLine(string.Join("\n", res));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 18752
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

struct node{int l;int r;};
node a[30];
int height(int h[],int i)
{
	int h1=0;
	int h2=0;
	if(a[i].r!=-1)
	{
		h1=height(h,a[i].r)+1;
	}
	if(a[i].l!=-1)
	{
		h2=height(h,a[i].l)+1;
	}
	h[i]=max(h1,h2);
	return h[i];
}

int main()
{
	int n;cin>>n;
	int k,l,r;
	int b[30],h[30];
	for(int i=0;i<30;b[i++]=-1);
	for(int i=0;i<n;i++)
	{
		cin>>k>>l>>r;
		a[k].l=l;
		a[k].r=r;
		if(l+1)b[l]=k;
		if(r+1)b[r]=k;
	}
	for(int i=0;i<n;i++)//node id: parent = p , sibling = s , degree = deg , depth = dep , height = h , type
 	{
 		int deg=2;
 		if(a[i].l==-1||a[i].r==-1)
 		{	
 			deg=1;
 			if(a[i].l==-1&&a[i].r==-1)deg=0;
 		}
 		int s=-1;
 		if(b[i]==-1)s=-1;
 		else if(a[b[i]].r==i)s=a[b[i]].l;
 		else s=a[b[i]].r;
 		
 		cout<<"node "<<i<<": parent = "<<b[i]<<", sibling = "<<s<<", degree = "<<deg<<", depth = ";
		
		int dep=1;
		if(b[i]!=-1)
		{
			for(k=b[i];b[k]!=-1;k=b[k],dep++);
		}
		else dep=0;
		
		cout<<dep<<", height = "<<height(h,i)<<", ";
		
		if(b[i]==-1)cout<<"root";
		else if(a[i].l+a[i].r==-2)cout<<"leaf";
		else cout<<"internal node";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



bool tree[55][55];//a<bだけを使う

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

  rep(i,55) rep(j,55) tree[i][j] = false;
  
  ll N, M; cin >> N >> M ;//node, edge

  vector<pair<ll,ll> > edge;
  rep(i,M){
    ll a, b ; cin >> a >> b; // a<b
    tree[a-1][b-1] = true;
    tree[b-1][a-1] = true;
    edge.pb(mp(a-1,b-1));
  }

  ll ans = 0;
  rep(time,M){
    ll a = edge[time].first, b = edge[time].second;

    bool check[55][55];
    rep(m,N)rep(n,N)
      	check[m][n] = tree[m][n];

    check[a][b] = false;
    check[b][a] = false;
    
    rep(k,N)rep(i,N)rep(j,N){
      if(i==j || i==k || j==k) continue;
      else if(check[i][k] && check[k][j])
	check[i][j] = true;

    }
    if(!check[a][b]) ans ++;
  }
  

  cout << ans << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
Sa = input()
Sb = input()
Sc = input()

na = len(Sa)
nb = len(Sb)
nc = len(Sc)

cnta = 0
cntb = 0
cntc = 0
prev = "a"
while True:
    if prev == "a":
        if cnta == na:
            print("A")
            exit()
        prev = Sa[cnta]

        cnta += 1
    elif prev == "b":
        if cntb == nb:
            print("B")
            exit()
        prev = Sb[cntb]
        cntb += 1
    elif prev == "c":
        if cntc == nc:
            print("C")
            exit() 
        prev = Sc[cntc]
        cntc += 1


Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001];

double   solve(vector<double>& arr, int i ,int x)
{
    if(x==0) return 1;
    if(i==0) return 0;     
    if(dp[i][x]>-0.9)
      return dp[i][x];
    return dp[i][x]=arr[i]*solve(arr,i-1,x-1)+(1-arr[i])*solve(arr,i-1,x);
}



int main() {
   int n;
   cin>>n;
   vector<double>  arr(n+1);
   memset(dp,-1,sizeof(dp));
   for(int i=1;i<=n;i++){
       cin>>arr[i];
   }
   cout<<fixed<<setprecision(10)<<solve(arr,n,(n+1)/2);
   return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  n--;

  if (d[n / 2] == d[n / 2 + 1]) {
    cout << 0 << endl;
    return 0;
  }

  cout << d[n / 2 + 1] - d[n / 2] << endl;
  return 0;
}


Measured memory_bytes: 640
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.random;
  
void main() {
  auto a = readln.chomp.split.map!(to!int);
  auto w = a[0];
  auto h = a[1];
  auto x = a[2];
  auto y = a[3];
  auto r = a[4];

  if (x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) writeln("Yes");
  else writeln("No");
}

Measured memory_bytes: 1052
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


int main(){
    IOS
    ll n;
    cin >> n;
    vi vec(n);
    for (int i = 0; i <n ; ++i) {
        cin>>vec[i];
    }
    ll sum1 = vec[0];
    ll sum2 =vec[n-1];
    int count1 = 1;
    int count2 = n-2;
    for (int j = 1; j <n-1 ; ++j) {
        //if(count1 > count2 )break;
       //
       // cout << sum1 <<" "<< sum2<<endl;
        //cout << "test ";
        if(sum1 < sum2){
            sum1+=vec[count1];
            count1++;
            continue;
        }else{
            sum2+=vec[count2];
            count2--;
            continue;
        }
    }

    ll dif = abs(sum1 - sum2);
    cout << dif;



    return 0;



}



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

int main()
{
	int n,KO,ACE=0;
	cin>>n>>KO;
	
	for(int i=1; i<=n; i++)
	{
		if(n<=KO)
			ACE=1;
		else
		{
			ACE=n/KO;
			if(ACE*KO<n)
				ACE+=1;
		}
	}
	
	cout<<ACE<< endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	static int b=1,ans=0;
	static int[] s,p;
	static int[,] h;
	static List<int>[] li;
	static void Main(){
		s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		p=Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);
		h=new int[2,s[0]+1];
		li=new List<int>[s[0]+1];
		for(int i=1;i<=s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			li[q[0]].Add(q[1]);
			li[q[1]].Add(q[0]);
		}
		for(;b<=s[0];b++){
			if(h[0,b]==0){fu(b);}
		}
		Console.WriteLine("{0}",ans);
	}
	static void fu(int a){
		ck(a,0);
		ck(p[a],1);
		for(int i=0;i<li[a].Count;i++){
			if(h[0,li[a][i]]==0){fu(li[a][i]);}
		}
	}
	static void ck(int a,int c){
		h[c,a]=b;
		if(h[c^1,a]==b){ans++;}
	}
}

Measured memory_bytes: 33568
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////

int main(){
	int N; cin >> N;
	int A,B;
	cin >> A >> B;
	int X,Y,Z;
	X=0; Y=0; Z=0;

	REP(i,N){
		int x;
		cin >> x;

		if (x <= A) X++;
		else if ((A+1 <= x) and (x <= B)) Y++;
		else Z++;
	}

	PRINTD(min({X,Y,Z}));

}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};

string s[25];
int dis[22][22];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
void init() {
	rep(i, 22)rep(j, 22)dis[i][j] = -inf;
}

signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)cin >> s[i];

	int ans = 0;

	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '.') {
				init();
				queue<P>Q;
				dis[i][j] = 0;
				Q.push(P(0,i*w+j));
				while (Q.size()) {
					P p = Q.front(); Q.pop();
					int X = p.second / w, Y = p.second%w;
					rep(k, 4) {
						int nx = X + dx[k], ny = Y + dy[k];
						if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] == '.' && dis[nx][ny]==-inf) {
							dis[nx][ny] = dis[X][Y] + 1;
							Q.push(P(dis[nx][ny], nx*w + ny));
						}
					}
				}
				int res = 0;
				rep(i, h)rep(j, w)res = max(res, dis[i][j]);
				ans = max(ans, res);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B ; 
    cin >> A >> B ;
    if(A == 1 && B != 1 )
    {
        cout << "Alice";
        
    }
    else if (B == 1 && A != 1 )
    {
        cout << "Bob" ;
    }
    else if (A == B)
    {
        cout << "Draw" ;
    }
    else if (A > B && B != 1)
    {
        cout << "Alice" ;
    }   
    else if (B > A && A != 1)
    {
        cout << "Bob" ;
    }   
    return 0;
}


Measured memory_bytes: 3104
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val (N, T) = readLine()!!.split(" ").map(String::toInt)

    var min:Int? = null
    for (n in 0 until N) {
        val (c, t) = readLine()!!.split(" ").map(String::toInt)
        if (t > T) continue

        min = if (min == null) c else Math.min(min, c)
    }
    println(min?:"TLE")
}

Measured memory_bytes: 36060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


int main() {
    ll N; cin >> N;
    ll ans5 = 0LL;
    ll num5=5;
    if(N%2){
        cout << 0 << endl;
        return 0;
    }
    while(N>=num5){
        ans5 += N/(num5*2);
        num5 *= 5;
    }

    cout << ans5 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    int cnt = 0;
    if (A >= B) {
        while (A >= B) { B *= 2; cnt++; }
    }
    if (B >= C) {
        while (B >= C) { C *= 2; cnt++; }
    }
    if (cnt <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3616