akhauriyash/Code-Regression huggingface dataset:
s=input()
q=int(input())
direction=1
#↑で1は右向き2は左向きに対応。
migi_matu=''
hidari_matu=''
#↑リストにしてしまうと後で文字sと連結できなくなる。
for i in range(q):
  k=input().split()
  #k[0] is Ti, k[1] is Fi, k[2] is character
  if k[0]=='1':
    direction*=(-1)
  if k[0]=='2':
    if k[1]=='1':
      if direction==1:
        hidari_matu+=k[2]
      if direction==-1:
        migi_matu+=k[2]
    else:
      if direction==1:
        migi_matu+=k[2]
      if direction==-1:
        hidari_matu+=k[2]
#  print('入力は',k,'とする。このとき')
#  print(i,'回目の操作後')
#  print(direction)
#  if direction==1:
#    print(hidari_matu[::-1]+s+migi_matu)
#  if direction==-1:
#    print(migi_matu[::-1]+s[::-1]+hidari_matu)
  
  
if direction==1:
  print(hidari_matu[::-1]+s+migi_matu)
if direction==-1:
  print(migi_matu[::-1]+s[::-1]+hidari_matu)

Measured memory_bytes: 4468
#include <iostream>
using namespace std;
int main(){
	int k = 0;
	cin>>k;
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[k-1];
	return 0;
} 

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

const int MAX = 10005;

bool search(int A[], int n, int key) {
  A[n] = key;
  int i {0};
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int S[MAX];
  int T[MAX];
  int n {0}, q {0}, cnt {0};
  cin >> n;
  for (int i = 0; i < n; i++) cin >> S[i];
  cin >> q;
  for (int i = 0; i < q; i++) cin >> T[i];

  for (int i = 0; i < q; i++) {
    if (search(S, n, T[i])) cnt++;
  }

  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3124
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int V;
int a[310][310];

int main() {
    int N;
    cin >> N;
    V = N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }
    ll ans = 0;
    bool ok = true;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            bool ok2 = true;
            for (int k = 0; k < N; k++) {
                if (k != i && k != j) {
                    if (a[i][k] + a[k][j] < a[i][j]) {
                        ok = false;
                    } else if (a[i][k] + a[k][j] == a[i][j]) {
                        ok2 = false;
                    }
                }
            }
            if (ok2) {
                ans += a[i][j];
            }
        }
    }
    if (ok) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;




int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll mx=a*b;
    mx=max(mx,c*d);
    cout<<mx<<endl;
    
    
    return 0;
}

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

using namespace std;

int getcolor(int n)
{
	if(n < 400)
		return 1;
	else if(n < 800)
		return 2;
	else if(n < 1200)
		return 3;
	else if(n < 1600)
		return 4;
	else if(n < 2000)
		return 5;
	else if(n < 2400)
		return 6;
	else if(n <2800)
		return 7;
	else if(n < 3200)
		return 8;
	else
		return 0;
}

int main()
{
	int color[9]={0};
	int n, score;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> score;
		color[getcolor(score)]++;
	}
	int ans = 0;
	for(int i=1;i<=8;i++)
	{
		if(color[i] != 0)
			ans++;
	}
	if(ans != 0)
		cout << ans << " " << ans + color[0] << endl;
	else
		cout << 1 << " " << color[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

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

	int x = 0;
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'I')
		{
			x++;
		}
		else
		{
			x--;
		}

		if (max < x)
			max = x;
	}

	cout << max << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
  //freopen("A.in", "r", stdin);
  ll n, x;
  scanf("%lld%lld", &n, &x);
  ll ans = n, w = n-x, h = x;
  while(w && h) {
    ans += w/h*2*h;
    w %= h;
    swap(w, h);
  }
  printf("%lld\n", ans - w - h);
}

Measured memory_bytes: 128
//==========================================
// ABC132a Fifty-Fifty
//
// 2019/08/16
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  string s;
  cin >> s;

  sort(s.begin(), s.end());
  if((s[0] == s[1]) && (s[2] == s[3]) && (s[0] != s[2])) cout << "Yes" << endl;
  else cout << "No" << endl;  
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
rst = [''] * N
is_end = False
if M == 0:
    if N == 1:
        print(0)
    else:
        print('1', '0' * (N - 1), sep='')
else:
    for i in range(M):
        s, c = input().split(' ')
        if (int(s) - 1) == 0 and N != 1 and c == '0':
            print(-1)
            is_end = True
            break
        elif rst[int(s) - 1] == '':
            rst[int(s) - 1] = c
        elif rst[int(s) - 1] != c:
            print(-1)
            is_end = True
            break
    if not is_end:
        for i, j in enumerate(rst):
            if i == 0 and j == '':
                print(1, end='')
            else:
                if j == '':
                    print(0, end='')
                print(j, end='')

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;
vector<vector<ll>> G;

int main(int argc, char **argv)
{
	cin >> N;
	G.resize(N);
	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<ll> color(N, -1);
	queue<ll> que;
	que.push(0);
	que.push(N-1);
	color[0] = 0;
	color[N-1] = 1;

	while (que.size())
	{
		ll n = que.front();
		que.pop();

		for (auto &nv : G[n])
		{
			if (color[nv] != -1) continue;
			color[nv] = color[n];
			que.push(nv);
		}
	}

	ll cnt{0};
	REP(i, N)
	{
		if (color[i] == 0)
			++cnt;
		else
			--cnt;
	}

	if (cnt > 0)
		std::cout << "Fennec" << std::endl;
	else
		std::cout << "Snuke" << std::endl;
		
}


Measured memory_bytes: 7168
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    set <intt> s;
    intt n, x;
    cin >> n;
    while (n --) cin >> x, s.insert (x);
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
<?php

list($n,$k) = explode(" ",trim(fgets(STDIN)));

$m = array();
$i=0;
while($i < $n){
list($a,$b) = explode(" ",trim(fgets(STDIN)));

if(isset($m[$a])){
$m[$a] += $b;
}else{
$m[$a] = $b;
}

++$i;
}

ksort($m);
foreach($m as $key => $val){
if($val >= $k){
echo $key;
break;
}else{
$k -= $val;
}
}

Measured memory_bytes: 14324
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        int n = s.size();
        if (s[n - 1] == 's')
            cout << s << "es" << '\n';
        else
            cout << s << "s" << '\n';
        
    }
    
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  bool ans = false;
  for(int i = 0; i <= n / 4; i++){
    for(int j = 0; j <= n / 7; j++){
      if(i * 4 + j * 7 == n){
        ans = true;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}
//小文字=大文字+32
int main() {
	int n,m;
	cin >> n>>m;
	vector<pair<int,int>>a(m);
	ll mati=0;
	ll ans=0;
	rep(i, m) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a.begin(), a.end());
	rep(i, m) {
		if (a[i].second >= mati) {
			mati = a[i].first;
			ans++;
		}
	}
	cout << ans;

}


Measured memory_bytes: 4040
N = int(input())
nums = input().split(" ")
nums2 = [int(x)-i-1 for i,x in enumerate(nums)]
nums2.sort()
length = len(nums2)
numpre = 0
same = 1
if length == 1:
  value = nums2[0]
 
for n,m in zip(nums2[:-1],nums2[1:]):
  if n == m:
    same += 1
  else:
    impact = same + numpre
    if impact > length-impact:
      value = n
      break
    numpre += same
    same = 1
  value = m
 
answer = 0
for i in nums2:
  answer += abs(i-value)
print(answer)

Measured memory_bytes: 28936
#include<bits/stdc++.h>
using namespace std;
long double SIN(long double p) { return sin(p*acos(-1) / 180.0l); }
int main() {
	while (true) {
		int n; cin >> n; if (n == 0)break; if (n % 3 == 0)n /= 3;
		long double D = sqrtl(3.0l)*(SIN(60.0l + 60.0l / n) / (SIN(60.0l + 60.0l / n) + SIN(60.0l / n))) - sqrtl(0.75l);
		printf("%.114Lf\n", sqrtl(0.25l + D*D)*SIN(60.0l / n)*n);
	}
	return 0;
}

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

char s[100][101];

int orde(const void* a, const void* b){

    return strcmp(a,b);
    /*
    const char *x = a, *y = b;

    if (x[0] < y[0])
        return -1;
    if (x[0] > y[0])
        return 1;

    return 0;
*/
}

int cmpindice(const void* a, const void* b){

    const int * x = a, *y = b;

    return strcmp(s[*x], s[*y]);


}

int main(){

    int n, l;

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

    
    int indice[n];

    for (int i = 0; i < n; i++){
        scanf(" %s", s[i]);
        indice[i] = i;
    }

    //qsort(s,n,sizeof(s[0]), orde);
    qsort(indice, n, sizeof(indice[0]), cmpindice);

    for (int i = 0; i < n; i++)
        printf("%s", s[indice[i]]);

    printf("\n");

return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	int t[102];
	int sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&t[i]);
		sum+=t[i];
	}
	int m;
	scanf("%d",&m);
	int p[102],x[102];
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&p[i],&x[i]);
		p[i]--;
	}
	for(i=0;i<m;i++)
	  printf("%d\n",sum-t[p[i]]+x[i]);
	return 0;
}

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

int main(){
  int A,B,K ;
  cin >> A >> B >>K ;
  int ans ;
  int i = 0 ;
  if(A >= B){
    ans = A ;
    while(i<K){
      if(A % ans == 0 && B % ans == 0){
        i ++;
        ans --;
      }
      else{
        ans --;
      }
    }
    cout << ans+1 << endl ;
  }
  else if(A < B){
    ans = B ;
    while(i<K){
      if(A % ans == 0 && B % ans == 0){
        i ++;
        ans --;
      }
      else{
        ans --;
      }
    }
    cout << ans+1 << endl ;
  }
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int M, D; cin >> M >> D;
    int ans = 0;
    for(int i = 4; i <= M; i++) {
        for(int j = 22; j <= D; j++) {
            int d1 = j%10;
            int d10 = j/10;
            if(d1 < 2 || d10 < 2) continue;
            if(d1*d10 == i) ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 
  int N=0;
  scanf("%d",&N);
 
  int save=0;
  int max=0;
  int all=0;
  for(int i=0;i<N;i++){
    scanf("%d",&save);
   
    if(max<save)max=save;
   
    all+=save;
  }
  max=max/2;
  all-=max;
  printf("%d",all);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    string s; cin >> s;
    int n = s.size();
    int count = 0;
    string str = "", pre_str = "";
    rep(i, n){
        str += s[i];
        if(str != pre_str){
            count++;
            pre_str = str;
            str = "";
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int S1;
	int h,m,s;
	cin>>S1;
	h=S1/3600;
	s=S1%60;
	int a;
	a=S1-s-h*3600;
	m=a/60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

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


int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	vector<int> lst;

	rep(i,a+1){
	    rep(j,b+1){
	        rep(k,c+1){
	            lst.push_back(i*500 + j*100 + k*50);
	        }
	    }
	}

	int n = lst.size(), cnt = 0;
	rep(i,n) if(lst[i] == x) cnt++;
	cout << cnt << endl;
}


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

int main(){
    bool z = true;
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n + 1);
    vector<ll> vert(n + 1);//ある深さの頂点の個数
    vector<ll> leaves(n + 2, 0);//ある深さから深さnまでの葉の枚数
    rep(i, n + 1) cin >> a[i];
    rep(i, n + 1) leaves[i] = a[i];
    for (ll i = n; i >= 0;i--){
        leaves[i] += leaves[i + 1];
    }
    vert[0] = 1;
    rep (i,n){
        if(vert[i]<=a[i]){//条件を満たす二分木が存在するかどうか
            z = false;
            break;
        }
        vert[i+1] = min((vert[i] - a[i]) * 2, leaves[i+1]);//深さ i の頂点のうち葉ではないものの個数の2倍と深さi+1から深さnまでの葉の枚数のうちの小さい方
        ans += vert[i+1];
    }
    if(a[n]!=vert[n]) z = false;//n=0の時
    if (z) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


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

const int mod = 1000000007;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};




int main(int argc, const char * argv[]) {
    ll N;
    cin >> N;
    if(N%10==2 ||N%10==4 ||N%10==5 ||N%10==7 ||N%10==9 ){
        cout << "hon" << endl;
    }
    else if(N%10==0 ||N%10==1||N%10==6 ||N%10==8 ){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
    
    
   return 0;
}



Measured memory_bytes: 3636
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n;
    cin>>n;
    Vec a(n);
    cin>>a;
    ll cnt = 0;
    rep(i,n){
        if(i%2==1)continue;
        if(a[i]%2==1)cnt++;
    }
    out(cnt);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    solve();
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n,ans = 0; cin >> n;
    vector<int> h(n+1);
    rep(i,n) cin >> h[i];

    while(accumulate(h.begin(),h.end(),0) != 0){
        vector<int> H(n,1e5);
        int l,r;
        rep(i,n){
            if(h[i] != 0){
                l = i;
                break;
            }
        }
        for(int j = l+1;j<n+1;j++){
            if(h[j] == 0){
                r = j-1;
                break;
            }
        }
        if(l==r){
            ans += h[r];
            h[r] = 0;
        }else{
            int m = 0;
            for(int k = l;k < r + 1;k++){
                H[m] = h[k];
                m++;
            }
            sort(H.begin(),H.end());
            for(int p = l;p < r + 1;p++){
                h[p] -= H[0];
            }
            ans += H[0];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N;
	scanf("%lld",&N);

	long long ans=(N*(N+1)*(N+2))/6;

	for(int i=0;i<N-1;i++){
		long long u,v;
		scanf("%lld%lld",&u,&v);
		if(u>v)swap(u,v);

		ans-=u*(N-v+1);
	}

	printf("%lld",ans);

	return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        char c = scanner.next().toCharArray()[0];
        char n = (char) ((c - 'a' + 1) % 26 + 'a');
        System.out.println(n);
    }

}



Measured memory_bytes: 23892
N, M, K = [int(i) for i in input().split()]

array_A = [int(i) for i in input().split()]
array_B = [int(i) for i in input().split()]

array_A_2 = [0]
array_B_2 = [0]

for a in array_A:array_A_2.append(array_A_2[- 1]+a)
for b in array_B:array_B_2.append(array_B_2[- 1]+b)

output, j = 0, M

for i in range(N + 1):
    if array_A_2[i] > K:
        break
    while array_B_2[j] > K - array_A_2[i]:
        j -= 1
    output = max(output, i + j)

print(output)

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

int main() {

int N;
  cin >> N;
  int a;
  a=N%10;
  if(a==3){
    cout << "bon" <<endl;
  }
  else if(a==0 || a==1 || a==6 || a==8){
    
    cout <<"pon" <<endl;
  }
  else{
    cout << "hon" <<endl;
}
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		sc.close();

		String one = s1.substring(0,1).toUpperCase();
		String two = s2.substring(0,1).toUpperCase();
		String three = s3.substring(0,1).toUpperCase();
		System.out.println(one + two + three);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;

const int M = 8005;

bitset<M*2> xbit,ybit;

int main(){

    string s;
    cin >> s;
    int x,y;
    cin >> x >> y;
    int len = s.length();

    int cnt = 0;
    while(cnt < len && s[cnt] == 'F'){
        cnt++;
    }
    //Mを初期位置とする
    xbit[M+cnt] = 1;
    ybit[M] = 1;
    int mode = 1;//x方向 or y方向

    int cc = 0;
    while(cnt <= len){
    
        if(s[cnt] == 'F'){
            cc++;
        }else{
            if(mode == 1){
                xbit = (xbit << cc) | (xbit >> cc);
            }else{
                ybit = (ybit << cc) | (ybit >> cc);
            }
            mode ^= 1;
            cc = 0;
        }
        cnt++;
    }

    if(xbit[M + x] & ybit[M + y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

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

int main() {
  int h,n,a,sum;
  cin >> h >> n;
  for(int i = 0; i < n; i += 1){
    cin >> a;
    sum += a;
  }
  if(h <= sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        String S = scanner.next();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            String s1 = S.substring(0,i);
            String s2 = S.substring(i,S.length());
            int count = 0;
            String s3 = "";
            for (int j = 0; j < s1.length(); j++) {
                char ch = s1.charAt(j);
                if (s2.indexOf(ch) != -1) {
                    if (s3.indexOf(ch) == -1) {
                        s3 += ch;
                    }
                }
            }
            count = s3.length();
            ans = Math.max(ans, count);
        }
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21460
// ※※※ 解答不能 ※※※
// 以下のソースを勉強する.
// niuez氏.
// https://atcoder.jp/contests/abc138/submissions/7007283
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;

LL dp[62][2][2][2];
LL dp2[62][2][2][2];

int main(){
  
    // 1. 入力情報取得.
    LL L, R;
    scanf("%lld %lld", &L, &R);
    L--, R++;
    
    // 2. dp更新.
    dp[61][0][0][0] = 1;
    for(LL d = 60; d >= 0; d--){
        for(LL flag = 0; flag <= 1; flag++){
            LL A = ((R >> d) & 1);
            LL B = ((L >> d) & 1);
            if(flag == 1) A = 1;
            for(LL next = 0; next <= A; next++){
                // LL nf = !!(next < A || flag);
                LL nf = !((next < A || flag) == 0);
                if(next == 0){
                    if(B == next){
                        dp[d][nf][0][0] += dp[d + 1][flag][0][0];
                        dp[d][nf][0][0] %= MOD;
                        dp[d][nf][1][0] += dp[d + 1][flag][1][0];
                        dp[d][nf][0][0] %= MOD;
                    }
                    dp[d][nf][1][1] += dp[d + 1][flag][1][1];
                    dp[d][nf][1][1] %= MOD;
                }else{
                    if(B == next){
                        dp[d][nf][1][0] += dp[d + 1][flag][0][0] + dp[d + 1][flag][1][0];
                        dp[d][nf][1][0] %= MOD;
                    }
                    if(B < next){
                        dp[d][nf][1][0] += dp[d + 1][flag][1][0];
                        dp[d][nf][1][0] %= MOD;
                        dp[d][nf][1][1] += dp[d + 1][flag][0][0] + dp[d + 1][flag][1][0];
                        dp[d][nf][1][1] %= MOD;
                    }
                    dp[d][nf][1][1] += dp[d + 1][flag][1][1] * 2;
                    dp[d][nf][1][1] %= MOD;
                }
            }
        }
    }
    // 3. 出力 ～ 後処理.
    printf("%lld\n", dp[0][1][1][1]);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
const int N = 3000;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    vector<vector<int>> o_count(h, vector<int>(w));
    vector<vector<int>> i_count(w, vector<int>(h));
    for(int i = 0; i < h; i++) {
        cin >> g[i];
        for(int j = 0; j < w; j++) {
            o_count[i][j] = (j ? o_count[i][j - 1] : 0) + (g[i][j] == 'O');
            i_count[j][i] = (i ? i_count[j][i - 1] : 0) + (g[i][j] == 'I');
        }
    }
    ll ans = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(g[i][j] == 'J') {
                ans += (o_count[i][w - 1] - o_count[i][j]) * (i_count[j][h - 1] - i_count[j][i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 83720
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[110];
char T[110];
int main(){
	scanf("%s%s",S,T);
	for(int i=0;S[i];i++){
		if(S[i]!=T[i]){
			printf("No\n");return 0;
		}
	}
	printf("Yes\n");
}


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

#define ull unsigned long long
#define ll long long

using namespace std;

int x[200010];

int main(){
    int k,n;
    scanf("%d %d",&k,&n);
    if(k<=n){
        printf("unsafe");
    }
    else{
        printf("safe");
    }
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int bar[3] = {2,1,0};

int mul[3][3] = {
	{0,0,0},
	{0,1,1},
	{0,1,2}
};

int add[3][3] = {
	{0,1,2},
	{1,1,2},
	{2,2,2}
};

string s;
int PQR[3];

bool isvar(char c) { return (c - '0' >= 0 && c - '0' <= 2) || (c - 'P' >= 0 && c - 'P' <= 2); }
int getvar(char c) {
	if (0 <= c - '0' && c - '0' <= 2) return c - '0';
	return PQR[c - 'P'];
}

int rec(int lft, int rgt) {
	//cerr << s.substr(lft, rgt-lft) << endl;
	int open_cnt = 0, close_cnt = 0, bar_cnt = 0;
	int nxt_lft = -1;
	
	stack< int > st;
	stack< char > op;
	for_(i,lft,rgt) {
		if (open_cnt == close_cnt && s[i] == '-') {
			++bar_cnt;
		}
		
		if (open_cnt == close_cnt && isvar(s[i])) {
			int x = getvar(s[i]);
			for_(rep,0,bar_cnt) x = bar[x];
			st.push(x);
			bar_cnt = 0;
		}
		
		if (open_cnt == close_cnt && s[i] == '*') op.push('*');		
		if (open_cnt == close_cnt && s[i] == '+') op.push('+');
		
		if (s[i] == '(') {
			if (open_cnt == close_cnt) nxt_lft = i+1;
			++open_cnt;
		}
		
		if (s[i] == ')') {
			++close_cnt;
			if (open_cnt == close_cnt) {
				int x = rec(nxt_lft, i);
				for_(rep,0,bar_cnt) x = bar[x];
				st.push(x);
				bar_cnt = 0;
			}
		}
		
		if (st.size() >= 2 && !op.empty()) {
			char opr = op.top(); op.pop();
			int x = st.top(); st.pop();
			int y = st.top(); st.pop();
			if (opr == '*') st.push(mul[x][y]);
			if (opr == '+') st.push(add[x][y]);
		}
	}
	
	return st.top();
}

int main() {
	while (cin >> s) {
		if (s == ".") break;
		int ans = 0;
		for_(p,0,3) for_(q,0,3) for_(r,0,3) {
			PQR[0] = p; PQR[1] = q; PQR[2] = r;
			if (rec(0, s.size()) == 2) ++ans;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int n,k,s;
int main()
{
	scanf("%d%d%d",&n,&k,&s);
	for(int i = 1;i <= k;i++)
	{
		printf("%d ",s);
	}
	for(int i = k + 1;i <= n;i++)
	{
		if(s == 1000000000)printf("1 ");
		else printf("%d ",s + 1);
	}
	return 0;
}

Measured memory_bytes: 1280
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int a, b;
    std::cin >> a >> b;
    std::cout << std::max({a + b, a - b, a * b}) << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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


def solve(N: int, A: "List[int]", Q: int, B: "List[int]", C: "List[int]"):
    from collections import defaultdict
    X = defaultdict(int)
    for a in A:
        X[a] += 1
    ret = sum(A)
    for b, c in zip(B, C):
        ret -= b * X[b]
        ret += c * X[b]
        X[c] += X[b]
        del X[b]
        print(ret)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = int(next(tokens))  # type: int
    B = [int()] * (Q)  # type: "List[int]"
    C = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, A, Q, B, C)

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 30112
#include <iostream>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int matri[m*n];
    int row_sum[m]={0};
    int col_sum[n]={0};
    int sum=0;
    for(int i=0;i<m*n;i++)
        cin>>matri[i];
    for(int i=0;i<m;i++)
    {
        {for(int j=0;j<n;j++) {
                cout << matri[i * n + j] << " ";
                row_sum[i] += matri[i * n + j];
            }
        }
        sum+=row_sum[i];
        cout<<row_sum[i]<<endl;
    }
    for(int i=0;i<n;i++)
    {    for(int j=0;j<m;j++)
        {
            col_sum[i]+=matri[i+j*n];
        }
        cout<<col_sum[i]<<" ";

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;
int main() {
    // 配列を受け取る
    int n;
    cin >> n;
    int A[n], B[n];
    for (int i=0;i<n;i++) {
        cin >> A[i];
    }
    for (int i=0;i<n;i++) {
        cin >> B[i];
    }

    int D1=0;
    for (int i=0;i<n;i++) {
        D1+=abs(A[i] - B[i]);
    }
    printf("%d\n", D1);

    int D2=0;
    for (int i=0;i<n;i++) {
        D2+=pow(A[i] - B[i], 2.0);
    }
    printf("%f\n", pow(D2, 0.5));

    long int D3=0;
    for (int i=0;i<n;i++) {
        D3+=pow(abs(A[i] - B[i]), 3.0);
    }
    printf("%f\n", pow(D3, 1.0/3.0));

    int max=0;
    for (int i=0;i<n;i++) {
        if (abs(A[i] - B[i]) > max) {
            max = abs(A[i] - B[i]);
        }
    }
    printf("%d\n", max);
}


Measured memory_bytes: 3340
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;


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

	int win=0;
	string S;

	cin >> S;

	REP(i, S.length())
	{
		if (S[i] == 'o')	win++;
	}

	if (win + (15 - S.length()) >= 8)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

	int num[N];
	void main()
	{
		memset(num,0x3f,sizeof num);
		int n=qread();
		for(int i=1;i<=n-1;i++){
			int tmp=qread();
			chmin(num[i],tmp);chmin(num[i+1],tmp);
		}
		int ans=0;for(int i=1;i<=n;i++) ans+=num[i];write(ans) ;
	}
};
int main()
{
	srand(time(0));
	mine::main();
}

Measured memory_bytes: 4096
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 555;

int n;
int c;

int main () {
    scanf("%d%d" , &n , &c);
    for(int x = 0; x <= 10000; x++){
        for(int y = 0; y <= 10000; y++){
                int z = (c/1000) - (10*x + 5*y);
                if(x + y + z != n)
                    continue;
                if(10*x + 5*y + 1*z == c/1000 && z >= 0){
                    printf("%d %d %d\n" , x , y , z);
                    return 0;
                }
        }
    }
    puts("-1 -1 -1");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(b-c)<=d))) printf("Yes\n");
        else printf("No");
        return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vi d(n); rep(i,n) cin >> d[i];
    int cnt = 0;
    rep(i,n) {
        rep(j,n) {
            if(i == j) continue;
            cnt += d[i]*d[j];
        }
    }

    cout << cnt/2 << '\n';
}

Measured memory_bytes: 256
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int N,M;
int c[MAXN];
int dp[MAXN];

void work(){
    while(~scanf("%d%d",&N,&M)){
        memset(dp,INF,sizeof(dp));
        dp[0]=0;
        for(int i=1;i<=M;i++){
            scanf("%d",&c[i]);
            for(int j=c[i];j<=N;j++){
                dp[j]=min(dp[j],dp[j-c[i]]+1);
            }
        }
        printf("%d\n",dp[N]);
    }
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<cstring> 
using namespace std;
char c[11];
int main()
{
	scanf("%s",c);
	int len=strlen(c);
	if(len<4||c[0]!='Y'||c[1]!='A'||c[2]!='K'||c[3]!='I') printf("No");
	else printf("Yes");
	return 0;
}

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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    ll x, y;
    cin >> x >> y;
    ll ans;
    if (x > y) {
        if (x < 0)
            ans = 2 + abs (x - y);
        else {
            ans = min (1 + abs (y + x), 2 + abs (y - x));
        }
    }
    else {
        ans = y - x;
        if (x <= 0 && y >= 0)
            ans = min (ans, 1 + abs (x + y));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628