akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2, 62);

int main(){
    int n;cin >> n;
    cout << n + n*n + n*n*n << endl;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

C = Counter(A)
ans = 0
# 大きい数から見ていく
for i in range(30, 0, -1):
    x = 2 ** i
    for k in C.keys():
        if x-k in C:
            # 同値ペアは別処理
            if k == x-k:
                p = C[k] // 2
                C[k] -= p * 2
                ans += p
            else:
                # 少ない方に合わせてペア作成
                p = min(C[k], C[x-k])
                C[k] -= p
                C[x-k] -= p
                ans += p
print(ans)


Measured memory_bytes: 33404
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
x = []

for i in range(n):
    x.append(s.count(s[i]) - t.count(s[i]))
    
x

if max(x)>=0:
    print('{}'.format(max(x)))
else:
    print('0')


Measured memory_bytes: 3060
module Main where

import           Control.Applicative
import           Data.List

main :: IO ()
main = do
    n   <- readLn
    p_i <- map read . words <$> getLine
    putStrLn $ show $ solve3 n p_i


solve3 :: Int -> [Int] -> Int
solve3 n p_i = leftBiggerThanRight p_i 200000
  where
    leftBiggerThanRight :: [Int] -> Int -> Int
    leftBiggerThanRight [] mini = 0
    leftBiggerThanRight (x : xs) mini
        | x <= mini = 1 + (leftBiggerThanRight xs x)
        | x > mini  = 0 + (leftBiggerThanRight xs mini)


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100100;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	vector<int> V(n);
	vector<int> C(n);

	for (int i = 0; i < n; i++)
	{
		cin >> V[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> C[i];
	}

	for (int i = 0; i < n; i++)
	{
		int tmp = V[i] - C[i];

		if (tmp > 0) ans += tmp;
	}
	cout << ans << endl;
}

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

int main() {
	/*int N;
	cin >> N;
	vector<int>h(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1]-h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = min(c[i] + abs(h[i + 1] - h[i]), c[i - 1] + abs(h[i + 1] - h[i - 1]));
	}
	cout << c[N - 1] << endl;*/



	/*int N, K;
	cin >> N >> K;
	vector<int>h(N);
	int i, j;

	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = c[i] + abs(h[i + 1] - h[i]);
		for (j = 1; j <= K && i + 1 - j >= 0; j++) {
			c[i + 1] = min(c[i + 1], c[i + 1 - j] + abs(h[i + 1] - h[i + 1 - j]));
		}
	}
	cout << c[N - 1] << endl;*/


	/*int N;
	cin >> N;
	vector<int>a(N), b(N), c(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<int>A(N), B(N), C(N);
	A[0] = a[0];
	B[0] = b[0];
	C[0] = c[0];
	for (i = 0; i < N - 1; i++) {
		A[i + 1] = a[i + 1] + max(B[i], C[i]);
		B[i + 1] = b[i + 1] + max(A[i], C[i]);
		C[i + 1] = c[i + 1] + max(A[i], B[i]);
	}
	cout << max({ A[N - 1], B[N - 1],C[N - 1] }) << endl;*/


	int N, W;
	cin >> N >> W;
	int i, j;
	vector<int>w(N + 1), v(N + 1);
	for (i = 0; i < N; i++) {
		cin >> w[i + 1] >> v[i + 1];
	}
	vector<vector<long long>>dp(N + 1, vector<long long>(W + 1));
	for (i = 0; i < N; i++) {
		for (j = 0; j <= W; j++) {
			if (j - w[i + 1] >= 0)dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i + 1]] + v[i + 1]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
	return 0;

}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s = scan.next();
		sb.append(s);
		sb.reverse();
		//System.out.println(sb);
		if(s.equals(sb.toString())) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int N, A, X; cin >> N >> A;
    X = A;
    VI x(N);
    REP(i, N){
        cin >> x[i];
        chmax(X, x[i]);
    }
    //dp[i][j][k]: x[0],..,x[i-1]からj枚で和がk
    vector<vector<VLL>> dp(N+1, vector<VLL>(N+1, VLL(N*X+1, 0)));
    dp[0][0][0] = 1;
    FORS(i, 1, N){
        REPS(j, N){
            REPS(k, N*X){
                dp[i][j][k] = dp[i-1][j][k];
                if(j && k >= x[i-1])
                    dp[i][j][k] += dp[i-1][j-1][k - x[i-1]];
            }
        }
    }
    ll ans = 0;
    FORS(i, 1, N){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int r, n;
  cin >> r >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int res = v.back() - v.front();
  for (int i = 1; i < n; i++) {
    res = min(res, r - v.at(i) + v.at(i-1));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
} 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
} 
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	double r; cin>>r;
	cout<<fixed<<setprecision(9)<<2 * 4*atan(1)*r<<endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);
class Modulo{
public:
    int val;
    static const int mod = 1e9+7;
    vector<int> factable = {1};
    vector<int> invtable = {1};
    int pro(int x,int y){return ((x%mod)*(y%mod))%mod;}
    int sum(int x,int y){return ((x%mod)+(y%mod))%mod;}
    int dif(int x,int y){int d =((x%mod)-(y%mod))%mod;if(d>=0){return d;}else{return d+mod;}}
    int quo(int x, int y){return pro(x,pow(y,mod-2));}
    int pow(int x,int y){
        if(y<=0){return 1;}
        if(y%2==0){int d = pow(x,y/2);return ((d%mod)*(d%mod))%mod;}
        else{return (x*pow(x,y-1))%mod;}
    }
    void operator=(int n){this->val = n%mod;}
    int operator+(int n){return sum(this->val,n);}
    int operator-(int n){return dif(this->val,n);}
    int operator*(int n){return pro(this->val,n);}
    int operator/(int n){return quo(this->val,n);}
    void operator+=(int n){this->val = sum(this->val,n);}
    void operator-=(int n){this->val = dif(this->val,n);}
    void operator*=(int n){this->val = pro(this->val,n);}
    void operator/=(int n){this->val = quo(this->val,n);}
    int fac(int x){
        //x! mod mod
        if(factable.size()<=x){
            int s = factable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    int facinv(int x){
        if(invtable.size()<=x){
            int s = invtable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    int com(int x,int y){
        //xCy mod mod = x!/((x-y)!*y!) mod mod
        if(x-y<y)return com(x,x-y);
        return pro(fac(x),pro(facinv(x-y),facinv(y)));
    }
};




int n,m;

signed main(){
    cin >> m >> n;
    print(m-n+1);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}

Measured memory_bytes: 256
import Data.List
import Debug.Trace

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as k

solve as k =
  ans
  where
    as' = group $ sort as
    len = length as'
    as'' = sortOn length as'
    check as@(a:_) k' acc
      | k'<=k = acc
      | otherwise =
--        traceShow (as,k',acc) $
        check (tail as) (k'-1) (acc + length a) 
    ans = check as'' len 0


Measured memory_bytes: 64252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	long long N;

	scanf("%lld", &N);

	int ans = 0;
	while(N>=10){
		int tmp = N%10;
		ans += 9;
		N /= 10;
		if(tmp!=9) N--;
	}

	ans += N;

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scn = new Scanner(System.in);
		String S = scn.next();
		int num = S.length();
		int i = 0;
		StringBuilder ans = new StringBuilder();
		while (i < num) {
			ans.append("x");
			i++;
		}

		System.out.println(ans);

	}

}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    for(int i=0;i<b;i++){
      cout<<a;
    }
    cout<<endl;
    return 0;
  }
  for(int i=0;i<a;i++)
    cout<<b;
  cout<<endl;
}

Measured memory_bytes: 3600
n = int(input())
L = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                pass
            elif L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i]:
                count +=1
print(count)

Measured memory_bytes: 9212
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    long long count = 0;

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

    std::cout << (count >= 0 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
vector<int> v;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,min(a,b)){
		if(a%(i+1)==0&&b%(i+1)==0)v.push_back(i+1);
	}
	cout<<v[v.size()-c]<<endl;
}


Measured memory_bytes: 256
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=5e6+20;
const int mod=1e9+7;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
map<ll,int>mp;
int main()
{
    ll t;
    t=read();
    ll b=0;
    ll cnt=0;
    ll f=10000000;
    while(f--){
        b=b*10+7;
        cnt++;
        b%=t;
        //mp[b]++;

        if(b==0){
            cout<<cnt;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}
/*

 */

Measured memory_bytes: 3612
INF = 10 ** 6
n = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)
odds = Array.new(10 ** 5 + 1, 0)
evens = Array.new(10 ** 5 + 1, 0)
nums.each_with_index do |num, index|
  if index.even?
    odds[num] += 1
  else
    evens[num] += 1
  end
end

odds_candidates = []
evens_candidates = []

2.times do
  odds_max = odds.index(odds.max)
  if odds[odds_max] == -1
    break
  else
    odds_candidates << [odds_max, n / 2 - odds[odds_max]]
    odds[odds_max] = -1
  end

  evens_max = evens.index(evens.max)
  if evens[evens_max] == -1
    break
  else
    evens_candidates << [evens_max, n / 2 - evens[evens_max]]
    evens[evens_max] = -1
  end
end

odds_candidates << [INF, n / 2]
evens_candidates << [INF, n / 2]

mins = []

odds_candidates.each do |odds_candidate|
  evens_candidates.each do |evens_candidate|
    if odds_candidate[0] == evens_candidate[0]
      next
    else
      mins << odds_candidate[1] + evens_candidate[1]
    end
  end
end

puts mins.min

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

void swap(int a, int b) {
	if (a > b) cout << b << " " << a << endl;
	else cout << a << " " << b << endl;
}
int main()
{
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) if (c % i == 0) ++count;
	cout << count << endl;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int n,a[]={1,2,4,8,16,32,64};

int main()
{
	scanf("%d",&n);
	while(1)
	{
		for(int i=0;i<7;++i) 
			if(a[i]==n) { printf("%d\n",a[i]); return 0; }
		n--;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char num[5];

    scanf("%s", num);

    if((num[0] == num[1] && num[1] == num[2]) || (num[1] == num[2] && num[2] == num[3]))
        printf("Yes");
    else
        printf("No");

    return 0;
}

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

#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REPD(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define DEBUG(x) cerr << __PRETTY_FUNCTION__ << ">> " << #x << " : " << x << endl

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int odd = 0;
  REP(i, n) {
    int x;
    cin >> x;
    odd += x % 2 == 1;
  }
  cout << (odd % 2 == 0 ? "YES" : "NO") << endl;
  return 0;
}



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

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S == U)
        cout << A-1 << " " << B << endl;
    else
        cout << A << " " << B-1 << endl;
    return 0;
}



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

int ar[maxn];
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, d) + -1 * (max(0, min(c, d - a - b))) << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX 100100

int n;
int a[MAX];

int main() {
  scanf("%d", &n);

  while(n) {
    int average = 0, cnt = 0;
    for(int i=0; i<n; ++i) {
      scanf("%d", &a[i]);
      average += a[i];
    }

    average /= n;

    for(int i=0; i<n; ++i)
      if(a[i]<=average) ++cnt;

    printf("%d\n", cnt);
    scanf("%d", &n);
  }

  return 0;
}



Measured memory_bytes: 3268
n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
  s.append(s[i]+a[i])

s.pop(0)

for x in range(0, n-1):
  ans = ans +(a[x]*(s[n-1]-s[x]))
  
print(ans%mod)
        


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int>v(n+1);
    v[0] = 1, v[1] = 1;
    for(int i = 2; i <= n; i++) v[i] = v[i-1] + v[i-2];
    cout << v[n] << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = Integer.toString(n);
    int cnt = 0;

    for (int i = 0; i < s.length(); i++) {
      cnt += Character.getNumericValue(s.charAt(i));
    }

    if ((n % cnt) == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35684
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int n,m,k,res = 0;
const int N = 8;
char g[N][N],backup[N][N];
bool str[N],stc[N];
void dfs(int u,int v)
{
	if(u >= n && v >= m)
	{
		int tmp = 0;
		for(int i = 0;i < n;++i)
			for(int j = 0;j < m;++j)
				if(g[i][j] == '#' && !str[i] && stc[j])
					++tmp;
		if(tmp == k)	++res;
		return ;
	}
	//
	dfs(u + 1,v + 1);
	//
	if(u < n)
	{
		str[u] = 1;
		dfs(u + 1,v + 1);
		str[u] = 0;		
	}
	if(v < m)
	{
		stc[v] = 1;
		dfs(u + 1,v + 1);
		stc[v] = 0;
	}
	if(u < n && v < m)
	{
		str[u] = 1;
		stc[v] = 1;
		dfs(u + 1,v + 1);
		str[u] = 0;
		stc[v] = 0;	
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0;i < n;++i)	scanf("%s",g[i]);
	dfs(0,0);
	printf("%d",res);
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define forn(i,n) for (int i=0;i<n;i++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define trav(a,x) for (auto& a : x)

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define mem(x,a) memset(x,a,sizeof(x))

typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 2e5 + 5;

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

 int dp[N];
 dp[0] = 0 ;
 rep(i,1,N)dp[i] = dp[i - 1] + i ;
 int ans = 0;

 rep(i,k,n+1){
  int mi = dp[i-1] , mx = dp[n] - dp[n-i];
  ans += (mx - mi + 1);
  ans %= MOD ;
 }
 cout << (ans + 1 ) % MOD << " ";


 return 0;
}        

Measured memory_bytes: 5120
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

s = i_s()

ans = 0
for i in range(2**(len(s)-1)):
    tmp = s[0]
    for j in range(len(s)-1):
        if i & (1<<j):
            tmp += "+"
        tmp += s[j+1]
    ans += eval(tmp)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int i, n, a, sum=0;
  cin >> n;
  a = n;
  while (1) {
    sum += a%10;
    a = a/10;
    if (a<1){
      break;
    }
  }
  if(n%sum == 0){
    cout << "Yes" << endl; 
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
	string ans="";
	int now=0;
	while(ans.size()<10){
		int l=-1, r=9;
		if(ans.size()<1) l=0;
		while(l+1<r){
			string n=ans;
			int mid=(l+r)/2;
			n += ('0'+mid);
			while(n.size()<18) n += '9';
			cout << "? " << n << endl;
			char res;
			cin >> res;
			if(res=='Y') r=mid;
			else l=mid;
		}
		ans += ('0'+r);
	}//40
	int l2=9, r2=10;
	while(ans[l2]=='0') --l2;
	int basl2=l2;
	//cout << basl2 << endl;
	while(l2+1<r2){
		int mid2=(l2+r2)/2;
		//cout << mid2 << endl;
		string ask=ans.substr(0, mid2);
		bool sunao=true;
		if(mid2==basl2+1){
			if(ask=="1"){
				ask="2";
			}else{
				ask[0]='1';
				for(int i=1; i<ask.size(); ++i){
					ask[i]='0';
				}
				ask += '0';
				sunao=false;
			}
		}else{
			ask.back()='9';
		}
		cout << "? " << ask << endl;
		char res2;
		cin >> res2;
		if((res2=='Y')^(!sunao)) r2=mid2;
		else l2=mid2;
	}
	cout << "! " << ans.substr(0, r2) << endl;
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    if (n % 2 == 0) {
        cout << fixed << setprecision(10) << 1.0 / 2 << endl;
    } else {
        cout << fixed << setprecision(10) << (n + 1.0) / n / 2 << endl; 
    }

    return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: usize = itr.next().unwrap().parse().unwrap();

    let keta = |x: usize| {
        let mut y = x;
        let mut res = 0;
        while y > 0 {
            res += 1;
            y /= 10;
        }
        res
    };

    let mut ans = 1 << 30;
    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            let a = i;
            let b = n / i;
            ans = min(ans, max(keta(a), keta(b)));
        }
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  vector<char>	s(n);
  for(int i=0;i<n;i++)	cin >> s[i];
  
  int ans=n;
  for(int i=1;i<n;i++){
    if(s[i]==s[i-1])	ans--;
  }
  cout << ans;
}

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

const int inf = 1e9 + 35;

void chmax (int &x, int y) {
    x = max(x, y);
}

signed main () {
    int n;
    cin >> n;
    vector < vector < bool > > f(n, vector < bool > (10, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            int x;
            cin >> x;
            f[i][j] = bool(x);
        }
    }
    vector < vector < int > > p(n, vector < int > (11));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= 10; ++j)
            cin >> p[i][j];
    }
    int ans = -inf;
    for (int mask = 1; mask < (1 << 10); ++mask) {
        int ans_cur = 0;
        bool common = 0;
        for (int i = 0; i < n; ++i) {
            int w = 0;
            for (int j = 0; j < 10; ++j) {
                if (f[i][j] && (mask & (1 << j)))
                    ++w;
            }
            if (w) 
                common = 1;
            ans_cur += p[i][w];
        }
        if (common)
            chmax(ans, ans_cur);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const A = numList0[0];
    const B = numList0[1];
    const C = numList0[2];
    // const N = numList0[0];
    // const AList = input[1].split(' ').map(x => parseInt(x, 10));

    // 入る分
    const capacity = A - B;
    const result = Math.max(0, C - capacity);

    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main(void){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i = 1; i * i <= N; i++){
        if(N % i == 0){
            long long m = N / i - 1;
            if(m > 1 && (N / m) == (N % m)) ans += m;

            // if(m > 1 && (N / m) != (N % m)) cout << m << endl;

            m = i - 1;
            if(m > 1 && (N / m) == (N % m)) ans += m;

            // if(m > 1 && (N / m) != (N % m)) cout << m << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using std:: bitset;

const int maxn = 2005;

bitset<maxn*maxn> bb;

int main()
{
	int n;
	scanf("%d", &n);
	bb[0] = 1;
	int sum = 0;
	for(int i = 1; i <= n; ++i)
	{
		int tmp;
		scanf("%d", &tmp);
		bb |= bb<<tmp;
		sum += tmp;
	}
	for(int i = (sum+1)>>1; ; ++i)
	{
		if(bb[i])
		{
			printf("%d", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  ll N, X, M;
  cin >> N >> X >> M;
  vector<ll> next(M, -1);
  vector<bool> visited(M, false);
  ll ret = 0;
  ll A = X;
  ll prev = -1;
  for (ll i=0; i<N; i++){
    if (visited[A]){
      ll sum_tmp = 0;
      ll st = A;
      ll c = 0;
      do {
        sum_tmp += A;
        A = (A * A) % M;
        c++;
      } while(A != st);
      ret += sum_tmp * ((N - i) / c);
      ll rem = (N - i) % c;
      for (ll j=0; j<rem; j++){
        ret += A;
        A = (A * A) % M;
      }
      break;
    }
      
    ret += A;
    visited[A] = true;
    prev = A;
    A = (A * A) % M;
  }
  
  cout << ret << "\n";
  return 0;
}

Measured memory_bytes: 3984
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var str = Console.ReadLine().Split(' ');
			var 持っている棒の数 = int.Parse(str[0]); // 1 ~ 50
			var 使う棒の数 = int.Parse(str[1]); // 1 ~ 50

			var 棒の長さの情報 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

			var ヘビのおもちゃの長さ = 棒の長さの情報.OrderByDescending(棒の長さ => 棒の長さ).Take(使う棒の数).Sum();

			Console.WriteLine(ヘビのおもちゃの長さ);
		}
	}
}

Measured memory_bytes: 13396
/*Lower_Rating*/
/*AGC035 card*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MAXN 2333
#define MOD 998244353
#define Pr pair<LL,LL>
#define PR pair<pair<int,int>,Pr>
#define X first
#define Y second
#define INF 2000000000000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int n;LL a[MAXN+5];
map<PR,LL> f;
LL dfs(int l,int r,LL x,LL y){
    if(l+1>=r)return 0;
    PR state=make_pair(make_pair(l,r),make_pair(x,y));
    if(f.count(state))return f[state];
    LL res=INF;
    for(int i=l+1;i<=r-1;i++)
    res=min(res,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
    f[state]=res;
    return res;
}
int main(){
    n=read();
    for(int i=1;i<=n;i++)
    a[i]=read();
    printf("%lld",dfs(1,n,1,1)+a[1]+a[n]);
}


Measured memory_bytes: 20608
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
use std::iter::*;
use std::vec::Vec;

fn main() {

    input!{
    	p: i32,
        q: i32,
        r: i32
    }
    let mut a = vec![p,q,r];
    a.sort();
    let ans = a[0] +  a[1];
    println!("{}",&ans)
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc080/tasks/abc080_b
#include <stdio.h>
#include <stdlib.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    for (i = 0; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(void) {
    int n, x;
    int fx = 0;
    
    n = get_num();

    x = n;
    while (x > 0) {
        fx += x % 10;
        x /= 10;
    }
    if (n % fx == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

for(int i=n;;i++){
if(IsPrime(i)){
cout << i;
break;
}

}



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[200100];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>a>>b;
  lol ans=0;
  for(int n=0;n<a;n++){
    cin >>i[n];
  }
  sort(i,i+a,greater<int>());
  for(int n=0;n<a;n++){
    if(n<b);
    else ans+=i[n];
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 1024
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
--import Data.Matrix.Unboxed
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
--import Data.Vector as V　--変数衝突
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

type Ans = String
type Road = String

--人が入れるかチェック
checkRange1 :: Road  -> Bool
checkRange1 [] = True
checkRange1 [r] = True
checkRange1 (r1:r2:road) = if r1 == '#' && r2 == '#' then False
    else checkRange1 (r2:road)

checkRange2 :: Int -> Int -> Int -> Bool -> Road  -> Bool
checkRange2 b d _ switch [] = switch
checkRange2 b d _ switch [r] = switch
checkRange2 b d cnt switch (r1:r2:r3:road)
  | (b-1) <= cnt && cnt <= (d-1) =
    if r1 == '#' && r2 == '#' then False
      else if r1 == '.' && r2 == '.' && r3 == '.' then checkRange2 b d (cnt+1) True (r2:r3:road)
        else checkRange2 b d (cnt+1) switch (r2:r3:road)
  | otherwise = if r1 == '#' && r2 == '#' then False
      else checkRange2 b d (cnt+1) switch (r2:r3:road)
checkRange2 b d cnt switch (r1:r2:road) = if r1 == '#' && r2 == '#' then False
    else checkRange2 b d (cnt+1) switch (r2:road)

solve :: Int -> Int -> Int -> Int -> Int -> String -> Ans
solve n a b c d road = do
  let pattern1 = if checkRange1 (drop a $ take (d+1) road) then "Yes" else "No"
      pattern2 = if checkRange1 (drop a $ take (c+1) road) && checkRange1 (drop b $ take (d+1) road) then "Yes" else "No"
      pattern3 = if checkRange2 b d 0 False (drop a $ take (c+1) road) then "Yes" else "No"
  if b < c && c < d then pattern1
    else if c < b && b < d then pattern2
      else if b < d && d < c then pattern3
        else error "b c d is invalid"

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> Ans
main0 cont =
   let remLines0 = map B.words (B.lines cont)
       [n',a',b',c',d']:remLines1 = remLines0
       n = readBInt n'
       a = readBInt a'
       b = readBInt b'
       c = readBInt c'
       d = readBInt d'
       [s]:remLines2 = remLines1
   in solve n (a-1) (b-1) (c-1) (d-1) (B.unpack s)

main :: IO ()
main = putStrLn . main0 =<< B.getContents


Measured memory_bytes: 2300
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define reps(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) for(int i=0;i<int(b);i++)
#define first ff
#define second ss
#define size sz
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
const int INF = 1e9 + 5;
int main()
{
    csl;
    int n;
    cin >> n;
    vector<int> dp(3,0);
    for(int d=0;d<n;d++)
    {
        vector<int> q(3);
        vector<int> inp(3);
        rep(j,3){
            cin >> inp[j];
        }

        rep(i,3)
        {
            rep(j,3)
            {
                if(i!=j)
                {
                    q[j] = max(q[j],dp[i] + inp[j]);
                }
            }
        }
        dp = q;

    }

    cout << max({dp[0],dp[1],dp[2]}) << endl;

}


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

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

    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    // aの合計を求める
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += a[i];
    }

    // 平均値に一番近いフレーム番号を求める
    int dist_min = 10001;
    int ans;
    for (int i = 0; i < N; i++) {
        int dist = abs(sum - a[i] * N);
        if (dist < dist_min) {
            dist_min = dist;
            ans = i;
        }
    }
    cout << ans << endl;

}


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

int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	long long n, d, x,y;
	scanf("%lld%lld",&n,&d);
	long long dis = d*d;
	long long ans, a = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld",&x,&y);
		ans = (x*x) + (y*y);
		if (ans <= dis) {
			a++;
			
		}
	}
	printf("%lld",a);
	
	return 0;
}//pd pdp


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


int main() {

  int64_t n;
  cin>>n;

  int64_t div=n;
  int64_t rem=0;
  string s;
  while(1){

    rem=(div-1)%26;
    div=(div-1)/26;
    

    char c;
      c=(char)(0x61+rem);

    s.push_back(c);

    if(div==0)
      break;
      
  }

  reverse(s.begin(),s.end());

  cout<<s<<endl;

  return 0;
}




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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	
	string s;
	cin>>s;
	
	if(s[1]=='R')
		cout<<"ABC \n";
	else cout<<"ARC \n";
	
	
	return 0;
}

Measured memory_bytes: 3652
N = int(input())
X = list(map(int, input().split()))

m = min(X)
M = max(X)

cost = [1000000009 for _ in range(101)]
for p in range(1,101):
    c = 0
    for x in X:
        c += (x-p)**2
    cost[p] = c

print(min(cost))

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

void Main() {
	int N, n;
	cin >> N;
	n = N % 10;
	string hon;

		if (n == 3) {
			hon = "bon";
		}
		else if (n == 0 || n == 1 || n == 6 || n == 8){
			hon = "pon";
		}
		else {
			hon = "hon";
		}
	cout << hon << endl;
}
int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var t = sc.intarr;
        int h = t[0];
        int w = t[1];

        bool ans = true;

        char[,] s = new char[h+2, w+2];

        for(int i = 0; i < h+2; ++i)
        {
            string ss="";
            if(i!=h+1&&i!=0) ss = sc.str;
            for(int j = 0; j < w+2; ++j)
            {
                if (i == 0 || i == h+1  || j == 0 || j == w+1)
                {
                    s[i, j] = '.';
                }
                else
                s[i, j] = ss[j-1];
            }
        }

        for(int i = 1; i < h+1; ++i)
        {
            for(int j = 1; j < w+1; ++j)
            {
                if(s[i,j]=='#'&&s[i-1,j]=='.' && s[i + 1, j] == '.' && s[i , j-1] == '.' && s[i , j+1] == '.')
                {
                    ans = false;
                }
            }
        }

        if (ans) wr.wri("Yes");
        else wr.wri("No");
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}



Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
 
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
 
using namespace std;
 
typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	int N;
	cin >> N;
	
	string str;
	cin >> str;
	
	int cnt1 = 0, cnt2 = 0;
	
	for(int i = 0; i < N; i++){
		if(str[i] == '<'){
			cnt1++;
		}else{
			break;
		}
	}
	
	for(int i = 0; i < N; i++){
		if(str[N - i - 1] == '>'){
			cnt2++;
		}else{
			break;
		}
	}
	
	cout << N - min(cnt1, cnt2) << endl;
	
	return 0;
}


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


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

  int count = 0;
  for (int i = 0; i < N; i++) {
    int x, a;
    cin >> x;
    a = K - x;
    count += 2 * min(x, a);
  }
  
  cout << count << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int a[1000000];
int main(void){
    int N,M; cin>>N>>M;
    int j=0; int ans=0;
    for(int i=1;i*i<=M;i++){
        if(M%i==0){
            a[j]=i;
            j++;
            if(i!=M/i){
                a[j]=M/i;
                j++;
            }
        }
    }
    for(int i=0;i<j;i++){
        if(a[i]<=M/N&&a[i]>ans){
            ans=a[i];
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var msg = "No";

            for(int i = 1; i < 10; i++)
            {
                for(int j = 1; j < 10; j++)
                {
                    if(i*j == N)
                    {
                        msg = "Yes";
                        break;
                    }
                }
            }
            Console.WriteLine(msg);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
using namespace std;

#define N 20000

int ret[N];
int gcd(int x,int y) {
  if(x==0) {
    return y;
  }
  return gcd(y%x,x);
}
void solve(int n) {
  int lim = 30000;
  int pos = 0;
  if(n*2<=lim) {
    if(n==3) {
      printf("2 5 63\n");
      return;
    } else {
      ret[0] = 2;
      ret[1] = 3;
      ret[2] = 9;
      ret[3] = 4;
      pos = 4;
      int parity = (n)%3;
      int sum = 0;
      for(int i=6;i<=lim && pos<n;i+=2) {
        ret[pos++] = i;
        sum += i;
      }
      parity = sum%3;
      if(parity==1) {
        ret[pos-1] += 2;
      } else if(parity==2){
        ret[pos-1] +=4;
      }
    }
  } else {
    if(n&1) {
      for(int i=2;i<=lim;i+=2) {
        if(i==6) continue;
        ret[pos++] = i;
      }
      for(int i=3;i<=lim && pos<n;i+=3) {
        if(i%2==0) continue;
        ret[pos++] = i;
      }
    } else {
      for(int i=2;i<=lim;i+=2) {
        ret[pos++] = i;
      }
      for(int i=3;i<=lim && pos<n;i+=3) {
        if(i%2==0) continue;
        ret[pos++] = i;
      }
    }
  }
  int sum = 0;
  for(int i=0;i<n;++i) {
    sum += ret[i];
  }
  int u = ret[0];
  for(int i=0;i<n;++i) {
    assert(ret[i]<=lim);
    assert(gcd(sum-ret[i],ret[i])!=1);
    u = gcd(u,ret[i]);
  }
  assert(u==1);
  for(int i=0;i<pos;++i) {
    printf("%d\n", ret[i]);
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  int n;scanf("%d ", &n);
  solve(n);
  return 0;
}


Measured memory_bytes: 384