akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI cnt(N + 1, 0);
	int ans = 0;
	eFOR(i, 1, 300) {
		eFOR(j, 1, 300) {
			eFOR(k, 1, 300) {
				int cn = (i + j + k)*(i + j + k) - i * j - i * k - j * k;
				if (cn > 0 && cn <= N)cnt[cn]++;
			}
		}
	}

	REP(i, N)cout << cnt[i + 1] << endl;
	return 0;
}



Measured memory_bytes: 3596
/*
    Vishal Raj
    IIT Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,l,r) for( int i = l; i < r; i++ )
#define li long long int

void upd( li & a, li b ) {
    if( a == -1 ) a = b;
    else a = min(a,b);
}

int main() {
    li n,w; cin>>n>>w;
    li dp[2][100100];
    memset(dp,-1ll,sizeof(dp));
    dp[1][0] = 0;
    FOR(i,0,n) {
        int u = i%2;
        li W,v; cin>>W>>v;
        FOR(j,0,100100) dp[u][j] = dp[1-u][j];
        FOR(j,0,100100) {
            if( dp[1-u][j] != -1 && j*1ll+v < 100100 ) upd(dp[u][j*1ll+v],dp[1-u][j]+W);
        }
    }
    int u = (n-1)%2;
    li ans = 0;
    FOR(i,0,100100) {
        if( dp[u][i] != -1 && dp[u][i] <= w ) ans = i*1ll;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    d=0
    s=list(x for x in s if x!="a")
    for j in range(n-1):
        if (i >> j)&1:
            s.insert(-j-1-d,"a")
            d+=1
    z="".join(s)
    y=list(map(int,z.split("a")))
    ans+=sum(y)
print(ans)
    
    
            


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long


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

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		int len = 0;
		int x = i;
		while (x){
			x /= 10;
			len++;
		}
		if (len % 2 == 1) ans++;
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}

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

using namespace std;

string S;

int main()
{
	int res, n, i;
	cin>>S;
	n = S.size();
	res = 0;
	for (i=0; i<n/2; i++) if (S[i] != S[n-i-1]) res ++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

const double PI=3.14159265358979323846;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    if (h > 12.0) h -= 12.0;

    double mr = 2 * PI * m / 60;
    double hr = 2 * PI * h / 12 + m / 60 * 2 * PI * 1 / 12;


    double xr = abs(hr - mr);
    if (xr > PI) xr = 2 * PI - xr;


    cout << fixed << setprecision(10) << pow(a * a + b * b - 2 * a * b * cos(xr), 0.5) << endl;

    return 0;
}

Measured memory_bytes: 4360
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A.append(K+A[0])
    print(K - max([A[i]-A[i-1] for i in range(1, N+1)]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25884
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


vector<int>G[200020];
bool visited[200020];

int dp[100010][30];
vector<int>a;
int N, L, Q;
int func(int n,int k){
	if (dp[n][k] != 0)return dp[n][k];
	int pos = a[n];
	if (k == 0) {
		int nex = pos + L;
		auto itr = ub(a, nex);
		itr--;
		int res = itr - a.begin();
		dp[n][k] = res;
		return res;
	}
	else {
		int b = func(n, k - 1);
		int res = func(b, k - 1);
		dp[n][k] = res;
		return res;
	}
}


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

	cin >> N;
	a.resize(N);
	REP(i, N) {
		cin >> a[i];
	}
	a.pb(INF);
	cin >> L >> Q;
	REP(i, Q) {
		int a, b; cin >> a >> b;
		a--, b--;
		if (a > b)swap(a, b);
		int ans = 0;
		bool ok = false;
		REPR(j, 29) {
			if (func(a, j) < b) {
				ans+=1<<j;
				a = func(a, j);
			}
		}
		ans++;
		//pe("ans:");
		print(ans);
	}
}


Measured memory_bytes: 29936
n=int(input())
def keta(a):
    k=1
    while True:
        if 10**(k-1) <= a <10**k:
            break
        k+=1
    return k
from math import sqrt
f=float("inf")
for i in range(1,int(sqrt(n))+1):
    if n%i==0:
        f=min(f,max(keta(i),keta(n//i)))
print(f)

Measured memory_bytes: 40432
n,m=map(int,input().split())
pem=1
if m==1:
    print(1)
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
if m!=1:
    a=max(f)+n
    fucfun(a)
    s=1
    for i in range(len(f)):
        t=com(f[i]+n-1,f[i])
        s=(s*t)%mod
    print(s)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, m, c; cin >> n >> m >> c;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        int sum = 0;

        for (int j = 0; j < m; ++j) {
            int a; cin >> a;
            sum += a * b[j];
        }

        sum += c;

        if (sum > 0) {
            ++ans;
        }
    }

    cout << ans << endl;
}

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

bool prime[N + 5] = {0};

void sprime() {
  prime[0] = 1;
  prime[1] = 1;
  for(int i = 2; i * i <= N; ++i)
    if(!prime[i])
      for(int j = 2; i * j <= N; ++j) prime[i * j] = 1;
}

int q;
int sum[100005] = {0};

void solve();

int main() {
  sprime();
  solve();
  cin >> q;
  for(int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }
  return 0;
}

void solve() {
  for(int i = 2; i <= 100000; ++i) {
    sum[i] += sum[i - 1];
    if(i % 2 == 0) continue;
    if((!prime[i]) && (!prime[(i + 1) / 2])) ++sum[i];
  }
}

Measured memory_bytes: 2048
//
//
//  prime.cpp - created by us162022
//
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, char *argv[])
{
  int n,x,count=0;
  cin >> n;

  for(int i=0; i<n; i++){
    cin >> x;

    if(x%2){
      bool flag=true;
      for(int j=3; j<=sqrt(x); j+=2){
	if(!(x%j)){
	  flag = false;
	  break;
	}
      }

      if(flag)
	count++;
      
    }

    else{
      if(x==2)
	count++;
    }
  }

  cout << count << endl;

}

Measured memory_bytes: 3112
#include<cstdio>
inline long long sum_layer(int n){
    return (1LL<<(n+2))-3;
}
inline long long sum_patty(int n){
    return (1LL<<(n+1))-1;
}
long long num_patty(int n,long long x){
    if(x==0)return 0;
    if(n==0)return 1;
    if(x<=sum_layer(n-1)+1)return num_patty(n-1,x-1);
    return sum_patty(n-1)+1+num_patty(n-1,x-sum_layer(n-1)-2);
}
int main(){
    int n;
    long long x;
    scanf("%d%lld",&n,&x);
    printf("%lld",num_patty(n,x));
    return 0;
}

Measured memory_bytes: 128
A=[0]*6
for i in range(6):
  A[i]=int(input())
  
isOK=True
for i in range(5):
  for j in range(i,5):
    if(abs(A[i]-A[j]) > A[5]):
      isOK=False
      
if(isOK):
  print("Yay!")
else:
  print(":(")


Measured memory_bytes: 9052
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] l = new int[n];
		
		for(int i=0; i<l.length; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();
		
		Arrays.sort(l);
		
		int sum = 0;
		for(int i=0; i<k; i++) {
			sum += l[n-1-i];
		}
		
		System.out.println(sum);
		
		
	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int k; cin >> k;
  string s; cin >> s;
  if(s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
  return 0;
}


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

using namespace std;

 
int main() {
    int L,R,d;
    cin >> L >> R >> d;
    int count = 0;
    for(int i =1;i <= R;i++){
        if(L<=i*d && R>=i*d){
            count ++;
        }
    }  
    cout << count << endl;  
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var count = 0;
            var cur = "";

            for (var i = 0; i < s.Length; i++)
            {
                if (cur != s[i].ToString())
                {
                    cur = s[i].ToString();
                    count++;
                }
                else
                {
                    cur = s[i].ToString();
                    if (i < s.Length - 1)
                    {
                        cur += s[i + 1].ToString();
                        count++;
                        i++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15712
fun main(args: Array<String>) {
    var N= nextInt()
    val dp = IntArray(N + 1) { 1000000007 }
    dp[0] = 0
    for (n in 1 .. N) {
        var power = 1
        while (power <= n) {
            dp[n] = Math.min(dp[n], dp[n - power] + 1)
            power *= 6
        }
        power = 1
        while (power <= n) {
            dp[n] = Math.min(dp[n], dp[n - power] + 1)
            power *= 9
        }
    }
    println(dp[N])
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")


Measured memory_bytes: 33976
#include<bits/stdc++.h>
#define IMAX 1000000000000

#define ll long long

using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
 
  ll b[n];
  for(ll i=0;i<n;i++)
    b[i]=IMAX;
  
  b[0]=0;
  
  for(ll i=0;i<n;i++)
  {
    ll x=i+1;
    ll y=i+2;
    if(x<n)
      b[x]=min(abs(a[i]-a[x])+b[i],b[x]);
    if(y<n)
      b[y]=min(abs(a[i]-a[y])+b[i],b[y]);
    
  }
 
  //for(ll i=0;i<n;i++)
    //cout<<b[i]<<"\n";
  
  
  cout<<b[n-1];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int a, b;
    cin >> a >> b;
    int con;
    bool res = false;
    if (b < 10) {
        con = 10 * a + b;
    } else if (b < 100) {
        con = 100 * a + b;
    } else {
        con = 1000 * a + b;
    }
    for (int i = 1; i < 1000; i++) {
        if (i * i == con) res = true;
    }
    if (res) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf') for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
	for j in range(1,k+1):
		
		if(i-j<0):
			break
		else:
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])

Measured memory_bytes: 88860
#include <iostream>
using namespace std;
int main()
{
	long long x, k, d;
	cin >> x >> k >> d;
	if (!x || x == d) {
		if (k % 2) cout << (x - d < 0 ? d - x : x - d);
		else cout << (x < 0 ? -x : x);
	}
	else {
		if (x < 0) x = -x;
		long long n = x / d, r = (x - n * d);
		if (n == k) {
			cout << (x - n * d);
		}
		else if (n > k) {
			cout << (x - k * d);
		}
		else {
			if ((k - n) % 2) cout << (d - r);
			else cout << (r);
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli a, b;
    cin>>a>>b;
    lli d = __gcd(a, b);
    cout<< a * b / d;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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

int main(){
    string input;
    cin >>  input;
    
    if((input=="AAA" ) or (input ==  "BBB")){
        cout << "No"<< endl;
    }else{
        cout << "Yes"<< endl;
    }
}

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


/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz...
　　 　 /　 　　  |   コード見ちゃだめ！！
　　　 /　 ヽ　　 ﾉ
　 　 │　　|　|　|
　／￣|　　 |　|　 |
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

int main(){
    string s,t;
    cin>>s>>t;
    vector<char>ss;
    vector<char>tt;
    for(int i=0;i<s.length();i++){
        ss.push_back(s[i]);
    }
    for(int i=0;i<t.length();i++){
        tt.push_back(t[i]);
    }
    
    sort(ss.begin(),ss.end());
    sort(tt.begin(),tt.end());
    reverse(tt.begin(),tt.end());
    

    if(ss<tt) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    



}

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

numbers_of_testimonies =[]
contents_of_testimonies =[]

for n in range(N):
  testimony = []
  x = int(input())
  numbers_of_testimonies.append(x)
  for _ in range(x):
    testimony.append(list(map(int,input().split())))
  contents_of_testimonies.append(testimony)

numbers_of_testimonies.insert(0,"x")
contents_of_testimonies.insert(0,"x")
ans = 0

for i in range(2**N):
  hypothesis = [0 for _ in range(N)]
  
  for j in range(N):
    if (i>>j) & 1:
      hypothesis[j] = 1
  hypothesis.insert(0,9)
  flag = True
  

  for k in range(1,N+1):
    if hypothesis[k] == 1:

      for l in range(numbers_of_testimonies[k]):
        if contents_of_testimonies[k][l][1] != hypothesis[contents_of_testimonies[k][l][0]]:
          flag = False

  if flag == True:
    ans = max(ans,hypothesis.count(1))
print(ans)

Measured memory_bytes: 9164
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	f := false
	for i := 0; i < n; i++ {
		if intScanner()%2 != 0 {
			f = true
		}
	}
	if f {
		fmt.Println("first")
	} else {
		fmt.Println("second")
	}
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long mod=1e9+7;
long long power(long long a,long long b)
{
	return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
long long M;
string C;
long long P[1<<17];
long long c[1<<17];
long long X[10];
int main()
{
	cin>>M>>C;
	if(C.size()==1)
	{
		if(M<10)cout<<M<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	P[0]=1;
	for(int i=1;i<C.size();i++)P[i]=P[i-1]*10%mod;
	for(int i=0;i<C.size();i++)
	{
		c[i]=C[i]-'0';
		(X[c[i]]+=P[C.size()-i-1])%=mod;
	}
	vector<int>A(10);
	for(int i=0;i<10;i++)A[i]=i;
	do{
		if(A[c[0]]==0)continue;
		long long now=0;
		for(int i=0;i<10;i++)(now+=X[i]*A[i])%=mod;
		if(now==M)
		{
			for(int i=0;i<C.size();i++)
			{
				cout<<A[c[i]];
			}
			cout<<endl;
			return 0;
		}
	}while(next_permutation(A.begin(),A.end()));
	cout<<-1<<endl;
}



Measured memory_bytes: 4852
#include <stdio.h>
#include <stdlib.h>
#define WHITE -1
#define GRAY 0
#define BLACK 1
#define INF 1000000
#define NIL -1

void dijkstra(void);

int n,G[100][100];

int main()
{
int i,id,k,v,c,j;

  scanf("%d",&n);
  if(n<1 || n>100) exit(1);

  for(i=0;i<n;i++){ //辺が入力されていないところをINFにするための処理
    for(j=0;j<n;j++){
      G[i][j] = INF;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      G[id][v] = c;
    }
  }

  dijkstra();
  
  return 0;
}

void dijkstra()
{
  int i,mincost,u,v;
  int d[100],color[100]; //d[]=重みが最小の辺の重みの記録、color[]=色

  for(i=0;i<n;i++){
    d[i] = INF; //辺なし(INF)に設定
    color[i] = WHITE; 
  }

  d[0] = 0; //始点
  color[0] = GRAY;

  while(1){
    mincost = INF; //breakの判定
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < mincost){ //訪問してないかつ、mincost(記録しているコスト)より新たなコストが小さかったら
	mincost = d[i]; //それを記録
	u = i; ///訪問したことを判断するため
      }
    }
    if(mincost == INF) break; //forループを回していなかったらbreak
    color[u] = BLACK; //訪問完了
    
    for(v=0;v<n;v++){
      if(color[v] != BLACK && d[u]+G[u][v] < d[v]){ //訪問してないかつ、uとvの間に辺があってその経路が記録している重みよりも小さかったら
        d[v] = d[u] + G[u][v]; //小さい方を記録
	color[v] = GRAY; //灰色に設定
      }
    }
  }
  
  for(i=0;i<n;i++){ //出力
    printf("%d ",i);
    if(d[i] == INF) printf("%d\n",-1);
    else printf("%d\n",d[i]);
  }
}



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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N)cin >> a[i];
	int ans = 0;

	for (int i = 0; i < N; i += 2) {
		if (a[i] % 2 == 1)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n;
int main()
{
	read(n);
	printf("%d\n",(n>>1)*(n-(n>>1)));
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a <= 0 && 0 <= b) {
        puts("Zero");
    } else if (a > 0) {
        puts("Positive");
    } else {
        int sgn = (b - a + 1) % 2;
        if (sgn)
            puts("Negative");
        else
            puts("Positive");
    }

}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let ma = min(a, b);
    let mi = if a + b >= n { a + b - n } else { 0 };
    puts!("{} {}\n", ma, mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const int inf = 1e9;
const size_t SIZE1 = 1 << 26;
const size_t SIZE2 = 2e5 + 10;
int min_buf[SIZE1];
int dp[SIZE2];
int bits_lis[SIZE2];

int main() {
    fill(min_buf, min_buf + SIZE1, inf);
    fill(dp, dp + SIZE2, inf);
    dp[0] = 0;
    
    string S;
    cin >> S;
    
    {
        int cur = 0;
        for(int i = 0; i < S.size(); i++) {
            int n = S[i] - 'a';
            int mask = 1 << n;
            cur ^= mask;
            bits_lis[i + 1] = cur;
        }
    }

    for(int i = 0; i <= S.size(); i++) {
        int cur = bits_lis[i];
        chmin(dp[i], min_buf[cur]);
        if(dp[i] == inf) continue;
        auto update = [&](int bits) { chmin(min_buf[bits], dp[i] + 1); };
        update(cur);
        int mask = 1;
        for(int i = 0; i < 26; i++) {
            update(cur ^ mask);
            mask <<= 1;
        }
    }

    cout << dp[S.size()] << endl;
    return 0;
}



Measured memory_bytes: 264340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+1]={0};
    for(int i=0;i<k;i++){
        ll d;
        cin>>d;
        ll ad[d];
        for(int j=0;j<d;j++){
            cin>>ad[j];
            a[ad[j]]=1;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]==0)
            ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>

void trace(int A[],int N){
  int i;
  for (i=0; i<N; i++){
    if(i>0)
      printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int i,j,v;
  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

  scanf("%d",&N);
  for(i=0; i<N; i++)
    scanf("%d",&A[i]);

  trace(A,N);
  insertionSort(A,N);

  return 0;
}



Measured memory_bytes: 2704
#include<stdio.h>
#include<string.h>
typedef struct point{
	int x,y;
}POINT;
POINT q[5000],sq[5000],g[15],s,c;
int qn,sqn;
char m[1005][1005],m2[1005][1005],x[1005];
int main(){
	int i,j,k,h,w,n,ans;
	int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
	FILE *fp;
	//fp=fopen("test.txt","r");
	fp=stdin;
	fscanf(fp,"%d%d%d",&h,&w,&n);
	for(i=0;i<=h+1;i++){
		if(i==0 || i==h+1){
			for(j=0;j<=w+1;j++)m[i][j]='X';
		}else{
			fscanf(fp,"%s",x);
			for(j=0;j<w;j++){
				if(x[j]>='1' && x[j]<='9'){
					g[x[j]-'0'].x=j+1;
					g[x[j]-'0'].y=i;
				}else if(x[j]=='S'){
					//s.x=j;s.y=i;
					g[0].x=j+1;g[0].y=i;
				}
			}
			//sprintf(m[i],"X%sX",x);
			strcat(m[i]+1,x);
			m[i][0]=m[i][w+1]='X';
		}
		//printf("%s\n",m[i]);
	}
	ans=0;
	memcpy(m2,m,sizeof(m));
	for(k=1;k<=n;k++){
		q[0].x=s.x=g[k-1].x;
		q[0].y=s.y=g[k-1].y;
		m[q[0].y][q[0].x]='X';
		qn=1;
		while(qn){
			sqn=0;
			for(i=0;i<qn;i++){
				m[q[i].y][q[i].x]='X';
				if(q[i].x==g[k].x && q[i].y==g[k].y)goto nex;
				for(j=0;j<4;j++){
					c.x=q[i].x+dx[j];
					c.y=q[i].y+dy[j];
					if(m[c.y][c.x]!='X'){
						sq[sqn].x=c.x;
						sq[sqn].y=c.y;
						sqn++;
						m[c.y][c.x]='X';
					}
				}
			}
			memcpy(q,sq,sizeof(POINT)*sqn);
			qn=sqn;
			ans++;
		}
		nex:
		//printf("%d\n",ans);
		memcpy(m,m2,sizeof(m2));
	}
	printf("%d\n",ans);
	fclose(fp);
	return 0;
}

Measured memory_bytes: 2364
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int64_t X, K, D, a, b;
  cin >> X >> K >> D;
  X = abs(X);

  if (X / D >= K)
  {
    cout << (X % D) + ((X / D) - K) * D << endl;
  }
  else
  {
    a = X % D;
    b = abs(X % D - D);
    if ((K - (X / D)) % 2 == 0)
    {
      cout << a << endl;
    }
    else
    {
      cout << b << endl;
    }
  }
}


Measured memory_bytes: 3160
n = gets.to_i
t = gets.split("\s").map(&:to_i)
result = 0
n.times do |i|
  result += t[i]
end
m = gets.to_i

m.times do |i|
  p, x = gets.split("\s").map(&:to_i)
  puts result - t[p-1] + x
end

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
  while(true) {
    int H, W;
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (i % 2 == 0) {
          if (j % 2 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        } else {
          if (j % 2 == 0) {
            cout << ".";
          } else {
            cout << "#";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3100
Dic = {}
N = int(input())
for _ in range(N):
    a = int(input())
    if a in Dic.keys():
        Dic[a] += 1
    else:
        Dic[a] = 1
ans = 0
for v in Dic.values():
    if v % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 15068
#include <stdio.h>

int main(void) {
	int s[1000000];
	int ans;
	scanf("%d", &s[0]);
	for(int i=0;i<1000000;i++)
		{
			if(s[i]%2==0)
			{
				s[i+1] = s[i]/2;
			}
			else
			{
				s[i+1] = 3*s[i]+1;
			}
			for(int j=0;j<i+1;j++)
			{
				if(s[i+1]==s[j])
				{
					
					ans = i+1;
					goto OUT;
				}
			}
		}
	OUT:
	printf("%d", ans+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

#define N 200000

int j[N];

int main(void) {

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        j[i] = 0;
    }

    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        j[a-1]++;
    }

    for (int i = 0; i < n; i++) {
        cout << j[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3936
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)


Measured memory_bytes: 22032
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            //int cnt = int.Parse(Console.ReadLine());
            long[] input=  Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long devideAns = input[0] / (input[1] + input[2]);
            long cnt = 0;
            if (0 < input[1])
            {
                cnt = devideAns * input[1];
            }
            else 
            {
                cnt = 0;
            }
            long ex = input[0] % (input[1] + input[2]);

            if (ex < input[1])
            {
                cnt = ex + cnt;
            }
            else
            {
                cnt = input[1] + cnt;
            }

            Console.WriteLine(cnt.ToString());
            
            
        }
    }
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template <typename T>
inline bool chmax (T& a, T b)
{
  if(a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  long long N;
  cin >> N;
  vector<long long> A (N);
  for(long long i; i < N; i++)
  {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long ans = A[0];
  long long i = 0, j = 1;
  int p = 0;
  while(i < N - 2)
  {
    if(p == 2)
    {
      j++;
      p = 0;
    }
    ans += A[j];
    p++;
    i++;
  }
  cout << ans << endl;
}


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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(a);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<ll> vi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vi> vvi;
const int mod=1e9+7;
const int mxN = 1e5+5;

void solve(){
	int n;cin>>n;
	vd p(n+1);
	rep(i,1,n) cin>>p[i];
	vvd dp(n+1,vd(2*n+1));
	// dp[i][j] denotes number of heads-tails = (j-n) after considering ith coin;
	dp[0][n]=1;
	rep(i,1,n){
		rep(j,0,2*n){
			if(j>0){
				dp[i][j] += dp[i-1][j-1]*p[i];
			}
			if(j<2*n){
				dp[i][j] += dp[i-1][j+1]*(1-p[i]);
			}
		}
	}
	
	double ans=0;
	rep(j,n+1,2*n){
		ans += dp[n][j];
	}
	cout<<fixed<<setprecision(10)<<ans<<"\n";
}

int main(){
	solve();
}
/*input
5
0.5 0.5 0.5 0.5 0.5 

0.42 0.01 0.42 0.99 0.42


*/

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

char exam_result(int m, int f, int r){
    if(m == -1 || f == -1) return 'F';
    else if(m + f >= 80) return 'A';
    else if(m + f >= 65) return 'B';
    else if(m + f >= 50) return 'C';
    else if(m + f >= 30) if(r>=50)return 'C';else return 'D';
    else return 'F';
}

int main()
{
    while(true){
        int m, f, r;
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1) break;
        else cout << exam_result(m, f, r) << endl;
    }
}


Measured memory_bytes: 3112
import java.util.*;

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

    String[] s = sc.next().split("");

    String ans = "Good";
    if (s[0].equals(s[1])) ans = "Bad";
    if (s[1].equals(s[2])) ans = "Bad";
    if (s[2].equals(s[3])) ans = "Bad";

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	for {
		m := nextInt()
		f := nextInt()
		l := nextInt()

		if m == -1 && f == -1 && l == -1 {
			break
		}

		if m == -1 || f == -1 {
			fmt.Println("F")
		} else if m+f >= 80 {
			fmt.Println("A")
		} else if m+f >= 65 {
			fmt.Println("B")
		} else if m+f >= 50 {
			fmt.Println("C")
		} else if m+f >= 30 {
			if l >= 50 {
				fmt.Println("C")
			} else {
				fmt.Println("D")
			}
		} else {
			fmt.Println("F")
		}

	}

}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



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

int main(void){
  int x,a,b;
  cin >> x >> a >> b;

  int d = b-a;
  if(d <= 0){
    cout << "delicious" << endl;
  }
  else{
    if(d > x){
      cout << "dangerous" << endl;
    }
    else{
      cout << "safe" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  ll N;cin >> N;
  cout << (N%2==0 ? N : N*2) << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input;
    list = [64, 32, 16, 8, 4, 2, 1];
    for(i = 0; i < list.length; i++) {
        if(list[i] <= input) {
            console.log(list[i]);
            break;
        }
    }
    
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  vll xyz(3, 0);
  ll k;
  cin >> xyz[0] >> xyz[1] >> xyz[2] >> k;
  vector<vll> v(3, vll(*max_element(xyz.begin(), xyz.end())));

  REP(i, 3){
    REP(j, xyz[i])
      cin >> v[i][j];
  }

  sort(v[0].rbegin(), v[0].rend());
  sort(v[1].rbegin(), v[1].rend());
  sort(v[2].rbegin(), v[2].rend());
  map<pair<int,pair<int,int>>, bool> visi;

 
  vll index(3, 0);

  priority_queue<pair<ll, vll>> que;
  pair<ll, vll> p = make_pair(0, index);
  REP(j, 3)
    p.FI += v[j][p.SE[j]];

  ll x,y,z;
  que.push(p);
  ll kCount = 0;
  while(que.empty() != true){
    pair<ll, vll> now = que.top();
    que.pop();
    cout << now.FI << "\n";

    kCount++;
    if(kCount >= k)
      break;

    REP(i, 3){
      now.SE[i]++;
      x = now.SE[0];
      y = now.SE[1];
      z = now.SE[2];
      if(now.SE[i] >= xyz[i]){
        now.SE[i]--;
        continue;
      }
      if(!visi[MP(x, MP(y, z))]){
        visi[MP(x, MP(y, z))] = 1;
        now.FI = v[0][x] + v[1][y] + v[2][z];
        que.push(now);
      }
      now.SE[i]--;
    }
  }

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    vec(b,n);
    input(b,n);
    int tot = 0;
    REP(i,n){
        tot += abs(a[i]-b[i]);
    }
    print(tot)
    double tot1;
    tot = 0;
    REP(i,n){
        tot += pow(a[i]-b[i],2);
    }
    tot1 = sqrt((double)tot);
    printD(tot1);
    tot = 0;
    REP(i,n){
        tot += abs(pow(a[i]-b[i],3));
    }
    tot1 = cbrt((double)tot);
    printD(tot1);
    tot = 0;
    REP(i,n){
        tot = max(tot,abs(a[i]-b[i]));
    }
    print(tot);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}






Measured memory_bytes: 3464
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n = int(input())
a = nl()

a_sorted_1 = sorted(a)
ai = a_sorted_1[-1]

a_sorted_2 = sorted(a_sorted_1[:-1], key = lambda x: abs(x - ai / 2))
aj = a_sorted_2[0]
print(ai, aj)

Measured memory_bytes: 14052
#include <iostream>

using namespace std;

int main () {

    unsigned long N, x;
    cin >> N >> x;

    unsigned long a[N];

    for (int i=0; i<N; i++)
    cin >> a[i];

    unsigned long sum = 0;
    if (a[0] > x){
      sum += a[0] - x;
        a[0] -= a[0] - x;
        
    }
    for (int j=0; j<N-1; j++){
        if(a[j]+a[j+1] > x){
          sum += a[j] + a[j+1] - x;
            a[j+1] -= a[j] + a[j+1] - x;
            
        }
    }

    cout << sum << "\n";
}


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

int main(){
        string a,b,c;
        auto last = [](string str){return str[str.size()-1];};
        auto start = [](string str){return str[0];};

        cin >> a >> b >> c;
        if(last(a)==start(b)&&last(b)==start(c)){
                cout << "YES" << endl;
        }
        else{
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int num1,num2,num3;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d%d%d",&num1,&num2,&num3);
  
  if(num1 == num2)
  {
    printf("%d\n",num3);
  }else if(num1 == num3)
  {
    printf("%d\n",num2);
  }else
  {
    printf("%d\n",num1);
  }
  
  return 0;
}
  

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

int HW[110][110];
int dp[110][110];
int H, W;
int search(int h, int w)
{   
    if(dp[h][w] != -1) return dp[h][w]; 
    int res = 1000;
    if(h > 1)
    if(HW[h][w] - HW[h -1][w] == 1)res = search(h - 1, w) + 1;
    else res = search(h - 1, w);
    
    if(w > 1)
    if(HW[h][w] - HW[h][w -1] == 1) res = min(res, search(h, w -1) + 1);
    else res = min(res, search(h, w -1));

    return dp[h][w] = res;

}

int main ()
{
    cin >> H >> W;

    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= H; i++)for(int j = 1; j <= W; j++)
    {
        char s;
        cin >> s;
        if(s == '#') HW[i][j] = 1;
        else HW[i][j] = 0;
    }

    if(HW[1][1] == 1)dp[1][1] = 1;
    else dp[1][1] = 0;

    cout << search(H, W) << endl;
    
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    long long  a, b;
    cin >> a >> b;

    if(b%2!=0)
    {
        if((b+1)%4!=0)
        {
            b = 1;
        }
        else
        {
            b = 0;
        }
    }
    else
    {
        if(b%4!=0)
        {
            b = b ^ 1;
        }
        else
        {
            
        }
        
    }
    
    long long  ans;
    if (a % 2 == 0)
    {
        if(a%4==0)
        {
            a = 0;
        }
        else
        {
            a = 1;
        }
    }
    else
    {
        if((a-1)%4==0)
        {
            a = a - 1;
        }
        else
        {
            a = (a - 1) ^ 1;
        }
    }
    ans = a ^ b;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n,i,y=0,y2=0,y3=0;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%4==0)
            ++y;
        else if(a[i]%2==0)
            ++y2;
        else if(a[i]%2!=0)
            ++y3;
    }
    if(y2==0 && y3<=y+1)
        printf("Yes\n");
    else if(y2>0 && y3<=y)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

int h, w;
char masu[50][50];
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> masu[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (masu[i][j] == '.') {
                int count = 0;
                for (int k = 0; k < 8; k++) {
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if (x >= 0 && x < w && y >= 0 && y < h &&
                        masu[y][x] == '#') {
                        count++;
                    }
                }
                cout << count;
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
    // for (int i = 0; i < h; i++) {
    //     for (int j = 0; j < w; j++) {
    //         cout << masu[i][j];
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    if b > a:
        return gcd(b,a)
    return gcd(b,a%b)

def main():
    a,b = map(int,input().split())
    g = gcd(max(a,b),min(a,b))
    lcm = a*b//g

    print(lcm)

main()


Measured memory_bytes: 2940