akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 3e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;

int a[maxN];
int cnt[maxN];
int b[maxN];
vector<int> v;
vector<int> s;
int m;
bool check(int x,int n,int k)
{
//	for(auto e:v)
//	{
//		if(e>x)
//		{
//			cnt += (e-x);
//		}
//	}
	int pos = upper_bound(v.begin(),v.end(),x) - v.begin();
	int cnt = (s[m]-s[pos]) - x*(m-pos);
	if((n-cnt)/k >= x)
	{
		return true;
	}
	else
		return false;
}
int main() {
	
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	v.clear();
	for(int i=1;i<=n;i++)
	{
		if(cnt[i] != 0)
		{
			v.push_back(cnt[i]);
		}
	}
	sort(v.begin(),v.end());
	m = v.size();
	s.resize(m+2);
	for(int i=1;i<=m;i++)
	{
		s[i] = s[i-1] + v[i-1];
	}
	for(int k=1;k<=n;k++)
	{
		if(v[m-1] <= n/k)
		{
			b[k] = n/k;
		}
		else
		{
			int ans = 0;
			int L = 1,R = n;
			while(L<=R)
			{
				int mid = (L+R)/2;
				if(check(mid,n,k))
				{
					ans = mid;
					L = mid+1;
				}
				else
				{
					R = mid-1;
				}
			}
			b[k] = ans;
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",b[i]);
	}
    return 0;
}

Measured memory_bytes: 6640
#include<iostream>
using namespace std;
int b[100000];
int main() {

	//C
	/*string s;
	int i;
	cin >> s;
	int k;
	if (s[0] == 'B') {
		k = 0;
	}
	else {
		k = 1;
	}
	int  counter = 0;
	for (i = 1; i < s.size(); i++) {
		if ((s[i] == 'W')&&(k == 0)) {
			k = 1;
			counter++;
		}
		if ((s[i] == 'B') && (k == 1)) {
			k = 0;
			counter++;
		}
	}

	cout << counter << endl;
	return 0;*/

	//D
	int n,t;
	cin >> n>> t;
	int i, a[100000];
	//int k = 1;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	//b[0] = -k;
	int dis;
	int min, max;
	min = a[0]; max = a[0]; dis = 0;
	int minchange = 0;
	for (i = 1; i < n; i++) {
		if (a[i] < min) {
			min = a[i];
			max = a[i];
			//minchange = 0;
		}
		if (a[i] > max) {
			max = a[i];
			if (max - min > dis)dis = max - min;
			//k++;

		}
	}
	int counter = 0;
	min = a[0]; max = a[0];
	for (i = 1; i < n; i++) {
		if (a[i] < min) {
			min = a[i];
			max = a[i];
		}
		if (a[i] > max) {
			max = a[i];
			if (max - min == dis)counter++;
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3964
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;

  char a[201];
  int i=1;
  while(i<n+1){
    char z,x;
    z=s.at(i-1);
    x=t.at(i-1);
    a[i*2-2]=z;
    a[i*2-1]=x;
    i++;
  }

  rep(j,n*2){
    cout<<a[j];
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
	long n = read.to!long;
	long a = read.to!long;
	long b = read.to!long;
	
	long ans;
	if(n == 1 && a < b) ans = 0;
	else if(a > b) ans = 0;
	else ans = (a + b * (n -1)) - (a * (n - 1) + b) + 1;
	
	ans.writeln;
	}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = [list(map(int, input().split()))[1::] for _ in range(M)]
P = list(map(int, input().split()))

answer = 0
for i in range(2 ** N):
  cnt = 0
  for j in range(M):
    tmp = 0
    for s in S[j]:
      if (i >> (s - 1)) & 1:
        tmp = 1 - tmp
    if tmp % 2 == P[j]:
      cnt += 1
  if cnt == M:
    answer += 1
    
print(answer)

Measured memory_bytes: 40688
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        for(int i = 0;i < 10;i++){
            int ans = r*x-d;
            System.out.println(ans);
            x = ans;
        }
    }
}

Measured memory_bytes: 21204
N = int(input())
P = [0] + list(map(int, input().split()))

cnt = 0
for i in range(1, N + 1):
    if i == P[i]:
        cnt += 1
        if i != N:
            P[i + 1], P[i] = P[i], P[i + 1]
        else:
            P[i - 1], P[i] = P[i], P[i - 1] 

print(cnt)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  long double a,b,x;
  cin >> a >> b >> x;
  long double ans;
  
  if(x > a*a*b/2) ans = atan(2*b/a-2*x/a/a/a)*180/M_PI;
  else if(x/2 == a*a*b) ans = 45;
  else ans = atan(a*b*b/2/x)*180/M_PI;
  
  cout << setprecision(10) << ans;
  return 0;
}

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

int main(){
    string s;
    long long K;
    cin >> s >> K;
    for(int i = 0; i < K; i++){
        if(s.at(i)=='1') continue;
        else{ 
            cout << s.at(i) << endl;
            return 0;
        }

    }
    cout << 1 << endl;
    return 0;
}

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

int main(){
  int i,j;ll cnt=0;
  int h,w,n;
  cin>>h>>w;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++)cin>>a[i];
  int c[h][w];
  i=0;j=0;
  int k=1,r=1;
  while(cnt!=h*w){
    for(int p=0;p<a[k];p++){
      c[i][j]=k;
      cnt++;
      if(r==1){
        if(j==w-1){
          r=-r;
          i++;
        }else j++;
      }else{
        if(j==0){
          r=-r;
          i++;
        }else j--;
      }
    }
    k++;
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cout<<c[i][j]<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    map<int,int> mp;
    REP(i,N){
        int a;cin>>a;
        if(mp.count(a)){
            cout<<"NO"<<endl;
            return 0;
        }
        mp[a]=i;
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
x,y,z,k = gets.split(' ')
x = x.to_i
y = y.to_i
z = z.to_i
k = k.to_i
a = gets.split(' ').map{|i|i.to_i}.sort.reverse
b = gets.split(' ').map{|i|i.to_i}.sort.reverse
c = gets.split(' ').map{|i|i.to_i}.sort.reverse

abc = Array.new
a.each_with_index do |a_item, a_index|
  if (a_index + 1)  > k
    break
  end
  b.each_with_index do |b_item, b_index|
    if (a_index + 1) * (b_index + 1) > k
      break
    end
    c.each_with_index do |c_item, c_index|
      if (a_index + 1) * (b_index + 1) * (c_index + 1) > k
        break
      end
      abc << a_item + b_item + c_item
    end
  end
end

abc = abc.sort.reverse

k.times do |k_i|
  puts abc[k_i]
end



Measured memory_bytes: 4600
import java.util.Scanner;

//AtCoder Beginner Contest 154
//E	Almost Everywhere Zero
public class Main {

	static String removeHeadZero(String N) {
		StringBuilder S = new StringBuilder();
		boolean hasNonZero = false;
		for (int i = 0; i < N.length(); i++) {
			if (!hasNonZero && N.charAt(i) - 48 != 0) {
				hasNonZero = true;
			}
			if (hasNonZero) {
				S.append(N.charAt(i));
			}
		}
		return S.toString();
	}

	static long countK1(String N) {
		String S = removeHeadZero(N);
		if (S.length() == 0) {
			return 0l;
		}
		long ans = 0;
		ans += S.charAt(0) - 48;
		ans += (S.length()-1) * 9;
		return ans;
	}

	static long countK2(String N) {
		String S = removeHeadZero(N);
		if (S.length() <= 1) {
			return 0l;
		}
 		long ans = 0;
		int first = S.charAt(0) - 48;
		StringBuilder nines = new StringBuilder();
		for (int i = 0; i < S.length()-1; i++) {
			nines.append("9");
		}
		ans += countK2(nines.toString());
		ans += (first-1) * countK1(nines.toString());
		ans += countK1(S.substring(1));
		return ans;
	}

	static long countK3(String N) {
		if (N.length() <= 2) {
			return 0l;
		}
 		long ans = 0;
		int first = N.charAt(0) - 48;
		StringBuilder nines = new StringBuilder();
		for (int i = 0; i < N.length()-1; i++) {
			nines.append("9");
		}
		ans += countK3(nines.toString());
		ans += (first-1) * countK2(nines.toString());
		ans += countK2(N.substring(1));
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int K = Integer.parseInt(sc.next());
		sc.close();

		long ans = 0;
		if (K == 1) {
			ans = countK1(N);
		}
		if (K == 2) {
			ans = countK2(N);
		}
		if (K == 3) {
			ans = countK3(N);
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 39120
#include "stdio.h"
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int R;
    cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    }
    else if(R < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool f(int x, vector<int>& v) {
    vector<int> a, b;
    a.push_back(0);
    b.push_back(0);
    for (int i : v) {
        if (i - a.back() >= x) a.push_back(i);
        else b.push_back(i);
    }

    rep(i, a.size() - 1) {
        if (a[i + 1] - a[i] < x) return false;
    }

    rep(i, b.size() - 1) {
        if (b[i + 1] - b[i] < x) return false;
    }

    return x <= (12 - a.back()) + (12 - b.back());
}

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

    vector<int> D(N);
    rep(i, N) cin >> D[i];

    sort(D.begin(), D.end());

    for (int i = 24; i >= 0; --i) {
        if (f(i, D)) {
            cout << i << endl;
            return 0;
        }
    }
}

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

#define rep(i,n) for(int i=0;i<int(n);i++)
#define MOD 1000000007

int main(){
  long int N,K;
  long int ans=0;

  cin >> N >> K;

  for(long int i=K;i<N+2;i++){
    ans+=i*(N-i+1)+1;
    //cout <<  ans << endl;
  }
  cout << ans % MOD << endl;
}


Measured memory_bytes: 3636
from sys import stdin


def main():
    n = int(stdin.readline())
    n_len = len(str(n))
    top = str(n)[0]

    ans = 0

    c = [[0 for _ in range(10)] for _ in range(10)]

    for i in range(n):
        i_str = str(i + 1)
        c[int(i_str[0])][int(i_str[-1])] += 1

    ans = 0

    for i in range(10):
        for j in range(10):
            ans += c[i][j] * c[j][i]

    print(ans)


if __name__ == "__main__":
    main()


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

//nが固定値のとき
const ll MOD = 1e9 + 7;
 
vector<long long> fact_inv, inv, Com;
 
/*  init_nCk :二項係数のための前処理
    計算量:O(k)
*/
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}


int main(){
  int x,y;
  cin>>x>>y;
  int n,r;
  bool ok = 0;
  for(int i = 0; i <= x/2; i++){
    int cnt2=i, cnt1=x-i*2;
    n = cnt1 + cnt2;
    r = cnt1;
    if(cnt2*1 + cnt1*2 == y){
      ok=1; break;
    }
  }
  if(ok){
    init_nCk(n,1000000);
    cout<<nCk(r)<<endl;
  }else cout<<0<<endl;
}


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

int a[100];

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	int ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			for(int k=j+1; k<n; k++) {
				if(a[i]+a[j] > a[k] && a[i] < a[k] && a[j] < a[k]) {
					if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

const ll MOD = 1000000000+7;

struct mint{
    ll x;
    mint(ll x):x((x%MOD+MOD)%MOD){}
    mint operator-() const{return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1; // tが１なら0を返す
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }
    mint inv() const{
        return pow(MOD-2); // 自分自身をmod-2乗
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/= a;
    }
};

mint f(ll n){
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x; 
}

mint choose(ll n, ll a){
    mint x = 1, y = 1;
    rep(i, a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}


int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = f(n) - 1 - choose(n, a) - choose(n, b);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABallDistribution solver = new ABallDistribution();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABallDistribution {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            out.println(n % k);
        }

    }
}



Measured memory_bytes: 22356
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    ans = 0
    for i in range(1,n):
        ans += (n-1)//i

    print(ans)
        

if __name__ == "__main__":
    main()

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

int main() {
    int n, k, t;
    std::cin >> n >> k;
    std::vector<int> v(n + 1);
    for (int i = 0; i < n; i++) {
        std::cin >> t;
        v[t]++;
    }
    std::sort(v.begin(), v.end());
    std::reverse(v.begin(), v.end());
    for (int j = 0; j < n + 1; j++) {
        if (v[j] == 0) {
            std::cout << 0 << std::endl;
            return 0;
        }
        k--;
        if (!k) {
            int ret = 0;
            for (int i = j + 1; i < n + 1; i++) ret += v[i];
            std::cout << ret << std::endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
	a = [int(input()) for _ in range(5)]
	last_order = 0
	min_time = 10
	for i,ai in enumerate(a):
		if(ai%10!=0 and min_time > ai%10):
			min_time = ai %10
			last_order = i

	ans = 0
	for i,ai in enumerate(a):
		if(i!=last_order and ai%10==0):
			ans += (ai//10)*10
		elif(i!=last_order):
			ans += (ai//10+1)*10
		else:
			ans += ai

	print(ans)


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

constexpr int WHITE=0;
constexpr int GRAY=1;
constexpr int BLACK=2;
constexpr int N=100;

int M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];
int n;

int next(int u){
   for(int v=nt[u]; v<n; v++){
      nt[u]=v+1;
      if(M[u][v]) return v;
   }
   return -1;
}

void dfs_visit(int r){
   for(int i=0; i<n; i++) nt[i]=0;

   stack<int> S;
   S.push(r);
   color[r]=GRAY;
   d[r]=++tt;

   while(!S.empty()){
      int u=S.top();
      int v=next(u);
      if(v!=-1){
         if(color[v]==WHITE){
            color[v]=GRAY;
            d[v]=++tt;
            S.push(v);
         }
      }
      else{
         S.pop();
         color[u]=BLACK;
         f[u]=++tt;
      }
   }
}

void dfs(){
   for(int i=0; i<n; i++){
      color[i]=WHITE;
      nt[i]=0;
   }
   tt=0;
   for(int u=0; u<n; u++){
      if(color[u]==WHITE) dfs_visit(u);
   }
   for(int i=0; i<n; i++){
      cout << i+1 << " " << d[i] << " " << f[i] << endl;
   }
}

int main(){
   int u, k, v;
   cin >> n;
   for(int i=0; i<n; i++){
      for(int j=0; j<n; j++) M[i][j]=0;
   }

   for(int i=0; i<n; i++){
      cin >> u >> k;
      u--;
      for(int j=0; j<k; j++){
         cin >> v;
         v--;
         M[u][v]=1;
      }
   }

   dfs();

   return 0;
}


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

template <typename T>
T _min(
  const T & lhs
  , const T & rhs
)
{
  return ((lhs < rhs) ? lhs : rhs);
}

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << _min(A, B) + _min(C, D);
  return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

string s;
ll n[2];

void init()
{
}

void solve()
{
    REPR(i, s.size()-1){
        int idx = s[i] - '0';
        n[idx]++;
    }
    cout << 2*min(n[0], n[1]) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[2][100],s=0,b,i,j,maxx=0;
	scanf("%d",&n);
	for(i=0;i<2;i++)
		for(j=0;j<n;j++)
			scanf("%d",&a[i][j]); 
	for(i=0;i<n;i++)
	{
		for(j=0;j<=i;j++)
			s+=a[0][j];
		for(j=i;j<n;j++)
			s+=a[1][j];
		maxx=max(maxx,s);
		s=0;
	}
	printf("%d",maxx);
	return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N + 1);
  for (int64_t i = 0; i <= N; ++i) {
    cin >> A[i];
  }
  vector<Pair> range(N + 1);
  range[N].first = A[N];
  range[N].second = A[N];
  for (int64_t depth = N - 1; depth >= 0; --depth) {
    range[depth].first = A[depth] + range[depth + 1].first / 2 + (range[depth + 1].first % 2);
    range[depth].second = A[depth] + range[depth + 1].second;
  }
  if (range[0].first > 1 || range[0].second < 1) {
    cout << -1 << endl;
    return 0;
  }

  vector<int64_t> number_of_nodes(N + 1, 0);
  number_of_nodes[0] = 1;
  int64_t result = number_of_nodes[0];
  for (int64_t depth = 1; depth <= N; ++depth) {
    number_of_nodes[depth] = min(range[depth].second, (number_of_nodes[depth - 1] - A[depth - 1]) * 2);
    result += number_of_nodes[depth];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6284
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	cin >> n;

	vector<string>s(n);

	REP(i, n) cin >> s[i];

	map<string, int>mp;

	for (int i = 0; i < n; i++) {
		mp[s[i]]++;
	}

	int maxv = 0;
	for (auto i : mp) {
		maxv = max(maxv, i.second);
	}

	vector<string>ans;

	for (auto i : mp) {
		if (i.second == maxv) {
			ans.push_back(i.first);
		}
	}

	SORT(ans);

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 28404
s = list(input())
a = set(s)
if len(a) == 2:
    s1 = s[0]
    s.remove(s1)
    if s1 in s:
        s.remove(s1)
        if s1 in s:
            print("No")
        else:
            print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define MOD 1000000007

long long int conbNum[4001][4001] = {};

void initConb(int n)
{
    conbNum[0][0] = 1;
    for(int i = 0; i < n+1; ++i)
    {
        for(int j = 0; j < n+1; ++j)
        {
            conbNum[i+1][j] += conbNum[i][j];
            conbNum[i+1][j] = conbNum[i+1][j] % MOD;
            conbNum[i+1][j+1] += conbNum[i][j];
            conbNum[i+1][j+1] = conbNum[i+1][j+1] % MOD;
        }
    }
}

long long int conb(int a, int b)
{
    return conbNum[a][b];
}

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

    int red = n - k;
    int blue = k;
    initConb(n);

    long long int ans = 0;
    for(int i = 1; i <= k; ++i)
    {
        // 赤の間(両端込み)から青の塊を突っ込む場所を i 個選ぶパターン数
        long long int num1 = conb(red+1, i);
        // 青の塊を i 個に分けるパターン数 = 青の間(両端なし)に仕切り i-1 個入れるパターン数
        long long int num2 = conb(blue - 1, i-1);
        // 両方を掛け合わせて i 回で取り出せるパターン数
        ans = (num1 * num2) % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 62976
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    cout<<n/3<<endl;

    return 0;
}


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

using namespace std;
string s,t;
int n,m;
int p1[1000005];
int p2[1000005];
int q;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    cin>>t;
    n=s.size();
    s=" "+s;
    m=t.size();
    t=" "+t;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='A') p1[i]=p1[i-1]+1;
        else p1[i]=p1[i-1]-1;
    }
    for (int i=1;i<=m;i++)
    {
        if (t[i]=='A') p2[i]=p2[i-1]+1;
        else p2[i]=p2[i-1]-1;
    }
    cin>>q;
    while (q--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int s1=p1[b]-p1[a-1];
        int t1=p2[d]-p2[c-1];
        if (s1<0) s1=3-(abs(s1)%3);
        else s1=s1%3;
        s1%=3;
        if (t1<0) t1=3-(abs(t1)%3);
        else t1=t1%3;
        t1%=3;
        //cout<<s1<< " "<<t1<<'\n';
        if (s1==t1) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
    }
    return 0;
}


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

from collections import deque

import bisect
n = int(input())

a = [int(input()) for i in range(n)]

#color = [a[0]]

d = deque()
d.appendleft(a[0])

for i in range(1,n):
    idx = bisect.bisect_left(d,a[i])
    if idx == 0:
        d.appendleft(a[i])
    else:
        d[idx-1] = a[i]
        
print(len(d))

Measured memory_bytes: 46940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    vector<double> p(n);
    rep(i,n) {
        int p_; cin >> p_;
        int sum = 0;
        REP(i,p_+1) sum += i;
        p[i] = (double)sum/p_;
    }
    double sum = 0;
    rep(i,k) sum += p[i];
    double ans = sum;
    for (int i = 1; i <= n-k; i++) {
        sum = sum - p[i-1] + p[i+k-1];
        ans = max(ans,sum);
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc152/submissions/9619555

import numpy as np
import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append((b, i))
    graph[b].append((a, i))

M = int(readline())


def get_path(U, V):
    visited = [False] * (N + 1)
    pred = [None] * (N + 1)
    stack = [U]
    visited[U] = True
    while stack:
        v = stack.pop()
        for w, i in graph[v]:
            if visited[w]:
                continue
            visited[w] = True
            pred[w] = (v, i)
            stack.append(w)
    path = 0
    w = V
    while w != U:
        v, i = pred[w]
        w = v
        path += 1 << i
    return path


condition_path = []
for i in range(M):
    u, v = map(int, readline().split())
    condition_path.append(get_path(u, v))


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


sgn = np.where(popcnt(np.arange(1 << M)) % 2, -1, 1)
S = np.zeros(1 << M, np.int64)
for i in range(M):
    S[1 << i:1 << (i + 1)] = S[:1 << i] | condition_path[i]


n_edges = popcnt(S)
x = 1 << (N - 1 - n_edges)
answer = np.sum(x * sgn)
print(answer)


Measured memory_bytes: 62660
N, X, M = map(int, input().split())
A = X
P = set([A])
cnt, cnt2 = -1, -1
S = A
S2 = 0
off = -1
for i in range(N-1):
    A = A**2%M
    if A in P and cnt == -1:
        cnt = i
        off = A
    elif A ==off:
        cnt2 = i
        break
    S += A
    if cnt != -1:
        S2 += A
    P.add(A)
l = max(cnt2-cnt,1)
if cnt2==-1:
    res = S
else:
    res = 0
    for i in range((N-cnt-1)%l):
        res += off
        off = off**2%M
    res += S + ((N-cnt2-1)//l)*S2
print(res)
"""
9 4 7
"""


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  map<int, ll> mp;
  rep(i, n) {
    int a, b; cin >> a >> b;
    mp[a] += b;
  }
  ll sum = 0;
  for(auto x : mp) {
    sum += x.second;
    if(sum >= k) {
      cout << x.first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4224
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N):
  j = A[i] - 1
  B[j] += 1
C = [ B[i]*(B[i] - 1)/2 for i in range(N) ]
S = sum(C)
for i in range(N):
  j = A[i] - 1
  ans = S - B[j] + 1
  print(int(ans))

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

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

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    int a[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    qsort(a, sizeof(a) / sizeof(int), sizeof(int), asc);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        x -= a[i];
        if (x < 0) {
            break;
        } else {
            ans++;
        }
    }
    if (x > 0) {
        ans--;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int x, y;
    cin >> x >> y;
    bool ok = false;
    for (int i = 0; i <= x; i++)
        if (i * 2 + (x - i) * 4 == y) ok = true;
    if (ok) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 3652
#include "cstdio"

int main(){
char op;
int a,b,ans;
while(1){
scanf("%d  %c %d",&a,&op,&b);
if(op == '?') break;
switch(op){
case '+':
ans = a+b;
break;

case '-':
ans = a-b;
break;

case '*':
ans = a*b;
break;

case '/':
ans = a/b;
break;
}
printf("%d\n",ans);
}
}

Measured memory_bytes: 2608
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#define INF (1e9)
#define se second
#define f first
#define N 505
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
int dijkstra();
int w,h,n,sy,sx,gy,gx,ay,ax,t,c[4][N][N],d[N][N];
 
int main(){
  string s;
  cin>>w>>h>>n;
  cin>>sx>>sy>>gx>>gy;
  while(n--){
    cin>>ax>>ay;
    cin>>t>>s;
    string a=s;
    while(--t) s+=a;
    for(int i=0;i<s.size();i++){
      if(s[i]=='L'&&ax!=0) c[3][ay][ax]++,c[1][ay+1][ax]++,ax--;
      if(s[i]=='U'&&ay!=0) c[2][ay][ax]++,c[0][ay][ax+1]++,ay--;
      if(s[i]=='R'&&ax!=w-1) c[1][ay+1][ax+1]++,c[3][ay][ax+1]++,ax++;
      if(s[i]=='D'&&ay!=h-1) c[0][ay+1][ax+1]++,c[2][ay+1][ax]++,ay++;
    }
  }
  cout<<dijkstra()<<endl;
  return 0;
}
 
int dijkstra(){
  priority_queue<P1,vector<P1>,greater<P1> > q;
  int dy[4]={0,-1,0,1},dx[4]={-1,0,1,0};
  for(int i=0;i<=h;i++)
    for(int j=0;j<=w;j++) d[i][j]=INF;
  for(int i=0;i<4;i++) d[sy][sx]=0,q.push(P1(0,P(sy,sx)));
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    int cost=t.f,y=t.se.f,x=t.se.se;
    if(d[y][x]<cost) continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i],co=c[i][y][x];
      if(ny<0||nx<0||h<ny||w<nx) continue;
      if(d[ny][nx]>cost+co){
    d[ny][nx]=cost+co;
    q.push(P1(cost+co,P(ny,nx)));
      }
    }
  }
  return d[gy][gx];
}

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

double dist(int xi, int yi, int xj, int yj) {
    return sqrt((xi - xj) * (xi - xj) + (yi - yj) * (yi - yj));
}

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

    vector< pair<int, int> > xy(n);
    for(int i = 0; i < n; i++) cin >> xy[i].first >> xy[i].second;
    sort(xy.begin(), xy.end());

    int num = 1;
    for(int i = n; i > 0; i--) num *= i;

    vector<double> dist_list(0);
    do {
        // for(auto v : xy) cout << "(" << v.first << ", " << v.second << ") ";
        // cout << endl;

        double d = 0;
        for(int i = 0; i < n - 1; i++) {
            d += dist(xy[i].first, xy[i].second, xy[i + 1].first, xy[i + 1].second);
        }
        dist_list.push_back(d);
    } while(next_permutation(xy.begin(), xy.end()));

    double ans = accumulate(dist_list.begin(), dist_list.end(), 0.0);
    ans /= num;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  ll a, b, c;
  cin >> a >> b >> c;
  ll k;
  cin >> k;
  ll ans = 0;
  if (k <= a) {
    ans = k;
  } else if (k <= a + b) {
    ans = a;
  } else {
    ans = a + (-1) * (k - (a + b));
  }

  cout << ans << endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	if (a > b)
		swap(a, b);
	if (a == b)
		cout << 0;
	else
		if ((b + a) % 2)
			cout << "IMPOSSIBLE";
		else
			cout << (b + a) / 2;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3 , "Ofast" , "inline")

#include <bits/stdc++.h>

#define rep(i , a , b) for(register int i=(a);i<=(b);i++)
#define per(i , a , b) for(register int i=(a);i>=(b);i--)


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int> pi;

template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}

const int maxn = 2e5 + 10;
const int inf = int (1e9);
const ll INF = ll (1e18);
const double PI = acos (- 1);
const int mod = 998244353;
const double eps = 1e-8;

int n;
ll k;
ll cnt[65];
ll c[maxn];

ll qpow(ll a,ll b) {
    ll ans = 1;
    while (b) {
        if(b&1) ans=ans*a;
        a=a*a;
        b>>=1;
    }
    return ans;
}
int main () {
    read (n);
    read (k);
    rep (i,1,n) {
        read (c[i]);
    }
    rep (i,0,60) {
        rep (j,1,n) {
            if((c[j]>>i)&1) {
                cnt[i]++;
            }
        }
    }
    ll ans = 0,res = 0;
    per (i, 60 , 0) {
        if((res|(1ll<<i))>k) {
            ans=ans+1ll*cnt[i]*qpow (2,i);
        }
        else {
            ans=ans+1ll*max (cnt[i],n-cnt[i])*qpow (2,i);
            if(n-cnt[i]>cnt[i]) res+=qpow (2,i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int A,B,C,K;
  cin >> A >> B >> C;
  cin >> K;
  int a,b;
  if( A>B )
    {
      if( A>C )
	{
	  a = A;
	  b = B+C;
	}
      else
	{
	  a = C;
	  b = A+B;
	}
    }
  else
    {
      if( B>C )
	{
	  a = B;
	  b = A+C;
	}
      else
	{
	  a = C;
	  b = A+B;
	}
    }
  while(K>0)
    {
      a *= 2;
      K--;
    }
  cout << a+b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
const ll MX = 1e14;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    if(a[0]==1){
        rep(i,n){
            if(a[i+1]>0){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << 1 << endl;
        return 0;
    }

    ll bound = 1;
    bool ok = true;
    rep(i,n+1){
        if(bound < a[i]){
            ok = false;
            break;
        }
        else{
            if(i==0){
                bound *= 2;
            }else{
                bound -= a[i];
                bound *= 2;
            }
        }
        if(bound >= MX) bound = MX;
        //cout << bound << " " ;
    }

    if(!ok){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> cumsum(n+1,0);
    for(int i=n;i>=0;i--){
        if(i==n) cumsum[i] = a[i];
        else cumsum[i] = a[i] + cumsum[i+1];
    }

    /*
    rep(i,n+1){
        cout << cumsum[i] << endl;
    }
    */

    ll ans = 1;
    ll now = 1;
    rep(i,n){
        if(cumsum[i+1] >= 2 * now){
            ans += 2 * now;
            now = 2 * now - a[i+1];
        }else{
            ans += cumsum[i+1];
            now = cumsum[i+1] - a[i+1];
        }  
        //cout << now <<  "  " << ans << endl; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{
ll n;
cin >> n;
string s;
cin >> s;
ll k;
cin >> k;
char a=s[k-1];
rep(i,n){
    if(a!=s[i])s[i]='*';
}


cout << s << endl;
return 0;
}








Measured memory_bytes: 256
import copy
n,ma,mb=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(n)]
l=10*n
inf=float("inf")
data=[[inf]*(l+1) for i in range(l+1)]
data[0][0]=0
for u in abc:
    a,b,c=u
    h=copy.deepcopy(data)
    for i in range(l-a+1):
        for j in range(l-b+1):
            if data[i][j]!=inf:
                h[i+a][j+b]=min(h[i+a][j+b],data[i][j]+c)
    data=h
k=1
ans=inf
while ma*k<=l and mb*k<=l:
    if data[ma*k][mb*k]!=inf:
        ans=min(ans,data[ma*k][mb*k])
    k+=1
if ans!=inf:
    print(ans)
else:
    print(-1)

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

int main()
{
  fastio;
  int n, k; cin >> n >> k;
  cout << (500 * n >= k ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;i++)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
#define debug(x)            cout<<#x<<'='<<(x)<<endl;
#define MOD (int)(1e9 + 7)
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    string s;
    cin>>s;
    int n=(int)s.size();
    int dp[n+1][13]={ { 0 } };
    dp[0][0]=1;
    f(i,n)
    {
        f(j,10)
        {
            int cur=s[i]-'0';
            if(s[i]=='?')
            {
                cur=j;
                
            }
            f(k,13)
            {
                int rem=(k*10+cur)%13;
                dp[i+1][rem]+=dp[i][k];
                dp[i+1][rem]%=MOD;
            }
            if(s[i]!='?')break;
        }
    }
    print(dp[n][5])
    
    
    
    return 0;
}

Measured memory_bytes: 13900
s=input()
t=input()
from bisect import bisect
points=[[]for i in range(26)]
a=ord("a")
for i,c in enumerate(s):
    points[ord(c)-a].append(i)
for p in points:
    p.append(10**9)

n=len(s)
idx=-1
stage=0
for c in t:
    c=ord(c)-a
    p=points[c]
    if len(p)==1:
        stage=0
        idx=-2
        break
    idx = p[bisect(p,idx)]
    if idx>10**6:
        idx=p[0]
        stage+=1
print(stage*n+idx+1)

Measured memory_bytes: 45808
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define il inline
#define rg register
#define gi read<int>
using namespace std;
const int O = 2e5 + 10, N = 1e6 + 10;
typedef long long ll;
template<class TT>
il TT read() {
	TT o = 0,fl = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-') ch = getchar();
	if (ch == '-') fl = -1, ch = getchar();
	while (isdigit(ch)) o = o * 10 + ch - '0', ch = getchar();
	return fl * o;
}
ll k, kk, l = 1, r, a[O], f[O], b[O], cnt[N], ans;
int n;
il bool check (ll x) {
    ll res = 0; memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; ++i) b[i] = x / f[i], ++cnt[b[i] >= N ? (N - 1) : b[i]];
    for (int i = 0, j = 0; i < N; ++i) while (cnt[i]) b[j] = i, --cnt[i];
    for (int i = 1; i <= n; ++i) res += max(0ll, a[i] - b[i]);
    return res <= k;
}
int main() {
    n = gi(), k = read<ll>();
    for (int i = 1; i <= n; ++i) a[i] = read<ll>(), kk += a[i];
    for (int i = 1; i <= n; ++i) f[i] = read<ll>();
    if (kk <= k) return puts("0") & 0;
    sort(f + 1, f + n + 1);
    sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) r = max(r, a[i] * f[i]);
    while (l <= r) {
        ll mid = l + r >> 1;
        if (check(mid)) r = mid - 1, ans = mid;
        else l = mid + 1;
    }
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string o, e;

    in >> o >> e;

    REP(i, o.size()){
        out << o[i];
        if(i < e.size()) out << e[i];
    }
    out << endl;
}


Measured memory_bytes: 256