akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;


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

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

vector<ll> dp(100005,LLONG_MAX);

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	vector<ll> h;
	ll i;
	for(i=0;i<n;i++)
	{
		ll val;
		cin>>val;
		h.pb(val);
	}
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		dp[i+2]=min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 2168
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());//快捷方便而又亲民的反转。
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='b') a[i]='d';//按题目要求操作。
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) printf("Yes");//判断是否与原始字符串相同。
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#define int long long
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
typedef long long ll;
inline void chkmax(int &x, int y){x<y?(x=y):0;}
inline void chkmin(int &x, int y){x>y?(x=y):0;}
const int N=5005;
int dp[N][N], a[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

signed main()
{
    int n=read(), A=read(), B=read(), ans=1ll<<60;
    rep(i, 1, n) a[i]=read();
    memset(dp, 0x3f, sizeof(dp)); dp[0][0]=0;
    rep(i, 1, n) rep(j, 0, n)
        if (a[i]>j) 
            chkmin(dp[i][j], dp[i-1][j]+A), 
            chkmin(dp[i][a[i]], dp[i-1][j]);
        else
            chkmin(dp[i][j], dp[i-1][j]+B);
    rep(i, 0, n) chkmin(ans, dp[n][i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<pair<ll,ll>> schedule(n);
    rep(i,0,n){
        cin>>schedule[i].second>>schedule[i].first;
    }
    sort(all(schedule));
    ll time=0;
    bool ok=true;
    rep(i,0,n){
        time+=schedule[i].second;
        if(time>schedule[i].first){
            ok=false;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3328
/**
*    author:  boutarou
*    created: 21.06.2020 21:30:14
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;
const lint MOD = 1e9 + 7;

long long mod_pow(long long n, long long p, long long m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        long long t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
long long modinv(long long a, long long mod) {
    return mod_pow(a, mod - 2, mod);
}

const lint MAX = 2000005;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint k;
lint n;
string s;

lint ans;
lint rest;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> k >> s;
    n = k + s.size();
    ans = mod_pow(26, n, MOD);
    COMinit();
    rep(i, s.size()) {
        rest += mod_pow(25, n - i, MOD) * COM(n, i) % MOD;
        rest %= MOD;
    }
    lint out = ans - rest;
    out %= MOD;
    if (out < 0) out += MOD;
    cout << out << endl;
    
    return 0;
}

Measured memory_bytes: 51228
#include<bits/stdc++.h>
#define ll long long
#define maxn 2005
using namespace std;
const ll inf=1e9+7;
int dp[maxn][maxn],ans[maxn],a[maxn][maxn];
int main()
{
    //freopen("input.txt","r",stdin);
    int n,x,y;cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            dp[i][j]=dp[j][i]=j-i;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j]=min(dp[i][x]+dp[y][j]+1,dp[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            ans[dp[i][j]]++;
    for(int i=1;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 17280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DXXOR {
public:
    int N;
    ll K;
    ll A[ten(5)+1];
    int bit[ten(5)+1][41];
    int bit_K[41]{0};

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> K;
        REP(i, N) in >> A[i];
        M0(bit);

        // O(1e6)
        ll b = 0;
        int keta = -1;
        while(b <= K) {
            keta++;
            b = 1ll << keta;
            REP(i, N) {
                bit[i][keta] = ((A[i] & b) > 0);
            }
        }

        ll max_x = 0;

        // keta_K * N = O(1e6)
        int keta_K = keta-1;
        FOR(k, 0, keta_K) {
            int cnt_z = 0;
            int cnt_o = 0;
            FOR(i, 0, N-1) {
                if (bit[i][k] == 0) cnt_z++;
                else if (bit[i][k] == 1) cnt_o++;
                else OUT("wwwwwww");
            }
            if (cnt_z > cnt_o) {
                bit_K[k] = 1;
                max_x |= (1ll << k);
            } else {
                bit_K[k] = 0;
            }
        }

        if (max_x <= K) {
            OUT(f(max_x));
            return;
        }

        // herasu
        ll argmax = 0;
        for (int k = keta_K; k >= 0; k--) {
            if (bit_K[k] == 0) continue;
            else {
                ll tmp = argmax + (1ll << k);
                if (tmp <= K) argmax = tmp;
            }
        }
        OUT(f(argmax));
    }

    ll f(ll xi) {
        ll ans = 0;
        REP(i, N) {
            ans += A[i] ^ xi;
        }
        return ans;
    }
};

int main() {
    DXXOR solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 17024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int K = sc.nextInt();
		
		int[] array = {a, b, c};
		int max = 0;
		for (int i : array) {
			if (max < i) {
				max = i;
			}
		}
		int answer = 0;
		int x = (int) Math.pow(2, K) * max;
		boolean twice = false;
		for (int j : array) {
			if (max == j && !twice) {
				answer += x;
				twice = true;
			} else {
				answer += j;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 19796
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int n;

int main() {
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        res += r - l + 1;
    }
    cout << res;

    return 0;
}

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

int main(void) {

	int   i,N;
	scanf("%d",&N);
	int   A[N],tmp;

	for(i=0;i<N;i++) {
		scanf("%d",&tmp);
		A[tmp-1]=i+1;
	}
printf("\n");
for(i=0;i<N;i++)
   printf("%d ",A[i]);
return 0;
}

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

int main()
{
    int n, m, count, ans;
    cin >> n;
    vector<string> s(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }
    cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++)
    {
        cin >> t.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        count = 0;
        for (int j = 0; j < n; j++)
        {
            if (s.at(i) == s.at(j))
            {
                count++;
            }
        }
        for (int j = 0; j < m; j++)
        {
            if (s.at(i) == t.at(j))
            {
                count--;
            }
        }
        a.at(i) = count;
    }
    ans = max(a.at(0), 0);
    for (int i = 1; i < n; i++)
    {
        ans = max(a.at(i), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	double t, x; cin >> t >> x;
	cout << t / x << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
sc = {}
out = False
for _ in range(m):
    s,c = [x for x in input().split()]
    if s in sc.keys():
        if sc[s] != c:
            print("-1")
            out = True
        else:
            sc[s] = c
    else:
        sc[s] = c
        

if not out:
    if n == 1:
        if not "1" in sc.keys():
            sc["1"] = "0"
        print(sc["1"])
    elif n == 2:
        if not "1" in sc.keys():
            sc["1"] = "1"
            if not "2" in sc.keys():
                sc["2"] = "0"
            print(sc["1"],sc["2"],sep="")
        else:
            if sc["1"] == "0":
                print("-1")
            else:
                if not "2" in sc.keys():
                    sc["2"] = "0"
                print(sc["1"],sc["2"],sep="")
    elif n == 3:
        if not "1" in sc.keys():
            sc["1"] = "1"
            if not "2" in sc.keys():
                sc["2"] = "0"
            if not "3" in sc.keys():
                sc["3"] = "0"
            print(sc["1"],sc["2"],sc["3"],sep="")
        else:
            if sc["1"] == "0":
                print("-1")
            else:
                if not "2" in sc.keys():
                    sc["2"] = "0"
                if not "3" in sc.keys():
                    sc["3"] = "0"
                print(sc["1"],sc["2"],sc["3"],sep="")

Measured memory_bytes: 3064
data HowMany = Only | Many | None | Ext1 deriving Eq

main = do
  getLine
  as <- map read.words <$> getLine :: IO [Int]
  putStr $ if solve as then "First" else "Second"

solve as
  | odd $ length $ filter even as = True
  | otherwise = inner odds as
  where
  inner Only as = not $ solve $ map (`div`g) as
    where g = foldr1 gcd as'
  inner _ as = False
  (as',odds) = go as None
  go [] odds = ([],odds)
  go (a:as) odds
    | a == 1  = ([],Ext1)
    | even a  = let (rs,odds') = go as odds in (a:rs,odds')
    | odds == Only = (a:as,Many)
    | odds == None = let (rs,odds') = go as Only in (a-1:rs,odds')



Measured memory_bytes: 41852
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int cnt;

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

	int N;
	cin >> N;

	vector<int>A(N);
	vector<int>ans(N);
	rep(i, N-1) {
		cin >> A[i];
		ans[A[i] - 1]++;
	}

	rep(i, N) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main()
{
    int n,i,j,count=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        if(a[i]!=i+1)
            count++;
    }
    if(count<=2)
        cout<<"YES";
    else
        cout<<"NO";

}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;
ll dp[100010][15]={0};
ll surp[6]={1,10,9,12,3,4};

int main(void){
    string s,t;
    cin>>s;
    t=s;
    for(ll i=0;i<s.length();i++){
        if(s[i]=='?')t[i]='9';
        else t[i]=s[i];
    }
    dp[0][0] = 1;
    ll offset=s.length()-1;
    for (ll i = 0;i < s.length();i++) {
        ll y=surp[offset%6];
        offset--;
        if(s[i]=='?'){
                for(ll k=0;k<13;k++){
                   for(ll l=0;l<=9;l++){
                       dp[i+1][(k+l*y)%13]=
                       (dp[i+1][(k+l*y)%13]+dp[i][k])%N;
                   }
                }
        }
        else{
            ll x=s[i]-'0';
                for(ll k=0;k<13;k++){
                    dp[i+1][(k+x*y)%13]=(dp[i+1][(k+x*y)%13]+dp[i][k])%N;
                }
        }
    }
	cout << (dp[s.length()][5]+N)%N << endl;

}

Measured memory_bytes: 12160
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;

int main()
{
	int n;
	cin >> n;
	stack<long> h;
	for (int i = 0; i < n; i++)
	{
		long n;
		cin >> n;
		h.push(n);
	}

	long bef = h.top();
	h.pop();

	for (int i = 1; i < n; i++)
	{
		long now = h.top();
		h.pop();
		if (now <= bef)
		{
			bef = now;
			continue;
		}
		if (now - bef == 1)
		{
			bef = now - 1;
			continue;
		}
		printf("No");
		return 0;
	}

	printf("Yes");
	return 0;
}


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

#define ll long long

int main()
{
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;

    if(m2==m1+1)
        cout<<"1"<<endl;
    else
        cout<<"0"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


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

    int y;
    scanf("%d",&y);    


    int ans = 0;

    ans = n + (y/2);

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#define N 210
#define M 10000010
using namespace std;
int prime[M+10],link[N],tot;
bool p[M+10],vis[N];
int n,m;
bool can[N][N],s[M+10];
vector<int>v[2];
bool check(int u)
{
	for(int i=1;i<=m;i++)
	if(can[u][i] && !vis[i])
	{
		vis[i]=1;
		if(!link[i] || check(link[i]))
 		{
			link[i]=u;
			return true;
		}
	}
	return false;
}
int main()
{
	p[1]=true;
	for(int i=2;i<=M;i++)
	{
		if(!p[i]) prime[++tot]=i;
		for(int j=1;j<=tot && i*prime[j]<=M;j++)
		{
			p[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	scanf("%d",&n);
	for(int i=1,u;i<=n;i++) scanf("%d",&u),s[u]=true;
	for(int i=1;i<=M;i++)
	if(s[i]^s[i-1]) v[i&1].push_back(i);
	n=v[0].size(),m=v[1].size();
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
		if(!p[abs(v[0][i]-v[1][j])]) can[i+1][j+1]=true;
	int ans=0;
    for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		ans+=check(i);
	}
	int tmp=ans;
	ans+=(n-ans)/2*2+(m-ans)/2*2;
	printf("%d",ans+((n&1)!=(tmp&1)?3:0));
	return 0;
}

Measured memory_bytes: 20864
#![allow(non_snake_case)]

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

fn main() {
    input!{
        A: isize,
        B: isize,
        K: usize,
    }
    let mut Ad = A;
    let mut Bd = B;
    let mut ans = Vec::with_capacity(K * 2);
    let mut buff = Vec::with_capacity(K);
    for _ in 0..K {
        ans.push(Ad);
        Ad += 1;
    }
    for _ in 0..K {
        buff.push(Bd);
        Bd -= 1;
    }
    ans.append(&mut buff);
    ans.sort();
    ans.dedup();
    for i in ans.iter() {
        if i >= &A && i <= &B {
            println!("{}", i);
        }
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <functional>

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

int main() {
	for (;;) {
		int n;
		scanf("%d", &n);
		if (!n) break;

		int color, back_color = -1;
		stack<int> go;

		rep(i, n) {
			scanf("%d", &color);
			if (!(i % 2)) {
				if (color == back_color) {
					int c = go.top();
					go.pop();
					go.push(c + 1);
				}
				else {
					go.push(1);
					back_color = color;
				}
			}
			else {
				if (color == back_color) {
					int c = go.top();
					go.pop();
					go.push(c + 1);
				}
				else {
					int c = go.top();
					go.pop();
					if (!go.empty()) {
						c += go.top();
						go.pop();
					}
					go.push(c + 1);
					back_color = color;
				}
			}
		}

		if (back_color) {
			go.pop();
		}

		int count = 0;
		while (!go.empty()) {
			count += go.top();
			go.pop();
			if (!go.empty()) go.pop();
		}

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

	}
	return 0;
}

Measured memory_bytes: 2668
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def solve():
    A,B,C,D = map(int, input().split())
    c = B//C - (A-1)//C
    d = B//D - (A-1)//D
    r = lcm(C,D)
    e = B//r - (A-1)//r
    ans = (B-A+1) - (c+d-e)
    return ans

print(solve())

Measured memory_bytes: 5048
def needed_to_flip(c):
    return ord('z') - ord(c) + 1

s = list(raw_input())
K = int(raw_input())
#s = list('xyz')
#K = 4


for i, c in enumerate(s):
	if c == 'a' and i != len(s) - 1:
		continue
	needed = needed_to_flip(c)
	#print "%s: needed: %d, has: %d" % (c, needed, K)
	if K >= needed:
		K -= needed
		s[i] = 'a'
		
	#print "flip: %s needed: %d, has: %d" % (s[i], needed,K) 
	if i == len(s) - 1:
		s[i] = chr(ord(s[i]) + (K % 26))

print ''.join(s)
 




Measured memory_bytes: 3588
K = int(input())
A,B = map(int,input().split())
x = int(A / K)
y = int(B / K)
x2 = A % K
y2 = B % K

if y == x and (x2 == 0 or y2 == 0):
    print('OK')
    exit()
if y != x or K == 1:
    print('OK')
else:
    print('NG')

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

int dice[6];

void turn(char c) {
  switch(c) {
    case 'N':
      swap(dice[0], dice[1]);
      swap(dice[1], dice[2]);
      swap(dice[2], dice[3]);
      break;
    case 'S':
      swap(dice[0], dice[3]);
      swap(dice[3], dice[2]);
      swap(dice[2], dice[1]);
      break;
    case 'E':
      swap(dice[0], dice[5]);
      swap(dice[5], dice[2]);
      swap(dice[2], dice[4]);
      break;
    case 'W':
      swap(dice[0], dice[4]);
      swap(dice[4], dice[2]);
      swap(dice[2], dice[5]);
      break;
    case 'R':
      swap(dice[1], dice[4]);
      swap(dice[4], dice[3]);
      swap(dice[3], dice[5]);
      break;
    case 'L':
      swap(dice[1], dice[5]);
      swap(dice[5], dice[3]);
      swap(dice[3], dice[4]);
      break;
    dafault:
      break;
  }
}

int main() {
  int n, s[6] = {1, 2, 6, 5, 3, 4};
  while(cin >> n, n) {
    int ans = 1;
    for(int i = 0; i < 6; i++) dice[i] = s[i];
    for(int i = 0; i < n; i++) {
      string s;
      cin >> s;
      turn(s[0]);
      ans += dice[0];
    }
    cout << ans << endl;
  }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	vll A(N); cin >> A;

	ll sum = 0ll;
	vll cnt(N+1, 0);
	for (auto &v : A) cnt[v]++;
	for (int i = 1; i <= N; i++) {
		sum += cnt[i] * (cnt[i]-1) / 2;
	}
	
	for (int k = 0; k < N; k++) {
		ll index = A[k];
		ll ans = sum;
		if (cnt[index] == 0) cout << ans << endl;
		else {
			ans -= cnt[index] * (cnt[index]-1) / 2;
			ans += (cnt[index]-1) * (cnt[index]-2) / 2;
			cout << ans << endl;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 5760
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i)

ary_two = []

ary.each do |x|
  ary_two << x.to_s(2)
end

i = 0

ary_two.each do |x|
  x.size.times do |j|
    if x[-(1+j)] == "0"
      i += 1
    else
      break
    end
  end
end

puts i

Measured memory_bytes: 6268
#include <iostream>

int main()
{
    int n{};
    std::string s1{}, s2{};
    std::cin >> n;
    std::cin >> s1 >> s2;
    std::string result(n * 2, 0);
    for (int i = 0; i <= n; i++) {
        result[i * 2] = s1[i];
        result[i * 2 + 1] = s2[i];
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#081c
import collections

N,K = map(int, input().split())
A_list = [int(e) for e in input().split()]

counted = collections.Counter(A_list)
count_listed = list(counted.values())
count_listed.sort(reverse=True)

ans = 0

if len(count_listed)>K:
    for i in range(len(count_listed)-K):
        ans += count_listed[len(count_listed)-1-i]
        
print(ans)

Measured memory_bytes: 32516
N = int(input())

combi = []

for i in range(26): # 4 * 25 = 100
    for j in range(16): # 7 * 15 = 105
        combi.append((4 * i) + (7 * j))
       
if N in combi:
    print('Yes')
else :
    print('No')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
typedef vector<ll> vll;
vll prime;
vector<pair<ll,ll> > Pair(100001);
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
int main() 
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll t=1;
//	cin>>t;
	while(t--)
	{
	    ll h,w;
	    cin>>h>>w;
	    if(h==1||w==1)
	    	cout<<1<<endl;
	    else if((h*w)%2!=0)
	    	cout<<(h*w)/2+1<<endl;
	    else cout<<(h*w)/2<<endl;
	    	
	    
	    
		
	}
	return 0;
}




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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
  fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int s,w; cin >> s >> w;
  cout << (s <= w ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;


    cout << x2 - (y2 - y1) << " ";
    cout << y2 + (x2 - x1) << " ";
    cout << x1 - (y2 - y1) << " ";
    cout << y1 + (x2 - x1) << endl;
}

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

deque<string> split_words(string s){
	bool flag = false;
	deque<string> words;
	string str;
	s.push_back(' ');

	for(unsigned int i=0 ; i < s.size() ; ++i ){
		char c = s[i];
		if( flag == false ){
			if( c != ' ' ){
				flag = true;
				str.clear();
				str.push_back( c );
			}
		}else{
			if( c != ' ' ){
				str.push_back( c );
			}
			if( c == ' ' ){
				flag = false;
				words.push_back( str );
				str.clear();
			}
		}
	}
	return words;
}

bool isOperator(string s){
	return ( s == "+" || s == "-" || s == "*" || s == "/" )? true : false ;
}

int s_to_i(string s){
	bool flag = false;
	int n = 0;

	for(unsigned int i=0 ; i < s.size() ; ++i ){
		if( i == 0 && s[i] == '-'){
			flag = true;
		}else{
			n *= 10;
			n += s[i] - '0';
		}
	}
	return (flag)? -n : n ;
}

double accum(double a, double b, string s){
	if( s == "+" )
		return a+b;
	else if( s == "-" )
		return a-b;
	else if( s == "*" )
		return a*b;
	else if( s == "/" )
		return a/b;
	return 0;
}


int main(){
	string s;
	while( getline( cin , s ) ){
		deque<string> words = split_words( s );
		stack<double> n;

		while( !words.empty() ){
			deque<string>::iterator it = words.begin();
			string str = *it;
			words.erase(it);
			if( isOperator( str ) ){
				double a = n.top();
				n.pop();
				double b = n.top();
				n.pop();
				n.push( accum( b , a , str ) );
			}else{
				n.push( s_to_i( str ) );
			}
		}
		printf("%.6lf\n", n.top() );
	}
}

Measured memory_bytes: 0
N = list(map(int, input()))
if N[-1] == 3:
    print("bon")
elif N[-1] == 0:
    print("pon")
elif N[-1] == 1:
    print("pon")
elif N[-1] == 6:
    print("pon")
elif N[-1] == 8:
    print("pon")
else:
    print("hon")

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

int main(void)
{
  string O, E;
  cin >> O;
  cin >> E;
  for(int i=0; i<E.size(); i++){
    cout << O.at(i) << E.at(i);
  }
  if(O.size() > E.size()){cout << O.at(O.size()-1) << endl;}
  else{cout << endl;}

  return 0;

}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    const n = nextInt()
    const s = next()
    let ans = []
    for(let i = 0; i<s.length; i++){
        let idx = (alpha.indexOf(s[i]) + n ) % 26
        ans.push(alpha[idx])
    }
    console.log(ans.join(""))
}
Main()

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll X;
    Scll(X);

    map<ll,pll> m;
    int N = 5000;
    ll t = 0;
    Rep(a,N) Repe(b,N,-N){
        t = a*a*a*a*a - b*b*b*b*b;
        if( t > 1e9 || t < 0 ) continue;
        m[t] = {a,b};
    }

    printf ("%lld %lld\n", m[X].first, m[X].second );



    return 0;
}



Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(a) (a).begin(),(a).end()


int main(){
  ll x,n;
  cin >> x >> n;
  vector<ll> p(n);
  rep(i,n) cin >> p.at(i);

  sort(p.begin(),p.end());
  int m = 10000;
  int ans = 0;
  for(int i=-100;i<=110;++i){
    if( binary_search(p.begin(),p.end(),i) ){
      continue;
    }
    int diff = abs(x-i);
    if( diff < m ){
      m = diff;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int>l(n);
  int ans=0;
  for(int i=0;i<n;i++)
    cin>>l.at(i);
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  for(int i=0;i<k;i++)
    ans+=l.at(i);
  cout<<ans;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4,sse4.1,sse4.2,avx,avx2,tune=native")
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<vector<pii>> r(n);
	rep(i, n-1){
		int u,v,w;
		cin >>u >>v >>w;
		r[u-1].emplace_back(v-1, w%2);
		r[v-1].emplace_back(u-1, w%2);
	}
	VI dst(n, -1);
	auto rec =[&](auto rec, int c, int p)->void{
		for(auto x: r[c]) if(x.first != p){
			dst[x.first] = dst[c] + x.second;
			rec(rec, x.first, c);
		}
	};
	dst[0]=0; rec(rec, 0, -1);
	rep(i, n) cout << dst[i]%2 <<"\n";
	return 0;
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a, b, c, d, e, f;
int dp[25000010];
int m;
int ans;

signed main() {
	cin >> n >> a >> b >> c >> d >> e >> f;
	dp[0] = 0;
	for (int i = a; i <= n; i++)dp[i] = max(dp[i], dp[i - a] + d - a);
	for (int i = b; i <= n; i++)dp[i] = max(dp[i], dp[i - b] + e - b);
	for (int i = c; i <= n; i++)dp[i] = max(dp[i], dp[i - c] + f - c);
	for (int i = 0; i <= n; i++)m = max(m, dp[i]);
	m += n;
	fill(dp, dp + n + 5, 0);
	dp[0] = 0;
	for (int i = d; i <= m; i++)dp[i] = max(dp[i], dp[i - d] + a - d);
	for (int i = e; i <= m; i++)dp[i] = max(dp[i], dp[i - e] + b - e);
	for (int i = f; i <= m; i++)dp[i] = max(dp[i], dp[i - f] + c - f);
	for (int i = 0; i <= m; i++)ans = max(ans, dp[i]);
	ans += m;
	cout << ans << endl;
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;

    rep(i,n/r+1){
        rep(j,n/g+1){
            if(n-r*i-g*j>=0&&
                    (n-r*i-g*j)%b==0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int result = 0;
  
  for (int i=1; i<=n; ++i) {
    for (int j=1; j<=5; ++j) {
      int a = i / pow(10, j);
      if (a == 0) {
        if (j % 2 == 1) {
          ++result;
        }
        break;
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

vector<lli> dp(100005, -1);
vector<lli> a(100005, 0);
lli n;
lli fun(lli idx)
{
	if (idx == n - 1)
		return 0;
	if (dp[idx] != -1)
		return dp[idx];
	lli oneStep = abs(a[idx] - a[idx + 1]) + fun(idx + 1);
	lli twoStep = INT_MAX;
	if (idx + 2 < n)
		twoStep = abs(a[idx] - a[idx + 2]) + fun(idx + 2);
	return dp[idx] = min(oneStep, twoStep);
}
void solve()
{
	cin >> n;
	f(i, 0, n - 1)
	cin >> a[i];
	cout << fun(0);
}
int main()
{
	IOS;
	solve();
	return 0;
}

Measured memory_bytes: 7920
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b;
  cin >> a >> b;
  if(a>0) cout << "Positive";
  else if(b>=0) cout << "Zero";
  else{
    if((b-a)%2==0)cout << "Negative";
    else cout << "Positive";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define all(_v) _v.begin(), _v.end()

double n;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin >> n;
    cout << 2 * n * acos(-1);
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#define INFINITY 2000000000
#define N 101
using namespace std;
void warshallFloyd();
int v,A[N][N];
int main(){
  int e,s,t,d,i,j;
  cin >> v >> e;
  for(i=0;i<v;i++){
    for(j=0;j<v;j++){
      if(i!=j) A[i][j]=INFINITY;
      else A[i][j]=0;
    }
  }
  for(i=0;i<e;i++){
    cin >> s >> t >> d;
    A[s][t]=d;
  }
  warshallFloyd();
  return 0;
}
void warshallFloyd(){
  int i,j,k,flag;
  for(k=0;k<v;k++){
    for(i=0;i<v;i++){
      for(j=0;j<v;j++){
	if(A[i][k]!=INFINITY&&A[k][j]!=INFINITY)A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
      }
    }
  }
  flag=0;
  for(i=0;i<v;i++){
    if(A[i][i]<0){
      flag=1;
      break;
    }
  }
  if(flag==1) cout << "NEGATIVE CYCLE" << endl;
  else{
    for(i=0;i<v;i++){
      for(j=0;j<v;j++){
	if(A[i][j]!=INFINITY) cout << A[i][j];
	else cout << "INF";
	if(j!=v-1) cout << ' ';
      }
      cout << endl;
    }
  }
}

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

using namespace std;

int main()
{
  int N, M; cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; ++i) {
    cin >> X[i];
  }

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

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

  vector<int> L(M-1);
  for (int i = 0; i < M - 1; ++i) {
    L[i] = X[i+1] - X[i];
  }

  sort(L.begin(), L.end(), greater<int>());

  int distance = X.back() - X.front();
  for (int i = 0; i < N - 1; ++i) {
    distance -= L[i];
  }

  cout << distance << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr int inf = std::numeric_limits<int>::max() / 2;
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> b(h);
    for (int i = 0; i < h; i++) {
        std::cin >> b[i];
    }

    std::vector<std::vector<int>> dist(h * w, std::vector<int>(h * w, inf));
    for (int i = 0; i < h * w; i++) dist[i][i] = 0;
    auto get = [w](int i, int j) { return i * w + j; };
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (b[i][j] == '#') continue;
        int k = get(i, j);
        if (i > 0 && b[i - 1][j] == '.') dist[k][get(i - 1, j)] = 1;
        if (i + 1 < h && b[i + 1][j] == '.') dist[k][get(i + 1, j)] = 1;
        if (j > 0 && b[i][j - 1] == '.') dist[k][get(i, j - 1)] = 1;
        if (j + 1 < w && b[i][j + 1] == '.') dist[k][get(i, j + 1)] = 1;
    }

    for (int k = 0; k < h * w; k++) for (int i = 0; i < h * w; i++) for (int j = 0; j < h * w; j++) {
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    int ret = 0;
    for (auto &v : dist) for (auto e : v) if (e < inf) ret = std::max(ret, e);

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<cstring>
#define INF 1000000000
using namespace std;
vector <int> adj[100001];
int h[100001],n,good,m,a,b,tim=0;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=m;i++){
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        good=1;
        for(auto x:adj[i])
            if(h[i]<=h[x])
                good=0;
        tim=tim+good;
    }
    cout<<tim;
}

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

const std::string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

const int MAX_L = 128;

int query(std::string s) {
	std::cout << "? " << s << std::endl;
	int x;
	scanf("%d", &x);
	return x;
}

int n;

bool check(std::string s) {
	return query(s) + s.size() == n;
}

int main() {
	assert(chars.size() == 62);
	std::vector<std::string> cur_que;
	for (int i = 0; i < 62; ++i) {
		std::string x(MAX_L, chars[i]);
		int v = MAX_L - query(x);
		n += v;
		if (v) cur_que.emplace_back(std::string(v, chars[i]));
	}
	while (cur_que.size() > 1) {
		std::sort(cur_que.begin(), cur_que.end(), [&] (const std::string &a, const std::string &b) { return a.size() < b.size(); });
		std::string a = cur_que[0], b = cur_que[1], ans = "";
		cur_que.erase(cur_que.begin(), cur_que.begin() + 2);
		while (a.size() > 0 && b.size() > 0) {
			if (check(ans + a[0] + b)) {
				ans += a[0];
				a.erase(a.begin());
			} else {
				ans += b[0];
				b.erase(b.begin());
			}
		}
		ans += a;
		ans += b;
		cur_que.emplace_back(ans);
	}
	std::cout << "! " << cur_que[0] << std::endl;
}

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

    if(a > b){
        cout << "a > b" << endl;
    }else if(a < b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    
}


Measured memory_bytes: 3072