akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import numpy as np

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


n = I()
result = factorization(n)

a = np.arange(1, 10)
a = np.cumsum(a)

if n == 1:
    print("0")
    exit()
else:
    ans = 0
    for l in result:
        ans += len(a[a <= l[1]])

print(ans)


Measured memory_bytes: 27300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Graph I - Connected Components
 */
public class Main {

	static final int NIL = -1;

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

		Main main = new Main();

		line = br.readLine();

		int n, m;
		n = parseInt(line.substring(0, line.indexOf(' ')));
		m = parseInt(line.substring(line.indexOf(' ') + 1));

		Vertex[] G = new Vertex[n];
		int color = 0;

		for (int i = 0; i < n; i++) {
			G[i] = main.new Vertex();
		}

		for (int i = 0; i < m; i++) {
			line = br.readLine();
			int s, t;
			s = parseInt(line.substring(0, line.indexOf(' ')));
			t = parseInt(line.substring(line.indexOf(' ') + 1));
			G[s].es.add(G[t]);
			G[t].es.add(G[s]);
		}

		for (int i = 0; i < n; i++) {
			if (G[i].color == NIL) {
				G[i].color = color++;
				Deque<Vertex> stack = new ArrayDeque<>();
				stack.push(G[i]);
				while (!stack.isEmpty()) {
					Vertex s = stack.pop();
					for (Vertex t : s.es) {
						if (t.color == NIL) {
							t.color = G[i].color;
							stack.push(t);
						}
					}
				}
			}
		}


		int q = parseInt(br.readLine());

		for (int i = 0; i < q; i++) {
			line = br.readLine();
			int s, t;
			s = parseInt(line.substring(0, line.indexOf(' ')));
			t = parseInt(line.substring(line.indexOf(' ') + 1));
			if (G[s].color == G[t].color) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}

	class Vertex {
		int color = NIL;
		List<Vertex> es = new ArrayList<>();
	}
}

Measured memory_bytes: 78192
n = input()
x = map(int, raw_input().split())

MOD = 10**9+7

j = 1
ans = 1
count = 0
for i in xrange(len(x)):
    if(x[i] >= 2*j-1):
        j += 1
        continue
    else:
        ans = ans*j%MOD
        count += 1

for i in xrange(len(x)-count):
    ans = ans*(i+1)%MOD

print ans

Measured memory_bytes: 11308
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, C;
	cin >> N >> C;
	vector<vector<int> > D(C, vector<int>(C));
	for (int i = 0; i < C; ++i) {
		for (int j = 0; j < C; ++j) {
			cin >> D[i][j];
		}
	}
	vector<vector<int> > A(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> A[i][j]; --A[i][j];
		}
	}
	vector<vector<int> > val(3, vector<int>(C));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			for (int k = 0; k < C; ++k) {
				val[(i + j) % 3][k] += D[A[i][j]][k];
			}
		}
	}
	int ans = inf;
	for (int i = 0; i < C; ++i) {
		for (int j = 0; j < C; ++j) {
			for (int k = 0; k < C; ++k) {
				if (i != j && j != k && k != i) {
					ans = min(ans, val[0][i] + val[1][j] + val[2][k]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] ss = Console.ReadLine().Split(' ');
      int H = int.Parse(ss[0]);
      int W = int.Parse(ss[1]);
      char[][] map = new char[H][];
      for(int i = 0; i < H; i++)
      {
        map[i] = Console.ReadLine().ToCharArray();
      }

      int[] dx = new int[] { 0, -1, 1, 0 };
      int[] dy = new int[] { -1, 0, 0, 1 };

      for(int y = 0; y < H; y++)
        for(int x = 0;x < W; x++)
        {
          if(map[y][x] != '#')
            continue;

          bool ok = false;
          for(int i = 0; i < dx.Length; i++)
          {
            int cy = y + dy[i];
            int cx = x + dx[i];
            if(cy < 0 || map.Length <= cy)
              continue;
            if(cx < 0 || map[cy].Length <= cx)
              continue;
            if(map[cy][cx] == '#')
            {
              ok = true;
              break;
            }
          }
          if(!ok)
          {
            Console.WriteLine("No");
            Console.ReadLine();
            return;
          }
        }

      Console.WriteLine("Yes");
      Console.ReadLine();
    }

  }
}

Measured memory_bytes: 27532
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int s,w;cin >> s >> w;
  if(w>=s) cout << "unsafe\n";
  else cout << "safe\n"; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3868
#include <iostream>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  // O(nm) < O(1000000)
  int ans = s.size();
  for (int i = 0; i < s.size() - t.size() + 1; ++i) {
    int cnt = 0;
    for (int j = 0; j < t.size(); ++j) {
      if (s[i + j] != t[j]) {
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(c.begin(),c.end()),c.end())
#define pb push_back
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		int y,m,d;
		cin>>y>>m>>d;
		int sum=0;
		for(int i=y+1;i<1000;i++){
			sum+=10*20;
			if(i%3!=0){
				sum-=5;
			}
		}
		for(int i=m+1;i<=10;i++){
			if(y%3!=0&&i%2==0){
				sum+=19;
			}else{
				sum+=20;
			}
		}
		int lim=20;
		if(y%3!=0&&m%2==0)
			lim=19;
		sum+=lim-d;
		cout<<sum+1<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
  	int N,L;cin>>N>>L;
  	int dif = INT_MAX;
  	int inde;
  	for(int i=1; i<N+1; i++){
    	int tmp = abs(L + i - 1);
      	if(dif > tmp){
          	dif = tmp;
          	inde = i;
        }
    }
  	
  	cout << N*L + (N*(N+1))/2 - N - L - inde + 1 << endl; 
	return 0;
}

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

int main(){
  int n; cin>>n;
  vector<long long> a(n+1),  b(n);
  for(int i=0; i<n+1; ++i)cin>>a[i];
  for(int i=0; i<n; ++i)cin>>b[i];
  long long ans=0LL;

  for(int i=0; i<n; ++i){
    if(a[i]>=b[i])ans+=b[i];
    else{
      ans+=a[i];
      b[i]-=a[i];
      if(a[i+1]>=b[i]){
        a[i+1]-=b[i];
        ans+=b[i];
      }else{
        ans+=a[i+1];
        a[i+1]=0;
      }
    }
  }

  cout<<ans<<endl;

  
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int n;
  cin >> n;
  int x[n];
  int y[n];
  rep(i,n){
    cin >> x[i];
    y[i] = x[i];
  }
  
  sort(y, y+n);
  if (y[n/2 - 1] == y[n/2]){
    rep(j,n){
      cout << y[n/2 -1] << endl;
    }
  }else{
    rep(j,n){
      if (x[j] <= y[n/2 - 1]){
        cout << y[n/2] << endl;
      }else{
        cout << y[n/2 - 1] << endl;
      }
    }
  }
  
  return 0;
}

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

int main() {
  string N;
  cin >> N;

  bool ans = false;
  int index = -1;
  for(int i = 0; i < N.size(); i++){
    if(N.at(i) == 'C') index = i;
  }
  
  if( index == -1 ){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = index; i < N.size(); i++){
    if(N.at(i) == 'F') ans = true;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import sys
import math
def simeq(a,b,c,d,e,f):
    return ((c*e-b*f)/(a*e-b*d)+0,((a*f-c*d)/(a*e-b*d))+0)

if __name__ == '__main__':
    for line in sys.stdin:
        (a,b,c,d,e,f) = map(float,line.split())
        (x,y) = simeq(a,b,c,d,e,f)
        print("{:.3f} {:.3f}".format(round(x,3),round(y,3)))

Measured memory_bytes: 7492
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class v:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    H, W = read_values()
    F = ["." * (W + 2)] + ["." + input() + "." for _ in range(H)] + ["." * (W + 2)]
    dp = [[10 ** 10 for _ in range(W + 2)] for __ in range(H + 2)]
    dp[1][0] = 0
    dp[0][1] = 0
    for h in range(1, H + 1):
        for w in range(1, W + 1):
            if F[h][w] == ".":
                dp[h][w] = min(dp[h - 1][w], dp[h][w - 1])
            else:
                hr = 0 if F[h - 1][w] == "#" else 1
                wr = 0 if F[h][w - 1] == "#" else 1
                dp[h][w] = min(dp[h - 1][w] + hr, dp[h][w - 1] + wr)
    print(dp[H][W])


if __name__ == "__main__":
    main()

Measured memory_bytes: 41136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>

using namespace std;

const int maxn = 3e5+1e2;

int s[maxn],vis[maxn];
int n,a,b,x,y;

int main()
{
  scanf("%d%d%d",&n,&a,&b);
  if ((long long)a*b<(long long)n){
  	cout<<-1;
  	return 0;
  }
  if (a+b>n+1)
  {
  	 cout<<-1;
  	 return 0;
  }
  int tmp=0;
  for (int i=n-a+1;i<=n;i++)
    s[++tmp]=i,vis[i]=1;
  if (tmp!=n)
  {
    for (int i=b-1;i>=1;i--)
    {
    	s[++tmp]=i;
    	vis[i]=1;
    	if (tmp==n) break;
	}
    for (int i=b;i<=n-a+1;i+=(b-1))
    {
    	for (int j=i+b-2;j>=i;j--)
    	{
    	  if (!vis[j]&&j<=n)
     	    s[++tmp]=j,vis[j]=1;
    	  if (tmp==n) break;
        }
	}
  }
  for (int i=1;i<=n;i++)
    printf("%d ",s[i]);
  return 0;
}


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

int main() {
  int n , k;
  int ans = 0;
  cin >> n >> k;
  vector<int> vec(n);
 
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
for(int i = 0; i < k; i++){
    ans =ans +vec.at(i);
}
cout << ans << endl;
} 

Measured memory_bytes: 3596
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		System.out.println(Math.min(sc.nextInt(), sc.nextInt())+Math.min(sc.nextInt(), sc.nextInt()));
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35600
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>

using namespace std;


int main(){

int n,x;
cin >> n >> x;
int minm = 1000;
int l = 0;
int summ = 0;

for (int i = 0; i < n; i++){
    cin >> l;
    summ += l;
    minm = min(minm, l);
}

x -= summ;
int p = n;

int k;
p += x/minm;

cout << p << endl;


return 0;
}


Measured memory_bytes: 256
import java.io.*;
  
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  
        String sentence;
        int[] abc = new int[26];
  
        while ((sentence = input.readLine()) != null) {
            for (int i = 0; i < sentence.length(); i++) {
                char c = sentence.charAt(i);
                     c = Character.toLowerCase(c);
                char cc = 'a';
                for (int j = 0; j < abc.length; j++) {
                    if (cc == c)
                        abc[j]++;
                    cc++;
                }
            }
        }
  
        char cc = 'a';
        for (int i = 0; i < abc.length; i++) {
            System.out.println(cc + " : " + abc[i]);
            cc++;
        }
    }
  
}

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

#define pb push_back
#define mp make_pair
typedef long long int ll;

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

	if (temp >= 30)
		cout << "Yes";
	else
		cout << "No";
}



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

#ifndef ONLINE_JUDGE
	freopen("1input.txt", "r", stdin);
	freopen("1output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 3608
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		final String S = sc.next();
		final boolean[] T = new boolean[N];
		for(int i=0;i<S.length();i++) {
			T[i] = S.charAt(i)=='L';
		}

		boolean base = T[0];
		int w = 1;
		for(int k=0;k<K;k++) {
			int l=w;
			for(;l<N;l++) {
				if(T[l]!=base) {
					break;
				}
			}
			if(l==N) {
				break;
			}
			int r=l+1;
			for(;r<N;r++) {
				if(T[r]==base) {
					break;
				}
			}
			r--;
			// 180度回転
			while(l<r) {
				boolean t = T[r];
				T[r] = !T[l];
				T[l] = !t;
				l++;
				r--;
			}
			if(l==r) {
				T[l]=!T[r];
			}
			w = r+1;
		}

		int score = 0;
		for(int i=0;i<N-1;i++) {
			if(T[i]==T[i+1]) {
				score++;
			}
		}

		out.println(score);
	}

}


Measured memory_bytes: 26544
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[100010],to[100010],co[100010],nt[100010],it[100010],l[100010];
void mklsb(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];      
    co[ta[b[i]]=i+e]=0;
  }
}
int MF(int e,int s,int t,int min){
  if(s==t)return min;
  int i,r;
  for(;it[s]+1;it[s]=nt[it[s]]){
    if(co[it[s]]==0||l[s]>=l[to[it[s]]])continue;
    r=MF(e,to[it[s]],t,MIN(min,co[it[s]]));
    co[it[s]]-=r;
    co[(it[s]+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
int maxf(int v,int e,int s,int g){
  int i,a=0,q[100010],t,r,c=3;
  while(1){
    for(i=t=0;i<v;i++)l[i]=-1;
    l[q[0]=s]=0;
    for(r=1;r-t;t++){
      for(i=ta[q[t]];i+1;i=nt[i]){
	if(co[i]&&l[to[i]]==-1)l[q[r++]=to[i]]=l[q[t]]+1;
      }
    }
    if(l[g]<0)return a;
    for(i=0;i<v;i++)it[i]=ta[i];
    while(r=MF(e,s,g,1e9))a+=r;
  }
}
int main(){
  int n,m,i,a[100010],b[100010],c[1000010],m1,m2;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  mklsb(n,m,a,b,c);//prls(n);
  m1=maxf (n,m,0,n-1);
  printf("%d\n",m1);
  return 0;
}
  

Measured memory_bytes: 2716
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        vector <int> a(3);
        cin >> a[0] >> a[1] >> a[2];
        sort(a.begin(),a.end());

        cout << a[2]-a[0] << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>

using namespace std;

class Solver {
public:
	static void solve() {
		int w, h;
		cin >> w >> h;
		vector<int> res;
		while (w > 0 && h > 0) {
			vector<vector<bool>> grid(h, vector<bool>(w, true));
			tuple<int, int> start;
			for (int i = 0; i < h; i++) {
				string s;
				cin >> s;
				for (int j = 0; j < w; j++) {
					if (s[j] == '#')grid[i][j] = false;
					if (s[j] == '@')start = make_tuple(i, j);
				}
			}

			queue<tuple<int, int>> que;
			que.push(start);
			int cnt = 0;
			
			while (!que.empty()) {
				auto pos = que.front();
				que.pop();
				int y = get<0>(pos);
				int x = get<1>(pos);
				if (y < 0 || h <= y || x < 0 || w <= x || !grid[y][x])continue;

				grid[y][x] = false;
				cnt++;
				que.push(make_tuple(y - 1, x));
				que.push(make_tuple(y + 1, x));
				que.push(make_tuple(y, x - 1));
				que.push(make_tuple(y, x + 1));
			}
			res.emplace_back(cnt);

			cin >> w >> h;
		}

		for (int i = 0; i < res.size(); i++) {
			cout << res[i] << endl;
		}
	}
};

int main() {
	Solver::solve();
}


Measured memory_bytes: 3164
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
int mod=1e9+7;
const int M=10000005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
 main()

{
    fast
    int k;
    cin>>k;
    int ten=1;
    int sum=0;
    mod=k;
    f(i,1,M)
    {
       sum=ad(sum,ten);
       int val=gun(sum,7LL);
       //cout<<sum<<" "<<ten<<" "<<k<<endl;
       if(val==0)
       {
           cout<<i<<endl;
           return 0;
       }
       ten=gun(ten,10LL);
    }
    cout<<"-1"<<endl;
    return 0;

}





































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

int main(){
  unsigned long long n,k;
  cin >> n >> k;
  vector<vector<int>> a(n,vector<int>(64));
  for(int i = 0; n > i; i++){
    cin >> a[i][0]; 
    a[i][0]--;
  }
  
  for(int i = 1; 64 > i; i++){
  	for(int j = 0; n > j; j++){
      a[j][i] = a[a[j][i-1]][i-1];
    }
  }
  
  int cur = 0;
  for(int i = 0; 64 > i; i++){
    if((k >> i) & 1){
       cur = a[cur][i];
    }
  }
  cout << cur + 1<< endl;
  return 0;
}

Measured memory_bytes: 61072
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long  N,countm=0,counta=0,countr=0,countc=0,counth=0;
    long long ans=0;
    
    string people;


    cin>>N;

    for(int i=0;i<N;i++){
        cin>> people;
        if(people[0]=='M')countm++;
        if(people[0]=='A')counta++;
        if(people[0]=='R')countr++;
        if(people[0]=='C')countc++;
        if(people[0]=='H')counth++;
    }


    ans=countm*counta*countr+countm*counta*countc+countm*counta*counth+countm*countr*countc+countm*countr*counth+countm*countc*counth+counta*countr*countc+counta*countr*counth+counta*countc*counth+countr*countc*counth;

    cout<<ans<<endl;

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// http://codeforces.com/blog/entry/18051
struct Segment_tree{
	using T=ll;

    int n;
    vector<T> data;
    const T out=0LL;

    Segment_tree(int n):n(n){
    	data.assign(2*n,out);
    }

	void update(int l, int r, T x) {
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l&1) data[l++]+= x;
			if (r&1) data[--r]+= x;
		}
	}

	T at(int p){
		T ret = 0;
		for (p += n; p > 0; p >>= 1) ret += data[p];
		return ret;
	}
};

int main(void){
	int n,q;
	cin >> n >> q;

	Segment_tree raq(n);

	rep(loop,q){
		int com,x,y,z;
		cin >> com;
		if(com){
			cin >> x;
			cout << raq.at(x-1) << endl;
		}else{
			cin >> x >> y >> z;
			raq.update(x-1,y,z);
		}
	}
	return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x) make_pair(x)

using namespace std;
using ll=long long;


int main() {
  ll n;
  cin >> n;
  ll s= (ll)pow(n,0.5);
  while((n%s) && s >0){
    s--;
  }

  ll t = n/s;

  cout << (s+t)-2;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {

            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int d, r;
            double f;

            d = a / b;
            r = a % b;
            f = (double)a / (double)b;

            Console.WriteLine(d + " " + r + " " + f.ToString("f8"));
        }
    }
}

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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string S, T;
    cin >> S >> T;

    if(T.size() - S.size() == 1 && equal(begin(S), end(S), begin(T))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    auto lenS = S.length();
    auto lenT = T.length();

    auto count = S.length();
    for (auto i = 0; i <= lenS - lenT; ++i) {
        auto modify = 0;
        for (auto j = 0; j < lenT; ++j) {
            if (S[i+j] != T[j]) {
                ++modify;
            }
        }
        if (modify < count) {
            count = modify;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int N, H, Cx, Cy, h_tmp;
	cin >> N;

	vector<int> x(N);
	vector<int> y(N);
	vector<int> h(N);
	for(int i=0; i<N; i++){
		cin >> x[i];
		cin >> y[i];
		cin >> h[i];
	}
	for(int j=0; j<=100; j++){
		for(int i=0; i<=100; i++){
			for(int k=0; k<N; k++){
				if(h[k]==0) continue;
				H = h[k] + abs(i-x[k]) + abs(j-y[k]);
			}
			for(int k=0; k<N; k++){
				h_tmp = max(H - abs(x[k]-i) - abs(y[k]-j), 0);
				if(h_tmp != h[k]) break;
				else if(k==N-1){
					cout << i << " " << j << " " << H << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

/*
               |
			   |
			   |
			   |
			   |
			   |
---------------+---------------
               |
			   |
			   |
			   |
			   |
			   |
*/

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FDistinctNumbers {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N;
    vector<int> cnt, sum;

    bool check(int k, int n) {
        if (k * n > N) return false;

        int idx = lower_bound(cnt.begin(), cnt.end(), n) - cnt.begin();

        int num = ((int)cnt.size() - idx) * n;
        num += sum[idx];
        return num >= k * n;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N;
        vector<int> A(N);
        map<int, int> mp;
        REP(i, N) {
            cin >> A[i];
            mp[A[i]]++;
        }
        for (auto kv : mp) {
            cnt.push_back(kv.second);
        }
        sort(cnt.begin(), cnt.end());
        sum = vector<int>(cnt.size() + 1, 0);
        REP(i, cnt.size()) {
            sum[i+1] = sum[i] + cnt[i];
        }

        FOR(k, 1, N) {
            int l = 0;
            int r = N + 1;
            while (r - l > 1) {
                int m = (r + l) / 2;
                if (check(k, m)) {
                    l = m;
                } else {
                    r = m;
                }
            }
            cout << l << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FDistinctNumbers solver;
    solver.solve(in, out);
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;


int main(){

    int k;
    cin>>k;
    long long x;
    cin>>x;
    if(500*k>=x){
        cout<<"Yes"<<endl;
    } 
    else{
        cout<<"No"<<endl;
    }
return 0;

}
/*


*/


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    private static int n;
    private static boolean[] visited;
    private static boolean[][] graph;
    public static void main(String[] args) {
        n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[m], b = new int[m];
        graph = new boolean[n][n];
        visited = new boolean[n];
        for (int i = 0; i < m; i++)
            graph[a[i] = scanner.nextInt() - 1][b[i] = scanner.nextInt() - 1] = graph[b[i]][a[i]] = true;
        int ans = 0;
        for (int i = 0; i < m; i++) {
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
            Arrays.fill(visited, false);
            dfs(0);
            if (IntStream.range(0, n).anyMatch(j -> !visited[j]))
                ans++;
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        System.out.println(ans);
    }

    private static void dfs(int v) {
        visited[v] = true;
        for (int v2 = 0; v2 < n; v2++)
            if (graph[v][v2] && !visited[v2])
                dfs(v2);
    }
}

Measured memory_bytes: 28368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int count = 0;
		for (int i = 0; i < s.length/2; i++) {
			if(s[i] != s[s.length-1-i])count++;
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == 'B') {
        if((i < (s.length() - 1)) && (s.charAt(i + 1) == 'C')) {
          list.add(3);
          i++;
        } else {
          list.add(1);
        }
      } else {
        if(s.charAt(i) == 'A') {
          list.add(0);
        } else {
          list.add(2);
        }
      }
    }
    long ans = 0;
    long p = 0;
    for(int i = 0; i < list.size(); i++) {
      if(list.get(i) == 3) {
        ans += p;
      } else if(list.get(i) == 0) {
        p++;
      } else {
        p = 0;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 30612
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int gcd (int a, int b) {
  int d=a;
  if (b!=0) {
    d=gcd(b, a%b);
  }
  return d;
}

int lcm (int a, int b) {
  return a*b/gcd(a,b);
}

int main() {
  int N;
  cin >> N;
  int s2=0, s4=0, a;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (a%4==0) {
      s4++;
    }
    else if (a%2==0) {
      s2++;
    }
  }
  if (s4>=N/2) {
    cout << "Yes" << endl;
  }
  else if ((N-s4*2)<=s2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
 

Measured memory_bytes: 3560
#include <iostream>
#define MAX 10000000

using namespace std;

bool prime[MAX];

void isPrime(void){

  fill( prime , prime + MAX , true );
  prime[0] = prime[1] = false;

  for( int i = 2 ; i*i < MAX ; i++ )
    if( prime[i] ){
      for( int j = 2*i ; j < MAX ; j += i ){
	prime[j] = false;
      }
    }

}

int main(void){

  isPrime();

  int n;
  while( cin >> n , n ){

    for( int i = n ; i >= 0 ; i-- ){
      if( prime[i] && prime[i - 2] && prime[i - 6] && prime[i - 8] ){
	cout << i << endl;
	break;
      }
    }
 
  }
  return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  string S[H+2];
  
  for(int i=1;i<H+1;i++){
    cin >> S[i];
    S[i]=' '+S[i]+' ';
  }
  for(int i=0;i<W+2;i++){
    S[0]+=' ';
    S[H+1]+=' ';
  }
  
  for(int k=1;k<H+1;k++){
    for(int i=1;i<W+1;i++){
      int j=0;
      if(S[k].at(i)=='.'){
        if(S[k-1].at(i)=='#')
          j++;
        if(S[k].at(i-1)=='#')
          j++;
        if(S[k+1].at(i)=='#')
          j++;
        if(S[k].at(i+1)=='#')
          j++;
        if(S[k-1].at(i-1)=='#')
          j++;
        if(S[k+1].at(i+1)=='#')
          j++;
        if(S[k-1].at(i+1)=='#')
          j++;
        if(S[k+1].at(i-1)=='#')
          j++;
        S[k].at(i)='0'+j;
      }
    }
  }
  for(int i=1;i<H+1;i++)
    cout << S[i] <<endl;
}

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

n = int(S**0.5)

if (n+1)**2 <= S:
  n = n+1

if S <= (n-1)**2:
  n = n-1

if S == n**2:
  print(*[0,0,0,n,n,0])
elif S <= n*(n+1):
  x = n*(n+1)-S
  print(*[0,n+1-x,n,n+1,n-1,0])
else: #S < (n+1)**2:
  x = (n+1)**2 -S
  print(*[0,n+1-x,n+1,n+1,n,0])

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

vector<int> G[2005];
vector<bool> koma;
vector<ll> maxG,minG,numG;
vector<bool> checked;
string s;

void calcCost(int node){
	checked[node] = true;

	vector<pair<ll,ll>> memo;//min,max
	if(koma[node]){
		numG[node] += 1;
	}
	//cout<<"bbb"<<endl;
	rep(i, G[node].size()){
		int next = G[node][i];
		if(checked[next]) continue;
		checked[next] = true;
		calcCost(next);
		maxG[node] += maxG[next] + numG[next];
		numG[node] += numG[next];
		memo.push_back(pair<ll,ll>{minG[next] + numG[next], maxG[next] + numG[next]});
	}
	//cout<<"ccc"<<endl;
	if(memo.size()==0){
		return;
	}
	sort(all(memo));
	reverse(all(memo));//minG*numGの降順
	if(memo.size() == 1){
		minG[node] += memo[0].first;
	}else if(memo.size() >= 2){
		ll sum = 0;
		reps(i,memo.size()-1){
			sum += memo[i].second;
		}
		minG[node] += max(memo[0].first - sum, (sum + memo[0].second)%2);
	}

}

int main(void){
	int n;
	
	cin>>n;
	cin>>s;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,s.size()){
		maxG.push_back(0);
		minG.push_back(0);
		numG.push_back(0);
		checked.push_back(false);
		koma.push_back(s[i]=='1');
	}

	ll ans = LINF;
	rep(node,n){
		rep(i,n){
			checked[i] = false;
			maxG[i] = 0;
			minG[i] = 0;
			numG[i] = 0;
		}

		/*calcCost(0);
		rep(i,n){
			cout<<i<<" "<<maxG[i]<<" "<<minG[i]<<" "<<numG[i]<<endl;
		}
		break;*/

		//cout<<"hoge"<<endl;
		calcCost(node);
		if(minG[node] == 0){
			//cout<<node<<" "<<maxG[node]<<endl;
			chmin(ans, maxG[node]/2);
		}
		//cout<<"aa"<<endl;
	}
	cout<<(ans==LINF?-1:ans)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<int> a(n, 0), b(n, 0), c(n, 0);
    REP(i, n) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(n+1, vector<int>(3, 0));
    
    REP(i, n) {
        dp[i+1][0] = max(dp[i][1] + b[i], dp[i][2] + c[i]);
        dp[i+1][1] = max(dp[i][2] + c[i], dp[i][0] + a[i]);
        dp[i+1][2] = max(dp[i][0] + a[i], dp[i][1] + b[i]);
    }

    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;

}

Measured memory_bytes: 6912
#include <stdio.h>

int main() {
     char clima[10];
     scanf("%s", clima);
     if (clima[0] == 'S') {
          printf("Cloudy\n");
     }
     if (clima[0] == 'C') {
          printf("Rainy\n");
     }
     if (clima[0] == 'R') {
          printf("Sunny\n");
     }
     return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
  int k;
  cin >> k;
  cout << k/2 * (k - k/2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC164A()
{
	int S, W;
	cin >> S >> W;
	if (S > W)
	{
		cout << "safe" << endl;
	}
	else
	{
		cout << "unsafe" << endl;
	}
}
int main()
{
	ABC164A();
	return 0;
}


Measured memory_bytes: 3656
<?php
$a = trim(fgets(STDIN));
$a = explode(' ', $a);

if ($a[0] == $a[1]) {
  echo 'a == b';
} else if($a[0] < $a[1]) {
  echo 'a < b';
} else {
  echo 'a > b';
}
echo PHP_EOL;

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

int e[3][3], mk[3][3];

int main() {
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			scanf("%d", &e[i][j]);

	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);

		for(int a = 0; a < 3; a++)
			for(int b = 0; b < 3; b++)
				if(e[a][b] == x)
					mk[a][b]++;
	}

	for(int i = 0; i < 3; i++) {
		int sf = 0, sc = 0;
		for(int j = 0; j < 3; j++) {
			sf += mk[i][j];
			sc += mk[j][i];
		}

		if(sf == 3 || sc == 3) {
			printf("Yes\n");
			return 0;
		}
	}

	if((mk[0][0] && mk[1][1] && mk[2][2]) ||
		(mk[0][2] && mk[1][1] && mk[2][0]))
			printf("Yes\n");

	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
    for (unsigned i = 0; i < v.size(); i++)
        in >> v[i];
    return in;
}


lo gcd(lo a, lo b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

void solve(){
	lo k;
	cin>>k;
	lo sum =0;
	REPV(i,1,k+1){
		REPV(j,1,k+1){
			REPV(l,1,k+1){
				sum+=gcd(i,gcd(j,l));	
			}
		}
	}

	cout<<sum;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(20);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <bitset>
#include <climits>
#include <algorithm>
using namespace std;

#define N_MAX 12
#define M_MAX 12

int N, M, X;
int C[N_MAX];
int A[N_MAX][M_MAX];

void input(){

    cin >> N >> M >> X;
    for (int i=0;i<N;i++){
        cin >> C[i];
        for (int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
}

void solve(){
    // i番目の本(値段C[i])を読むと、j番目のアルゴリズムの理解度がA[i][j]だけ上がる。
    // 全てのアルゴリズムの理解度をX以上にすることは可能か？-->全部買った時が最大
    // ビット全探索ができるよ。
    // 選択したiについて、sigma_i(C[i])をとる。sigma_i(A[i][j])の最小値をとる。最小値がX以上ならオッケー
    // sigma_i(C[i])の最小値を出力する。
    int ans = INT_MAX;

    for (int k = 0; k < (1 << N); k++){ //本の選び方パターン
        int sum_C = 0;
        int sum_A[M_MAX] = {}; //これで0初期化
        bitset<N_MAX> bit_counter(k);

        for (int i = 0; i < N; i++){ //本の番号i
            if (bit_counter[i]){
                sum_C += C[i];
                for (int j=0;j<M;j++){ //アルゴリズム番号j
                    sum_A[j] += A[i][j];
                }
            }
        }
        // sum_Aの最小値がX以上ならば
        if (*min_element(sum_A, sum_A+M) >= X){
            //sum_Cが前の値と比べて小さければansに代入
            ans = min(ans,sum_C);
        }
    }
    if (ans == INT_MAX){
        ans = -1;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3196
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Number of Amidakuji
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 100;
const int MAX_W = 7;
const int WBIT = 1 << MAX_W;
const int MOD = 1000000007;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi wbs;
int dp[MAX_H + 1][MAX_W + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int h, w, k;
  scanf("%d%d%d", &h, &w, &k);
  w--, k--;
  int wbits = 1 << w;

  for (int bits = 0; bits < wbits; bits++) {
    bool ok = true;
    for (int i = 0, bi = 3; ok && i < w - 1; i++, bi <<= 1)
      ok = ((bits & bi) != bi);
    if (ok) wbs.push_back(bits);
  }
  //printf("%lu\n", wbs.size());

  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (vi::iterator vit = wbs.begin(); vit != wbs.end(); vit++) {
      int &bits = *vit;
      for (int j = 0; j <= w; j++) {
	if (j > 0 && (bits & (1 << (j - 1))))
	  addmod(dp[i + 1][j - 1], dp[i][j]);
	else if (j < w && (bits & (1 << j)))
	  addmod(dp[i + 1][j + 1], dp[i][j]);
	else
	  addmod(dp[i + 1][j], dp[i][j]);
      }
    }
  }

  printf("%d\n", dp[h][k]);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<chrono>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef vector<P> vP;
int main() {
	int n;
	cin >> n;
	int ans = n;
	ll sum = 0;
	vl A(n);
	for (int i = 0; i < n; i++)cin >> A[i];
	sort(A.begin(), A.end());
	for (int i = 0; i < n; i++) {
		ll a = A[i];
		if (sum * 2 < a) {
			ans = n - i;
		}
		sum +=a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	var total float64
	for i := 0; i < n; i++ {
		a := nextInt()
		total += 1 / float64(a)
	}

	ans := 1 / total
	fmt.Printf("%.6f\n", ans)
}


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

#define PI 3.141592653589


int main(){
	double r;
	double area, around;

	cin >> r;

	area = r * r * PI;

	around = 2 * r * PI;

	cout << fixed << setprecision(5) << area << " " << around << endl;

}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, c, k, t[100000];
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t, t+n);

	int pos = t[0], ans = 0, cnt = 1;
	for (int i = 1; i < n; i++) {
		if(pos+k < t[i] or cnt == c){
			ans++;
			cnt = 0;
			pos = t[i];
			// cout << "between " << i << " and " << i+1 << endl;
		}
		cnt++;
	}
	cout << ans + 1 << endl;
	return 0;
}

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

int main() {
	vector<int>a(3);
	for (int i = 0; i < 3; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	cout << a.at(0)*10+a.at(1)+a.at(2) << endl;
}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime 1000000007

using namespace std;

#define INF 1000000000

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	ll n;
	cin >> n;
	vl vet(n);
	for(auto&p: vet){
		cin >> p;
	}
	sort(vet.begin(), vet.end());
	ll sum = -vet.back();
	for(auto&p: vet){
		sum += p;
	}
	cerr << sum << " " << vet.back() << "\n";
	if(sum > vet.back()){
		cout << "Yes\n";
	} else{
		cout << "No\n";
	}

	return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
using ll  = long long;
using vi  = vector<int>;

vi l, p;

int f(int n, int x){ // 1 <= x
  if(n == 0) return 1;

  if(x == 1) return 0;
  else if(1 < x and x < l[n-1] + 2) return f(n-1, x-1);
  else if(x == l[n-1] + 2) return p[n-1] + 1;
  else if(l[n-1] + 2 < x and x < 2 * l[n-1] + 3) return p[n-1] + 1 + f(n-1, x - l[n-1] - 2);
  else if(x == 2 * l[n-1] + 3) return p[n];
  else{
    dump(n,x);
    assert(false);
  }
}

signed main(){
  int n,x; cin >> n >> x;

  l.resize(n+1); p.resize(n+1);
  l[0] = p[0] = 1;
  rep(i,n){
    l[i+1] = 2 * l[i] + 3;
    p[i+1] = 2 * p[i] + 1;
  }

  cout << f(n,x) << endl;
}

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

int gcd(int a, int b) {
  return b?gcd(b,a%b):a;
}

int main(){
  int n,ans=0;cin>>n;
  vector<int> a(n,0),b(0);
  REP(i,n) cin>>a.at(i);
  sort(a.begin(),a.end());
  b.push_back(a.at(0));
  b.push_back(a.at(1));
  REP(i,n-2) if(a.at(i)!=a.at(i+1)||a.at(i+1)!=a.at(i+2)) b.push_back(a.at(i+2));
  n=b.size();
  
  if(n==1) ans=b.at(0);
  else if(n==2) ans=max(b.at(0),b.at(1));
  else REP(i,n){
    int g=b.at(0);
    if(!i) g=b.at(1);
    REP(j,n){
      if((i==j)||(!i&&j==1)||(i&&!j)) continue;
      g=gcd(g,b.at(j));
      if(g<ans) break;
    }
    ans=max(g,ans);
  }
  cout<<ans;
}

Measured memory_bytes: 640