akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int V, E, R, S[500010], T[500010], D[500010];
int C[100010];
const int Inf = 10000*100000+100;

int main() {
  cin >> V >> E >> R;
  for (int i=0; i<E; ++i)
    cin >> S[i] >> T[i] >> D[i];
  for(int i=0; i<V; i++) C[i] = Inf;
  C[R] = 0;
  for (int t=0; t<V; ++t) {
    bool update = false;
    for (int i=0; i<E; ++i) {
      int s = S[i], t = T[i], d = D[i];
      if (C[s] < Inf && C[t] > C[s] + d) {
	C[t] = C[s] + d;
	update = true;
      }
    }
    if (!update) break;
  }
  for(int i=0; i<V; i++) {
    if (C[i] == Inf) cout << "INF" << endl;
    else cout << C[i] << endl;
  }
  return 0;
}

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

bool check(vector<int> v, vector<int> w){
  for(int i=0; i<v.size(); i++){
    if(v[i]!=w[i]) return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];
  
  vector<int> num(N); for(int i=0; i<N; i++) num[i]=i+1;
  
  int a=-1;
  int b=-1;
  int now=1;
  do{
    if(check(P, num)) a=now;
    if(check(Q, num)) b=now;
    if(a>0 && b>0) break;
    now++;
  }while(next_permutation(num.begin(), num.end()));
  cout << abs(a-b) <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

#define ull unsigned long long
#define ll long long
#define inf 1000000000
#define INF 1000000000000000000ll
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pii pair < int , int >
#define pll pair < ll , ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); ++ it)
#define all(a) a.begin(), a.end()
#define sqr(x)  (x) * (x)
#define sqrl(x)  (x) * 1ll * (x)

const int N = 10005;

int n;
int a[N];

int main (){
	scanf("%d", &n);
	for(int i = 1;i <= n + n;++ i)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + n + 1);
	int res = 0;
	for(int i = 1;i <= n + n;i += 2){
		res += a[i];
	}
	printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mod 1000000007
using namespace std;
typedef long long ll;

int main(void)
{
    const double PI=3.14159265358979323846;
    double n;
    cin>>n;
    cout<<2*n*PI<<endl;
    return 0;
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int H = scanner.nextInt();
            int W = scanner.nextInt();
            if (H == 0 && W == 0) break;
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    System.out.print('#');
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 37168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF = 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int min = INF;
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) <= min) {
            ret++;
            min = vec.at(i);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    if S <= W: return 'unsafe'
    else: return 'safe'


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    print(solve(S, W))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
using namespace std;
typedef long long ll;
int n,a[200010];
int main() {
	scanf("%d",&n);
	int mx[2]={-0x7fffffff,-0x7fffffff};
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		if(a[i]>mx[0]) mx[1]=mx[0],mx[0]=a[i];
		else if(a[i]>mx[1]) mx[1]=a[i];
	}
	for(int i=1;i<=n;i++) {
		if(a[i]==mx[0]) printf("%d\n", mx[1]);
		else printf("%d\n", mx[0]);
	}
	return 0;
}

Measured memory_bytes: 2432
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

XXX = 2 * (10 ** 10)
A, B, Q = get_ints
S = []
T = []
X = []

A.times do
  S << get_int
end

B.times do
  T << get_int
end

Q.times do
  X << get_int
end

S.sort!
T.sort!

X.each.with_index do |x, i|
  s_index = S.bsearch_index { |v| v > x }
  t_index = T.bsearch_index { |v| v > x }

  s_left = s_index.nil? ? S.last : s_index > 0 ? S[s_index - 1] : nil
  s_right = s_index.nil? ? nil : S[s_index]
  t_left = t_index.nil? ? T.last : t_index > 0 ? T[t_index - 1] : nil
  t_right = t_index.nil? ? nil : T[t_index]

  kouho = []
  # 左に行く
  kouho.push (s_left.nil? || t_left.nil?) ? XXX : [(x - s_left).abs, (x - t_left).abs].max
  # 右に行く(S, Tの大きい方)
  kouho.push (s_right.nil? || t_right.nil?) ? XXX : [(x - s_right).abs, (x - t_right).abs].max

  # Sの左の最初に言って右のTに行く
  kouho.push (s_left.nil? || t_right.nil?) ? XXX : (x - s_left).abs * 2 + (x - t_right).abs
  # 左のTの最初に行って右のSに行く
  kouho.push (t_left.nil? || s_right.nil?) ? XXX : (x - t_left).abs * 2 + (x - s_right).abs
  # 右のSに最初に行って、左のTに行く
  kouho.push (s_right.nil? || t_left.nil?) ? XXX : (x - s_right).abs * 2 + (x - t_left).abs
  # 右のTに最初に行って、左のいSに行く
  kouho.push (t_right.nil? || s_left.nil?) ? XXX : (x - t_right).abs * 2 + (x - s_left).abs

  puts kouho.min
end


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

int main(){
    int64_t A,B,K;

    cin >> A >> B >> K;

    if(K >= A && B-(K-A) < 0){
        cout << 0 << ' ' << 0;
        return 0;
    }

    if(K >= A){
        
        cout << 0 << ' ' << B-(K-A);
        return 0;
    }
    if(K < A){

        cout << A-K << ' ' << B;
        return 0;
    }

    

/*
    for (size_t i = 0; i < K; i++)
    {
        if(A >= 1){
            A--;
            
        } else if (B >= 1){
            B--;
            
        } else
        {
            break;
        }


    }
*/
    

}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

struct st {
  int C;
  int S;
  int F;
};

int main() {
  int n;
  cin >> n;
  vector<st> v(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> v[i].C >> v[i].S >> v[i].F;
  }

  // 出力 s = 駅番号
  for (int s = 0; s < n - 1; s++) {
    ll t = 0;  // 時間
    for (int i = s; i < n - 1; i++) {
      if (t <= v[i].S) {
        t = v[i].S;
      } else {
        if (t % v[i].F != 0) {  // 待ち時間がある時は
          t += v[i].F - (t % v[i].F);
        }
      }
      t += v[i].C;
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S,T,ans="Yes";
  cin>>S>>T;
  map<char,char> ST,TS;
  rep(i,0,S.size()){
    if(S[i]!=T[i]){
      if(ST.count(S[i])){
        if(ST.at(S[i])!=T[i]){
          ans="No";
          break;
          }
        }
        else
          ST[S[i]]=T[i];
      }
      if(TS.count(T[i])){
        if(TS.at(T[i])!=S[i]){
          ans="No";
          break;
          }
        }
      else
        TS[T[i]]=S[i];
    }
  cout<<ans;
  }


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

using namespace std;
using lint = long long;

int main() {
    lint X;
    cin >> X;

    lint a = 100;
    int res = 0;
    while (a < X) {
        a += a * 0.01;
        res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sp <<" "<<
bool isprime(ll n){
    if (n <= 1)return false;ll g=sqrt(n);
    for (ll i = 2; i <= g; i++)if (n % i == 0)return false;
    return true;
}
ll MOD=LLONG_MAX;
ll power(ll base, ll exp)
{
    if(exp==1)return base;
    else{if(exp%2==0){ll base1=(pow(power(base, exp/2),2));return base1%MOD;}
        else{ll ans=(base*pow(power(base,(exp-1)/2),2));return ans%MOD;}}
}
ll temp,temp1,temp2;
int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    if(n<=2)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        int i,j,k,res=0;
        sort(v.begin(),v.end());
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    if(v[i]!=v[j]&&v[j]!=v[k]&&v[k]!=v[i]&&v[k]<v[i]+v[j])
                        res++;
                }
            }
        }
        cout<<res<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3676
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        int ans;
        if (N == 1) {
            ans = 1;
        } else if (N < 4) {
            ans = 2;
        } else if (N < 8) {
            ans = 4;
        } else if (N < 16) {
            ans = 8;
        } else if (N < 32) {
            ans = 16;
        } else if (N < 64) {
            ans = 32;
        } else {
            ans = 64;
        }
        out.println(ans);

        out.flush();
    }
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    double ans = 6.28318530717958623200*n;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3788
class Vector():
    def __init__(self, num_vector):
        self.vector = [[] for i in range(0, num_vector)]

    def pushBack(self, t, x):
        self.vector[t].append(x)
        return self

    def dump(self, t):
        print(' '.join(map(str, self.vector[t])))
        return self

    def clear(self, t):
        self.vector[t].clear()
        return self


num_vector, num_queue = tuple(map(int, input().split(' ')))
A = Vector(num_vector)

for i in range(0, num_queue):
    queue = tuple(map(int, input().split(' ')))
    if queue[0] == 0:
        A.pushBack(queue[1], queue[2])
    elif queue[0] == 1:
        A.dump(queue[1])
    elif queue[0] == 2:
        A.clear(queue[1])


Measured memory_bytes: 60692
#include <functional>
#include <iostream>

std::function<int(int, int)> CharcterToOperate(char Character)
{
    if(Character == '+') return [](int X, int Y){return X + Y;};
    if(Character == '-') return [](int X, int Y){return X - Y;};
    if(Character == '*') return [](int X, int Y){return X * Y;};
    return [](int X, int Y){return X / Y;};
}

int main()
{
    while(true){
        int X, Y;
        char Op;
        std::cin >> X >> Op >> Y;
        if(Op == '?') return 0;
        std::cout << CharcterToOperate(Op)(X, Y) << std::endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  int n,k; cin>>n>>k;
  vector<int> vis(n+10,0);
  for(int i=0,d,a ; i<k ; i++){
    cin>>d;
    while(d>0){
      cin>>a;
      vis[a]=1;
      --d;
    }
  }
  int cnt=0;
  for(int i=1 ; i<=n ; i++) cnt+=(vis[i]==0);
  cout<<cnt;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

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

int main(){
    string t;
    cin >> t;
    int skip = 0;
    for(int i=0;i<t.size();i++){
        if(t.at(i)=='?'){
            t.at(i) = 'D';
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 3716
const main = input => {
  const [[N]] = input

  const _ = N.slice(-1)

  if (['2', '4', '5', '7', '9'].includes(_)) return [['hon']]
  if (['0', '1', '6', '8'].includes(_)) return [['pon']]

  return [['bon']]
}

const wrapper = data => {
  const input = data.split('\n').map(line => line.split(' '))
  const output = main(input)
  console.log(output.map(line => line.join(' ')).join('\n'))
}

wrapper(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29636
'use strict'
function main(input) {
    const tmp = Array.from(input.split('\n'));
    const NM = tmp.shift().split(' ').map((elem) => parseInt(elem), 10);
    const N = NM[0];
    const M = NM[1];

    const mod = 1000000007;
    const A = tmp.map((elem) => parseInt(elem, 10));
    let dp = Array(N + 1).fill(0);
    for (let a of A) {
        dp[a] = -1;
    }
    dp[0] = 1;

    for (let i = 0; i < N; i++) {
        if (dp[i] === -1) {
            continue;
        }
        if (dp[i + 1] !== -1) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }
        if (dp[i + 2] !== -1) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }


    }
    console.log(dp[N]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 27556
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int a = int.Parse(input[2]);
        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
            WriteLine(48-a);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;
const ll INF =1e15;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> G(n+1);
    ll dp[100005][3];
    Fill(dp,INF);
    rep(i,m){
        int u,v;
        cin>>u>>v;
        G[u].emplace_back(v);

    }
    int s,t;
    cin>>s>>t;
    dp[s][0]=0;
    queue<pii> que;
    que.push(make_pair(s,0));
    while(!que.empty()){
        pii tmp = que.front();que.pop();
        int nex = (tmp.second+1)%3;
        for(auto v:G[tmp.first]){
            if(dp[v][nex]!=INF) continue;
            dp[v][nex] = dp[tmp.first][tmp.second]+1;
            que.push(make_pair(v,nex));
        }
    }
    if(dp[t][0]==INF){
        cout<<-1<<endl;
    }else{
        cout<<dp[t][0]/3<<endl;
    }
    return 0;
}

Measured memory_bytes: 8064
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        long N, A, B;
        {long[] a = in.ll(); N = a[0]; A = a[1]; B = a[2];}
        long sum = A+B;
        long ans = N/sum*A+Math.min(N%sum, A);
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23252
def palindrome(string): return 1 if string==string[::-1] else 0

kaibun=input()

N=len(kaibun)
A=kaibun[0:int((N-1)/2)]
B=kaibun[int((N+3)/2-1):int(N)]


if palindrome(kaibun) & palindrome(A) & palindrome(B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
    
    int n;
    int q;
    int S[100000];
    int left;
    int right;
    int mid;
    int count = 0;
    int key;
    int i;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);

    for(i=0; i<q; i++){
        scanf("%d", &key);
        left = 0;
        right = n;
        while(right>=left){
            mid = (left+right)/2;
            if(S[mid]==key){
                count++;
                break;
            }
            if(key>S[mid]){
                left = mid + 1;
            }
            else{
                right = mid-1;
            }   
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2108
N = int(input())
S = input()

cost = list(S).count("E")

ans = 1000000
for si in S:
    if si == "E":
        cost -= 1
    elif si == "W":
        if cost < ans:
            ans = cost
        cost += 1
else:
    if cost < ans:
        ans = cost
print(ans)

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

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main(){
        int r,c;
		cin>>r>>c;
		int mat[101][101] = {0};
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				cin>>mat[i][j];
				mat[i][c]+=mat[i][j];
			}
		}
		for(int i=0;i<r;i++){
			for(int j=0;j<=c;j++){
				mat[r][j]+=mat[i][j];
			}
		}

		for(int i=0;i<=r;i++){
			for(int j=0;j<=c;j++){
				cout<<mat[i][j];
				if(j==c)
					break;
				cout<<" ";
			}
			cout<<endl;
		}
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] A_list = Console.ReadLine().Split(' ');
            int[] B_list = new int[n];                
            for (int i = 0; i < n; i++)
            {
                B_list[i] = int.Parse(A_list[i]);
            }            
            int x = 0;
            int y = 0;

            while (x == 0)
            {
                
                for (int i = 0; i < n; i++)
                {
                    x += B_list[i] % 2;
                    B_list[i] = B_list[i] / 2;
                }

                if (x == 0)
                {
                    y += 1;
                }                              
              
            }
            Console.WriteLine(y);            
        }
    }
}


Measured memory_bytes: 13140
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

class comb {
    ll inf;
    vector <ll> fact, inv;
public:
    comb(ll n, ll infi) {
        fact.resize(n + 1);
        inv.resize(n + 1);
        inf = infi;
        fact[0] = 1;
        for(ll i = 1; i <= n; i++)
            fact[i] = (fact[i - 1]  * i) % inf;
        for(ll i = 0; i <= n; i++)
            inv[i] = exp(fact[i], inf - 2);
    }
    ll ncr(ll n, ll r) {
        ll ans = fact[n];
        ans = (ans * inv[r]) % inf;
        ans = (ans * inv[n - r]) % inf;
        return ans;
    }
    ll f(ll n) {
        return fact[n];
    }
    ll iv(ll n) {
        return inv[n];
    }
    ll exp(ll a, ll b) {
        ll res = 1;
        while(b > 0) {
            if(b & 1)
                res = (res * a) % inf;
            a = (a * a) % inf;
            b >>= 1;
        }
        return res;
    }
};

void solve()
{
    ll n, m;
    cin >> n >> m;
    ll inf = (ll)1e9 + 7;
    comb c(m, inf);
    ll ans = c.ncr(m, n);
    ll der = c.f(m);
    for(ll i = 1; i <= n; i++)
    {
        ll temp = c.ncr(n, i);
        temp = (temp * c.f(m - i)) % inf;
        if(i % 2 == 0)
            der = (der + temp) % inf;
        else der = (der + inf - temp) % inf;
    }
    //cout << der << endl;
    ans = (ans * der) % inf;
    ans = (ans * c.f(n)) % inf;
    ans = (ans * c.iv(m - n)) % inf;
    cout << ans << endl;
}

signed main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

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

int main( void )
{
  int A, B, K;
  cin >> A >> B >> K;
  int min;
  
  if( A > B )
    min = B;
  else
    min = A;
  
  int count = 0;

  for( int i = min; i >= 0; i-- ) {
    if( A % i == 0 && B % i == 0 ) {
      count++;
    }
    if( count == K ) {
      cout << i << endl;
      break;
    }
  }
}

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

int main(){
	int a, b, c;
	while(cin >> a >> b >> c && !(a == -1 && b == -1 && c == -1)){
		if(a == -1 || b == -1)
			cout << 'F' << endl;
		else if(a+b >= 80)
			cout << 'A' << endl;
		else if(a+b >= 65)
			cout << 'B' << endl;
		else if(a+b >= 50)
			cout << 'C' << endl;
		else if(a+b >= 30)
			if(c >= 50)
				cout << 'C' << endl;
			else
				cout << 'D' << endl;
		else
			cout << 'F' << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

string ans = "Yes";
string anss = "";

void proc(string& s, ll& x, ll& y, ll& z, bool nolast, ll& i) {
  map<string, ll> code;
  code["AB"] = 0;
  code["BC"] = 1;
  code["CA"] = 2;

  ll curc = code[s];

  if (x == 0 && y == 0) {
    cout << "No" << endl;
    exit(0);
  }
  if (x > y) {
    x--, y++;
    anss += s[1];
  } else if (x == 1 && y == 1 && z == 0 && nolast) {
    string ns;
    cin >> ns;    
    i++;
    if (ns == "AC") ns = "CA";
    ll nexc = code[ns];
    if (curc == nexc) {
      anss += s[0];
      anss += ns[1];
    } else if ((curc + 1) % 3 == nexc) {
      anss += s[1];
      anss += ns[1];
      x = 0, y = 1, z = 1;
    } else if ((curc + 2) % 3 == nexc) {
      anss += s[0];
      anss += ns[0];
      x = 1, y = 0, z = 1;
    }
  } else {
    x++, y--;
    anss += s[0];
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, a, b, c;
  cin >> n >> a >> b >> c;
  rep(i, n) {
    string s;
    cin >> s;
    bool nolast = i != n - 1;
    if (s == "AB") {
      proc(s, a, b, c, nolast, i);
    } else if (s == "BC") {
      proc(s, b, c, a, nolast, i);
    } else if (s == "AC") {
      s = "CA";
      proc(s, c, a, b, nolast, i);
    }
  }
  cout << ans << endl;
  if (ans == "Yes")
    for (char c : anss) cout << c << endl;

  return 0;
}


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

int main() {
  int a[5];
  for (int i = 0; i < 5; i++)
    cin >> a[i];
  
  int sum = 0;
  int minOnes = 10;
  for (int i = 0; i < 5; i++) {
    int ones = a[i] % 10;
    ones = ones == 0 ? 10 : ones;
    
    sum += a[i] + 10 - ones;
    
    if (minOnes > ones)
      minOnes = ones;
  }
  
  cout << (sum - 10 + minOnes) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	int N;cin>>N;
  vi A(N);rep(i,N)cin>>A[i];

  ll money = 1000;

  vi list;
  for(int i=0; i<N; i++){
    list.push_back(A[i]);
    //cout<<i<<" ";debug(list);

    if(i==N-1){
      if(!list.empty()){
        ll buy = money / list.front();
      money -= buy * list.front();
      money += buy * list.back();
      }
      break;
    }

    if(A[i] <= A[i+1]){
      //明日上がる
      ;
    }else{
      //明日下がる
      ll buy = money / list.front();
      money -= buy * list.front();
      money += buy * list.back();
      list.clear();
    }
  }

  cout<<money<<endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

	int n;
	cin >> n;

	int sum = 0;
	int mi = INF;
	rep(i, n) {
		int s;
		cin >> s;
		sum += s;
		if (s % 10) {
			mi = min(s, mi);
		}
	}

	if (sum % 10) {
		cout << sum << endl;
	}else
	if (mi == INF) {
		cout << 0 << endl;
	}else {
		cout << sum - mi << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// B - Card Game for Two
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> card(N);

    //入力
    for (int i = 0; i < N; i++) {
        cin >> card.at(i);
    }

    int sum = 0;
    
    //ソートして順番に正負
    sort(card.begin(), card.end());
    for (int i = 0; i < N ; i++) {
        if (i % 2 == 0) {
            sum += card.at(N - 1 - i);
        }
        else {
            sum -= card.at(N - 1 - i);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N,A,B;cin>>N>>A>>B;
    string s;cin>>s;

    int a=0,b=0;
    REP(i,N){
        if(s[i]=='a'&&a+b<A+B){
            cout<<"Yes"<<endl;
            a++;
        }else if(s[i]=='b'&&a+b<A+B&&b<B){
            cout<<"Yes"<<endl;
            b++;
        }else{
            cout<<"No"<<endl;
        }


    }

    return 0;
}

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


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

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

int main(){
  boost;

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

  int dp[n+1]={};
  // memset(dp,,sizeof dp);
  // cout<<dp[0]<<"\n";
  for(int i=0;i<n+1;i++){
    dp[i]=INT_MAX;
  }

  dp[0]=0;
  // dp[1]=abs(a[1]-a[0]);
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i-j<0)
      break;

      dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
    }
  }
  cout<<dp[n-1];
 
}



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

using namespace std;

typedef long long LL;
#define mod 1000000007

#define MAX_N 305
#define MAX_M 305

int N, M;

void input()
{
  cin >> N >> M;
}

//パスの長さ パスに含まれる頂点の数 強連結の数
LL dp[MAX_N][MAX_N][MAX_N];
LL solve()
{
  memset(dp, 0, sizeof(dp));
  dp[0][1][1] = 1;

  for (int i = 0; i < M; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= N; k++) {

        dp[i+1][j+1][k] += dp[i][j][k] * (N-j);
        dp[i+1][j+1][k] %= mod;

        if(j >= k){
          dp[i+1][j][k] += dp[i][j][k] * (j-k);
          dp[i+1][j][k] %= mod;
        }

        dp[i+1][j][j] += dp[i][j][k]*k;
        dp[i+1][j][j] %= mod;

      }
    }
  }

  return dp[M][N][N];
}

int main()
{
  input();

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 221952
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>
#include <math.h>

int main()
{
	int N, D;
	std::vector<std::vector<int>> X;

	std::cin >> N >> D;
	X.resize(N);
	for (auto& xs : X) {
		xs.resize(D);
		for (auto& x : xs) {
			std::cin >> x;
		}
	}
	
	int result = 0;
	for (int i = 0; i < N-1; ++i) {
		for (int j = i+1; j < N; ++j) {
			int d2 = 0;
			for (int k = 0; k < D; ++k) {
				int d = X[i][k] - X[j][k];
				d2 += d*d;
			}
			if (int(sqrt(d2)) == sqrt(d2)) {
				++result;
			}
		}
	}
	
	std::cout << result << "\n";
}


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

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

}


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

int main(int argc, char const *argv[]) {
  int A,B,T,sum = 0;
  cin >>A >> B >> T;
  for (size_t i = A; i < T+0.5; i += A) {
    sum += B;
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

int in[1001];
string dp[101][101][2];

bool check(string &s){
  int cur=s[s.size()-1]-'0';
  for(int i=s.size()-2;i>=0;i--){
    if(s[i]=='0'&&cur==1)cur=0;
    else cur=1;
  }
  return cur==1;
}

string dfs(int zero,int one,int dig){
  if(!(zero|one))return "";
  if(dp[zero][one][dig]!="-1")
    return dp[zero][one][dig];
  if(one==0&&zero==1&&dig==0)return "0";
  if(one==1&&zero==0&&dig==1)return "1";
  string res;
  string tmp;
  if(zero>=1){
    if(dig==1){
      string a='0'+dfs(zero-1,one,0);
      if(dfs(zero-1,one,0)!="n"){
	if(res=="")res=a;
	else res=min(res,a);
      }
    }
    else{
      string a='0'+dfs(zero-1,one,1);
      if(dfs(zero-1,one,1)!="n"){
	if(res=="")res=a;
	else res=min(res,a);
      }
    }
  }
  if(one>=1){
    if(dig==1){
      for(int i=0;i<2;i++){
	string a='1'+dfs(zero,one-1,i);
	if(dfs(zero,one-1,i)!="n"){
	  if(res=="")res=a;
	  else res=min(res,a);
	}
      }
    }
  }
  if(res=="")res="n";
  return dp[zero][one][dig]=res;
}

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++)cin>>in[i];
  int one,zero;
  zero=one=0;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(in[i]==0)zero++;
    else if(in[i]==1)one++;
    else in[cnt++]=in[i];
  }
  sort(in,in+cnt);
  if(one>=1||!(one|zero)){
    if(cnt!=1&&in[cnt-1]==3&&in[cnt-2]==2)
      swap(in[cnt-1],in[cnt-2]);
    // 最後に1がつくれる場合
    // どの順番が辞書順最初になるか調べる
    for(int i=0;i<101;i++)
      for(int j=0;j<101;j++)
	for(int k=0;k<2;k++)
	  dp[i][j][k]="-1";
    string a=dfs(zero,one,1);
    for(int i=0;i<a.size();i++)
      in[cnt++]=a[i]-'0';
  }
  else{
    if(zero%2==1){
      int tmp=in[0];
      for(int i=0;i<cnt-1;i++)in[i]=in[i+1];
      in[cnt-1]=tmp;
      // 1が無いので、適当なやつをまぜて1をつくる
      for(int i=0;i<101;i++)
	for(int j=0;j<101;j++)
	  for(int k=0;k<2;k++)
	    dp[i][j][k]="-1";
      string a=dfs(zero,1,1);
      cnt--;
      if(cnt!=1&&in[cnt-1]==3&&in[cnt-2]==2)
	swap(in[cnt-1],in[cnt-2]);
      for(int i=0;i<a.size();i++){
	if(a[i]-'0'==1)in[cnt++]=tmp;
	in[cnt++]=0;
      }
    }
    else{
      if(cnt!=1&&in[cnt-1]==3&&in[cnt-2]==2)
	swap(in[cnt-1],in[cnt-2]);
      for(int i=0;i<zero;i++)in[cnt++]=0;
    }
  }
  
  for(int i=0;i<N;i++)
    cout<<in[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = []

for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == 'S':
		a.append(y)
	elif x == 'H':
		a.append(y+13)
	elif x == 'C':
		a.append(y+26)
	elif x == 'D':
		a.append(y+39)

for i in range(1, 53):
	if not(i in a):
		if i <= 13:
			print('S {}'.format(i))
		elif i <= 26:
			print('H {}'.format(i-13))
		elif i <= 39:
			print('C {}'.format(i-26))
		elif i <= 52:
			print('D {}'.format(i-39))


Measured memory_bytes: 5596
div = 1000000007

n, m, *b = map(int, open(0).read().split())
a = set(b)
 
f = [0] * (n + 1)
f[0] = 1

if 1 not in a:
    f[1] = 1
 
for i in range(2, n + 1):
    if i in a:
        continue
    f[i] = (f[i - 1] + f[i - 2]) % div
 
print(f[-1])


Measured memory_bytes: 59952
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun solve(): Int {
    var res = 0
    return res
}


fun main(args: Array<String>) {
    val N = readInt()
    val A = readLongArray()

    if (A.contains(0L)) {
        println(0)
        return
    }

    var ans = 1.toBigInteger()
    for (i in 0 until N) {
        ans *= A[i].toBigInteger()
        if (ans > 1000000.toBigInteger() * 1000000.toBigInteger() * 1000000.toBigInteger()) {
            ans = (-1).toBigInteger()
            break
        }

    }

    println(ans)
}


Measured memory_bytes: 64348
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;

int main()
{
  string w;
  string t;
  int i;
  int count=0;
  
  cin >> w;
  
  for(i=0;w[i]!='\0';i++)
  {
    w[i]=static_cast<char>(toupper(w[i]));
  }
  
  while(cin >> t)
  {
    //cin >> t;
    if(t=="END_OF_TEXT")
      break;
      
    for(i=0;t[i]!='\0';i++)
    {
       t[i]=static_cast<char>(toupper(t[i]));
    }
    
    if(t==w)
    {
      count++;
    }
    
  }
  
  cout << count <<"\n";
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
const int N = 18;

int n;
int best[1<<N][3], ans[1<<N];

void insert(int mask, int val){
    auto a = best[mask];
    a[2] = val;
    if (a[2] > a[1]) swap(a[2], a[1]);
    if (a[1] > a[0]) swap(a[1], a[0]);
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    forn(i,1<<n) {
        int x; cin >> x;
        insert(i,x);
    }
    forn(i,n) {
        forn(mask, 1<<n) if ((mask>>i)&1) {
            int nmask = mask - (1<<i);
            forn(j,2) insert(mask, best[nmask][j]);
        }
    }
    forsn(i,1,1<<n) {
        ans[i] = max(ans[i], best[i][0] + best[i][1]);
        ans[i+1] = max(ans[i+1], ans[i]);
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 7764
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int t;
    cin>>t;
    if(!t)break;
    vector<int> c(t);
    REP(i,t)cin>>c[i];
    int n;
    cin>>n;
    vector<int> d(n),m(n);
    REP(i,n)cin>>d[i]>>m[i];
    vector<int> itv(100,100);
    REP(i,n){
      --d[i];
      itv[d[i]]=min(itv[d[i]], m[i]);
    }
    vector<vector<int>> dp(102,vector<int>(t,10000));
    dp[0][t-1] = 0;
    REP(i,100){
      REP(j,t) {
        dp[i+1][0] = min(dp[i+1][0], dp[i][j] + 1);
      }
      REP(j,t) {
        if (itv[i] >= c[j])
          dp[i+1][j] = min(dp[i+1][j], dp[i][(j+t-1)%t]);
      }
    }
    cout<<*min_element(begin(dp[100]),end(dp[100]))<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>

using namespace std;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef long long ll;
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define NEXTP(c) next_permutation(ALL(c))
#define SUM(c) accumulate(ALL(c),0)
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define ANS(x) cout << (x) << endl;
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF 1000000000 // 10^9
const double EPS = 1e-10;

int main(){
    int K,T;
    cin >> K >> T;
    int a[T];
    int s=0, m=0;
    REP(i, T){
        cin>>a[i];
        s += a[i];
        m = max(m, a[i]);
    }

    cout << ((s-m<m-1)? m-1-(s-m) : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int ctoi(char a)
{
	if (a == '0')
		return 0;
	else if (a == '1')
		return 1;
	else if (a == '2')
		return 2;
	else if (a == '3')
		return 3;
	else if (a == '4')
		return 4;
	else if (a == '5')
		return 5;
	else if (a == '6')
		return 6;
	else if (a == '7')
		return 7;
	else if (a == '8')
		return 8;
	else if (a == '9')
		return 9;
}

int main()
{
	char N[11];
	scanf("%s", N);

	int i, S;
	for (i = 0, S = 0; i < strlen(N); i++)
		S += ctoi(N[i]);

	if (atoi(N) % S == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int n;
ll x = 1, y = 1, a, b, k;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b; k = 1;
		if (a < x) k = max(k, (x + a - 1) / a);
		if (b < y) k = max(k, (y + b - 1) / b);
		x = a * k; y = b * k;
	} cout << x + y << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
from statistics import mean, median,variance,stdev

N = int(input())
XY = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append([x, y])

XY_perm = list(itertools.permutations(XY))

L = []
set_length = len(XY_perm[0])

for i in range(len(XY_perm)):
    L_set =[]
    for j in range(set_length-1):
        st_x = XY_perm[i][j][0]
        st_y = XY_perm[i][j][1]

        ed_x = XY_perm[i][j+1][0]
        ed_y = XY_perm[i][j+1][1]

        length = ((ed_x-st_x)**2 + (ed_y-st_y)**2)**0.5
        L_set.append(length)
    L.append(sum(L_set))

print(mean(L))



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

int main() {
  int h,w;
  string sub;
  cin >> h >> w;
  vector<string> a(h+2,"#");
  for(int i = 1; i < w + 2; i++){
    a.at(0) += "#";
  }
  for(int i = 1; i < h + 1; i++){
    cin >> sub;
    a.at(i) += sub + "#";
  }
  a.at(h + 1) = a.at(0);
  for(int i = 0; i < h + 2; i++){
    cout << a.at(i) << endl;
  }
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<string> v(n);
    for(auto &x : v){
        cin >> x;
        sort(ALL(x));
    }
    debug(v);
    map<string, ll> mp;
    for(auto &x : v){
        mp[x]++;
    }
    ll ans = 0;
    for(auto &x : mp){
        ans += (x.S * (x.S - 1) / 2);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 16624