akhauriyash/Code-Regression huggingface dataset:
import java.awt.geom.Point2D;
import java.util.*;

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

	public Main() {
		new AOJ0090().doIt();
	}

	class AOJ0090{
		void doIt(){
			final double EPS=1.0e-8;
			while(true){
				int n = in.nextInt();
				if(n==0)break;
				ArrayList<Point2D> p = new ArrayList<Point2D>();
				ArrayList<Point2D> list = new ArrayList<Point2D>();
				for(int i=0;i<n;i++){
					String res[] = in.next().split(",");
					p.add(new Point2D.Double(Double.parseDouble(res[0]),Double.parseDouble(res[1])));
				}
				for(int i=0;i<n;i++)for(int s=i+1;s<n;s++){
					Point2D[] a = intersectPtCC(new Circle(p.get(i),1),new Circle(p.get(s),1));
					if(a==null)continue;
					list.add(a[0]);list.add(a[1]);
				}
				int result = 1;
				for(int i=0;i<list.size();i++){
					int cnt = 0;
					for(int s=0;s<n;s++){
						if(list.get(i).distanceSq(p.get(s))<=(1+EPS)*(1+EPS))cnt++;
					}
					result = Math.max(result, cnt);
				}
				System.out.println(result);
			}
		}

		class Circle{
			Point2D p;
			double r;
			Circle(Point2D p,double r){ 
				this.p=p;
				this.r=r;
			}
			Circle(double x,double y,double r){  
				this.p=new Point2D.Double(x,y); 
				this.r=r;
			}
		}
		 //円と円の交点
		Point2D [] intersectPtCC(Circle a,Circle b){
		double dis = a.p.distance(b.p);
		if(dis > a.r + b.r)return null;
		Point2D v = sub(b.p, a.p);
		double rc=(dis*dis+a.r*a.r- b.r*b.r)/(2*dis);
		double rate = rc / dis;
		v = mul(rate, v);
		Point2D c = add(v, a.p);
		double disC2c = c.distance(b.p);
		double disqc = Math.sqrt(b.r * b.r - disC2c * disC2c);
		Point2D v2 = sub(b.p, c);
		v2 = mul(disqc / disC2c, v2);
		Point2D [] res = new Point2D[2];
		res[0] = add(normalVector1(v2), c);
		res[1] = add(normalVector2(v2), c);
		return res;
		}

		Point2D normalVector1(Point2D p){
			return new Point2D.Double(-p.getY(), p.getX());
		}
		Point2D normalVector2(Point2D p){
			return new Point2D.Double(p.getY(), -p.getX());
		}
		Point2D mul(double n,Point2D p1){
			return new Point2D.Double(p1.getX()*n,p1.getY()*n);
		}
		Point2D sub(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()-p2.getX(),p1.getY()-p2.getY());
		}
		Point2D add(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()+p2.getX(), p1.getY()+p2.getY());
		}
	}
}

Measured memory_bytes: 25620
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	string  s;
	cin>>s;
	int ans=0;
	bool a=false;
	for(int i=1;i<s.size();i++){
		if(s[i]!='9'){
			a=true;
		}
		ans+=9;
	}
	if(a){
		ans+=s[0]-'1';
	}
	else{
		ans+=s[0]-'0';
	}
	
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

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

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}

	int diff = INF;

	int ans = -1;
	for (int i = 0; i < n; i++) {
		int bufd=abs(n*a[i] - sum);

		if (diff > bufd) {
			diff = bufd;
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define pi 3.14
#define maxn 10009
#define eps (long double)1e-9 
#define MOD 1000000007
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<max(a+b,max(a*b,a-b));
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        int a;
        cin >> a;
        sum += a;
    }

    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    vector<Int> A(N);
    unordered_map<Int, Int> mp;
    rep(i, 0, N) { cin >> A[i]; mp[A[i]]++; }

    if (N%2 == 0) {
        for(Int i = 1; i < N; i += 2) {
            if (mp[i] != 2) { cout << 0 << endl; return 0; }
        }
    }
    else {
        if (mp[0] != 1) { cout << 0 << endl; return 0; }
        for(Int i = 2; i < N; i += 2) {
            if (mp[i] != 2) { cout << 0 << endl; return 0; }
        }
    }

    Int res = 1;
    rep(i, 0, N/2) {
        res *= 2;
        res %= 1000000007;
    }

    cout << res << endl;
}


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

int main(){
    int n; cin >> n;
    if ( n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon" << endl;
    else if ( n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8 ) cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

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

Nlist = [0 for i in range(10)]

Ntmp = N
for i in range(10):
    Nlist[i] = Ntmp % 10
    Ntmp = Ntmp // 10

sum = 0
for i in range(10):
    sum = sum + Nlist[i]

if N % sum == 0:
    print('Yes')
else:
    print('No')


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		100050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int par[MAX],rankn[MAX];

void init(int n){
	for(int i=0;i<n;++i){
		par[i] = i;
		rankn[i] = 0;
	}
}

int ufind(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x] = ufind(par[x]);
	}
}

void unite(int x,int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y) return ;
	if(rankn[x] < rankn[y]){
		par[x] = y;
	}else{
		par[y]=x;
		if(rankn[x]==rankn[y])rankn[x]++;
	}
}
bool same(int x,int y){
	return  (ufind(x) == ufind(y));
}

//
int main(){
	int N,M;
	cin>>N>>M;
	V X(M);
	REP(i,M)cin>>X[i];
	sort(ALL(X));
	V d(M-1);
	REP(i,M-1)d[i] = X[i+1]-X[i];
	sort(ALL(d));
	//init(M);

	ll ans = 0;
	REP(i,M-N)ans += d[i];

	cout << ans << endl;

	return 0;
}




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

using namespace std;
typedef long long ll;
const int MAXN=2005,MOD=1e9+7;
int n,k,fac[MAXN*MAXN],inv[MAXN*MAXN],dp[MAXN];

ll quick_pow(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,a=a*a%MOD)
		if(b&1) ret=ret*a%MOD;
	return ret;
}
ll C(int a,int b)
{if(a<b) return 0;return 1ll*fac[a]*inv[a-b]%MOD*inv[b]%MOD;}
void inc(int &a,int b){a+b>MOD?a+=b-MOD:a+=b;}

int main()
{
	scanf("%d%d",&n,&k);
	if(k==1) return puts("1"),0;
	fac[0]=dp[0]=1;
	for(int i=1;i<=n*k;i++) fac[i]=1ll*fac[i-1]*i%MOD;
	inv[n*k]=quick_pow(fac[n*k],MOD-2);
	for(int i=n*k-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;
	
	for(int i=0;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			inc(dp[j],dp[j-1]*C(i+(k-1)*j-1,k-2)%MOD);
	
	ll res=1ll*dp[n]*fac[n]%MOD;
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 31616
#include <stdio.h>

int main(void)
{
	int h, a;
	int atk = 0;

	scanf("%d%d", &h, &a);

	/* モンスターの体力が0以下になるまで、攻撃回数を数える */
	while (h > 0)
	{
		h -= a;
		atk++;
	}

	printf("%d", atk);

	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int n;
	while (~scanf("%d", &n)) {
		vector<int> a(n);
		for (int i = 0; i < n; ++ i)
			scanf("%d", &a[i]);
		ll ans = INFL;
		rep(k, 2) {
			ll sum = 0, cost = 0;
			rep(i, n) {
				sum += a[i];
				int sign = (k + i) % 2 == 0 ? 1 : -1;
				if (sum * sign <= 0) {
					ll t = abs(sum) + 1;
					cost += t;
					sum += t * sign;
				}
			}
			amin(ans, cost);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

ll n,k;
vector<ll> g[100010]; 
ll ans=0;
ll d1[100030],d2[100030];
vector<bool> used(100010,false);

ll mult(ll n,ll m){//n^m%modを求める
    if(m==0) return 1;
    if(m==1){
        return n%mod;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%mod;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%mod;
    }
}

void make_table(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			d1[i]=1;
			d2[i]=1;
		}else{
			d1[i]=(i*d1[i-1])%mod;
			d2[i]=mult(d1[i],mod-2);
		}
	}
}

template <class T>
T comb_mod_2(T n,T k){
    if(n<k) return 0;
    return (((d1[n]*d2[n-k])%mod)*d2[k])%mod;
}

void dfs(ll v){
  if(used[v]) return ;
  //cout<<' '<<v<<endl;
  used[v]=true;
  ll num=0;
  for(auto itr:g[v]){
    if(!used[itr]) num++;
  }
  if(v==1){
    ans*=comb_mod_2(k-1,num);
    ans%=mod;
    ans*=d1[num];
    ans%=mod;
    //cout<<num<<' '<<comb_mod_2(k-1,num)<<' '<<ans<<endl;
  }else{
    ans*=comb_mod_2(k-2,num);
    ans%=mod;
    ans*=d1[num];
    ans%=mod;
  }
  for(auto itr:g[v]) dfs(itr);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    rep(i,n-1){
      ll a,b;
      cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    make_table(100010);
    ans=k;
    dfs(1);
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
bingo = []
checks = {}
for i in range(3):
    a, b, c = map(int,input().split())
    bingo.append(a)
    bingo.append(b)
    bingo.append(c)
    
n = int(input())
numbers = [int(input()) for i in range(n)]

for number in numbers:
    if number in bingo:
        l = bingo.index(number)
        bingo[l] = 0
        
result = "No"

for i in range(3):
    if sum(bingo[i*3:i*3 + 3])==0:
        result = "Yes"

for i in range(3):     
    if sum(bingo[i::3])==0:
        result = "Yes"

if sum(bingo[2:7:2]) == 0 :
    result = "Yes"
    
if sum(bingo[0::4]) == 0:
    result = "Yes"
    
print(result)


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

int n, x, y;

bitset<100> used;
int ans;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<pair<int, int>> a(n), b(n);
    for (auto& i : a) cin >> i.second >> i.first;
    for (auto& i : b) cin >> i.second >> i.first;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	vector<int> groups(n);
	vector<pair<int, vector<int>>> sz(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[j].first < b[i].first && a[j].second < b[i].second) {
				sz[i].second.push_back(j);
				groups[j]++;
			}
		}
		sz[i].first = sz[i].second.size();
	}
	sort(sz.begin(), sz.end());
	
	for (int i = 0; i < n; i++) {
		int node = -1, rem = -1;
		for (auto& j : sz[i].second) {
			if (!used[j]) {
				if (rem == -1 || groups[j] < rem) {
					node = j;
					rem = groups[j];
				}
			}
			groups[j]--;
		}
		if (node != -1) {
			used[node] = 1;
			ans++;
		}
	}

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[100005][4];
int a[100005][4];
int n;
 int max_pts(int row,int i)
 {
     if(dp[row][i] != -1){
         return dp[row][i];
     }

     if(i==1){
         if(row==n){return max(a[row][2],a[row][3]);}
         int op1 = a[row][2] + max_pts(row+1,2);
         int op2 = a[row][3] + max_pts(row+1,3);
         return dp[row][i] = max(op1,op2);
     }
    else if(i==2){
         if(row==n){return max(a[row][1],a[row][3]);}
         int op1 = a[row][1] + max_pts(row+1,1);
         int op2 = a[row][3] + max_pts(row+1,3);
         return dp[row][i] = max(op1,op2);
     }

     else{
         if(row==n){return max(a[row][1],a[row][2]);}
         int op1 = a[row][1] + max_pts(row+1,1);
         int op2 = a[row][2] + max_pts(row+1,2);
         return dp[row][i] = max(op1,op2);
     }
     

 }
 int32_t main(){
     cin>>n;
     memset(a,0,sizeof(0));
     
     for(int i=1;i<=n;i++){
         for(int j=1;j<=3;j++){
             cin>>a[i][j];
         }
     }
     memset(dp,-1,sizeof(dp));
     int op1 = max_pts(1,1);

      memset(dp,-1,sizeof(dp));
     int op2 = max_pts(1,2);

      memset(dp,-1,sizeof(dp));
     int op3 = max_pts(1,3);

     cout<<max(max(op1,op2),op3);
 }

Measured memory_bytes: 14496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll a;
    cin >> a;
    while (a--)
    {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, s.size())if (s[i] != t[i])ans++;
	cout << ans << "\n";
}



signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)
	solve();
		return 0;
}


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

signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int ans = 0;
  int L = 0;
  rep(i, N) L += A[i];
  
  int m = 0;
  int M = 0;
  rep(i, N) {
    if(m < L/2) m += A[i];
    if(m == L/2) {
      cout << 0 << endl;
      return 0;
    }
    if(m > L/2) {
      M = m;
      m -= A[i];
      break;
    }
  }
  
  ans = min(abs(L-m-m), abs(L-M-M));
  
  cout << ans <<endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}

int main() {
    FAST;
    //freopen ("in.txt", "r", stdin);
    int n;cin>>n;
    vi a(n);
    FOR(i,n)cin>>a[i];
    int cnt=0;
    bool changed=false;
    for(int i=1;i<n;i++){
        if (changed){
            changed=false;
        }else{
            if (a[i]==a[i-1]){
                cnt++;
                changed=true;
            }
        }
    }
    cout << cnt;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int w,h;
	
	while(1){
		scanf("%d", &h);
		scanf("%d", &w);
		
		if(w == 0 && h == 0)
			return 0;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if( i == 0 || j == 0 || i == (h-1) || j == (w-1))
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<int> X(N);
    int s = 0;
    REP(i,N) { cin >> X[i]; s += X[i];}
    int p1, p2;
    p1 = s/N;
    p2 = (s+N-1)/N;
    int ans1 = 0;
    REP(i,N) ans1 += (X[i]-p1)*(X[i]-p1);
    int ans2 = 0;
    REP(i,N) ans2 += (X[i]-p2)*(X[i]-p2);
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int n;cin>>n;
        vi a(n);
        inputarr(a,n);
        // int ans=0;
        // // reverse(all(a));
        // FORD(i,n-2,1){
        //     if(a[i]<=a[i+1]){
        //        ans++;
        //     }
        //     amin(a[i],a[i+1]);
        // }
        // cout<<ans<<endl;
        int ans=1;
        rep(1,n){
            if(a[i]<=a[i-1]){
                ans++;
            }
            amin(a[i],a[i-1]);
        }
        cout<<ans<<endl;



        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 1792
l = input().split()
N = int(l[0])

l = input().split()
W = [int(x) for x in l]

# print(N, W)

# W.sort()

min_diff = 100*100
for i in range(N):
    diff = sum(W[0:i]) - sum(W[i:])
    if diff < 0:
        diff = -diff
    if min_diff > diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 38512
s= [i+1 for i in range(13)]
h= [i+1 for i in range(13)]
c= [i+1 for i in range(13)]
d= [i+1 for i in range(13)]
 
n=int(input())
for cnt in range(n):
    e,n =input().split()
    if e == 'S':s[int(n)-1]=0
    elif e == 'H':h[int(n)-1]=0
    elif e == 'C':c[int(n)-1]=0
    elif e == 'D':d[int(n)-1]=0
 
for i in s:
    if i != 0: print('S '+repr(i))
for i in h:
    if i != 0: print('H '+repr(i))
for i in c:
    if i != 0: print('C '+repr(i))
for i in d:
    if i != 0: print('D '+repr(i))

Measured memory_bytes: 7760
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int f[200001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        f[x]++;
    }
    vi v;
    for (int i = 1; i < 200001; ++i)
        if (f[i])
            v.push_back(f[i]);

    sort(all(v));
    int p = 0, sol = 0;
    while (v.size() - p > k)
        sol += v[p++];
    cout << sol;
}


Measured memory_bytes: 2168
n = int(input())
restaurant_list = []
for i in range(n):
    s, p = input().split()
    restaurant_list.append([s, int(p), i+1])

restaurant_list_ordered = sorted(restaurant_list, key=lambda x: (x[0], -x[1]))

for e in restaurant_list_ordered:
    print(e[2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	cout<<N*(N-1)/2-N/2<<endl;
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;++j){
			if(j==((N%2)?N:N+1)-i)continue;
			cout<<i<<' '<<j<<endl;
		}
	}
}

Measured memory_bytes: 3508
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

void ctsm(const int &tmp, long long int &sm, long long int &ct)
{
    if ((0LL <= sm + tmp) && (0LL < sm))
    {
        ct += 1LL + sm + tmp;
        sm = -1LL;
    }
    else if ((sm + tmp <= 0LL) && (sm < 0LL))
    {
        ct += 1LL - sm - tmp;
        sm = 1LL;
    }
    else sm = sm + tmp;
}

int main()
{
    int n;
    gc(n);

    int tmp;

    gc(tmp);

    long long int sm = 0LL;
    long long int ct = 0LL;

    sm = 0 == tmp ? 1LL : sm + tmp;
    ct = 0 == tmp ? 1LL : ct;

    // opposite
    tmp = (-1) * tmp;

    long long opsm = 0LL;
    long long opct = 0LL;

    opsm = 0 == tmp ? -1LL : 0 < tmp ? 1LL : -1LL;
    opct += abs(tmp) + 1LL;

    for (int i = 1; i < n; i++)
    {
        gc(tmp);

        // count sum
        ctsm(tmp, sm, ct);
        // opposite count sum
        ctsm(tmp, opsm, opct);
    }

    printf("%lld\n", ct < opct ? ct : opct);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N; cin >> N;
    int max = 0;
    int sum = 0;
    int i = 0;
    while (i < N) {
        int tmp;
        cin >> tmp;
        if (tmp > max) max = tmp;
        sum += tmp;
        i++;
    }
    max < sum - max ? cout << "Yes" << endl : cout << "No" << endl;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = (n * (n - 1) + m * (m - 1)) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5e5+5;
int vis[N],st[N],a[N],top,n,x;
int main(){
	scanf("%d%d",&n,&x);
	if(x==1||x==(n<<1)-1)return puts("No"),0;
	puts("Yes");
	if(x!=2){
		a[n]=x,a[n-1]=x+1,a[n+1]=x-1,a[n+2]=x-2;
		vis[x]=vis[x+1]=vis[x-1]=vis[x-2]=1;
	}else{
		a[n]=x,a[n-1]=x-1,a[n+1]=x+1,a[n+2]=x+2;
		vis[x]=vis[x-1]=vis[x+1]=vis[x+2]=1;
	}
	fp(i,1,(n<<1)-1)if(!vis[i])st[++top]=i;
	fp(i,1,n-2)a[i]=st[top--];
	fp(i,n+3,(n<<1)-1)a[i]=st[top--];
	fp(i,1,(n<<1)-1)printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define int long long
int a[214514];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=1141541919810;
    int sum=0;
    int sum1=0;
    for(int l=0;l<n;l++){
        sum1+=a[l];
    }
    for(int k=0;k<n-1;k++){
        sum+=a[k];
        if(abs(sum1-sum*2)<ans){
            ans=abs(sum1-sum*2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d",&a,&b);
	c=a+b;
	if (c>=24)
	{
		d=c-24;
		printf("%d\n",d);
	}else
	{
		printf("%d\n",c);
	}
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int List [][] = new int [N][D];
        int opt =0;
        for(int i=0;i<N;i++) for(int j=0;j<D;j++)List[i][j]=sc.nextInt();
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                int sum=0;
                for(int k=0;k<D;k++){
                    sum+=Math.pow(List[i][k]-List[j][k],2);
                }
                double num = Math.sqrt(sum);
                if(Math.round(num)==num) opt++;
            }
        }
        System.out.println(opt);
    }
}


Measured memory_bytes: 23124
# 5で割って1余る素数（1の位が1の素数）を挙げれば良い
def is_primary(n):
    k = 2
    while k*k <= n:
        if n % k == 0:
            return False
        k += 1
    return True

n = int(input())

count = 0
ans = []
for i in range(11, 5001, 10):
    if is_primary(i):
        ans.append(i)
        count += 1
        if count == n:
            break

print(" ".join(map(str, ans)))


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100000000

#define N 3
#define N2 9
#define LIMIT 31

typedef struct { char b[N2+1]; } Board;
Board board;
int minstep;
typedef enum { R, U, L, D } Direction;
typedef struct { int pos; Direction dir; } Motion;

const Motion motion[N2][5] =
  {{{1,L},{3,U},{-1}}, {{0,R},{2,L},{4,U},{-1}}, {{1,R},{5,U},{-1}},
   {{0,D},{4,L},{6,U},{-1}}, {{1,D},{5,L},{7,U},{3,R},{-1}},
   {{2,D},{8,U},{4,R},{-1}},
   {{3,D},{7,L},{-1}}, {{4,D},{8,L},{6,R},{-1}}, {{5,D},{7,R},{-1}}  };

const int rr[4][5] = {{0,0,1,0,0},{0,0,0,1,0},{1,0,0,0,0},{0,1,0,0,0}};

int dd[N2][N2];
int dist(char *b)
{
  int i, n, d = 0;
  for (i=0; i<N2; i++) {
    n = b[i]-1;
    if (n<0)   continue;
    d += dd[n][i];
  }
  return d;
}

void search(int step, Motion prev)
{
  int i, d=0;
  d = dist(board.b);
  if (step+d>minstep) return;
  if (d==0) {
    printf("%d\n", step);
    exit(0);
  }
  Board board_bak = board;
  for (i=0; motion[prev.pos][i].pos>=0; i++) {
    Motion m = motion[prev.pos][i];
    if (rr[m.dir][prev.dir]) continue; //元に戻るのを防止
    board.b[prev.pos] = board.b[m.pos];
    board.b[m.pos] = 0;
    search(step+1, m);
    board = board_bak;
  }
}

void aaaaa(int a){
  int i, count=0;
  for(i=0; i<a; i++)count++;
}

int main()
{
  int i, j, a=10;
  for (i=0; i<N2; i++)
    for (j=0; j<N2; j++)
      dd[i][j] = abs(i%N-j%N) + abs(i/N-j/N);
  
  Motion m;
  m.dir = 4;
  Board ini_board;
  for (i=0; i<N2; i++) {
    fscanf(stdin, "%hd", (short int*)&ini_board.b[i]);
    if (ini_board.b[i]==0) m.pos = i;
  }
  for (minstep=dist(ini_board.b); minstep<=LIMIT; minstep++) {
    board = ini_board;
    search(0, m);
  }
  puts("no result.");
  aaaaa(a);
  return 0;
}




Measured memory_bytes: 2148
n = int(input())
res = []
sco = []
idx = []

for i in range(n):
    _list = list(input().split())
    _list.append(i+1)
    res.append(_list)

res = sorted(res, key=lambda x: (x[0], -int(x[1])))

for i, j, k in res:
    print(k)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int a, b,c,cake;
	cin >> a;
	cin >> b;
	a = a + 1;
	cake = 0;
	for (int i = 1; i <= b; i++) {
		cin >> c;
		cake += c;
	}
	if (cake%a == 0) {
		cout << cake / a << endl;
	}
	else {
		cout << cake / a + 1 << endl;
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
   int h,n;
  cin>>h>>n;
  
  int sum=0,x;
  
 for(int i=0; i<n; i++)
 {
     cin>>x;
   sum+=x;
 }
  
  if(sum>=h)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  
  return 0;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var k = int.Parse(list[1]);

        var countList = new List<int>();
        var tn = n;

        var _ = Math.Max(tn - k + 1, 0);
        countList.Add(_);
        tn -= _;

        while (k > 1)
        {
            var half = (int)Math.Ceiling(k * 0.5);
            _ = Math.Max(tn - half + 1, 0);
            countList.Add(_);
            tn -= _;
            k = half;
        }

        double ans = 0.0;
        double p = 1.0;

        for (int i = 0, count = countList.Count; i < count; ++i)
        {
            var c = countList[i];
            ans += p * c;
            p *= 0.5;
        }
        ans *= 1.0 / n;

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int k, s;
    cin >> k >> s;

    int count = 0;
    REP(a, k + 1) REP(b, k + 1) {
        if (s - a - b >= 0 && s - a - b <= k)
            count++;
    }

    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    string s, t;
    cin >> s >> t;
    // 塊として等しいことが必要。
    // ただし、文字のペアは一つだけ。(map[s[i]] = t[i]で管理)
    map<char, char> mp_s;
    map<char, char> mp_tt;
    for(int i=0; i<s.length(); i++){
        mp_s[s[i]] = '0';
        mp_tt[t[i]] = '0';
    }

    int flag = 0;
    for(int i=0; i<s.length()-1; i++){
        if(s[i] != s[i+1] && t[i] == t[i+1]){
            flag = 1;
        }
        else if(s[i] == s[i+1] && t[i] != t[i+1]){
            flag = 1;
        }

        // ただし、文字のペアは一つだけ。(map[s[i]] = t[i]で管理)
        if(mp_s[s[i]] == '0'){
            mp_s[s[i]] = t[i];
        }
        else if(mp_s[s[i]] != t[i]){
            flag = 1;
        }

        if(mp_tt[t[i]] == '0'){
            mp_tt[t[i]] = s[i];
        }
        else if(mp_tt[t[i]] != s[i]){
            flag = 1;
        }
    }

    if(flag == 0) cout << "Yes";
    else cout << "No"; 
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
using namespace std;
#define ll long long
const ll inf =  0x3f3f3f3f;
ll n,x,y,w,m,s;
ll g[220][220],v[15];
void flyod()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
                g[j][k] = min(g[j][k] , g[j][i] + g[i][k]);
        }
    }
}

int main()
{
    while(scanf("%lld%lld%lld",&n,&m,&s) != EOF)
    {
        ll cnt = inf;
        for(int i=0;i<s;i++)
        {
            scanf("%lld",&v[i]);
        }
        sort(v,v+s);

        for(int i=0;i<=n;i++)
        {
            g[i][i] = 0;
            for(int j=0;j<=i;j++)
            {
                g[j][i] = g[i][j] = inf;
            }
        }
        for(int i=0;i<m;i++)
        {
            scanf("%lld%lld%lld",&x,&y,&w);
            g[x][y] = g[y][x] = min(g[x][y],w);
        }

        flyod();
        do{
            ll k = 0;
            for(int i=0;i<s-1;i++)
            {
                k += g[ v[i] ][ v[i+1] ];
            }
            cnt = min(cnt,k);
        }while(next_permutation(v,v+s));
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MN=1e5+10,MW=1e5+10;
int n,w;
int ans,dp[MW];
typedef pair<int,int> P;
P a[MN];
signed main()
{
    scanf("%lld%lld",&n,&w);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i].first,&a[i].second);
    if(a[0].first<=w)
        dp[a[0].first]=a[0].second,ans=a[0].second;
    for(int i=1;i<n;i++)
        for(int j=w;j;j--)
            if(j-a[i].first>=0)
                dp[j]=max(dp[j],dp[j-a[i].first]+a[i].second),ans=max(ans,dp[j]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
//cod2016_qualA_a.cpp
//Sat Oct 20 22:21:13 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	for (int i=0;i<12;i++){
		cout << s[i];
		if (i==3){
			cout << " ";
		}
	}

	printf("\n");
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 2000001

int B[N];
int C[N];

void countingSort(int A[], int B[], int k, int n){
  int i, j;

  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }   
  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  } 
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i != n) printf(" ");
  }
  printf("\n");

}

int main(){
  int A[N];
  int i, j, n;
  int k=0;


  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }

  
  countingSort(A, B, k, n);

  return 0;
}



Measured memory_bytes: 17384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
      	int c = a * b;
      	if(c % 2 == 0){
          System.out.println("Even");
        }
        else{
          System.out.println("Odd");
        }
	}
}


Measured memory_bytes: 23764
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

s = input()
n = len(s)
xc, yc, zc, wc = 1,0,0,0

for c in s:
    if c == "?":
        x = xc*3
        y = xc + yc * 3
        z = yc + zc * 3
        w = zc + wc * 3

    elif c == "A":
        x = xc
        y= yc + xc
        z = zc
        w = wc

    elif c == "B":
        x = xc
        y = yc
        z = zc + yc
        w = wc

    else:
        x = xc
        y = yc
        z = zc
        w = wc + zc

    xc,yc,zc,wc = [cur%1000000007 for cur in [x,y,z,w]]

print(wc)



Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

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

int main()
{
	int n, i;
	scanf("%d", &n);
	int A[n];
	lop(i, n){
		scanf("%d", &A[i]);
	}
	
	qsort(A, n, sizeof(int), compare_int);
	
	for(i=0; i<n-1; i++){
		if(A[i]==A[i+1]){ printf("NO"); return 0; }
	} 
	
	printf("YES");
	
return 0;
}

Measured memory_bytes: 1788
// Aizu Vol-1 0142: Nature of Prime Numbers
// 2017.8.16 bal4u@uu
// 4m+3????´???°?????§???

#include <stdio.h>
#include <string.h>

#define MAX  10000
#define SQRT 100     // sqrt(MAX)
#define HALF 5000
int sqr[HALF + 5];
int a[HALF + 5];
int d[HALF + 5];
char f[MAX + 5];

char prime[MAX + 5], *p, *q, *pmax;

int main()
{
	int n;
	int i, j, k, b, m;

	pmax = prime + MAX;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2) {
		if (!*p) {
			for (q = p + k; q <= pmax; q += k) *q = 1;
		}
	}
	for (i = 1; i <= 5000; i++) sqr[i] = i*i;

	while (1) {
		scanf("%d", &n); if (!n) break;
		if (n == 1 && !(n & 1)) while (1);		// Panic!

		// 4m+3????´???°
		if (!prime[n] && n % 4 == 3) {	
			char buf[10];
			k = n >> 1;
			sprintf(buf, "%d", k - 1);
			for (i = 1; i <= k; i++) puts(buf);
			continue;
		}

		// ???????\???°????????????????????????????¨????
		k = n >> 1;
		memset(d, 0, sizeof(d[0])*(k+2));
		memset(f, 0, sizeof(f[0])*(n+2));
		m = 0;
		for (i = 1; i <= k; i++) {
			b = sqr[i] % n;
			if (!f[b]) f[b] = 1, a[m++] = b;
		}

		for (i = 0; i < m; i++) {
			for (j = 0; j < m; j++) {
				if (b = a[i] - a[j]) {
					if (b < 0) b += n;
					if (b > k) b = n - b;
					d[b]++;
				}
			}
		}
		for (i = 1; i <= k; i++) printf("%d\n", d[i]);
	}
	return 0;
}

Measured memory_bytes: 700
#include<stdio.h>
#include<stdlib.h>
long int_sort(const void *,const void *);
int main(void){
  int N,K,i;
  long H[200001],sum=0;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%ld",&H[i]);
  }
  if(K>=N)printf("0");
  else{
   qsort( H, N,sizeof(long), int_sort);
   
  for(i=K;i<N;i++){
    sum+=H[i];
  }
  printf("%ld",sum);
  }
  return 0;
}
    
  
  long int_sort(const void * n1, const void * n2)
{
	if (*(long*)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
  }
 

Measured memory_bytes: 3324
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    const char* p[3] = {sa.c_str(), sb.c_str(), sc.c_str()};
    char n = 'a';
    while(1)
    {
        int i = n - 'a';
        if(!*p[i])
            break;
        n = *p[i];
        ++(p[i]);
    }
    cout << char('A' + (n - 'a')) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
  ld s,h,H,M;
  cin>>s>>h>>H>>M;
  ld tmp=(M/60)*360;
  ld tmp2=tmp/12+(H/12)*360;
  //cout<<tmp2<<endl;
  if(tmp==0)tmp=360;
  ld teta=(abs(tmp-tmp2)/180)*M_PI;
  //cout<<teta<<endl;
  ld c=s*s+h*h-2*s*h*cos(teta);
  cout<<fixed<<setprecision(10)<<sqrt(c)<<endl;
}

Measured memory_bytes: 4104
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{  
 int r, d, x;
 cin >> r >> d >> x;
 for(int i = 0; i < 10; i++){
     x = r*x-d;
     cout << x << endl;
 }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    while(n--){
        ll u;
        cin >> u;
        while(u%2==0){
            u /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        v[i]=d;
    }
    sort(v.begin(),v.end());
    ll Max=1e18;
    if(v[0]==0){
        cout<<0;
        return 0;
    }
    ll ans=1;
    for(ll i=0;i<n;i++){
        ans*=v[i];
        if(ans<=0||ans>Max){
            cout<<-1;
            return 0;
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n);
	
	for(int i = 0; i<n; i++)
		cin>> a[i];
	
	//크기 순으로 정렬 
	sort(a.begin(), a.end());
	
	//제일 큰수가 나중에 나누어져야 가장 큰 값이 나온다.
	double ans = ((double)a[0] + a[1])/2;
	
	for(int i = 2; i<n; i++)
		ans = (ans+a[i])/2;
	
	cout << ans;
	
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
/*
 * src.cpp
 *
 *  Created on: 2016/09/11
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

string S;

typedef long long ll;

int main(){
	cin>>S;
	int n=S.length();
	ll ans=0;
	REP(i,1<<(n-1)){
		ll pre=S[0]-'0';
		REP(j,n-1){
			if ((i>>j) & 1){
				//+を入れる
				ans+=pre;
				pre=S[j+1]-'0';
			}else{
				pre=pre*10+S[j+1]-'0';
			}
		}
		ans+=pre;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
from math import gcd
 
n=int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)*(a//abs(a))
  elif a:
    g = a
  else:
    g = b
  
  p = a//g,b//g
  d[p] = d.get(p,0)+1
 
ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w=d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v)+pow(2,w)-1)
  ans %= mod
print((ans+zeros-1)%mod)

Measured memory_bytes: 71924