akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

struct E {
	int x, y, cost;
};
vector<E>V;
signed main() {
	int l; cin >> l; int r = l;
	int n = 0;
	while (r != 1) {
		n++;
		r /= 2;
	}
	l--;
	n++;
	for (int i = 1; i < n; i++) {
		V.push_back({ i,i + 1,0 });
		V.push_back({ i,i + 1,1 << (n - i - 1) });
	}
	l++;
	int k = 1 << (n - 1);
	for (int i = 1; i < n; i++) {
		if (l&(1 << (n - i-1))) {
			V.push_back({ 1,i + 1,k });
			k += (1 << (n - i-1));
		}
	}
	cout << n << " " << V.size() << endl;
	for (E a : V) {
		cout << a.x << " " << a.y << " " << a.cost << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b,c,x,y,ans;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(a+b>2*c)
	{
		ans+=min(x,y)*2*c;
		if(x>y)
		{
			ans+=(x-y)*a;
		}
		else  ans+=(y-x)*b;
	}
	else{
		ans+=x*a+y*b;
	}
	int sum=max(x,y)*2*c;
	printf("%d\n",min(ans,sum));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    int q;
    cin >> a >> q;
    deque<char> deck;
    for(int i = 0; i < a.size(); i++)
    {
        deck.push_back(a[i]);
    }
    int flag = 0;
    for(int i = 0; i < q; i++){
        int c;
        cin >> c;
        if(c == 1){
            flag == 0 ? flag = 1: flag = 0;
        }
        if(c == 2)
        {
                int d;
                char e;
                cin >> d >> e;
                if(d == 1 && flag == 0)
                deck.push_front(e);
                if(d == 1 && flag == 1)
                deck.push_back(e);
                if(d == 2 && flag == 0)
                deck.push_back(e);
                if(d == 2 && flag == 1)
                deck.push_front(e);
                
            
        }
    }
            if(flag == 0)
            {
                for(int i = 0; i < deck.size(); i++)
                cout << deck[i];
            }
                      if(flag == 1){
                          for(int i = deck.size() - 1; 0 <= i; i--)
                            cout << deck[i];
                      }           
                      cout << "\n"; 
}

Measured memory_bytes: 896
#include<iostream>
#include<climits>
using namespace std;
int g[12][12];
const int INF = INT_MAX/2;
int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0)break;
    fill(*g,*(g+12),INF);
    for(int i = 0;i < 12;i++)g[i][i] = 0;

    for(int i = 0;i < n;i++){
      int a,b,c;
      cin >> a >> b >> c;
      g[a][b] = g[b][a] = c;
    }
  
    for(int k = 0;k < 12;k++){
      for(int j = 0;j < 12;j++){
        for(int i = 0;i < 12;i++){
          
          g[i][j] = min( g[i][j], g[i][k] + g[k][j]);
        }
      }
    }  
    
    int ans = INF,node = 0;
    for(int i = 0;i < 12;i++){
      int tmp = 0;
      for(int j = 0;j < 12;j++){
        tmp += g[i][j] == INF ? 0 : g[i][j];
      }
      if(tmp > 0 && tmp < ans){
        node = i;
        ans = tmp;
      }
    
    }
    cout << node << ' ' << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e9+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(b==0){return a;}return gcd(b,a%b);}//a>b
llint lcm(llint a,llint b){return (a/gcd(max(a,b),min(a,b)))*b;}
int main(void){
	int i,n,ans=0;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];a[i]--;}
	for(i=0;i<n;i++){if(i==a[a[i]]){ans++;}}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, t;
set<int> s;
vector<int> v;
int temp;

bool d(int x) {
    s.clear();
    rep(i,0,n) {
        s.insert(v[i]);
        if(v[i] - *s.begin() >= x) temp++;
    }
    if(temp) return true;
    else return false;
}

signed main() {
    cin >> n >> t;
    v.resize(n);
    rep(i,0,n) cin >> v[i];

    int ans;
    int lb = -1, ub = INF;
    while(ub - lb > 1) {
        temp = 0;
        int mid = (ub + lb) / 2;
        if(d(mid)) {
            lb = mid;
            ans = temp;
        }
        else ub = mid;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair

long long n, x, d;

map<long long, vector<pair<long long, long long> > > mp;

struct ban
{
    long long x;
    int z;
};
bool operator<(const ban& a, const ban& b)
{
    return (a.x < b.x);
}

vector<ban> v;

int main()
{
    cin >> n >> x >> d;
    if (d == 0)
    {
        if (x == 0)
        {
            cout << 1 << endl;
            return 0;
        }
        else
        {
            cout << n + 1 << endl;
            return 0;
        }
    }
    if (d < 0)
    {
        d *= (-1);
        x *= (-1);
    }
    long long r = 0, l = 0;
    for (int i = -1; i < n; ++i)
    {
        if (i != -1)
        {
            l += i;
            r += (n - 1 - i);
        }
        mp[((i + 1) * x) % d].push_back(m_p(((i + 1) * x) / d + l, ((i + 1) * x) / d + r));
    }
    long long ans = 0;
    for (map<long long, vector<pair<long long, long long> > >::iterator it = mp.begin(); it != mp.end(); ++it)
    {
        vector<ban> v;
        for (int i = 0; i < it->second.size(); ++i)
        {
            ban t;
            t.x = it->second[i].first;
            t.z = 1;
            v.push_back(t);
            t.x = it->second[i].second + 1;
            t.z = -1;
            v.push_back(t);
        }
        sort(v.begin(), v.end());
        int p = 0;
        for (int i = 0; i < v.size() - 1; ++i)
        {
            p += v[i].z;
            if (p > 0)
            {
                ans += (v[i + 1].x - v[i].x);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 22144
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, *a = map(int, read().split())
a.sort()
if a[0] + 1 < a[-1]:
    print('No')
elif a[0] == a[-1]:
    if a[-1] == N - 1 or 2 * a[-1] <= N:
        print('Yes')
    else:
        print('No')
else:
    b = a.count(a[0])
    c = N - b
    if b < a[-1] and 2 * (a[-1] - b) <= c:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14044
#!/usr/bin/env python3

import sys

def to_be_celebrate(n):
    if n == '3':
        return True
    if n == '5':
        return True
    if n == '7':
        return True
    return False

X = sys.stdin.readline().rstrip()

print('YES' if to_be_celebrate(X) else 'NO')

Measured memory_bytes: 2940
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % MOD;
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	string s; cin >> s;
	stack<char> st;

	rep(i, s.size()) {
		if (s[i] != 'B') st.push(s[i]);
		else if(st.size() != 0) st.pop();
	}

	stack<char> tmp;
	ll n = st.size();
	rep(i, n) {
		tmp.push(st.top());
		st.pop();
	}
	rep(i,n) {
		cout << tmp.top();
		tmp.pop();
	}
	cout << endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int>P;

int main(){
    string n;
    cin>>n;
    cout<<(n.find("9")!=-1?"Yes":"No")<<endl;
    return 0;
}

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

int main () {
  int N ;
  cin >> N ;
  
  int ans = 0 ;
  
  for(int i = 0 ; i < 32000 ; i++ ) {
    if( i * i > N ) break ;
    ans = i * i ;
  }
  
  cout << ans << endl ;
  
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
map<string,int> dp;
int direction[]={1,-1,4,-4};
//分?代表右移、左移、下移、上移
void bfs()
{
    queue<string> que;
    que.push("01234567");
    dp["01234567"]=0;
    while(!que.empty()){
        string now=que.front();
        que.pop();
        //p是字符串中0的位置
        int p=0;
        for(int i=0;i<8;i++){
            if(now[i]=='0'){
                p=i;
                break;
            }
        }
        for(int i=0;i<4;i++){
            int n=p+direction[i];
            if(n>=0&&n<8&&!(p==3&&i==0)&&!(p==4&&i==1)){
                //右上角不能向右移、左下角不能向左移
                string next=now;
                swap(next[p],next[n]);
                if(dp.find(next)==dp.end()){
                    //用find函数来定位数据出?位置，它返回的一个迭代器，
                    //当数据出??，它返回数据所在位置的迭代器，
                    //如果map中没有要?找的数据，它返回的迭代器等于end函数返回的迭代器
                    dp[next]=dp[now]+1;
                    que.push(next);
                }
            }
        }
    }
}
int main()
{
    bfs();
    string s;
    while(getline(cin,s)){
       s.erase(remove(s.begin(),s.end(),' '),s.end());
       cout<<dp[s]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5360
import sys

N=int(raw_input())
list_S=[raw_input() for i in range(N)]

list_MARCH=["M", "A", "R", "C", "H"]
list_only_MARCH=[i for i in list_S if i[0] in list_MARCH]

num_MARCH=len(list_only_MARCH)
list_num=[0, 0, 0, 0, 0]
for i in list_only_MARCH:
  if   i[0]=="M": list_num[0]=list_num[0]+1
  elif i[0]=="A": list_num[1]=list_num[1]+1
  elif i[0]=="R": list_num[2]=list_num[2]+1
  elif i[0]=="C": list_num[3]=list_num[3]+1
  elif i[0]=="H": list_num[4]=list_num[4]+1

ans_num=num_MARCH*(num_MARCH-1)*(num_MARCH-2)/6
if ans_num==0:
  print 0
  sys.exit()

for i in list_num:
  if i==2: ans_num=ans_num-(num_MARCH-2)
  elif i>=3:
    ans_num=ans_num-(i*(i-1)*(i-2)/6)
    ans_num=ans_num-((num_MARCH-i)*i*(i-1)/2)

print ans_num

Measured memory_bytes: 11376
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}


#define pii pair<int,int>
#define l first
#define r second

const int N=3e5+5;
int n,m,tr[N];
pii a[N];

inline bool cmp(const pii &x,const pii &y){
	return x.r-x.l<y.r-y.l;
}

#define lowbit(x) (x&(-x))

void up(int x,int v){
	while(x<=n){
		tr[x]+=v;
		x+=lowbit(x); 
	}
}

int que(int x){
	int res=0;
	while(x){
		res+=tr[x];
		x-=lowbit(x);
	}
	return res;
}

signed main(){
	read(m);read(n);
	for(int i=1;i<=m;i++) read(a[i].l),read(a[i].r);
	sort(a+1,a+1+m,cmp);
	for(int i=1,pt=1;i<=n;i++){
		int cur=0;
		while(pt<=m&&a[pt].r-a[pt].l+1<i) up(a[pt].l,1),up(a[pt].r+1,-1),pt++;
		for(int j=i;j<=n;j+=i) cur+=que(j);
		write(cur+m-pt+1);puts("");
	}
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  cin>>A;
  for(auto &I:A){I--;}
  vector<ll> cnt0(3*M+1,0);
  vector<ll> cnt1(3*M+1,0);
  ll ans=0;
  for(int i=1;i<N;i++){
    ll s=A[i-1],g=A[i];
    if(s>g){g+=M;}
    ans+=g-s;
    cnt1[s+1]++;
    cnt1[g+1]--;
    cnt0[g+1]-=g-s;

    s+=M;
    g+=M;
    if(g>=3*M){continue;}
    cnt1[s+1]++;
    cnt1[g+1]--;
    cnt0[g+1]-=g-s;

    s+=M;
    g+=M;
    if(g>=3*M){continue;}
    cnt1[s+1]++;
    cnt1[g+1]--;
    cnt0[g+1]-=g-s;
  }

  ll dif=cnt1[0];
  for(int i=1;i<3*M;i++){
    cnt0[i]+=cnt0[i-1]+dif;
    dif+=cnt1[i];
  }
  ll mx=0;
  for(auto &I:cnt0){mx=max(mx,I);}
  cout<<ans-mx<<endl;

  return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<int> A(1<<20);

int main() {
    ll n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>A[i];

    ll ans = 0;
    for(int i=0;i<n-1;i++) {
        if(A[i] + A[i+1] > x) {
            ll y = A[i]+A[i+1]-x;
            ans += y;
            if(A[i+1] >= y) {
                A[i+1] -= y;
            } else {
                A[i+1] = 0;
                A[i] = x;
            }
        }
    }

    cout<<ans;




    return 0;
}


Measured memory_bytes: 4352
import java.util.*;

public final class Main {

    public static void main(String[] args) {


        Scanner s = new Scanner(System.in);

        int N = s.nextInt();

        long[][] length = new long[N][N];

        for (int i = 0; i < N; i++) {

            for (int j = 0; j < N; j++) {

                length[i][j] = s.nextLong();

            }
        }


        long result = 0;
        for (int i = 0; i < N;i ++) {

            for (int j = i+1; j< N; j++) {

                long dist = length[i][j];

                boolean flag = true;
                for (int k = 0; k < N; k++) {

                    if (k == i || k == j) continue;

                    long sum = length[i][k] + length[k][j];

                    if (sum < dist) {

                        System.out.print(-1);
                        return;
                    } else if (sum == dist) {

                        flag = false;
                    }
                }

                if (flag) result +=dist;
            }
        }

        System.out.print(result);
    }


}

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

int main() {
  int A, B;
  cin >> A >> B;

  int t = 0;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      t += A;
      A--;
    } else {
      t += B;
      B--;
    }
  }
  cout << t << endl;
}

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

int main(void){
    ll h,w; cin >> h >> w;
    ll ans = pow(10,11);
    vector<ll>s(3);
    for(int i=1;i<h;i++){
        s[0]= i * w;
        ll rest_h = h - i;
        if(rest_h%2==0 || w%2==0){
            s[1] = rest_h*w/2;
            s[2] = rest_h*w/2;
        }else{
            if(rest_h < w){
                s[1] = (w/2) * rest_h;
                s[2] = (w/2 + 1) * rest_h;
            }else{
                s[1] = (rest_h/2) * w;
                s[2] = (rest_h/2 + 1) * w;
            }
        }
        ll tmp = *max_element(s.begin(),s.end())-*min_element(s.begin(),s.end());
        if(tmp < ans) ans = tmp;
        // cout << i << ' ' <<  ans << endl;
    }
    
    for(int i=1;i<w;i++){
        s[0]= i * h;
        ll rest_w = w - i;
        if(rest_w%2==0 || h%2==0){
            s[1] = rest_w*h/2;
            s[2] = rest_w*h/2;
        }else{
            if(rest_w < h){
                s[1] = (h/2) * rest_w;
                s[2] = (h/2 + 1) * rest_w;
            }else{
                s[1] = (rest_w/2) * h;
                s[2] = (rest_w/2 + 1) * h;
            }
        }
        ll tmp = *max_element(s.begin(),s.end())-*min_element(s.begin(),s.end());
        if(tmp < ans) ans = tmp;
        // cout << i << ' ' << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007

vector<ll>tree(100000,LLONG_MAX);
void build(ll s,ll e,ll p,vector<ll>&arr)
{
	if(s==e)
	{
		tree[p]=arr[s];
		return;
	}
	ll mid=(s+e)/2;
	build(s,mid,2*p+1,arr);
	build(mid+1,e,2*p+2,arr);
	tree[p]=min(tree[2*p+1],tree[2*p+2]);
}

ll query(ll s,ll e,ll l,ll u, ll p)
{
	if(e<l || s>u)
		return LLONG_MAX;
	else if(s<=l && u<=e && l<=u)
		return tree[p];
	ll mid=(l+u)/2;
	ll left=query(s,e,l,mid,2*p+1);
	ll right=query(s,e,mid+1,u,2*p+2);
	return min(left,right);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin>>n;
	ll f=1;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		if(a%2==0)
		{
			if(!(a%3==0 || a%5==0))
				f=0;
		}
	}
	if(f==1)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	cout<<endl;

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int A[111111],B[111111];

signed main(){
    cin>>N>>K;
    rep(i,N)cin>>A[i]>>B[i];

    int ans=0;
    int sum=0;
    rep(i,N)if((A[i]&K)==A[i])sum+=B[i];
    ans=sum;


    for(int i=30;i>=0;i--){
        if(!(K>>i&1))continue;
        sum=0;
        rep(j,N){
            int aa=A[j];
            int kk=K;
            if(aa>>i&1)continue;
            rep(k,i){
                if(aa>>k&1)aa^=1ll<<k;
                if(kk>>k&1)kk^=1ll<<k;
            }
            if((aa&kk)==aa)sum+=B[j];
        }

        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n, d;
    cin >> n >> d;
    
    if (d == 10)
        cout << to_string(n).size();
    else
    {
        int cnt = 0;
        while (n >= 1)
        {
            n /= d;
            ++cnt;
        }
        
        cout << cnt;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
ll dp[55][55][2510];
int main( ){
    int n;
    cin>>n;
    int a;
    cin>>a;
    vi x(n);
    rep(i,0,n)cin>>x[i];
    dp[0][0][0]=1;
    rep(i,0,n){
        rep(j,0,n){
            rep(k,0,2501){
                if(k+x[i]<2510)
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
        rep(j,1,n+1){
            ans+=dp[n][j][j*a];
        }
    cout<<ans<<endl;
    return 0;
}




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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

unsigned int randxor(){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

#define int ll

int D;
const int N=26;
vector<vector<int>>s;
vector<int>c;

ll score(vector<int>&t){
  ll score=0;
  ll ans=0;
  vector<int>last(N,-1);
  for(int i=0;i<D;i++){
    ans+=s[i][t[i]];
    last[t[i]]=i;
    for(int j=0;j<N;j++){
      if(last[j]==-1)ans-=c[j]*(i+1);
      else ans-=c[j]*(i-last[j]);
    }
    score+=max(ans+1000000,0ll);
  }
  return score;
}

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

  auto start = std::chrono::system_clock::now();  
  cin>>D;
  c.resize(N);
  for(int i=0;i<N;i++)cin>>c[i];
  s.resize(D,vector<int>(N));
  for(int i=0;i<D;i++)for(int j=0;j<N;j++)cin>>s[i][j];

  vector<int>t(D,0);

  ll S=0;
  for(int i=0;i<D;i++){
    for(int j=0;j<N;j++){
      int memon=t[i];
      t[i]=j;
      ll SS=score(t);
      if(S<SS)S=SS;
      else t[i]=memon;
    }
  }
  while(true){
    for(int x=0;x<100;x++){
      int d=randxor()%D;
      int n=randxor()%N;
      int memon=t[d];
      if(memon==n)n++;
      t[d]=n;
      ll SS=score(t);
      if(S<SS)S=SS;
      else t[d]=memon;
    }
    auto end = std::chrono::system_clock::now();
    auto dur = end-start;
    auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
    if(1980<msec)break;
  }

  for(auto it:t)cout<<it+1<<endl;
  return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>

    int main(void){
      int x[4], y[4];
      scanf("%d", x);
      scanf("%d", y);
      scanf("%d", x+1);
      scanf("%d", y+1);

      int dx = x[1] - x[0];
      int dy = y[1] - y[0];
      int Dx = -dy;
      int Dy = dx;

      x[2] = x[1] + Dx;
      y[2] = y[1] + Dy;

      x[3] = x[2] - dx;
      y[3] = y[2] - dy;

      printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);

      return 0;
    }


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

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

int main(){
  
  int n;
  cin >>n;
  vector<int> list(n);
  rep(i,n ) cin>>list.at(i);
  int ans=list[0];
  rep(i,n-1)ans =gcd(ans,list[i+1]);
  cout<<ans<<endl;
}



Measured memory_bytes: 3688
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vll h(n+1);
    fo(i,n){
        cin>>h[i+1];
    }
    vll c(n+1);
    fo(i,n){
        c[i+1]=1000000007;
    }
    c[1]=0;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=min(i+k,n);j++){
            c[j]= min(c[j], c[i]+ abs(h[i]-h[j]));
        }
    }
        
    cout<<c[n]<<nl;
    

    


	return 0;
}


Measured memory_bytes: 4672
program probC
    implicit none
    integer(16)::X, K, D, ans, c
    integer::i, j
    read(*,*) X, K, D
    X = abs(X)
    c = X/D
    if(c >= K)then 
    	write(*,*) X - K*D
    else
        K = K - c
        if(mod(K,2) == 0)then 
        	write(*,*) X - c*D
        else 
            write(*,*) abs(X - (c+1)*D)
        end if
    end if
    stop
end program

Measured memory_bytes: 2836
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
  set<ll> s;
  for(ll i=0;i<3;i++)
  {
	 ll x;
	 cin>>x;
	 s.insert(x); 
	}
 cout<<s.size();
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


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

using namespace std;

vector<vector<int>> kalnough;

int N, A, B;
int C;
void build(int level) {
	if (level <= 1)return;
	for (int i = 1; i < level; i++) {
		for (int bit = 0; bit < (1 << i); bit++) {
			kalnough[i].push_back(kalnough[i - 1][bit]);
		}
		for (int bit = (1 << i); bit < (1 << (i + 1)); bit++) {
			kalnough[i].push_back(kalnough[i - 1][(1 << (i + 1)) - 1 - bit] + (1 << i));
		}
	}

}

int cntbit(int bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int erase_head(int a, int b) {
	if (a & (1 << b))a -= (1 << b);
	return a;
}

int main() {
	cin >> N >> A >> B;

	if (N == 1) {
		cout << "Yes" << endl;
		if (A == 0) {
			cout << "0 1" << endl;
		}
		else {
			cout << "1 0" << endl;
		}
		return 0;
	}

	N--;

	kalnough.resize(20);
	kalnough[0].push_back(0);
	kalnough[0].push_back(1);
	build(20);
	int C = A ^ B;
	//この作業で、0スタート,Cで終わると固定できる

	vector<int> ans;

	if (cntbit(C) % 2 == 0) {
		cout << "No" << endl;
		return 0;
	}
	int flg = 0;
	int pos = -1;
	
	for (int i = 0; i < kalnough[N - 1].size(); i++) {
		if (kalnough[N - 1][i] != erase_head(C, N) && flg == 0) {
			if (i % 2 == 0) {
				ans.push_back(kalnough[N - 1][i]);
				ans.push_back(kalnough[N - 1][i] + (1 << N));
			}
			else {
				ans.push_back(kalnough[N - 1][i] + (1 << N));
				ans.push_back(kalnough[N - 1][i]);
			}
		}
		else if (kalnough[N - 1][i] == erase_head(C, N) && flg == 0) {
			pos = i;
			if (i % 2 == 0) {
				ans.push_back(kalnough[N - 1][i]);
				flg = 1;
			}
			else {
				ans.push_back(kalnough[N - 1][i] + (1 << N));
				flg = 2;
			}
		}
		else if(flg == 1){
			ans.push_back(kalnough[N - 1][i]);
		}
		else if (flg == 2) {
			ans.push_back(kalnough[N - 1][i] + (1 << N));
		}
	}

	for (int i = (1 << N) - 1;; i--) {
		if (flg == 1) {
			ans.push_back(kalnough[N - 1][i] + (1 << N));
		}
		else {
			ans.push_back(kalnough[N - 1][i]);
		}
		if (i == pos)break;
	}

	cout << "YES" << endl;
	for(int i = 0; i < ans.size();i++){
		cout << (ans[i] ^ A) << " " ;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <string>
std::string s;
int f(int a, int b, int c){
	int i=s[a];
	return ((i!='s'&&i==s[b]&&i==s[c])?i:0);
}
int main(){
	int i,j;
	while(getline(std::cin,s)){
		char c=(f(0,4,8)||f(2,4,6))?s[4]:0;
		if(!c){
			for(i=0;i<3;i++){
				c=f(i,i+3,i+6);
				if(c)break;
				j=i*3;
				c=f(j,j+1,j+2);
				if(c)break;
			}
			if(!c)c='d';
		}
		std::cout<<c<<"\n";
	}
}

Measured memory_bytes: 1164
s = input()
l = []
i = 0
while i < len(s):
    if s[i] == "A":
        l.append(0)
    elif s[i] == "B":
        if i < len(s)-1 and s[i+1] == "C":
            l.append(1)
            i += 1
        else: l.append(-1)
    else: l.append(-1)
    i += 1

cnt, ans = 0, 0
for x in l:
    if x == 0: cnt += 1
    elif x == 1: ans += cnt
    else: cnt = 0

print(ans)


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 3 1 2");
            //3.000000 0
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 2 1 1");
            //2.000000 1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int W = wkArr[0];
        int H = wkArr[1];
        int x = wkArr[2];
        int y = wkArr[3];

        int Menseki = W * H;

        if (W == x * 2 && H == y * 2) {
            Console.WriteLine("{0} {1}", (decimal)W * (decimal)H / 2M, 1);
        }
        else {
            Console.WriteLine("{0} {1}", (decimal)W * (decimal)H / 2M, 0);
        }
    }
}


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

int main()
{
  int n; cin >> n;
  int a;
  vector<int> b(n);
  rep(i, n) b[i] = 0;   //initialization
  rep(i, n-1){
      cin >> a;
      b[a-1]++;
  }
  rep(i, n-1){
      cout << b[i] << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
int main(){
        int a,b,c,s;//変数
        
        scanf("%d %d %d",&a,&b,&c);//a,b,cを入力
        
        if(a >= 1 && a <= 10000 && b >= 1 && b <= 10000 && c >= 1 && c <= 10000 ){
        	//aとbを入れ替え
                if(a > b){
                        s = a;
                        a = b;
                        b = s;
                }
        	//bとcを入れ替え
                if(b > c){
                        s = b;
                        b = c;
                        c = s;
                }
        	//aとbを入れ替え
                if(a > b){
                        s = a;
                        a = b;
                        b = s;
                }
        	//出力
                printf("%d %d %d\n",a,b,c);
        }
        return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s.size()>=6 && s[2]==s[3] && s[4]==s[5])
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	cout << (n < 1200 ? "ABC" : "ARC") << endl;
	return 0;
}

Measured memory_bytes: 256
n = [int(input()) for i in range(5)]
q = []
for i in n:
    if i%10 == 0:
        q.append(10)
    else:
        q.append(i%10)
ans = 0
for i in range(5):
    ans =  ans + n[i] - q[i] + 10
ans = ans - 10 +q[q.index(min(q))]
print(ans)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	int med1 = n / 2, med2 = (n - 1) / 2;
	if(n % 2 == 1) {
		long long sum = 0;
		for(int i = 0; i < n; i++) {
			sum += abs(a[med1] - a[i]);
		}
		cout << sum << endl;
	}
	else{
		long long sum1 = 0, sum2 = 0;
		for(int i = 0; i < n; i++) {
			sum1 += abs(a[med1] - a[i]);
			sum2 += abs(a[med2] - a[i]);
		}
		cout << min(sum1, sum2) << endl;
	}
  
	return 0;
}	


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //int t = sc.nextInt();
    //while (t-- > 0) {
    int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt();
    int tmp = y;
    y = x;
    x = z;
    z = tmp;
    System.out.println(x + " " + y + " " + z);
    //}
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int v ,e;
int sta[10001];
vector <int> gin[10001];
vector <int> gout[10001];
queue <int> Q;
vector <int> ans;

void toporogical_sort(){
  for(int i=0;i<v;i++)
    if(gin[i].size() == 0) {
      Q.push(i);
    }
  while(!Q.empty()) {
    int t = Q.front();
    Q.pop();
    ans.push_back(t);

    for(int i=0;i<gout[t].size();i++){
      int nx = gout[t][i];
      int size = gin[nx].size();
      for(int j=0;j<size;j++)
	if(gin[nx][j] == t){
	  gin[nx].erase(gin[nx].begin()+j);
	  break;
	}
      if(gin[nx].size() == 0) Q.push(nx);
    }
  }


}


int main() {

  cin >> v >> e;

  for(int i=0;i<e;i++) {
    int s,t;
    cin >> s >> t;
    gin[s].push_back(t);
    gout[t].push_back(s);
  }
  toporogical_sort();

  for(int i=ans.size()-1;i>=0;i--) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 2592
using System;
class Program
{
    static void Main(string[] args)
    {
        var m = int.Parse(Console.ReadLine());
        var r = Console.ReadLine().Split(' ');
        int rc = 0;
        int ans = 0;

        rc = int.Parse(r[0]);
        ans++;
        for (int i = 1; i < m; i++)
        {
            if(rc <= int.Parse(r[i])){
                rc = int.Parse(r[i]);
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int N;
  string str1, str2;
  cin >> N >> str1 >> str2;
  for(int i=0; i<N; i++)
  {
    cout << str1[i] << str2[i];
  }
  
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N,W,a,b,sum=0;
	cin>>N>>W;
	vector <pair<ll,ll>> v;
	for(ll i=0;i<N;i++)
	{
		cin>>a>>b;
		sum+=b;
		v.pb(mp(a,b));
	}
	ll ar[sum+1];
	for(ll i=1;i<sum+1;i++)
		ar[i]=1000000000000;
	ar[0]=0;
	for(ll j=0;j<N;j++)
		for(ll i=sum;i>=0;i--)
			if(i>=v[j].ss)
				ar[i]=min(ar[i],v[j].ff+ar[max((i-v[j].ss),0ll)]);
	ll ans=0;
	for(int i=0;i<sum+1;i++)
		if(ar[i]<=W)
			ans=i;
	cout<<ans<<endl;
}	


Measured memory_bytes: 1024
import java.util.*;

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 count = 0;
    if(A == B) count++;
    if (B == C) count++;
    if (A == C) count++;

    if (count == 1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

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

  if(n==1){
    cout << 0 << endl;
    return 0;
  }

  vector<int> c(n);
  vector<int> s(n);
  vector<int> f(n);

  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

  rep(i,n-1){
    int t = s[i] + c[i];
    for(int j = i + 1; j < n-1; j++){
      if(s[j] > t) t = s[j] + c[j];
      else{
        int tmp = s[j];
        while(t>tmp){
          tmp += f[j];
        }
        t = tmp + c[j];
      }
    }
    cout << t << endl;
  }

  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main(){
    ll n;
    cin >> n;
    ll ans = n * (n-1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<unordered_map>
using namespace std ;

#define MAXN 200007

int n ;
pair < int , int > a[ MAXN ] ;

vector < pair < int , int > > srt ;

int cnt[ MAXN ] ;
int sm = 0 ;


long long f ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        cnt[ i ] = 0 ;
    }
    int sz = srt.size ( ) ;
    int en = -1 ;
    int sm = 0 ;
    long long mnint = -1 ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( en < i ) {
            ++ cnt[ srt[ i ].second ] ;
            ++ sm ;
            en = i ;
        }
        while ( en < sz - 1 && sm < n ) {
            ++ en ;
            ++ cnt[ srt[ en ].second ] ;
            if ( cnt[ srt[ en ].second ] == 1 ) { ++ sm ; }
        }
        if ( sm == n ) {
            long long sr = srt[ en ].first - srt[ i ].first ;
            if ( mnint < 0 || mnint > sr ) { mnint = sr ; }
        }
        -- cnt[ srt[ i ].second ] ;
        if ( cnt[ srt[ i ].second ] == 0 ) { -- sm ; }
    }
    return mnint * ( srt[ sz - 1 ].first - srt[ 0 ].first ) ;
}

long long obtain ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        cnt[ i ] = 0 ;
    }
    int sz = srt.size ( ) ;
    long long fst = -1 ;
    long long lst = -1 ;
    int sm = 0 ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( cnt[ srt[ i ].second ] > 0 ) {
            if ( fst == -1 ) { fst = srt[ i ].first ; }
        }
        else {
            cnt[ srt[ i ].second ] = 1 ;
            ++ sm ;
            if ( sm == n ) { lst = srt[ i ].first ; }
        }
        if ( sm == n && fst > -1 ) { break ; }
    }
    return ( lst - srt[ 0 ].first ) * ( srt[ sz - 1 ].first - fst ) ;
}

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d%d" , &a[ i ].first , &a[ i ].second ) ;
        srt.push_back ( { a[ i ].first , i } ) ;
        srt.push_back ( { a[ i ].second , i } ) ;
    }
    sort ( srt.begin ( ) , srt.end ( ) ) ;
}

void solve ( ) {
    if ( n == 1 ) {
        printf ( "0\n" ) ;
        return ;
    }
    int sz = srt.size ( ) ;
    long long ans = obtain ( ) ;
    if ( srt[ sz - 1 ].second != srt[ 0 ].second ) {
        ans = min ( ans , f ( ) ) ;
    }
    printf ( "%lld\n" , ans ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 7408
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
    int a, b, c;
    long long k;
    cin >> a >> b >> c >> k;
    
    a -= b;
    a = k%2 ? -a : a;

    if (abs(a) > 10e8)
        cout << "Unfair" << endl;
    else
        cout << a << endl;

}



Measured memory_bytes: 256
H,W=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(H)]

INF=10**10
tmp=[[INF]*10 for i in range(10)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            tmp[i][j]=min(c[i][k]+c[k][j] for k in range(10))
            c[i][j]=min(tmp[i][j],c[i][j])

ans=0
for i in range(H):
    for j in range(W):
        if a[i][j]!=-1: ans+=c[a[i][j]][1]
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const ll INF = (ll) 1e18;
const int BITS = 18;
const int MAX = (1 << 18) + 5;
const int MAX_VAL = 1e5 + 5;
vector<ii> queries[MAX];
ll memo[BITS][MAX_VAL];
vector<int> visited_states[BITS];
vector<int> dfs_stack;
multiset<int> weights;
int v[MAX], w[MAX];
int n, min_weight[BITS];

ll roll(int idx, int limit) {
    if (limit < 0) {
        return -INF;
    }
    if (idx == -1) {
        return 0;
    }
    if (min_weight[idx] > limit) {
        return 0;
    }
    ll &ans = memo[idx][limit];
    if (~ans) {
        return ans;
    }
    visited_states[idx].push_back(limit);
    int node = dfs_stack[idx];
    ans = max(roll(idx - 1, limit), roll(idx - 1, limit - w[node]) + v[node]);
    return ans;
}

ll ans[MAX];
void dfs(int node) {
    if (node > n) return;
    weights.insert(w[node]);
    int id = dfs_stack.size();
    dfs_stack.push_back(node);
    min_weight[id] = *weights.begin();
    for (auto &each : queries[node]) {
        int l, idx;
        tie(l, idx) = each;
        ans[idx] = roll(id, l);
    }
    dfs(2 * node);
    dfs(2 * node + 1);
    dfs_stack.pop_back();
    id = dfs_stack.size();
    for (auto &each : visited_states[id]) memo[id][each] = -1;
    visited_states[id].clear();
    weights.erase(weights.find(w[node]));
}

void solve() {
    scanf("%d", &n);
    fori (i, 1, n + 1) scanf("%d %d", v + i, w + i);
    int q;
    scanf("%d", &q);
    fori (i, 0, q) {
        int k, l;
        scanf("%d %d", &k, &l);
        queries[k].emplace_back(l, i);
    }
    memset(memo, -1, sizeof memo);
    dfs(1);
    fori (i, 0, q) {
        printf("%lld\n", ans[i]);
    }
}

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



Measured memory_bytes: 33120
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()

#print(A)
#print(B)
#print(C)

ans = 0
for b in B:
    a = bisect.bisect_right(A, b-1)
    c = N - bisect.bisect_right(C, b)
    #print("smaller",a,"bigger",c)
    ans += a*c

print(ans)

Measured memory_bytes: 23360