akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long n, m;

// GCD ユークリッドの互除法バージョン
long long GCD(long long a, long long b) {
    if(b == 0) return a;
    else return GCD(b, a%b);
}

//LCM（GCDとの併用前提）
long long lcm(long long a, long long b) {
    long long g = GCD(a, b);
    long long l = a * (b / g);
    return l;
}

int main() {
    cin >> n >> m;
    vector<long long> ca(n, 0);
    vector<long long> cca;
    for(int i = 0; i < n; ++i) cin >> ca.at(i);
    sort(ca.begin(), ca.end());
    ca.erase(unique(ca.begin(), ca.end()), ca.end());
    int alen = ca.size();

    bool even = true;
    for(int i = 0; i < alen; ++i) {
        cca.push_back(ca.at(i)/2);
    }
    while(even) {
        for(int i = 0; i < alen; ++i) ca.at(i) /= 2;
        for(int i = 0; i < alen; ++i) {
            if(ca.at(i) % 2 != 0) {
                even = false;
                break;
            }
        }
    }

    bool flg = true;
    for(int i = 0; i < alen; ++i) {
        if(ca.at(i) % 2 == 0) {
            flg = false;
            break;
        }
    }
    

    long long ans = 0;
    if(flg) {
        long long total = 1;
        for(int i = 0; i < alen; ++i) {
            total = lcm(total, cca.at(i));
        }
        ans = m / total;
        ans = (ans+1)/2;
    }

    cout << ans << endl;
}

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int q=Math.max(a,b);
		int p=Math.min(a,b);
		if(p==1 && q==3)
		System.out.println("2");
		else if(p==2 && q==3)
		System.out.println("1");
	    else if(p==1 && q==2)
	    System.out.println("3");
	}}

Measured memory_bytes: 23508
import sys
import math
import itertools
import collections
from collections import deque
 
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
 
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
 
def main():
    N = NI()
    A = NLI()
    cA = collections.Counter(A)
    
    sortedA = sorted(list(cA.items()))
    
    if N % 2 == 1:
        if sortedA[0] != (0,1):
            print(0)
            sys.exit()
        
        ans = 1
        for n in range(1,len(sortedA)):
            if sortedA[n] != (n*2 , 2):
                print(0)
                sys.exit()
            ans = ans * 2 % MOD
                
        print(ans)
        
        
    else:
        ans = 1
        for n in range(len(sortedA)):
            if sortedA[n] != tuple([n*2+1 , 2]):
                print(0)
                sys.exit()
            ans = ans * 2 % MOD
                
        print(ans)
    
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 20936
#include <stdio.h>
int main(void)
{
	int A, B, max=0;

	scanf("%d", &A);
	scanf("%d", &B);

	if (A + B > A - B)
		max = A + B;

	else
		max = A - B;

	if (A*B > max)
		max = A * B;

	printf("%d", max);

	rewind(stdin);
	getchar();
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long ll;
int main()
{
    string s,s1,s2;
    cin>>s;
    s2=s;
    int flag=0,len=s.length();
    s1=s;
    reverse(s.begin(),s.end());
    if(s!=s1)
        flag=1;
    s=s2.substr(0,(len-1)/2);
    s1=s;
    reverse(s.begin(),s.end());
    if(s!=s1)
        flag=1;
    s=s2.substr((len+3)/2-1,len-(len+3)/2+1);
    s1=s;
    reverse(s.begin(),s.end());
    if(s!=s1)
        flag=1;
        if(flag)
            cout<<"No";
        else
            cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
a,b,c,d = map(float,input().split())
a = complex(a,b)
b = complex(c,d)
for _ in range(int(input())):
    c = complex(*map(float,input().split()))
    q = b-a
    c-=a
    p = a+ q*((c/q).conjugate())
    print(p.real,p.imag)


Measured memory_bytes: 5632
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007

using namespace std;

char S[1001];

int main()
{
    int N, i, D1, D2, doublet;
    bool checked;

    scanf("%d", &N);

    checked = false;
    doublet = 0;

    while(N--){
        scanf("%d%d", &D1, &D2);
        if(D1 == D2)
            ++doublet;
        else
            doublet = 0;
        if(doublet == 3)
            checked = true;
    }

    printf(checked ? "Yes" : "No");

    return 0;
}


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

int M[200][200];
string color[200];
queue<int> q;
int d[200];
int n;
const int INF = 1001001001;

void bfs(int s){
    rep(i, n){
        color[i] = "WHITE";
        d[i] = -1;
    }

    color[s] = "GRAY";
    d[s] = 0;
    q.push(s);
    while(!q.empty()){
        int u = q.front(); q.pop();
        for (int i = 0; i <= n; i++){
            if(M[u][i] && color[i] == "WHITE"){
                color[i] = "GRAY";
                d[i] = d[u] + 1;
                q.push(i);
            }
        }
        color[u] = "BLACK";
    }
}

int main() {
    cin >> n;
    rep(i, n){
        int a, b; cin >> a >> b;
        rep(j, b){
            int x; cin >> x;
            x--;
            M[i][x] = 1;
        }
    }
    bfs(0);
    rep(i, n){
        cout << i+1 << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3252
import sys
input = sys.stdin.readline
N, C, K = map(int, input().split())
res = 1
t = []
for _ in range(N):
  t.append(int(input()))
t.sort()
x = t.pop()
c = 1
for i in range(N - 1):
  y = t.pop()
  if abs(x - y) > K or (c >= C):
    res += 1
    x = y
    c = 0
  c += 1
print(res)

Measured memory_bytes: 43740
#include <bits/stdc++.h>
using namespace std;
int main() {
 int n;
  cin >> n;
  vector<char> vec(n);
    for (int i = 0; i < n; i++) {
      cin >> vec.at(i);
    }
  int count = 0;
  for (int i = 0; i < n - 2; i++) {
  if (vec.at(i) == 'A' && vec.at(i+1) == 'B' && vec.at(i+2) == 'C') {
    count++;
  }
  }
  cout << count << endl;
  }

Measured memory_bytes: 256
#include <cstdio>

#define maxn 666
int ecnt;
struct edge {
	int a, b, w;
} e[maxn];
inline void link(int a, int b, int w)
{
	e[++ecnt] = (edge) {a, b, w};
}
int main()
{
	int l; scanf("%d", &l);
	int len = 0;
	for (int tmp = l; tmp; tmp >>= 1, ++len) ;
	int pw = 1;
	for (int i = len; i > 1; --i)
	{
		link(i - 1, i, 0);
		link(i - 1, i, pw);
		pw <<= 1;
	}
	pw = 1 << (len - 1);
	l -= pw;
	for (; l; )
	{
		int now = 32 - __builtin_clz(l);
		link(1, len - now + 1, pw);
		pw += 1 << (now - 1);
		l -= 1 << (now - 1);
	}
	printf("%d %d\n", len, ecnt);
	for (int i = 1; i <= ecnt; ++i) printf("%d %d %d\n", e[i].a, e[i].b, e[i].w);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")


#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

void solve() {
	int n; cin >> n ;
	set<string> s;
	rep(i,0,n) {
		string str; cin >> str;
		s.ins(str);
	}
	cout << sz(s) ;
}

signed main() {


    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 19284
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int n = s.size();
    int flag=1;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]) flag = 0;
    }
    if(flag) cout << "Good" << endl;
    else cout << "Bad" << endl;
}


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

int main() {
  int h, w, m;
  cin >> h >> w >> m;
  map<pair<int, int>, int> obj;
  vector<int> vx(h), vy(w);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    obj[make_pair(x, y)]++;
    vx.at(x)++;
    vy.at(y)++;
  }
  
  int vxmax = 0, vymax = 0;
  for (int i = 0; i < h; i++) {
    vxmax = max(vxmax, vx.at(i));
  }
  for (int i = 0; i < w; i++) {
    vymax = max(vymax, vy.at(i));
  }
  
  vector<int> vx_i, vy_i;
  int64_t vxcount = 0, vycount = 0;
  for (int i = 0; i < h; i++) {
    if (vx.at(i) == vxmax) {
      vxcount++;
      vx_i.push_back(i);
    }
  }
  for (int i = 0; i < w; i++) {
    if (vy.at(i) == vymax) {
      vycount++;
      vy_i.push_back(i);
    }
  }
    
  if (vxcount * vycount > m) {
    cout << vxmax + vymax << endl;
    return 0;
  }
  
  for (int i : vx_i) {
    for (int j : vy_i) {
      if (obj[make_pair(i, j)] == 0) {
        cout << vxmax + vymax << endl;
        return 0;
      }
    }
  }
  
  cout << vxmax + vymax - 1 << endl;
}


Measured memory_bytes: 28524
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

// Nの桁数
int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll a,b;cin>>a>>b;
    ll g = GCD(a,b);
    // cout<<g<<endl;
    const auto &pf = prime_factorize(g);
    // for (auto p:pf) cout<<p.first<<" "<<p.second<<endl;
    cout<<pf.size()+1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int days = sc.nextInt();
    int[][] input = new int[days][3];
    for (int i = 0; i < days; i++) {
      input[i][0] = sc.nextInt();
      input[i][1] = sc.nextInt();
      input[i][2] = sc.nextInt();
    }
    for (int j = 1; j < days; j++) {
      input[j][0] += Math.max(input[j - 1][1], input[j - 1][2]);
      input[j][1] += Math.max(input[j - 1][0], input[j - 1][2]);
      input[j][2] += Math.max(input[j - 1][0], input[j - 1][1]);
    }
    System.out
        .print(Math.max(Math.max(input[days - 1][0], input[days - 1][1]), input[days - 1][2]));
    sc.close();
  }
}

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

int main()
{
    int N;
    cin >> N;
    
    if (N < 10){
        cout << N << endl;
    }
    if( (N>=10) && (N < 100)){
        cout << 9 << endl;
    }
    if( (N>=100) && (N < 1000)){
        cout << N - 100 + 1 + 9 << endl;
    }
    if( (N>=1000) && (N < 10000)){
        cout << 909 << endl;
    }
    if( (N>=10000) && (N < 100000)){
        cout << N - 10000 + 1 + 909 << endl;
    }
    if( N == 100000){
        cout << 90909 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def countboth(s1,s2): #len(s1)<len(s2)だと早い
    count = 0
    alph = 'abcdefghijklmnopqrstuvwxyz'
    if len(s1)*len(s2) == 0:
        return 0
    
    for a in alph:
        if a in s1 and a in s2:
            count += 1
    return count

n = int(input())
s = input()
cmax = 0
i = 1
while i < n-1:
    if i < (n/2):
        s1, s2 = s[:i],s[i:]
    else:
        s2, s1 = s[:i],s[i:]
    cmax = max(countboth(s1,s2), cmax)
    i += 1
print(cmax)

Measured memory_bytes: 3064
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int R = sc.nextInt();
        int S = sc.nextInt();
        int P = sc.nextInt();
        String T = sc.next();

        int ans = 0;
        /*T = T.replace("r","P").replace("p","S").replace("s","R");
        System.out.println(T);

        for(int i=0; i<T.length(); i++) {

            if(T.charAt(i) == 'R'){
                if(i >= K && T.charAt(i - K) == 'R') 
                    continue;
                ans += R;
            } 
            else if(T.charAt(i) == 'S') {
                if(i >= K && T.charAt(i - K) == 'S') 
                    continue;
                ans += S;
            } 
            else if(T.charAt(i) == 'P') {
                if(i >= K && T.charAt(i - K) == 'P') 
                    continue;
                ans += P;
            }
        }
        */

        boolean[] win = new boolean[N];
        for(int i = 0; i<N; i++) {
            //最初に例外処理をすることでTの範囲外のExceptionを防ぐ
            //win[i - k]は連続で手がカウントできなくなることを防ぐ
            if(i >= K && win[i - K] && T.charAt(i) == T.charAt(i - K))
                continue;
            else {
                win[i] = true;
            }
            switch (T.charAt(i)) {
            case 'r':
                ans += P;
                break;
            case 's':
                ans += R;
                break;
            case 'p':
                ans += S;
                break;
            }
            
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 28080
# https://atcoder.jp/contests/abc147/tasks/abc147_c
# ビット全探索を自作ライブラリでやり直し
# 仮定している不親切な人と、実際に証言で言及されている不親切な人が一致するなかで最大の正直者の場合が答え
# 具体的には、仮定をおく→正直ものの証言を集める→仮定に反する証言がある場合は矛盾
# 矛盾するときは無視、矛盾しないときの人数を記録していく。


def iter_p_adic(p, length):
    '''
    連続して増加するp進数をリストとして返す。lengthはリストの長さ
    return
    ----------
    所望のp進数リストを次々返してくれるiterator
    '''
    from itertools import product
    tmp = [range(p)] * length
    return product(*tmp)


import sys
read = sys.stdin.readline


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


N = read_a_int()
objection = []
for _ in range(N):
    a = read_a_int()
    hatugenn = read_tuple(a)
    objection.append(hatugenn)


def is_ok(katei):
    # 正直もの ==1であるlist kateiから、矛盾するかしないかを返す
    syoujiki = set()  # 仮定した正直者の集合
    for i, k in enumerate(katei):
        if k == 1:
            syoujiki.add(i)
    for s in syoujiki:
        # 発言の収集
        for x, y in objection[s]:
            x -= 1  # 0based-index
            if y == 0:
                if x in syoujiki:
                    return False  # 不親切な人と言われ仮定と矛盾
            else:
                if x not in syoujiki:
                    return False  # 正直者と発言しているが、仮定は正直者ではないとしていて矛盾
    return True


ans = 0
for katei in iter_p_adic(2, N):
    # bit全探索
    if is_ok(katei):
        ans = max(ans, sum(katei))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=__gcd(i,__gcd(j,k));
				}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<stdio.h>
#define mod 1000000007
using namespace std;
int mincosttogo(int a[],int memo[],int st,int end,int k)
{
  if(st>end)
    return 0;
  if(st==end)
  	return a[0];
  if(memo[end]!=-1)
  	return memo[end];
  // if(st==end)
  // 	return a[0];
  // if(memo[end]!=-1)
  //   return memo[end];
  int temp1=INT_MAX,temp2=INT_MAX;
 // if(end>=1)
    for(int i=1;i<=k;i++)
    {
      if(end -i>=0)
      temp2=mincosttogo(a,memo,st,end-i,k)+a[end];
      temp1=min(temp1,temp2);
    }
 
  return memo[end]=temp1;
}
int main()
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	// int t;
	// scanf("%d",&t);
	// while(t--)
	// {
		
     
    
 //     }
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	long long height=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			height+=a[i-1]-a[i];
			a[i]+=a[i-1]-a[i];
		}
	}
	
    cout << height << endl;
}

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int[] c = new int[n];
        int[] t = new int[n];
        for (int i = 0; i < n ; i++) {
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }
        int min = 100000;
        for (int i = 0; i < n ; i++) {
            if (t[i] <= T) {
                min = Math.min(c[i], min);
            }
        }
        if (min == 100000) {
            System.out.println("TLE");
        } else {
            System.out.println(min);
        }

    }

}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = Long.parseLong(sc.next());
		long V = Long.parseLong(sc.next());
		long B = Long.parseLong(sc.next());
		long W = Long.parseLong(sc.next());
		long T = Long.parseLong(sc.next());
		sc.close();
 
		if(V > W) {
			long diff = V - W;
			long distance = Math.abs(A - B);
			if(distance <= diff * T) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35472
/*************************************************************************
  > File Name: f.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Sat Apr  4 22:42:40 2020
*************************************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int check(ll n, ll i) {
    while (n % i == 0)
        n /= i;
    return n % i == 1;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, n1;
    cin >> n;
    n1 = n - 1;
    ll ans = 0;
    for (ll i = 1; i * i <= n1; i++) {
        if (n1 % i == 0) {
            if (i > 1)
                ans++;
            if (n1 / i != i)
                ans++;
        }
    }
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (i > 1)
                ans += check(n, i);
            if (n / i != i)
                ans += check(n, n / i);
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    char c;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
    	cin >> c;
    	if(c == 'W')
    		v[i] =  1;
    	else
    		v[i] = 0;
    }

    int left = 0, right = n - 1;
    int ans = 0;

    while(left < right) {
    	if(v[left] == 1 && v[right] == 0) {
    		left++;
    		right--;
    		ans++;
    	}
    	else if(v[left] == 0)
    		left++;
    	else if(v[right] == 1)
    		right--;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

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

	vector<double> v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());

	double tmp = 0;
	double ans = (v.at(0) + v.at(1)) / 2;
	for (int i = 2; i < n; i++)
	{
		tmp = (ans + v.at(i)) / 2;
		ans = tmp;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/08/04.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    string s;
    cin >> s;
    int n=s.length();
    vi a(n,0);
    rep(i,n-1){
        if(s[i]=='R'&&s[i+1]=='L'){
            int c=0;
            for(int j=i;j>=0;j--){
                if(s[j]=='L') break;
                if(c%2) a[i+1]++;
                else a[i]++;
                c++;
            }
            c=0;
            for(int j=i+1;j<n;j++){
                if(s[j]=='R') break;
                if(c%2) a[i]++;
                else a[i+1]++;
                c++;
            }
        }
    }
    rep(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<bool> S(13,false), H(13,false), C(13,false), D(13,false);
    for(int i = 0; i < n; i++){
        char mark; int num;
        cin >> mark >> num;
        if(mark == 'S') S[num-1] = true;
        if(mark == 'H') H[num-1] = true;
        if(mark == 'C') C[num-1] = true;
        if(mark == 'D') D[num-1] = true;
    }

    for(int i = 0; i < 13; i++){
        if(!S[i]) cout << "S " << i+1 << endl; 
    }
    for(int i = 0; i < 13; i++){
        if(!H[i]) cout << "H " << i+1 << endl; 
    }
    for(int i = 0; i < 13; i++){
        if(!C[i]) cout << "C " << i+1 << endl; 
    }
    for(int i = 0; i < 13; i++){
        if(!D[i]) cout << "D " << i+1 << endl; 
    }

}


Measured memory_bytes: 3104
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};


typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, K; cin >> N >> K;
    ll A[N]; F0R(i, N) cin >> A[i];
    F0R(i, N-K) {
        cout << (A[i+K] > A[i] ? "Yes":"No") << nl;
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0, ans = n, xo = 0;
  int l = 0, r = 0;
  bool flag = true;
  while(l < n) {
    while(r < n && ((sum + a[r]) == (xo ^ a[r]))) {
      sum += a[r];
      xo ^= a[r];
      r++;
    }
    ans += (r - l) - 1;
    sum -= a[l];
    xo ^= a[l];
    l++;
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef VVI matrix;

matrix identity(int n)
{
  matrix A(n,vector<int>(n));
  for(int i=0;i<n;i++) A[i][i] = 1;
  return A;
}

/*
vector<int> multi(const matrix& A,const vector<int>& B)
{
  vector<int> ret(A.size());
  for(int i=0;i<A.size();++i)
    for(int j=0;j<A[0].size();++j)
      ret[i] = A[i][j]*B[j];
  return ret;
}
*/

matrix multi(const matrix& A,const matrix& B)
{
  matrix C(A.size(),vector<int>(B[0].size()));
  for(int i=0;i<C.size();++i)
    {
      for(int j=0;j<C[i].size();++j)
	{
	  for(int k=0;k<A[i].size();++k)
	    {
	      C[i][j] += A[i][k]*B[k][j];
	      if(C[i][j] >= 1)
		break;
	    }
	  if(C[i][j] > 1)
	    C[i][j] = 1;
	}
    }  
  return C;
}

matrix pow(const matrix& A,int n)
{
  return !n?identity(A.size()):
    (n%2?multi(A,pow(A,n-1)):pow(multi(A,A),n/2));
}

typedef pair<int,int> P;
int N,M,Z;

void print(const matrix& A)
{
  cout << "print" << endl;
  for(int i=0;i<A.size();i++)
    for(int j=0;j<A[i].size();j++)
      j == A[i].size()-1?cout << A[i][j] << endl:cout << A[i][j] << " "; 
}


int main()
{
 
  while(cin >> N >> M >> Z,N|M|Z)
    {
      vector<P> vec;
      vec.push_back(P(1,1));
      for(int i=0;i<M;i++)
	{
	  int s,d;
	  cin >> s >> d;
	  vec.push_back(P(s,d));
	  vec.push_back(P(d,s));
	}

      matrix mat(vec.size(),vector<int>(vec.size()));
      
      for(int i=0;i<vec.size();i++)
	for(int j=0;j<vec.size();j++)
	  if(i == j || !j || (vec[i].first == vec[j].second))
	    mat[i][j] = 0;
	  else
	    mat[i][j] = (vec[i].second == vec[j].first); 
      // print(mat);
      mat = pow(mat,Z);
      //print(mat);

      bool c = false;
      for(int i=0;i<mat.size();i++)
	if(vec[i].second == N && mat[0][i])
	    {
	      c = true;
	      break;
	    }

      c?cout << "yes" << endl:cout << "no" << endl;

    }
  return 0;
}

Measured memory_bytes: 2640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll>vec(N,0);
  for(ll i=0;i<K;i++){
    ll a;
    cin>>a;
    for(ll j=0;j<a;j++){
      ll b;
      cin>>b;
      vec.at(b-1)=1;
    }
  }
  ll c=0;
  for(ll i=0;i<N;i++){
    if(vec.at(i)==0){
      c+=1;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

int bs(ll n,vector<pair<ll,ll>> &v){
  int l = -1,r = v.size();
  while(r-l > 1){
    int mid = (l+r)/2;
    if(v[mid].first < n)l = mid;
    else r = mid;
  }
  return r;
}

int main(){
  
  #define mk make_pair
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  ll res = 0,pre = v[0];
  vector<pair<ll,ll>> mem;
  mem.push_back(mk(v[0],0));
  rep(i,n){
    ll pos = bs(v[i],mem);
    for(ll j = pos;j < mem.size();j++){
      if(j-1 >= 0){
        pre -= mem[j].first*(mem[j].second-mem[j-1].second);
      }else{
        pre -= mem[j].first*(mem[j].second+1);
      }
    }
    if(pos-1 >= 0)pre += v[i]*(i-mem[pos-1].second);
    else pre += v[i]*(i+1);
    {
      ll k = mem.size();
      for(ll j = pos;j < k;j++)mem.pop_back();
    }
    mem.push_back(mk(v[i],i));
    res += pre;
  }
  cout << res << "\n";


  

  return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N; cin >> N;
	vector<int> a(N);
	REP(i,N) cin >> a[i];

	int ans = 1 << 30;
	FOR(i,-100,101){
		int sum = 0;
		REP(j,N) sum += abs((int)pow(i-a[j],2));
		ans = min(ans, sum);
	}

	cout << ans << endl;




	return 0;

}


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

int main() {
    string s;
    cin >> s;
    string ans;
    for(int i = 0; i < s.length(); i++){
        if( s[i] == '0' || s[i] == '1'){
            ans += s[i];
        }else if(s[i] == 'B'){
           ans = ans.substr(0,ans.length()-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String a = sc.next();
    String b = a.substring(5,7);
    int n = Integer.parseInt(b);
    if (n>4) {
      System.out.println("TBD");
    } else {
      System.out.println("Heisei");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<vector<int> > adj(110);
    int D[110];
    for(int i = 0; i < n; i++){
        int u, k;
        cin >> u >> k; 
        D[u] = -1;
        for(int j = 0; j < k; j++){
            int v;
            cin >> v;
            adj[u].push_back(v);
        }
    }
    queue<int> Q;
    Q.push(1);
    D[1] = 0;
    while(!Q.empty()){
        int cur = Q.front(); 
        Q.pop();
        for(int i = 0; i < adj[cur].size(); i++){
            int dst = adj[cur][i];
            if(D[dst] == -1){
                D[dst] = D[cur]+1;
                Q.push(dst);
            }
        }
    }
    for (int i = 1; i < n+1; i++){
        cout << i << " " << D[i] << endl;
    }
}

Measured memory_bytes: 3132
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
dp = [[0] * (n + 1) for _ in range(3)]
for i in range(n % 2 + 2):
    for j in range(1 + i, n + i, 2):
        if i == 0:
            if j == 1:
                dp[i][j] = a[j]
            else:
                dp[i][j] = dp[i][j - 2] + a[j]
        else:
            dp[i][j] = max(dp[i - 1][j - 1], dp[i][j - 2] + a[j])
ans = dp[n % 2 + 1][n]
print(ans)

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

int main() {

	ll n; cin >> n;
	vector<ll> accum(n + 1, 0);
	for (ll i = 1; i <= n; i++) {
		ll a; cin >> a;
		accum[i] += a;
		accum[i] += accum[i - 1];
	}
	ll ans = 9223372036854775807LL;
	for (ll i = 1; i <= n - 1; i++) {
		ll left = accum[i];
		ll right = accum[n] - accum[i];
		ll tmp = abs(left - right);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4732
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>L(M), R(M);
	int LMAX = 0;
	int RMIN = 1e9;
	for (int i = 0; i < M; i++)
	{
		cin >> L[i] >> R[i];
		LMAX = max(LMAX, L[i]);
		RMIN = min(RMIN, R[i]);
	}
	cout << max(0, RMIN - LMAX + 1) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

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

ll N;




int main() {

	string S;
	ll N,K;
	cin >> N >>  K >> S;


	S[K-1] = (S[K-1] - 'A') + 'a';


	cout << S << endl;

	
	return 0;

}

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

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

  vector<int> p(n);
  for (auto& e : p)
    cin >> e;

  vector<int> mn(n);
  mn[0] = p.front();

  for (int i = 1; i < n; ++i) {
    mn[i] = min(p[i], mn[i - 1]);
  }

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i] == mn[i])
      ++cnt;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;


void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	int k;
	cin>>k;
	

	while(b<=a and k>0)
	{
		b*=2;
		k--;
	}	
	
	while(c<=b and k>0)
	{
		c*=2;
		k--;
	}
	
	if(k==0 and c>b and b>a)
	{
		cout<<"Yes"<<"\n";
		return ;
	}
	
	while(k>0)
	{
		c*=2;
		k--;
		if(k==0)
		break;
		else
		{
			b*=2;
			if(k==0)
			break;
			else
			{
				a*=2;
				k--;
			}
		}
		if(k==0)
		break;
	}
	if(k==0 and c>b and b>a)
	{
		cout<<"Yes"<<"\n";
		return ;
	}
	
	cout<<"No"<<"\n";
	
	
	
}
signed main()
{
    
	nuenxfiu
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	//TT
	solve();
     return 0;
}

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

int main(){
  char N[4];
  cin >> N;
  if ((N[0] == N[1] & N[1] == N[2] & N[2] == N[3]) |
      (N[0] == N[1] & N[1] == N[2] & N[2] != N[3]) |
      (N[0] != N[1] & N[1] == N[2] & N[2] == N[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,k,i;
  scanf("%d %d %d",&n,&m,&k);
  int** A[n][m+1];
  for(i=0;i<n;i++){
    int j,x;
     for(j=0;j<m+1;j++){
       scanf("%d",&x);
       A[i][j]=x;
     }
  }
  int p,P,sum=-1;
  P=(int)pow(2,n);
  for(p=0;p<P;p++){
    int q,r=p,s;
    int N[m+1];
    for(s=0;s<m+1;s++){
      N[s]=0;
    }
    for(q=0;q<n;q++){
      if(r%2==1){
        for(s=0;s<m+1;s++){
          int vd,vf;
          vd=N[s];
          vf=A[q][s];
          N[s]=vd+vf;
        }
      }
      r=r/2;
    }
    for(s=1;s<m+1;s++){
      if(N[s]<k){
        break;
      }
      if(s==m){
        if(sum==-1){
          sum=N[0];
        }else if(sum>N[0]){
          sum=N[0];
        }
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 2560
x1,y1,x2,y2=map(int,input().split())
vec1=[x1-x2,y1-y2]  #3->4
vec2=[y1-y2,x2-x1]  #2->3

print(x2+vec2[0],y2+vec2[1],\
      x2+vec2[0]+vec1[0],y2+vec2[1]+vec1[1])

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

int main(void){
    ll n, m;
    cin >> n >> m;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    vector<p> vp;
    for(ll i = 0; i < m; i++){
        ll c, b;
        cin >> c >> b;
        vp.push_back(p(b, c));
    }
    sort(vp.begin(), vp.end());
    ll ans = 0;
    ll now = 0;
    for(ll i = m-1; i >= 0; i--){
        ll x = vp[i].first, y = vp[i].second;
        ll count = 0;
        //cout << x << " " << y << endl;
        for(ll j = now; j < n; j++){
            if(x>a[j]){
                a[j] = x;
                count++;
                now++;
            }
            if(count==y || a[j]>x)
                break;
        }
    }
    for(ll i = 0; i < n; i++){
        ans+=a[i];
        //cout << a[i] << " ";
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<long long, long long>


using namespace std;
const long long int MOD=1e9+7;

int main(){
   long long n, k;
   cin >> n >> k;
   long long cnt=0;
   while(n>0){
     cnt++;
     n/=k;
   }
   cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int d[300000],g[300000],q[300000],r[300000];
int i,k,n,p;
long long m;

int main()
{
	scanf("%d%lld",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	for (i=n;i>0;i--)
	{
		if (d[g[i]])
			r[i]=d[g[i]]+1;
		d[g[i]]=i;
	}
	for (i=n;i>0;i--)
		if (! r[i])
			r[i]=d[g[i]]+n+1;
	for (p=r[1];;p=r[p])
	{
		while (p>n)
			p=p-n,k++;
		if (p==1)
			break;
	}
	m=m%k;
	if (! m)
		return 0;
	for (p=1,k=1;;p=r[p])
	{
		while (p>n)
			p=p-n,k++;
		if (k==m)
			break;
	}
	memset(d,0,sizeof(d));
	for (k=0;p<=n;p++)
		if (d[g[p]])
			while (d[g[p]])
				d[q[k]]=0,k--;
		else
			k++,q[k]=g[p],d[g[p]]=1;
	for (i=1;i<=k;i++)
		printf("%d ",q[i]);
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_V 1010
const ll INF=1e18;

struct edge {ll to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,ll cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

ll dfs(int v,int t,ll f){
  if(v==t) return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      ll d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(int s,int t){
  ll flow=0;
  for(;;){
    for(int i=0;i<MAX_V;i++) used[i]=false;
    ll f=dfs(s,t,INF);
    if(f==0) return flow;
    flow+=f;
  }
}


int N;
vector<ll> A;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  int s=0,t=N+1;
  ll ans=0;
  for(int i=0;i<N;i++){
      if(A[i]>0){
          ans+=A[i];
          add_edge(s,i+1,A[i]);
          add_edge(i+1,t,0);
      }else{
          add_edge(s,i+1,0);
          add_edge(i+1,t,abs(A[i]));
      }
  }

  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
          if(i==j) continue;
          if((j+1)%(i+1)==0) add_edge(j+1,i+1,INF);
      }
  }

  ans-=max_flow(s,t);
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
def v_and_num(queue):
  output = [(0,0)]
  for i in range(len(queue)+1):
    hand = queue[:i]
    hand = sorted(hand)
    for j in range(len(hand)):
      output.append((i+j,sum(hand[j:])))
      if hand[j] > 0:
        break
  return output


n,k = list(map(int,input().split(" ")))
D =   list(map(int,input().split(" ")))

"""
left = D[:n//2+1]
right = list(reversed(D[n//2+1:]))

l = v_and_num(left)
r = v_and_num(right)
M = 0
for k1, v1 in l:
  for k2, v2 in r:
    if k1+k2 > k:
      continue
    if v1+v2 > M:
      M = v1+v2
      """

r = min(k,n)
M = 0
for a in range(r+1):
  for b in range(r+1-a):
    hand = D[:a] + D[-b:] if b!=0 else D[:a]
    hand = list(sorted(hand))
    i = 0
    for i in range(min(k-a-b+1,a+b)):
      if hand[i] > 0:
        break
    buf = sum(hand[i:])
    if buf > M:
      M = buf
print(M)


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

A, B, C = ds_in()
print(max(A, B, C) * (10-1) + (A+B+C))


Measured memory_bytes: 2940
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream> //stringstream(from int to string)
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl

template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max

using namespace std;

char tanni[4] = {'i','x','c','m'};
int tanni_num[4] = {1,10,100,1000};

int get_number(string mcxi) {
	int total_num=0;
	int back_num = -1;
	int tanni_index = -1;

	rep(i,mcxi.size()) {
		tanni_index = -1;
		rep(j,4) { //単位があるか
			if (mcxi[i] == tanni[j]) {tanni_index = j; break;}
		}
		if (tanni_index == -1) { //number[2-9]
			back_num = mcxi[i]- '0';
		}
		else { //char[mcxi]
			if (back_num == -1) { //back_numがないとき
				total_num += tanni_num[tanni_index];
			}
			else {
				total_num += back_num * tanni_num[tanni_index];
			}
			back_num = -1;
		}
	}
	
	return total_num;
}

string get_mcxi(int num) {
	string mcxi="";
	int ii=0;
	stringstream ss;
	ss << num;
	string num_str = ss.str();

	for(int i = num_str.size()-1; i >= 0; i--)
	{
		if (num_str[i] == '1') {
			mcxi.insert(mcxi.begin(),tanni[ii]);
		}
		else if (num_str[i] == '0') { 
			//pass
		}
		else {
			mcxi.insert(mcxi.begin(),tanni[ii]);
			mcxi.insert(mcxi.begin(),num_str[i]);
		}
		ii++;
	}
	return mcxi;
}


int main() {
	int N;
	string left_str,right_str;
	int left_num,right_num;
	int sum_num;

	cin >> N;
	rep(n,N) {
		cin >> left_str >> right_str;
		left_num = get_number(left_str);
		right_num = get_number(right_str);
		sum_num = left_num + right_num;
		//cout << sum_num << " ";
		cout << get_mcxi(sum_num) << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	vector<vector<int>> a(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3;j++) {
			cin >> a[i][j];
		}
	}

	int n;
	cin >> n;
	vector<vector<bool>> bingo(3, vector<bool>(3,false));

	for (int i = 0; i < n;i++) {
		int b;
		cin >> b;
		for (int j = 0;j < 3; j++) {
			for (int k = 0; k < 3;k++) {
				if (a[j][k] == b) {
					bingo[j][k] = true;
				}
			}
		}
	}

	bool canBingo = false;

	for (int i = 0;i < 3; i++) {
		bool cB = true;
		for (int j = 0; j < 3;j++) {
			if (!bingo[i][j]) {
				cB = false;
			}
		}

		if (cB) {
			canBingo = true;
			break;
		}

	}

	for (int i = 0;i < 3; i++) {
		bool cB = true;
		for (int j = 0; j < 3;j++) {
			if (!bingo[j][i]) {
				cB = false;
			}
		}

		if (cB) {
			canBingo = true;
			break;
		}

	}

	{
		bool cB = true;
		for (int i = 0; i < 3;i++) {
			if (!bingo[i][i]) {
				cB = false;
			}

		}
		if (cB) {
			canBingo = true;
		}
	}
	{
		bool cB = true;
		for (int i = 0; i < 3;i++) {
			if (!bingo[i][2-i]) {
				cB = false;
			}

		}
		if (cB) {
			canBingo = true;
		}
	}
	cout << (canBingo ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256