akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a, b, sub;
    rep(i, n){
        ll temp;
        cin >> temp;
        a.pb(temp);
    }
    rep(i, n){
        ll temp;
        cin >> temp;
        b.pb(temp);
    }
    rep(i, n){
        ll temp;
        temp = a[i] - b[i];
        sub.pb(temp);
    }
    sort(ALL(sub));
    ll index = sub.size() - 1, ans = 1;
    bool flag1 = false;
    rep(i, n){
        if(sub[i] < 0){
            flag1 = true;
            ans++;
            bool flag = true;
            while(flag){
                if(sub[index] < 0){
                    print(-1);
                    return 0;
                }
                if(0 < sub[index] + sub[i]){
                    sub[index] += sub[i];
                    sub[i] = 0;
                    flag = false;
                } else if(0 == sub[index] + sub[i]){
                    sub[i] = 0;
                    sub[index] += sub[i];
                    flag = false;
                    index--;
                    ans++;
                }else{
                    sub[i] += sub[index];
                    sub[index] = 0;
                    ans++;
                    index--;
                }
            }
        } else{
            if(flag1){
                print(ans);
            } else{
                print(0);
            }
            return 0;
        }
    }
    print(-1);
}

Measured memory_bytes: 3316
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range (D)]
M = 26
INF = 10**20

def judge(t):
    last = [0]*M
    score = 0
    for i in range(D):
        score += S[i][t[i]-1]
        last[t[i]-1] = i+1
        for m in range(M):
            score -= C[m]*(i+1-last[m])
    return score

from random import randint
import time
start = time.time()
ans = [0]*D
lasts = [0]*(M+1)


score = 0
for i in range(D):
    contest = 0
    max_score = -INF
    for m in range(M):
        new_score = score
        new_score += S[i][m]
        for m2 in range(M):
            if m==m2:continue
            new_score -= C[m2]*(i+1-lasts[m2])
        if new_score>max_score:
            contest = m+1
            max_score = new_score
    
    ans[i] = contest
    lasts[contest-1] = i+1
    score = max_score

while (time.time()-start<1.5):
    # 解を変更
    new_ans = [a for a in ans]
    idx = randint(0,D-1)
    val = randint(1,26)
    new_ans[idx] = val
    # スコアが上がっているか？
    new_score = judge(new_ans)
    if new_score>score:
        score = new_score
        ans[idx] = val

for a in ans:
    print(a)

Measured memory_bytes: 81380
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long int hoge(int n){
	if(n==0) return 1;
	if(n==1) return 2;
	return hoge(n/2)*hoge(n-n/2);
}
int main(){
	int n,a;
	cin>>n>>a;
	vector<int> x(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
		x[i]-=a;
	}
	sort(x.begin(),x.end());
	/*
	for(int i=0;i<x.size();i++){
		cout<<x[i]<<endl;
	}
	*/
	vector<int>minus(3000,0);
	vector<int>plus(3000,0);
	minus[0]=1;
	plus[0]=1;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(x[i]<0){
			for(int j=2999+x[i];j>=0;j--){
				minus[j-x[i]]+=minus[j];
			}
		}else if(x[i]==0){
			cnt++;
		}else{
			for(int j=2999-x[i];j>=0;j--){
				plus[j+x[i]]+=plus[j];
			}
		}
	}
	long long int sum=0;
	for(int i=0;i<3000;i++){
		sum+=(long long int)minus[i]*plus[i];
	}
	/*
	cout<<"minus\n";
	for(int i=0;i<3000;i++){
		if(minus[i]!=0){
			cout<<i<<" "<<minus[i]<<endl;
		}
	}
	cout<<"plus\n";
	for(int i=0;i<3000;i++){
		if(plus[i]!=0){
		cout<<i<<" "<<plus[i]<<endl;
		}
	}
	*/
	sum*=hoge(cnt);
	cout<<sum-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
typedef long long ll;
using namespace std;

int main(){
    ll N, ans;   cin >> N;
    ans = 0;
    if(N%2==0){
        for(int j=1; j<=25; j++){
          ans += N/10;
          N /= 5;
        }
    }
    cout << ans;
}

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

int main() {
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = i; j > 0; j /= 10) {
      sum += j % 10;
    }
    if (a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
}

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

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

using namespace std;

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

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

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll m;
  cin >> m;

  ll n = 0, s = 0;
  rep(i, m) {
    ll d, c;
    cin >> d >> c;
    n += c;
    s += d * c;
  }

  ll beg = (9 * n + s);
  ll chk = (beg - 9) % 9;
  ll end;
  if (chk == 0)
    end = 18;
  else
    end = chk + 9;
  ll ans = (beg - end) / 9;
  cout << ans << endl;

  return 0;
}


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

int main(int argc, char const *argv[])
{
	long n, a, b;

	cin >> n >> a >> b;

	if( (a > b) || (n == 1 && a != b) )
		cout << "0";
	else
		cout << (b - a) * (n - 2) + 1;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100005
#define INF 0x3f3f3f3f
using namespace std;

int n, k;
vector<int> bef, aft;

int getBest(int d1, int d2) {
    return d1 + d2 + min(d1, d2);
}

int main() {
    ios::sync_with_stdio(0);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (x < 0)
            bef.push_back(x);
        else if (x > 0)
            aft.push_back(x);
        else
            --k;
    }
    if (k == 0) {
        cout << "0\n";
        return 0;
    }

    reverse(bef.begin(), bef.end());
    
    int sol = INF;
    if (bef.size() >= k)
        sol = -bef[k - 1];
    if (aft.size() >= k)
        sol = min(sol, aft[k - 1]);

    if (bef.empty() || aft.empty()) {
        cout << sol << "\n";
        return 0;
    }

    int i = min(k - 2, (int) bef.size() - 1);
    int j = k - 2 - i;

    while (i >= 0 && j < (int) aft.size()) {
        sol = min(sol, getBest(-bef[i], aft[j]));
        --i, ++j;
    }

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 1020
import sys
from operator import add

n = int(sys.stdin.readline().strip())
A = [ [0] for i in range(n)]
for i in range(n):
	temp = map(int ,sys.stdin.readline().strip().split(" "))
	A[i] = temp


weight = [None for i in range(n)]
mitayatu=[False for i in range(n)]

def min(array):
	temp = 100000
	index= 0
	for i in range(n):
		if array[i] is not None and mitayatu[i]==False:
			if temp>=array[i]:
				temp = array[i]
				index = i
	return index

def owari():
	for i in mitayatu:
		if i is False:
			return False
	return True
# zero origin
def prim(nodeid):
	#print(nodeid)
	if owari() == True:
		return
	if mitayatu[nodeid]==True:
		return
	mitayatu[nodeid]=True
	for i in range(n):
		if A[nodeid][i]!=-1:
			if weight[i] is None:
				weight[i]=A[nodeid][i]
			elif weight[i]>A[nodeid][i] and mitayatu[i]==False:
				weight[i]=A[nodeid][i]
	prim(min(weight))

weight[0]=0
prim(0)

#print(weight)
print(reduce(add, weight))

Measured memory_bytes: 6768
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int r,c,i,j,len,yoko[1200],yokosum=0,data[101][101]={0};
	long int rSum[101]={0},cSum=0,allSum=0;

	scanf("%d %d",&r,&c);

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&data[i][j]);
		}
	}

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cSum+=data[i][j];
			allSum+=data[i][j];
			rSum[j]+=data[i][j];
			printf("%d ",data[i][j]);
		}
		printf("%d\n",cSum);
		cSum=0;
	}
	
	for(i=0;i<c;i++){
		printf("%d ",rSum[i]);
	}
	printf("%d\n",allSum);
	
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	ll a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')
		cout<<a+b<<endl;
	else
		cout<<a-b<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
////////////////////////////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
////////////////////////////////////////////////////////////////////


int N,K; 
vector<int> a;
bool dp[5102][5102] = {};

bool check(int i){
    vector<int> S;
    S.PB(0); // 1-indexed
    REP(j,N){
        if (i==j) continue;
            S.PB(a[j]);
        }

        FORq(j,0,K){
            dp[0][j] = false;
        }

        dp[0][0] = true;

        FORq(x,1,N-1){
            FORq(y,0,K){
                if (y-S[x] < 0) dp[x][y] = dp[x-1][y];
                else dp[x][y] = ((dp[x-1][y]) or (dp[x-1][y-S[x]]));
                //printf("dp[%d][%d] = %d\n",x,y,dp[x][y]);
            }
        }

        FORq(k,max(0,K-a[i]),K-1){
            if (k < 0) continue;
            if (dp[N-1][k]) {
                return true;
            }
        }
    return false;
}

int binary_search(int key){
	// lower_bound
	// <= left never satisfy
	// right <= always satisfy

	int left = -1; 
	int right = N; // index of size + 1;

	while(right - left > 1){
			int mid = left + (right - left) / 2;

			if (check(mid)) right = mid;
			else left = mid;
	}

	// left is the maximum that don't satisfy the condition.
	// right is the minimum that satisfies the condtion.
	
	return right; 

}

int main(){
    SCD2(N,K);
    VSCD(a,N);
    sort(ALL(a));
    PRINTD(binary_search(1));

}


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

long long MOD=1000000007LL;

long long fac[1000000],finv[1000000],inv[1000000];

long long dp[1111][1111];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<1000000;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

long long COM(int n,int k){
	if(n<k)return 0;
	if(n<0 || k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	int N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	
	COMinit();
	
	for(int i=0;i<=N;i++)dp[i][0]=1;
	for(int i=1;i<=N;i++)for(int j=0;j<=N;j++){
		dp[i][j]=dp[i-1][j];
		if(i<A || i>B)continue;
		for(int k=C;k<=min(D,j/i);k++){
			long long add=dp[i-1][j-i*k]*COM(N-(j-i*k),i*k);
			add%=MOD;
			add*=fac[i*k];
			add%=MOD;
			add*=MODpow(finv[i],k);
			add%=MOD;
			add*=finv[k];
			add%=MOD;
			dp[i][j]+=add;
			dp[i][j]%=MOD;
		}
	}
	cout << dp[N][N] << endl;
	return 0;
}

Measured memory_bytes: 33280
#include <stdio.h>

int main(void){

  int n,m;
  scanf("%d %d", &n, &m);
  char a[n][n+1];
  char b[m][m+1];
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%s", b[i]);
  }

  int match = 0;
  int flag;
  for (int i = 0; i < n-m+1; i++) {
    for (int j = 0; j < n-m+1; j++) {
      flag = 0;
      for (int row = 0; row < m; row++) {
        for (int column = 0; column < m; column++) {
          if (a[i+row][j+column] != b[row][column]) {
            flag = 1;
            break;
          }
        }
        if (flag == 1) {
          break;
        }
      }
      if (flag == 0) {
        match = 1;
      }
      if (match == 1) {
        break;
      }
    }
    if (match == 1) {
      break;
    }
  }
  if (match == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let f1 = floor (float n /. 1.08) in
        let f2 = ceil  (float n /. 1.08) in
        let b1 = int_of_float (floor (f1 *. 1.08)) in
        let b2 = int_of_float (floor (f2 *. 1.08)) in
        if b1 = n then Printf.printf "%d\n" (int_of_float f1) else
        if b2 = n then Printf.printf "%d\n" (int_of_float f2) else print_endline ":("
    in
    main ()

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_78B(){
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    int ctr = 0;
    while(1){
        x -= (y + z);
        if(x < 0) break;
        ctr++;
    }
    cout << ctr << endl;
}

int main(void){
    solve_78B();
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i=0; i<N; i++) cin >> W[i];

  string ans = "Yes";
  vector<string> E;
  E.push_back(W[0]);
  for (int i=1; i<N; i++) {
    if (W[i][0] == W[i-1][W[i-1].size()-1]) {
      if (find(E.begin(), E.end(), W[i]) == E.end()) {
        E.push_back(W[i]);
      } else {
        ans = "No";
        break;
      }
    } else {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
long long v[50],c[50];
using namespace std;
int main(){
	long long n,res=0;
	cin>>n;
	for (int i=0;i<n;i++) cin>>v[i];
	for (int i=0;i<n;i++) cin>>c[i];
	for (int i=0;i<n;i++)
		if (v[i]>c[i]) res+=(v[i]-c[i]);
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


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

  if(k%2==1){
    ll a=n/k;
    cout<<a*a*a<<endl;
  }else{
    ll a=n/(k/2);
    ll b=n/k;
    a-=b;
    cout<<a*a*a+b*b*b<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mp(p1,p2) make_pair(p1,p2)
#define mod 1000000007
#define PI 3.14159265358979323846
#define pii pair<ll ,ll>
using namespace std;
#define fast                                                                   \
 ios_base::sync_with_stdio(false);                                            \
 cin.tie(NULL);                                                               \
 cout.tie(NULL);
 
int main()
{
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
   fast
   ll n;
   cin >> n;
   ll a;
   cin >> a;
   ll b;
   cin >> b;
   ll c;
   cin >> c;
   ll d;
   cin >> d;
   string s;
   cin >> s;
   fr(i,b-1,d)
   {
     if(s[i]=='#' && s[i-1]=='#')
     {
      cout << "No";
      return 0;
     }
   }
   fr(i,a-1,c)
   {
      if(s[i]=='#' && s[i-1]=='#')
     {
      cout << "No";
      return 0;
     }
   }
   if(c>d)
   {
      bool ans = false;
      if(s[b]=='.' && s[b-2]=='.')ans=true;
      fr(i,b+1,d)
      {
        if(s[i]=='.' && s[i-1]=='.' && s[i-2] == '.')ans=true;
      }
      if(s[d]=='.' && s[d-2]=='.')ans=true;
      if(ans)
      {
         cout << "Yes";
      }
      else
         cout << "No";
      
      return 0;
   }
   cout << "Yes";
   return 0;
}

Measured memory_bytes: 592
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
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;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long X, Y;
    scan(X, Y);
    foreach (_; 1 .. N)
    {
        long T, A;
        scan(T, A);
        long na = (X + T - 1) / T;
        long nb = (Y + A - 1) / A;
        long n = max(na, nb);
        X = n * T;
        Y = n * A;
    }
    writeln(X + Y);
}


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

int main()
{
  int n;
  string s;
  cin>>n>>s;
  int counti=0;
  for(int i=0; i<n-2 ; i++)
  {
     if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        counti++;
  }
  cout<<counti;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n,k,d;
    cin>>n>>k;
    bool num[10];
    rep(i,10) num[i]=1;
    rep(i,k){
        cin>>d;
        num[d]=0;
    }
    queue<ll> q;
    for(ll i=1;i<10;i++){
        if(num[i]) q.push(i);
    }
    while(1){
        ll now=q.front(); q.pop();
        if(now>=n){
            cout<<now<<endl;
            return 0;
        }
        rep(i,10){
            if(num[i]) q.push(now*10+i);
        }
    }
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define mod 1000000007
//#define mod 998244353
#define N 1000001
#define ll long long int
#define pr pair<ll,ll>
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define line cout<<'\n'
#define all(v) v.begin(),v.end()
#define rev(s) reverse(all(s))
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tt = 1;
    //cin>>tt;
    f(t,1,tt){
        ll n; cin>>n;
        if(n%10==3) cout<<"bon";
        else if(n%10==0 or n%10==1 or n%10==6 or n%10==8) cout<<"pon";
        else cout<<"hon";
    }
    return 0;
}

Measured memory_bytes: 3596
import fractions
from functools import reduce
N = int(input())
T = [int(input()) for i in range(N)]

def lcm_base(x, y):
  return (x*y)//fractions.gcd(x,y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

ans = lcm_list(T)

print(ans)



Measured memory_bytes: 5856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, 0);
  vector<vll> check(1, vll(n, 0));
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      vll x = check[i - w[memo]];
      x[memo] = 1;
      check.emplace_back(x);
    }
    else check.emplace_back(check[i - 1]);
  }
  cout << dp[ww] << endl;
}


Measured memory_bytes: 83248
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

const LL LIM = 100000000000LL;
// const LL LIM = 120LL;

vi ans;
int k,n;

void solve(int len, LL x, LL tot) {
  if(!len) return;
  LL sum = 1 - (len == n);
  LL tmp;
  if(len == n) {
    tmp = tot / k;
  } else {
    if(x == 1) return;
    tmp = (tot - 1) / k;
  }
  rep(i,1,k+1) {
    if(sum + tmp >= x) {
      ans.pb(i);
      solve(len - 1, x - sum, tmp);
      return;
    }
    sum += tmp;
  }
}

int main() {
  S2(k,n);

  if(k % 2 == 0) {
    printf("%d ",k / 2);
    rep(i,1,n) printf("%d ",k); printf("\n");
    return 0;
  }

  LL tot = 0, tmp = k;
  int idx = 0;
  for(int i = 1; i <= n; i++) {
    tot += tmp;
    if(tot > LIM) {
      tot -= tmp;
      break;
    }
    idx = i;
    tmp *= k;
    if(tmp > LIM) break;
  }
  // printf("%d %lld\n",idx,tot);
  double loss = 0;
  if(n & 1) loss = -0.5;
  rep(i,idx+1,n+1) {
    ans.pb((k + 1) / 2);
    loss += 0.5;
  }
  // printf("%lf\n",tot * 0.5 - loss);
  LL x = tot * 0.5 - loss;
  solve(idx, x + (idx < n), tot + (idx < n));
  rep(i,0,ans.size()) printf("%d ",ans[i]); printf("\n");
  return 0;
}


Measured memory_bytes: 10612
#include<iostream>
#include<cstdio>

using namespace std;


int main(){
  int h,w,imap[1010][1010],H[1010],W[1010];
  for(int i=0;i<1010;i++)H[i] = W[i] = 0;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> imap[i][j];
      if(imap[i][j] == 0)H[i]++,W[j]++;
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      (H[i]+W[j]+imap[i][j])%2==1?cout << 0:cout << 1;
      if(j != w-1)cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
}

Measured memory_bytes: 384
def check(ss,i,j)
  bomb=0
  -1.upto(1) do |ii|
    -1.upto(1) do |jj|
      if i+ii>=0 && i+ii<=H-1 && j+jj>=0 && j+jj<=W-1
        bomb+=1 if ss[i+ii][j+jj]=="#"
      end
    end
  end
  return bomb
end
H,W=gets.split.map(&:to_i)
ss=H.times.map{gets.chomp}
H.times do |i|
  W.times do |j|
    print ss[i][j]=="." ? check(ss,i,j):ss[i][j]
  end
  print "\n"
end


Measured memory_bytes: 1788
n = input()
arr = map(int, raw_input().split())
answer = arr[n-1]

dp = [[0]*21 for i in range(n)]
dp[0][arr[0]] = 1

for i in range(1, n-1):
  for j in range(21):
    if dp[i-1][j] == 0: continue
    vp = j + arr[i]
    vm = j - arr[i]

    if vp <= 20:
      dp[i][vp] += dp[i-1][j]
    if vm >= 0:
      dp[i][vm] += dp[i-1][j]

print dp[n-2][answer]

Measured memory_bytes: 4256
#include <cstdio>

int main(){
	int m, n;
	int a[100][100], b[100];
	long c[100] = {0};
	
	scanf(" %d %d", &m, &n);
	
	for(int i=0; i<m; ++i){
		for(int j=0; j<n; ++j){
			scanf(" %d", &a[i][j]);	
		}
	}
	
	for(int i=0; i<n; ++i){
		scanf(" %d", &b[i]);
	}
	
	for(int i=0; i<m; ++i){
		for(int j=0; j<n; ++j){
			c[i] += a[i][j]*b[j];
		}	
	}
	
	for(int i=0; i<m; ++i)
		printf("%ld\n", c[i]);
	
	return 0;
}

Measured memory_bytes: 1068
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    if(N[0] == '9' || N[1] == '9'){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  
  s = s+s;
  
  int flag = 0;
  if(s.find(t) < s.size())
    flag = 1;
  
  
  if(flag==1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
t=1
for i in range(N):
    if x-A[i]>=0:
        ans+=1
        x-=A[i]
    else:
        t=0
if x==0:
    print(ans)
else:
    print(ans-t)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = acos(-1) ;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	cin>>n>>m;
	if(n>1&&m>1)
		cout<<(ll)ceil(n*m*1.0/2);
	else cout<<"1";

}


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

using namespace std;

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

    int n;
    while(cin>>n,n){
        int res=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if((i+j)*(j-i+1)/2==n) res++;
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 2984
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

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

int main(){
  ll a, b, c, d, ans;
  cin >> a >> b >> c >> d;
  a--;
  
  ll x = c * d / gcd(c, d);
  ans = (b - (b/c + b/d - b/x)) - (a - (a/c + a/d - a/x));
  print(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);
int A[2000];
int m[2000];
int n;

int main(){
    int q,i,j,judge;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&m[i]);
    }
    for(i=0;i<q;i++){
        judge = solve(0,m[i]);
        if(judge==1) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}
int solve(int i,int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    return solve(i+1,m) || solve(i+1,m-A[i]);
}


Measured memory_bytes: 2052
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

int main() {
  int N,K;
  cin >> N >> K;
  long long sum = 1;
  sum *= K;
  for (int i=1; i < N; i++) {
    sum *= K-1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3572
import sys
n,k=map(int,input().split())
if 2*k-1>n:
  print(-1)
  sys.exit()
a=[i for i in range(k,k+n)]
A=[]
for i in range(len(a)):
  if i%2==0:
    A.append(a[i])
for i in range(len(a)):
  if i%2==1:
    A.append(a[i])
b1=[i for i in range(k+n,k+n+(n+1)//2)]
b2=[i for i in range(k+n+(n+1)//2,k+2*n)]
b1.reverse()
b2.reverse()
B=b1+b2
C=[i for i in range(k+2*n,k+3*n)]
for i in range(n):
  print(A[i],B[i],C[i])

Measured memory_bytes: 18648
#include<bits/stdc++.h>
#define m 1000003
using namespace std;

vector<string>dic(m);

int getchar(const string&s,int i){
	if(s.at(i)=='A')return 1;
	else if(s.at(i)=='C')return 2;
	else if(s.at(i)=='G')return 3;
	else if(s.at(i)=='T')return 4;
	else return 0;
}

long getkey(const string&s){
	long sum=1;
	for(int i=0;i<(int)s.size();++i){
		sum+=getchar(s,i);
		sum*=5;
	}
	return sum;
}

int h1(int key){return key%m;}
int h2(int key){return 1+(key%(m-1));}

int insert(const string&s){
	long key=getkey(s);
	for(int i=0,h;;++i){
		h=(h1(key)+i*h2(key))%m;
		if(s==dic.at(h))return 1;
		else if(dic.at(h).size()==0){
			dic.at(h)=s;
			return 0;
		}
	}
	return 0;
}
bool find(const string&s){
	long key=getkey(s);
	for(int i=0,h;;++i){
		h=(h1(key)+i*h2(key))%m;
		if(dic.at(h)==s)return true;
		else if(dic.at(h).size()==0)return false;
	}
	return false;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string cmd,s;
	for(int i=0;i<n;++i){
		cin>>cmd>>s;
		if(cmd.at(0)=='i')insert(s);
		else{
			if(find(s))cout<<"yes\n"s;
			else cout<<"no\n"s;
		}
	}
}


Measured memory_bytes: 24252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    string s; cin>>s;
    ll flg=0;
    rep(i,0,s.size()){
        if(s[N]=='-'){
            rep(j,0,10){
                if(i!=N&&s[i]-'0'==j){
                    flg+=1;
                }
            }
        }
    }
    cout <<(flg==N+M ? "Yes":"No")<< endl;
    return 0;
}

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

int main(){
    int a,b,c,x;
    1 <= a,b,c <= 10000;
    cin >> a >> b >> c;
    if(a > b){
        x = a;
        a = b;
        b = x;
    }if(b > c){
        x = b;
        b = c;
        c = x;
    }if(a > b){
        x = a;
        a = b;
        b = x;
    }
    cout << a <<" "<< b <<" "<< c << endl;
    return 0;
}


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL a, b, c;
	cin >> a >> b >> c;

	LL k;
	cin >> k;

	while (k && b <= a) {
		b *= 2; k--;
	}
	while (k && c <= b) {
		c *= 2; k--;
	}

	if (a < b && b < c) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

}

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

using namespace std;

int main()
{
   
    int a,b,ans,dif;
    scanf("%d %d",&a,&b);


    if(a<=b)
        ans=a;

    else
    {
        a--;
        ans=a;

    }
  
  
    printf("%d\n",ans); 

    return 0;
}



Measured memory_bytes: 256
require 'pp'
require 'prime'

n = gets.to_i
primes = Prime.prime_division(n)

total = 0
primes.each do |prime, cnt|
    #pp cnt
    sub = 1
    while cnt >= sub
        total += 1
        cnt -= sub
        sub = sub + 1
    end
end

puts total


Measured memory_bytes: 14636
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
ans=float("inf")
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
    if ans==0:
        print(ans)
        exit()
print(ans)

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

using namespace std;

int main(){
    string str="";
    cin >> str;
    if(str[1]==str[0] && str[2]==str[0]){
        cout << "No" << endl;
    } else{
        cout << "Yes" << endl;
    }
    return 0;
}






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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll nminus = 0;
    ll plussum= 0;
    ll m = 1e10;
    rep(i,N){
        cin >> A[i];
        if(A[i] < 0){
            nminus++;
            plussum -= A[i];
            m = min(m, -A[i]);
        }else{
            plussum += A[i];
            m = min(m, A[i]);
        }
    }
    if(nminus % 2 == 0){
        cout << plussum << endl;
    }else{
        cout << plussum-m*2 << endl;
    }
}

Measured memory_bytes: 1024
while str = STDIN.gets

  break if str == "\n"

  (xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2) = str.chomp.split(/ /).map(&:to_f)

  puts (xa1 <= xb2 && xa2 >= xb1) && (ya1 <= yb2 && ya2 >= yb1) ? "YES" : "NO"

end

Measured memory_bytes: 8640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    int A = 100;
    int cnt = 0;
    while(true) {
        if (A >= X) {
            cout << cnt << endl;
            return 0;
        }
        A = A * 1.01;
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    using P = pair<int, int>;
    vector<vector<P>> v(n, vector<P>());
    rep(i, n){
        int a;
        cin >> a;
        rep(j, a){
            int x, y;
            cin >> x >> y;
            v[i].push_back({x-1, y});
        }
    }

    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        bool ok = true;
        rep(i, n){
            rep(j, v[i].size()){
                if((bit >> i) & 1){
                    if(((bit >> v[i][j].first) & 1) != v[i][j].second) ok = false;
                }
            }
        }
        if(ok){
            int cnt = 0;
            rep(i, n) cnt += ((bit >> i) & 1);
            chmax(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  char c;
  string v = "aiueo"; 
  cin >> c;
  
  cout << ((v.find(c) != string::npos) ? "vowel" : "consonant") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int b[n+1] = {0};
    for (int i = 0; i < n; i++) { int a; cin >> a; b[i+1] = (b[i] + a - 1) % k; }
    map<int, int> s;
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i >= k) s[b[i-k]]--;
        ans += s[b[i]];
        s[b[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include <stdio.h>

int sumofintegers(int n,int s,int t,int u,int v){
  int a=0,b,c,d,i;
  b=t+1;
  for(i=v;i<10;i++){
    if((c=u+i)>s) break;
    if(n==b && s==c){
      a=1;
      break;
    } else {
      if((d=i+1)>9) break;
      a+=sumofintegers(n,s,b,c,d);
    }
  }
  return a;
}

int main(){
  int n,s;
  while(scanf("%d %d",&n,&s)){
    if(n==0 && s==0) break;
    printf("%d\n",sumofintegers(n,s,0,0,0));
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N, M; cin>>N>>M;
    vi A(M); REP(i,M) cin>>A[i];

    int sum = 0;
    REP(i,M) {
        sum += A[i];
    }

    int ans = sum <= N ? N-sum : -1;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3684
import fractions

def lcm(p,q):
    return (p*q) // fractions.gcd(p,q)

def g(x,k):
    return x // k

def f(x,c,d):
    return x - (g(x,c)+g(x,d)-g(x,lcm(c,d)))

a,b,c,d = map(int, input().split())

print(f(b,c,d)-f(a-1,c,d))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;
#define get(vv, times) for(int ii = 0; ii < times; ++ii) {int jj; cin >> jj; (vv).pb(jj);}
 
int n, k, a[300100], r[300100], b[300100], sum, ans;
priority_queue <int, vector <int>, greater <int>> qp;
priority_queue <int> pq;
 
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    ans = -1e18l;
    for(int i = 0; i < 3 * n; ++i) cin >> a[i];
    sum = 0;
    for(int i = 0; i < 3 * n; ++i) {
        qp.push(a[i]);
        sum += a[i];
        if (qp.size() > n) {
            sum -= qp.top();
            qp.pop();
        }
        // cout << i << '\n';
        r[i] = sum;
    }
    sum = 0;
    for(int i = 3 * n - 1; i >= 0; --i) {
        // cout << a[i] << '\n';
        pq.push(a[i]);
        sum += a[i];
        // cout << "a[i]: " << a[i] << " sum: " << sum << " pq.size(): " << pq.size() << '\n';
        if (pq.size() > n) {
            // cout << i << " hello\n";
            // assert(0);
            sum -= pq.top();
            pq.pop();
        }
        // cout << i - n << '\n';
        // cout << sum << '\n';
        b[i] = sum;
    }
    // for (int i = 0; i < n * 3; ++i) cout << r[i] << ' ';
    // cout << '\n';
    // for (int i = 0; i < n * 3; ++i) cout << b[i] << ' ';
    for(int i = n-1; i < 2 * n; ++i) {
        ans = max(ans, r[i] - b[i+1]);
    }
    cout << ans;
    // time
}

Measured memory_bytes: 11832
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

# ??\??????????????????????????§????????????????????????????????????
count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v


for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
        print('#' * 20)

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int n;
  cin>>n;
  int ans = 0;
  rep(i, 0, n)
  {
    int l, r;
    cin>>l>>r;
    ans += (r-l+1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 14080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long[] a = new long[n];

		for (int i=0; i<n;i++){
			a[i] = sc.nextLong();
		}
		
		long m = 0;
		for(int i=0; i<n;i++){
			for(int j=i+1;j<n;j++){
				long ab = a[i]-a[j];
				if ( ab < 0 ) ab*=(-1);
			
				if ( ab>m ) m = ab;
			}
		}
		
		System.out.println(m);
		
	}

}


Measured memory_bytes: 21844
import decimal
import sys
from decimal import Decimal

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B = rl().split()
    ans = Decimal(A) * Decimal(B)
    ans = ans.quantize(Decimal('0'), rounding=decimal.ROUND_FLOOR)
    print(ans)


if __name__ == '__main__':
    solve()


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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back

double a;

double f(int n) {
    if(n == 1) return a;
    if(n % 2 == 0)
        return f(n-1) * 2.0;
    else
        return f(n-1) / 3.0;
}

int main() {
    while(cin >> a) {
        double ans = 0;
        for(int i=1; i<=10; i++) ans += f(i);
        printf("%20lf\n", ans);
    }

    return 0;
}

Measured memory_bytes: 1244