akhauriyash/Code-Regression huggingface dataset:
# BILLS = [10, 5, 1]
# BILL_TO_IDX = {
#   BILLS[0] => 0,
#   BILLS[1] => 1,
#   BILLS[2] => 2,
# }
BILLS = [10, 5]
BILL_TO_IDX = {
  BILLS[0] => 0,
  BILLS[1] => 1,
  # BILLS[2] => 2,
}

FAILED = [-1, -1, -1]

$dp_table = {}

def is_failure(bills)
  bills[0] == -1
end

def add_dp_table(rest_step, rest_money, used_bills)
  $dp_table[rest_step] ||= {}
  $dp_table[rest_step][rest_money] = used_bills
end

def is_failed_already(rest_step, rest_money)
  !$dp_table[rest_step].nil? &&
    !$dp_table[rest_step][rest_money].nil? &&
    !is_failure($dp_table[rest_step][rest_money])
end

# 戻り値: [int, int, int]
# true/false(成功/失敗), rest_money を0にするためにお札を何枚使ったか
# def dp(rest_step, rest_money)
#   # 探索打ち切り条件
#   return FAILED if rest_money < 0
#   return FAILED if rest_money / BILLS[0] > rest_step
#   return FAILED if is_failed_already(rest_step, rest_money)
#   # 終了した?
#   if rest_step == 0
#     return rest_money == 0 ? [0, 0, 0] : FAILED
#   end
#   # 探索
#   result = FAILED
#   BILLS.each do |bill|
#     next_rest_step = rest_step - 1
#     next_money = rest_money - bill
#     used_bills = dp(next_rest_step, next_money)
#     unless is_failure(used_bills)
#       # 使ったお札に探索したお札を1枚追加
#       # puts "success! used_bills: #{used_bills}"
#       # puts "next (rest_step: #{next_rest_step}, rest_money(#{next_money}))"
#       # puts "use #{bill}(idx: #{BILL_TO_IDX[bill]})"
#       used_bills[BILL_TO_IDX[bill]] += 1
#       result = used_bills
#     end
#     add_dp_table(next_rest_step, next_money, used_bills)
#   end
#   return result
# end

def dp(step, money)
  (0..step).each do |yukichi|
    (0..step - yukichi).each do |higuchi|
      hideyo = step - yukichi - higuchi
      return [yukichi, higuchi, hideyo] if
        yukichi * 10 + higuchi * 5 + hideyo * 1 == money
    end
  end
  return [-1, -1, -1]
end

n, y = gets.split
res = dp(n.to_i, y.to_i / 1000)
puts res.join(" ")


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<queue>
#include<tuple>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef tuple<ll,int,int> til;
const int INF=1e+9;
const ll INFLL=1e+17;
bool comp(ll &a,ll &b){
  return a>b;
}
bool f[1000010][1010];
int main(){
  int x,y,z,k;cin>>x>>y>>z>>k;
  ll a[1010],b[1010],c[1010];
  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];
  rep(i,z) cin>>c[i];
  ll d[1000010];
  int s=0;
  rep(i,x){
    rep(j,y){
      d[s]=a[i]+b[j];
      s++;
    }
  }
  sort(d,d+s,comp);
  sort(c,c+z,comp);
  priority_queue<til> q;
  int cnt=0;
  ll res[3010];
  fill(f,0);
  q.push(make_tuple(d[0]+c[0],0,0));
  f[0][0]=true;
  while(cnt<k){
    til t=q.top();q.pop();
    ll &p=get<0>(t);
    int &i=get<1>(t);
    int &j=get<2>(t);
    res[cnt]=p;
    cnt++;
    if(j+1<z&&!f[i][j+1]){
      q.push(make_tuple(d[i]+c[j+1],i,j+1));
      f[i][j+1]=true;
    }
    if(i+1<s&&!f[i+1][j]){
      q.push(make_tuple(d[i+1]+c[j],i+1,j));
      f[i+1][j]=true;
    }
  }
  rep(i,k) prin(res[i]);
  

  return 0;
}


Measured memory_bytes: 994560
import sys
sys.setrecursionlimit(10**6)


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    e = [list(map(int, input().split())) for _ in range(n-1)]
    p = [list(map(int, input().split())) for _ in range(q)]

    e2 = [[] for _ in range(n)]
    for ee in e:
        a, b = ee
        e2[a-1].append(b-1)
        e2[b-1].append(a-1)

    counters = [0] * n
    for pp in p:
        counters[pp[0]-1] += pp[1]

    used = [0] * n

    def dfs(x, p_sum):
        counters[x] += p_sum
        used[x] = 1
        for y in e2[x]:
            if used[y] == 1:
                continue
            dfs(y, counters[x])

    dfs(0, 0)
    print(*counters)


main()


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

int     main() {
        long N, T;
        cin >>N >>T;
        T +=1;
        long C=1001;
        long c, t;
        for (long i=1; i<=N; i++) {
                cin >>c >>t;
                if (T>t) {
                        C=min(C, c);
                }
        }
        if (C==1001) {
                cout <<"TLE" <<endl;
        } else {
                cout <<C <<endl;
        }
        return 0;
}

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

struct TreeQuery{
    std::vector<std::vector<std::pair<int,int>>> tree;
    std::vector<int> dist;
    TreeQuery() = delete;
    TreeQuery(const std::vector<std::vector<std::pair<int,int>>>&& t){
        tree = t;
        dist.assign(tree.size(), -1);
    }

    void memDist(const size_t v, const int d){
        if(dist[v] != -1) return;
        dist[v] = d;
        for(const std::pair<int,int> next : tree[v]) memDist(next.first, d+next.second);
    }

    size_t twoPointDist(const size_t x, const size_t y){
        std::fill(dist.begin(), dist.end(), -1);
        memDist(x, 0);
        return dist[y];
    }

    size_t furthestPoint(const size_t start){
        std::fill(dist.begin(), dist.end(), -1);
        memDist(start, 0);
        return std::max_element(dist.begin(), dist.end()) - dist.begin();
    }   

    size_t diameter(const size_t v=0){
        size_t x = furthestPoint(v);
        size_t y = furthestPoint(x);
        return dist[y];
    }
};

using namespace std;
using i64 = int_fast64_t;
int main(){
    int N, s, t, w;
    cin >> N;
    vector<vector<pair<int,int>>> a(N);
    for(int i = 0; i < N-1; i++){
        cin >> s >> t >> w;
        a[s].push_back({t, w});
        a[t].push_back({s, w});
    }
    TreeQuery tr(move(a));
    cout << tr.diameter() << endl;
}



Measured memory_bytes: 16168
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<ll>divisors; divisors.reserve(sqrt(n));
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            divisors.push_back(i);
            if (i * i != n)divisors.push_back(n / i);
        }
    }
    ll ans = 0;
    REPC(d, divisors) {
        ll m = d - 1;
        if (n / (m + 1) < m)ans += m;
    }
    cout << ans << endl;
}

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

int n;
char buf[10000];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    int cnt = 0;
    string prev;
    for (int i=0; i<n; i++) {
      scanf(" %s", buf);
      string s(buf);
      if (s == "lu" && prev == "ru") cnt++;
      if (s == "ld" && prev == "rd") cnt++;
      if (s == "ru" && prev == "lu") cnt++;
      if (s == "rd" && prev == "ld") cnt++;
      prev = s;
    }
    printf("%d\n", cnt);
  }
}

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

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] command = Console.ReadLine().Split(' ');

                switch (command[0])
                {
                    case "print":
                        Print(str, int.Parse(command[1]), int.Parse(command[2]));
                        break;
                    case "replace":
                        str = Replace(str, int.Parse(command[1]), int.Parse(command[2]), command[3]);
                        break;
                    case "reverse":
                        str = Reverse(str, int.Parse(command[1]), int.Parse(command[2]));
                        break;
                    default:
                        break;
                }

            }

        }
        public static void Print(string str, int a, int b)
        {
            Console.WriteLine(str.Substring(a, b - a + 1));
        }
        public static string Replace(string str, int a, int b, string p)
        {
            string result = "";
            result += str.Substring(0, a);
            result += p;
            result += str.Substring(b + 1);
            return result;
        }
        public static string Reverse(string str, int a, int b)
        {
            string result = "";
            result += str.Substring(0, a);
            for (int id = b; id >= a; id--)
            {
                result += str[id].ToString();
            }
            result += str.Substring(b + 1);
            return result;
        }

    }
}


Measured memory_bytes: 22012
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool cmp(pair<int,int>a,pair<int,int>b)
{
	return a.second<b.second;
}
main()
{
	int n;
	cin>>n;
	vector<pair<int,int>>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i].first>>a[i].second;
	sort(a.begin(),a.end(),cmp);
	int i,start=0;
	for(i=0;i<n;i++)
	{
		start+=a[i].first;
		if(start>a[i].second)
			break;
	}
	if(i==n)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
	

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

int main()
{
  int min = INT_MAX;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.length() - t.length() + 1; i++)
  {
    int cnt = 0;
    string inner_s = s.substr(i, t.length());
    for (int j = 0; j < t.length(); j++)
    {
      cnt += inner_s[j] != t[j];
    }
    if (cnt < min)
    {
      min = cnt;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
int v[2004];

int caut_bin(int st, int fin, int sum) {
    int p = st;
    while (st <= fin) {
        int mij = (st + fin) / 2;
        if (v[mij] >= sum) {
            fin = mij - 1;
        } else {
            st = mij + 1;
        }
    }
    return st - p;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++) {
        cin >> v[i];
    }
    int sum = 0;
    sort(v, v + n);
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j < n; j ++) {
            sum += caut_bin(j + 1, n - 1, v[i] + v[j]);
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
P = list(map(int, input().split()))
p = sorted(P)
Q = list(map(int, input().split()))
q = sorted(Q)
a = 0
b = 0

import itertools
i = 1
for ptn in itertools.permutations(range(1, N+1)):
  if list(ptn)==P:
    a = i
  if list(ptn)==Q:
    b = i
  i += 1
print(abs(a-b))

Measured memory_bytes: 9100
#include <iostream>
using namespace std;
int main(void){
    int a, b, x;
    char op;
    
        for(;;){
            cin >> a >> op >> b;
            if(op == '?') break;
            
            if(op == '+') x = a + b;
            if(op == '-') x = a - b;
            if(op == '*') x = a * b;
            if(op == '/') x = a / b;
            cout << x << endl;
        }
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int l = S.size();
	int c = count(S.begin(), S.end(), 'o');
	if (15 - l + c >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int GCD(int, int);

int main(void){

        unsigned long a[50], b[50], x,result;
	int n=0,i;

	while ((scanf("%lu%lu", &a[n], &b[n]) != EOF) && (n < 50)) {
		if (((0 < (a[n], b[n]))) 
			&& ((a[n], b[n]) <= 2000000000) 
			&& (((a[n]*b[n])/(GCD(a[n],b[n]))) < 2000000000)) {
			n++;
		}
	}

	for (i = 0; i < n; i++) {
		x = a[i] * b[i];
		result = GCD(a[i], b[i]);
		printf("%lu %lu\n",result,x/result);
	}
	return 0;
}

int GCD(int a, int b) {
  int i;
  unsigned long r, tmp,x;
		x = a * b;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		/* ????????°????????????????????? */
		r = a % b;
		while (r != 0) {
			a = b;
			b= r;
			r = a % b;
		}
		return b;
}

Measured memory_bytes: 604
// #include "matching.h"
#include <iostream>
#include <vector>

using Compatibility = std::vector<std::vector<short>>;

namespace {

constexpr int64_t modulo = 1e9 + 7;

int num_set_bits(int mask)
{
    int num{0};
    while (mask) {
        if (mask & 1)
            ++num;
        mask >>= 1;
    }
    return num;
}

void mod_add(int& add_to, int value)
{
    add_to += value;
    if (add_to >= modulo)
        add_to -= modulo;
}

} // namespace

int64_t num_ways_to_match(const Compatibility& compatibility,
                          uint16_t num_pairs)
{
    std::vector<int> dp(1 << num_pairs); // 2^n
    dp.front() = 1;

    for (int mask = 0; mask < (1 << num_pairs) - 1; ++mask) {
        const auto m = num_set_bits(mask);
        for (int w = 0; w < num_pairs; ++w) {
            if (compatibility[m][w] && !(mask & (1 << w))) {
                int m2 = mask ^ (1 << w);
                mod_add(dp[m2], dp[mask]);
            }
        }
    }
    return dp.back();
}

int main(int argc, char* argv[])
{
    uint16_t num_pairs{0};
    std::cin >> num_pairs;
    Compatibility compatibility(num_pairs, std::vector<short>(num_pairs, 0));
    for (auto i = 0; i < num_pairs; ++i) {
        for (auto j = 0; j < num_pairs; ++j) {
            short match;
            std::cin >> match;
            compatibility[i][j] = match;
        }
    }
    std::cout << num_ways_to_match(compatibility, num_pairs) << std::endl;
    return 0;
}


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

hights = [int(h) for h in input().split()]


eval = []

def chmin(a,b):
    if a > b:
        b = a
        return True
    return False

for i in range(N):
    if i == N:
        break
    elif i == 0:
        eval.append(0)
        continue
    elif i == 1:
        eval.append(abs(hights[i] - hights[i-1] ))
        continue

    to_next = abs(hights[i] - hights[i-1]) + eval[i-1]
    prev_to_next = abs(hights[i] - hights[i-2]) + eval[i-2]
    if prev_to_next > to_next:
        eval.append(to_next)
    else:
        eval.append(prev_to_next)
print(eval[N-1])

Measured memory_bytes: 13716
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	double ans = 0.0, a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		ans += 1.0 / a;
	}
	ans = 1.0 / ans;
	cout << ans << endl;
}

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

using namespace std;

int main(void){
	int n, q, sum_time = 0;
	queue<pair<string,int> > que;

	cin >> n >> q;

	for(int i = 0;i < n;i++){
		string name;
		int time;
		cin >> name >> time;
		que.push(make_pair(name,time));
	}
	while(que.size()){
		string name;
		int time;
		name = que.front().first;
		time = que.front().second;
		que.pop();
		if(time - q > 0){
			sum_time += q;
			que.push(make_pair(name,time - q));
		}else{
			sum_time += time;
			cout << name << " " << sum_time << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4400
/**
  *    author: Behradm
  *    Created: %Y%.%M%.%D% %h%:%m%:%s%
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k;
	string s;
	cin >> k >> s;
	if ((int) s.size() <= k)
		cout << s;
	else {
		string res = "";
		for (int i = 0; i < k; i++)
			res += s[i];
		res += "...";
		cout << res << '\n';
	}
	return 0;
}



Measured memory_bytes: 3656
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=105*105+2*105;//1~n 为颜色点 n+1~2*n为行点 所有没到过的格子给行->颜色连一条边 跑完后，每个颜色新增的哪个行，标记打上，然后在B里放入这个。 
const int inf=1e9;
struct Flow{
	int s,t,head[maxn],cur[maxn],cnt,q[maxn],rk[maxn];
	struct gg{
		int u,v,w,next;
	}side[maxn*2];
	Flow(){s=maxn-3,t=maxn-2,cnt=1;}
	void reset(){
		cnt=1;memset(head,0,sizeof(head));	
	}
	void ins(int u,int v){
		side[++cnt]=(gg){u,v,1,head[u]};head[u]=cnt;
		side[++cnt]=(gg){v,u,0,head[v]};head[v]=cnt;
	}
	bool bfs(){
		memset(rk,0,sizeof(rk));int hd=1,tl=1;q[tl]=s;rk[s]=1;
		while(hd<=tl){
			int u=q[hd++];
			for(int i=head[u];i;i=side[i].next){
				int v=side[i].v;if(rk[v]||!side[i].w)continue;
				rk[v]=rk[u]+1;q[++tl]=v;
			}
		}
		return rk[t];
	}
	int dfs(int u,int flow){
		if(u==t)return flow;
		int tot=0;
		for(int &i=cur[u];i;i=side[i].next){
			int v=side[i].v;if(rk[u]+1!=rk[v]||!side[i].w)continue;
			int sent=dfs(v,min(flow,side[i].w));flow-=sent;tot+=sent;
			side[i].w-=sent;side[i^1].w+=sent;
		}
		return tot;
	}
	void dinic(){
		int maxflow=0;
		while(bfs()){
			memcpy(cur,head,sizeof(head));
			maxflow+=dfs(s,inf);
		}
	}
}f;
int A[105][105],B[105][105],C[105][105],col[105][105];//col=属于哪一行 
bool used[105][105];
int n,m;
int get_col(int num){
	int tmp=num%m;if(!tmp)tmp=m;
	return (num-tmp)/m+1;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)rep(j,1,m)scanf("%d",&A[i][j]),col[i][j]=get_col(A[i][j]);
	rep(floor,1,m){
		f.reset();
		rep(i,1,n)f.ins(f.s,i),f.ins(i+n,f.t);
		rep(i,1,n)rep(j,1,m)if(!used[i][j])f.ins(col[i][j],i+n);
		f.dinic();
		rep(i,n+1,2*n){//枚举每一行 
			for(int j=f.head[i];j;j=f.side[j].next){
				int v=f.side[j].v;
				if(v<=n&&f.side[j].w){//颜色v->行i-n的匹配被点亮 
					rep(k,1,m){//寻找这一行中符合这一颜色的 
						if(col[i-n][k]==v&&!used[i-n][k]){
							used[i-n][k]=1;
							B[i-n][floor]=A[i-n][k];//填过来 
							break;
						}
					}
					break;
				}
			}
		}
	}
	//现在B中每一列的任意一种颜色只有一个
	rep(i,1,n)rep(j,1,m)C[get_col(B[i][j])][j]=B[i][j];
	rep(i,1,n){rep(j,1,m)printf("%d ",B[i][j]);printf("\n");}
	rep(i,1,n){rep(j,1,m)printf("%d ",C[i][j]);printf("\n");}
	return 0;
}


Measured memory_bytes: 4348
#include<stdio.h>
main(){
  int b,c,d,e,n,ans=0;
  while(scanf("%d",&n)!=EOF){
    for(b=0;b<10;b++){
      for(c=0;c<10;c++){
	for(d=0;d<10;d++){
	  for(e=0;e<10;e++){
	    if(b+c+d+e==n){
	      ans=ans+1;
	    }
	  }
	}
      }
    }
    printf("%d\n",ans);
    ans=0;
  }
  return 0;
}

Measured memory_bytes: 596
#天気予報 S晴れ,C曇り,R雨
S = gets.chomp.split("").map(&:to_s)
#実際の天気 S晴れ,C曇り,R雨
T = gets.chomp.split("").map(&:to_s)
tenkicount = 0
(0..2).each do |n|
    if S[n] == T[n]
        tenkicount += 1
    end
end
puts tenkicount

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)(n); i++)
#define reps(i,s,e) for(int i=s; i<(int)(e); i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    Graph<ll> values(R+1, vll(C+1, -1));
    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;
        values[r][c] = v;
    }
    vector<vector<vector<ll>>> dp(R+1, vector<vector<ll>>(C+1, vll(4, 0)));
    reps(r, 1, R+1) {
        reps(c, 1, C+1) {
            rep(k, 4) {
                if (values[r][c] == -1) {
                    if (k == 0) {
                        dp[r][c][k] = std::max(dp[r][c-1][k], dp[r-1][c][3]);
                    } else {
                        dp[r][c][k] = std::max(dp[r][c-1][k], dp[r][c][k-1]);
                    }
                } else {
                    if (k == 0) {
                        dp[r][c][k] = std::max(dp[r][c-1][k], dp[r-1][c][3]);
                    } else if (k == 1) {
                        dp[r][c][k] = std::max(std::max(std::max(dp[r][c-1][k-1] + values[r][c], dp[r-1][c][3] + values[r][c]), dp[r][c-1][k]), dp[r][c][k-1]);
                        // cout << dp[r][c][k] << endl;
                    } else {
                        // cout << "k2" << endl;
                        dp[r][c][k] = std::max(std::max(dp[r][c-1][k-1] + values[r][c], dp[r][c-1][k]), dp[r][c][k-1]);
                        // cout << dp[r][c][k] << endl;
                    }
                }
            }
            // cout << r << c << " " << dp[r][c][3] << endl;
        }
    }
    cout << dp[R][C][3] << endl;
}

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

int main()
{
    int a, b;
    scanf("%d%d%d", &a, &b);
    if (a + b > 9)
    {
        printf("error\n");
    }
    else
    {
        printf("%d\n", a + b);
    }
    return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
ll=LI()
ll.sort()
ans=0
#print(ll)
for i in range(n):
    for j in range(i):
        if ll[i]==ll[j]:continue
        for k in range(j):
            if ll[i]==ll[k] or ll[j]==ll[k]:continue
            if ll[i]<ll[j]+ll[k]:
                #print(i,j,k)
                ans+=1
print(ans)



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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n>>m;
    if((max(n,m)-min(n,m))%2!=0)
    cout<<"IMPOSSIBLE";
    else
    cout<<(max(n,m)+min(n,m))/2;
    return 0;
}


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

int Board[102][102];    //Board[j, x, w][i, y, h]
bool isOK;              //迷路がOKかNGか
int xs, ys, xg, yg;     //StartとGoalの座標

void DFS(int c, int x, int y){
    if(Board[x][y] != c){
        return;
    }
    else if(x==xg && y==yg){
        isOK = true;    //Goalなら迷路はOK
        return;
    }

    Board[x][y] = 0;

    DFS(c, x+1, y  );
    DFS(c, x  , y+1);
    DFS(c, x-1, y  );
    DFS(c, x  , y-1);
}

int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        
        isOK = false;               //初期値をNGに
        for(int i=1;i<=100;i++){     //Boardの初期化
            for(int j=1;j<=100;j++)
                Board[j][i] = -1;
        }
        cin >> xs >> ys >> xg >> yg;

        int n, c, d, x, y;
        cin >> n;
        for(int t=0;t<n;t++){
            cin >> c >> d >> x >> y;
            int wb = 2+(!d*2);      //d=0なら横長
            int hb = 2+(d*2);       //d=1なら縦長
            for(int i=0;i<hb;i++){
                for(int j=0;j<wb;j++)
                    Board[x+j][y+i] = c;
            }
        }

        DFS(Board[xs][ys], xs, ys);

        if(isOK)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;

    }

    return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;


int main() {
	int n;
	string s[105];
	int p[105], num[105];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> p[i];
		num[i] = i + 1;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (s[j] > s[j + 1]) {
				swap(s[j], s[j + 1]);
				swap(p[j], p[j + 1]);
				swap(num[j], num[j + 1]);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1 ; j++) {
			if (s[j] == s[j + 1] && p[j] < p[j + 1]) {
				swap(s[j], s[j + 1]);
				swap(p[j], p[j + 1]);
				swap(num[j], num[j + 1]);
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
a=list(map(int,input().split()))
n = a[0]
m = a[1]
l = a[2]

matrixA=[[] for i in range(n)] #A=n*m matrix
matrixB=[[] for i in range(m)] #B=m*l matrix
matrixC=[[0 for i in range(l)] for i in range(n)] #C=n*l matrix

#input
for i in range(n):
    values=list(map(int,input().split()))
    for j in range(m):
        matrixA[i].append(values[j])
for i in range(m):
    values=list(map(int,input().split()))
    for j in range(l):
        matrixB[i].append(values[j])

# start calc
for i in range(n):
    for j in range(l):
        for k in range(m):
            matrixC[i][j] += matrixA[i][k] * matrixB[k][j]
# print
for i in range(n):
    print(*matrixC[i])


Measured memory_bytes: 7064
/**
 *   created: 23 May 2019  18:00:38
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi > in;
vector< vl > mem;
int n,m;

long long sol(int i,int j){
	if(i==n-1 && j==m-1)
		return 1;
	if(i>=n || j>=m)
		return 0;
	if(mem[i][j]!=-1)
		return mem[i][j];
	if(j+1<m && in[i][j+1]==1)
		mem[i][j] = (max(mem[i][j],(ll)0)%MOD + sol(i,j+1)%MOD)%MOD;
	if(i+1<n && in[i+1][j]==1)
		mem[i][j] = (max(mem[i][j],(ll)0)%MOD + sol(i+1,j)%MOD)%MOD;
	if(mem[i][j]==-1)
		mem[i][j] = 0;
	return mem[i][j];
}
int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		// int n,m;
		cin>>n>>m;
		in.resize(n,vi(m));
		rep(i,0,n){
			rep(j,0,m){
				char c;
				cin>>c;
				in[i][j] = c=='.';
			}
		}
		if(in[0][0]==0){
			cout<<0;
			return 0;
		}
		mem.resize(n,vl(m,-1));
		cout<<sol(0,0);
	}
	return 0;
}


Measured memory_bytes: 12160
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#define rad(r) (r * M_PI / 180)
int main() {
	int a, b, C;
	scanf("%d %d %d", &a, &b, &C);
	printf("%f\n", a*b*sin(rad(C))/2);
	printf("%f\n", a+b+sqrt(a*a+b*b-2*a*b*cos(rad(C))));
	printf("%f\n", b*sin(rad(C)));
}

Measured memory_bytes: 1112
def max_heapify(x = 1)
  l = 2*x
  r = 2*x+1
  if l <= $n && $heap[l][0] > $heap[x][0]
    maximum = l
  else
    maximum = x
  end
  if r <= $n && $heap[r][0] > $heap[maximum][0]
    maximum = r
  end
  if maximum != x
    $heap[x], $heap[maximum] = $heap[maximum], $heap[x]
    max_heapify(maximum)
  end
end

def extract
  key = $heap[1]
  $heap[1] = $heap[$n]
  $n -= 1
  max_heapify
  key
end

def insert(key)
  $n += 1
  $heap[$n] = key
  i = $n
  while i > 1 && $heap[i/2][0] < $heap[i][0]
    $heap[i], $heap[i/2] = $heap[i/2], $heap[i]
    i /= 2
  end
end

def dist(p0, p1)
  Math.sqrt( (p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2 )
end

def find(x)
  x == $sibling[x] ? x : $sibling[x] = find($sibling[x])
end

n, m = gets.split.map(&:to_i)
$sibling = Array.new(n + 1) { |i| i }
p = [ 0, *n.times.map { gets.split.map(&:to_f) } ]
q = m.times.map { gets.split.map(&:to_i) }
sum = 0
$n = 0
$heap = []
q.each do |a, b|
  insert( [dist(p[a], p[b]), a, b] )
end
until $n < 1
  d, p1, p2 = extract
  if ( p1 = find(p1) ) != ( p2 = find(p2) )
    $sibling[p2] = p1
  else
    sum += d
  end
end
p sum < 0 ? 0 : sum

Measured memory_bytes: 15276
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    double n,k;
    cin >> n >> k;
    double prob = 0;
    for (int i = 1; i < n+1; i++)
    {
        int score = i;
        double sum = 1;
        while (score < k)
        {
            score *= 2;
            sum *= 0.5;
        }
        prob += sum/n;
    }
    cout << fixed << setprecision(10) << prob << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        double n;
        cin >> n;
        vector<double> a(n);
        rep(i, n) cin >> a[i];
        double rev = 0;
        rep(i, n) rev += 1.0 / a[i];
        cout << fixed << setprecision(10) << 1 / rev << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, n, f, reminder;
  cin >> N;
  f = 0;
  n = N;
  
  for (int i = 10 ;;)
  {
    if ( N == 0)
      break;
      
    reminder = n % i;
    f += reminder;
    
    if ( n / i == 0)
      break;
    
    n /= i;
  }
  if ( N != 0)
  {
   if ( N % f == 0)
     cout << "Yes" << endl;
   else
     cout << "No" << endl;
  }
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
MOD = 1000000007
tmp = list(map(int, input().split()))
n = tmp[0]
k = tmp[1]

co = 1
ci = 1
for i in range(k):
  co *= (n-k+1-i)
  co //= (i+1)
  if i == 0:
    ci *= 1
  else:
    ci *= (k-i)
    ci //= (i)
#  print (str(ci)+' '+str(co)+' '+str(int(co * ci) % MOD))
  print (int(co * ci) % MOD)

Measured memory_bytes: 41840
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

signed  main(){
    int n, m, t, p;
    while(cin>>n>>m>>t>>p&&n){
        vector<vector<int> > paper(n, vector<int>(m, 1));
        REP(i, t){
            int d, c;
            cin >> d >> c;
            if(d==1){
                vector<vector<int> > newpaper(max((int)paper.size()-c, c), vector<int>((int)paper.front().size(), 0));
                REP(y, paper.front().size()){
                    REP(j, c){
                        newpaper[j][y]+=paper[c-j-1][y];
                    }
                    REP(j, paper.size()-c){
                        newpaper[j][y]+=paper[j+c][y];
                    }
                }
                paper=newpaper;
            }else{
                vector<vector<int> > newpaper(paper.size(), vector<int>(max((int)paper.front().size()-c, c), 0));
                REP(x, paper.size()){
                    REP(j, c+1){
                        newpaper[x][j]+=paper[x][c-j-1];
                    }
                    REP(j, paper.front().size()-c){
                        newpaper[x][j]+=paper[x][j+c];
                    }
                }
                paper=newpaper;
            }
        }
        REP(i, p){
            int x, y;
            cin >> x >> y;
            cout << paper[x][y] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3064
<?php
// スタック
$stack = array();

while(1){
	$res = fscanf(STDIN, '%d', $n);
	if ($res==0) break;
	
	if ($n===0) {
		$end = array_pop($stack);
		echo $end.PHP_EOL;
	} else {
		array_push($stack, $n);
	}
}

Measured memory_bytes: 6576
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl h(n);
    ll M = 0;
    ll cnt = 0;
    rep(i,n){
        cin >> h[i];
        if(h[i] >= M){
            cnt++;
            M = h[i];
        }
    }
    cout << cnt << "\n";
}

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



int main() {

int n ,k, sum=0 ;
cin >> n >> k ;
int arr[n];

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

    cin >> arr[i];
}

sort (arr,arr+n);


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

    sum +=arr[i];


}

cout << sum << endl;

	return 0;

}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		//modpow
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		//累乗
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		//順列
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		//組み合わせ
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		//重複組み合わせ
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/


ll LCS(string& s, string& t) {


	auto dp = make_v<ll>(s.size() + 10, t.size() + 10);
	fill_v(dp, 0);

	for (ll i = 0; i < s.size(); i++) {
		for (ll j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	return dp[s.size()][t.size()];
}


int main() {

	int n;
	cin >> n;
	for (int _ = 0; _ < n; _++)
	{
		string s, t;
		cin >> s >> t;
		cout << LCS(s, t) << endl;
	}

	

	return 0;
}


Measured memory_bytes: 10764
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int a,b,c=0,d=0,e,f,m,n,p,x,y,z,t,i,j,k;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a==b)
            c++;
        else
            c=0;
        v.push_back(c);
    }
    for(i=0;i<v.size();i++)
    {
        if(v[i]>=3)
        {
            cout<<"Yes"<<endl;
            d=1;
            break;
        }
    }
    if(d==0)
        cout<<"No"<<endl;
    v.clear();
}




Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

vector<vector<int>> g;
bool seen[9][9];

int main(){
    int n,m; 
    cin >> n >> m;
    vector<int> v(n);
    g.resize(n);
    rep(i,n){
        v[i] = i;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    do{
        bool can = false;
        for (int i = 0;i < n-1;i++){
            bool f = false;
            for (auto nx:g[v[i]]){
                if (nx == v[i+1]){
                    f = true;
                }
            }
            if (!f) break; 
            if (i == n-2 && f) can = true;
        }
        if (can) ans++;
        //if (can){
        //    rep(i,n) cout << v[i];
        //    cout << endl;
        //}

    }while(next_permutation(v.begin()+1,v.end()));
    
    cout << ans << endl;
    


    
    
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

//in
//3
//8 12 40
func main() {

  var cnt int
  fmt.Scan(&cnt)

  var nums = make([]int,cnt)
  for i := 0 ; i < cnt ; i++ {
     fmt.Scan(&nums[i])
  }
  
  var flag = true
  var result = 0
  for flag {
    for i :=0 ; i< cnt ; i++ {
      if nums[i]%2 == 0 {
        nums[i] = nums[i] / 2
      } else {
      	flag = false
      }
    }
    if flag == true {
      result = result +1 
    }
  }
  
  fmt.Println(result)
}



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

using namespace std;
#define ll long long
#define ld long double

#define endl '\n'
#define FAST                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
ll fastPow(ll x, ll b)
{
    if (b == 0)
        return 1;
    else if (!(b & 1))
    {
        return fastPow(x * x, b / 2);
    }
    else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
struct def
{
    string h = ">";
};
vector<int> allPrimes;
void sieve(int n)
{
    vector<bool> prime(n + 1, true); 
    
    for (int p = 2; p * p <= n; p++)
    {
        
        if (prime[p] == true)
        {
            for (int i = p * 2; i <= n; i += p)
                prime[i] = false;
        }
    }

    for (int p = 2; p <= n; p++)
        if (prime[p])
            allPrimes.push_back(p);
}
ll numoffact(ll n)
{
    sieve(n);
    ll result = 1;
    for (int i = 0; i < allPrimes.size(); i++)
    {
        ll p = allPrimes[i];
        ll exp = 0;
        while (p <= n)
        {
            exp = exp + (n / p);
            p = p * allPrimes[i];
            p %= mod;
        }
        result = (result * (exp + 1))%mod;
    }
    return result%mod;
}
int main()
{
    FAST int n;
    cin>>n;
    cout << numoffact(n) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String lineStr1 = scan.nextLine();
		String lineStr2 = scan.nextLine();
		scan.close();
		
		String[] splitStr1 = lineStr1.split(" ");
		int N = Integer.parseInt(splitStr1[0]);
		int X = Integer.parseInt(splitStr1[1]);
		
		String[] splitStr2 = lineStr2.split(" ");
		int len = splitStr2.length;
		int[] cityList = new int[len];
		
		for (int i = 0 ; i < len ; i++) {
			cityList[i] = Integer.parseInt(splitStr2[i]);
		}
		
		int[] diffList = new int[len];
		int miniDiff = 1000000000;
		for (int j = 0 ; j < len ; j++) {
			int diff = Math.abs(X - cityList[j]);
			diffList[j] = diff;
			if (miniDiff > diff) {
				miniDiff = diff;
			}
		}
		
		for (int k = miniDiff ; k > 0 ; k--) {
			boolean flg = false;
			for (int l = 0 ; l < len ; l++) {
				if (diffList[l] % k != 0) {
					flg = true;
					break;
				}
			}
			if (!flg) {
				System.out.print(k);
				return;
			}
		}
	}
}


Measured memory_bytes: 48680
// 参考:http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3891837#1

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define MAX 100000

int n, q;
vector<int> G[MAX];

int id[MAX];
int es[2 * (MAX - 1)];
ll bit[MAX + 1];

void dfs(int v, int p, int &k){
	id[v] = k;
	k++;
	for(int i = 0; i < G[v].size();++i){
		int to = G[v][i];
		if(to != p){
			es[2 * to] = k;
			dfs(to, v, k);
			es[2 * to + 1] = k;
		}
	}
}

ll sum(int i){
	ll s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, ll x){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}
}

int main(){
    int k;
	scanf("%d", &n);
	for(int i = 0; i < n;++i){int k;
		scanf("%d", &k);
		for(int j = 0; j < k;++j){
			int c;
			scanf("%d", &c);
			G[i].push_back(c);
		}
	}
	k = 0;
	dfs(0,-1,k);
	
	scanf("%d", &q);
	for(int i = 0; i < q;++i){
		int op;
		scanf("%d", &op);
		if(op == 0){
			int v;
			ll w;
			scanf("%d %lld", &v, &w);
			add(es[2 * v], w);
			add(es[2 * v + 1], -w);
		}else{
			int u;
			scanf("%d", &u);
			printf("%lld\n", sum(id[u]));
		}
	}
}



Measured memory_bytes: 16300
data = input().split()

# ??????????????????????????????????£?
# n : ????????????????????????
# S : ????????????
n = 1000
S = [0 for i in range(n)]

def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False

def isFull():
    global top, n
    return top > n-1

def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x

def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1]

top = 0

for e in data:


    if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand')


print(S[top])

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  string s;
  cin >> s;

  if(s.size() == 2) cout << s << endl;
  else{
    reverse(all(s));
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int N;
double dp[310][310][310];
//dp[i][j][k]で寿司が3個の皿がi枚、２個の皿がj枚、3個の皿がk枚ある
//状態から寿司を全てなくすのに必要な操作回数の期待値
//次に残0枚の皿を引く確率はN-i-j-k/N,行先はdp[i][j][k]
//残1枚の皿を引く確率はi,行先はdp[i-1][j][k]
//残2枚の皿を引く確率はj,行先はdp[i+1][j-1][k]
//残3枚の皿を引く確率はk,行先はdp[i][j+1][k-1]
//期待値漸化式はdp[i][j][k]=(dp[i][j][k]*(N-i-j-k)/N+dp[i-1][l][k]*i/N+dp[i+1][j-1][k]*j/N+dp[i][j+1][k-1]*k/N)+1;
//これを変形して自己ループを除去すると
//dp[i][j][k]=(dp[i-1][[j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k+N)*1/i+j+k;
double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) {
		return 0.0;
	}
	double res = 0.0;
	if (i > 0)res += rec(i - 1, j, k)*i;
	if (j > 0)res += rec(i + 1, j - 1, k)*j;
	if (k > 0)res += rec(i, j + 1, k - 1)*k;
	res += N;
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}
int main() {
	cin >> N;
	int one = 0, two = 0, three = 0;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		if (a == 1)++one;
		else if (a == 2)++two;
		else ++three;
	}
	memset(dp, -1, sizeof(dp));
	cout << fixed << setprecision(10) << rec(one, two, three) << endl;
	return 0;
}

Measured memory_bytes: 233088
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
    int n,m; cin >> n >> m;
	if (m==0){
		if (n!=1){
			cout << pow(10,n-1) << "\n";
			return 0;
		}
		else{
			cout << 0 << "\n";
			return 0;
		}
	}
	map<int,int> A;
	for (int i=1;i<=3;i++){
		A.insert({i,-1});
	}

	for (int i=0;i<m;i++){
		int a,b; cin >> a >> b;
		if (a>n){
			cout << "-1" << "\n";
			return 0;
		}
		if (A[a]!=-1 && A[a]!=b){
			cout << "-1" << "\n";
			return 0;
		}
		A[a]=b;
	}
	int l=0;
	int y=-1;
	for (int i=n-1;i>0;i--){
		y=max(y,A[i]);
	}
	if (y==0 && A[n]==-1){
		cout << "-1" << "\n";
		return 0;
	}
	for (int i=1;i<=n;i++){
		if (A[i]==-1 && i!=1) A[i]=0;
		else if (A[i]==-1) A[i]=1; 
		l+=A[i]*pow(10,n-i);
	}
	cout << l << "\n";
}


Measured memory_bytes: 256