akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt() % 10;
		if (N == 2 || N == 4 || N == 5|| N == 7 || N == 9) {
			System.out.println("hon");
		} else if (N == 0 || N == 1 || N == 6 || N == 8) {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}
	}

}

Measured memory_bytes: 35772
#include <stdio.h>

int main(){
	int n,i,m,b[100];
	scanf("%d",&n);
	n--;
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	m=b[0];
	for(i=1;i<n;i++){
		m+=min(b[i-1],b[i]);
	}
	m+=b[n-1];
	printf("%d",m);
	return(0);
}

int min(int a, int b){
	if(a<=b){
		return(a);
	}else{
		return(b);
	}
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        long mx = (long)Math.pow(10, 18);
        
        long ans = 1;
        for(int i = 0; i < n; i++) {
            long next = sc.nextLong();
            if(next == 0) {
                ans = 0;
                break;
            }
            if(ans == -1) continue;
            if(ans > mx/next || ans*next > mx) {
                ans = -1;
            } else {
                ans *= next;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59456
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<int, int>  ii;
typedef pair<double, double>  iidb;
typedef pair<ii, int>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1010000
#define offset 200
#define ptr nodo*


using namespace std;
ll v[tam];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
   	int n;
   	cin>>n;
   	ll tot=0,tot2=0;
   	forr(i,0,n)
   	{
   		cin>>v[i];
   		tot+=v[i];
   	}
   	//cout<<tot<<endl;
   	ll minn=1e18;
   	forr(i,0,n-1)
   	{
   		tot2+=v[i];
   		minn=min(minn,abs(tot2-(tot-tot2)));
   	}
   	cout<<minn<<endl;
}

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

int main(){
  ll a,b;
  cin>>a>>b;
  ll c=b-a;
  ll id=c-1;

  ll ans=(1+id)*id/2;
  ans -= a;

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


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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(c-b  <= 0){
        cout << "delicious" << endl;
    }
    else if(c-b > 0 && c-b <= a){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int X =sc.nextInt();
		long sum = 0;
		long remain_1 = 0;
		long quo_1 = 0;
		//long remain_2 = 0;
		long quo_2 = 0;

		quo_1=X/500;
		remain_1 = X%500;
		quo_2=remain_1/5;
		sum=(quo_1*1000)+(quo_2*5);

		System.out.println(sum);
		//System.out.print(ans);
    }
}

Measured memory_bytes: 27096
n, m, x = map(int, input().split())
b = [list(map(int, input().split())) for _ in range(n)]
ans = 100000000
for i in range(1<<n):
	res = 0
	s = [0 for _ in range(m)]
	for j in range(n):
		if (i>>j)&1:
			res += b[j][0]
			for k in range(1, m+1):
				s[k-1] += b[j][k]
	if min(s) >= x:
		ans = min(ans, res)
if ans != 100000000:
	print(ans)
else:
	print(-1)

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

int main()
{

    long double s;
    //int s;
    cin >> s;

    lint a, b, c, d;

    lint ans, tmp=0;
    lint x = pow(10, 9);

    a = ceil(sqrt(s));
    b = a;


    if(tmp==1){
        c = 0;
    }
    c = 1;
    d = a * b - s;

    cout << "0 0 " << a << " " << c << " " << d << " " << b;

    return 0;

}

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

int main() {
	int K, T;
	cin >> K >> T;
	int Odd = 0, Even = 0;
	vector<int>A(T);
	for (int i = 0; i < T; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
	for (int a : A) (Odd < Even ? Odd : Even) += a;

	cout << max(abs(Odd - Even) - 1, 0) << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> h(N + K + 10);
    rep(i, N) cin >> h[i];

    vector<ll> dp(N + K + 10, INF);
    dp[0] = 0;
    rep(i, N) {
        rep(j, K) {
            chmin(dp[i + 1 + j], dp[i] + abs(h[i + 1 + j] - h[i]));
        }
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
#define int long long int

using namespace std;

signed main(){

    int h, w; cin >> h >> w;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
using namespace std;
using namespace __gnu_pbds;
void OJ();

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

string go( int n , int k , string s ){
    string t = s.substr(0,k);
    for ( int i = 0; i < k; ++i ){
        for ( int j = i; j < n; j += k )
            s[j] = t[i];
    }
    return s;
}

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

    int r; cin >> r;
    cout << fixed << setprecision(10) << 2.0 * acos(-1) * r;
    return 0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\in.txt" , "r" , stdin  );
   // freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}
ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


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

long long N, K;
long long A[100005];

#define LESS 0
#define JUST 1

//   何番目のbit?,less?
long long dp[55][2];

bool getbit(long long num, long long idx){
	//cout << "getbit " << num << "," << idx << endl;
	return (num>>idx) & 1;
}

long long bitlen(long long num){
	long long ans = 0;
	while(num>0){
		num = num>>1;
		ans++;
	}
	return ans;
}


int main(){
	cin >> N >> K;
	long long asum = 0;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
		asum += A[i];
	}
	if(K == 0){
		cout << asum << endl;
		return 0;
	}


	for(long long i = 0; i < 55; i++){
		for(long long j = 0; j < 2; j++){
			dp[i][j] = -1;
		}
	}

	//long long kbit_len = bitlen(K);
	long long kbit_len = 50;
	dp[kbit_len][JUST] = 0;
	for(long long i = kbit_len - 1; i >= 0; i--){
		bool kbit = getbit(K, i);
		//cout << "i = " << i << "kbit " << kbit << endl;

		long long abitsum = 0;
		for(long long j = 0; j < N; j++){
			if(getbit(A[j], i)){
				abitsum++;
			}
		}
		//zeroを置いた時の増加分
		long long zero_addnum = abitsum << i;
		//oneを置いた時の増加分
		long long one_addnum = (N-abitsum) << i;

		// put 0
		if(kbit){
			//less -> less
			if(dp[i+1][LESS]>=0) {
				dp[i][LESS] = max(dp[i][LESS], dp[i+1][LESS] + zero_addnum);
			}
			//JUST -> less
			if(dp[i+1][JUST]>=0) {
				dp[i][LESS] = max(dp[i][LESS], dp[i+1][JUST] + zero_addnum);
			}
		} else {
			//less -> less
			if(dp[i+1][LESS]>=0) {
				dp[i][LESS] = max(dp[i][LESS], dp[i+1][LESS] + zero_addnum);
			}
			//JUST -> JUST
			if(dp[i+1][JUST]>=0) {
				dp[i][JUST] = max(dp[i][JUST], dp[i+1][JUST] + zero_addnum);
			}
		}
		// put 1
		if(kbit){
			//less -> less
			if(dp[i+1][LESS]>=0) {
				dp[i][LESS] = max(dp[i][LESS], dp[i+1][LESS] + one_addnum);
			}
			//JUST -> JUST
			if(dp[i+1][JUST]>=0) {
				dp[i][JUST] = max(dp[i][JUST], dp[i+1][JUST] + one_addnum);
			}
		} else {
			//less -> less
			if(dp[i+1][LESS]>=0) {
				dp[i][LESS] = max(dp[i][LESS], dp[i+1][LESS] + one_addnum);
			}
		}
	}
	cout << max(dp[0][0],dp[0][1]) << endl;
}


Measured memory_bytes: 1024
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, r = list(map(int, readline().split()))
    if n >= 10:
        print(r)
    else:
        print(r + 100 * (10 - n))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <string>
#include <iostream>
#include <regex>

using namespace std;

int main()
{
	regex reg1("[A-Z]*C[A-Z]*F[A-Z]*");
	string s1;
	smatch r1;
	cin >> s1;
	bool b = regex_match(s1, r1, reg1);
	if (b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first 
#define s second 
using namespace std;
const int mod=1e9+7;
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
bool isprime(int n){ if(n==1) return false; for(int i=2;i<=sqrt(n);i++)	if(n%i==0) return false; return true;}

/*

*/



void solve()
{
	int n;
	cin>>n;
	string s="";	
	while(n>0)
	{	
		int x=n%26;
		if(x==0)
		{ 
			s+='z';
			n--;
		}
		else s+=('a'+x-1);
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
}

int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

using namespace std;

int main(){
	int N;
	cin>>N;
    vector <int>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
        a[i]-=1;
    }
	
    vector <bool>t(N,false);
    int sum=0;
    for(int i=0 ; i<N ; i++){
        if(t[i])continue;
        if(a[a[i]]==i){
            sum+=1;
            t[i]=true;
            t[a[i]]=true;
        }
    }
	cout<<sum<<"\n";
	
	
	return 0;
}


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

int main(void){
    
    int n;
    cin >> n;
    vector<int> a(n);
    int xsum = 0;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        xsum ^= a.at(i);
    }
    for(int i = 0; i < n; i++){
        int result = xsum ^ a.at(i);
        cout << result << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3972
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll a[N],l,r;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	l=r=2;
	for(int i=n;i>=1;--i){
		l=(l-1)/a[i]+1,r=r/a[i];
		if(l>r){
			return !printf("-1\n");
		}
		l=l*a[i],r=(r+1)*a[i]-1;
	}
	printf("%lld %lld\n",l,r);
	return 0;
}



Measured memory_bytes: 4480
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int h[n], a[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long bit[200100] = {}, dp[200100] = {};
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        long long val = 0;
        for (int x = h[i]; x > 0; x -= x&-x) val = max(val, bit[x]);
        dp[i+1] = val + a[i];
        for (int x = h[i]+1; x <= n; x += x&-x) bit[x] = max(bit[x], val + a[i]);
    }
    cout << *max_element(dp, dp+n+1) << endl;
}


Measured memory_bytes: 4992
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int X = Integer.parseInt(tokens[0]);
		int Y = Integer.parseInt(tokens[1]);

		int temp = Y - (X * 2);
		if (temp % 2 != 0) {
			System.out.println("No");
		} else {
			temp /= 2;
			if (temp >= 0 && temp <= X) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 32600
//#define DEBUG
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
const int inf = 0X3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int mod = 1000000007;
typedef long long ll;

ll Pow(ll a, ll b) {
    ll ans = 1;
    while(b > 0) {
        if (b & 1) {
            ans = ans * a;
        }
        a = a * a;
        b >>= 1;
    }
    return ans;
}

ll sum;
ll x;
int main() {
    while(~scanf("%lld", &x)) {
        int tmp = 0;
        sum = 0;
        for (int i = 0; ; i++) {
            if (Pow(2, i) >= x) {
                tmp = i;
                break;
            }
        }
        if (Pow(2, tmp) != x) tmp -= 1;
        //cout << tmp;
        for (int i = 0; i <= tmp; i++) {
            sum += Pow(2, i);
        }
        printf("%lld\n", sum);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
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);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;

    int counta = 0, countb = 0;
    rep(i, n){
        if(s[i] == 'a'){
            if(counta + countb < a + b){
                cout << "Yes" << endl;
                counta++;
            }else cout << "No" << endl;
        }else if(s[i] == 'b'){
            if(counta + countb < a + b and countb < b){
                cout << "Yes" << endl;
                countb++;
            }else cout << "No" << endl;
        }else cout << "No" << endl;
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
 #define rep(i,a,b) for (int i=a;i<b;i++)
 #define rep2(i,a,b) for (int i=a;i>=b;i--)
 #define mod 1000000007
 #define INF  1e9+5
 #define f first
 #define se second
 #define endl '\n'
 #define ll long long
 #define ii pair <int,int>
 #define pll pair <ll,ll>
 #define vi vector <int>
 #define vl vector <ll>
 #define vvi vector < vi >
 #define vii vector < ii >
 #define vvii vector < vii >
 #define vll vector < ll >
 #define mi map<int,int>
 #define mll map<ll,ll>
 #define mci map<char,int>
 #define msi map<string,int>
 #define vb  vector <bool>
 #define pb push_back
 #define mk make_pair
 #define sz(a) a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define int long long int
 #define Anurag_Gupta ios_base::sync_with_stdio(false);
#define IIIT_ALLD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
vi fact(1000007);
inline int mdpower(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
inline int power(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res*a);
        b/=2;
        a = a*a;
    }
    return res;
}

inline void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}

inline int inverse(int a)
{
    return mdpower(a,mod-2);
}
int n;
int arr[3][100005];
int dp[100005][8];
int solve(int idx,int mask)
{
    
	if(idx==n)
		return 0;
		if(dp[idx][mask]!=-1)
		return dp[idx][mask];
    //cout<<idx<<" "<<mask<<"\n";
	if(mask&(1))
	{
	    
		mask&=~(1<<0);
		 int x =arr[1][idx]+solve(idx+1,mask|2);
		 int y = arr[2][idx]+solve(idx+1,mask|4);
		 int maxi = max(x,y);
		 mask=mask|1;
		 return dp[idx][mask]=maxi;
	
	}

	if(mask==0)
	{
		return dp[idx][mask]=max(arr[0][idx]+solve(idx+1,mask|1),max(arr[1][idx]+solve(idx+1,mask|2),arr[2][idx]+solve(idx+1,mask|4)));
		mask=0;
			 ///mask=mask|1;
		 
	}

	else if(mask&(2))
	{
	 	 mask&=~(1<<1);
		 dp[idx][mask|2]=max(arr[0][idx]+solve(idx+1,mask|1),arr[2][idx]+solve(idx+1,mask|4));
			 
	
	}
	else if(mask&(4))
	{
		mask&=~(1<<2);
		 return dp[idx][mask|4]=max(arr[0][idx]+solve(idx+1,mask|1),arr[1][idx]+solve(idx+1,mask|2));
			
		
	}
}
 signed main()
 {
     Anurag_Gupta
     IIIT_ALLD
     
   
            memset(dp,-1,sizeof dp);
         cin>>n;
         for(int i=0;i<n;i++)
         {
         	cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
         }

         cout<<solve(0,0);
 }


Measured memory_bytes: 21376
#include<iostream>
#include<cstring>

int n, m;
int l;
int d;
bool ver[31][11];

int sim( int v )
{
	for( int i = 0; i != d; ++i )
	{
		if( v < n - 1 && ver[i][v] )
			++v;
		else if( v > 0 && ver[i][v-1] )
			--v;
	}
	
	return v;
}

int main()
{
	while( std::cin >> n, n )
	{
		memset( ver, false, sizeof( ver ) );
		std::cin >> m >> l >> d;
		--m; --l;
		for( int i = 0; i != d; ++i )
		{
			for( int j = 0; j != n - 1; ++j )
			{
				char c;
				std::cin >> c;
				ver[i][j] = c - '0';
			}
		}

		if( sim( m ) == l )
			std::cout << 0 << std::endl;
		else
		{
			bool f = false;

			for( int i = 0; i != d; ++i )
			{
				for( int j = 0; j != n - 1; ++j )
				{
					if( !ver[i][j] && ( !j || !ver[i][j-1] ) && ( j == n - 2 || !ver[i][j+1] ) )
					{
						ver[i][j] = true;
						if( sim( m ) == l )
						{
							std::cout << i + 1 << " " << j + 1 << std::endl;
							f = true;
							goto end;
						}
						ver[i][j] = false;
					}
				}
			}

		end:;

			if( !f )
				std::cout << 1 << std::endl;
		}
	}

	return 0;
}

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

const int INF = 1E+9;

int V, E;
struct city{
    int t;
    int d;
};
vector<vector<city>> G(16);

int dp[1<<16][16];

int main() {
    cin >> V >> E;

    int si, ti, di;
    rep(i, E) {
        cin >> si >> ti >> di;
        G[si].push_back({ti, di});
    }

    rep(i, 1<<16) rep(j, 16) dp[i][j] = INF;
    dp[0][0] = 0;

    for (int bit=0; bit < (1<<V); bit++) {
        for (int now=0; now<V; now++) {
            for (auto c: G[now]) {
                if (!(bit & (1<<c.t))) {
                    dp[bit | (1<<c.t)][c.t] = min(dp[bit | (1<<c.t)][c.t], dp[bit][now] + c.d);
                }
            }
        }
    }

    int ans = dp[(1<<V)-1][0];
    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 7244
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>

using namespace std;

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

   char sCopy[s.length()], tCopy[s.length()];

   int count = 0;

   for(int i = 0; i < s.length(); i++) {
       if(s.at(i) != t.at(i)) {
           count++;
       }
   }

    cout<<count;


}

Measured memory_bytes: 3832
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Queue<Double> pque = new PriorityQueue<>();
        for(int i = 0; i < n; i++) pque.add(sc.nextDouble());
        while(pque.size() > 1) {
            double tmp = (pque.poll() + pque.poll()) / 2.0;
            pque.add(tmp);
        }
        System.out.println(pque.poll());
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<algorithm>

int main()
{
    int r,g,b;
    while(scanf("%d%d%d",&r,&g,&b)==3){
        int ans=0;
        ans=r*100+g*10+b;
        if ((ans%4==0))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

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

int a[n],b[n],c[n];

for(int i=0;i<n;i++)cin >> a[i];
for(int i=0;i<n;i++)cin >> b[i];
for(int i=0;i<n-1;i++)cin >> c[i];

int res=0;
for(int i=0;i<n;i++){
res+=b[a[i]-1];
}
for(int i=0;i<n-1;i++){
if(a[i+1]-a[i]==1){
res+=c[a[i]-1];
}
}
cout << res;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	string s;
	int w;
	cin >> s >> w;

	int pos = 0;
	while(pos < s.size()){
		cout << s[pos];
		pos += w;
	}
	cout <<  endl;
}


Measured memory_bytes: 256
operator fun Pair<Int, Int>.plus(pair: Pair<Int, Int>) = Pair(first + pair.first, second + pair.second)
operator fun Pair<Int, Int>.minus(pair: Pair<Int, Int>) = Pair(first - pair.first, second - pair.second)
fun Pair<Int, Int>.manhattanTo(pair: Pair<Int, Int>) = (this - pair).manhattanLength()
fun Pair<Int, Int>.manhattanLength() = Math.abs(first) + Math.abs(second)

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private fun List<IntRange>.zipWithIndices() =
        mapIndexed { first, range ->
            range.map { second -> Pair(first, second) }
        }.flatten()

fun main(args: Array<String>) {
    val (H, W, D) = readInts()
    val A = (0 until H).map { readInts() }

    val numberCache = {
        val result = mutableMapOf<Int, Pair<Int, Int>>()
        (0 until H).map { (0 until W) }.zipWithIndices().forEach { pair ->
            val (h, w) = pair
            result[A[h][w]] = Pair(h, w)
        }
        result
    }()

    val mpCache = {
        val result = mutableMapOf<Int, Int>()
        (1 until D + 1).forEach { width ->
            (width until H * W + 1).step(width).forEach { index ->
                val prevIndex = index - D
                val totalMp = result[prevIndex]?.let { previous ->
                    val diff = numberCache[prevIndex]!!.manhattanTo(numberCache[index]!!)
                    previous + diff
                } ?: 0

                result[index] = totalMp
            }
        }
        result
    }()

    val Q = readLine()!!.toInt()
    (0 until Q).forEach {
        val (L, R) = readInts()
        println(mpCache[R]!! - mpCache[L]!!)
    }
}

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


int main() {
    int n;
    cin >> n;
    vector<int> six,nine;
    six.push_back(1);
    nine.push_back(1);
    int sixp = 6, ninep = 9;
    while(sixp<100000){
        six.push_back(sixp);
        sixp *= 6;
    }
    while(ninep<100000){
        nine.push_back(ninep);
        ninep *= 9;
    }

    int ans = 999999;
    for(int i = 0; i <= n; i++){
        int tmpans = 0;
        int rem = n-i;
        int p = six.size()-1;
        while(rem!=0){
            while(rem<six[p]){p--;}
            rem -= six[p];
            tmpans++;
        }
        p = nine.size()-1;
        rem = i;
        while(rem!=0){
            while(rem<nine[p]){p--;}
            rem -= nine[p];
            tmpans++;
        }
        ans = min(ans,tmpans);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int N,K;
  cin >> N >> K;
  int sunuke[N] ={0};
  int d;
  int num=0;
  for(int i=0;i<K;i++)
  {
    cin >> d;
  	for(int j=0;j<d;j++)
    {
      cin >> num;
      sunuke[num-1]= 1;
  	}
  }
 int count=0;
 for(int i=0;i<N;i++)
 {
 	if(sunuke[i]== 0) count++;
 }
 cout << count << endl;
  
}

Measured memory_bytes: 3636
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] arr=new int[] {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
		int ans=0;
		for(int j=105;j<=n;j+=2){
			int[] h=new int[201];
			int a=1;
			int k=j;
			while(true){
				for(int i=0;;i++){
					if(k==arr[i]){h[arr[i]]++;goto f;}
					else if(k%arr[i]==0){
						k/=arr[i];
						h[arr[i]]++;
						break;
					}
				}
			}
			f:
			foreach(int i in h){if(i>0){a*=i+1;}}
			if(a==8){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13268
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

s = input()
isFound = False

for i, (a, b) in enumerate(zip(s[:-1], s[1:])):
    if a == b:
        isFound = True
        start, end = i+1, i+2
        break

for i, (a, b) in enumerate(zip(s[:-2], s[2:])):
    if a == b:
        isFound = True
        start, end = i+1, i+3
        break

if isFound is False:
    print("-1 -1")
else:
    print("{} {}".format(start, end))


Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  int ans=MAX;
  for(ll i=1; i*i<=n; i++) {
    if(n%i) continue;
    ll j=n/i;
    stringstream ss,ss2;
    string s,s2;
    ss << i;
    ss >> s;
    ss2 << j;
    ss2 >> s2;
    ans=min(ans,(int)max(s.size(),s2.size()));
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is_all_neg(vector<int> v)
{
    for(int x:v)
    {
        if(x>0)
            return false;
    }
    return true;
}
bool is_all_pos(vector<int> v)
{
    for(int x:v)
    {
        if(x<0)
            return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    vector<int> dat(n);
    for(int i=0;i<n;++i)cin>>dat[i];
    sort(dat.begin(),dat.end());
    int sum = 0;
    for(int i=0;i<n;++i)sum+=abs(dat[i]);
    if(is_all_neg(dat))
    {
        cout<<sum + dat.back()*2<<endl;
        int x = dat.back();
        for(int i=n-2;i>=0;--i)
        {
            cout<<x<< " " << dat[i] <<endl;
            x = x - dat[i];
        }
    }else if(is_all_pos(dat))
    {
        cout<<sum - dat[0]*2<<endl;
        int x = dat[0];
        for(int i=1;i<n-1;++i)
        {
            cout<<x << " " << dat[i]<<endl;
            x = x - dat[i];
        }
        cout<<dat[n-1]<<" "<<x<<endl;
    }else
    {
        cout<<sum<<endl;
        int p = 0;
        for(;p<n;++p)
        {
            if(dat[p] >= 0)
                break;
        }
        int x = dat[p];
        for(int i=p-1;i>0;--i)
        {
            cout<<x<<" "<<dat[i]<<endl;
            x = x - dat[i];
        }
        if(p == n-1)
        {
            cout<<x<<" "<<dat[0]<<endl;
        }else
        {
            cout<<dat[0]<<" "<<x<<endl;
            x = dat[0] - x;
            for(int i=p+1;i<n-1;++i)
            {
                cout<<x<<" "<<dat[i]<<endl;
                x = x - dat[i];
            }
            cout<<dat[n-1]<<" "<<x<<endl;
        }
    }
}

Measured memory_bytes: 2680
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;

  int n;
  cin>>n;
  if(n>=30)
  cout<<"Yes";
  else 
  cout<<"No";
}



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

int main() {
  int n,k,x;
  int a=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    a+=min(x,k-x);
  }
  cout<<a*2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  int h,w;
  cin>>h>>w;

  vector<string> p(h);
  rep(i,h){
    cin>>p[i];
  }

  vector<int> dx={1,-1,0,0,1,1,-1,-1};
  vector<int> dy={0,0,1,-1,1,-1,1,-1};

  rep(i,h){
    rep(j,w){
      if(p[i][j]=='.'){
        int cnt=0;
        rep(k,8){
          int dh=i+dx[k];
          int dw=j+dy[k];
          if(dh<0||dh>=h||dw<0||dw>=w) continue;
          if(p[dh][dw]=='#') cnt++;
        }
        string z=to_string(cnt);
        p[i][j]=z[0];
      }
    }
  }

  rep(i,h){
    cout << p[i] << endl;
  }


}

Measured memory_bytes: 256
import sys
def gcm(a,b):
    if a<b: a,b=b,a
    if (a%b==0): return b
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Measured memory_bytes: 4208
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S;
	vector<pair<double,double>> P;
	while(cin>>S){
		auto T = split_naive(S,',');
		double x,y;
		sscanf(T[0].c_str(),"%lf",&x);
		sscanf(T[1].c_str(),"%lf",&y);
		P.emplace_back(x,y);
	}

	double sum = 0;
	for(int i=0,ei=P.size()-2;i<ei;i++){
		double a = hypot(P[i+1].first-P[0].first,P[i+1].second-P[0].second);
		double b = hypot(P[i+1].first-P[i+2].first,P[i+1].second-P[i+2].second);
		double c = hypot(P[i+2].first-P[0].first,P[i+2].second-P[0].second);
		double z = (a+b+c)/2.0;
		sum += sqrt(z*(z-a)*(z-b)*(z-c));
	}
	out(sum);
	
	return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
const double PI = 3.14159265398979;
int main() {
	
	double a,b,x;
	cin >>a>>b>>x;
	if(x*2>=a*a*b){
		double y = (a*a*b-x)*2/(a*a*a);
		double s = atan(y);
		cout << fixed << setprecision(10);
		cout << s*180/PI << endl;
	}
	else{
		double y = x*2/(b*b*a);
		double s = atan(y);
		cout << fixed << setprecision(10);
		cout << 90-s*180/PI << endl;
	}
	
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <fstream>
using namespace std;

int main()
{
    string S;

    cin >> S;

    if(S == "ooo") {
        cout << 1000 << endl;
    }
    else if (S == "xoo")
    {
        cout << 900 << endl;
    }
    else if (S == "oxo")
    {
        cout << 900 << endl;
    }
    else if (S == "oox")
    {
        cout << 900 << endl;
    }
    else if (S == "xxo")
    {
        cout << 800 << endl;
    }
    else if (S == "xox")
    {
        cout << 800 << endl;
    }
    else if (S == "oxx")
    {
        cout << 800 << endl;
    }
    else {
        cout << 700 << endl;
    }
    
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = int(input())
    y, m = s // 100, s % 100
    if (y == 0 or y > 12) and (m == 0 or m > 12):
        print('NA')
    elif y > 12 or y == 0:
        print('YYMM')
    elif m > 12 or m == 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')


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

int main(){
  
  int N, M;
  cin >> N >> M;
  
  int val;
  priority_queue<int> vals;
  rep(i,N){
    cin >> val;
    vals.push(val);
  }
  
  int topVal;
  while (M > 0){
    topVal = vals.top();
    vals.pop();
    vals.push(topVal / 2);
    M--;
  }
  
  long long sum = 0;
  while(!vals.empty()){
    sum += vals.top();
    vals.pop();
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 892
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-A[i] for i in range(N)]
ans = 0
heapq.heapify(A)
for i in range(M):
    value = -heapq.heappop(A)
    value //= 2
    heapq.heappush(A, -value)
print(-sum(A))

Measured memory_bytes: 92372
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    K = list(map(int, lines.pop(0).split(' ')))
    N = int(lines.pop(0))
    K.sort()
    a = K.pop(-1)
    print(a * 2**N + sum(K))


#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]
#
# solve !!
#
solve(lines)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)
void Main() {
	int n; cin >> n;
	bitset<1000001> v;
	v[0] = 1;
	//rep(i, n)cout << v[i];
	repi(i, 0, n) {
		//cout << v;
		if (v[i] == 1) {
			repi(j, 100,106) {
				v[i + j] = 1;
			}
		}
	}
	//rep(i,n)cout << v[i];
	cout << v[n];
}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL a(N), b(N);
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];
    LL ans = 0;

    for(int i = 0; i <= 30; i++) //i bit
    //for(int i = 0; i <= 4; i++) //i bit
    {
        LL Tn = 1LL << (i+1);
        VL xs,ys;
        REP(j,N){
            xs.pb(a[j] % Tn);
            ys.pb(b[j] % Tn);
        }
        sort(xs.begin(),xs.end());
        sort(ys.begin(),ys.end());
        LL cnt = 0;
        //cout << printVector(xs) << endl;
        //cout << printVector(ys) << endl;

        for(LL x : xs)  {
            int idx = lower_bound(ys.begin(),ys.end(), 4 * (1LL << (i))-x) - lower_bound(ys.begin(),ys.end(), 3 * (1LL << (i))-x) + 1;

            int idx1 = lower_bound(ys.begin(),ys.end(), 2 * (1LL << (i))-x) - lower_bound(ys.begin(),ys.end(), (1LL << (i))-x) + 1;

            cnt += idx + idx1;
        }
        if((cnt)%2 == 1) {
            ans += (1LL << i);
        }

    }
    cout << ans << endl;

}

Measured memory_bytes: 10464
#include <iostream>
#include <cstdio>

using namespace std;
const int MAXN = 1e5 + 5;

int n;
char s[MAXN];

int main() {
	cin >> n >> (s + 1);
	int las = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] != las) {
			ans++;
			las = s[i];
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

int main() {
	int A1, A2, A3;	cin >> A1 >> A2 >> A3;
	int answer;
	vector<int> A;
	A.push_back(A1);
	A.push_back(A2);
	A.push_back(A3);
	sort(A.begin(), A.end());
	cout << A[2] - A[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,k;
  int ans;
  int i;
  scanf("%d%d",&n,&k);
  ans=k;
  for(i=1;i<=n-1;i++){
    ans*=(k-1);
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1704
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()

ans = 0
b_start,a_end,b_start_a_end = 0,0,0
for i in range(N):
    s = S()
    if s[0] == 'B' and s[-1] == 'A':
        b_start_a_end += 1
    elif s[0] == 'B':
        b_start += 1
    elif s[-1] == 'A':
        a_end += 1
    for j in range(len(s)-1):
        if s[j] == 'A' and s[j+1] == 'B':
            ans += 1

if b_start_a_end == 0:
    print(ans+min(b_start,a_end))
else:
    ans += b_start_a_end-1
    if a_end > 0:
        ans += 1
        a_end -= 1
    if b_start > 0:
        ans += 1
        b_start -= 1
    ans += min(b_start,a_end)
    print(ans)


Measured memory_bytes: 68380
// ABC 118 D

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  const string minf = "-";

  const int C[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; ++i) {
    cin >> A[i];
  }

  vector<string> dp(N + 1);
  for (auto& e : dp)
    e = minf;
  dp[0] = "";

  auto cmp = [](const string& a, const string& b) -> bool {
    if (a.size() == b.size())
      return a < b;
    return a.size() < b.size();
  };

  for (int i = 0; i <= N; ++i) {
    // ちょうど i本 マッチ棒を使わないケースを飛ばす.
    if (dp[i] == minf)
      continue;
    for (int j = 0; j < M; ++j) {
      const int k = i + C[A[j]];
      if (k <= N) {
        dp[k] = max(dp[k], dp[i] + to_string(A[j]), cmp);
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 33024
#include<iostream>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
int n;
int s[100000], f[100000];
pair<int, int> itv[100000];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        s[i] = x - l;
        f[i] = x + l;
    }
    for (int i = 0; i < n; i++) {
        itv[i].first = f[i];
        itv[i].second = s[i];
    }
    sort(itv, itv + n);
    int ans = 0, t = itv[0].second - 10;
    for (int i = 0; i < n; i++) {
        if (t <= itv[i].second) {
            ans++;
            t = itv[i].first;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a!=2&&b!=2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int a = 0, b = 0, c = 0;
  for(int i = 0; i < N; i++){
    int p;
    cin >> p;
    if(p <= A) a++;
    else if(A < p && p <= B) b++;
    else c++;
  }

  cout << min(min(a, b), c) << endl;
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int Q, A, B;
	cin >> Q;
	rep(i, 0, Q)
	{
		cin >> A >> B;
		int r = sqrt(A*B);
		if (r*r == A * B)
		{
			if (A == B)
			{
				cout << (r - 1) * 2 << endl;
			}
			else
			{
				cout << (r - 1) * 2 - 1 << endl;
			}
		}
		else
		{
			int rr = sqrt(A*B - EPS);
			if ((A*B - 1) / rr == rr)
			{
				cout << (rr - 1) * 2 << endl;
			}
			else
			{
				cout << rr * 2 - 1 << endl;
			}
		}
	}

	return 0;
}

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

using namespace std;

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

    double p[n+1];

    for(int i=1;i<=n;i++) cin >> p[i];

    double dp[n+1][n+1]; memset(dp,0,sizeof(dp));

    dp[0][0] = 1;

    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            dp[i][j] = dp[i-1][j]*(1-p[i]);
      	    if(j)dp[i][j]+= dp[i-1][j-1]*p[i];  
        }
    }

    double total =0;

    for(int i=n/2+1;i<=n;i++) total += dp[n][i];

    cout << fixed << setprecision(10) << endl;
    cout << total << endl;

}

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

using namespace std;

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


int main(){
  int N, X;
  cin >> N >> X;
  int ans;
  cin >> ans;
  if(ans>=X) ans = ans - X;
  else ans = X - ans;
  rep(i,N-1){
    int x;
    cin >> x;
    if(x>=X) x = x - X;
    else x = X - x;
    ans = GCD(ans, x);
  }
  cout << ans << endl;
   
}
    




Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<vector>
int minElement(vector<int> a, int n){
    if(n==1)
    return 1;
    int count=1;
    int min = a[0];
    for(int i=1;i<n;i++){
         if(a[i]<min)
        count++;
        
         if(a[i]<min)
        min=a[i];
    }
    return count;
}
int main() {
      int n;
      cin>>n;
      vector<int> a(n);
      for(int i=0;i<n;i++){
          cin>>a[i];
      }
     cout<<minElement(a,n);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ; 
int main(){
	long long int n , m  ,a ,ans = 0  ;
	cin>> n >> m ; 
	string q ;
	//set<int > s ; 
	vector<pair <int , int >> s(n+ 4 , {0 , 0}) ; 
	//int penal[n+1 ] = {0} ; 
	for(int i = 0  ; i < m ; ++i ){
		cin>> a >> q ; 
	    if(q == "AC" && s[a].first != 1){
			s[a].first = 1 ; 
			ans++ ;  
		}
		else if ( s[a].first != 1 ){
			s[a].second+=1 ; 
		}
	}
	long long int ans2 = 0 ; 
	for(int i = 1 ; i <= n ; ++i){
		if( s[i].first == 1 ){
		ans2 += s[i].second ; 
	  }
	}
	cout<<ans <<" "<< ans2 <<endl;
}
	


Measured memory_bytes: 1024