akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int a[2][n];
    rep(2)repp(j,n) cin >> a[i][j];

    priority_queue<Piii> que;
    que.push(Piii(a[0][0], Pii(0, 0)));
    int ans = 0;
    while(!que.empty()){
        Piii p = que.top(); que.pop();

        if(p.second.first == 1 && p.second.second == n-1){
            ans = max(ans, p.first);
        }

        if(p.second.first == 0){
            que.push(Piii(p.first + a[1][p.second.second], Pii(1, p.second.second)));
        }
        if(p.second.second != n-1){
            que.push(Piii(p.first + a[p.second.first][p.second.second+1], Pii(p.second.first, p.second.second+1)));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
long long a,b,c,h,w,k[]={0,0,-1,1},l[]={1,-1,0,0},i,j;;
char s[405][405],t;
void d(int x,int y){
  char t;
  ((t=s[x][y])-'#'?a:b)++;
  s[x][y]=0;
  for(int i=0;i<4;++i)if(s[x+k[i]][y+l[i]]+t==81)d(x+k[i],y+l[i]);
}
int main(){
  scanf("%d%d",&h,&w);
  for(i=1;i<=h;++i)scanf("%s",s[i]+1);
  for(i=1;i<=h;++i)for(j=1;j<=w;++j)if(s[i][j])a=b=0,d(i,j),c+=a*b;
  printf("%lld\n",c);
}

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

long long N, H, a[100009], b[100009], s[100009], sum, G, sx = 1, cx = 1;

int main() {
	cin >> N >> H;
	for (int i = 1; i <= N - 1; i++) cin >> a[i] >> b[i];
	s[1] = H; for (int i = 2; i <= N; i++) s[i] = s[i - 1] - a[i - 1];

	//for(int i=1;i<=N;i++) cout<<s[i]<<" ";cout<<endl;
	while (true) {
		while (sx <= N && G + s[sx] >= 1) sx++; if (sx > N) break;
		long long maxn = 0, maxid = 0;
		for (int j = cx; j < sx; j++) {
			long long cost = min(b[j], H - (G + s[j]));
			if (maxn < cost) { maxn = cost; maxid = j; }
		}
		long long B = (H - (G + s[maxid])) / maxn;
		long long B2 = (-(s[sx] + G) + maxn) / maxn; B = min(B, B2);//cout<<B<<endl;
		//cout<<G<<" "<<sx<<" "<<maxn<<" "<<maxid<<" "<<B<<" "<<sum<<endl;
		sum += B; G += maxn * B;
		cx = maxid;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 5432
import java.util.*;
import java.io.*;
import java.lang.*;

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 = sc.nextInt();
        int d = sc.nextInt();

        if ((Math.abs(a-b)<=d && Math.abs(b-c)<=d) || (Math.abs(a-c)<=d))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

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

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> mat(h, vector<int>(w));
    vector<vector<bool>> used(h, vector<bool>(w, false));
//    std::fill(used.begin(), used.end(), false);
    char c;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> c;
            mat[i][j] = (c == '.');
        }
    }
    queue<P> que;
    ll res = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (used[i][j]) continue;
            que.push(P(i, j));
            used[i][j] = true;
            ll black = 0;
            ll white = 0;
            while (!que.empty()) {
                P curr = que.front();
                que.pop();
                int x = curr.first;
                int y = curr.second;
//                used[x][y] = true;
                if (mat[x][y]) ++black;
                else ++white;
                for (int k = 0; k < 4; ++k) {
                    int nx = x + dx[k];
                    int ny = y + dy[k];
                    if ((nx >= 0 && nx < h) && (ny >= 0 && ny < w) && !used[nx][ny] && mat[nx][ny] != mat[x][y]) {
                        used[nx][ny] = true;
                        que.push(P(nx, ny));
                    }
                }
            }
//            cout << b << " " << w << endl;
            res += black * white;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    int x,y;cin>>x>>y;
    rep(i,0,101){
        rep(j,0,101){
            if(i+j==x && 2*i+4*j==y){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
}

Measured memory_bytes: 3628
#include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

vector<int> vec;

void makesosuu(void){
	FOR(i, 2, 999999){
		if(i == 2){
			vec.pb(i);
		}else if(i % 2 != 0){
			bool flag = true;
			int j = 3;
			while(j * j <= i){
				if(i % j == 0){
					flag = false;
					break;
				}
				j += 2;
			}
			if(flag) vec.pb(i);
		}
	}
	return;
}

int sosuu(int n){
	int i = 0;
	while(vec[i] <= n && i < vec.size()) ++i;

	return i;
}

int main(){
    int n;
    makesosuu();
    while(cin >> n){
        cout << sosuu(n) << endl;   
    }	
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    int res = 400000005;
    for(int i=0; i<N-K+1; i++) {
        int l = x[i], r = x[i+K-1];
        int al = abs(l), ar = abs(r);
        int temp = 400000006;
        if(l<0 && r>=0) {
            temp = min(al*2+ar, ar*2+al);
        } else if(r < 0) {
            temp = al;
        } else {
            temp = ar;
        }
        res = min(res, temp);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

char str[maxn];
int len;

int main()
{
	scanf("%s",str); len=strlen(str);
	for(int i=0;i+1<len;i++) if(str[i]=='A'&&str[i+1]=='C') return puts("Yes"),0;
	puts("No");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    VI c(m); cin >> c;

    VI dp(n + 1, INF);
    dp[0] = 0;
    FOR(i, 0, m)eFOR(j, c[i], n) {
        chmin(dp[j], dp[j - c[i]] + 1);
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll N;cin>>N;
    vector<ll> a(N),b(N),c(N);
    rep(i,0,N)cin>>a.at(i);
    rep(i,0,N)cin>>b.at(i);
    rep(i,0,N)cin>>c.at(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll bko[100010],brui[100010];
    rep(i,0,N){
        bko[i]=c.end()-upper_bound(c.begin(),c.end(),b.at(i));
    }
    brui[0]=0;
    rep(i,1,N+1){
        brui[i]=bko[i-1]+brui[i-1];
    }
    ll ans=0;
    rep(i,0,N){
        if(a.at(i)<b.at(N-1)){
            ans+=brui[N]-brui[upper_bound(b.begin(),b.end(),a.at(i))-b.begin()];
        }
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 4224
S = list(input())
targ = 'ACGT'

ans = 0
ans_tmp = 0
for i, Si in enumerate(S):
    if Si in targ:
        ans_tmp += 1
    else:
        ans = max(ans, ans_tmp)
        ans_tmp = 0
else:
    ans = max(ans, ans_tmp)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h> 

int main(void) 
{
	
	int i,j,temp;
	int data[5];
	
		
	for(i=0;i<5;i++){
		scanf("%d",&data[i]);
			}

		for(i=0;i<4;i++){
			for(j=i+1;j<5;j++){
				if(data[i]<data[j]){
					temp=data[i];
					data[i]=data[j];
					data[j]=temp;
				}
			}
		}
		
		for(i=0;i<4;i++){
			printf("%d ",data[i]);
		}

		printf("%d\n",data[5-1]);

		return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		if(!solve(n, s))
			System.out.println(-1);
	}
	
	static boolean solve(int n, String s){
		int ans[][] = new int[4][n];
		
		ans[0][0] = 1;
		ans[0][1] = 1;
	
		ans[1][0] = 0;
		ans[1][1] = 1;
		
		ans[2][0] = 1;
		ans[2][1] = 0;
		
		ans[3][0] = 0;
		ans[3][1] = 0;
		
		for(int i=0;i<4;i++){
			if(build(ans[i], s)){
				for(int j=0;j<n;j++){
					System.out.print(ans[i][j] == 1 ? 'S':'W');
				}
				return true;
			}
		}
		return false;
	}
	
	static boolean build(int a[], String s){
		int n = a.length;
		for(int i=1;i<n-1;i++){
			char c = s.charAt(i);
			if(a[i] == 1 &&  c == 'o' || a[i] == 0 &&  c == 'x'){
				a[i+1] = a[i-1];
			}
			else{
				a[i+1] = 1-a[i-1];
			}
		}
		
		boolean f1 = check(a[n-1], a[0], a[1], s.charAt(0));
		boolean f2 = check(a[n-2], a[n-1], a[0], s.charAt(n-1));
		
		return f1 && f2;
	}
	
	static boolean check(int a1, int a2, int a3, char c){
		if(a2==1){
			if(c=='o')
				return a1==a3;
			else
				return a1!=a3;
		}
		else{
			if(c=='o')
				return a1!=a3;
			else
				return a1==a3;
			
		}
	}
}


Measured memory_bytes: 34580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  
  vector<ll>x(N+1);//範囲なしを含まなければならないのでx[0]を空白にする
 ll sum=0;
 for(ll i=1;i<=N;i++){
    cin>>x[i];
  }
  
  ll dp[N+1][N+1][N*K+1];//N*１~N*Kまでの和がわかればいいのでN*K+1で十分
  rep(i,N+1){
    rep(j,N+1){
rep(k,N*K+2){
  dp[i][j][k]=0;
}
    }
  }

  dp[0][0][0]=1;
  for(ll j=0;j<=N;j++){//jはx[1]からx[j]まで使うという意味 x[0]は何も使わないという意味
    for(ll k=0;k<=N;k++){//そのうちk個使う
for(ll s=0;s<=N*K;s++){//上の条件で和sになるパターン数
 if(j>=1&&s<x[j]){//x[j]を足してsになるものが存在しない
dp[j][k][s]=dp[j-1][k][s];//x[j]を使わない
  }
else if(j>=1&&k>=1&&s>=x[j]){//x[j]を足してsになるものが存在する
dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];//x[j]を使うパターンとx[j]を使うパターン
}

    }
    }
  }
  ll ans=0;
  for(ll i=1;i<=N;i++){
ans+=dp[N][i][K*(i)];//i個取った時平均がK*iになることを考える
    

}
  
  cout<<ans<<endl;
  
}



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

typedef long long ll;

const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> h(3,vector<int>(N));
    for (int i = 0; i < N; i++) cin >> h[0][i] >> h[1][i] >> h[2][i];
    vector<vector<int>> dp(N+5,vector<int>(3,-1));
    dp[1][0] = h[0][0];
    dp[1][1] = h[1][0];
    dp[1][2] = h[2][0];
    for (int i=1;i<N;i++){
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                if (k==j) continue;
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + h[j][i]);
            }
        }
    }
    int ans = -1;
    for (int i=0;i<3;i++){
        ans = max(ans, dp[N][i]);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 6904
// http://agc010.contest.atcoder.jp/tasks/agc010_f

#include <iostream>
#include <vector>

//{
struct _read_type {
	std::istream& str;
	_read_type(std::istream& str) : str (str) {}
	template <typename T>
	_read_type operator , (T& t) { str >> t; return *this; }
} _read (std::cin);
struct _write_type {
	std::ostream& str;
	_write_type(std::ostream& str) : str (str) {}
	template <typename T>
	_write_type operator , (T t) { str << t; return *this; }
} _write (std::cout);
#define  read _read ,
#define write _write,
//}

int nnode;
std::vector<std::vector<int>> adjlist;
enum class state {undef, win, lose};
std::vector<state> dfs_trace;

state dfs(int node) {
	if (dfs_trace[node] != state::undef) return dfs_trace[node];
	bool can_get_to_lose = false;
	for (int child : adjlist[node]) {
		if (dfs(child) == state::lose) can_get_to_lose = true;
	}
	return dfs_trace[node] = can_get_to_lose ? state::win : state::lose;
}

int main() {
	#ifndef _GLIBCXX_DEBUG
	std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr);
	#endif // _GLIBCXX_DEBUG
	read nnode;
	std::vector<int> data (nnode);
	adjlist.assign(nnode, {});
	for (int& x : data) read x;
	for (int e = 1; e < nnode; ++e) {
		int u, v; read u, v;
		--u; --v;
		if (data[u] > data[v]) adjlist[u].push_back(v);
		if (data[v] > data[u])adjlist[v].push_back(u);
	}
	dfs_trace.assign(nnode, state::undef);
	for (int node = 0; node < nnode; ++node) if (dfs(node) == state::win) write node+1, ' ';
	write '\n';
}




Measured memory_bytes: 384
import math
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    a = math.log2(K/i)
    if a > 0:
        ans += 0.5**math.ceil(math.log2(K/i))/N
    else:
        ans += 1/N
print(ans)

Measured memory_bytes: 9356
def solve(N, arr):
  ways = [float('inf')] * N
  ways[0] = 0
  
  for i in range(len(ways)):
    if i - 1 >= 0:
      ways[i] = min(ways[i], ways[i-1] + abs(arr[i] - arr[i-1]))
    if i - 2 >= 0:
      ways[i] = min(ways[i], ways[i-2] + abs(arr[i] - arr[i-2]))
  return ways[-1]

N = int(input())
arr = [int(s) for s in input().split()]
print(solve(N, arr))

Measured memory_bytes: 13980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        //var s = Console.ReadLine();
        var l = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => -x).ToArray();

        var ans = 0;
        for (int i = 0; i < l.Length - 2; i++)
        {
            for (int j = i + 1; j < l.Length - 1; j++)
            {
                for (int k = l.Length - 1; k > j; k--)
                {
                    if (l[i] < l[j] + l[k] &&
                        l[j] < l[k] + l[i] &&
                        l[k] < l[i] + l[j])
                    {
                        ans += k - j;
                        break;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13416
S = input()
word_01 = '01'
word_10 = '10'
q, mod = divmod(len(S), 2)
if mod == 0:
    word_01 = word_01 * q
    word_10 = word_10 * q
else:
    word_01 = word_01 * q + '0'
    word_10 = word_10 * q + '1'
S_list = list(S)
word_01_list = list(word_01)
word_10_list = list(word_10)
counter1 = 0
counter2 = 0
for num1, num2, num3 in zip(S_list, word_01_list, word_10_list):
    if num1 != num2:
        counter1 += 1
    if num1 != num3:
        counter2 += 1
result = min(counter1, counter2)
print(result)

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

int n;
vector<int> a;

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    cin >> n;
    a.resize(n+1);
    for(int i=0;i<=n;i++)
    	cin >> a[i];
   	vector<int> dp(n+1);
    
    dp[n] = a[n];
    for(int i=n-1;i>=0;i--)
    	dp[i] = a[i] + dp[i+1];

    int ans = 1, curr = 1;
    if(a[0] == 1 and n >= 1)
    {
    	cout << "-1\n";
    	return 0;
    }
    for(int i=1;i<=n;i++)
    {
    	int max_poss = 2*(curr-a[i-1]);
    	if(curr < a[i-1])
    	{
    		cout << "-1\n";
    		return 0;
    	}
    	curr = min(max_poss, dp[i]);
    	ans += curr;
    }
    if(curr - a[n]) cout << "-1\n";
    else
    	cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4784
#include<iostream>
using namespace std;
int main(){
	int a[16]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};
        int n;
	cin>>n;
        int x,y;
        for(int i=0;i<n;i++){
		cin>>x>>y;
		int l,m;
                if(x<y){
                    for(int j=0;j<10;j++)
                        if(a[j]==x) l=j;
	            for(int k=l;k<10;k++)
			if(a[k]==y) m=k;
		    for(int p=l;p<m;p++)
		        cout<<a[p]<<" ";
                    cout<<a[m];
                } else{if(y<=5){
		    for(int j=0;j<16;j++)
                        if(a[j]==x) l=j;
	            for(int k=l;k<16;k++)
			if(a[k]==y) m=k;
		    for(int p=l;p<m;p++){
		         cout<<a[p]<<" ";
                    }
                    cout<<a[m];
	            
                    }else {
                       for(int j=0;j<16;j++)
                            if(a[j]==x) l=j;
                       for(int p=l;p<=15;p++)
		            cout<<a[p]<<" ";
                       for(int k=0;k<16;k++)
			    if(a[k]==y) m=k;
                       for(int q=1;q<m;q++)
		           cout<<a[q]<<" ";                       
                        cout<<a[m];
                    }              
                 }
                 cout<<endl;
        }
        return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 43524
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

bool ok(string s) {
  // cerr << s << endl;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] != s[n - 1 - i]) return false;
  }
  return true;
}

int main() {
  
  string s; cin >> s;
  int n = s.size();
  string s1 = s.substr(1 - 1, n / 2);
  string s2 = s.substr((n + 3) / 2 - 1, n / 2);
  if (ok(s) and ok(s1) and ok(s2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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




int main() {
    int a,b;
    
    cin >> a >> b;
    
    int A=0,B=0;
    
    for(int i=0;i<b;i++){
        int p=10,k=0;
        k = pow(p,i);
        A += a*k;
    }
    
    for(int i=0;i<a;i++){
        int p=10,k=0;
        k = pow(p,i);
        B += b*k;
    }
    
    string ans1,ans2;
    
    ans1=to_string(A);
    ans2=to_string(B);
    
    
    if(ans1<ans2)cout << ans1 << endl;
    else if(ans1>ans2)cout << ans2 << endl;
    else cout << ans1 << endl;
    
    
    
}






Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


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

    return 0;
}

Measured memory_bytes: 256
/*
    对于一条把树分成s和n-s的边
	C(s,k) -> s! / k! / (s-k)!
	C(n-s,k) -> (n-s)! / k! / (n-s-k)! 
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=600005,ha=924844033,root=5;
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}

inline int ksm(int x,int y){
	int an=1;
	for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
	return an;
}

int jc[maxn+5],ni[maxn+5],n,m,ans,to[maxn*2],ne[maxn*2],num,inv;
int a[maxn+5],b[maxn+5],r[maxn+5],siz[maxn+5],hd[maxn],N,l,INV;

inline void addline(int x,int y){ to[++num]=y,ne[num]=hd[x],hd[x]=num;}

inline int C(int x,int y){ return x<y?0:jc[x]*(ll)ni[y]%ha*(ll)ni[x-y]%ha;}

inline void init(){
	jc[0]=1;
	for(int i=1;i<=maxn;i++) jc[i]=jc[i-1]*(ll)i%ha;
	ni[maxn]=ksm(jc[maxn],ha-2);
	for(int i=maxn;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}

void dfs(int x,int fa){
	siz[x]=1;
	for(int i=hd[x];i;i=ne[i]) if(to[i]!=fa) dfs(to[i],x),siz[x]+=siz[to[i]];
	if(x!=1) ADD(a[siz[x]],jc[siz[x]]),ADD(a[n-siz[x]],jc[n-siz[x]]);
}

inline void NTT(int *c,int f){
	for(int i=0;i<N;i++) if(i<r[i]) swap(c[i],c[r[i]]);
	
	for(int i=1;i<N;i<<=1){
		int omega=ksm(f==1?root:inv,(ha-1)/(i<<1));
		for(int j=0,P=i<<1;j<N;j+=P){
			int now=1;
			for(int k=0;k<i;k++,now=now*(ll)omega%ha){
				int x=c[j+k],y=c[j+k+i]*(ll)now%ha;
				c[j+k]=add(x,y);
				c[j+k+i]=add(x,ha-y);
			}
		}
	}
	
	if(f==-1) for(int i=0;i<N;i++) c[i]=c[i]*(ll)INV%ha;
}

inline void solve(){
	dfs(1,1);
	for(int i=0;i<n;i++) b[n-i]=ni[i];
	
	for(N=1;N<=(2*n);N<<=1) l++;
	for(int i=0;i<N;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	
	NTT(a,1),NTT(b,1);
	for(int i=0;i<N;i++) a[i]=a[i]*(ll)b[i]%ha;
	INV=ksm(N,ha-2),NTT(a,-1);
	
	for(int i=1;i<=n;i++) a[i+n]=add(ha-a[i+n]*(ll)ni[i]%ha,C(n,i)*(ll)n%ha);
}

int main(){
//	freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	
	init(),inv=ksm(5,ha-2);
	
	scanf("%d",&n);
	
	int uu,vv;
	for(int i=1;i<n;i++) scanf("%d%d",&uu,&vv),addline(uu,vv),addline(vv,uu);
	
	solve();
	
	for(int i=1;i<=n;i++) printf("%d\n",a[i+n]);
	return 0;
}

Measured memory_bytes: 30592
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;

  int zero = count(s.begin(), s.end(), '0');
  int one =  count(s.begin(), s.end(), '1');
  int ans = min(zero, one) * 2;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, M, X[100001];
vector<P> p;
map<int, bool> mp;

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

    cin >> N >> M;
    for(int i = 0; i < M; ++i) cin >> X[i];
    sort(X, X + M);
    for(int i = 1; i < M; ++i) {
        p.push_back(P(abs(X[i] - X[i - 1]), X[i]));
    }
    sort(p.begin(), p.end(), greater<P>());
    int it = 0;
    mp[X[0]] = true;
    while(N > 1 && it < M - 1) {
        mp[p[it++].second] = true;
        --N;
    }
    int res = 0, before = 0;
    for(int i = 0; i < M - 1; ++i) {
        if(mp[X[i + 1]]) {
            res += X[i] - X[before];
            before = i + 1;
        }
        else if(i == M - 2) {
            res += X[i + 1] - X[before];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8816
<?php
fscanf(STDIN, "%d", $N);
$X = explode(" ", trim(fgets(STDIN)));
$Y = $X;
sort($Y);

$n1 = $Y[$N / 2 - 1];
$n2 = $Y[$N / 2];

// echo "{$n1} {$n2}\n";

for ($i = 0; $i < $N; $i++) {
	if ($n2 <= $X[$i]) {
		echo $n1;
	} else {
		echo $n2;
	}
	echo PHP_EOL;
}


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

using namespace std;

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

    int n, cnt = 0;

    cin >> n;
    for (int i = 1; i <= n; i += 2) {
        int num = 0;
        for (int j = 1; j <= i; ++j)
            if (i % j == 0) ++num;
        if (num == 8) ++cnt;
    }

    cout << cnt << endl;

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int S,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>W;
	if(W>=S) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int q = scanner.nextInt();
        scanner.nextLine();

        final int[] a = new int[q];
        for (int i = 0; i < a.length; i++) {
            a[i] = Integer.parseInt(scanner.nextLine());
        }

        final int[] okCounts = new int[n];
        for (int i = 0; i < a.length; i++) {
            okCounts[a[i] - 1]++;
        }

        for (int i = 0; i < n; i++) {
            if (okCounts[i] - q + k > 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 115788
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#define LL long long
using namespace std;
#define maxn 100007
char s[maxn];
int a[maxn];
int main()
{
    int n,i,j,k,first,x,y,ans=-1;
    scanf("%s",s+1);
    n=strlen(s+1);
    //first=s[0]-'0';
    a[1]=1;
    k=1;
    if(n>1)
    {
        for(i=2;i<=n+1;i++)
        {
            if(s[i]==s[i-1])
                a[k]++;
            else
            {
                k++;
                a[k]=1;
            }
        }
    }
    k--;
    //printf("k=%d\n",k);
    x=n;
    if(k>1)
    {
        int pre=a[1];
        for(i=2;i<=k;i++)
        {
            x=min(x,max(pre,n-pre));
            pre+=a[i];
        }
    }
    //x=max(x,(n+1)/2);
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 512
N=int(input())
NList=[input() for i in range(N)]
M=int(input())
MList=[input() for i in range(M)]

ans=0
for a in range(0,N):
  A=NList.count(NList[a])-MList.count(NList[a])
  if A >ans:
    ans = A
    
if ans >0:
  print(ans)
else:
  print(0)


Measured memory_bytes: 3060
using System;

namespace Rally
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String[] input = Console.ReadLine().Split(' ');
            int[] X = new int[N];
            for(int i = 0; i < N; i++)
            {
                X[i] = int.Parse(input[i]);
            }

            double result=Double.PositiveInfinity;
            double cost;
            
            for(int i = 0; i < 100; i++)
            {
                cost = 0;
                for(int j = 0; j < N; j++)
                {
                    cost += Math.Pow((X[j] - i), 2);
                }
                result = Math.Min(result, cost);

            }
            Console.WriteLine((int)result);
        }
    }
}


Measured memory_bytes: 11220
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353


def judge(li):
    c = s[0]
    for i in range(len(li)):
        if li[i] == False:
            c += s[i+1]
        else:
            c += "+" + s[i+1]
    return c
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    li = [False]*(n)
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = True
    a = judge(li)
    e = a[0]
    sumli = []
    for j in range(1,len(a)):
        if a[j] == "+":
            sumli.append(int(e))
            e = ""
        else:
            e += a[j]
    sumli.append(int(e))
    ans += sum(sumli)
print(ans)

Measured memory_bytes: 3316
N=int(input())
s=input()

count=0

for i in range(0,10):
    if str(i) in s[:-2]:
        index_1=s.index(str(i))

        for j in range(0,10):
            if str(j) in s[index_1+1:-1]:
                index_2=s[index_1+1:-1].index(str(j))+index_1+1

                for k in range(0,10):
                    if str(k) in s[index_2+1:]:
                        count+=1
print(count)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define MAXN  50005 
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(ll i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
	IOS;
	ll t,n,l;
	ll i,j,m,mn,d,x,a,b,y,ans=0,temp,sum,c;
	string s,s1;
	cin>>s>>s1;
	n=s.size();
	rep(i,0,n)if(s[i]!=s1[i])ans++;
	cout<<ans;
}

Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var a = consoleReader.Split.Int;
            var b = consoleReader.Split.Int;

            long count = 0;
            for (int i = 0; i < N; i++)
            {
                if (a[i] > b[i])
                {
                    count += b[i];
                }
                else
                {
                    count += a[i];
                    b[i] -= a[i];

                    if (a[i + 1] > b[i])
                    {
                        count += b[i];
                        a[i + 1] -= b[i];
                    }
                    else
                    {
                        count += a[i + 1];
                        a[i + 1] = 0;
                    }
                }
            }
            return count;
        }
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 34140
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

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

	int sum_l=0;
	int sum_r = 0;
	for(int i = 0; i < m; i++)
	{
		if(a[i] < x){
			sum_l++;
		}else{
			sum_r++;
		}
	}

	cout << min(sum_l, sum_r) << endl;
	
	return 0;
}

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

#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
#define N 100007
#define mod 1000000007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll cnt=0;
    while(a>=b)
    {
        b=b*2;
        cnt++;
    }
    while(b>=c)
    {
        c=c*2;
        cnt++;
    }
    if(cnt<=k)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	if (a == 1) a += 13;
	if (b == 1) b += 13;
	if (a == b) cout << "Draw" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,a[100],al,bo;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	sort(a,a+n,greater<int>() );
	al=0;	bo=0;
	for(i=0;i<n;i++)	{
		if(i%2==0)	al+=a[i];
		else bo+=a[i];
	}
	printf("%d\n",al-bo);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;



int main()
{
	int n;cin>>n;
	list<int> s;
	rep(i,n)
	{
		char a[20];
		scanf("%s",a);
		

		if(!strncmp(a,"insert",12))
		{int k;
		scanf("%d",&k);
			//cout<<"aaa"<<endl;
				s.insert(s.begin(),k);
		}
		else if(!strncmp(a,"delete",12))
		{int k;
		scanf("%d",&k);
			for(auto itr = s.begin();itr != s.end();++itr)
			if(*itr==k){s.erase(itr);break;}
		}
		else if(!strncmp(a,"deleteFirst",12))
		{
			s.pop_front();
		}
		else if(!strncmp(a,"deleteLast",12))
		{
			s.pop_back();
		}
		//for(auto itr = s.begin(); itr != s.end();++itr)
	//printf("%d ",*itr);
	//printf("\n");
	}
	for(auto itr = s.begin(); itr != s.end();++itr)
	{
	if(itr!=s.begin())printf(" ");
	printf("%d",*itr);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 34404
#include<iostream>

using namespace std;

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int y3 = (x2-x1)+y2;
  int x3 = -(y2-y1)+x2;
  int y4 = (x3-x2)+y3;
  int x4 = -(y3-y2)+x3;
  cout << x3 << " " << y3 << ' ' << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
/* Written in FCP - alpha version */
#ifdef false
/* Original code */
$i
X:int
$p
if X >= 30 {
    <<"Yes"
}{
    <<"No"
}
#endif
/* Transpiled code */

#include <bits/stdc++.h>

#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second

using namespace std;

using str = string;
using uint = unsigned int;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<str>;
using vvs = vector<vector<str>>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<typename T>
std::ostream& operator<<(std::ostream& s, std::vector<T> t) {
    for (int i = 0; i < sz(t); i++) {
        s << t[i] << (i == sz(t) - 1 ? "" : " ");
    }
    return s;
}



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

    
        int X;
cin >> X;
if (X >= 30) {
    cout <<"Yes";
} else {
    cout <<"No";
};
        goto end_tc_label;
        end_tc_label:;
    
}


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

int kazu[100001] = {0};

void swap (long long *x, long long *y) {
  long long temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

void swap2 (int *x,  int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (long long array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); swap2(&kazu[i], &kazu[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新
  swap2(&kazu[pivot], &kazu[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (long long array[], int left, int right) {
  long long pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}





int main(){
    int n,m;
    long long nedan[100001] = {0};

    
 
    scanf("%d%d",&n,&m);

    
    for (int i = 0; i < n; i++) {
       scanf("%lld%d",&nedan[i],&kazu[i]);
    }


    quick_sort(nedan, 0, n-1);




    long long ans = 0;
    int num = 0;

    for (int i = 0; i < m; i++) {
        if (kazu[num] == 0) {
            num++;
        }
        kazu[num]--;
        ans = ans + nedan[num];

    }

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


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n,a[100000],i,c=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];	
	}
	for(i=1;i<=n;i++){
		if(a[i]==i){
		int t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			c++;		
		}
	if(a[i]==i&&i==n){
		int t=a[i];
			a[i]=a[i-1];
			a[i-1]=t;
			c++;		
		}	
	}
	cout<<c<<endl;
    //code:尧雷
	return 0;
}


Measured memory_bytes: 640
n = int(input())
v = list(map(int,input().split()))
v1 = sorted(v[0::2])
v2 = sorted(v[1::2])
s1 = set(v1)
s2 = set(v2)

eve = [[0,0]]
odd = [[0,0]]
cnt_eve = 1
cnt_odd = 1

for i in range(1,n//2):
    ## 偶数項
    if v1[i] == v1[i-1]:
        cnt_eve += 1
    else:
        eve.append([cnt_eve, v1[i-1]])
        cnt_eve = 1
    ## 奇数項
    if v2[i] == v2[i-1]:
        cnt_odd += 1
    else:
        odd.append([cnt_odd, v2[i-1]])
        cnt_odd = 1
    if i == n//2 - 1:
        eve.append([cnt_eve, v1[i]])
        odd.append([cnt_odd, v2[i]])


eve.sort(key=lambda x: x[0], reverse=True)
odd.sort(key=lambda x: x[0], reverse=True)

if eve[0][1] != odd[0][1]:
    ans = n - eve[0][0] - odd[0][0]
    print(ans)
else:
    ans = n - max(eve[0][0] + odd[1][0], eve[1][0] + odd[0][0])
    print(ans)

Measured memory_bytes: 22912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		int n = in.nextInt() ;
		int t[] = new int[109] ;
		long res[] = new long[109] ;
		int k=0;
		long total = 0 ;
		for(int i=1;i<=n;i++) {
			t[i] = in.nextInt() ;
			total+=t[i];
		}
		int m = in.nextInt() ;
		for(int i=0;i<m;i++) {
			int p = in.nextInt() ;
			int x = in.nextInt() ;
			res[k++]=total+(x-t[p]);
		}
		for(int i=0;i<k;i++) {
			System.out.println(res[i]) ;
		}
	}

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 
fast;
ll n,m;
cin>>n>>m;

ll h[n+1];
for(ll i=1;i<=n;i++) cin>>h[i];

set<ll> s;
for(ll i=1;i<=n;i++)s.insert(i);

for(ll i=0;i<m;i++)
{
    ll a,b;
    cin>>a>>b;

    if(h[a]>h[b])
        s.erase(b);
    else if(h[b]>h[a])s.erase(a);
    else 
    {
        s.erase(a);
        s.erase(b);
    }
}
cout<<s.size();

}

Measured memory_bytes: 9140
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <vector>

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;
}

int main()
{
    int N;

    gc(N);

    int tmp;
    int64_t ttl = 0;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        gc(tmp);
        a[i] = tmp;
        ttl += tmp;
    }

    int64_t now = 0;
    int64_t mn = INT64_MAX;
    for (int i = 0; i < N - 1; i++)
    {
        now += a[i];
        mn = min(mn, abs(ttl - 2 * now));
    }

    printf("%" PRId64 "\n", mn);
    return 0;
}


Measured memory_bytes: 1024