akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

int mpow(int base, ll exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;
void iluzn(){
int x;
cin>>x;
if(x)  cout<<0;
else
  cout<<1;
// cout<<83;
}




 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, ll exp) {
  base %=mod ;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10696
#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int c = getInt();

  REP(cc, c){
    const int p = std::abs(getInt());
    const int q = std::abs(getInt());

    const int mx = max(p, q);

    bool ans = false;
    REP(n,mx + 1) REP(m,mx + 1){
      if(n + m <= 1 ||
         (n == p && m == q) ||
         (m == p && n == q))
        continue;

      const int dbl = n * n + m * m;
      if((m * p + n * q) % dbl == 0 &&
         (m * q - n * p) % dbl == 0)
        ans = true;
    }

    puts(ans ? "C" : "P");
  }

  return 0;
}

Measured memory_bytes: 1012
#include<stdio.h>
int main(void){
    int x,y,temp;
    while (1){
        scanf("%d%d",&x,&y);
        if(x==0 && y==0){
            break;
        }
        if(x>y){
            temp = x;
            x = y;
            y = temp;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> edge [100001];
int dp [100001],dp2 [100001],par [100001];

void dfs(int curr,int prev)
{
	dp [curr] = 0;
	for(const auto& it : edge [curr]) if(it != prev){
		dfs(it,curr);
		par [it] = curr;
		if(dp [it] == 0){
			dp [curr] = 1;
		}
	}
}

void dfs2(int curr,int prev,int val)
{
	dp2 [curr] = val;
	int sum = 0;
	if(prev != -1){
		sum += dp2 [curr] == 0;
	}
	for(const auto& it : edge [curr]) if(it != prev){
		sum += dp [it] == 0;
	}
	for(const auto& it : edge [curr]) if(it != prev){
		if(sum - (dp [it] == 0) > 0){
			dfs2(it,curr,1);
		}
		else{
			dfs2(it,curr,0);
		}
	}
}

int main()
{
	scanf("%d",&N);
	FOR(i,0,N - 1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u].push_back(v);
		edge [v].push_back(u);
	}

	dfs(1,-1);
	dfs2(1,-1,1);

	bool ans = false;
	FOR(i,1,N + 1){
		bool b = true;
		for(const auto& it : edge [i]) if(it != par [i]){
			b &= dp [it];
		}
		b &= dp2 [i];
		ans |= b;
	}
	printf("%s\n",ans ? "First" : "Second");

	return 0;
}


Measured memory_bytes: 7040
n = gets.chomp.to_i
pn = gets.chomp.split.map(&:to_i)

result = 1

if pn.size == 1
  puts 1
  exit
end

p_min = pn[0]

pn.each_with_index do |pi, i|
  if i == pn.size - 1
    next
  end

  if p_min >= pn[i + 1]
    p_min = pn[i + 1]
    result += 1
  end

end

puts result


Measured memory_bytes: 16520
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, K; cin >> N >> K;
    cout << 1 + (N - K + K - 1 -1) / (K - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [110]
a = list(map(int, input().split()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
    
print(Alis-Bob)

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

#include <atcoder/segtree>
int op(int a, int b){ return max(a,b); } // 処理
int e(){ return 0; } // 単位元
using MONOID = int;
using SEG_T = atcoder::segtree<MONOID, op, e>;
#define SEGT_MAX 300001

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

	int n, k; cin>>n>>k;
	SEG_T seg(SEGT_MAX);
	for(int i=0; i<n; ++i){
		int a; cin>>a;
		int l = max(0, a - k);
		int r = min(a + k + 1, SEGT_MAX);
		int longest = seg.prod(l, r); // [l,r)
		seg.set(a, longest + 1);
	}
	cout<< seg.all_prod() <<endl;
}


Measured memory_bytes: 8472
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,0,n) cin >> a[i];
  int cnt=0;
  rep(i,0,n){
    if(a[i]<0) cnt++;
  }
  vector<ll> ab(n);
  rep(i,0,n) ab[i]=abs(a[i]);
  ll t=0;
  rep(i,0,n) t+=ab[i]; 

  if(cnt%2==0){
    cout << t << endl;
    return 0;
  }
  sort(ab.begin(), ab.end());
//  cout << cnt <<' ' << ab[0] << ' ' << t << endl;
  cout << t - ab[0]*2 << endl;
  return 0;
}

Measured memory_bytes: 4844
import math

n=int(input())
n_sqrt=int(math.sqrt(n))

ans=[]

for i in range(1,n_sqrt+1):
  if n%i==0:
    x=int(max(math.log10(i)+1,math.log10(n//i)+1))
    ans.append(x)

print(min(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n;
    sci(n);
    vi a(n+1);
    vll pref(n+1);
    pref[0] = 0;
    rep(i,1,n){
        sci(a[i]);
        pref[i] = pref[i-1] + a[i];
    }
    vvll dp(n+1,vll(n+1));//dp[i][j] = maxtotal X in the (i,j) sequence.
    rep(i,1,n){
        dp[i][i] = a[i];
        dp[0][i] = dp[i][0] = 0;
    }
    for(int length = 2;length <= n;++length){
        for(int start = 1,end = length; end <= n;++start,++end){
            ll sum = pref[end] - pref[start-1];
            dp[start][end] = max(sum - dp[start+1][end],sum - dp[start][end-1]);
        }
    }
    cout << 2*dp[1][n] - pref[n] << endl;
}

Measured memory_bytes: 73752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

long long GCD(long long a, long long b) {
	if(b == 0)
		return a;
	else
		return GCD(b, a % b);
}

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

	int table[1000001];
	for(int i = 0; i < 1000001; i++) table[i] = 0;

	for(int i = 0; i < N; i++) {
		int tmp = A[i];
		for(int a = 2; a * a <= tmp; a++) {
			if(tmp % a != 0) continue;
			long long ex = 0;

			while(tmp % a == 0) {
				ex = 1;
				tmp /= a;
			}

			table[a] += ex;
			// cout << a << " " << table[a] << "\n";
		}
		if(tmp != 1) {
			table[tmp]++;
			// cout << tmp << " " << table[tmp] << "\n";
		}
	}
	bool flag = true;
	for(int i = 0; i < 1000001; i++) {
		if(table[i] >= 2) {
			flag = false;
			break;
		}
	}
	if(flag) {
		cout << "pairwise coprime";
		return 0;
	}

	int g = A[0];
	for(int i = 1; i < N; i++) g = GCD(g, A[i]);
	if(g == 1)
		cout << "setwise coprime";
	else
		cout << "not coprime";
	return 0;
}

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    vector<vector<int>> ope(M,vector<int>(2));
    rep(m,0,M) cin>>ope.at(m).at(0)>>ope.at(m).at(1);

    set<int> redInBox;
    redInBox.insert(0);
    vector<int> balls(N,1);

    for(auto o:ope){
        int fromB=o.at(0)-1,toB=o.at(1)-1;
        if(redInBox.count(fromB)){
            redInBox.insert(toB);
        }
        if(balls.at(fromB)==1) redInBox.erase(fromB);

        balls.at(fromB)--;
        balls.at(toB)++;
    }

    cout<<redInBox.size()<<endl;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <string.h>
 
int main(){
  int l, i, al[120] = {};
  char s[2048] ={};
  while(scanf("%s", s) != EOF){
     l = strlen(s);
    for(i = 0;i < l;i++) if('A' <= s[i] && 'Z' >= s[i]) s[i] += 'a' - 'A';
    for(i = 0;i < l;i++) if('a' <= s[i] && s[i] <= 'z') al[s[i] - 'a']++;
  }
  for(i = 0;i < 26;i++)
    printf("%c : %d\n", i + 'a', al[i]);
  return 0;
}


Measured memory_bytes: 2052
from math import gcd
k=int(input())
l=[]
for a in range(1,k):
    for b in range(a+1,k+1):
        l.append(gcd(a,b))
s=2*sum(l)+(k*(k+1))//2
for m in l:
    for c in range(1,k+1):
        s=s+2*gcd(c,m)
print(s)

Measured memory_bytes: 9316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n;
long long k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a.at(i);
  
  vector<int>s;
  vector<int>ord(n+1,-1);
  int c=1,l=0;
  {
  	int v=1;
    while(ord.at(v) == -1){
      	ord.at(v)=s.size();
      	s.push_back(v);
    	v=a.at(v-1);
    }
    c=s.size()-ord.at(v);
    l=ord.at(v);
  }
  
  if(k<l) cout<<s.at(k)<<endl;
  else{
  	k-=l;
    k%=c;
    cout<<s.at(l+k)<<endl;
  }
}

Measured memory_bytes: 5764
while True:
         n,k = map(int,input().split())
         if n == 0:
                  break
         a = [int(input()) for i in range(n)]
         s = [0]
         for i in range(n):
                  s.append(a[i]+s[i])
                  ans = 0
         for i in range(len(s) - k):
                  if ans < s[i + k] - s[i]:
                           ans = s[i + k] - s[i]
         print(ans)



Measured memory_bytes: 13320
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// AtCoder Beginner Contest 140
int main(){

    int n;
    cin >> n;

    vector<int> b(n - 1);
    rep(i, n - 1)cin >> b[i];

    const int inf = 1000000;
    vector<int> a(n, inf);
    rep(i, n - 1){
        chmin(a[i], b[i]);
        chmin(a[i + 1], b[i]);
    }

    int ans = 0;
    rep(i, n)ans += a[i];
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys

n, k = map(int, input().split())
element = [None]*n

for i in range(n):
  element[i] = [int(x) for x in input().split()]

element.sort()

c = 0
for i in range(n):
  c += element[i][1]
  if c >= k:
    print(element[i][0])
    sys.exit()

Measured memory_bytes: 26052
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INOUT freopen(name".inp","r", stdin); freopen(name".out","w",stdout);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pb push_back
#define ppb pop_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fab(i,a,b) for(i=a;i<=b;i++)
#define f0r(i,n) for(i=n-1;i>=0;i--)
#define f1r(i,n) for(i=n;i>=1;i--)
#define fabr(i,a,b) for(i=b;i>=a;i--)
#define hi cout<<"hi\n";

#define ln "\n"

using namespace std;
const ld pi=acos(-1);
const ll mod=1e9+7;
const ll MAX=INT_MAX;
const ll MIN=INT_MIN;

//strstream


int main()
{
    FAST;
    ll t,n,i,j,k,len,x,y,z,c,f,flag,p,q,mx,mn,l,r,sum,ans,tmp,it,pos;
    string s;
    char ch;
    vll v;
    t=1;
    while(t--)
    {
        cin>>n;
        ll a[n+1];
        f1(i,n)
        cin>>a[i];
        
        ans=a[0];mn=MIN;
        ll mem[n+1];
        mem[0]=0;
        mem[1]=0;
        mem[2]=abs(a[2]-a[1]);
        
        fab(i,3,n)
        {
            mem[i]=min(mem[i-1]+abs(a[i]-a[i-1]),mem[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<mem[n]<<ln;
    }
	return 0;
}


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


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    for( int i = 0 ;i < 5 ; i ++){
        if(arr[i] == 0 ){
            cout<< i+1;
            break;
        }
    }

    return 0;


    



    

}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        for (int i=0; i<N; i++) {
            p[i] = sc.nextInt();
        }

        System.out.println(solve(N, K, p));
    }

    private static double solve(int N, int K, int[] p) {
        double[] exp = new double[N];
        for (int i=0; i<N; i++) {
            exp[i] = (1+p[i])  / 2.0;
//            System.err.print(exp[i] + " ");
        }


        double sum = 0;
        for (int k=0; k<K; k++) {
            sum += exp[k];
        }

        double max = sum;
        for (int k=K; k<N; k++) {
            sum = sum - exp[k-K] + exp[k];
            max = Math.max(max, sum);
        }

        return max;
    }
}

Measured memory_bytes: 83352
import Control.Applicative
import Debug.Trace
import Data.Char (ord)

solve (a:as) bs cs 0 = solve as bs cs a
solve as (b:bs) cs 1 = solve as bs cs b
solve as bs (c:cs) 2 = solve as bs cs c
solve _ _ _ 0 = "A"
solve _ _ _ 1 = "B"
solve _ _ _ 2 = "C"

charToInt c = ord c - ord 'a'

main = do
    [a, b, c] <- map (map charToInt) <$> lines <$> getContents
    putStrLn $ solve a b c 0


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

using namespace std;

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

  int total = accumulate(T.begin(), T.end(), 0);
  for (int i = 0; i < M; i++) {
    cout << total - T[P[i] - 1] + X[i] << "\n";
  }

  return 0;
}


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

int N, M, Q;
long long ans = 0;
vector<int> a(50), b(50), c(50), d(50);

void dfs(vector<int> v, int depth, int lastNum) {
	if (depth == N) {
		// 数列が完成したらスコア計算
		long long score = 0;
		for (int i = 0; i < Q; i++) {
			if (v[b[i] - 1] - v[a[i] - 1] == c[i])score += d[i];
		}
		ans = max(ans, score);
	}
	else {
		for (int i = lastNum; i < M + 1; i++) {
			// 末尾の数字以上の数字を結合したパターン分岐
			vector<int>nw = v;
			nw.push_back(i);
			dfs(nw, depth + 1, i);
		}
	}

}

int main() {
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	vector<int> v;
	dfs(v, 0, 1);
	cout << ans;
}

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

typedef long long ll;
typedef unsigned long long ull;

const int MOD=1e9+7;

struct modint {
    int val;
    modint inv() const{
        int tmp,a=val,b=MOD,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return modint(x);
    }
public:
    modint():val(0){}
    modint(ll x){if((val=x%MOD)<0)val+=MOD;}
    modint pow(ll t){modint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    modint& operator+=(const modint& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
    modint& operator-=(const modint& x){if((val+=MOD-x.val)>=MOD)val-=MOD; return *this;}
    modint& operator*=(const modint& x){val=(ll)val*x.val%MOD; return *this;}
    modint& operator/=(const modint& x){return *this*=x.inv();}
    bool operator==(const modint& x) const{return val==x.val;}
    bool operator!=(const modint& x) const{return val!=x.val;}
    bool operator<(const modint& x) const{return val<x.val;}
    bool operator<=(const modint& x) const{return val<=x.val;}
    bool operator>(const modint& x) const{return val>x.val;}
    bool operator>=(const modint& x) const{return val>=x.val;}
    modint operator+(const modint& x) const{return modint(*this)+=x;}
    modint operator-(const modint& x) const{return modint(*this)-=x;}
    modint operator*(const modint& x) const{return modint(*this)*=x;}
    modint operator/(const modint& x) const{return modint(*this)/=x;}
};

struct factorial {
    vector<modint> Fact, Finv;
public:
    factorial(int _n): Fact(_n+1), Finv(_n+1) {
        Fact[0]=modint(1); for (int i = 0; i < _n; ++i) Fact[i+1]=Fact[i]*(i+1);
        Finv[_n]=modint(1)/Fact[_n]; for (int i = _n; i > 0; --i) Finv[i-1]=Finv[i]*i;
    }
    modint fact(int n,bool inv=0) { if (inv) return Finv[n]; else return Fact[n]; }
    modint nPr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[n-r]; }
    modint nCr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main() {
  int x, y;
  cin >> x >> y;
  if ((x+y) % 3 != 0) { 
    cout << 0 << endl;
    return 0;
  }
  factorial fact(1000010);
  int move = (x+y)/3;
  int x1y2 = (move - (x-y))/2;
  int x2y1 = (move - (y-x))/2;
  // cerr << move << " " << x1y2 << " " << x2y1 << endl;
  cout << fact.nCr(move, x1y2).val << endl;
}


Measured memory_bytes: 8064
# include <iostream>

using namespace std;

int main(){

int n;
  cin >> n;
  
  int sum=0;
  int largest=0;
  int p;
  for(int i=0;i<n;i++){
  cin >> p;
    sum+=p;
    largest=max(largest,p);
  
  }
  cout << sum-largest/2 << endl;


}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int n, m;
queue<int> a;
vector<ll> c;
ll mod = 1000000007;

ll get(int to)
{
    if (to == a.front())
    {
        a.pop();
        return 0LL;
    }

    ll prev1, prev2;
    if (to == 1)
    {
        prev1 = c[to - 1];
        prev2 = 0LL;
    }
    else
    {
        prev1 = c[to - 1];
        prev2 = c[to - 2];
    }

    return prev1 + prev2;
}

int main()
{
    cin >> n >> m;
    c.resize(n);
    for (int i = 0; i < m; i++)
    {
        int tmp;
        cin >> tmp;
        a.push(tmp);
    }

    c[0] = 1LL;
    for (int i = 1; i < n; i++)
    {
        c[i] = get(i) % mod;
    }
    cout << get(n) % mod << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int a,b,k;
int main()
{
    k=read();a=read();b=read();
    for(int i=k;i<=b;i+=k)
        if(a<=i)
        {
            puts("OK");
            return 0;
        }
    puts("NG");
}


Measured memory_bytes: 2992
n, m, x = map(int, input().split())
c = [0] * n
a = [[]] * n
for i in range(n):
	c[i], *a[i] = map(int, input().split())
ans = 2**32
for mask in range(1 << n):
	res = [0] * m
	cost = 0
	for i in range(n):
		if mask >> i & 1:
			cost += c[i]
			for j in range(m):
				res[j] += a[i][j]
	if all(v >= x for v in res):
		ans = min(ans, cost)
print(ans if ans != 2**32 else -1)

Measured memory_bytes: 9104
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

X = input()

t_cnt, s_cnt = 0, 0
for Xi in X:
    if Xi == "S":
        s_cnt += 1
    elif Xi == "T":
        if s_cnt > 0:
            s_cnt -= 1
        else:
            t_cnt += 1

print(t_cnt + s_cnt)

Measured memory_bytes: 4264
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int a,b;

int main(){
    scanf("%2d%2d", &a, &b);
    if((a > 12 or !a) and (b > 12 or !b)) cout <<"NA";
    else if(a > 12 or !a) cout <<"YYMM";
    else if(b > 12 or !b) cout <<"MMYY";
    else cout <<"AMBIGUOUS";
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100010,M = 0x3f3f3f3f;
//int n,num[N],m[N],dp[N][3],ans;
//char s[N];
int main(){
	long long a,b,k;
	scanf("%lld %lld %lld",&a,&b,&k);
	int t=1;
	while(k--){
		if(t){
			if(a%2==0){
				a/=2;
				b+=a;
			}
			else{
				a-=1;
				a/=2;
				b+=a;				
			}
			t=0;
		}
		else{
			if(b%2==0){
				b/=2;
				a+=b;
			}
			else{
				b-=1;
				b/=2;
				a+=b;				
			}			
			t=1;
		}
	}
	printf("%lld %lld\n",a,b);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 2);
  A[0] = 0;
  for (int i = 1; i <= N; i++)
    cin >> A[i];
  A[N + 1] = 0;
  int sum = 0;
  for (int i = 0; i <= N; i++)
    sum += abs(A[i] - A[i + 1]);
  for (int i = 1; i <= N; i++)
    cout << sum - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]) << endl;
  return 0;
}

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

int main(void){
    int M, N, Abuf;
    int Asum = 0;
    vector<int> A;
    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        Asum += Abuf;
    }
    sort(A.begin(), A.end(), greater<int>());
    if(A[M-1]*4*M >= Asum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
// Created by Jaikirat Sandhu on 16/06/18.
//

#include <iostream>
#include <vector>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int A, B;
    cin >> A >> B;

    if(A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    }else {
        cout << ":(" << endl;
    }
}

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

int main() {
  int N;
  std::cin >> N;
  
  int i = 0;
  bool flg = false;
  while (i < N){
    string st;
    std::cin >> st;
    if (st == "Y"){
      flg = true;
    }
    i++;
  }
  if (flg){
    std::cout << "Four" << std::endl;
  }
  else{
    std::cout << "Three" << std::endl;
  }
}


Measured memory_bytes: 3612
from collections import deque

n,m = map(int,input().split())
a = [[] for _ in range(n)]

for i in range(m):
    x, y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

c = [0]*n
que = deque([])
que.append(0)

while len(que) > 0:
    e = que.popleft()
    for i in a[e]:
        if c[i] > 0:
            continue
        c[i] = e + 1
        que.append(i)
print("Yes")
for i in range(1,n):
    print(c[i])
    

Measured memory_bytes: 36940
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cEdges=vector<vector<pair<int,int>>>;

int main() {
	string str;
	cin>>str;
	if(str.size()==2){
		cout<<(str[0]==str[1]?"1 2":"-1 -1")<<endl;
	}
	else{
		bool flag=false;
		for(int i=0;i<str.size()-2;++i){
			if(str[i]==str[i+1] || str[i]==str[i+2] || str[i+1]==str[i+2]){
				cout<<i+1<<" "<<i+3<<endl;
				flag=true;
				break;
			}
		}
		if(!flag)cout<<-1<<" "<<-1<<endl;
	}
	//system("pause");
	return 0;
}

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

int n,arr[200009];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
    if(arr[1]>0)
    {
        printf("-1\n");
        return 0;
    }
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        if(arr[i]-arr[i-1]>1)
        {
            printf("-1\n");
            return 0;
        }
        if(arr[i]-arr[i-1]==1)continue;
        ans+=arr[i-1];
    }
    ans+=arr[n];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
def partition(A, p, r):
    x = A[r]
    i = p
    for j in range(p, r):
        if A[j] <= x:
            A[i], A[j] = A[j], A[i]
            i += 1
            
    A[i], A[r] = A[r], A[i]
    return i

n = int(input())
A = list(map(int, input().split()))
r = partition(A, 0, n-1)

ans = [str(x) for x in A]
ans[r] = '[{}]'.format(ans[r])
print(' '.join(ans))


Measured memory_bytes: 16592
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

ll a, b, c, k;

int main()
{
	cin >> a >> b >> c >> k;
	if (k&1)
		cout << b-a << endl;
	else
		cout << a-b << endl;
	return 0;
}


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

namespace AtCoder
{
    class Abc117D
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = nk[0];
            var k = nk[1];

            long kk = k;
            int digitN = 0;
            while (kk > 0)
            {
                digitN++;
                kk >>= 1;
            }

            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            if (k == 0)
            {
                Console.WriteLine(a.Sum());
                return;
            }

            long kMaxCase  = 0;
            long otherCase = 0;

            long mask = 1L << (digitN - 1);
            for (int j = 0; j < n; j++)
            {
                kMaxCase  += mask & (a[j] ^ mask);
                otherCase += mask & (a[j] ^ 0);
            }
            mask >>= 1;

            for (int i = 1; i < digitN; i++)
            {
                long bit0Value = 0;
                long bit1Value = 0;
                for (int j = 0; j < n; j++)
                {
                    bit1Value += mask & (a[j] ^ mask);
                    bit0Value += mask & (a[j] ^ 0);
                }

                otherCase += Math.Max(bit0Value, bit1Value);

                if ((k & mask) == 0)
                    kMaxCase += bit0Value;
                else
                {
                    otherCase = Math.Max(otherCase, kMaxCase + bit0Value);
                    kMaxCase += bit1Value;
                }
                mask >>= 1;
            }

            var ans = Math.Max(otherCase, kMaxCase);
            mask = ~((1L << digitN) - 1);
            ans += a.Select(i => i & mask).Sum();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31324
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int a,b,c,d;
  cin >>a >>b>>c>>d;
  int cnta = (c+b-1)/b;
  int cntb = (a+d-1)/d;
  if(cnta<=cntb){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define D(i,j) ((i)*y+(j))
#define MP(i,j) mp[D(i,j)]

int x,y,xy,opt;
int ed;
int d[4];

void solve(char mp[],int s,int now){
  int i,j,k,r;
  int c,dir,tmp;
  int dis[120], q[120], q_st, q_size;
  char send[120];

/*  printf("%d %d\n",s,now);
  rep(i,x){ rep(j,y) putchar(MP(i,j)); puts(""); }*/

  rep(i,xy) dis[i]=-1; dis[s]=0;
  q[0]=s; q_st=0; q_size=1;
  while(q_size){
    i=q[q_st++]; q_size--;
    rep(k,4){
      j=i+d[k];
      if(mp[j]=='#' || mp[j]=='w' || mp[j]=='c' || dis[j]>=0) continue;
      dis[j]=dis[i]+1;
      q[q_st+q_size++]=j;
    }
  }

  if(dis[ed]>=0 && now+dis[ed]<opt) opt=now+dis[ed];
  rep(r,xy) if(mp[r]=='c') rep(k,4){
    i=r-d[k]; if(dis[i]==-1) continue;
    rep(j,xy) send[j]=mp[j];
    c=r; dir=d[k];
    for(;;){
      if(send[c+dir]=='#' || send[c+dir]=='c') break;
      if(send[c+dir]=='w'){send[c]='.'; send[c+dir]='.'; c=-1; break;}
      send[c]='.'; send[c+dir]='c';
      c+=dir;
    }
    if(c==r) continue;
    solve(send,i,now+dis[i]);
  }
}

int main(){
  int i,j,k,l,m,n;
  char mp[120];
  int s;

  for(;;){
    scanf("%d%d",&x,&y); if(!x)break;
    opt=1000000000;

    xy=x*y;
    rep(i,x) scanf("%s",mp+i*y);
    rep(i,xy) if(mp[i]=='@') mp[i]='.', s=i;
    rep(i,xy) if(mp[i]=='E') mp[i]='.', ed=i;

    d[0]=1; d[1]=-1; d[2]=y; d[3]=-y;
    solve(mp,s,0);
    if(opt==1000000000) opt=-1;
    printf("%d\n",opt);
  }
  
  return 0;
}

Measured memory_bytes: 432
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    lint a, b, c, K;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &K);
    lint ans = 0;
    ans += min(a, K);
    K = max(0LL, K-a-b);
    ans -= min(c, K);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){//予選決勝法、左と右の予選に分けてそれらの最大で決勝をする
	int n;cin>>n;
	string s;cin>>s;

	int l[n+1],r[n+1];//境目で左右に分けて、左側にある白の数と右側にある黒の数を足して
	l[0]=0;r[n]=0;//小さいものを答えとする

	for(int i=0;i<n;i++){
		if(s[i]=='#') l[i+1]=l[i]+1;
		else l[i+1]=l[i];
	}
	for(int i=n-1;i>=0;i--){
		if(s[i]=='.') r[i]=r[i+1]+1;
		else r[i]=r[i+1];
	}

	int ans=inf;
	for(int i=0;i<=n;i++) ans=min(ans,l[i]+r[i]);

	cout<<ans<<endl;
}

Measured memory_bytes: 2180
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string a, b;
    cin >> a >> b;
    int num = stoi(a + b);
    int sq = sqrt(num);
    if (sq * sq == num)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# E - Crested Ibis vs Monster
H, N = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a,b))

max_a = max(AB[i][0] for i in range(N))
DP = [10**18 for i in range(H + max_a + 1)]
DP[0] = 0
for i in range(1, H + max_a):
    DP[i] = min(DP[i - a] + b for a, b in AB)

print(min(DP[H:]))


Measured memory_bytes: 3704
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n;
    p_que queue;
    for (int i=0; i<2*n; ++i){
        scanf("%d", &q);
        queue.push(q);
    }
    int ans = 0;
    for (int i=0; i<n; ++i){
        queue.pop();
        int s = queue.top();
        queue.pop();
        ans += s;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(void)
{
    string err = "UNRESTORABLE";
    string _S = "";
    string S = "";
    string T = "";
    string ret = "";

    cin >> _S;
    cin >> T;

    for(int i = 0;i < _S.size();i++)
    {
        S = _S;
        for(int j = 0;j < T.size() && _S.size() > i + j;j++)
        {
            if(_S[i + j] == T[j] || _S[i + j] == '?')
            {
                S[i + j] = T[j];
                if(j == (T.size() - 1))
                {
                       replace(S.begin(), S.end(), '?', 'a');
                       if(ret == "" || ret > S)
                       {
                            ret = S;
                       }
                }
            }
            else
            {
                break;
            }
        }
    }

    if("" == ret)
    {
        ret = err;
    }

    cout << ret << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int INF = 4e6+10;
const int maxn = 2e5+10;

vector<int> g[maxn];

ll binpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)
			res*=a;
		a*=a;
		b/=2;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin >> x;
	for(ll A=-1123;A<1123;++A){
		ll a = (A*A*A*A*A);
		//cout << "a = " << a << '\n';
		if(a == x){
			cout << A << " " << 0 << '\n';
			return 0;
		}
		else if(a < x){
			for(ll B=-1123;B<0;++B){
				ll b = (B*B*B*B*B);
				if(a+(-b)==x){
					cout << A << " " << B << '\n';
					return 0;
				}
			}
		}
		else{
			for(ll B=1;B<1123;++B){
				ll b = (B*B*B*B*B);
				if(a+b==x){	
					cout << A << " " << B << "\n";
					return 0;
				}
			}
		}
	}
	return 0;
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int t;
	if(a > b)
	{
		t = a;
		a = b;
		b = t;
	}
	if(a > c)
	{
		t = a;
		a = c;
		c = t;
	}
	if(b > c)
	{
		t = b;
		b = c;
		c = t;
	}
	cout << a << " " << b << " " << c << endl;
	cin >> a;

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p = 1e9 + 7;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<int> inv(n + 1);
  inv[1] = 1;
  for (int i = 2; i <= n; i++) {
    inv[i] = (ll)(p - p / i) * inv[p % i] % p;
  }
  int ans = 0;
  for (int i = 0, j = 1; i < n; i++) {
    j = (ll)j * (p + 1) / 3 % p;
    ans = (ans + (ll)inv[n - i] * inv[n] % p * j) % p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int l;
 cin>>l;
 double d;
 d=1.0;
 d*=l;
 d/=3;
 d=d*d*d;
 std::cout << std::setprecision(8) << d << '\n';
 return 0;
}


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

using namespace std;

typedef long long ll;

ll x[64];

int main(int, char**)
{
	char b;
	cin >> b;
	if (b == 'A')
		cout << "T" << endl;
	else if (b == 'T')
		cout << "A" << endl;
	else if (b == 'C')
		cout << "G" << endl;
	else if (b == 'G')
		cout << "C" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,ab,ac;
	cin>>a>>b>>c;
	ab=fabs(a-b);
	ac=fabs(a-c);
	if(ab>ac)
	cout<<'B'<<endl;
	if(ac>ab)
	cout<<'A'<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)


int main() {
    string s ,t;
    cin >> s >> t;
    cout << t << s;

    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


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

using namespace std;
char str[13];

int main() {
    //  freopen("in.txt", "rt", stdin);
    int n;
    scanf("%d", &n);
    map<string, int> mp;
    long long ans = 0;
    while (n--) {
        scanf("%s", str);
        sort(str, str + 10);
        ans += mp[string(str)]++;
    }
    printf("%lld", ans);
}

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

int main() {
    string s;
    cin >> s;
    
    bool w=true;
    string forth,back;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if(t==1) w = !w;
        else{
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(w==true && f==1) forth += c;
            else if(w==false && f==2) forth += c;
            else back += c ;
        }
    }
    string ans;

    if(w==true){
        reverse(forth.begin(),forth.end());
        ans += forth;
        ans += s;
        ans += back;

        cout << ans << endl;
    }
    else{
        reverse(s.begin(),s.end());
        reverse(back.begin(),back.end());
        ans += back;
        ans += s;
        ans += forth;

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

Measured memory_bytes: 4244
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,l,r,ans;
bool check(int x){
	int sum=0;
	while(x){
		sum+=x%10;
		x/=10;
	}
	return (sum>=l&&sum<=r);
}
int main(){
	scanf("%d%d%d",&n,&l,&r);
	for(int i=1;i<=n;i++)if(check(i))ans+=i;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int num;
    cin >> num;
    int integer[num];
    for(int i = 0; i < num; i++) {
        cin >> integer[i];
    }
    int check = 0;
    int count = 0;
    while(check == 0) {
        for(int i = 0; i < num; i++) {
            if(integer[i] % 2 == 0) {

            } else {
                check++;
            }
        }
        if(check == 0) {
            for(int i = 0; i < num; i++) {
                integer[i] /= 2;
            }
            count++;
        }
        
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256