akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N, T;
	cin >> N >> T;
	vector<int> c(N);
	vector<int> t(N);
	int ans = intMAX;
	for(int i=0; i<N; ++i) cin >> c[i] >> t[i];
	for(int i=0; i<N; ++i){
		if(t[i] <= T) ans = min(ans, c[i]);
	}
	if(ans == 51000) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3624
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, X, T, ans = 0, count = 0 ;
  cin >> N >> X >> T ;
  ans = ( ( (N-1) / X ) + 1) * T ;
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3620
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	
	static long mod = (long)1e9+7;
	
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			/*
			for(Integer key:s.keySet()) {
				System.out.print(key);
				System.out.print(" ");
				System.out.println(s.get(key));
			}*/
			
			Map<Integer,Integer>sum = new TreeMap<Integer,Integer>();
			
			
			for(int i= N;i>=1;i--) {
				Map<Integer,Integer> s = primefact(i);
				
				for(Integer key:s.keySet()) {
					if(sum.containsKey(key)) {//含まれている
						sum.put(key, sum.get(key)+s.get(key));
					}else {
						sum.put(key, s.get(key));
					}
				}
			}
			
			long goukei = 1;
			
			for(Integer key:sum.keySet()) {
				
				goukei = (goukei*(sum.get(key)+1))%mod;
				
				/*
				System.out.print(key);
				System.out.print(" ");
				System.out.println(sum.get(key));
				*/
			}
			
			System.out.println(goukei);
			
			
			
			
		}
		
		
	}
	
	
	
	/*for(Integer key:A.keySet()) {
	System.out.println(key);//素数
	System.out.println(A.get(key));//素数の指数
	}みたいな感じで表示できる*/	
	private static Map<Integer,Integer> primefact(int n){//入力ｎの素数とその指数をmapに格納
		Map<Integer,Integer> map = new TreeMap<Integer,Integer>();
		for(int i = 2;i*i<=n;i++) {
			if(n%i!=0) {
				continue;
			}
			int ex = 0;//素因数分解した素数たちの指数
			
			while (n % i == 0) {//iでわれる限りやる
				++ex;
				n /= i;
				}		
			map.put(i, ex);//(素数、その素数の指数)
		}
		if(n!=1) {//もし最後に素数が残ったら入れておく
			map.put(n, 1);
		}
		return map;
	}
		

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



int n;
multiset<int>st;
int a[1 << 19];
signed main() {
	cin >> n;
	rep(i, 1 << n) {
		int a; cin >> a;
		st.insert(a);
	}
	a[0] = *(--st.end());
	rep(i, n) {
		for (int j = (1 << i) - 1; j >= 0; j--) {
			int next = j + (1 << i);
			if (st.upper_bound(a[j] - 1) == st.begin()) {
				cout << "No" << endl; return 0;
			}
			auto it = --st.upper_bound(a[j] - 1);
			a[next] = *it;
			st.erase(it);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
ll n,mod;
const int nax=1e5+5;
ll down[nax];
vector<vector<int>> v(nax);
ll up[nax];
int vis[nax]={0};
ll ans[nax];
void dfs2(int ci){
	vis[ci]=1;
	ll g=up[ci];
	for(auto x : v[ci]){
		if(vis[x]==1) continue;
		dfs2(x);
		g=(g*down[x])%mod;
	}
	ans[ci]=g;
}
void dfs(int ci){
	vis[ci]=1;
	ll val=1;
	for(auto x : v[ci]){
		if(vis[x]==1) continue;
		dfs(x);
		val=(val*down[x])%mod;
	}
	val++;
	val%=mod;
	down[ci]=val;
}
void dfs1(int ci){
	vis[ci]=1;
	if(ci==0) up[ci]=1;
	vector<int> t;
	for(auto x : v[ci]){
		if(vis[x]==1) continue;
		t.push_back(x);
	}
	vector<ll> pre(t.size()),suff(t.size());
	for(int i=0;i<t.size();i++){
		pre[i]=down[t[i]];
		if(i > 0) pre[i]=(pre[i]*pre[i-1])%mod;
	}
	for(int i=(int)t.size()-1;i>=0;i--){
		suff[i]=down[t[i]];
		if(i<(int)t.size()-1) suff[i]=(suff[i]*suff[i+1])%mod;
	}
	for(int i=0;i<t.size();i++){
		ll g=1;
		if(i-1 >=0 ) g*=pre[i-1];
		if(i+1<=(int)t.size()-1) g=(g*suff[i+1])%mod;
		up[t[i]]=(up[ci]*g +1 )%mod;
		dfs1(t[i]);
	}
}
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>mod;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	for(int i=0;i<n;i++) vis[i]=0;
	dfs1(0);	
	for(int i=0;i<n;i++) vis[i]=0;
	dfs2(0);
	for(int i=0;i<n;i++) cout<<ans[i]<<"\n";
}

Measured memory_bytes: 22912
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    a,b,c = map(int,input().split())
    ans = "NO"
    for i in range(1,b+1):
        if (a*i)%b==c:
            ans = "YES"
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int H,W; cin >> H >> W;
    ve_vec a(H,vec(W));
    rep(i,H) rep(j,W) cin >> a[i][j];
    veb row(H,false);
    veb col(W,false);
    rep(i,H) {
        rep(j,W){
            if(a[i][j] == '#') {
                row[i] = true;
                col[j] = true; 
            }
        }
    }
    rep(i,H) {
        if(row[i]){
            rep(j,W){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  string s;
  cin >> s ;
  long long int count_b = 0;
  long long int sum = 0;
  for (int i = 0; i < (int)s.length(); i++){
    if (s[i]=='B'){
      count_b++;
    }else{
      sum += count_b;
    }
  }
  cout << sum;
  return 0;
}

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

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

// ===============================================================================

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll ans = INFL;
  for (int i = 0; i + k - 1 < n; i++) {
    ll l = v[i], r = v[i + k - 1];
    ans = min(ans, min(abs(l) + abs(r - l), abs(l - r) + abs(r)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  while(cin>>n){
    ll sum=0;
    vi a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    rep(i,n-1)a[i+1]+=a[i];
    rep(i,n)sum+=a[i];
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct node{
    int p, l, r;
};

node t[MAX];
int n, d[MAX];

int AllDepth(int u, int p){
    d[u] = p;
    if(t[u].r != NIL) AllDepth(t[u].r, p);
    if(t[u].l != NIL) AllDepth(t[u].l, p+1);
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        t[i].p = NIL;
        t[i].l = NIL;
        t[i].r = NIL;
    }
    int id, k, c, f, r;
    for(int i = 0; i < n; i++) {
        cin >> id >> k;
        for(int j = 0; j < k; j++) {
            cin >> c;
            if(!j) t[id].l = c;
            else t[f].r = c;
            f = c;
            t[c].p = id;
        }
    }
    for(int i = 0; i < n; i++) if(t[i].p == NIL) r = i;
    AllDepth(r, 0);
    for(int i = 0; i < n; i++) {
      int u = i;
      cout << "node " << u;
      cout << ": parent = " << t[u].p;
      cout << ", depth = " << d[u] << ", ";
      if(t[u].p == NIL) cout << "root, ";
      else if(t[u].l == NIL) cout << "leaf, ";
      else cout << "internal node, ";
      cout << "[";
      for(int i = t[u].l; i != NIL; i = t[i].r){
          if(i != t[u].l)cout << ", ";
          cout << i;
      }
      cout << "]" << endl;
    }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string n; cin>>n;
  
  int sum = 0;
  int num = stoi(n); 
  
  int size = n.length();
  
  rep(i, size) {
    char c = n[i];
    sum += c - '0';
  }
  
  if(num%sum==0) cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
	int w,h,n,x,y,a;
	cin>>w>>h>>n;
	vector<int> v[4];
	rep(i,n){
		cin>>x>>y>>a;
		v[a-1].pb(((a<3)?x:y));
	}
	rep(i,4)if(v[i].size()>0)sort(all(v[i]));
	int l[4];
	l[0]=(v[0].size())?v[0][v[0].size()-1]:0;
	l[1]=(v[1].size())?v[1][0]:w;
	l[2]=(v[2].size())?v[2][v[2].size()-1]:0;
	l[3]=(v[3].size())?v[3][0]:h;
	cout<<((l[1]-l[0]>0 && l[3]-l[2]>0)?(l[1]-l[0])*(l[3]-l[2]):0)<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    vector<vector<ll>>dp(n,vector<ll>(3));
    for (ll i = 0;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        if (i==0){dp[i][0] = a;dp[i][1] = b;dp[i][2] = c;continue;}
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}

Measured memory_bytes: 5760
nim, mike, kite = map(int, input().split())
H = [int(input()) for _ in range(nim)]
C = mike - kite
l, r = 0, 1<<30
while r - l > 1:
    m = (l + r) // 2
    if sum([max((h - kite * m + C - 1) // C, 0) for h in H]) <= m:
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 11060
#B
"""
def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")
"""

#C
k, a, b = map(int, input().split())

if a + 1 >= b:
    print(k + 1)
else:
    ans = k - 2*((k-(a-1))//2) + 1 + (b-a) * ((k - (a - 1)) // 2)
    print(ans)

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

const long long MOD = 1000000007;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll S) {
  vector<ll> dp(S + 1, 0);

  dp.at(0) = 1;
  FOR(i, 1, S + 1) {
    FOR(j, 0, i - 2) {
      dp.at(i) += dp.at(j);
      dp.at(i) %= MOD;
    }
  }

  cout << dp.at(S) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll S;
  scanf("%lld", &S);
  solve(S);
  return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>

int main(){

    int total=0;
    int count=0;
    int rows;
    scanf("%d", &rows);
    int columns;
    scanf("%d", &columns);
    int blokHitam;
    scanf("%d", &blokHitam);
    while(total<blokHitam){
        if(rows>=columns){
            total+=rows;
//            printf("sekarang total blok hitam= %d\n", total);
        }
        else if(columns>=rows){
            total+=columns;
//            printf("sekarang total blok hitam= %d\n", total);
        }
    count++;
    }
printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> s(m), c(m);
    vector<int> selected_number(4, -1);
    bool flag = true;
    for (int i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        if (selected_number[s] != -1 && selected_number[s] != c)
        {
            flag = false;
            break;
        }
        selected_number[s] = c;
    }
    if (n != 1 && selected_number[1] == 0)
        flag = false;

    int sum = 0;
    if (n > 1 && selected_number[1] == -1)
        sum += pow(10, n - 1);
    for (int i = 1; i <= 3; i++)
    {
        if (selected_number[i] != -1)
            sum += selected_number[i] * pow(10, n - i);
    }

    if (flag)
        cout << sum << endl;
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, i;
    long s;

    scanf("%d",&n);

    s = 0;
    for(i=1; i<=n; i++){
        if((i%3 != 0)&&(i%5 != 0))
            s = s + i;
    }
    printf("%ld\n",s);
    return 0;
}

Measured memory_bytes: 1692
H, W = map(int, input().split())

M = [list(map(lambda x:0 if x == "#" else -1, input())) for _ in range(H)]

def set(i, j, x):
    if x < 0 or M[i][j] == 0:
        return
    x += 1
    if M[i][j] < 0:
        M[i][j] = x
    else:
        M[i][j] = min(M[i][j], x)

for i in range(H):
    for j in range(W):
        if j > 0:
            set(i, j, M[i][j-1])
        if i > 0:
            set(i, j, M[i-1][j])

for i in range(H-1, -1, -1):
    for j in range(W-1, -1, -1):
        if j < W-1:
            set(i, j, M[i][j+1])
        if i < H-1:
            set(i, j, M[i+1][j])

print(max(y for x in M for y in x))


Measured memory_bytes: 58332
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(a int64, b int64) int64 {
	return (b - 1 + a -2)/ (a -1)
}

func main() {
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	res := solve(a, b)
	fmt.Fprintln(out, res)
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 1772
#include<iostream>
using namespace std;
int main(){
    int K,S;
    cin >> K >> S ;
    int x,y,z,answer;
    answer=0;
    for(x=0;x<=K;x++){
        for(y=0;y<=K;y++){
            z=S-x-y;
            if(0<=z and z<=K){
                answer=answer+1;
            }
            
        }
    }
    cout<<answer<<endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n;
vector<int> c[400];
ll chash[400];
int dup[400]; // 重複回数

inline ll get_hash(vector<int> v) {
	ll res = INF;
	REP(i, 4) {
		chmin(res, v[0] * 1000000000ll + v[1] * 1000000ll + v[2] * 1000ll + v[3]);
		rotate(v.begin(), v.begin() + 1, v.end());
	}
	return res;
}

int main() {
	cin >> n;
	REP(i, n) {
		c[i].resize(4);
		REP(j, 4) scanf("%d", &c[i][j]);
		
		if (c[i][0] == c[i][2] && c[i][1] == c[i][3]) {
			if (c[i][0] == c[i][1]) dup[i] = 4;
			else dup[i] = 2;
		}
		else dup[i] = 1;
		
		chash[i] = get_hash(c[i]);
	}
	
	map<ll,  int> pat[5]; // 各タイルを正規化したもののそれぞれの個数
	REP(i, n) pat[ dup[i] ][ chash[i] ]++;
	
	ll ans = 0;
	
	REP(i, n) FOR(j, i + 1, n) {
		if (i == j) continue;
		
		vector<int> v(8); // 各頂点の色
		REP(k, 4) v[k] = c[i][k];
		
		REP(p, 4) {
			
			REP(k, 4) v[k + 4] = c[j][(k + p) % 4];
			
			int dd[4][4] = { {1,0,7,6}, {0,3,4,7}, {2,1,6,5}, {3,2,5,4} };
			
			map<ll, int> now; // 各方向から見た色の配置
			REP(k, 4) {
				vector<int> u(4);
				REP(l, 4) u[l] = v[dd[k][l]];
				now[get_hash(u)]++;
			}
			
			ll add = 1;
			
			for (map<ll, int>::iterator it = now.begin(); it != now.end(); ++it) {
				bool ng = true;
				
				REP(k, 5) {
					ll cnt = pat[k][it->first];
					
					if (dup[i] == k && chash[i] == it->first) cnt--;
					if (dup[j] == k && chash[j] == it->first) cnt--;
					
					if (cnt < it->second) continue;
					
					ng = false;
					
					REP(l, it->second) {
						add *= (cnt - l) * k;
					}
				}
				
				if (ng) { add = 0; break; }
			}
			
			ans += add;
			
		}
	}
	
	
	cout << ans / 3 << endl;
	return 0;
}

Measured memory_bytes: 100096
#include <functional>
#include <numeric>
#include <cstring>
#include <iostream>
using namespace std;

const int M = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
#if 1
    int cnt[n+1];
    cnt[0] = 0;
    for (int i = 0; i < n; i++) cnt[i+1] = cnt[i] + (s[i] == '0');
    int R[n+1];
    iota(R, R+n+1, 0);
    for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r;
        R[l] = max(R[l], r);
    }
    for (int i = 1; i <= n; i++) R[i] = max(R[i], R[i-1]);
    long long dp[2][n+1];
    int cur = 0, prev = 1;
    memset(dp, 0, sizeof dp);
    dp[prev][0] = 1;
    for (int i = 1; i <= n; i++) {
        fill(dp[cur], dp[cur]+n, 0);
        if (R[i] < i) continue;
        const int s = cnt[R[i]] - cnt[R[i-1]];
        // cerr << i << " " << s << endl;
        for (int k = 0; k <= n && k+s-1 <= n; k++) {
            if (0 <= k + s - 1) dp[cur][k+s-1] += dp[prev][k];
            if (k + s < R[i] - i + 1) dp[cur][k+s] += dp[prev][k];
        }
        for (int k = 0; k <= n; k++) dp[cur][k] %= M;
        swap(cur, prev);
        // for (long long x : dp[prev]) cerr << x << " "; cerr << endl;
    }
    cout << dp[prev][0] << endl;
#else
    int l[m], r[m];
    for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
    int ans = 0;
    function<bool(int)> check = [&](int ss) {
        int c0 = 0, c1 = 0, j = 0, R = 0;
        for (int i = 0; i < n; i++) {
            while (l[j] == i + 1) {
                while (R < r[j]) {
                    if (s[R] == '0') c0++; else c1++;
                    R++;
                }
                j++;
            }
            while (R <= i) {
                if (s[R] == '0') c0++; else c1++;
                R++;
            }
            if ((ss >> i) & 1) {
                if (c1 == 0) return false;
                else c1--;
            } else {
                if (c0 == 0) return false;
                else c0--;
            }
        }
        return true;
    };

    for (int s = 0; s < 1<<n; s++) if (check(s)) ans++;
    cout << ans << endl;
#endif
}


Measured memory_bytes: 3300
#include <iostream>
#include<stdio.h>
using namespace std;
 
int main(){
  int x,y,i;
  int idou[5];
  idou[0]=0;
  for(i=1;i<=4;i++)
    {
      scanf("%d",&idou[i]);
      idou[0]=idou[0]+idou[i];
    }

      y=idou[0]%60;

      x=idou[0]/60;

      printf("%d\n%d\n",x,y);
    
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstring>
#include <vector>
#include <string>

using namespace std;

int dp[1001][8];
vector<int> ss;
int n;

int saiki(int d,int stat){
    if(dp[d][stat] > -1) return dp[d][stat];
    if(n == d) {
	return dp[d][stat] = 1;
    }
    long long int ans = 0;
    for(int i=0;i<8;i++){
	if( (stat & i) != 0 && ( ( i & (1 << ss[d]) ) != 0) ){
	    ans += saiki(d+1,i) % 10007;
	}
    }
    return dp[d][stat] = ans;
}

int main(){

    string s;
    memset(dp,-1,sizeof(dp));
    cin >> n;
    cin >> s;
    for(int i=0;i<s.size();i++){
	int temp;
	if(s[i] == 'J') temp = 0;
	else if(s[i] == 'O') temp = 1;
	else if(s[i] == 'I') temp = 2;
	ss.push_back(temp);
    }
    int ans = 0;
    for(int i=0;i<4;i++){
	if( ( (1<<ss[0]) & 2*i+1) != 0 )
	    ans +=  saiki(1,2*i+1) % 10007; 
    }
    ans %= 10007;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
using namespace std;
int data[3][100005];
int rdata[100005],flag[100005];
int _abs(int a)
{
    return a>0?a:-a;
}
int dfs(int a)
{
    flag[a]=1;
    int nex=rdata[a];
    if(flag[nex])return 1;
    else return 1+dfs(nex);
}
int main()
{
    int n;
    scanf("%d",&n);
    rep(j,0,3)rep(i,1,n+1)scanf("%d",&data[j][i]);
    rep(i,1,n+1)
    {
        if(data[1][i]%3!=2)
        {
            puts("No");
            return 0;
        }
        rdata[i]=(data[1][i]+1)/3;
    }
    rep(i,1,n+1)if((data[0][i]+2)/3!=rdata[i]||(data[2][i]+2)/3!=rdata[i])
    {
        puts("No");
        return 0;
    }
    rep(i,1,n+1)if(rdata[i]%2!=i%2)
    {
        puts("No");
        return 0;
    }
    long long cnt[2]={0,0},nxd[2]={0,0};
    rep(i,1,n+1)if(data[0][i]%3==0)cnt[i%2]++;
    rep(i,1,n+1)if(!flag[rdata[i]])nxd[i%2]+=(dfs(rdata[i])%2)^1;
    if(cnt[0]%2==nxd[1]%2&&cnt[1]%2==nxd[0]%2)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 2176
N = int(input())
s = [input() for _ in range(N)]

ans = 0
num_a = 0
num_b = 0
num_ba = 0
num_ab = 0
for i in s:
    if(i[-1]=='A' and i[0]=='B'):
        num_ba += 1
    elif(i[-1]=='A'):
        num_a+=1
    elif(i[0]=='B'):
        num_b+=1
    last = ''
    for k in i:
        if(k=='A'):
            last = 'A'
        elif(last == 'A' and k=='B'):
            num_ab += 1
            last = ''
        else:
            last = ''

ans += num_ab

num_conn = min(num_a,num_b)
if(num_a!=num_b and num_ba!=0):
    ans+=num_ba+num_conn
elif(num_ba==0):
    ans+=num_conn
elif(num_a==0 and num_b==0):
    ans+=num_ba-1
else:
    ans+=num_ba+num_conn
print(ans)


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2)) <= (double) d) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

using namespace std;
#define int long long
#define N 1666666

signed main(){
	int l,r,d;cin>>l>>r>>d;
	int s=0;
	for(int i=l;i<=r;i++)
		if(i%d==0) s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 1.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    vector<int> g[n];
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, 0, n)
    {
        bool ok1 = false, ok2 = false;
        for (int j : g[i])
        {
            if (j == 0)
                ok1 = true;
            if (j == n - 1)
                ok2 = true;
        }
        if (ok1 && ok2)
        {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}

Measured memory_bytes: 12016
n = int(input())

s = input().split()

s = [int(x) for x in s]

x_max = max(s)
x_min = min(s)


    
    
def ex(pnt):
    sm = 0
    for j in s:
        sm += (pnt - j)**2
    
    return sm

result = 10 **9

for i in range(x_min,x_max+1):
    koho = ex(i)
    if(result > koho):
        result = koho

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int g = 0;
    rep(i, 2){
        if(a > b){
            g+= a;
            a --;
        }
        else{
            g+= b;
            b--;
        }
    }
    cout << g << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

#define MAX 100
#define Infty 9999999999
using namespace std;

int n,e;
long long d[MAX][MAX];

void floyd(){
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            if (d[i][k]==Infty)
                continue;
            for (int j = 0; j < n; ++j) {
                if (d[k][j]==Infty)
                    continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main() {
    scanf("%d %d",&n,&e);
    int s,t,v;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            d[i][j]=((i==j)?0:Infty);
        }
    }

    for (int k = 0; k < e; ++k) {
        scanf("%d %d %d",&s,&t,&v);
        d[s][t]=v;
    }
    floyd();

    bool negative=false;
    for (int l = 0; l < n; ++l) {
        if (d[l][l]<0)
            negative= true;
    }

    if (negative)
        cout<<"NEGATIVE CYCLE"<<endl;
    else{
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (j)
                    cout<<" ";
                if (d[i][j]==Infty)
                    cout<<"INF";
                else
                    cout<<d[i][j];
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3312
local s = io.read("*l")
local t = io.read("*l")

local s_bytes = {s:byte(1, s:len())}
local t_bytes = {t:byte(1, t:len())}
table.sort(s_bytes)
table.sort(t_bytes, function(x, y) return x > y end)

local diff_value = -1
for i = 1, math.min(#s_bytes, #t_bytes) do
    if s_bytes[i] ~= t_bytes[i] then
        diff_value = i
        break
    end
end

local is_yes = false
if diff_value == -1 then
    if #s_bytes < #t_bytes then
        is_yes = true
    end
else
    if s_bytes[diff_value] < t_bytes[diff_value] then
        is_yes = true
    end
end

print(is_yes and "Yes" or "No")

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

int main() {
  int red, green, blue, count;
  string result;
  
  cin >> red >> green >> blue;
  cin >> count;
  
  result = "No";
  
  for (int i=0; i<=count; i++) {
    if(red >= green) {
      green = green * 2;
    } else if(green >= blue) {
      blue = blue * 2;
    } else {
      result = "Yes";
    }
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		int ans = 0;
		for(int i = 0; i < 4; i++) {
			if(S.charAt(i) == '+') {
				ans ++;
			}else {
				ans --;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=1e10;
    for(ll i=-100; i<=100; i++){
        ll tmp=0;
        rep(j,n) tmp+=(i-a[j])*(i-a[j]);
        chmin(res, tmp);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
dp = [0] * (W + 1)
for i in range(N):
    vi, wi = map(int, input().split())
    for w in range(W + 1):
        if w - wi >= 0:
            dp[w] = max(dp[w], dp[w - wi] + vi)

print(dp[W])


Measured memory_bytes: 5920
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	ll k; cin>>k;
	string a; cin>>a;
	ll y = 'Z';
	lp(i,0,sz(a)){
		ll t = a[i] + k;
		if(t > 'Z') t-=26;
		a[i] = char(t%(y+1));
		cout<<a[i];
	}
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main() {
    string num, name;
    int pick;
    priority_queue<int> pickles;
    while(cin >> num && num != "end" ) {
        if (num == "insert") {
            cin >> pick;
            pickles.push(pick);
        } else {
            cout  << pickles.top() << endl;
            pickles.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 7016
fun main(args: Array<String>) {
  val K = readInt()
  var sum = 0L
  for (i in 1..K) {
    for (j in 1..K) {
      for (k in 1..K) {
        val list = listOf(i, j, k).sorted()
        val a = list[0]
        val b = list[1]
        val c = list[2]
        val gcdAB = gcd(a, b)
        val gcdAll = gcd(gcdAB, c)
        sum += gcdAll
      }
    }
  }
  println(sum)
}

fun gcd(a: Int, b: Int): Int {
  if (a < b) return gcd(b, a)
  if (b == 0) return a
  return gcd(b, a % b)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 58508
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int asum = 0;
		int bsum = 0;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Integer[] A = new Integer[n];
		for (int i = 0; i < n; i++) {
			A[i] = a[i];
		}
		Arrays.sort(A, Comparator.reverseOrder());
		for (int i = 0; i < n; i++) {
			if (i%2==0) {
				asum += A[i];
			} else {
				bsum += A[i];
			}
		}
		System.out.println(asum-bsum);
	}
}


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

int main() {
	int N,K;
	cin >> N >> K;

	string ac = "1111111111";
	for(int i=0; i<K; i++) {
		int x; 
		cin >> x;
		ac[x] = '0';
	}

	int mx = N;
	while (true) {
		string ss = to_string(mx);
		
		bool hantei = true;
		for(int j=0; j<ss.size(); j++) {
			if (ac[ss[j] -'0'] == '0') {
				hantei = false;
				break;
			}
		}
		if (hantei) {
			break;
		} else {	
			mx++;
		}
	}
	
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    ll n;
    cin>>n;
    vector<ll>A(n+1);
    for(int i=1;i<=n;i++) cin>>A[i];
    map<ll,ll>mp;
    for(int i=1;i<=n;i++)
    mp[-A[i]-i]++;
    ll ans=0;
    for(int j=1;j<=n;j++)
    ans+=mp[A[j]-j];
    cout<<ans;
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 27388
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int N;
int A[1000005];

void insertionSort(int g,int& cnt)
{
	FOR(i, N, g)
	{
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort()
{
	int cnt = 0;
	vector<int> G;
	int n = N;
	while (n > 0)
	{
		G.push_back(n);
		n /= 2;
	}
	int m = G.size();
	REP(i, m)
	{
		insertionSort(G[i], cnt);
	}
	cout << m << endl;
	REP(i, m)
	{
		cout << G[i];
		if (i == m - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	cout << cnt << endl;
	REP(i, N)
	{
		cout << A[i] << endl;
	}
}

int main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	shellSort();

	return 0;
}


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

int memo[20][20]={0};

int rec(int h,int w){
  if(memo[h][w]!=-1) return memo[h][w];
  memo[h][w] = rec(h-1,w) + rec(h,w-1);
  return memo[h][w];
}

int main(){


  while(1){
    for(int i=1;i<20;i++){
      for(int j=1;j<20;j++){
	memo[i][j]=-1;
      }
    }
    
    int h,w,n;
    scanf("%d %d",&w,&h);
    if(w==0 && h==0) break;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      memo[b][a]=0;
    }
    
    memo[1][0]=1;
    
    printf("%d\n",rec(h,w));

  }  

  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
int main() {
  int A;
  int B;
  int N = 1;
  int ans;
  scanf("%d",&A);
  scanf("%d",&B);
  if (B==1) {
    printf("%d\n",0);
    return 0;
  }
  for (int i=1; i<20; i++) {
    if (1+(A*i)-i>=B) {
      printf("%d\n",i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <functional>

using namespace std;

template<typename T>
struct segment_tree {
    using F = function<T(T, T)>;

    int n;
    vector<T> node;
    F merge;
    T identity;

    segment_tree(int n, F merge, T identity)
        : n(n), node(n<<1, identity), merge(merge), identity(identity) {}

    T operator[](int i) { return node[i + n]; }

    void set(int i, T x) {
        node[i += n] = x;
        while (i >>= 1) node[i] = merge(node[i<<1|0], node[i<<1|1]);
    }

    T fold(int l, int r) {
        T res = identity;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) res = merge(res, node[l++]);
            if (r & 1) res = merge(node[--r], res);
        }
        return res;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    auto merge = [](int a, int b) { return min(a, b); };
    segment_tree<int> seg(n, merge, INT_MAX);
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) cout << seg.fold(x, y+1) << '\n';
        else seg.set(x, y);
    }
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

int n;
int a[105];

vector<int> v;

ll dfs(int count){
    if (count == n){
        bool flag = false;
        for (int i = 0; i < n; i++){
            if (v[i] % 2 == 0){
                flag = true;
            }
        }

        if (flag){
            return 1;
        }
        else{
            return 0;
        }
    }
    ll ret = 0;
    for (int i = -1; i <= 1; i++){
        v.push_back(a[count] + i);
        ret += dfs(count + 1);
        v.pop_back();
    }
    return ret;
}

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

    sort(a, a + n);

    cout << dfs(0) << endl;



}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int n,count;
void selectSort(int a[])
{
	int min;
	for(int i=0;i<n;i++)
	{
		min=i;
		for(int j=i;j<n;j++)
		{
			if(a[j]<a[min])
			{
				min=j;
			}
		}
		if(i!=min)
		{
			swap(a[i],a[min]);
			count++;
		}
	}
}
void print(int a [])
{
	for(int i=0;i<n;i++)
	{
		if(i>0) cout<<' ';
		cout<<a[i];
	}
	cout<<endl<<count<<endl;
}
int main()
{
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	selectSort(a);
	print(a);
	return 0;
}


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

using namespace std;

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

    int ans=0;
    for(int i=9;i<=n;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) cnt++;
            if(cnt>8) break;
        }
        if(cnt==8) ans++;
        cnt=0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get
stack=[]
S.each do|s|
  if s=="+"
      val2=stack.pop
      val1=stack.pop
      stack.push(val1+val2)
  elsif s=="-"
      val2=stack.pop
      val1=stack.pop
      stack.push(val1-val2)
  elsif s=="*"
      val2=stack.pop
      val1=stack.pop
      stack.push(val1*val2)
  else
      stack.push(s.to_i)
  end
end
puts stack


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

long    Pat(long N, long X, vector<long> &T, vector<long> &P) {
        if (N==0) return 0;
        long H=(T.at(N)-1)/2;
        if (T.at(N)-X<2) return P.at(N);
        else if (X-H>1) return (Pat(N-1, X-(T.at(N)+1)/2, T, P)+1+P.at(N-1));
        else if (X-H==1) return (1+P.at(N-1));
        else if (X-H==0) return P.at(N-1);
        else return Pat(N-1, X-1, T, P);
}

int     main() {
        long N, X;
        cin >>N >>X;
        vector<long> T(51);
        vector<long> P(51);
        T.at(0)=P.at(0)=1;
        for (long i=1; i<51; i++) {
                T.at(i)=T.at(i-1)*2+3;
                P.at(i)=P.at(i-1)*2+1;
        }
        cout << Pat(N, X, T, P) << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
    // Your code here!
   int A,B,C;
   cin>>A>>B>>C;
   if(B/A>=C){cout<<C;}
   else cout<<B/A;
   return 0;
    
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try{

            int x = Integer.parseInt(br.readLine());

            System.out.println( x * x * x );

        }catch(IOException e){
            System.out.println(e);
        }

    }
}


Measured memory_bytes: 24232