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

int main() {

  int A1;
  int A2;
  int A3;
  int x;
  
  cin >> A1;
  cin >> A2;
  cin >> A3;
  
  x = A1 + A2+ A3;
  
  if( x >= 22 ){
    
    cout << "bust" << endl;
    
  }
  else{
    
    cout << "win" << endl;
  }
  
}


Measured memory_bytes: 256
/* ex4_3: Stone Monument
    Jun_JPN */

#include <stdio.h>
#include <math.h>

int height(int w_tower, int e_tower);   // 雪の高さを求めるheight関数を宣言

int main(void){

    int w_tower, e_tower;

    scanf("%d %d", &w_tower, &e_tower);

    printf("%d\n", height(w_tower, e_tower));

    return 0;
}

int height(int w_tower, int e_tower){
    /* 西からn番目の塔が高さw_towerメートルだけ雪から出ていたすると，積雪の高さはn(n+1)/2 - w_towerメートル
        また，nは等式「e_tower - w_tower = n+1」から求まる */
    return (e_tower - w_tower - 1)*(e_tower - w_tower)/2 - w_tower;
}

Measured memory_bytes: 128
from math import gcd
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            tmp = gcd(gcd(i, j), k) * 6
            if i == j and j == k: tmp //= 6
            elif i == j or j == k or k == i: tmp //= 2
            ans += tmp
print(ans)


Measured memory_bytes: 68076
#include<bits/stdc++.h>
using namespace std;
#define maxn 200008
#define int long long
int n;
map<int,int> vis;
map<int,int> tar;
map<int,int> map1;
map<int,int> map2;
int v[maxn];
bool ok[maxn];
int ans=0;
int fa[maxn];
bool check[maxn];
int flag;
int a[maxn];
int b[maxn];
pair<int,int> tmp[maxn];
int ff=false;
void dfs(int u){
    cout<<u<<' ';
    if(u==a[n+1]){
        flag=1;
    }
    v[u]=1;
    if(v[map2[a[u]]]){
        return ;
    }else{
        dfs(map2[a[u]]);
    }
}
int find(int a){
    if(fa[a]==a)return a;
    return fa[a]=find(fa[a]);
}
main(){
  //  freopen("duliu.in","r",stdin);
  //  freopen("duliu.out","w",stdout);
    scanf("%lld",&n);
    int sum=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        vis[a[i]]++;
        sum^=a[i];
    }
    vis[sum]++;
    a[n+1]=sum;
    int ans=0;
    sum=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        tar[b[i]]++;
        sum^=b[i];
    }
    map<int,int>::iterator iter;
    for(iter=tar.begin();iter!=tar.end();iter++){
        if(vis[iter->first]<iter->second){
            cout<<-1<<endl;
            return 0;
        }
    }
    b[n+1]=sum;
    int tot=0;
    int cnt=0;
    int loop=0;
    for(int i=1;i<=n+1;i++){
        if(a[i]!=b[i]){
            tot++;
            if(!map1.count(a[i])){
                map1[a[i]]=++cnt;
                fa[cnt]=cnt;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=b[i]){
            fa[find(map1[a[i]])]=find(map1[b[i]]);
        }
    }
    for(int i=1;i<=n;i++){
        if(fa[i]==i){
            loop++;
        }
    }
    if(a[n+1]!=b[n+1])tot-=2;
    else if(map1.count(a[n+1]))tot-=1;
    cout<<tot+loop<<endl;
    return 0;
}

Measured memory_bytes: 26752
n = int(input())
a = list(map(int, input().split()))

def g(mid):
	for i in range(n):
		if f(mid * n + i):
			return True
	return False	

def f(mid):
	over = 0
	for x in a:
		over += (x + mid + 1) // (n + 1)
	return over <= mid

ok = 10 ** 30
ng = -1

while ok - ng > 1:
	mid = (ok + ng) // 2
	if g(mid):
		ok = mid
	else:
		ng = mid

for i in range(n):
	if f(ok * n + i):
		print(ok * n + i)
		break

Measured memory_bytes: 3064
<?php

while (($line = trim(fgets(STDIN))) !== '0 0') {
    sscanf($line, '%d %d', $H, $W);
    $map = new SplFixedArray($H);
    $visited = array();
    for ($i = 0; $i < $H; $i++) {
        $map[$i] = new SplFixedArray($W);
        $line = trim(fgets(STDIN));
        foreach (str_split($line) as $j => $ch) {
            $map[$i][$j] = $ch;
        }
    }

    $p = '0 0';
    $result = 'LOOP';
    while (!in_array($p, $visited)) {
        sscanf($p, '%d %d', $x, $y);
        $visited[] = $p;
        switch ($map[$y][$x]) {
            case '>':
                $p = sprintf('%d %d', $x + 1, $y);
                break;

            case '<':
                $p = sprintf('%d %d', $x - 1, $y);
                break;

            case '^':
                $p = sprintf('%d %d', $x, $y - 1);
                break;

            case 'v':
                $p = sprintf('%d %d', $x, $y + 1);
                break;

            default:
                $result = $p;
                break 2;
        }
    }

    echo $result, PHP_EOL;
}

Measured memory_bytes: 7860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long x;
		for(int i = 1;(x = Long.parseLong(br.readLine())) != 0;i++){
			System.out.printf("Case %d: %d%n", i, x);
		}
	}
}

Measured memory_bytes: 46540
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (int i = n - 1; i >= a; i--)
#define show(x) cout << x << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vpair vector<pair<ll, ll>>
#define vtuple vector<tuple<ll, ll, ll>>
#define ff first
#define ss second
#define mod 1000000007
#define memset(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ld r;
	cin>>r;
	cout<<fixed<<setprecision(20)<<(ld)2*M_PI*r<<endl;
	auto t2 = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
	clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 3804
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
tmp = []
cnd = 0
for i in range(n):
    cnd = sum(a[:i+1]) + sum(b[i:])
    tmp.append(cnd)
    cnd = 0
print(max(tmp))

Measured memory_bytes: 9176
#include <stdio.h>

int main(){
	
	int D=0;
	scanf("%d", &D);
	if (D==25){
		printf("Christmas\n", D);
	}
	if (D==24){
		printf("Christmas Eve\n", D);
	}
	if (D==23){
		printf("Christmas Eve Eve\n", D);
	}
	if (D==22){
		printf("Christmas Eve Eve Eve\n", D);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_S = 100005;
string check[4] = {"dream","dreamer","erase","eraser"};
bool ok[MAX_S];

int main()
{
	string S;
	cin >> S;
	ok[0] = true;
	for (int i = 1; i <= S.size(); ++i)
	{
		rep(j,4)
		{
			if (i >= check[j].size())
			{
				if (ok[i-check[j].size()] && S.substr(i-check[j].size(),check[j].size()) == check[j])
				{
					ok[i] = true;
				}
			}
		}
	}
	if (ok[S.size()])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
  double xa,ya,xb,yb,xc,yc,xd,yd,xan,yan,xanan,yanan;

  while(cin >>  xa>> ya>>xb>>yb>>xc>>yc>>xd>>yd){
      xan=xb-xa;
      yan=yb-ya;
      xanan=xd-xc;
      yanan=yd-yc;
      if((xan*xanan + yan*yanan )==0){
cout << "YES" << endl;
 
      }else{
   cout << "NO" << endl;
 
      }
    }


  



  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int n,K;
vector<int> A[7];
vector<int> tmp;
inline vector<int> getInv(vector<int> x)
{
	vector<int> res;
	for(rint i=1;i<=n;++i) res.pb(0);
	for(rint i=0;i<n;++i) res[x[i]]=i;
	return res;
}
inline vector<int> Mul(vector<int> p,vector<int> q)
{
	vector<int> res;
	for(rint i=0;i<n;++i) res.pb(p[q[i]]);
	return res;
}
inline vector<int> ksm(vector<int> x,int y)
{
	vector<int> res;
	for(rint i=0;i<n;++i) res.pb(i);
	while(y)
	{
 		if(y&1)res=Mul(res,x);
 		x=Mul(x,x);y>>=1;
	}return res;
}
int main()
{	
	n=read();K=read();
	for(rint i=1;i<=n;++i) {int x=read()-1;A[1].pb(x);}
	for(rint i=1;i<=n;++i) {int x=read()-1;A[2].pb(x);}
	for(rint i=3;i<=6;++i)
		A[i]=Mul(A[i-1],getInv(A[i-2]));
	tmp=Mul(Mul(A[2],getInv(A[1])),Mul(getInv(A[2]),A[1]));
	vector<int> res=ksm(tmp,(K-1)/6);
	res=Mul(Mul(res,A[(K-1)%6+1]),getInv(res));
	for(rint i=0;i<n;++i) cout<<res[i]+1<<" ";
	return 0;
}	

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[1000000];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=1000000;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(1000000);j+=i)
           { prime[j]=false;}

    }
    }
}

int main()
{
   ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  cin>>n;
  if(n&1)
  {

      cout<<(n/2)*((n/2) + 1);
  }
  else
  {
      cout<<(n/2)*(n/2);
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		LinkedList<Integer> list = new LinkedList<Integer>();

		for (int i=0; i<n; i++) {
			String str = br.readLine();

			if (str.startsWith("insert")) {
				list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}else if (str.equals("deleteFirst")) {
				list.pollFirst();
			}else if (str.equals("deleteLast")){
				list.pollLast();
			}else {
				list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}
		}

		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringBuilder sb = new StringBuilder();
		sb.append(list.poll());
		for (Integer s : list) {
			sb.append(" ");
			sb.append(s);
		}
		bw.write(sb.toString());
		bw.newLine();
		bw.close();

		br.close();
	}
}

Measured memory_bytes: 134924
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
// #include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <cassert>
#include<unordered_set>
using namespace std;

int main(){
    long long int n,k;
    cin >> n >> k;
    vector<int> a(n);
    // cout << "通過1" << endl;
    rep(i,n){
        cin >> a[i];
    }
    // cout << "通過" << endl;
    vector<long long int> town_visittime(n, -1);
    bool flag = true;

    int i=0;
    int next;

    town_visittime[0] = 0;

    long long int loopstart;
    long long int loopend;
    long long int count = 0;
    vector<long long int> visittime_town;

    while(flag){
        // cout << i+1 << endl;

        if(count == k){
            cout <<  i+1 << endl;
            return 0;
        }
        next=a[i]-1;
        visittime_town.push_back(i);
        if(town_visittime[next] < 0){
            town_visittime[next] = town_visittime[i]+1;
        }
        else{
            loopstart = town_visittime[next];
            loopend = town_visittime[i];
            flag = false;                        
        }
        count++;
        i = next;
    }
    // cout << loopstart << ", " << loopend << endl;
    long long int loop = loopend - loopstart + 1;

    cout << visittime_town[loopstart + (k - (loopstart - 1) - 1)%loop]+1 << endl;

    
}

Measured memory_bytes: 7700
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL b = mod_pow(a, n / 2);
		return (b*b) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
int main() {
	LL m, n;
	cin >> m >> n;
	cout << mod_pow(m, n) << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N = 205;
const int MAX_LG = 60;

void add_to_basis (ll vec, vector<ll> &basis) {
  // invariant: smallest set bit of basis[i] is i
  for (int i = 0; i < MAX_LG; i++) {
    if (vec & 1LL << i) {
      if (basis[i] != -1) {
        vec ^= basis[i];
      }
    }
  }

  if (vec == 0) return;

  int idx = -1;
  for (int i = 0; i < MAX_LG; i++) {
    if (vec & 1LL << i) {
      idx = i;
      break;
    }
  }
  basis[idx] = vec;
}

bool in_span (ll vec, vector<ll> &basis) {
  for (int i = 0; i < MAX_LG; i++) {
    if (vec & 1LL << i) {
      if (basis[i] != -1) {
        vec ^= basis[i];
      }
    }
  }
  return vec == 0;
}

ll arr [MAX_N];

void solve () {
  int n;
  cin >> n;

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

  string s;
  cin >> s;

  vector<ll> basis (60, -1);
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '0') {
      add_to_basis(arr[i], basis);
    } else {
      if (!in_span(arr[i], basis)) {
        cout << 1 << '\n';
        return;
      }
    }
  }

  cout << 0 << '\n';
  return;
}

int main () {
  ios::sync_with_stdio(false);
  
  int testc;
  cin >> testc;

  for (int i = 0; i < testc; i++) {
    solve();
  }
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[][] count=new int[10][10];
        for(int k=1;k<=n;k++)
        {
           int j=k%10;
           String s=String.valueOf(k);
           int i=s.charAt(0)-'0';
            count[i][j]++;
        }
        int res=0;
        for(int i=0;i<=9;i++)
            for(int j=0;j<=9;j++)
            {
                res+=count[i][j]*count[j][i];
            }
        System.out.println(res);
    }
}


Measured memory_bytes: 32980
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
set<int>a;
int main()
{
    int n,choose,temp;
    cin >> n;
    while (n--)
    {
        cin >> choose;
        switch (choose)
        {
        case 0:
            cin >> temp;
            a.insert(temp);
            cout << a.size() << endl;
            break;
        case 1:
            cin >> temp;
            if (a.find(temp) == a.end())cout << 0 << endl;
            else cout << 1 << endl;
        }
    }
    
}


Measured memory_bytes: 12436
n = int(raw_input())

D = []
for i in range(0,4):
    bb = []
    for k in range(0,3):
        b = [0,0,0,0,0,0,0,0,0,0]
        bb.append(b)
    D.append(bb)

for i in range(0,n):
    [b,f,r,v] = raw_input().split()
    b = int(b) - 1
    f = int(f) - 1
    r = int(r) - 1
    v = int(v)
    D[b][f][r] = D[b][f][r] + v

for b in range(0,4):
    for f in range(0,3):
        s = ''
        for r in range(0,10):
            v = str(D[b][f][r])
            s = s + ' ' + v
        print s
    if b < 3:
        print "####################"

Measured memory_bytes: 4264
#include <stdio.h> 
int main(void){ 
int n,i,s,min,max,ave; 
int sum = 0; 
 
while(1){
 
scanf("%d",&n); 
scanf("%d",&s);

if(n==0)
break;

sum = s; 
max = s; 
min = s; 
for (i = 2;i <= n;i++){ 
    scanf("%d",&s); 
    sum += s; 
    if(s>max) 
    max = s; 
    if(s<min) 
    min = s; 
   
   ave = (sum-min-max)/(n-2); 
} 
printf("%d\n",ave); 
}
return 0; 
    
} 



Measured memory_bytes: 2036
//#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stack>
using namespace std;
typedef long long ll;
	ll a[1111111];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	ll tt=0;
	ll flag=0;
	
	for(int i=1;i<n;i++)
	{
		if(a[i]>=a[i+1])
			tt++;
		else
			tt=0;
		flag=max(flag,tt);
	}
	cout<<flag<<endl;
		
	return 0;
}



Measured memory_bytes: 1024
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

/////
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  int w; scanf("%d",&w);
  int n; scanf("%d",&n);
  vector<int> T(w);
  REP(i,w) T[i] = i;
  REP(i,n)
  {
    int a, b;
    scanf("%d,%d",&a,&b);
    swap(T[a-1],T[b-1]);
  }
  REP(i,w) cout << T[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

vector<int> kg[200001];
int g[200001], ss[200001];
P ps[200001];
bool s[200001], win[200002];

signed main() {
  int n;
  cin >> n;
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    kg[--a].pb(--b);
    kg[b].pb(a);
  }

  for(int i = 2; i <= n; i += 3) win[i] = true;

  queue<int> kq;
  kq.push(0);
  s[0] = true;
  while(!kq.empty()) {
    int x = kq.front(); kq.pop();
    rep(i, 0, kg[x].size()) {
      if(!s[kg[x][i]]) {
        s[kg[x][i]] = true;
        kq.push(kg[x][i]);
        g[kg[x][i]] = x;
      }
    }
  }

  queue<int> q;
  rep(i, 1, n) {
    if(kg[i].size() == 1) {
      q.push(i);
    }
  }

  int count = 0;
  while(!q.empty()) {
    count++;
    queue<int> kq;
    while(!q.empty()) {
      int x = q.front(); q.pop();
      int nxt = g[x];
      if(count > ps[nxt].second) ps[nxt].second = count;
      if(ps[nxt].second > ps[nxt].first) swap(ps[nxt].second, ps[nxt].first);
      if(nxt == 0) continue;
      ss[nxt]++;
      if(ss[nxt] >= kg[nxt].size() - 1) {
        kq.push(nxt);
        //cout << count << ": " << x + 1 << " → " << nxt + 1 << endl;
      }
    }
    q = kq;
  }
  int mx = 0;
  rep(i, 0, n) {
    mx = max(mx, ps[i].first + ps[i].second);
  }
  mx++;
  if(!win[mx]) {
    cout << "First" << endl;
  }else {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 19584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1010101010
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define mp make_pair

using namespace std;





int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



vector<ll> w1, w2, w3, w4;
int main() {
	int N, W;
	cin >> N >> W;
	ll w, v; cin >> w >> v;
	w1.pb(v);
	REP(i, N - 1) {
		int wei, val;
		cin >> wei>>val;
		if (wei == w)w1.pb(val);
		if (wei == w+1)w2.pb(val);
		if (wei == w+2)w3.pb(val);
		if (wei == w+3)w4.pb(val);
	}
	int A = w1.size(), B = w2.size(), C = w3.size(), D = w4.size();
	VSORT(w1); VSORT(w2); VSORT(w3); VSORT(w4);
	VREVERSE(w1); VREVERSE(w2); VREVERSE(w3); VREVERSE(w4);
	ll ans = 0;
	REP(a, A+1) {
		REP(b, B+1) {
			REP(c, C+1) {
				REP(d, D+1) {
					ll WWO = w * a + (w + 1)*b + (w + 2)*c + (w + 3)*d;
					if (WWO <= W) {
						ll res = 0;
						REP(i, a)res += w1[i];
						REP(i, b)res += w2[i];
						REP(i, c)res += w3[i];
						REP(i, d)res += w4[i];
						ans = max(ans, res);
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	string s;
	int first, end;
	bool f = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' && f == 0) {
			first = i;
			f = 1;
		}
		if (s[i] == 'Z') {
			end = i;
		}
	}
	cout << end - first+1 << endl;





		return 0;
}

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

using namespace std;

int csum[100001];

int main() {
	csum[1] = 0;
	for (int i = 2; i <= 100000; i++) {
		int times = 1;
		for (int x = 2; x * x <= i; x++) {
			if (i % x == 0) {
				times *= x;
				if (times >= 2 * i) {
					csum[i] = 1;
					break;
				}
				times *= (i / x);
				if (times >= 2 * i) {
					csum[i] = 1;
					break;
				}
			}
		}
		
	}

	for (int i = 1; i <= 100000; i++) {
		csum[i] += csum[i - 1];
	}
	
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int N;
		cin >> N;
		cout << csum[N] - csum[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3500
n = gets.chomp.to_i                                                           
                                                                              
                                                                              
yes_times = 0                                                                 
answer = 'No'                                                                 
                                                                              
n.times do                                                                    
  line = gets.chomp.split(" ").map(&:to_i)                                    
  if line[0] == line[1]                                                       
    yes_times += 1                                                            
  else                                                                        
    yes_times = 0                                                             
  end                                                                         
  if yes_times > 2                                                            
    answer = 'Yes'                                                            
    break                                                                     
  end                                                                         
end                                                                           
print answer

Measured memory_bytes: 14376
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
int main(){
    cin>>N>>M;
    cout<<((N==M)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = abc156c()

fun abc156c() {
    val n = readLine()!!.toInt()
    val xList = readLine()!!.split(' ').map { it.toLong() }

    var answer = Long.MAX_VALUE / 10

    for (i in 1..100) {
        val sum = xList.map { (i - it) * (i - it) }.sum()
        answer = Math.min(answer, sum)
    }

    println(answer)
}


Measured memory_bytes: 36512
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) sort(x.begin(),x.end())
#define RALL(x) sort(x.rbegin(),x.end())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
ll n;
ll MIN;
ll cnt;
ll sum;
/*signed*/int main(void) {
    cin >> n;
    MIN = INF;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        MIN = min(MIN, abs(a[i]));
        if (a[i] <= 0) ++cnt;
        sum += abs(a[i]);
    }
    (cnt % 2 ? cout << sum - MIN * 2 << endl : cout << sum << endl);
    return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <string>
int main(void) {
  using namespace std;
  string s = "abc";
  string inp;
  cin >> inp;
  for(auto c : s) {
    for(auto d : inp) {
      if(c == d) goto next;
    }
    // if inp does not have c
    cout << "No" << endl;
    return 0;
  next:
    ;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int n,a[10005];
long long sum;

int main()
{
	cin>>n;

	for(int i=1; i<=n; i++)
		cin>>a[i];
	for(int i=1; i<=n; i++)
		for(int j = i+1; j<=n; j++)
			sum += a[i]*a[j];

	cout<<sum<<endl;

	return 0;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/





ll a[N];


int main()
{
    ll a,b,c,x,y,i,j;
    cin>>a>>b;
    x=a-(2*b);
    if(x<0)
        x=0;
    cout<<x<<endl;
    return 0;

}
































Measured memory_bytes: 256
using System;

namespace AOJ
{
    namespace Rect{
        public static class Rectangle
        {
            public static void Main()
            {
                int Rect_width, Rect_height;
                int circumference, area;

                string[] x = Console.ReadLine().Split();
                Rect_width = int.Parse(x[0]);
                Rect_height = int.Parse(x[1]);

                circumference = 2 * (Rect_width + Rect_height);
                area = Rect_width * Rect_height;

                Console.WriteLine(area + " " + circumference);
            }
        }
    }
}


Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin >> n;
  int a[100][100];
  rep(i,n)rep(j,n)cin >> a[i][j];
  ll ans = 0;
  rep(i,n)loop(j,i+1,n){
      ans += min(a[i][j],a[j][i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
const long long Mod=1e9+7;
int N,M,cnt=0,c[50]={};
inline long long Mul(int x,int y){
	if(y==0) return 1;
	if(y==1) return x;
	long long X=Mul(x,y/2);
	if(y%2) return X*X%Mod*x%Mod;
	else return X*X%Mod;
}
inline long long C(int n,int m){
	long long Sum=1;
	for(long long i=n-m+1;i<=n;i++) Sum=Sum*i%Mod;
	for(long long i=1;i<=m;i++) Sum=Sum*Mul(i,Mod-2)%Mod;
	return Sum;
}
int main(){
	scanf("%d%d",&N,&M);
	long long x=M;
	for(int i=2;i*1LL*i<=x;i++){
		if(x%i==0){
			++cnt;
			for(;(x%i)==0;x/=i) ++c[cnt];
		}
	}
	if(x>1) c[++cnt]=1;
	long long Ans=1;
	for(int i=1;i<=cnt;i++)
	 Ans*=C(c[i]+N-1,N-1),Ans%=Mod;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 256
def find_minimum_normal_attack(monster_num, special_move_num, monster_healths):
    return sum(sorted(monster_healths, reverse=True)[special_move_num:])


if __name__ == '__main__':
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    print(find_minimum_normal_attack(n, k, h))


Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define vec vector

typedef uint8_t   i8;
typedef uint16_t  i16;
typedef int       i32;
typedef long long i64;

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

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

const i64 inf = 1LL << 60;
const i32 mod = 1e9 + 7;

using namespace std;

/* Input variables. */
i32 n;
vec<i64> h;
vec<i64> dp;

/* Solve! */
void solve() {
  dp = vec<i64>(n, inf);
  dp[0] = 0;
  irep(i, 1, n) {
    chmin(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
    if (i >= 2) chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
  }
  cout << dp[n - 1] << endl;
}

int main() {
  /* Input handling. */
  cin >> n;
  h = vec<i64>(n);
  rep(i, n) cin >> h[i];

  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

vector<vector<int>> dp[2];

vector<int> mov[2];

int main()
{
    string s;
    int goal[2];

    cin >> s;
    cin >> goal[0] >> goal[1];

    int curr = 0;
    while (curr < s.size() && s[curr] == 'F')
    {
        goal[0]--;
        curr++;
    }

    int axis = 0;
    int length = 0;
    while (curr < s.size())
    {
        if (s[curr] == 'T')
        {
            if (length != 0)
            {
                mov[axis].push_back(length);
            }
            axis = 1 - axis;
            length = 0;
        }
        else
        {
            length++;
        }
        curr++;
    }
    if (length != 0)
    {
        mov[axis].push_back(length);
    }
    for (int a = 0; a < 2; a++)
    {
        for (const int &v : mov[a])
        {
            goal[a] += v;
        }
    }
    if (goal[0] < 0 || goal[1] < 0)
    {
        cout << "No" << endl;
        return 0;
    }

    for (int a = 0; a < 2; a++)
    {
        dp[a].resize(mov[a].size() + 1);
        for (int i = 0; i < dp[a].size(); i++)
        {
            dp[a][i].resize(goal[a] + 1);
            for (int j = 0; j <= goal[a]; j++)
            {
                if (i == 0)
                {
                    dp[a][i][j] = j == 0 ? 1 : 0;
                    continue;
                }

                dp[a][i][j] = dp[a][i - 1][j];
                dp[a][i][j] += j - 2 * mov[a][i - 1] >= 0 ? dp[a][i - 1][j - 2 * mov[a][i - 1]] : 0;
            }
        }
    }

    cout << ((dp[0][mov[0].size()][goal[0]] != 0 && dp[1][mov[1].size()][goal[1]]) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 58496
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll g = gcd(n, m);
    ll L = n * m / g;

    for (int i = 0, j = 0; i < n; i += n / g, j += m / g) {
        if (s[i] != t[j]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << L << endl;
    return 0;
}

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

int main(){
    vector<int> abc(3);
    rep(i, 3) cin >> abc[i];
    sort(abc.begin(), abc.end());
    int ans = 0;
    if ( ( abc[2] - abc[0] ) % 2 == 0 && ( abc[2] - abc[1] ) % 2 == 0 ) {
        ans = ( abc[2] - abc[0] ) / 2 + ( abc[2] - abc[1] ) / 2;
    }
    else if ( ( abc[2] - abc[0] ) % 2 == 1 && ( abc[2] - abc[1] ) % 2 == 1 ) {
        ans = ( abc[2] - abc[0] ) / 2 + ( abc[2] - abc[1] ) / 2 + 1;
    }
    else {
        ans = ( abc[2] - abc[0] ) / 2 + ( abc[2] - abc[1] ) / 2 + 2;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
x = 0
# for a in A:
#     print(bin(a))
# print()
for a in A:
    x ^= a
idx = 0
for i in range(59, -1, -1):
    if x>>i & 1 == 0:
        for j, a in enumerate(A[idx:], idx):
            if a>>i & 1:
                break
        else:
            continue
        A[idx], A[j] = A[j], A[idx]
        for j in range(N):
            if j != idx and A[j] >> i & 1:
                A[j] ^= a
        idx += 1
s = 0
#for a in A:
#    print(bin(a))
for a in A:
    s ^= a
#print(f"s={bin(s)}")
for i in range(60):
    if x>>i & 1 == 1 and s>>i & 1:
        s ^= 1<<i
#print(x, s)
print(x + (s<<1))


Measured memory_bytes: 86136
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
  //
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> que;
  rep(i, n) {
    ll a;
    cin >> a;
    que.push(a);
  }
  if (n == 1) {
    ll a = que.top();
    while (m > 0) {
      a = a / 2;
      m--;
    }
    cout << a << endl;
    return 0;
  }
  ll r = m;
  while (r > 0) {
    ll a1 = que.top(); que.pop();
    ll a2 = que.top(); que.pop();
    while(r > 0 && a1 >= a2) {
      a1 = a1 /2;
      r--;
    }
    que.push(a1);
    que.push(a2);
  }
  ll ans = 0;
  while (!que.empty()) {
    ll a = que.top(); que.pop();
    ans += a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean t = true;
		if(s.length()%2!=0) {
			System.out.println("No");
		}else {
			for(int i=0;i<s.length();i+=2) {
				if(s.charAt(i)!='h'||s.charAt(i+1)!='i') {
					t = false;
					break;
				}
			}
			if(t == true) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
		}
	}
}


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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    int n,k;
    cin>>n>>k;
    int a[n],ans=0,t,s,p,q;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        t=0;s=0;
        for(int j=0;j<i;j++){
            if(a[j]<a[i])t++;
        }
        for(int j=i+1;j<n;j++){
            if(a[j]<a[i])s++;
        }
        p=(((k+1)*k)/2)%MOD;q=(((k-1)*k)/2)%MOD;
        ans=(ans+s*p+t*q)%MOD;
    }
    cout<<ans;
    

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const int MOD = 1e9 + 7;;
 
template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}
 
namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

char s[MAXN];
int n, sum[MAXN], nxt[MAXN][3];
int dp[MAXN], ans;

void init() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
}

void solve() {
	bool flag = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i + 1]) {
			flag = 0; break;
		}
	}
	if (flag) {
		printf("1\n");
		return;
	}
	for (int i = 1; i <= n; ++i) {
		sum[i] = (sum[i - 1] + (s[i] - 'a' + 1)) % 3;
	}
	nxt[n][0] = nxt[n][1] = nxt[n][2] = n + 1;
	for (int i = n; i >= 0; --i) {
		for (int j = 0; j < 3; ++j) {
			nxt[i][j] = nxt[i + 1][j];	
		}
		nxt[i][sum[i + 1]] = i + 1;
	}
	dp[0] = 1;
	for (int i = 0; i <= n; ++i) {
		if (i && sum[i] == sum[n]) {
			Inc(ans, dp[i]);
		}
		for (int j = 1; j < 3; ++j) {
			Inc(dp[nxt[i][(sum[i] + j) % 3]], dp[i]);
		}
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 2432
import itertools
import math
n=int(input())
s=[0]*n
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())
a=list(itertools.permutations(range(n)))
ans=0
for i in range(len(a)):
    for j in range(1,n):
        ans+=((x[a[i][j-1]]-x[a[i][j]])**2+(y[a[i][j-1]]-y[a[i][j]])**2)**0.5
print(ans/len(a))


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

void DBG() { cerr << endl; }
template<typename Head, typename... Tail>
void DBG(Head H, Tail... T) { cerr << ' ' << H; DBG(T...); }
#ifdef NAIM
#define dbg(...) cerr << "(" << (#__VA_ARGS__) << "):", DBG(__VA_ARGS__)
#else 
#define dbg(...)
#endif

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ll long long
#define ints(a...) int a; read(a)
#define IN(a) for (auto &it : a) cin >> it

void solve() {
    ints(n, m);
    vector<int> h(n + 1), state(n + 1, 1);
    for (int i = 1; i <= n; i++) read(h[i]);

    while (m--) {
        ints(a, b);
        state[a] &= h[a] > h[b];
        state[b] &= h[b] > h[a];        
    }

    cout << accumulate(state.begin() + 1, state.end(), 0);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, K;
    cin >> N >> K;
    vector<ll> x(N);
    REP(i,N) cin >> x[i];
    ll ans = LINF;
    REP(i,N-K+1){
        chmin(ans, abs(0LL - x[i]) + abs(x[i] - x[i+K-1]));
        chmin(ans, abs(0LL - x[i+K-1]) + abs(x[i] - x[i+K-1]));
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 1024