akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int d, goal; cin >> d >> goal;
    vector<int> p(d), c(d);
    for(int i=0; i<d; i++) cin >> p[i] >> c[i];

    int ans = 10000000;

    for(int bit=0; bit<(1<<d); bit++){
        int score = 0;
        int cnt = 0;
        for(int i=0; i<d; i++){
            if(bit&(1<<i)){
                score += 100*(i+1)*p[i];
                score += c[i];
                cnt += p[i];
            }
        }

        int adid;
        for(int i=0; i<d; i++){
            if((bit&(1<<i)) == 0) adid = i;
        }

        if(score >= goal){
            ans = min(ans, cnt);
            continue;
        }

        if((goal-score-1)/(100*(adid+1)) + 1 < p[adid]) cnt += (goal-score-1)/(100*(adid+1)) + 1;
        else continue;

        ans = min(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k,s;
  cin >> k >> s;
  long long ans = 0;
  rep(x,k+1){
      rep(y,k+1){
          if(s-x-y >= 0 && s-x-y <= k){
              ans++;
          }
      }
  }
  cout << ans << endl;
  return 0;
}


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

/*?´???°????????°1??????????´???°??§????????????0???????????¢??°*/
int prime(int x) {
	int i;
	for (i = 2; i <= sqrt(x);i++) {
		if (x%i == 0)
			return 0;
	}
	return 1;
}

int main(void) {
	int n, j, k = 0;
	/*printf("??´??°?????\????????????????????????");*/
	scanf("%d", &n);
	int a[10000];
	/*printf("??\???????????´??°?????°????????´??°?????\????????????????????????");*/
	for (j = 0; j < n;j++) {
		scanf("%d", &a[j]);
	}
	for (j = 0; j < n;j++) {
		k = k + prime(a[j]);
	}
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 632
<?php
    for($i=0;$i<5;$i++){
        $X[] = intval(trim(fgets(STDIN)));
    }
    $ans = 10;
    for($i=0;$i<5;$i++){
        $amari = $X[$i]%10;
        if(($amari < $ans) && ($amari!=0)){
            $ans = $amari;
            $i_memory = $i;
        }
    }
    $sum=0;
    
    for($i=0;$i<5;$i++){
        if($i==$i_memory){
            $sum+=$X[$i];
            // echo "a";
        }else{
            if($X[$i]%10==0){
                $sum+=$X[$i];
                // echo "b";
            }else{
                $sum+=(intdiv($X[$i]+10,10)*10);
                // echo "c";
            }
        }
        // echo $sum."\n";
    }
    echo $sum;
    
?>

Measured memory_bytes: 16060
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
signed main(){
    cin >>n >>m;
    int k=m/n;
    int ans;
    for (int i=k;i>0;i--){
        if(m%i==0){ans=i;break;}
    }
 //   cout <<k<<endl;
    cout <<ans<<endl;

}

Measured memory_bytes: 256
# 35行目. >だと1ケース通らずWA, >=だとAC. なんで？？？？？

A, B, C, D, E, F = map(int, input().split())

# 可能な水の総量
water_list = []
A_max = F // (100 * A)
B_max = F // (100 * B)
for i in range(A_max + 1):
    for j in range(B_max + 1):
        temp = 100 * A * i + 100 * B * j
        if temp <= F:
            water_list.append(temp)
water_list = list(set(water_list))

# 可能な砂糖の総量
sugar_list = []
C_max = F // (C)
D_max = F // (D)
for i in range(C_max + 1):
    for j in range(D_max + 1):
        temp = C * i + D * j
        if temp <= F:
            sugar_list.append(temp)
sugar_list = list(set(sugar_list))

max_conc = 0
max_conc_water = 0
max_conc_sugar = 0
for water in water_list:
    for sugar in sugar_list:
        # 水があるか and 溶解度を超えていないか and 容器に入るか
        if water != 0 and sugar <= ((E * water) / 100) and water + sugar <= F:
            conc = (100 * sugar) / (water + sugar)
            if conc >= max_conc:
                max_conc = conc
                max_conc_water = water
                max_conc_sugar = sugar

print(max_conc_water + max_conc_sugar, max_conc_sugar)
# print(max_conc)


Measured memory_bytes: 18332
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> h(N);
	for (ll i = 0; i < N; ++i)
		cin >> h[i];

	sort(h.begin(), h.end());
	ll res{1ll<<50};
	for (ll i = 0; i < N-K+1; ++i)
	{
		res = min(res, abs(h[i] - h[i+K-1]));
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
    ll N, M;
    cin >> N >> M;
    if(N == 1 and M == 1) puts("1");
    else if(N == 1) cout << (M - 2) << endl;
    else if(M == 1) cout << (N - 2) << endl;
    else cout << (M - 2) * (N - 2) << endl;
}

Measured memory_bytes: 3544
N, q = map(int, input().split())
S = input()
Q = [list(map(int ,input().split())) for _ in range(q)]

cnt = [0] * (N+1)
tmp = S[0]
for i in range(2,N+1):
	if tmp == "A" and S[i-1] == "C":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

	tmp = S[i-1]

for l,r in Q:
	ans = cnt[r] - cnt[l-1]

	if S[l-2] == "A" and S[l-1] == "C":
		ans -= 1

	print(ans)


Measured memory_bytes: 30632
#include <iostream>
using namespace std;
int a[100001],s[100001],i,i2,n,l,r;
int main()
{
	a[0]=a[1]=1;
	for(i=2;i<=100000;i++)
	{
		if(a[i]==0)
		{
			for(i2=i*2;i2<=100000;i2+=i)
				a[i2]=1;
		}
	}
	for(i=1;i<=100000;i++)
	{
		s[i]=s[i-1];
		if(a[i]==0&&a[(i+1)/2]==0)s[i]++;
	}
	cin>>n;
	while(n--)
	{
		cin>>l>>r,cout << s[r]-s[l-1]<<'\n';
	}
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))
a = list(reversed(sorted(a)))
x = 0
y = 0
for i in range(len(a)-1):
         if a[i] == a[i+1]:
                  x = a[i]
                  break
for j in range(i+2,len(a)-1):
         if a[j] == a[j+1]:
                  y = a[j]
                  break
print(x*y)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <cstdio>
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[105];
    scanf("%s", s);

    int cnt = 0;
    int i, n, m;
    n = strlen(s);

    for (i = 0; i < n; i++)
    {
        if (s[i] == s[n - i - 1])
        {
            continue;
        }
        if (i >= (n - i))
            break;
        else
        {
            s[n - i - 1] = s[i];
            cnt++;
        }
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        long a = 1;
        for(long i = 2; i * i <= n; i++) {
            if(n % i != 0) continue;
                
            if(Math.abs(i - n/i) < Math.abs(a - n/a))
                a = i;
        }
		System.out.println(Math.max(count(n/a), count(a)));
    }
    
    private static int count(long A) {
        int cntA = 0;
        while(A > 0) {
            cntA++;
            A /= 10;
        }
        return cntA;
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}


int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}


int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}


int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n;
  cin>>n;
  map<string,int> m;
  rep(i,n){
    string s;
    cin>>s;
    m[s]++;
  }
  cout<<m.size();
}

Measured memory_bytes: 19228
def main():
    N = int(input())
    *A, = map(int, input().split())

    dp = [0] * (N + 1)
    dp[0] = 1000

    for i, a in enumerate(A):
        dp[i + 1] = dp[i]
        for j in range(i):
            buy, rest = divmod(dp[j], A[j])
            dp[i + 1] = max(dp[i + 1], buy * a + rest)

    print(dp[-1])


if __name__ == '__main__':
    main()


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	if (a <= b) {
		cout << a;
	}
	else {
		cout << a-1;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long int n,a[100009],i,j,count=0,b[100009];

cin>>n;
for(i=0;i<n+1;i++)
cin>>a[i];

long long int tsum=0;
for(i=0;i<n+1;i++)
tsum=tsum+a[i];


for(i=0;i<n;i++)
cin>>b[i];

for(i=0;i<n;i++)
{
 count=a[i];
 a[i]=max(0ll,a[i]-b[i]);
 long long int e;
 e=max(b[i]-count,0ll);
 a[i+1]=max(a[i+1]-e,0ll);

}
long long int sum=0;
for(i=0;i<n+1;i++)
sum=sum+a[i];

cout<<tsum-sum<<endl;
return 0;
}



Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int x;cin>>x;
    rep(i,100000){
        if(x<=(i*(i+1))/2){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

d,n = map(int, input().split())

if d==0:
    if n != 100:
        print(n)
    else:
        print(101)
elif d==1:
    if n != 100:
        print(n*100)
    else:
        print(10100)
else:
    if n != 100:
        print(n*10000)
    else:
        print(1010000)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}
struct node
{
	int p,l,r;
};
int n;
node a[30];
string typ[30];
int sib(int x)
{
	if(a[x].p==-1)return -1;
	if(a[a[x].p].l==x)
	{
		return a[x].r;
	}
	else
	{
		return a[a[x].p].l;
	}
}
int deg(int x)
{
	int ans=0;
	if(a[x].l!=-1)
	{
		ans++;
		if(a[a[x].l].r!=-1)ans++;
	}
	return ans;
}
int dep(int x)
{
	int ans =0;
	int y=x;
	while(1)
	{
		if(a[y].p==-1)break;
		ans++;
		y=a[y].p;
	}
	return ans;
}
int h(int x)
{

	int ans = 0;
	if(a[x].l==-1)return ans;
	int h1=-1,h2=-1;
	if(a[x].l!=-1)h1=h(a[x].l);
	if(a[a[x].l].r!=-1)h2=h(a[a[x].l].r);
	ans=max(h1,h2)+1;


	return ans;
}
void print(int x)
{
	cout<<"node "<<x<<": ";
	cout<<"parent = "<<a[x].p<<", ";
	cout<<"sibling = "<<sib(x)<<", ";
	cout<<"degree = "<<deg(x)<<", ";
	cout<<"depth = "<<dep(x)<<", ";
	cout<<"height = "<<h(x)<<", ";
	cout<<typ[x]<<endl;
}
int main() {

	rep(i,30)a[i].p=a[i].l=a[i].r=-1;
	cin>>n;
	rep(i,n)
	{
		int id,R,L;
		cin>>id>>R>>L;
		if(R<L)swap(R,L);
		a[id].l=R;
		if(R!=-1)
		{
			a[R].p=id;
			a[R].r=L;
		}
		if(L!=-1)a[L].p=id;
	}
	rep(i,n)
	{
		if(a[i].p==-1)
		{
			typ[i]="root";

		}
		else if(a[i].l==-1)
		{
			typ[i]="leaf";

		}
		else
		{
			typ[i]="internal node";

		}
	}

	rep(i,n)
	{
		print(i);
	}



}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void)
{
    int n, y, m10000, m5000, m1000;
    scanf("%d %d", &n, &y);

    int mon = y;
    m10000 = mon / 10000;
    mon %= 10000;
    m5000 = mon / 5000;
    m1000 = (mon % 5000) / 1000;

    while (m10000 + m5000 + m1000 < n)
    {
        int sum = m10000 + m5000 + m1000;
        if (n - sum >= 4)
        {
            if (0 < m5000)
            {
                m5000 -= 1;
                m1000 += 5;
            }
            else if (0 < m10000)
            {
                m10000 -= 1;
                m5000 += 2;
            }
            else
            {
                break;
            }
        }
        else
        {
            if (0 < m10000)
            {
                m10000 -= 1;
                m5000 += 2;
            }
            else
            {
                break;
            }
        }
    }

    if (m10000 + m5000 + m1000 == n)
    {
        printf("%d %d %d", m10000, m5000, m1000);
    }
    else
    {
        printf("-1 -1 -1");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[100005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	set<int> s;
	int ans=0;
	int i=1;
	s.insert(1);
	while(i!=2){
		i=ar[i];
		if(s.count(i)){
			cout<<"-1";
			return 0;
		}
		s.insert(i);
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 5760
"""
D - XOR World

解説を参考に作成.
いろいろ試している最中に法則に気付けるチャンスはあった...無念
"""

import math


def solve():
    A, B = map(int, input().split())
    print(all_xor(A - 1) ^ all_xor(B))


def all_xor(num):
    """
    0 ~ numまでのすべての数値の排他的論理和を求める.

    :param num:
    :return:
    """
    if num % 2 == 0:
        if (num - 2) % 4 == 0:
            return num
        else:
            return 1 ^ num
    else:
        if (num - 1) % 4 == 0:
            return 0
        else:
            return 1


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VLL = vector <long long>;

int main() {
    // N * N
    const int INF = 1000000;
    int N;
    cin >> N;

    VLL dp(N+1);
    VLL price(N+1);

    dp[0] = 1000;
    price[0] = INF;

    for (int d = 1; d <= N; ++d) {
        cin >> price[d];
        for (int pd = 0; pd < d; ++pd) {
            // no trading
            dp[d] = max(dp[d], dp[pd]);

            // last trading day
            long long minP = INF;

            for (int i = pd; i < d; ++i) {
                minP = min(minP, price[i]);
            }

            long long allIn = dp[pd] / minP;
            long long remainder = dp[pd] % minP;

            dp[d] = max(dp[d], allIn * price[d] + remainder);
        }
    }

    cout << dp[N] << endl;

    return 0;
}

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

using namespace std;

#define lint long long

const lint mod = 1E9 + 7;

lint Factorial(int a){
    lint ans = 1;
    for(lint i = 1; i <= a; ++i){
        ans *= i;
        ans %= mod;
    }
    return ans;
}


int main(){
    int N;
    cin >> N;
    vector<int> a(N + 1), b(N + 1);

    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> b[i];
    }
    a[N] = 1E9 + 1;
    b[N] = 1E9 + 1;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int posA = 0, posB = 0;
    int diff = 0, cnt = 0;
    lint ans = 1;
    while(posA < N || posB < N){
        // cout << a[posA] << " " << b[posB] << endl;
        if(a[posA] < b[posB]){
            if(diff < 0){
                ans *= -diff;
                ans %= mod;
            }
            diff++;
            posA++;
        } else {
            if(diff > 0){
                ans *= diff;
                ans %= mod;
            }
            diff--;
            posB++;
        }
    }

    cout << ans << endl;
}

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

int main() {
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[1]-a[0] == a[2]-a[1]){
        cout<<"YES";
    } else cout<<"NO";
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll a,b;
	ll x;
	cin >> a >> b >> x;
	//f(n) := 0以上n以下の整数のうち条件を満たすものの個数
	ll plus , minus;
	plus = b / x + 1;
	if(a ==0) { minus = 0;}
	else minus = (a-1) / x + 1;

	cout << plus - minus << endl;
}


Measured memory_bytes: 256
/*
 push yourself until you succed
*/
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long int
#define PI 2 * acos(0.0)
#define MAX 1000000000000000000
#define in(a) scanf("%d",&a);
#define out(a) printf("%d",a);
#define INF 1000000 
#define M 1000000007
#define pi 3.14159265 
using namespace std; 
int main(){ 
   fast_io
   ll n;
   cin>>n;
   vector<ll> v,v1;
   ll u = n;
   while(u--){
       ll x,y;
       cin>>x>>y;
       ll a = x+y;
       ll b = x-y;
       v.push_back(a);
       v1.push_back(b);
   }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    ll ans = v[n-1] - v[0];
    ll ans1 = v1[n-1] - v1[0];
    cout<<max(ans,ans1)<<endl;
   return 0;
} 

Measured memory_bytes: 6664
#include <stdio.h>

int tmp, cnt, j, m, n, a[1000000];

void insertionSort(int a[], int n, int g) {
  for(int i = g; i < n; i++) {
    tmp = a[i];
    j = i-g;
    while(j>=0 && a[j]>tmp) {
      a[j+g]=a[j]; j-=g;
    ++cnt;
    }
    a[j+g]=tmp;
  }
}

void shellSort(int a[], int n) {
  m=0; cnt=0;
  int G[100];
  G[0]=1;
  for(m=1 ; 3*G[m-1]+1 <= n ; m++) G[m] = 3*G[m-1]+1;
  printf("%d\n", m);
  for(int i=m-1; i>=0; --i) {
    printf("%d%c", G[i], " \n"[i==0]);
    insertionSort(a, n, G[i]);
  }
}

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





Measured memory_bytes: 5620
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	scanf("%d%d", &n, &k);
	priority_queue<int> pq;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		pq.emplace(x);
	}
	while (k--)
	{
		int x = pq.top();
		pq.pop();
		pq.push(x / 2);
	}
	LL ans = 0;
	while (!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

bool smaller(std::string s1, std::string s2, int L)
{
    for(int i = 0; i < L; ++i)
    {
        if(s1 < s2)
            return true;
        else if(s2 < s1)
            return false;
    }
    return false;
}

int main()
{
    int N, L;
    std::string s;
    std::vector<std::string> S;
    std::cin >> N >> L;
    bool flag = false;

    for(int i = 0; i < N; ++i)
    {
        flag = false;
        std::cin >> s;
        if(i == 0)
            S.push_back(s);
        else
        {
            for(auto w = S.begin(); w != S.end(); ++w)
            {
                if(smaller(s, *w, L))
                {
                    S.insert(w, s);
                    flag = true;
                    break;
                }
            }

            if(!flag)
                S.push_back(s);
        }
    }

    s = "";
    for(int i = 0; i < N; ++i)
        s += S[i];
    
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
import copy
N = int(input())
A = list(map(int,input().split()))

A = sorted(A)

ans = min(A)
while(1):
    prev = ans
    B = list(map(lambda x: x % ans , A[1:]))
    A = [ans] + [i for i in B if i != 0]
    ans = min(A)
    if ans == prev:
        print(ans)
        exit(0)
    A = sorted(A)


Measured memory_bytes: 14820
a, b, c, d, e, f = map(int, input().split())
dp = [[False] * 3001 for _ in range(3001)]
dp[0][0] = True
satomizumax = 0
satomax = 0
for sm in range(f + 1):
    for sg in range(f + 1):
        # // 4toori
        # sg/sm <= e/(100+e)
        if sg * (100 + e) > e * sm:
            break

        if dp[sm][sg]:
            if satomax * sm <= sg * satomizumax:
                satomizumax = sm
                satomax = sg
            if sm + 100 * a <= f + 1:
                dp[sm + 100 * a][sg] = True
            if sm + 100 * b <= f + 1:
                dp[sm + 100 * b][sg] = True
            if sm + c <= f + 1 and sg + c <= f + 1:
                dp[sm + c][sg + c] = True
            if sm + d <= f + 1 and sg + d <= f + 1:
                dp[sm + d][sg + d] = True
print(satomizumax, satomax)


Measured memory_bytes: 79768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int A, B, C;

	cin >> A >> B >> C;
	int ans = B / A;

	if(ans > C)
	{
		ans = C;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll) v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                   31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
                   73, 79, 83, 89, 97, 101, 103, 107};

    unordered_map<ll, ll> mp;

    ll ans = 0;
    rep(i, N)
    {
        string s;
        cin >> s;
        ll x = 1;
        rep(j, len(s)) x *= prime[s[j] - 'a'];
        ans += mp[x];
        ++mp[x];
    }

    print(ans);

    return 0;
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int fac[maxn] , invf[maxn] , inv[maxn] , n , m , h , w;
int dp[maxn];
typedef pair<int,int> ii;
ii a[maxn];

int Pow(int a , int b)
{
    if(b == 0)return 1;
    int r = Pow(a , b / 2);
    if(b & 1)return (ll)r * r % mod * a % mod;
    return (ll)r * r % mod;
}

void precal()
{
    fac[0] = invf[0] = 1;
    for(int i = 1 ; i < maxn ; ++i){
        inv[i] = Pow(i,mod-2);
        assert((ll)i * inv[i] % mod == 1);
        fac[i] = (ll)fac[i - 1] * i % mod;
        invf[i] = (ll)invf[i - 1] * inv[i] % mod;
        assert(fac[i] * 1ll * invf[i] % mod == 1);
    }
}

int way(ii x , ii y)
{
    if(x.first == y.first || x.second == y.second)return 1;
    if(x.second > y.second || x.first > y.first)return 0;
    return (ll)fac[y.first + y.second - x.first - x.second]
    * invf[y.first - x.first] % mod * invf[y.second - x.second] % mod;
}

void enter()
{
    cin >> h >> w >> n;
    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i].first >> a[i].second;
    sort(a + 1 , a + n + 1);
    a[++n] = make_pair(h,w);
}

void solve()
{
    for(int i = 1 ; i <= n ; ++i)
    {
        dp[i] = way(make_pair(1,1),a[i]);
        for(int j = 1 ; j < i ; ++j)
            dp[i] = (dp[i] - (ll)dp[j] * way(a[j],a[i]) + (ll)mod * mod) % mod;
    }
//    cout << way(a[2],a[3]) << endl;
    cout << dp[n];
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    precal();enter();solve();
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void){
    IOS;
    int k; cin >> k;
    ll n = 0;
    for (int i = 1; i <= k; ++i){
        n = n*10+7;
        if (n%k == 0){
            cout << i << endl; return 0;
        }
        n %= k;
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<tuple<string,int,int>> res;
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        res.push_back(make_tuple(s,-p,i+1));
    }
    sort(res.begin(),res.end());
    for(int i = 0; i < n; i++){
        int num;
        tie(ignore,ignore,num) = res.at(i);
        cout << num << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int n,a,max,min;
    scanf("%d ",&n);
    for(int i=0;i<n;i++){
        scanf("%d%*c",&a);
        max=(i==0)?a:(max<a)?a:max;
        min=(i==0)?a:(min>a)?a:min;
    }
    printf("%d",max-min);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
const ll MOD=1000000007;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
  ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
  ll n, x;
  cin>>n>>x;
  vll A (n);
  F (i,0,n,1) cin>>A[i];
  ll cnt=0;
  F (i,1,n,1) {
    if (x<A[i-1]+A[i]) {
      ll take= (A[i-1]+A[i])-x;
      cnt+=take; A[i]=max(0LL,A[i]-take);
  }
  }
  cout<<cnt;


return 0;
}




Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int vari[3];
string s;

string regenerate(string t) {
    int n = t.length();
    string ret = "";
    rep(i,0,n) {
        if(i < n-1 && t[i] == '-' && t[i+1] == '-') i++;
        else ret += t[i];
    }
    return ret;
}

int opnot(int m) {
    return 2 - m;
}

vector< vector<int> > opmul{ {0, 0, 0}, {0, 1, 1}, {0, 1, 2} };
vector< vector<int> > oppls{ {0, 1, 2}, {1, 1, 2}, {2, 2, 2} };

int retvari(char c) {
    string chk = "PQR";
    if(chk.find(c) != string::npos) return vari[ chk.find(c) ];
    else return c - '0';
}

int solve(int l, int r) {
    if(r - l == 1) return retvari(s[l]);
    else {
        int cnt = 0, nl = -1, nr = -1;
        int vl, vr;
        rep(i,l,r) {
            if(s[i] == '(') {
                cnt++;
            }
            if(s[i] == ')') {
                cnt--;
            }
            if(s[i] == '*' && cnt == 0) {
                vl = solve(l, i);
                vr = solve(i+1, r);
                return opmul[vl][vr];
            }
            if(s[i] == '+' && cnt == 0) {
                vl = solve(l, i);
                vr = solve(i+1, r);
                return oppls[vl][vr];
            }
        }
    }

    if(s[l] == '-') return opnot( solve(l+1, r) );
    else return solve(l+1, r-1);
}

signed main() {
    while(cin >> s, s != ".") {
        s = regenerate(s);
        int n = s.length(), cnt = 0;
        rep(i,0,3) rep(j,0,3) rep(k,0,3) {
            vari[0] = i, vari[1] = j, vari[2] = k;
            if(solve(0, n) == 2) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
int x(long long n)
{
   int  sum = 0, remainder;
   long long t;
   t = n;

   while (t != 0)
   {
      remainder = t % 10;
      sum       = sum + remainder;
      t         = t / 10;
   }

   return sum;
}
int main ()
{
    long long int n;
    int sum;
    scanf("%lli",&n);
    sum=x(n);
    if(n%sum) printf("No");
    else printf("Yes");
    return 0;

}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //acceleration
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  //initialization
  long long int a;
  double b;
  cin >> a >> b;
  
  long long int c = round(b * 100); 
  long long int d = a * c / 100;
  cout << (long long int)d << "\n";
}

Measured memory_bytes: 3768
#include <stdio.h>
void bubbleSort(int A[100],int N);
int main(){
  int A[100],N,i;

  scanf("%d",&N);

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

void bubbleSort(int A[100],int N){
  int flag=1,tmp,count=0,j;
  while(flag==1){
  flag = 0;
   for(j = N-1;j>=1;j--)
     if(A[j] < A[j-1]){
       count++;
       tmp = A[j];
       A[j] = A[j-1];
       A[j-1] = tmp;
       flag = 1;
     }
   }
    for(j=0;j<N;j++){
      if(j<N-1){
     printf("%d ",A[j]);
      }
      if(j==N-1){
       printf("%d",A[j]);
       printf("\n");
      }
    }
      printf("%d",count);
      printf("\n");
}



Measured memory_bytes: 2120
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	string A, B;
	cin >> A >> B;
	if (A < B) {
		cout << "<" << endl;
	}
	else if (A == B) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,ans=0;
  	cin >> n >> m;
    while(1){
      if(n==m){
        break;
      }
      if(n/10000==n%10&&(n/1000)%10==(n/10)%10){
        ans++;
      }
      n++;
    }
    if(m/10000==m%10&&(m/1000)%10==(m/10)%10){
      ans++;
    }
    cout << ans << endl;
  	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        a.add(s);
        int n = f(s);
        for(int i = 1; !a.contains(n); i++){
            a.add(n);
            n = f(n);
        }
        System.out.println(a.size() + 1);
        scan.close();
    }
    
    public static int f(int n){
        if(n % 2 == 0) return n / 2;
        return n * 3 + 1;
    }
}

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

using namespace std;

int n;

bool solve(){
    int i,j;
    string str;
    cin >> str;
    if(str.length()%2) return false;
    for(i = 0;i < str.length();i++){
        if(i%2){
            if(str[i] != 'i') return false;
        }
        else{
            if(str[i] != 'h') return false;
        }
    }
    return true;
}

int main(){
    if(solve()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N, M;
    scan(N, M);
    auto b = new bool[](M);
    auto A = aryread();
    b[] = false;
    foreach (a; A[1 .. $])
        b[a - 1] = true;
    foreach (_; 1 .. N)
    {
        auto C = aryread();
        auto tmp = new bool[](M);
        foreach (c; C[1 .. $])
            tmp[c - 1] = true;
        foreach (i; 0 .. b.length)
            b[i] = b[i] && tmp[i];
    }
    // writeln(b);
    writeln(M - b.map!(x => 0 ^^ x).sum());
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  int crush = 0;
  int count = 1;
  rep(i, N){
    if(count != a[i]){
      crush++;
    }
    else{
      count++;
    }
  }
  if(crush == N){
    crush = -1;  
  }
  cout << crush << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}



const int MAX = 30000000;
ll f[MAX],finv[MAX],inv[MAX];
void COMinit(int N){
    f[0] = 1;
    f[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=N;++i){
        f[i] = f[i-1]*i %MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) %MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int N, int K){
    if(N<K || N<0 || K <0){ return 0; }
    return f[N]*(finv[K]*finv[N-K]%MOD) %MOD;
}

void solve(){
  COMinit(3000);
  int S; cin>>S;

  ll ans = 0LL;
  ll cub = 0LL;
  while(S>=3){
    S -= 3;
    ++cub;
    ll x = COM(S+cub-1,cub-1);
    dprint(x);
    ans = (ans+x)%MOD;
  }
  cout << ans << "\n";
}
int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe";
    else cout << "safe";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll dp[22222];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    REP(i,N) cin >> A[i] >> B[i];
    REP(i,22222) dp[i] = LINF;
    dp[0] = 0;
    for(int i=1;i<22222;i++){
        REP(j,N){
            if(i - A[j] >= 0) chmin(dp[i], dp[i-A[j]] + B[j]);
        }
    }
    ll ans = LINF;
    for(int i=H;i<22222;i++) chmin(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;
int main(void){
	int N;
	cin >> N;
	for(int i=1; i<=9; i++){
		for(int j=1; j<=9; j++){
			if(N==i*j){
			cout << "Yes" << endl;
			return 0;
			}
		}
	}
	cout << "No" << endl;
	
}


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

#define   REP(i, n) for(int i = 0;            i <  (int)(n); i++)
#define  CREP(i, n) for(int i = 1;            i <= (int)(n); i++)
#define  RREP(i, n) for(int i = (int)(n) - 1; i >= 0;        i++)
#define RCREP(i, n) for(int i = (int)(n);     i >  0;        i++)

using ll = long long;

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

    std::string S;
    std::cin >> S;
    std::string year  = S.substr(S.size(), 4);
    std::string month = S.substr(S.size() - 5, 2);
    std::string day   = S.substr(S.size() - 8, 2);

    if("2019" < year) {
        std::cout << "TBD" << std::endl;
    }
    else if("2019" == year || "04" < month ) {
        std::cout << "TBD" << std::endl;
    }
    else {
        std::cout << "Heisei" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> cnt;
    rep(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    ll ans = 0;
    for(auto itr = cnt.begin(); itr != cnt.end();itr++){
        if((*itr).first <= (*itr).second)ans += (*itr).second - (*itr).first;
        else ans += (*itr).second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7040
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    int m = 1e9;
    while (t--) {
        int x;
        cin >> x;
        int a = 0, b = 0;
        for (int i = -150; i <= 150; i++) {
            for (int j = -150; j <= 150; j++) {
                if (pow(i, 5) - pow(j, 5) == x) {
                    a = i;
                    b = j;
                    break;
                }
            }
        }
        cout << a << " " << b << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const int p = 1e9+7;

ll qpow(ll a,ll b)
{
    ll res = 1 % p;
    while(b)
    {
        if(b & 1)res = res * a % p;
        b >>= 1;
        a = a * a % p;
    }
    return res;
}
ll inv(ll m)
{
    return qpow(m,p-2) %  p ;
}
ll C(ll m,ll n)
{
    if(m > n)return 0;
    ll up(1),down(1);
    for(int i = n - m + 1;i <= n;i++)up = up * i % p;
    for(int i = 1;i <= m;i++)down = down * i  % p;
    return up * inv(down);
}
ll Lucas(ll m,ll n)
{
    if(n == 0)return 1;
    return C(m % p,n % p) * Lucas(m / p,n / p) % p;
}
int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    ll ans = qpow(2,n) - 1 % p;
    ans -= (Lucas(a,n) % p + Lucas(b,n) % p) %p;
    ans = (ans % p + p) %p;
    cout << ans % p;

    return 0;
}

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

int main(){
    //ios::sync_with_stdio(false);
    int num;
    while(scanf("%d",&num)!=EOF){
    	if(num<1200)
    		printf("ABC\n");
    	else if(num<2800 && num>=1200)	
    		printf("ARC\n");
    	else
    		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{

  int n;
  long int a[250];
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  int count = 0;

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

    if (a[i] % 2 == 1) {
      flag = true;
    }
    a[i] /= 2;
  }
   if ( flag == true) {break;}
   count++;
  }
    std::cout << count << std::endl;

  return 0;
}


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

using namespace std;

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256