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

int popcnt(unsigned x) {
  int ret = 0;
  for (int i = 0; i < 32; i++) {
    ret += x & 1;
    x >>= 1;
  }
  return ret;
}

int f(unsigned x) {
  int ret = 0;
  while (x != 0) {
    x %= popcnt(x);
    ret++;
  }
  return ret;
}

int str_mod(const string& x, int m) {
  int ret = 0;
  if (m == 0) return ret;
  for (char c : x) {
    ret <<= 1;
    ret += c - '0';
    ret %= m;
  }
  return ret;
}

vector<int> tpow_mod(int n, int m) {
  if (m == 0) return vector<int>();
  vector<int> ret(n, 1 % m);
  for (int i = 1; i < n; i++) ret[i] = ret[i - 1] * 2 % m;
  return ret;
}

int main() {
  int n;
  string x;
  cin >> n >> x;
  int pc = count(x.begin(), x.end(), '1');
  int xmp = str_mod(x, pc + 1);
  int xmm = str_mod(x, pc - 1);
  vector<int> tmp = tpow_mod(n, pc + 1);
  vector<int> tmm = tpow_mod(n, pc - 1);
  reverse(x.begin(), x.end());
  for (int i = n - 1; i >= 0; i--) {
    if (x[i] == '1') {
      if (pc == 1) {
        cout << 0 << '\n';
      } else {
        int m = pc - 1;
        cout << (1 + f((xmm + m - tmm[i]) % m)) << '\n';
      }
    } else {
      int m = pc + 1;
      cout << (1 + f((xmp + tmp[i]) % m)) << '\n';
    }
  }
}

Measured memory_bytes: 5080
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = intArray[0];
            int B = intArray[1] * 2;
            if(A <= B)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(A - B);
            }
           
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28192
lines = []
N,K = gets.split.map(&:to_i)

lines=gets.split.map(&:to_i)
K.times do
imos=Array.new(N,0)

N.times do |k|
  p=[k-lines[k],0].max
  imos[p]+=1
  m=[k+lines[k]+1,N].min
  imos[m]-=1 if N>m
end
(N-1).times do |i|
  imos[i+1]+=imos[i]
end
lines=imos
break if imos.all? {|v| v == N }
end
puts lines.join(" ")

Measured memory_bytes: 80648
n, x = map(int, input().split())
def all_putty(m):
 return 2**(m+1)-1
count = 0
for l in range(n+1)[::-1]:
  mark = 2**(1+l)-1
  if x >= mark:
    count += all_putty(l-1) +1
    x -= mark
  else:
    x -= 1
print(count)

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

int main()
{
    int n;
    cin >> n;
    map<string,vector<pair<int,int>>> mp;
    rep(i,n)
    {
        string s;
        int p;
        cin >> s >> p;
        if(mp.count(s))
            mp[s].push_back({p,i});
        else
        {
            vector<pair<int,int>> v(1,{p,i});
            mp.insert({s,v});
        }
    }

    for(auto& c:mp)
    {
        sort(c.second.begin(),c.second.end(),greater<pair<int,int>>());
        for(auto r:c.second)
            cout << r.second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
hl = LI()
# count = 0

# len_h = len(hl)

# def m1(n):
#     if n > 0:
#         n = n - 1
#     else:
#         n = 0
#     return n

# max_hana = max(hl)
# if max_hana == 0:
#     print(0)
#     sys.exit()

# for i in range(max_hana):
#     for j in range(len_h):
#         if j == 0:
#             if hl[j] > 0:
#                 count += 1
#         else:
#             if hl[j] > 0 and hl[j-1] == 0:
#                 count += 1
#             elif hl[j] > 0 and hl[j-1] == 0:
#                 count += 1
#     hl = list(map(m1, hl))

# print(count)

######################
# 隣との差分を考えたほうが早い

# 1    2    4    2    1    0      計4
#   1    2    0    0     0

ans = hl[0]
for i in range(1, n):
    ans += max(0, hl[i] - hl[i - 1])
print(ans)



Measured memory_bytes: 9224
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
L=[int(i) for i in input().split()]
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      A=[L[i],L[j],L[k]]
      A.sort()
      a,b,c=A
      if a<b<c and c<a+b:
        ans+=1

print(ans)


Measured memory_bytes: 73944
n,k = map(int,input().split())
a = list(map(int,input().split()))

p = []
m = []
for i in a:
    if i >= 0:
        p.append(i)
    else:
        m.insert(0,-i)
p.insert(0,0)
m.insert(0,0)

ans = 10**9
for i in range(k+1):
    if i < len(p) and k-i < len(m):
        d_p = p[i]
        d_m = m[k-i]
        d = min(d_p,d_m)*2 + max(d_p,d_m)
        ans = min(ans,d)

print(ans)

Measured memory_bytes: 20132
class SegmentTree():
    def __init__(self, arr, func=min, ie=2**63):
        self.h = (len(arr) - 1).bit_length()
        self.n = 2**self.h
        self.ie = ie
        self.func = func
        self.tree = [ie for _ in range(2 * self.n)]
        for i in range(len(arr)):
            self.tree[self.n + i] = arr[i]
        for i in range(1, self.n)[::-1]:
            self.tree[i] = func(self.tree[2 * i], self.tree[2 * i + 1])

    def set(self, idx, x):
        idx += self.n
        self.tree[idx] = x
        while idx:
            idx >>= 1
            self.tree[idx] = self.func(self.tree[2 * idx], self.tree[2 * idx + 1])

    def query(self, lt, rt):
        lt += self.n
        rt += self.n
        vl = vr = self.ie
        while rt - lt > 0:
            if lt & 1:
                vl = self.func(vl, self.tree[lt])
                lt += 1
            if rt & 1:
                rt -= 1
                vr = self.func(self.tree[rt], vr)
            lt >>= 1
            rt >>= 1
        return self.func(vl, vr)

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
A = list(map(int, input().split()))

st = SegmentTree(A, max, 0)
res = list()

for _ in range(Q):
    t, x, y = map(int, input().split())
    if t == 1:
        st.set(x - 1, y)
    elif t == 2:
        res.append(st.query(x - 1, y))
    else:
        hi = N + 1
        lo = x - 1
        while hi - lo > 1:
            mid = (hi + lo) // 2
            if st.query(x - 1, mid) >= y:
                hi = mid
            else:
                lo = mid
        res.append(lo + 1)

print('\n'.join(map(str, res)))

Measured memory_bytes: 124692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A, sum = 0;
    bitset<2000*2000+1> bs;
    bs.set(0);
    rep(i, N){
        cin >> A;
        sum += A;
        bs |= (bs<<A);
    }
    for(int i = (sum+1)/2;;i++){
        if(bs[i]) {cout << i << endl; break;}
    }
}

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



int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<long long>());
	vector<long long> p;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			p.push_back(a[i]);
			i++;
		}
		if (p.size() == 2) {
			cout << p[0] * p[1] << endl;
			return 0;
		}
		
	}
	cout << 0 << endl;
	return 0;
}



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

using namespace std;

#define F first
#define S second
#define MAX_N 100010

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vbl;

vi adj[MAX_N];
vi dp;
int res = 0;

int dfs(int u) {
  int len = 0;
  for (auto v : adj[u]) {
    if (dp[v] != -1) {
      len = max(len,1+dp[v]);
    }
    else {
      len = max(len,1+dfs(v));
    }
  }

  dp[u] = len;
  res = max(res,len);
  return len;
}

int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  dp.assign(n+1,-1);

  for (int i = 0 ; i < m ; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
  }

  for (int i = 1 ; i <= n ; i++) {
    if (dp[i] == -1) dfs(i);
  }

  cout << res << endl;

  return 0;
}

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

using namespace std;

int main()
{
	int a, b, ans;
	string op;

	while (1)
	{
		// ??\???
		cin >> a >> op >> b;

		if (op == "+")
		{
			ans = a + b;
			cout << ans << endl;
		}
		else if (op == "-")
		{
			ans = a - b;
			cout << ans << endl;
		}
		else if (op == "*")
		{
			ans = a * b;
			cout << ans << endl;
		}
		else if (op == "/")
		{
			ans = a / b;
			cout << ans << endl;
		}
		else
		{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;
int cnt;
int ans;

signed main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'A')cnt++;
		else if (s[i] == 'B'&&s[i + 1] == 'C') {
			ans += cnt;
			i++;
		}
		else cnt = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		int A[] = new int[N];
		for(int i=0;i<N;i++)A[i]=sc.nextInt();
 		sc.close();
 		
 		rsort(A);
 		
 		//２数の和がKを越えるものだけ使うことにする。
 		int R = 2*100000 + 100;
 		int L = 0;
 		while(L+1<R) {		
 			int C = (L+R)/2;//このcが実現できるか調べるK
 			long subsum = 0;
 			for(int i=0;i<N;i++) {
 				int base = A[i];
 				int r = N;
 				int l = i-1;
 				while(l+1<r) {
 					int c = (l + r)/2;
 					if(base + A[c]>=C)l=c;
 					else r = c;
 				}
 				if(l-i<0)continue;
 				subsum += 1 + 2*(l-i);
 			}
 			if(subsum>=M) L = C;
 			else R = C;
 		}
 		//Lが最小のX
 		
 		long memosum = 0;
 		int min = Integer.MAX_VALUE;
 		int memo[] = new int[N];
 		for(int i=0;i<N;i++) {
				int base = A[i];
				int r = N;
				int l = i-1;
				while(l+1<r) {
					int c = (l + r)/2;
					if(base + A[c]>=L)l=c;
					else r = c;
				}
				memo[i]=l-i; //到着要素番号が入ってる
				
				if(l-i>=0) {
					memosum += 2*(l-i)+1;
					min = Math.min(min,base+A[l]);
				}
				
			}
 		
 		
 		
 		long sum[] = new long[N+1];
 		for(int i=0;i<N;i++)sum[i+1]=sum[i]+ A[i];
 		
 		long ans = 0;
 		for(int i=0;i<N;i++) {
 			if(memo[i]<0)break;
			int last = i+memo[i];
			long tmp = ((long)last-i+1)*2*A[i]+2*(sum[last+1]-sum[i+1]);
			ans += tmp;
 		}
 		long mul = Math.max(0,memosum-M);
 		ans -= mul*min;
 		System.out.println(ans);
	}
	
	static void rsort(int[] x) {
		Arrays.sort(x);
		int len = x.length;
		for(int i=0;i<len/2;i++) {
			int tmp = x[i];
			x[i]=x[len-1-i];
			x[len-1-i]=tmp;
		}
	}
}


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

int calc(int X)
{
	int res=0;
	for(int i=1;i*i<=X;i++) if(X%i==0){
		int j=X/i;
		if((i+j)%2==1) res++;
	}
	return res;
}

signed main()
{
	int S; cin>>S;
	S*=4;
	int ans=0;
	for(int i=1;i*i<=S;i++) if(S%i==0){
		int X=i, Y=S/i;
		ans+=calc(X)*calc(Y);
		if(X!=Y) ans+=calc(X)*calc(Y);
	}
	cout<<ans<<endl;
	return 0;
}




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

typedef long long ll;
const int N = 200;
ll dp[21][N];

ll solve(int n,int sum,int now,vector<int> &in,int veri){
  //cout << n <<" " << now <<" " << sum << " " << veri << endl;
  if (n == now){
    if (sum == veri)return 1;
    else return 0;
  }
  
  ll &ret = dp[sum][now];
  if (ret == -1){
    ret=0;
    if (0<=sum+in[now] && sum+in[now] <= 20){
      ret+=solve(n,sum+in[now],now+1,in,veri);
    }

    if (now != 0 && 0<=sum-in[now] && sum-in[now] <= 20){
      ret+=solve(n,sum-in[now],now+1,in,veri);
    }
  }
  return ret;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,21)rep(j,N)dp[i][j]=-1;
    vector<int> in(n-1);
    int veri;
    rep(i,n-1)cin>>in[i];
    cin>>veri;
    cout << solve(n-1,0,0,in,veri) << endl;
  }
  return false;
}

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

int main () {
  string s;
  cin >> s;
  if (s.at(5) == '1') cout << "TBD" << endl;
  else if (s.at(6) > '4') cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}

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

using namespace std;

#define ll long long
#define PR pair<int, ll>

const int N = 1e6 + 5;

PR a[N];
multiset<ll> ms;

bool cmp(PR x, PR y) {
  return x.second == y.second ? x.first > y.first : x.second > y.second;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    ll x;
    scanf("%lld", &x);
    ms.insert(x);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %lld", &a[i].first, &a[i].second);
  }
  sort(a, a + m, cmp);
  ll ans = 0;
  for (int i = 0; i < m; i++) {
    int x = a[i].first;
    while (*ms.begin() < a[i].second && x > 0 && !ms.empty()) {
      ms.erase(ms.lower_bound(*ms.begin()));
      ans += a[i].second;
      x--;
    }
  }
  for (auto i : ms) {
    ans += i;
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <set>
#include <queue>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define QCLR(q) while(!q.empty()) q.pop();

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

int N,K,rx[100],ry[100],gx,gy;

class Hex
{
public:
	int px[8], py[8];
	Hex(int tpx[8], int tpy[8])
	{
		REP(i,N) 
		{
			px[i]=tpx[i];
			py[i]=tpy[i];
		}
	}

	bool operator<(const Hex& h) const
	{
		REP(i,N)
		{
			if(px[i]!=h.px[i]) return px[i]<h.px[i];
			if(py[i]!=h.py[i]) return py[i]<h.py[i];
		}
		return false;
	}
};

class State
{
public:
	Hex h;
	int c;
	State(Hex h, int c)
	:h(h),c(c)
	{}
};

set<Hex> s;
queue<State> q;

int dist60(int x1, int y1, int x2, int y2)
{
	return (abs(x1-x2)+abs(y1-y2)+abs((x1+y1)-(x2+y2)))/2;
}

bool crash(Hex& h, int p)
{
	REP(i,K) if(h.px[p]==rx[i]&&h.py[p]==ry[i]) return true;
	
	return false;
}

bool connect(Hex& h, int j)
{
	REP(i,j)
	{
		if(h.px[i]==h.px[j]&&h.py[i]==h.py[j]) return false;
		
		int cnt=0;
		REP(k,6)
		{
			int tx=h.px[i]+dx[k], ty=h.py[i]+dy[k];
			if(h.px[j]==tx&&h.py[j]==ty) 
			{
				cnt++;
				break;
			}
		}
		
		if(abs(i-j)==1&&cnt!=1) return false;
		if(abs(i-j)!=1&&cnt==1) return false;
	}
	
	return true;
}

bool create(int p, Hex& h, int c, bool sk)
{
	if(p==N) 
	{
		if(!s.count(h)) 
		{
			s.insert(h);
			q.push(State(h,c+1));
			return true;
		}
		return false;
	}
	
	int cnt=0;
	if(connect(h,p)) create(p+1,h,c,false);
	if(!sk)
	{
		REP(i,6)
		{	
			h.px[p]+=dx[i], h.py[p]+=dy[i];
			if(crash(h,p) || !connect(h,p))
			{
				h.px[p]-=dx[i], h.py[p]-=dy[i];
				continue;
			}
			
			if(create(p+1,h,c,true)) cnt++;
			h.px[p]-=dx[i], h.py[p]-=dy[i];
			
			if(p==0||p==N-1) { if(cnt==2) break; }
			else { if(cnt==1) break; }
		}
	}
	
	return false;
}

int bfs(int ix[8], int iy[8])
{
	q.push(State(Hex(ix,iy), 0));

	while(1)
	{
		State s=q.front(); q.pop();
		if(s.h.px[0]==gx&&s.h.py[0]==gy) return s.c;
		int dist=dist60(gx,gy,s.h.px[0],s.h.py[0]);
		if(dist>1) dist+=(dist-1)*2;
		if(dist60(gx,gy,s.h.px[0],s.h.py[0]) > 20-s.c) continue;
		create(0,s.h,s.c,false);
	}
	
	return 0;
}
int main()
{
	while(scanf("%d", &N),N)
	{
		QCLR(q);
		s.clear();
		int px[8], py[8];
		REP(i,N) scanf("%d %d", &px[i], &py[i]);
		
		scanf("%d", &K);
		REP(i,K) scanf("%d %d", &rx[i], &ry[i]);

		scanf("%d%d", &gx,&gy);
		printf("%d\n", bfs(px,py));
	}
}

Measured memory_bytes: 8796
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define maxi(a,b) (((a) > (b)) ? (a) : (b))

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    /********************************************************/
    string s;
    cin >> s;

    if (s.find("C") != string::npos && s.find("F") != string::npos && s.find("C") < s.rfind("F"))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    /********************************************************/
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);
    vector<ll> a(N+1);
    vector<ll> b(M+1);
    int best = 0;
    a.at(0) = 0;
    b.at(0) = 0;
    int j = M;
    int buf = 0;
    int va = 0;
    for(int i=0;i<N;i++) {
        cin >> A.at(i);
    }
    for(int i=0; i<M; i++) {
        cin >> B.at(i);
    }
    for(int i=1; i<N+1; i++) {
        a.at(i) = a.at(i-1) + A.at(i-1); 
    }
    for(int i=1; i<M+1; i++) {
        b.at(i) = b.at(i-1) + B.at(i-1);
    }
    for(int i=0;i<=N;i++) {
        if (a.at(i) > K){
            break;
        }

        best = K - a.at(i);

        while(true) {
            if (j==0) {
                break;
            }
            if (b.at(j) <= best) {
                break;
            }
            j--;
        }
        buf = max(buf,i+j);
    }
    cout << buf << endl;
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
#define minc *(c.begin())
#define maxc *(c.end()-1)
main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  vector<int> c;
  c.push_back(a[n-1]);
  for(int i=n-2;i>=0;--i){
    if(a[i]<minc)c[0]=a[i];
    else if(maxc<=a[i])c.push_back(a[i]);
    else {
      auto itr=lower_bound(c.begin(),c.end(),a[i]+1);
      int k=*itr;
      c.erase(itr);
      auto itr2=c.insert(lower_bound(c.begin(),c.end(),a[i]),a[i]);
      if(itr2==c.end()-1)maxc=*(c.end()-1);
      else if(itr2==c.begin())minc=c[0];
    }
  }
  cout<<c.size();
}


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

int main(){
  	LL a,p;
  	cin >> a >> p;
  	p += a * 3;
  	
 	cout << p/2 << endl;
  
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
      	long V = sc.nextLong();
      	long B = sc.nextLong();
      	long W = sc.nextLong();
      	long T = sc.nextLong();
        long A1 = A;
      	long B1 = B;
      	int ans = 0;
      	if(A < B) {
      	for(long i = 0;i<T;i++){
          A1 = A1 + V;
          B1 = B1 + W;
          if(A1 >= B1){ ans = 1; break;}
        }
        } else if (A > B) {
        for(long i = 0;i<T;i++){
          A1 = A1 - V;
          B1 = B1 - W;
          if(A1 <= B1){ ans = 1; break;}
        }
        } else {
          ans = 1;
        }
          
        if(ans == 1){
          System.out.println("YES");
        } else {
          System.out.println("NO");
        }
        
    }
}

Measured memory_bytes: 35764
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

const int num = 10;

int main() {
	while (1) {
		vector<vector<int>>oks(1024, vector<int>(10, 0));
		int N; cin >> N;
		if (!N)break;
		string st; cin >> st;
		vector<vector<int>>vs;
		vector<int>v;
		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (st[i] == 'u') {
				vs.emplace_back(v);
				v.clear();
			}
			else {
				v.emplace_back(st[i]-'0');
			}
		}
		for (auto v : vs) {
			if (v.empty())continue;
			bitset<10>bs;
			bs[v[0]] = true;
			oks[0][v[0]] = true;
			for (int i = 1; i < v.size(); ++i) {
				oks[bs.to_ulong()][v[i]] = true;
				if (bs[v[i]]) {
					ok = false;
				}
				else {
					bs[v[i]] = true;
				}
			}
		}
		for (int j = 0; j < 1024; ++j) {
			for (int k = 0; k < 10; ++k) {
				if (!oks[j][k])continue;
				for (int l = 0; l < 1024; ++l) {
					for (int m = 0; m < 10; ++m) {
						if ((!oks[j][k]) || (!oks[l][m]))continue;
						if (j&l)continue;
						if (!(j&(1 << m)) && (l&(1 << k)))oks[j | l][m] = true;
					}
				}
			}
		}
		for (int j = 0; j < 1024; ++j) {
			for (int k = 0; k < 10; ++k) {
				if (!oks[j][k])continue;
				for (int l = 0; l < 1024; ++l) {
					for (int m = 0; m < 10; ++m) {
						if ((!oks[j][k]) || (!oks[l][m]))continue;
						if (j&l)continue;
						if ((j&(1 << m)) && l&(1 << k)) {
							ok = false;
							break;
						}
					}
				}
			}
		}
		if (ok)cout << "SAFE" << endl;
		else cout << "UNSAFE" << endl;
	}
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = "";
        if (s.Last() == '3')
        {
            answer = "bon";
        }
        else if (s.Last() == '0' || s.Last() == '1' || s.Last() == '6' || s.Last() == '8')
        {
            answer = "pon";
        }
        else
        {
            answer = "hon";
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 26264
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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


int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(), l.end());

    ll ans = 0;
    for (int i = n-1; i >= 2; --i) {
        for (int j = i-1; j >= 1; --j) {
            int r = l[j];
            int le = l[i]-l[j]+1;
            auto itrr = upper_bound(l.begin(), l.end(),r);
            auto itrl = lower_bound(l.begin(), l.end(), le);
            if (itrl-l.begin() > j) continue;
            int tmp = (l.begin()+j)-itrl;
            ans += tmp;
        }
    }
    // print(l);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int ret = 100*a + b*10 + c;
  if(ret % 4 == 0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sorted(il(), reverse=True)

    ret = 0
    for n in range(1, N):
        ret += A[(N - n) // 2]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29280
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
const int MOD= 1e9 + 7;
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b < 24) cout << a + b << endl;
	else cout << a + b - 24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define mxn 100010
#define LL long long
using namespace std;
int n,m,sl,fh,p[mxn],fa[mxn],vis[mxn];
LL ans,a[mxn],b[mxn],s[mxn];
int t,h[mxn];
struct edge
{
	int to,nxt;
}e[mxn<<1];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
bool cmp(const int &x,const int &y) {return s[x]<s[y];}
void add(int u,int v)
{
	e[++t]=(edge){v,h[u]};h[u]=t;
	e[++t]=(edge){u,h[v]};h[v]=t;
}
int getfa(int x)
{
	if(fa[x]!=x) fa[x]=getfa(fa[x]);
	return fa[x];
}
int main()
{
	n=rd();m=rd();int x,y;
	for(int i=1;i<=n;++i)
	{
		a[i]=rd();b[i]=rd();
		s[i]=a[i]=max(0ll,a[i]-b[i]);
		fa[i]=p[i]=i;
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=m;++i) x=rd(),y=rd(),add(x,y);
	int u,v,fx,fy;
	for(int k=1;k<=n;++k)
	{
		vis[u=p[k]]=1;
		for(int i=h[u];i;i=e[i].nxt)
			if(vis[v=e[i].to])
			{
				fx=getfa(u);fy=getfa(v);
				if(fx==fy) continue;
				b[fx]+=b[fy];fa[fy]=fx;
				s[fx]=min(s[fx],s[fy]+max(0ll,a[fx]-s[fy]-b[fy]));
			}
	}
	printf("%lld\n",s[p[n]]+b[p[n]]);
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
ll x;
int main()
{
    cin >> x;
    ll res = x / 11 * 2;
    x %= 11;
    if(x == 0) {}
    else if(x <= 6) res ++;
    else res += 2;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
vector<int>edg[MAX] , vec[MAX] , rec[MAX];
int col[MAX] , sz[MAX];

void dfs(int node, int p) {
    
    int prevsz = vec[col[node]].size();
    sz[node] = 1;
    
    for(auto x : edg[node]) {
        if(x == p) continue;
        dfs(x , node);
        sz[node] += sz[x];
        
        int tmp = sz[x];
        for(int i = prevsz ; i < vec[ col[node] ].size() ; i++ ) {
            tmp -= vec[ col[node] ][i];
        }
        while(vec[col[node]].size() > prevsz) vec[col[node]].pop_back();
        
        rec[col[node]].push_back(tmp);
    }
    vec[col[node]].push_back(sz[node]);
    
}

ll get(ll n) {
    
    return (n*(n-1) )/2 + n;
}

int main()
{
    fastRead;
    int n;
    cin>>n;
    for(int i =1 ; i <=n ; i++ ) cin>>col[i];
    
    for(int i =1 ; i < n ;i++) {
        int u , v;
        cin>>u>>v;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }
    
    edg[0].push_back(1);
    
    dfs(0 , -1  );


    for(int i =1 ; i <=n ; i++ ) {
        int val = sz[1];
        for(auto x : vec[i]) val -= x;
        rec[i].push_back(val);
    }
    
    for(int i =1 ; i <=n ; i++ ) {
        ll ans = get(n);
        for(auto x : rec[i]) ans -= get(x);
        cout<<ans<<'\n';
    }
        
//    for(int i =1 ;i <=n ; i++  ) {
//        cout<<i<<" -- \n";
//        for(auto x : rec[i]) cout<<x<<" ";
//        cout<<'\n';
//    }
    return 0;
}

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

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++ )

int main()
{
  string a, b;
  cin >> a >> b;
  if(a == "H" && b == "H") cout << "H\n";
  else if(a == "H" && b == "D") cout << "D\n";
  else if(a == "D" && b == "H") cout << "D\n";
  else if(a == "D" && b == "D") cout << "H\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int max = Math.max(A-B, A+B);
		max = Math.max(max, A*B);
		System.out.println(max);
	}
}


Measured memory_bytes: 21844
import Data.Char

op "+" n0 n1 = show $ read(n0) + read(n1)
op "-" n0 n1 = show $ read(n0) - read(n1)
op "*" n0 n1 = show $ read(n0) * read(n1)

isOperator s = s == "+" || s == "-" || s == "*"

exec :: [String] -> [String]
exec (n0:n1:o:ls)
  | isOperator o = let r = op o n0 n1
                   in r:ls
  | otherwise = n0:(exec (n1:o:ls))

ans :: [String] -> Int
ans x =
  if length x == 1
  then read $ head x
  else ans $ exec x

main = do
  c <- getLine
  let i = words c
      o = ans i
  print o

Measured memory_bytes: 4084
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char str[1200];
	int i=0;

	gets(str);
	
	while(str[i]){
		if(islower(str[i]))	/*?°???????????????????*/
		str[i]=toupper(str[i]);/*?°????????????¢??????????????????????????§?????????????????????*/
		else if(isupper(str[i]))	/*??§??????????????????*/
		str[i]=tolower(str[i]);/*??§???????????¢?????????????????????????°??????????????????????*/
		i++;	
		}

		printf("%s\n",str);

	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    ll ans = 0;
    repd(i, 1, n) {
        ll diff = a[i - 1] - a[i];
        if (diff > 0) {
            ans += diff;
            a[i] += diff;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4752
#include<cstdio>
#include<cstring>
using namespace std;
char in[200005];
int n,a;
long long ans;
int main()
{
	scanf("%s",in+1);n=strlen(in+1);
	for(int i=n;i;--i) 
		if(in[i]=='W') a++;
		else ans+=a;
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

bool is_AGCT(char c) {
  if (c == 'A' || c == 'G' || c == 'C' || c == 'T') {
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;

  ll ans = 0;

  ll n = s.size();

  rep(l, n) {
    if (is_AGCT(s[l])) {
      for (int r = l; r < n; r++) {
        if (is_AGCT(s[r])) {
          chmax(ans, r - l + 1);
        } else {
          l = r;
          break;
        }
        if (r == n - 1) {
          break;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
S = list(input())
T = list(input())
ans = 1e9

for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i:len(T)+i][j] == T[j]: continue
        tmp += 1
    ans = min (ans,tmp)

print(ans)

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

void s(int& a,int& b);

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i=1;i<=n;i++)
        cin >> a[i];
    for (int i=1;i<=(n/2);i++)
        s(a[i],a[n-i+1]);
    for (int i=1;i<=n;i++)
        cout << a[i] << (i!=n?" ":"");
    cout << endl;
}

void s(int& a,int& b){
    int t;
    t=a;
    a=b;
    b=t;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int X; cin >> X;
    const int M = 1000;
    FOR(i, -M, M + 1) FOR(j, -M, M + 1){
        if(i * i * i * i * i - j * j * j * j * j == X){
            cout << i << " " << j << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
	int x1,x2,x3,x4,x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;

	int ans = 0;
	if(x1 == 0) {
		ans = 1;
	} else if(x2 == 0) {
		ans = 2;
	} else if(x3 == 0) {
		ans = 3;
	} else if(x4 == 0) {
		ans = 4;
	} else {
		ans = 5;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    char temp;
    for(int i = 0; i < s.size() - 1; i++)
    {
        for(int j = i + 1; j < s.size(); j++)
        {
            if(s[i] > s[j])
            {
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }
        }
    }
    for(int i = 0; i < t.size() - 1; i++)
    {
        for(int j = i + 1; j < t.size(); j++)
        {
            if(t[i] < t[j])
            {
                temp = t[i];
                t[i] = t[j];
                t[j] = temp;
            }
        }
    }
    if(s.compare(t) < 0)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false;
double sqrtNum = sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d=0;
    cin>>a>>b>>c;
    if((c-b)%2==0){
	d=(c-b)/2;
	b=0;
	c=0;
    }
    else{
	if((b-1)<(a-c)){
	    c-=b;
	    d=b;
	    b=1;
	}
	else{
	    b+=(a-c+1);
	    d=a-c+1;
	    c=a;
	}
	d+=(abs(b,c)/2);
    }
    cout<<d<<"\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
A = list(map(int, input().split()))

flag = 0
for i in A:
    if i % 2 == 0:
        if i % 3 != 0 and i % 10 != 0:
            flag = 1
print("DENIED" if flag == 1 else "APPROVED")


Measured memory_bytes: 2940
// AOJ 0371: Electronic Metronome
// 2017.11.14 bal4u@uu

#include <stdio.h>

int t[100002];

char buf[10], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, x, y, max, ans;

	fgets(p=buf, 10, stdin);
	n = getint();
	max = 0;
	for (i = 0; i < n; i++) {
		fgets(p=buf, 10, stdin);
		t[i] = getint();
		if (t[i] > max) max = t[i];
	}
	ans = 0;
	if (max & 1) y = max/3;
	else         y = max/2;
	for (i = 0; i < n; i++) {
		for (x = t[i]; ; x++) {
			if (x > y)     { ans += max - t[i]; break; }
			if (max % x == 0) { ans += x - t[i]; break; }
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    VL a(N);
    rep(i, 0, N) cin >> a[i];

    VVL ans(H, VL(W));
    ll now = 1, cnt = 0;
    rep(h, 0, H){
        if(h % 2 == 0){
            rep(w, 0, W){
                ans[h][w] = now;
                cnt++;
                if(cnt == a[now-1]){
                    now++;
                    cnt = 0;
                }
            }
        }else{
            for(ll w = W-1; w >= 0; w--){
                ans[h][w] = now;
                cnt++;
                if(cnt == a[now-1]){
                    now++;
                    cnt = 0;
                }
            }
        }
    }
    cerr << "hoe" << endl;
    rep(h, 0, H){
        rep(w, 0, W){
            cout << ans[h][w];
            if(w == W-1) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
//#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
const int INF=1001001001;
int H,W,N;//H=1000,W=1000,N=10000000
//?¨????????????????O(N)?????????O(H???W)?????????????????????????????¨??????
//????´????????????¨H*W??????????????????N????????????30%??§??????
//???????????°?????????????????§
//??¶???????¨??????§?????????????????????
int m[1002][1002];//0?????????1?????±
int pm[1002][1002];//??????
class WALK{
    private:
    
    public:
    pair<int,int> solve(){
        scanf("%d %d %d",&H,&W,&N);//N???????????£????????????????????°????????????
        if(H==0&&W==0&&N==0)return mp(-1,-1);
        fill(pm[0],pm[H+1],0);
        rep(i,H){
            rep(j,W){
                scanf("%d",&m[i][j]);
            }
        }
        //???????????°??????????????°??¶???????????????????????????
        rep(i,H){
            rep(j,W){
                pm[i][j]=0;
                if(i==0&&j==0){
                    pm[i][j]=N-1;
                }else if(i==0){//???????????????
                    pm[i][j]+=( m[i][j-1]==1&&(pm[i][j-1])%2 ? (pm[i][j-1])/2+1 : (pm[i][j-1])/2 );
                }else if(j==0){//???????????????
                    pm[i][j]+=( m[i-1][j]==0&&(pm[i-1][j])%2 ? (pm[i-1][j])/2+1 : (pm[i-1][j])/2 );
                }else{
                    pm[i][j]+=( m[i][j-1]==1&&(pm[i][j-1])%2 ? (pm[i][j-1])/2+1 : (pm[i][j-1])/2 );
                    pm[i][j]+=( m[i-1][j]==0&&(pm[i-1][j])%2 ? (pm[i-1][j])/2+1 : (pm[i-1][j])/2 );
                    
                }
            }
        }
        //N???????????????????????§???????????§??¢?´¢??????
        pair<int,int> ans=mp(0,0);
        while(1){
            if(ans.first==H || ans.second==W)break;
            if( ( m[ans.first][ans.second]+pm[ans.first][ans.second] )%2 ){
                ans.second++;
            }else{
                ans.first++;
            }
        }
        return ans;
    }
};
signed main(){
    while(1){
        WALK ans;
        pair<int,int> p=ans.solve();
        if(p.first==-1)break;
        printf("%d %d\n",p.first+1,p.second+1);
    }
    return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int n; cin >> n;
  multiset<int, greater<int> > s;
  int v[n];
  for(int i=0; i<n; i++){
    cin >> v[i];
    s.insert(v[i]);
  }
  for(int i=0; i<n; i++){
    s.erase(s.find(v[i]));
    cout << *s.begin() << endl;
    s.insert(v[i]);
  }
}



Measured memory_bytes: 12544