akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

int main(){

    int h,w,a,b;
    cin >> h >> w >> a >> b;

    vector<ModInt> fact(1, ModInt(1, MODN));
    vector<ModInt> invfact(1, ModInt(1, MODN));

    rep(i, 200005){
        fact.pback(fact[i] * ModInt(i + 1, MODN));
    }

    rep(i, 200005){
        invfact.pback(ModInt(1, MODN) / fact[i + 1]);
    }

    function<ModInt(int, int)> combi = [&](int a, int b) -> ModInt{
        return fact[a] / fact[b] / fact[a - b];
    };

    int tmpy = h - a;
    int tmpx = b + 1;

    ModInt ans = ModInt(0, MODN);
    int k = 0;

    while(tmpy != 0 && tmpx <= w){

        //cerr << tmpy << " " << tmpx << endl;

        ModInt tmp = combi((tmpy - 1) + (tmpx - 1), min(tmpy - 1, tmpx - 1));
        tmp = tmp * combi((a + k) + (w - 1 - b - k), min(a + k, w - 1 - b - k));

        ans = ans + tmp;

        k++;
        tmpy--;
        tmpx++;
    }

    cout << ans.n << endl;
    
    return 0;
}

Measured memory_bytes: 12524
use std::io::Read;
fn main() {
    let (h,w,a,b)= {
        let inputstr = {
            let mut inputstr = String::new();
            std::io::stdin().read_to_string(&mut inputstr).unwrap();
            inputstr
        };
        let mut inputiter = inputstr.split_whitespace();
        (
            inputiter.next().unwrap().parse::<usize>().unwrap(),
            inputiter.next().unwrap().parse::<usize>().unwrap(),
            inputiter.next().unwrap().parse::<usize>().unwrap(),
            inputiter.next().unwrap().parse::<usize>().unwrap()
        )
    };
    let ans = (1..h+1).map(|y|{
        (1..w+1).map(|x|{
            if (x>a) ^ (y>b) {'1'} else {'0'}
        }).collect::<String>()
    }).collect::<Vec<_>>().join("\n");
    print!("{}",ans);
}


Measured memory_bytes: 7292
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

int main(void) {
	int i = 0, j = 0, num, mm, b;
	ll ans = 0;
	cin >> num >> mm;
	vector<int> d(num), c(mm);
	map<int, ll> mp;
	for (; i < num; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end());
	for (i = 0; i < mm; i++) {
		scanf("%d%d", &b, &c[i]);
		mp[c[i]] += b;
	}
	sort(c.begin(), c.end(), greater<int>());
	c.erase(unique(c.begin(), c.end()), c.end());
	for (i = 0, b = 0; i < num; i++) {
		if (j < c.size()) {
			ans += max(c[j], d[i]);
			mp[c[j]]--;
			if (mp[c[j]] == 0)
				j++;
		}
		else
			ans += d[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    ll n,a,b; cin >> n >> a >> b;
    ll x=n/(a+b);
    ll ans=0;
    ans+=x*a;
    ll res=n-x*(a+b);
    ans+=min(res,a);
    cout << ans << endl;
}




Measured memory_bytes: 3648
//============================================================================
// Name        : main.cpp
// Author      : nekoroko
// Version     : none
// Copyright   : Your copyright notice
// Description : AtCoder
//============================================================================
#include <iostream>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>

using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	vector<long long> A(N);
	vector<long long> rain(N);
	for(int i = 0; i < N; ++i){
		scanf("%lld", &A[i]);
	}

	long long rain1 = 0;
	for(int i = 0; i < N; ++i){
		if(i % 2 == 0)rain1 += A[i];
		else rain1 -= A[i];
	}
	rain[0] = rain1;

	for(int i = 1; i < N; ++i){
		rain[i] = 2 * (A[i - 1] - rain[i - 1] / 2);
	}

	for(int i = 0; i < N; ++i){
		printf("%lld ", rain[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
	long long int N, A, B, ans;
	cin >> N >> A >> B;

	if (N == 1) {
		if (A == B) ans = 1;
		else ans = 0;
	}
	else if (A > B) {
		ans = 0;
	}
	else {
		ans = 1 + (N - 2) * (B - A);
	}
	cout << ans << endl;
	system("pause");
}

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

int main(){
    int books, algo, know;
    cin >> books >> algo >> know;

    vector<int> cost;
    vector<vector<int>> each;
    
    cost.resize(books);
    each.resize(books, vector<int>());

    for(int i = 0; i < books; i++){
        cin >> cost[i];
        each[i].resize(algo);
        for(int j = 0; j < algo; j++){
            cin >> each[i][j];
        }
    }

   
    int price = INT_MAX;
 
    for(int buy = 1; buy <= (int)pow(2, books) - 1; buy++){
        int total = 0;
        int knowt[algo] = {0};

        for(int i = 0; i < books; i++){
            if((buy/(int)pow(2, i)) % 2 == 1){
                total += cost[i];
                for(int j = 0; j < algo; j++){
                    knowt[j] += each[i][j];
                }
            }
        }

        int minknow = knowt[0];
        for(int i = 1; i < algo; i++){
            minknow = min(minknow, knowt[i]);
        }

        if(minknow >= know){
            price = min(price, total);
        }

        
    }    

    if(price == INT_MAX){
         cout << -1 << endl;
    } else {
        cout << price << endl;
    }
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll long long
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define fd(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
const char* fin="1.in";
const char* fout="1.out";
const int inf=0x7fffffff;
const int mo=998244353;
const int maxn=1000007;
int n,m,ans,fact[maxn];
int qp(int a,int b){
	int c=1;
	while (b){
		if (b&1) c=1ll*c*a%mo;
		a=1ll*a*a%mo;
		b>>=1;
	}
	return c;
}
int inv(int x){return qp(x,mo-2);}
int C(int a,int b){return 1ll*fact[a]*inv(1ll*fact[b]*fact[a-b]%mo)%mo;}
int main(){
	scanf("%d%d",&n,&m);
	if (n>m) swap(n,m);
	fact[0]=1;
	fo(i,1,maxn-1) fact[i]=1ll*fact[i-1]*i%mo;
	fo(i,1,n) ans=(ans+1ll*C(i+i,i)*C(n-i+m-i,n-i))%mo;
	ans=1ll*ans*inv(2)%mo;
	ans=1ll*ans*inv(C(n+m,n))%mo;
	ans=(ans+m)%mo;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4224
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a, b, c = inpl()
k = inp()
FLAG = True
while k:
    if b > a:
        FLAG = False
        break
    b *= 2
    k -= 1
if FLAG:
    print("No")
    exit()
FLAG = True
while k:
    if c > b:
        break
    c *= 2
    k -= 1
if FLAG and c <= b:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 69008
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    cin >> N;
    if(N%2==1){
        int M=(N-1)*(N-1)/2;
        cout << M << endl;
        REP(i,N-1){
            REP(j,i){
                if(i+j+2!=N){
                    cout << j+1 <<" " << i+1 << endl;
                }
            }
        }
        REP(i,N-1){
            cout << i+1 << " " << N << endl;
        }
    }else{
        int M=N*(N-2)/2;
        cout << M << endl;
        REP(i,N){
            REP(j,i){
                if(i+j+2!=N+1){
                    cout << j+1 <<" " << i+1 << endl;
                }
            }
        }
        
    }
    
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    REP (i, 10) {
        REP (k, 10) {
            if (i * k == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

string divide[4]={"dream","dreamer","erase","eraser"};
bool dp[100005];

signed main()
{
    string s; cin>>s;
    int N=s.size();

    dp[0]=1;
    REP(i,N){
        if(!dp[i]) continue;
        for(string div:divide){
            if(s.substr(i,div.size())==div){
                dp[i+div.size()]=1;
            }
        }
    }
    cout<<(dp[N]? "YES":"NO")<<endl;
    
}


Measured memory_bytes: 512
n, k = map(int, input().split())
E = list(map(lambda x: (x + 1) * 0.5, list(map(int, input().split()))))
e = sum(E[:k])
emax = e
for i in range(k, n):
    e += E[i] - E[i - k]
    emax = max(e, emax)
print(emax)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[]) {
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt","r",stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long a,v;
    cin>>a>>v;
    long long b,w;
    cin>>b>>w;
    long long t;
    cin>>t;
    long long dist=abs(a-b);
    if((v-w)*t>=dist) cout<<"YES"<<endl; 
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	const int MAX=301;
	int N,M;
	cin>>N>>M;
	int A[MAX][MAX]={};
	bool spo[MAX]={};
	int ans=INF;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin>>A[i][j];
			A[i][j]--;
		}
	}
	for(int s=M;s>0;s--){
		int peo[MAX]={};
		int maxi=0;
		//一番人気のスポーツはどれか
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				if(spo[A[i][j]]==0){
					peo[A[i][j]]++;
					break;
				}
			}
		}
		int fav=0;
		for(int i=0;i<M;i++){
			if(maxi<peo[i]){
				maxi=peo[i];
				fav=i;
			}
		}
		ans=min(ans,maxi);
		spo[fav]=1;
		//cout<<fav<<" "<<maxi<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
from collections import deque

n = int(input())
a = map(int, input().split())

b = deque()
for i, k in enumerate(a):
    b.append(k) if i % 2 == 0 else b.appendleft(k)

print(' '.join(map(str, b))) if n % 2 == 0 else print(' '.join(map(str, reversed(b))))

Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;

    for(int i=a; i<=b; i++){
        if(c % i == 0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3064
import sys

H, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for n in range(N)]

dp = [sys.maxsize for i in range(H+1)]
dp[0] = 0

# 各ダメージ段階の最小値を求める
for i in range(H):
    if dp[i] == sys.maxsize:
        continue
    # 各魔法を使って最小値なら更新
    for j in range(N):
        a = min(i + AB[j][0], H)
        b = dp[i] + AB[j][1]
        if dp[a] > b:
            dp[a] = b

print(dp[H])


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

bool isPal(string s){
    for(ll i=0,j=s.size()-1;i<j;i++,j--){
        if(s[i] != s[j])
            return false;
    }
    return true;
}

void solve(){
    string s;
    cin>>s;
    ll n = s.size();
    bool flg = isPal(s);
    s = ' ' + s;
    string a , b;
    for(ll i=1;i<=(n-1)/2;i++)
        a += s[i];
    //cout << a << ' ';
    for(ll i=(n+3)/2;i<=n;i++)
        b += s[i];
    //cout << b;
    if(isPal(a) and isPal(b) and flg )
        cout << "Yes";
    else cout << "No";
}

int main(){
    
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll ans[2];
    int l, r;
    int lv, rv, cnt = 0;
    bool mins = true;
    vector<int> nv(2), diff(2);
    if (n == 2) {
        cout << (a[1] - a[0]) << endl;
        return 0;
    }
    rep(i, 2) {
        l = 0; r = n - 1;
        ans[i] = 0;
        if (i == 0) {
            mins = true;
            ans[i] += abs(a[n - 1] - a[0]);
            ans[i] += abs(a[n - 2] - a[0]);
            lv = a[n - 2];
            rv = a[n - 1];
            l++;
            r -= 2;
        }
        else {
            mins = false;
            ans[i] += abs(a[0] - a[n - 1]);
            ans[i] += abs(a[1] - a[n - 1]);
            lv = a[0];
            rv = a[1];
            l += 2;
            r--;
        }
        cnt = 3;
        while(cnt < n) {
            if ((cnt + 1) == n) {
                ans[i] += max(abs(lv - (mins ? a[l] : a[r])), abs(rv - (mins ? a[l] : a[r])));
                cnt++;
                break;
            }
            if (mins) {
                nv[0] = a[l];
                nv[1] = a[l + 1];
                l += 2;
            }
            else {
                nv[0] = a[r];
                nv[1] = a[r - 1];
                r -= 2;
            }
            cnt += 2;
            diff[0] = abs(nv[0] - lv) + abs(nv[1] - rv);
            diff[1] = abs(nv[1] - lv) + abs(nv[0] - rv);
            lv = nv[0];
            rv = nv[1];
            ans[i] += max(diff[0], diff[1]);
            mins = !mins;
        }
    }
    
    cout << max(ans[0], ans[1]) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

// class Radix {
//    private:
//     const char* s;
//     int a[128];

//    public:
//     Radix(const char* s = "abcdefghijklmnopqrstuvwxyz") : s(s) {
//         int i;
//         for (i = 0; s[i]; ++i) a[(int)s[i]] = i;
//     }
//     std::string to(long long p, int q) {
//         int i;
//         if (!p) return "0";
//         char t[64] = {};
//         for (i = 62; p; --i) {
//             t[i] = s[p % q];
//             p /= q;
//         }
//         return std::string(t + i + 1);
//     }
//     std::string to(const std::string& t, int p, int q) {
//         return to(to(t, p), q);
//     }
//     long long to(const std::string& t, int p) {
//         int i;
//         long long sm = a[(int)t[0]];
//         for (i = 1; i < (int)t.length(); ++i) sm = sm * p + a[(int)t[i]];
//         return sm;
//     }
// };

string to_name(ll num) {
    if (num < 1) return "";

    return to_name((num - 1) / 26) + (char)('a' + ((num - 1) % 26));
}

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

    cout << to_name(N) << endl;

    // Radix r;
    // cout << r.to(N - 1, 26) << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 1000000007

vector<ll> ab;
vector<ll> abc;

int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >>k;
  ll a[1010]={0},b[1010]={0},c[1010]={0};
  rep(i,x){
    cin >>a[i];
  }
  rep(i,y){
    cin >> b[i];
  }
  rep(i,z){
    cin >> c[i];
  }
  ll da[1010]={0},db[1010]={0},dc[1010]={0};
  sort(a,a+x,greater<ll>());
  rep(i,x){
    da[i]=a[0]-a[i];
  }
  sort(b,b+y,greater<ll>());
  rep(i,y){
    db[i]=b[0]-b[i];
  }
  sort(c,c+z,greater<ll>());
  rep(i,z){
    dc[i]=c[0]-c[i];
  }
  ll it=0,tmp=0,tmp2=0;
  rep(i,x){
    rep(j,y){
      if(it>=3000){
        if(tmp>da[i]+db[j]){
          ab.push_back(da[i]+db[j]);
          if(tmp2<da[i]+db[j]){
            tmp=tmp2;
            tmp2=da[i]+db[j];
          }
        }
      }else{
        ab.push_back(da[i]+db[j]);
        if(tmp<da[i]+db[j]){
          tmp2=tmp; //second greatest
          tmp=da[i]+db[j];
        }
        it++;
      }
    }
  }
  sort(ALL(ab));
  ll res=3000;
  if(ab.size()<3000)res=ab.size();
  it=tmp=tmp2=0;
  rep(i,res){
    rep(j,z){
      if(it>=3000){
        if(tmp>ab[i]+dc[j]){
          abc.push_back(ab[i]+dc[j]);
          if(tmp2<ab[i]+dc[j]){
            tmp=tmp2;
            tmp2=ab[i]+dc[j];
          }
        }
      }else{
        abc.push_back(ab[i]+dc[j]);
        if(tmp<ab[i]+dc[j]){
          tmp2=tmp; //second greatest
          tmp=ab[i]+dc[j];
        }
        it++;
      }
    }
  }
  sort(ALL(abc));
  ll max=a[0]+b[0]+c[0];
  rep(i,k){
    cout << max-abc[i] <<endl;
  }

}


Measured memory_bytes: 43236
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[4];
  a[0] = n/1000;
  n %= 1000;
  a[1] = n/100;
  n %= 100;
  a[2] = n/10;
  n %= 10;
  a[3] = n;
  int i;
  int ans = 0;
  for(i = 0;i < 4;++i){
    if(a[i] == 2){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
const ll MOD=998244353;

ll dp[3024][3024];
void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    dp[0][0]=1;
    dp[1][0]=b; dp[1][1]=a;
    repi(i,2,d-b+1){
        dp[1][i]=dp[1][i-1]*a%MOD;
    }
    repi(i,2,c-a+1){
        ll sum=0;
        rp(j,d-b+1){
            if(j==0){
                dp[i][0]=dp[i-1][0]*b%MOD;
                continue;
            }
            sum+=dp[i-1][j-1];
            sum%=MOD;
            sum*=a+i-1;
            sum%=MOD;
            dp[i][j]=sum+dp[i-1][j]*(b+j);
            dp[i][j]%=MOD;
        }
    }
    ll pre=0;
    rp(i,d-b){
        pre+=dp[c-a][i];
        pre%=MOD;
        pre*=c;
        pre%=MOD;
    }
    ll ans=pre+dp[c-a][d-b];
    ans%=MOD;
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

using ll = long long;
const ll INF = 1LL << 50;

int main(){

  int n,m;
  cin >> n >> m;

  const int nmax = 1001;
  const int mmax = 2001;
  int a[mmax],b[mmax];
  ll c[mmax];

  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }

  ll d[nmax];

  for(int i=0; i<=n; i++){
    d[i] = INF;
  }

  d[1] = 0;

  for(int loop = 0; loop < n-1; loop++){
    for(int i=0; i<m; i++){
      if(d[a[i]] == INF){
        continue;
      }
      if(d[b[i]] > d[a[i]] + c[i]){
        d[b[i]] = d[a[i]] + c[i];
      }
    }
  }

  ll ans = d[n];

  bool negative[nmax];

  for (int i = 0; i <= n; ++i) {
    negative[i] = false;
  }

 for (int loop = 0; loop < n ; ++ loop) {
  for (int i = 0; i < m; ++i) {
    if (d[a[i]] == INF) continue;
    if (d[b[i]] > d[a[i]] + c[i]) {
      d[b[i]] = d[a[i]] + c[i];
      negative[b[i] ] = true;
    }

    if (negative[a[i]] == true) {
      negative[b[i]] = true;
    }
 }
}

if(negative[n]){
  cout << "inf" << endl;
}
else{
  cout << -ans << endl;
}
  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a[400][400];
  int N, i, j, k, x, y, left, right, front, back;
  int n[201], d[201];
  while (1) {
    scanf("%d", &N);
    if (N == 0) return 0;
    
    for (i = 1; i < N; i++)
      scanf("%d%d", &n[i], &d[i]);
    for (i = 0; i < 400; i++)
      for (j = 0; j < 400; j++)
	a[i][j] = -1;

    a[200][200] = 0;
    for (i = 1; i < N; i++) {
      for (k = 0; k < 400; k++)
	for (j = 0; j < 400; j++)
	  if (a[j][k] == n[i]) goto loop_end;
    loop_end: ;
      x = k;
      y = j;
      if (d[i] == 0) a[y][x - 1] = i;
      else if (d[i] == 1) a[y + 1][x] = i;
      else if (d[i] == 2) a[y][x + 1] = i;
      else a[y - 1][x] = i;
    }

    for (j = 0; j < 400; j++)
      for (i = 0; i < 400; i++)
	if (a[i][j] != -1) {
	  left = j;
	  break;
	}

    for (i = 0; i < 400; i++)
      for (j = 0; j < 400; j++)
	if (a[i][j] != -1) {
	  front = i;
	  break;
	}

    for (j = 399; j >= 0; j--)
      for (i = 399; i >= 0; i--)
	if (a[i][j] != -1) {
	  right = j;
	  break;
	}

    for (i = 399; i >= 0; i--)
      for (j = 399; j >= 0; j--)
	if (a[i][j] != -1) {
	  back = i;
	  break;
	}

    printf("%d %d\n", left - right + 1, front - back + 1);
  }
}

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

int n , k, r , s, p;
template<class T> inline int janken (T& a, T b){
	if (b == 'r'){
		a = 'p';
		return p;
	} else if (b == 's'){
		a = 'r';
		return r;
	} else {
		a = 's';
		return s;
	}
}
int main()
{
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	string ans = t;
	int res = 0;
	for (int i = 0; i < n; i++){
		if (i >= k){
			char c;
			int tmp;
			tmp = janken(c, t[i]);
			if (ans[i-k] != c) ans[i] = c;
			else {
				ans[i] = 'x';
				tmp = 0;
			}
			res += tmp;
		} else {
			res += janken(ans[i], t[i]);
		}
	}
	cout << res << endl;
}


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

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

   }
  int m,n;
  m=1;
  for(i=0;i<2;i++)
   {    n=2;
       for(j=0;j<3;j++)
       {
        b[i][j]=a[m][n];
        n--;
       }
       m--;
   }
    for(i=0;i<2;i++)
   {
      for(j=0;j<3;j++)
      {
        if(a[i][j]!=b[i][j])
        {cout<<"NO";
            exit(0);
      }
      }
   }
       cout<<"YES";

    return 0;
}


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

int main()
{
	int P,Q,R,X,Y,Z;
	cin >> P >> Q >> R;
	X=P+Q;
	Y=Q+R;
	Z=R+P;
	cout << min(min(Y,Z),min(X,Y));
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<bool> w_seen(f / 100 + 1, false);
  vector<bool> s_seen(f + 1, false);

  vector<int> w;
  vector<int> s;

  queue<int> que;
  que.push(0);
  while(!que.empty())
  {
    int now = que.front();
    que.pop();

    if (now > f / 100) continue;
    if (w_seen[now]) continue;

    w_seen[now] = true;
    w.emplace_back(now);
    que.push(now + a);
    que.push(now + b);
  }

  que.push(0);
  while(!que.empty())
  {
    int now = que.front();
    que.pop();

    if (now > f) continue;
    if (s_seen[now]) continue;

    s_seen[now] = true;
    s.emplace_back(now);
    que.push(now + c);
    que.push(now + d);
  }

  // sort(ALL(w));
  // sort(ALL(s));

  int ans_sw = 100;
  int ans_s = 1;
  for(const auto& wv : w)
  for(const auto& sv : s)
  {
    if (wv * e < sv) continue;

    int sw = wv * 100 + sv;
    if (sw > f) continue;

    if (ans_s * sw <= sv * ans_sw)
    {
      ans_s = sv;
      ans_sw = sw;
    }
  }

  cout << ans_sw << " " << ans_s;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int x=a+b,y=b+c,z=c+a;
	if(x <= y && x <= z)
		{printf("%d",x);}
	else if( y <= x && y <= z)
		{printf("%d",y);}
	else
		{printf("%d",z);}
	return 0;
}


Measured memory_bytes: 128
# num = int(input())
# h, w = list(map(int, input().split()))
# arr = list(map(int, input().split()))

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

new_list_reverse = sorted(org_list, reverse=True)

print(sum(new_list_reverse[:k]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
using namespace std;

int main() {
    nl // Lofi songs		
    int a, b;
    cin >> a >> b;

    if(a>=13) cout << b;
    else if(a>=6 && a<= 12) cout << b/2;
    else cout << 0;
}	


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 100005;
int p[N];
int find(int x)
{
	if(p[x] == x)	return x;
	return find(p[x]);
}
int main()
{
	int n,q;cin >> n >> q;
	while(n && q)
	{
		long long res = 0;
		p[1] = 1;
		for(int i = 2;i <= n;++i)
			cin >> p[i];
		for(int i = 0;i < q;++i)
		{
			char op;int x;
			cin >> op >> x;
			if(op == 'M') p[x] = x;
			else res += (long long)find(x);
		}
		cout << res << endl;
		cin >> n >> q;
	}
	return 0;
}


Measured memory_bytes: 3468
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
      int n,m,c;
      {
	  	var p = Console.ReadLine().Split().Select(i=>int.Parse(i)).ToArray();
        n=p[0];
        m=p[1];
        c=p[2];
      }
      int s = 0;
      int[] b = Console.ReadLine().Split().Select(i=>int.Parse(i)).ToArray();;
      for(int i = 0;i<n;i++)
      {
        var p = Console.ReadLine().Split().Select(j=>int.Parse(j)).Select((v,j)=>new{v,ind=j}).ToArray();
        if(p.Sum(v=>v.v*b[v.ind]) + c > 0)
        	s++;
        
      }
      Console.WriteLine(s);
	}
}

Measured memory_bytes: 13396
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int h, w;
    char s[55][55];
    bool ans = true;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                if ((i - 1 >= 0 && s[i - 1][j] == '.') && (i + 1 >= 0 && s[i + 1][j] == '.') && (j - 1 >= 0 && s[i][j - 1] == '.') && (j + 1 >= 0 && s[i][j + 1] == '.')) ans = false;
            }
        }
    }
    if (ans)Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m,v;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m>>v;
    cout << v<<" "<<n<<" "<<m << "\n";
}


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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int64_t ans = vec.at(0);
  if(N != 1){
  for(int j=1; j<N; j++){
    if(ans %vec.at(j) != 0){
      for(int64_t k=1; k<1000000000000000000; k++){
        if(ans*k %vec.at(j) == 0){
          ans = ans*k;
          break;
        }
      }
    }
   }
  }
  cout << ans << endl;     
}

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

#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 INF 1e9

vector<int> dp(100600, 0);

int main(){
  int X;
  cin >> X;
  dp[0] = 1;
  REP(i, X){
    if(dp[i] != 0){
      REP(j, 6){
        dp[i+100+j] = 1;
      }
    }
  }
  if(dp[X]){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        if (x-500*i-100*j) % 50 == 0 and 0 <= (x-500*i-100*j) // 50 <= c:
            ans += 1
print(ans)

Measured memory_bytes: 3060
import bisect

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for i in range(N):
    x=bisect.bisect_left(A,B[i])
    y=N-bisect.bisect_right(C,B[i])
    ans+=x*y
print(ans)


Measured memory_bytes: 29488
#include <iostream>

int Area( int height, int width )
{
    return height * width;
}

int Circumference( int height, int width )
{
    return ( height + width ) * 2;
}

int main()
{
    int height, width;
    std::cin >> height >> width;

    std::cout
        << Area( height, width ) << " "
        << Circumference( height, width )
        << std::endl;
    return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<int> p(n);
  vector<int> q(n);
  int i;
  for(i=0;i<n;i++)cin>>p.at(i);
  for(i=0;i<n;i++)cin>>q.at(i);
  vector<int> num(n);
  for(i=0;i<n;i++)num.at(i)=i+1;
  int count=0;
  int nump=-1;
  int numq=-1;
  do
  {
    count++;
    bool samep=true;
    bool sameq=true;
    for(i=0;i<n;i++)
    {
      if(num.at(i)!=p.at(i))samep=false;
      if(num.at(i)!=q.at(i))sameq=false;
    }
    if(samep){nump=count;}
    if(sameq){numq=count;}
  }while(next_permutation(num.begin(),num.end()));
  cout<<abs(nump-numq)<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let residual = a.iter().skip(2).fold(0, |s, &x| s ^ x);
    let mut a2 = a[0] + a[1];

    let max_bit = 43;
    let mut cands = vec![-1; max_bit];
    for i in (0..max_bit).rev() {
        if (residual >> i) & 1 == 0 {
            if a2 >= 1 << (i + 1) {
                cands[i] = 1;
                a2 -= 1 << (i + 1);
            } else if a2 >= 1 << i {
                cands[i] = 0;
            } else {
                cands[i] = 0;
            }
        } else {
            if a2 >= 1 << (i + 1) {
                a2 -= 1 << i;
            } else if a2 >= 1 << i {
                a2 -= 1 << i;
            } else {
                println!("-1");
                return;
            }
        }
    }
    if a2 > 0 {
        println!("-1");
        return;
    }
    debug!(cands);
    let mut a0 = 0;
    for i in (0..max_bit).rev() {
        if cands[i] == 1 {
            a0 += 1 << i;
        }
    }
    if a0 > a[0] {
        println!("-1");
        return;
    }
    for i in (0..max_bit).rev() {
        if cands[i] == -1 {
            if a0 + (1 << i) <= a[0] {
                a0 += 1 << i;
            }
        }
    }
    if a0 == 0 {
        println!("-1");
        return;
    }
    println!("{}", a[0] - a0);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2116
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int a[100000][3];
int F(int num)
{
    int ans;
    int dp[num+1][3];
    
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
     
   for(int i=1;i<=num;i++)
   {
    for(int j=0;j<3;j++)
    {
        if(j==0)
        dp[i][j]=max((a[i][j]+dp[i-1][j+1]),(a[i][j]+dp[i-1][j+2]));
        else if(j==1)
        dp[i][j]=max((a[i][j]+dp[i-1][j-1]),(a[i][j]+dp[i-1][j+1]));
        else 
        dp[i][j]=max((a[i][j]+dp[i-1][j-1]),(a[i][j]+dp[i-1][j-2]));
    }

   }
   
    int res[3];
    res[0]=dp[num][0];
    res[1]=dp[num][1];
    res[2]=dp[num][2];
    
    ans=max(dp[num][0],max(dp[num][1],dp[num][2]));
    return ans;
}


int main() {
    int n;

    cin>>n;
   

for(int i=0;i<n;i++)
{
    for(int j=0;j<3;j++)
    cin>>a[i][j];
}
   
   
int ans=F(n-1);
cout<<ans;
return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

long long int gcd(long long int a,long long int b);

int main()
{
    long long int a,b,e,ans,c,d;

    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    e = c * d / gcd(c,d);
    //printf("%lld %lld %lld %lld %lld",a,b,c,d,e);
    ans = (b - (a - 1)) - ((b / c) - ((a - 1) / c)) - ((b / d) - ((a - 1) / d)) + ((b / e) - ((a - 1) / e));

    printf("%lld",ans);
}

long long int gcd(long long int a,long long int b)
{
    long int tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
long long f[100003][4]={0};
vector<int> a,b,c;
int main()
{
    int n;
    int i;
    long long ans;
    scanf("%d",&n);
    a.resize(n+1);
    b.resize(n+1);
    c.resize(n+1);
    for(i=1;i<=n;i++)
    {
	scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    f[0][1]=f[0][2]=f[0][3]=0;
    for(i=1;i<=n;i++)
    {
	f[i][1]=max(f[i-1][2],f[i-1][3])+a[i];
	f[i][2]=max(f[i-1][1],f[i-1][3])+b[i];
	f[i][3]=max(f[i-1][1],f[i-1][2])+c[i];
    }
    ans=max(f[n][1],f[n][2]);
    ans=max(ans,f[n][3]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4480
(defun solve (n a b)
  (let ((ans 0)
        (pre 0))
    (dotimes (i n)
      (cond
        ((< (aref a i) (+ (aref b i) pre))
         (incf ans (aref a i))
         (setq pre (min (aref b i) (- (+ (aref b i) pre) (aref a i)))))
        (t
         (incf ans (+ (aref b i) pre))
         (setq pre 0))))
    (incf ans (min (aref a n) pre))
    ans))


(defun main ()
  (let* ((n (read))
         (a (make-array (1+ n) :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")"))))
         (b (make-array n :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")")))))
    (princ (solve n a b))
    (fresh-line)))

(main)


Measured memory_bytes: 58088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string s;
  cin >> s;
  rep(i, size(s)) if (odd(i + 1)) cout << s[i];
  cout << endl;
}
int main(void) { solve(); }

Measured memory_bytes: 3752
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

s = 100000
ansi = 0
for i in range(0, n):
    tm = t - h[i] * 0.006
    if s > abs(a-tm):
        s = abs(a-tm)
        ansi = i

print(ansi+1)


Measured memory_bytes: 3060
n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


print('{}:'.format(n), *prime_factorize(n))


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


int main(){





long long c, x ,a=0;
cin >> x ;

if (x%2==0) {
   x=x/2 ;
   cout << x*x ;}
else {c = x;
    x=x/2+1;
    a=c-x ;
    cout << a*x ;
}





return 0 ;

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    
    ll  n;
    cin>>n;
    ll a[n];
    fi(i,0,n)
      {cin>>a[i];
       }
    sort(a,a+n,greater<ll>());
    ll t = a[0];
    priority_queue<pair<int, int> > q;
    q.push({a[1],a[0]});
    q.push({a[1],a[0]});
    for(int i=2;i<n;i++)
    {
      auto it = q.top();
      q.pop();
      ll fi = it.first;
      ll se = it.second;
      //cout<<a[i]<<" "<<fi<<" "<<se<<"\n";
      t+=min(fi,se);
      q.push({a[i],fi});
      q.push({a[i],se});
    }
    cout<<t;
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}


Measured memory_bytes: 6920
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    int N;
    cin >> N;
    ll ans=0;
    for(int i=0; i<N; i++){
        ll a;
        cin >> a;
        while(a%2==0){
            ans++;
            a/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> s(m), c(m); rep(i, m) cin >> s[i] >> c[i];

	int l, r; {
		if (n == 1) {
			l = 0, r = 9;
		} else if (n == 2) {
			l = 10, r = 99;
		} else {
			l = 100, r = 999;
		}
	}

	int ans = -1;
	for (int i = l; i <= r; i++) {
		string str = to_string(i);
		bool flag = true;
		rep(j, m) {
			if (str[s[j] - 1] - '0' != c[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	if ((a - b)% 2) {
		cout << min(a + (b - a - 1) / 2,(n - b + 1) + (b - a - 1) / 2) << endl;
	}
	else cout << (abs(b - a) + 1) / 2 << endl;
}

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

using namespace std;

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

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> cuts;
    rep(i, M) {
        int a, b; cin >> a >> b;
        cuts.push_back({a, b});
    }
    
    sort(cuts.begin(), cuts.end());
    
    int ans = 1, b = N;
    rep(i, M) {
        if(cuts[i].first < b) {
            b = min(b, cuts[i].second);
        } else {
            b = cuts[i].second;
            ans++;
        }
    }

    
    cout << ans << endl;
}


Measured memory_bytes: 1400