akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000010;
const int MAXK = 100010;
const int MAXQ = 200010;

int n, a[MAXN], k;
int dp[MAXK][2];

int solve(int k, int p) {
    if (dp[k][p] != -1) return dp[k][p];
    int res = 0;
    FOR(i,1,n)
        if (k >= a[i])
            if (!solve(k-a[i], 1-p)) {
                res = 1;
                break;
            }
    return dp[k][p] = res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    FOR(i,0,k)
        FOR(j,0,1) dp[i][j] = -1;
    if (solve(k, 0)) cout << "First";
    else cout << "Second";
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int cnt = 0;
    for (int i = 0; i < 1000; i++)
    {
        int keta = 0;
        string num = to_string(i);
        if(num.size()==1) num = "00" + num;
        if(num.size()==2) num = "0" + num;

        for (int k = 0; k < N; k++)
        {
            if(num[keta] == S[k]){
                if(keta == 2){cnt++; break;}
                keta++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
 
char c[14][14];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
 
int belong[14][14];
int ok[10000];
int gx,gy;
 
int ans = 0;
int ccc = 0;
int dfs(int x,int y,int C,int px,int py){
    if( c[y][x] == '#' || c[y][x] == '*') return 0;
    if( C + abs(x-gx) + abs(y-gy) >= ans ) return 0;
    if( c[y][x] == 'G'){
        ans = C;
        return 0;
    }
    for(int i = 0 ; i < 4 ; i++){
        int tx = x + dx[i];
        int ty = y + dy[i];
        if( px == tx && ty == py ) continue;
        if( c[ty][tx] == '*' ) return 0;
    }
    char cur = c[y][x];
    c[y][x] = '*';
    for(int i = 0 ; i < 4 ; i++){
        int tx = x + dx[i];
        int ty = y + dy[i];
        if( c[ty][tx] == 'X' ){
            int b = belong[ty][tx];
            if( ok[b] > 0 ){
                ok[b]--;
                dfs(tx,ty,C+1,x,y);
                ok[b]++;
            }
        }else{
            dfs(tx,ty,C+1,x,y);
        }
    }
    c[y][x] = cur;
    return 0;
}
int grouping(int x,int y,int k){
    if( c[y][x] != 'X') return 0;
    if( belong[y][x] != -1 ) return 0;
    belong[y][x] = k;
    ccc++;
    for(int i = 0 ; i < 4 ; i++)
        grouping(x+dx[i],y+dy[i],k);
}
 
int main(){
    ios_base::sync_with_stdio(false);
    int W,H;
    while(cin >> W >> H && W){
        rep(i,14)rep(j,14) belong[i][j] = -1;
        rep(i,14)rep(j,14) 
            c[i][j] = '#';
        int sx , sy;
        for(int i = 0 ; i < H ; i++){
            for(int j = 0 ; j < W ; j++){
                cin >> c[i+1][j+1];
                if(c[i+1][j+1] == 'S'){
                    c[i+1][j+1] = '.';
                    sx = j+1 , sy = i+1;
                }else if(c[i+1][j+1] == 'G' ){
                    gx = j+1 , gy = i+1;
                }
            }
        }
        int k = 0;
        for(int i = 1 ; i <= H ; i++){
            for(int j = 1 ; j <= W ; j++){
                if( c[i][j] == 'X' && belong[i][j] == -1){
                    ccc = 0;
                    grouping(j,i,k);
                    ok[k] = ccc / 2;
                    k++;
                }
            }
        }
        ans = 1e7;
        dfs(sx,sy,0,-1,-1);
        cout << ans << endl;
         
    }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<double,P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int h, w;
vector<string> s;

int bfs(int si, int sj){
    vector<vector<int> > d(h, vector<int>(w, IINF));
    d[si][sj] = 0;
    queue<P> que;
    que.push(P(si,sj));
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        int i = p.first, j = p.second;
        for(int k=0;k<4;k++){
            int ni = i+di[k], nj = j+dj[k];
            if(ni < 0 || ni >= h) continue;
            if(nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(d[ni][nj] > d[i][j] + 1){
                d[ni][nj] = d[i][j] + 1;
                que.push(P(ni,nj));
            }
        }
    }
    int res = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '.') res = max(res, d[i][j]);
        }
    }
    return res;
}

int main(){
    cin >> h >> w;
    s.resize(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.') ans = max(ans,bfs(i,j));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
  long long int i,a,b,x,ans;
  scanf("%lld %lld %lld",&a,&b,&x);
  ans=b/x-a/x;
  if(a%x==0)ans++;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;



int main(){
    int r0,w,c,r;
    while(cin >> r0 >> w >> c >> r,r0 != 0 && w != 0 && c != 0 && r != 0) {
        int nc = r0 / w;
        if(nc > c) cout << 0 << endl;
        else{
            int ans = (c * w - r0) / r;
            if((c * w - r0) % r != 0) ans++;
            cout << ans  << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3072
#include<iostream>

using namespace std;

double money = 100000;

int i;

int main()
{
	cin>>i;
	for(i;i>0;--i)
	{
		money *= 1.05;
		money = (long)(money/1000+0.99)*1000;
	}
	printf("%.0lf\n",money);
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
alice = []
bob = []


for i in range(N):
    if i % 2 == 0:
        alice.append(a[i])
    else:
        bob.append(a[i])

print(sum(alice) - sum(bob))

Measured memory_bytes: 9180
//
//  main.c
//  AOJ
//
//  Created by x17036xx on 2017/04/18.
//  Copyright ?? 2017??´ x17036xx. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {

    int a;
    int b;
    int c;
    int x;
    
    scanf("%d %d %d",&a,&b,&c);
    if (a>b) {
        x=a;
        a=b;
        b=x;
    }if (b>c){
        x=b;
        b=c;
        c=x;
    }if (a>b) {
        x=a;
        a=b;
        b=x;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=s.size();
  int left,right;
  for(int i=0;i<a;i++){
    if(s[i]=='A'){
      left=i;
      break;
    }
  }
  for(int i=a-1;i>=0;i--){
    if(s[i]=='Z'){
      right=i;
      break;
    }
  }
  cout<<right-left+1<<endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  printf("%lf\n", sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));

return 0;
}

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

int main()
{
    int a, b;
    char op;
    while (cin >> a >> op >> b, op != '?') {
        switch (op) {
            case '+':
                cout << a + b << '\n';
                break;
            case '-':
                cout << a - b << '\n';
                break;
            case '*':
                cout << a * b << '\n';
                break;
            case '/':
                cout << a / b << '\n';
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(all(v));
	int sum = 0;
	for(int i=0;i<k;i++)
		sum+=v[i];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using lint = long int;

int N;
lint a[410];
lint A[410] = { 0 };  //累積和
lint dp[410][410] = { 0 };  //動的計画法用メモ
lint res;


lint integ_slimes(int l, int r){
    if(l == r) return 0;
    if(dp[l][r] > 0) return dp[l][r];  //既に求まっている

    lint tmp = -1;
    lint RS = A[r]-A[l-1], RST;  //[l,r]区間の和
    for(int c = l; c < r; c++){
        RST = integ_slimes(l, c)+integ_slimes(c+1, r);
        if(tmp < 0) tmp = RST;
        else tmp = min(tmp, RST);
    }
    tmp += RS;

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


int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
        A[i] = A[i-1] + a[i];  //累積和の作成
    }

    res = integ_slimes(1, N);
    cout << res << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(2 * N);
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2)
    ans += min(L[i], L[i + 1]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a==b){
        cout << c << endl;
    }
    else if(b==c){
        cout << a << endl;
    }
    else if(a==c){
        cout << b << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e5 + 10;

int N;
ll K, cnt;
int a[MAX], b[MAX], dfn[MAX];

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d%lld", &N, &K);
    for (int i = 1; i <= N; i++) scanf("%d", &a[i]), dfn[i] = -1;
    int now = 1; ll circle = 1;
    while (1) {
        dfn[now] = cnt, b[cnt] = now, cnt++;
        if (dfn[a[now]] != -1) {
            circle = cnt - dfn[a[now]];
            break;
        }
        now = a[now];
    }
    cnt -= circle;
    if (K <= cnt) printf("%d\n", b[K]);
    else {
        K -= cnt; K %= circle;
        printf("%d\n", b[cnt + K]);
    }

    return 0;
}

Measured memory_bytes: 6048
# coding: utf-8
# Your code here!

S=list(input())


S=list(map(lambda x : ord(x)-97,S))

alpha=[0]*26
for s in S:
    alpha[s]=1

if len(S)!=26:
    for i in range(26):
        if alpha[i] == 0:
            S.append(i)
            ans=S[:]
            ans=list(map(lambda x :chr(x+97), ans))
            print("".join(ans))
            exit()
else:
    for i in range(26)[::-1]:
        if alpha[S[i]:].count(0)>0:
            for j in range(S[i],26):
                if alpha[j]==0:
                    ans=S[:i]+[j]
                    ans=list(map(lambda x :chr(x+97), ans))
                    print("".join(ans))
                    exit()
        else:
            alpha[S[i]]=0

print(-1)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    string wins;
    getline(cin, wins);
    
    int toWin = wins.length()-7;
    
    for(int i=0;i<wins.length();i++){
        if(wins[i]=='o') toWin--;
    }
    
    cout << (toWin<=0 ? "YES" : "NO");
    
    return 0;
}


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

using namespace std;

ll n,m,nn;
pair<ll,ll> p[100005];
vector<pair<ll,ll> > v;


int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for (int i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second;
        if (p[i].first <= m)
        v.push_back({p[i].first , p[i].second}) , nn++;
    }
    sort(v.begin() , v.end());
    int j = 0;
    ll ans = 0;
    multiset<ll> ms;
    for (int i=1;i<=m;i++)
    {
        while (j < nn && v[j].first <= i && j < nn)
        {
            ms.insert(-v[j].second);
            j++;
        }
        if (ms.empty())continue;
        ll o = *ms.begin();
        o *= -1;
        ans+=o;
        ms.erase(ms.begin());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8048
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int H, W;
    cin >> H >> W;
    Graph C(1500, vector<int>(1500)), dp(1500, vector<int>(1500, 0));
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> C[i][j];
        }
    }

    int len = 0;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(C[i][j] == 1) dp[i][j] = 0;
            else dp[i][j] = min(dp[i-1][j], min(dp[i][j-1], dp[i-1][j-1])) + 1;
            len = max(len, dp[i][j]);
        }
    }

    cout << len * len << endl;

}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 3e-11
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 202020
#define LOGN 29
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
 
struct trie{
	vi tam, f[2];
	int root, ptr;
	trie(){
		tam.resize(MAXN*(LOGN+1)+10);
		f[0].resize(MAXN*(LOGN+1)+10);
		f[1].resize(MAXN*(LOGN+1)+10);
	}
	void init(){
		tam[0]=tam[1]=f[0][0]=f[0][1]=f[1][0]=f[1][1]=0;
		root = 1, ptr = 2;
	}
	void insert(int node, int v, int k){
		while(1){
			tam[node]+=1;
			if(k<0) return;
			int b = (v>>k)&1;
			if(!f[b][node]){
				f[b][node] = ptr;
				f[0][ptr]=0;
				f[1][ptr]=0;
				tam[ptr]=0;
				ptr++;
			}
			node = f[b][node];
			k--;
		}
	}
	void insert(int v, int k){ insert(root,v,k); }
	int sem_q(int node, int v, int k){
		int ret = 0;
		while(1){
			if(k < 0 || tam[node]==0){
				ret += tam[node];
				break;
			}
			int b = (v>>k)&1;
			if(!b){
				ret += tam[f[0][node]];
				node = f[1][node];
				k--;
			}
			else{
				node = f[0][node];
				k--;
			}
		}
		return ret;
	}
	int com_q(int node, int v, int k){
		int ret = 0;
		while(1){
			if(k < 0 || tam[node]==0)
				break;
			int b = (v>>k)&1;
			if(b){
				ret += tam[f[1][node]];
				node = f[0][node];
				k--;
			}
			else{
				node = f[1][node];
				k--;
			}
		}
		return ret;
	}
	int count(int v, int k){
		int b = (v>>k)&1, ret = 0;
		if(b)
			ret = sem_q(f[0][root], v, k-1) + com_q(f[1][root], v, k-1);
		else
			ret = com_q(f[0][root], v, k-1) + sem_q(f[1][root], v, k-1);
		return ret;
	}
}tree;
 
int n, veta[MAXN], vetb[MAXN], ans;
 
int main(){
	scanf("%d", &n);
	rep(i,0,n)
		scanf("%d", &veta[i]);
	rep(i,0,n)
		scanf("%d", &vetb[i]);
	rep(k,0,LOGN){
		tree.init();
		rep(i,0,n) tree.insert(veta[i], k);
		rep(i,0,n) if(tree.count(vetb[i],k)&1) ans ^= (1<<k);
	}
	printf("%d\n", ans);
}

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

long long n,y,total=0;
bool flag=false;

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

	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
				total=i*10000+j*5000+((n-i-j)*1000);
			if(total==y){
				cout<<i<<' '<<j<<' '<<n-i-j;
				flag=true;
				break;
			}
		}
		if(flag==true)
			break;
	}
	if(flag==false)
		cout<<-1<<' '<<-1<<' '<<-1;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A, reverse=True)

    val_list = []
    heappush(val_list, (-min(A[0], A[1]), A[1], A[0], 1))
    heappush(val_list, (-min(A[0], A[1]), A[1], A[0], 1))
    ans = A[0]

    for a in A[2:]:
        val, a1, a2, edge = heappop(val_list)
        ans += -val
        if edge != 1:
            heappush(val_list, (-a, a, a1, 0))
            heappush(val_list, (-a, a, a2, 0))
        else:
            heappush(val_list, (-a, a, a1, 1))
            heappush(val_list, (-a, a, a2, 0))
    print(ans)



if __name__ == "__main__":
    run()

Measured memory_bytes: 43476
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  INF = Float::INFINITY
  def chmin(a, b) a < b ? a : b end

n = gets.to_i
w = gets.split.map(&:to_i)

s = Array.new(w.size+1,0)
n.times do |i|
  s[i+1] = s[i] + w[i]
end

min = INF
1.upto(n) do |i|
  min = chmin(((s[n] - s[i]) - s[i]).abs, min)
end

puts min

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

int main () {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D)
     cout << "Left" << endl;
    else if (A + B == C + D)
     cout << "Balanced" << endl;
    else if (A + B < C + D)
     cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int index = 1;
        while(true){
            int x = sc.nextInt();
            if(x == 0) break;
            System.out.println("Case " + index + ": " + x);
            index++;
        }
        sc.close();
    }
}


Measured memory_bytes: 41868
#include<stdio.h>

int main (void) {
	char c;
	scanf (" %c", &c);
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') printf ("vowel\n");
	else printf ("consonant\n");
	return 0;
}

Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    for(int i=0; i<N; i++) {
        cin >> B[i];
    }

    ll ans = 0;
    queue<int> que;
    for(int i=0; i<N; i++) {
        int v1 = B[(i + N - 1) % N];
        int v2 = B[i];
        int v3 = B[(i + 1) % N];
        if(v1 < v2 and v2 > v3 and v2 > A[i]) que.emplace(i);
    }

    while(que.size()) {
        int k = que.front(); que.pop();
        ll ub, lb;
        {
            ll v1 = B[(k + N - 1) % N];
            ll v3 = B[(k + 1) % N];
        
            ub = 1LL * (B[k] + v1 + v3 - 1) / (v1 + v3) + 10;
            lb = 0;
        }
        
        while(ub - lb > 1) {
            ll mid = (ub + lb) / 2;
            ll v1 = B[(k + N - 1) % N];        
            ll v2 = B[k];
            ll v3 = B[(k + 1) % N];
            v2 -= mid * (v1 + v3);

            bool cond = (v2 >= A[k]);
            if(cond) lb = mid;
            else ub = mid;
        }
        
        ll cnt = lb;
        {
            int v1 = B[(k + N - 1) % N];
            int v3 = B[(k + 1) % N];

            ans += cnt;
            B[k] -= cnt * (v1 + v3);
        }

        for(int d=-1; d<=1; d++) {
            int i = (k + d + N) % N;
            int v1 = B[(i + N - 1) % N];
            int v2 = B[i];
            int v3 = B[(i + 1) % N];
            // fprintf(stderr, "v1 = %d, v2 = %d, v3 = %d\n", v1, v2, v3);
            if(cnt > 0 and v1 < v2 and v2 > v3 and v2 > A[i] and v1 + v3 < B[i]) {
                que.emplace(i);
            }
        }
    }

    bool ok = true;
    for(int i=0; i<N; i++) ok &= (A[i] == B[i]);
    cout << (ok ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
 
void maxheap(int *,int);

int main(int argc,char *argv[]) {
    int *heap, key, index, half, tmp;
    char cmd[20];
 
    heap = malloc(sizeof(int) * 2000001);
    heap[0] = 1;
    while (1) {
        scanf("%s %d ", cmd, &key);
        if (cmd[0] == 'i') {
            heap[0]++;
            index = heap[0];
            heap[index] = key;
 
            half = index / 2;
            while (index > 1 && heap[half] < heap[index]) {
                tmp = heap[index];
                heap[index] = heap[half];
                heap[half] = tmp;
                index /= 2;
                half = index / 2;
            }
        } else if (cmd[1] == 'x') {
            printf("%d\n", heap[1]);
            heap[1] = heap[heap[0]];
            heap[0]--;
            maxheap(heap, 1);
        } else {
            return 0;
        }
    }
    return 0;
}
void maxheap(int *heap, int i) {
  int heapsize, l, r, largest, tmp;
  
  heapsize = heap[0];
  l = 2*i;
  r = 2*i + 1;
  if (l <= heapsize && heap[l] > heap[i]) 
      largest = l;
  else 
      largest = i;
  if (r <= heapsize && heap[r] > heap[largest]) 
      largest = r;
  if (largest != i) 
    {
      tmp = heap[i];
      heap[i] = heap[largest];
      heap[largest] = tmp;
      maxheap(heap, largest);
    }
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,K;
    cin>>N>>K;
    int P[50]={};
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    sort(P,P+50,greater<int>());
    int sum=0;
    for(int i=0;i<K;i++){
        sum+=P[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  double ave;
  int ans;
  int check;
  ave = (a+b)/2.0;
  check = (a+b) % 2;
  if(check > 0)
  {
    ans = ave + 0.5;
  }
  else
  {
    ans = ave;
  }
  cout << ans << endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    ans=0
    
    N=I()
    for a in range(1,N):
        for b in range(1,N):
            if a*b>=N:
                break
            ans+=1
            
    print(ans)

        
        
    

main()


Measured memory_bytes: 73396
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std; typedef long long ll;
typedef pair<string,string> P; const int INF = 1e9+1;
int main() {
  int n; cin>>n;
  string s; cin>>s;

  map<P, ll> mp;
  for(int i=0;i<(1<<n);i++) {
    string s1, s2;
    for(int j=0;j<n;j++) {
      if (i & (1<<j)) s1+=s[j];
      else s2+=s[j];
    }
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    mp[make_pair(s1,s2)]++;
  }
  ll an=0;
  for(int i=0;i<(1<<n);i++) {
    string s1, s2;
    for(int j=0;j<n;j++) {
      if (i & (1<<j)) s1+=s[n+j];
      else s2+=s[n+j];
    }
    an += mp[make_pair(s1,s2)];
  }
  cout<<an<<endl;
}

Measured memory_bytes: 87040
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ma=max(a,max(b,c));
	int m=ma;
	int count =0;
	while(count<k){
		count++;
		ma=ma*2;
	}
	cout<<ma+a+b+c-m<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
x = N.times.map{gets.split.map(&:to_i)}
a = []
b = []

(0..N-1).each do |i|
  a << x[i][0]-x[i][1]
  b << x[i][0]+x[i][1]
end

puts [a.max-a.min,b.max-b.min].max

  

Measured memory_bytes: 31588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

ll n;
string a;
vector<string> ans;
string c = "abcdefghijklm";

int main(void) {
    ll n;
    cin >> n;
    ll ans = 0;
    if(n>1){
        for(ll i = 1; i <= sqrt(n); i++){
            ll check = n-i;
            ll b = check/i;
        if(check%i==0 && n%b==i)
            ans+=check/i;
        }
    }
   // cout << 2499687339915-2499686339916 << endl;
    cout << ans << endl;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

bool f(string s){
   bool f=1;
   rep(i,0,s.size())if(s[i]!=s[s.size()-1-i])f=0;
   return f;
}

int main(){
   string s; cin>>s;
   int n=s.size();
   string t=s.substr(0,(n-1)/2),r=s.substr((n+1)/2,(n-1)/2);
   cerr<<t<<r<<endl;
   if(f(s)&&f(t)&&f(r))puts("Yes"); else puts("No");
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a<b){
                System.out.println("a < b");
            }else if(a>b){
                System.out.println("a > b");
            }else{
                System.out.println("a == b");
            }
        }
        public static void main(String[] args){
            Main obj = new Main();
            obj.solve();
        }
    }
    

Measured memory_bytes: 17160
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
    _fast_
    ll t = 1;
  //  cin>>t;
    while(t--){
    ll n,k;
    cin>>n>>k;
    ll arr[n];

    f(n)
    {
        cin>>arr[i];
    }
    
    ll dp[n];
    for(ll i = 0;i<n;i++)
    {
        dp[i] = INT_MAX;
    }
    
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    
    for(ll i = 2;i<min(n,k);i++)
    {
        for(ll j = 0;j<i;j++)
        {
            dp[i] = min(dp[j]+abs(arr[j]-arr[i]),dp[i]);
        }
    }
    for(ll i = min(k,n);i<n;i++)
    {
        for(ll j = i-k;j<i;j++)
        {
            dp[i] = min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
        }
    }
    cout<<dp[n-1]<<"\n";

    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int c;
  c=a*b;
  if(c%2==0)
  {
    cout<<"Even";
  }
  if(c%2==1)
  {
    cout<<"Odd";
  }




return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int n,m;
  cin>>n>>m;
  int a[m],b[m],y[3],x,c=0,ans=0;
  rep(i,0,m) cin>>a[i]>>b[i];
  
  if(n==1){
    rep(i,0,10){
      rep(j,0,m){
        if(i==b[j]) c++;
      }
      if(c==m){
        co(i);
        ans++;
        break;
      }
      c=0;
    }
  }
  if(n==2){
    rep(i,10,100){
      rep(j,0,m){
        if(a[j]==1) if(i/10==b[j]) c++;
        if(a[j]==2) if(i%10==b[j]) c++;
      }
      if(c==m){
        co(i);
        ans++;
        break;
      }
      c=0;
    }
  }
  if(n==3){
    rep(i,100,1000){
      rep(j,0,m){
        if(a[j]==1) if(i/100==b[j]) c++;
        if(a[j]==2) if(i%100/10==b[j]) c++;
        if(a[j]==3) if(i%10==b[j]) c++;
      }
      if(c==m){
        co(i);
        ans++;
        break;
      }
      c=0;
    }
  }
  if(ans==0) co(-1);
  return 0;
}


Measured memory_bytes: 256
z3 = ['aa.',
      '..a',
      '..a']
z4 = ['abcc',
      'abdd',
      'eegh',
      'ffgh']
z5 = ['biihh',
      'baa.g',
      'c..ag',
      'c..af',
      'ddeef']
z6 = ['aa.bbc',
      '..ae.c',
      '..aedd',
      'bbcaa.',
      'e.c..a',
      'edd..a']
z7 = ['bbccdd.',
      'aa.aa.b',
      '..a..ab',
      '..a..ac',
      'aa.aa.c',
      '..a..ad',
      '..a..ad']
n = int(input())
if n == 2:
  print(-1)
elif n == 3:
  for x in z3:
    print(x)
else:
  m = n // 4 - 1
  if n % 4 == 0:
    for x in z4:
      print(x + '.' * (n-4))
  if n % 4 == 1:
    for x in z5:
      print(x + '.' * (n-5))
  if n % 4 == 2:
    for x in z6:
      print(x + '.' * (n-6))
  if n % 4 == 3:
    for x in z7:
      print(x + '.' * (n-7))
  for i in range(m):
    for x in z4:
      l = n % 4 + (i+1) * 4
      print( '.' * l + x + '.' * (n-l-4) )

Measured memory_bytes: 4084
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	string str;
	cin>>n;
	cin>>str;
	vector<int> R(n,0),G(n,0),B(n,0);
	if(str[0] == 'R')
		R[0] = 1;
	else if(str[0] == 'G')
		G[0] = 1;
	else
		B[0] = 1;
	for(int i=1;i<n;i++)
	{
		R[i] = R[i-1] + (str[i]=='R');
		G[i] = G[i-1] + (str[i]=='G');
		B[i] = B[i-1] + (str[i]=='B');
	}
    /*for(int i=0;i<n;i++)
        cout<<R[i]<<"\t";
    cout<<"\n";
    for(int i=0;i<n;i++)
        cout<<G[i]<<"\t";
    cout<<"\n";
    for(int i=0;i<n;i++)
        cout<<B[i]<<"\t";
    cout<<"\n";*/
	ll ans = 0;
	for(int i=0;i<n-3;i++)
	{
		for(int j=i+3;j<n;j++)
		{
            if((str[i]=='R' && str[j]=='G') || (str[i]=='G' && str[j]=='R')) 
            {
                int b = B[j-1] - B[i];
                if(((j+i) % 2 ==0) && (B[(i+j)/2]-B[((i+j)/2)-1]==1))
                    --b;
                ans += b;
            }
            else if((str[i]=='R' && str[j]=='B') || (str[i]=='B' && str[j]=='R'))
            {
                int g = G[j-1] - G[i];
                if(((j+i) % 2 ==0) && (G[(i+j)/2]-G[((i+j)/2)-1]==1))
                    --g;
                ans += g;
            }
            else if((str[i]=='B' && str[j]=='G') || (str[i]=='G' && str[j]=='B'))
            {
                int r = R[j-1] - R[i];
                if(((j+i) % 2 ==0) && (R[(i+j)/2]-R[((i+j)/2)-1]==1))
                    --r;
                ans += r;
            }
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;

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

const int maxn = 1e9 + 10, mod = 1e9 + 7;
const int maxa = 4e5 + 25;

int n,k;
int fact[maxa];

int power(int a, int b){
	int ret = 1;
	while(b){
		if(b & 1)
			ret = 1ll * ret * a % mod;
		b >>= 1;
		a = 1ll * a * a % mod;
	}
	return ret;
}

int comb(int n, int m){
	if(n < 0) return 0;
	if(m < 0) return 0;
	if(m > n)
		return 0;
	//assert(m <= n);
	return 1ll*fact[n]*power(fact[n-m], mod-2)%mod*power(fact[m], mod-2)%mod;
}


int main(){
	
	cin >> n >> k;
	
	fact[0] = 1;
	for(int i = 1; i < maxa; i++){
		fact[i] = 1ll * fact[i-1] * i % mod;
	}
	
	int ans = comb(n+n-1, n-1);
	//printf("-- %d\n",ans);
	int sub = 0;
	/*int cur = n;
	for(int i = 1; i <= n && cur > 0; i++){
		cur -= k+1;
		if(cur <= 0) break;
		sub += 1ll*comb(cur+n-1, n-1)%mod;
		if(sub >= mod) sub -= mod;
	}*/
	/*{
		int cur = k;
		sub += 1ll*comb(n,k)*comb(cur+n-1, n-1)%mod*(n-k)%mod;
		if(sub >= mod) sub -= mod;
	}*/
	/*
	for(int a = 1; a <= k; a++){
		sub += 1ll
	}
	ans -= sub;
	if(ans < 0) ans += mod;
	printf("%d\n",ans);
	*/
	ans = 1;
	k = min(k, n);
	for(int i = 1; i <= k; i++){
		ans += 1ll*comb(n,i)*comb(n-1,n-i-1)%mod;
		if(ans >= mod) ans -= mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict
H, W, N = map(int, input().split())
P = [0] * 10
P[0] = (H - 2) * (W - 2)
G = defaultdict(lambda: defaultdict(int))
for i in range(N):
  a, b = map(int, input().split())
  for i in range(max(a - 3, 0), min(a, H - 2)):
    for j in range(max(b - 3, 0), min(b, W - 2)):
      p = G[i][j]
      P[p] -= 1
      P[p + 1] += 1
      G[i][j] += 1
for i in range(10):
  print(P[i])

Measured memory_bytes: 160772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define pi 3.14159265358979323846264338328
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=3005;
//i_am_noob
int n,l,a[maxn];
ld k;

struct point{ld x,y;}p[maxn],suf[maxn],cur,mid,ans;
point rot(point p, ld theta){
    point ret;
    ret.x=p.x*cos(theta)-p.y*sin(theta),ret.y=p.y*cos(theta)+p.x*sin(theta);
    return ret;
}
point to_point(ld theta){
    point ret;
    ret.x=cos(theta),ret.y=sin(theta);
    return ret;
}
inline ld dist(point p1, point p2){return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cout << fixed << setprecision(15);
    cin >> n >> l;
    rep(n) cin >> a[i];
    ans.x=ans.y=suf[0].x=suf[0].y=0;
    rep(n) p[i].x=cos(2*pi*a[i]/l),p[i].y=sin(2*pi*a[i]/l);
    rep2(i,1,n+1) suf[i].x=suf[i-1].x+cos(pi*a[n-i]/l),suf[i].y=suf[i-1].y+sin(pi*a[n-i]/l);
    rep2(i,1,n+1) suf[i].x/=i,suf[i].y/=i;
    rep(n) rep2(j,i+1,n){
        cur=rot(suf[n-1-j],pi*(a[i]+a[j])/l/2+pi/2);
        mid.x=cos(pi*(a[i]+a[j])/l),mid.y=sin(pi*(a[i]+a[j])/l);
        k=dist(p[i],mid);
        cur.x*=k,cur.y*=k;
        cur.x+=cos(pi*(a[i]+a[j])/l),cur.y+=sin(pi*(a[i]+a[j])/l);
        ans.x+=cur.x*(n-1-j),ans.y+=cur.y*(n-1-j);
    }
    ans.x/=n*(n-1)*(n-2)/6,ans.y/=n*(n-1)*(n-2)/6;
    print2(ans.x,ans.y);
    return 0;
}


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

using namespace std;

int a[4][4];
int main(){
    for(int i = 1; i<= 3;i++) {
        for(int j = 1;j <= 3;j ++) {
            cin>>a[i][j];
        }
    }
    for(int k = -1000;k <= 1000;k++) {
        int a2,a3,b1,b2,b3;
        int a1 = k;
        b1 = a[1][1] - k;
        b2 = a[1][2] - k;
        b3 = a[1][3] - k;
        a2 = a[2][1] - b1;
        a3 = a[3][1] - b1;
        bool flg = false;
        if(a[2][2] != a2 + b2) flg = true;
        if(a[2][3] != a2 + b3) flg = true;
        if(a[3][2] != a3 + b2) flg = true;
        if(a[3][3] != a3 + b3) flg = true;
        if(!flg) {
            cout<<"Yes"<<endl;return 0;
        }

    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

# 10^5
for i in range(1, N+1):
    # iはサイコロの出目
    cnt = 0
    score = i
    while(True):
        if score >= K:
            break
        score = score * 2
        cnt += 1
        
    ans += (1/N) * ((1/2) ** cnt)

print(ans)

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

using namespace std;
#define int long long
const int MOD = 1000000007;
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void sub(int &a, const int &b) {
	a -= b;
	if (a < 0) a += MOD;
}
int dp[5001][5001][2];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	if (A > B) swap(A, B);
	//vector<vector<vector<int> > > dp(N + 1, vector<vector<int> >(N + 1, vector<int>(2, 0)));
	dp[0][0][0] = 1;
	dp[0][0][1] = 1;
	int p2[100005];
	p2[0] = 1;
	for (int i = 1; i < 100005; i++) {
		p2[i] = p2[i - 1] * 2 % MOD;
	}
	int res = 0;
	for (int j = 0; j < N; j++) {
		for (int i = j; i < N; i++) {
			// for (int x = i + 1; x <= min(N, j + B - 1); x++) {
			// 	add(dp[x][j][1], dp[i][j][0]);
			// }

			if (i == j) {
				if (i > 0) {
					add(dp[j + 1][i + 1][0], dp[j][i][0]);
				}
			} else {
				add(dp[j][i + 1][0], dp[j][i][0]);
				add(dp[j][i + 1][1], dp[j][i][1]);
			}

			{
				int mn = i + 1;
				int mx = min(N, j + B - 1) + 1;
				if (mn < mx) {
					add(dp[j][mn][1], dp[j][i][0]);
					if (mx <= N) {
						sub(dp[j][mx][1], dp[j][i][0]);
					}
				}
			}

			if (j + B <= N) {
				add(res, dp[j][i][0] * p2[N - (j + B)] % MOD);
			}
			// for (int x = i + 1; x <= min(N, i + A - 1); x++) {
			// 	//cerr << i << " " << j << " " << x << endl;
			// 	add(dp[x][x][0], dp[i][j][1]);
			// }
			{
				int mn = i + 1;
				int mx = min(N, i + A - 1) + 1;
				if (mn < mx) {
					add(dp[mn][mn][0], dp[j][i][1]);
					if (mx <= N) {
						sub(dp[mx][mx][0], dp[j][i][1]);
					}
				}
			}

			// for (int x = i + A; x <= min(N, j + B - 1); x++) {
			// 	//cerr << i << " " << j << " " << x << endl;
			// 	add(dp[x][j][0], dp[i][j][1]);
			// }

			{
				int mn = i + A;
				int mx = min(N, j + B - 1) + 1;
				if (mn < mx) {
					add(dp[j][mn][0], dp[j][i][1]);
					if (mx <= N) {
						sub(dp[j][mx][0], dp[j][i][1]);
					}
				}
			}

			{
				int x = max(i + A, j + B);
				if (x <= N) {
					add(res, dp[j][i][1] * p2[N - x] % MOD);
				}
			}
		}
	}
	cout << res << endl;
}

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

int main(){
    int n;

    while(cin>>n){
        int a,b;
        cin>>a>>b;
        int first=0,second = 0,third = 0;
        for(int i=1; i<=n; i++){
            int val;
            cin>>val;
            if(val<=a){
                ++first;
            }
            else if(val>=a+1 && val<=b){
                second++;
            }
            else
                third++;

        }
        cout<<min(first,min(second,third))<<endl;
    }
}


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

//	long long dp[2000][2000] = {};
int main(){
//	string t,b;
//	cin >> t >> b;
//	dp[0][0] = 1LL;
//
//	for(int i=0; i<t.size(); i++){
//		for(int j=0; j<b.size(); j++){
//			dp[i+1][j] += dp[i][j];
//			if(t[i] == b[j]){
//				dp[i+1][j+1] += dp[i][j];
//			}
//			dp[i+1][j] %= 1000000007;
//			dp[i+1][j+1] %= 1000000007;
//		}
//		dp[i+1][b.size()] += dp[i][b.size()];
//	}
//
//	cout << dp[t.size()][b.size()]%1000000007 << endl;
//
//	return 0;
	int p, m, c;
	cin >> p >> m >> c;

	cout << p + m + c << endl;

	
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum1[100010];
int sum2[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int q; cin >> q;
    rep(i, S.length()) {
        sum1[i + 1] += sum1[i] + (S[i] - 'A') + 1;
        sum2[i + 1] += sum2[i] + (T[i] - 'A') + 1;
    }
    while(q--) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        int len1 = sum1[b] - sum1[a - 1];
        int len2 = sum2[d] - sum2[c - 1];
        if (len1 % 3 == len2 % 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  int k, a, b;
  cin >> k >> a >> b;
  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if(a!=b&&a!=c&&b!=c){
       cout<<"No";
   }
   else
       if(a==b&&a==c&&b==c){
           cout<<"No";
     }
   
     else{
         cout<<"Yes";
     }
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string n;
    cin >> n;
    bool good=false;
    if(n[0]==n[1] && n[1]==n[2]) good=true;
    if(n[1]==n[2] && n[2]==n[3]) good=true;
    if(good){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
       int N=scan.nextInt();
        int X=scan.nextInt()-1;
        int Y=scan.nextInt()-1;
        int L[]=new int[N];
for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
 int R=Math.min(Math.abs(X-i)+1+Math.abs(j-Y),Math.abs(j-X)+1+Math.abs(i-Y));
      int  K=Math.min(Math.abs(i-j),R);
      L[K-1]=L[K-1]+1;
    }

}
for(int h=0;h<N-1;h++){System.out.println(L[h]);}


    }

}



Measured memory_bytes: 22740