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

string calc(char s){
    if(s == '0') return "0000";
    if(s == '1') return "0001";
    if(s == '2') return "0010";
    if(s == '3') return "0011";
    if(s == '4') return "0100";
    if(s == '5') return "0101";
    if(s == '6') return "0110";
    if(s == '7') return "0111";
    if(s == '8') return "1000";
    if(s == '9') return "1001";
    if(s == 'a') return "1010";
    if(s == 'b') return "1011";
    if(s == 'c') return "1100";
    if(s == 'd') return "1101";
    if(s == 'e') return "1110";
    if(s == 'f') return "1111";
}

int main(){
    int q; cin>>q;
    while(q--){
        string s; cin>>s;
        string t = "";
        for(int i=0; i<8; i++){
            t += calc(s[i]);
        }

        int ans1 = 0;
        int num1 = (1 << 23);
        for(int i=1; i<=24; i++){
            ans1 += (t[i] == '1') * num1;
            num1 /= 2;
        }

        double ans2 = 0.0;
        double num2 = 0.5;
        for(int i=25; i<=31; i++){
            ans2 += (t[i] == '1') * num2;
            num2 /= 2;
        }

        if(t[0] == '1') cout << "-";
        if(ans2 == 0.0){
            cout << ans1 << ".0" << endl;
        }
        else{
            double ans3 = 1. * ans1 + ans2;
            printf("%.20g\n", ans3);
        }
    }
}


Measured memory_bytes: 3284
# -*- coding: utf-8 -*-

h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
	
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
			
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end='')
		print()

Measured memory_bytes: 4468
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
ll inf = 1e11;

//

int main(void){
	ll N,M,l,r,d,dist[100010];
	vector<ll> v[100010];
	vector<ll> c[100010];
	bool can=true;
	scanf("%lld%lld",&N,&M);
	rep(i,M){
		scanf("%lld%lld%lld",&l,&r,&d);
		v[l].push_back(r);
		v[r].push_back(l);
		c[l].push_back(d);
		c[r].push_back(-d);
	}
	reg(i,1,N)dist[i]=inf;
	reg(i,1,N){
		if(!can)break;
		if(dist[i]==inf){
			dist[i]=0;
			queue<ll> Q;
			Q.push(i);
			while(!Q.empty()){
				ll p = Q.front();Q.pop();
				rep(j,v[p].size()){
					ll q = v[p][j];
					if(dist[q]==inf){
						dist[q]=dist[p]+c[p][j];
						Q.push(q);
					}else if(dist[p]+c[p][j]!=dist[q]){
						can=false;
						break;
					}
				}
			}
		}
	}
	if(can){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 18304
#include<bits/stdc++.h>
using namespace std;
int solve() {
  int r = 0,n = 0, k; cin >> k;
  {int T; cin >> T;
   while (T--) {
     int t; cin >> t;
     n = max(n, t);
  }}
  if (n <= (k+1)/2) return 0;
  n -= (k*1)/2;
  if (k % 2 == 0) n--,r++;
  return r + n * 2;
}

int main() {
  cout << solve() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll> v;
	v.pb(0);
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	v.pb(0);
	ll sum = 0;
	rep(i,0,v.sz-1){
		sum += abs(v[i+1]-v[i]);
	}
	rep(i,1,v.sz-1){
		ll a = v[i-1];
		ll b = v[i];
		ll c = v[i+1];
		if(a>c)swap(a,c);
		if(a<=b&&b<=c){
			cout << sum << endl;
		}
		if(b<a){
			cout << sum-(a-b)*2 << endl;
		}
		if(c<b){
			cout << sum-(b-c)*2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2164
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>

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

int a[200000],n,b;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    REP(i,n)cin>>a[i];
    REP(i,n)b^=a[i];
    REP(i,n)cout<<(a[i]^b)<<"\n";
    return 0;
}

Measured memory_bytes: 4360
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int dp[100];
signed main(){
	int n;
	cin>>n;
	dp[0]=2;
	dp[1]=1;
	f(i,n-1){
		dp[i+2]=dp[i]+dp[i+1];
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double 
#define pb push_back
#define pii pair<ll,ll>
ll M = 1e9+7;

ll power(ll a,ll b,ll c=M){
    ll res=1;
    a%=c;
    while(b>0){
        if(b%2)res= (res*a)%c;
        a = (a*a)%c;
        b/=2;
    }
    return res;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,ans=0;
    cin>>n>>k;
    string str,tm;
    str="#";
    cin>>tm;
    str = str+tm+"#";
    for(int i=1;i<=n;++i){
        if(str[i]=='L' && str[i-1]=='L')ans++;
        if(str[i]=='R' && str[i+1]=='R')ans++;
    }
    ll rl=0,lr=0;
    for(int i=1;i<=n;++i){
        if(str[i]=='L' && str[i+1]=='R')lr++;
        if(str[i]=='R' && str[i+1]=='L')rl++;
    }
    ans += 2*min(min(lr,rl),k);
    ll tmp = min(min(lr,rl),k);
    rl-=tmp;
    lr-=tmp;
    k-=tmp;
    if(k>0){
        if(str[n]=='R' && lr>0)ans++,lr--,k--;
        if(str[1]=='L' && lr>0 && k>0)ans++,rl--,k--;
        if(str[n]=='L' && rl>0 && k>0)ans++,rl--,k--;
        if(str[1]=='R' && rl>0 && k>0)ans++,rl--,k--;
    }
    cout << ans << '\n';
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL x, y, z, n, a[100000][3], ans[100000];
typedef pair<LL, int> PP;
PQ<PP> pq[3][3];

PP get(int f, int t) {
	PP p = pq[f][t].top();
	while(ans[p.SE] != f) { pq[f][t].pop(); p = pq[f][t].top(); }
	return p;
}

void add(int i, int v) {
	ans[i] = v;
	inc(j, 3) {
		if(j == v) { continue; }
		pq[v][j].emplace(a[i][j] - a[i][v], i);
	}
}

bool RT(int r) { // r: 1 or 2
	PP e[3];
	inc(j, 3) { e[j] = get(j, (j + r) % 3); }
	
	if(e[0].FI + e[1].FI + e[2].FI <= 0) { return false; }
	inc(j, 3) { add(e[j].SE, (j + r) % 3); }
	return true;
}

bool SW(int f, int t) {
	PP ft = get(f, t);
	PP tf = get(t, f);
	
	if(ft.FI + tf.FI <= 0) { return false; }
	add(ft.SE, t);
	add(tf.SE, f);
	return true;
}

LL calc() {
	LL sum = 0;
	inc(i, n) {
		sum += a[i][ans[i]];
	}
	return sum;
}

int main() {
	cin >> x >> y >> z;
	n = x + y + z;
	inc(i, n) {
	inc(j, 3) {
		cin >> a[i][j];
	}
	}
	
	inc(i, n) {
		int v;
		if(inID(i, 0,     x)) { v = 0; }
		if(inID(i, x, x + y)) { v = 1; }
		if(inID(i, x + y, n)) { v = 2; }
		add(i, v);
	}
	
	// 適当
	inc(x, 8) {
		inc(j, 3) { while(SW(j, (j + 1) % 3)) { } }
		dec(j, 3) { while(SW(j, (j + 1) % 3)) { } }
		while(RT(1)) { }
		while(RT(2)) { }
		while(RT(1)) { }
		while(RT(2)) { }
	}
	
	cout << calc() << endl;
	
	return 0;
}


Measured memory_bytes: 9836
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int H = ScanInt(), W = ScanInt();
        var a = new List<string>();
        for (int i = 0; i < H; i++) {
            var isAllWhite = true;
            var line = Scan();
            for (int j = 0; j < W; j++) {
                if (line[j] == '.') continue;
                isAllWhite = false;
                break;
            }
            if (!isAllWhite) a.Add(line);
        }
        for (int i = 0; i < W; i++) {
            var isAllWhite = true;
            foreach (var s in a) {
                if (s[i] == '.') continue;
                isAllWhite = false;
                break;
            }
            if (!isAllWhite) continue;
            for (int j = 0; j < a.Count; j++) {
                a[j] = new StringBuilder(a[j][..i]).Append(a[j][(i + 1)..]).ToString();
            }
            i--;
            W--;
        }
        foreach (var line in a) {
            Console.WriteLine(line);
        }
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = ArrayPool<byte>.Shared.Rent(1024);
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 25760
#include <bits/stdc++.h>
using namespace std;
const long long M=1000000007;
long long qpow(long long x,long long y) //unit*x=x
{
    long long ans=1;
    while (y){
        if (y&1) ans=ans*x%M;
        x=x*x%M;
        y=y>>1;
    }
    return ans;
}
long long C(int a,int n){
    long long p=1;
    long long q=1;
    for (int i=n-a+1;i<=n;++i) p=(p*i)%M;
    for (int i=1;i<=a;++i) q=(q*i)%M;
    return p*qpow(q,M-2)%M;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<((qpow(2,n)-1-C(a,n)-C(b,n))%M+M)%M;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;
#define mapp map<int,int>
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)
 
bool comps(const pair<int,int> &a, const pair<int,int> &b) {return (a.second<b.second);} 

int fac[100001];
int power(int x, unsigned int y)
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}

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

int binomialCoeff(int n, int k)
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}
void precomp()
{ 
    fac[0] = 1; 
    for (int i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%mod;
}
int modInverse(int n, int p) {return powerp(n, p-2, p);}
int nCrModPFermat(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r   
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
signed main()
{
    
    IOS
    int k;
    cin>>k;
    queue <int> res;
    rep(i,1,10) res.push(i);
    int ans;
    rep(i,0,k)
    {
        ans=res.front();
        res.pop();
        if(ans%10>0) res.push(ans*10+(ans%10-1));
        res.push(ans*10+ans%10);
        if(ans%10<9) res.push(ans*10+(ans%10+1));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n = sc.nextInt();
		//String[][] array = new String[100][500];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_tree=new ArrayList<Integer>();
		//List<Integer> list_add=new ArrayList<Integer>();
		int m = sc.nextInt();
		int d = sc.nextInt();

		int count=0;

		for(int i=1;m+1>i;i++) {
			for(int j =1;d+1>j;j++) {
				int ten= j/10;
				int one = j%10;
				if(ten>=2&&one>=2&&i==ten*one) {
					count++;
				}
			}

		}

		System.out.println(count);

	}

}

Measured memory_bytes: 21076
import java.util.Scanner;
import java.util.Arrays;
public class Main{
        public static void main(String[] args){
                final Scanner cin = new Scanner(System.in);
                int n = cin.nextInt();
                long[] arr=new long[n];
                for(int i=0;i<n;i++){
                        arr[i]=cin.nextLong();
                }   
                Arrays.parallelSort(arr);
                if(arr[0]==0){
                        System.out.print(0);
                        return;
                }   
                long mul=1L;
                for(long a:arr){
                        if(mul*1.0*a>(long)1e18){
                                System.out.print(-1);
                                System.exit(0);
                        }   
                        mul=mul*a;
                }   
                System.out.print(mul>(long)1e18?-1:mul);
        }   
}

Measured memory_bytes: 61568
S=input()

s1=S[0]
nc=0
for i,st in enumerate(S[1:]):
    if s1==st:
        nc+=1
        it=i
        
if nc==1:
    if it==0:
        if S[2]==S[3]:
            print('Yes')
        else:
            print('No')
    elif it==1:
        if S[1]==S[3]:
            print('Yes')
        else:
            print('No')

    elif it==2:
        if S[1]==S[2]:
            print('Yes')
        else:
            print('No')
            
            
    

else:
   print('No')    


Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
struct node{int x,y;}a[214514];
multiset<int> S1,S2;
bool cmp(node x,node y){return x.x<y.x;}
int ans=0;
signed main(){
    int n;
    cin>>n;
    if (n==1)  {puts("0");  return 0;}
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].x>>a[i].y;
        if (a[i].x>a[i].y)  swap(a[i].x,a[i].y);
        S1.insert(a[i].x),S2.insert(a[i].y);
    }
    ans=1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin());
    sort(a+1,a+n+1,cmp);
    for (int i=1; i<=n; i++)
    {
        S1.erase(S1.find(a[i].x)),S1.insert(a[i].y);
        S2.erase(S2.find(a[i].y)),S2.insert(a[i].x);
        ans=min(ans,1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin()));
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<int> ans(N, 0); //正解数
  for (int i = 0; i < Q; i++) {
    ll a = 0;
    cin >> a;
    ans[a-1]++;
  }
  for (int i = 0; i < N; i++) {
    ll final = K - Q + ans[i];
    if (final > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

  
  


Measured memory_bytes: 1024
#include <iostream>
int main(){
int x,y;
std::cin >> x >> y;
if(x==2 || y==2)
std::cout << "No" << std::endl;
else if(y==6 || y==9 || y==11 &&x==4)
std::cout << "Yes" << std::endl;
else if(y==9 || y==11 && x==6)
std::cout << "Yes" << std::endl;
else if(x==9 && y==11)
std::cout << "Yes" << std::endl;
else if(y==3 || y==5 || y==7 || y==8 || y==10 || y==12 &&x==1)
std::cout << "Yes" << std::endl;
else if(y==5 || y==7 || y==8 || y==10 || y==12 &&x==3)
std::cout << "Yes" << std::endl;
else if(y==7 || y==8 || y==10 || y==12 &&x==5)
std::cout << "Yes" << std::endl;
else if(y==8 || y==10 || y==12 && x==7)
std::cout << "Yes" << std::endl;
else if(y==10 || y==12 &&x==8)
std::cout << "Yes" << std::endl;
else if(x==10 && y==12)
std::cout << "Yes" << std::endl;
else
std::cout << "No" << std::endl;
}

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), d = sc.nextInt();
		System.out.println((int)Math.ceil(n * 1.0 / (2 * d  + 1)));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
using namespace std;
/*
#ifdef JUDGE
#include <fstream>
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
#include <iostream>
using std::cin;
using std::cout;
#endif
*/
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
long double eps = 1.0E-14;
long long MOD = 1000000007;
long long gcd_(long long A, long long B)
{
	long long temp;
	if (A == 1 || B == 1)
		return 1;
	if (A < B)
	{
		temp = A;
		A = B;
		B = temp;
	}
	while (B != 0)
	{
		temp = (A%B);
		A = B;
		B = temp;
	}
	return A;
}
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t,T;
	cin >> T;	
    ans = 0LL;
    for(int i = 1; i <= T; i ++ ){
        for(int j = 1; j <= T; ++ j) {
            ll gc = i > 1 && j > 1 ? gcd_(i,j) : 1;
            for(int k = 1; k <= T; ++ k) {
                if (i == 1 || j == 1 || k == 1) {
                   ans += 1;
                } else {
                    ans += gcd(gc,k);
                }
 
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
n = int(input())
p = [int(i) for  i in input().split()]
count = 0
for i in range(1, n - 1):
	if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
		count += 1
print(count)

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define fst first
#define snd second

int main()
{
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << arr[n-1] << "\n";
}


Measured memory_bytes: 764
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string n;
    cin >> n;
    lli ans=0;
    bool c = false;
    rep(i,n.size()){
        if(i==0){
            ans += n[i] - '0';
            continue;
        }
        else if(n[i]!='9'&&!c){
            ans--;
            c = true;
        }
        if(c||n[i]=='9'){
            ans += 9;
        }
    }
    out(ans);
}

Measured memory_bytes: 3548
#参考
#https://atcoder.jp/contests/abc148/submissions/9111279

N = int(input())
a = [int(i) for i in input().split()]

if 1 not in a:
  ans = -1
else:
  ans = 0
  counter = 1
  for i in range(N):
    if a[i] == counter:
      counter += 1
    else:
      ans +=1

print(ans)

Measured memory_bytes: 77516
<?php
fscanf(STDIN, "%d %d", $n, $k);
$ds = explode(' ', trim(fgets(STDIN)));

$f = array_fill(0, 10, 0);
foreach ($ds as $d) $f[$d] = 1;
while (!can_pay($n)) $n++;
echo $n, "\n";

function can_pay($n) {
	global $f;
	$s = strval($n);
	for ($i = 0; $i < strlen($s); $i++) {
		if ($f[$s[$i]]) return false;
	}
	return true;
}

Measured memory_bytes: 3704
import java.util.Scanner;

/**
 * Created by wild on 16/08/28.
 */
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] strLine = scan.next().split("");

        String tmp = null;

        for (int i = 0; i < strLine.length; i++){
            tmp = strLine[i];
            if (!nums(strLine, tmp)){
                System.out.println("No");
                break;
            }else {
                if ((i+1) == strLine.length){
                    System.out.println("Yes");
                }
            }
        }

    }

    public static boolean nums(String[] str, String detectChar){
        int count = 0;
        for (int i = 0; i < str.length; i++){
            if (detectChar.equals(str[i])){
                count++;
            }
        }

        if (count%2 == 0){
            return true;
        }else {
            return false;
        }
    }
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size(),ans;
  char center;
  if(n % 2 == 0){
    ans = n/2;
    if(s.at(n/2) == s.at(n/2-1) && n > 2){
      center = s.at(n/2);
      char nextl = s.at(n/2-2),nextr = s.at(n/2+1);
      int left = n/2-2,right = n/2+1;
      ans++;
      while(center == nextl && center == nextr && right < n && left >= 0){
        ans++;left--;right++;
        if(right < n && left >= 0){
          nextl = s.at(left);nextr = s.at(right);
        }
      }
    }
    else if(n == 2){
      if(s.at(0) == s.at(1)){
        ans = 2;
      }
      else{
        ans = 1;
      }
    }
  }
  else{
    ans = n/2+1;
    if(n > 1){
      center = s.at(n/2);
      char nextl = s.at(n/2-1),nextr = s.at(n/2+1);
      int left = n/2-1,right = n/2+1;
      while(center == nextl && center == nextr && left >= 0 && right < n){
        ans++;left--;right++;
        if(left >= 0 && right < n){
          nextl = s.at(left);nextr = s.at(right);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
while 1:
    n=int(raw_input())
    if n==0:break
    a=[map(int,raw_input().split()) for _ in xrange(n)]
    ans=[[0]*(n+1) for _ in xrange(n+1)]
    for i in xrange(n+1):
        for j in xrange(n+1):
            if i==n :
                if j==n:
                    ans[n][n]+=sum(ans[n])
                else:
                    for k in xrange(n):
                        ans[n][j]+=a[k][j]
            else:
                if j==n:
                    for k in xrange(n):
                        ans[i][n]+=a[i][k]
                else:
                    ans[i][j]=a[i][j]
    for i in xrange(n+1):
        print("".join(map(lambda x:str(x).rjust(5),ans[i])))

Measured memory_bytes: 6468
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
const int  N = 1e6+66;
#define  LL long long

int main()
{
	int n;
	cin>>n;
	int Max=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		int p;
		cin>>p;
		sum+=p;
		Max=max(Max,p);
	}
	printf("%d\n",sum-Max/2);

	return 0;
}



Measured memory_bytes: 256
# C
#C

N, M = map(int, input().split())

sc = {i+1:[] for i in range(N)}

for _ in range(M):
  si, ci = map(int, input().split())
  sc[si] += [ci]

sc = {k:list(set(v)) for k,v in sc.items()}

flag = True

if N>1 and 0 in sc[1]:
  flag = False

for v in sc.values():
  if len(v)>1:
    flag = False


ans = -1

if flag:
  cand = [0]*N
  if N>1:
    cand[0] = 1
  for k, v in sc.items():
    if len(v)>0:
      cand[k-1] = v[0]
  ans = "".join([str(c) for c in cand])

print(ans)


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

vector<P> prime_factorize(ll n) {
    vector<P> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
  int n;
  cin >> n;
  vector<int>data(n+1);
  rep(i,1,n+1){
    vector<P>prime = prime_factorize(i);
    rep(j,0,prime.size()) data[prime[j].first] += prime[j].second;
  }
  int c3 = 0,c5 = 0,c15 = 0,c25 = 0,c75 = 0;
  rep(i,0,data.size()){
    if(data[i] >= 2) c3++;
    if(data[i] >= 4) c5++;
    if(data[i] >= 14) c15++;
    if(data[i] >= 24) c25++;
    if(data[i] >= 74) c75++;
  }
  ll ans = c5*(c5-1)*(c3-2)/2+c15*(c5-1)+c25*(c3-1)+c75;
  cout << ans << endl;
}

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



int main(){
    ll N , M;
    cin >> N >> M;
    
    map<int,int> mp;
    
    for(int i = 0; i < M; i++){
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        mp[tmp1]++;
        mp[tmp2]++;
    }

    for(int i = 1; i <= N; i++){
        if(mp[i] % 2 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;

}



Measured memory_bytes: 8240
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll >
#define vi          vector<ll int>
#define vii         vector<pii>
#define mi          map<ll int,ll int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007 
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        2000005

using namespace std;


void solve()
{
	ll r,g,b;
	cin>>r>>g>>b;
	ll k;
	cin>>k;
	while(k>0)
	{
	//	cout<<r<<" "<<g<<" "<<b<<" "<<k<<endl;
		if(r>=g)
		{
			g=g*2;
			
		}
		else if(g>=b)
		{
			b=b*2;
			
		}
		else
		{
			if(r<g&&g<b)
			{
				cout<<"Yes"<<endl;
				return;
			}
		}
		if(r<g&&g<b)
			{
				cout<<"Yes"<<endl;
				return;
			}
		k--;
	}
		if(r<g&&g<b)
			{
				cout<<"Yes"<<endl;
				return;
			}
	cout<<"No"<<endl;
	

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

Measured memory_bytes: 3632
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-15 23:42:18
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    long A, B, C, D;
    cin >> A >> B >> C >> D;

    long ans = B - A + 1;
    // Cで割り切れる
    ans -= B/C;
    ans += (A-1)/C;

    // Dで割り切れる
    ans -= B/D;
    ans += (A-1)/D;

    // C でも D でも割り切れる
    long l = (C*D)/(__gcd(C, D));
    ans += B/l;
    ans -= (A-1)/l;

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


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1276
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
bool sieve[2000000];
int main(void)
{
    int n;
    cin >> n;
    for (int k = 0; k < n; ++k)
    {
        string order, mes;
        cin >> order >> mes;
        reverse(order.begin(), order.end());
        for (int j = 0; j < order.size(); ++j)
        {
            switch (order[j])
            {
            case 'A':
                reverse(mes.begin(), mes.end());
                break;
            case 'J':
                rotate(mes.begin(), mes.begin() + mes.size() - 1, mes.end());
                break;
            case 'C':
                rotate(mes.begin(), mes.begin() + 1, mes.end());
                break;
            case 'E':
                for (int i = 0; i < mes.size() / 2; ++i)
                {
                    swap(mes[i], mes[(mes.size() + 1) / 2 + i]);
                }
                break;
            case 'M':
                for (int i = 0; i < mes.size(); ++i)
                {
                    if (mes[i] >= '0' && mes[i] <= '8')
                    {
                        mes[i] = (char)(mes[i] + 1);
                        continue;
                    }
                    if (mes[i] == '9')
                        mes[i] = '0';
                }
                break;
            case 'P':
                for (int i = 0; i < mes.size(); ++i)
                {
                    if (mes[i] >= '1' && mes[i] <= '9')
                    {
                        mes[i] = (char)(mes[i] - 1);
                        continue;
                    }
                    if (mes[i] == '0')
                        mes[i] = '9';
                }
                break;
            }
        }
        cout << mes << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
int main()
{
	int a,b,c,different;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c)
		different=1;
	else if(a!=b&&b!=c&a!=c)
		different=3;
	else 
		different=2;
	printf("%d",different);
	return 0;
}

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

S = [int(input())for _ in range(N)]
S.sort()

S_all = sum(S)

if S_all % 10 != 0:
    print(S_all)
    exit()

i = 0
while i < N and S[i] % 10 == 0:
    i += 1

if i != N:
    print(S_all - S[i])
else:
    print(0)

Measured memory_bytes: 3064
ls = list(map(int, input().split()))
A = ls[0]
B = ls[1]
C = ls[2]
D = ls[3]

k = [ i for i in range(0,101) if A <= i <= B and C <= i <= D]
if not k:
    print(0)
else:
    print(max(k) - min(k))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n,m,x;
int c[N],a[100][100],sum;
int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        sum += c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    int ans=1e9;
    for (int t = 0; t < (1 << n); ++t){
        int cnt = 0;
        vector<int> v(m);
    for (int i = 0; i < n; ++i) {
        if (t >> i & 1) {
            cnt += c[i];
            for (int j = 0; j < m; ++j) {
                v[j] += a[i][j];
            }
        }
    }
    bool flag = 1;
    for (int j = 0; j < m; ++j) {
        if (v[j] < x) flag = 0;
    }
    if (flag) ans = min(ans, cnt);
}
    if(ans==1e9) puts("-1");
    else printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3800
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto& x : v) cin >> x;
	sort(v.rbegin(), v.rend());
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (i & 1) ans -= v[i];
		else ans += v[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   string s;
   cin>>s;
   if(s[s.length()-1]=='s')
   {
       cout<<s<<"es"<<endl;
   }
   else if(s[s.length()-1]!='s')
   {
       cout<<s<<"s"<<endl;
   }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = c - (a-b);
  ans = max(ans, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def geta(n=0)
  return $stdin.gets.to_i if n==0
  ar = []
  n.times do 
    ar << $stdin.gets.chomp.split
  end
  return ar.flatten(1) if n<=1
  return ar
end

@ar = geta(1).map(&:to_i)
y,x = @ar.sort

rems = [y]
while (rem=x%y)>0
  rems << rem
  x = y
  y = rem
end

p rems.min


Measured memory_bytes: 6864
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    while(true){
        cin >> s;
        if(s=="0"){
            break;
        }
        int d=0;
        for(int i=0;i<s.size();i++){
            int n=s[i]-48; // TODO：文字コードを数値に変換する
            // cout << s[i] << " " << n << endl;
            d+=n;
        }
        cout << d << endl;
    }
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;

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

	int a,b,c,i,j;

	cin>>a>>b;
	i=0;
	while(a>0){
		a-=b;
		i++;
	}
	cout<<i;

    return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b>=a-b&&a+b>=a*b)cout<<a+b<<endl;
	else if(a-b>=a+b&&a-b>=a*b)cout<<a-b<<endl;
	else cout<<a*b<<endl;
	return 0;
} 

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
minv = min(x,y)
ans = a*x + b*y
for i in range(1,max(x,y)+1):
    if i <= minv:
        ans = min(ans, a*(x-i)+b*(y-i)+c*2*i)
    elif i == max(x,y):
        ans = min(ans, c*2*i)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,x,t;
    cin >> n >> x >>t;
    if (n <= x) {
        cout << t << endl;
        return 0;
    } else {
        if (n % x == 0) {
            cout << ((n /x))* t << endl;
        } else {
            cout << ((n /x) +1)* t << endl;
        }
    }
}

Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long h = sc.nextLong();
    long result = 0L;
    long count = 1L;
    while (h > 0) {
      result += count;
      count *= 2L;
      h /= 2L;
    }
    System.out.println(result);
  }
}

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

using ll = int64_t;

int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<ll> a(n);
	for(int i = 0; i < n; ++i)
		std::cin >> a[i];
	ll sum = 0; 
	std::vector<ll> s, b;
	for(auto v : a) {
		sum += v;
		s.push_back(sum);
		b.push_back(sum);
	}
	for(int i = 0; i < n; ++i) 
		for(int j = i + 1; j < n; ++j) 
			b.push_back(s[j] - s[i]);
	std::sort(std::begin(b), std::end(b), std::greater<ll>());
	ll ans = 0;
	for(int i = 50; i >= 0; --i) {
		ans |= 1ll << i;
		int num = 0;
		for(auto c : b) 
			if((ans & c) == ans)
				++num;
		if(num < m)
			ans ^= 1ll << i;
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6404
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b)
	{
		printf("a == b\n");
	}
	else
	{
		if(a>b)
		{
			printf("a > b\n");
		}
		else
		{
			printf("a < b\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
import sys

readline = sys.stdin.readline
N, K = map(int, readline().split())
X = [0] * (10**5+1)
for _ in range(N):
    a, b = map(int, readline().split())
    X[a] += b
for i, x in enumerate(X):
    K -= x
    if K <= 0:
        print(i)
        break


Measured memory_bytes: 5748
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

int main(void) {
  int a, p;
  cin >> a >> p;

  prt((3*a+p)/2);
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
tpos=[[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
  l,r=map(int,input().split())
  tpos[l][r]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    tpos[i][j]=tpos[i][j]+tpos[i-1][j]+tpos[i][j-1]-tpos[i-1][j-1]
for _ in range(q):
  l,r=map(int,input().split())
  print(tpos[r][r]-tpos[l-1][r]-tpos[r][l-1]+tpos[l-1][l-1])

Measured memory_bytes: 13348
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>  // setprecision
// #include <string>
// #include <set>
// #include <algorithm>

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

int main(int argc, char const *argv[]) {
    ll a, b, x;
    cin >> a >> b >> x;
    // p(a, b, x);

    ll start = (a + x - 1) / x;
    ll end = b / x;
    // p(start, end);
    cout << end - start + 1 << endl;

    return 0;
}


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

const int N = 606;
vector < int > g[N];
int memo[N][N], n;
double dp[N][N];

double solve(int blocked, int u){
  double resp = .0;
  if(u == n) return .0;
  double mx = -1;
  int mx_vtx;
  if(g[u].size() == 0) return 1e9;
  if(memo[blocked][u] != -1) return dp[blocked][u];
  memo[blocked][u] = 1;
  for (int v : g[u]){
    double aux = solve(blocked, v);
    resp += aux;
    if(mx < aux) {
      mx = aux, mx_vtx = v;
    }
  }
  if(u != blocked){
    return dp[blocked][u] = (resp/(double)g[u].size()) + 1;
  }
  else {
    resp -= solve(blocked, mx_vtx);
    if(g[u].size() == 1) return dp[blocked][u] = 1e9;
    return dp[blocked][u] = (resp/((double)g[u].size()-1)) + 1;
  }
}

int main(){
  int m;
  scanf("%d %d", &n, &m);
  for (int i=0; i<m; i++){
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
  }
  memset(memo, -1, sizeof memo);
  double ans = solve(0, 1);
  for (int i=1; i<=n; i++){
    ans = fmin(ans, solve(i, 1));
  }
  printf("%.8lf\n", ans);
}


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

#define ntest 0
#define PI acos(-1)

using namespace std;
int a, b, h, m;
double ah, am, angle;
void solve() {
    cin >> a >> b >> h >> m;
    ah = h * 30;
    am = m * 6;
    ah += m * 0.5;
    angle = abs(ah - am);
    if (angle > 180) angle = 360 - angle;
    cout << fixed << setprecision(20) << sqrt(a *1.0* a + b * b - 2 * a * b * cos(angle*PI/180.0));
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 4236
if __name__ == '__main__':
  n = int(input())
  a = input().split()
  a = [int(x) for x in a]
  ans = 1

  if 0 in a:
        print(0)
  else:
      for i in a:
        ans = ans*i
        if ans > 10**18:
            ans = -1
            break
      print(ans)

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   vector<int> v(n,0);
   v[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++){
       v[i]=std::min(v[i-1]+abs(a[i-1]-a[i]),v[i-2]+abs(a[i-2]-a[i]));
   }
   cout<<v[n-1];
   return 0;
}

Measured memory_bytes: 3872