akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ll k;
	cin >> k;
	if (k <= 9) {
		cout << k << endl;
		return 0;
	}
	//k>=10
	vector<ll>s = { 1,2,3,4,5,6,7,8,9 };
	deque<ll>sq;
	for (int i = 0; i < 9; i++)sq.push_back(s.at(i));
	while (s.size()<=k) {
		ll a = sq.front();
		if (a % 10 == 0) {
			s.push_back(a * 10);
			s.push_back(a * 10 + 1);
			sq.push_back(a * 10);
			sq.push_back(a * 10 + 1);
		}
		else if (a % 10 == 9) {
			s.push_back(a * 10 + 8);
			s.push_back(a * 10 + 9);
			sq.push_back(a * 10 + 8);
			sq.push_back(a * 10 + 9);
		}
		else {
			int x = a % 10;
			s.push_back(a * 10 + x - 1);
			s.push_back(a * 10 + x);
			s.push_back(a * 10 + x + 1);
			sq.push_back(a * 10 + x - 1);
			sq.push_back(a * 10 + x);
			sq.push_back(a * 10 + x + 1);
		}
		sq.pop_front();
	}
	//for (int i = 0; i < s.size(); i++)cout << " " << s.at(i);
	cout << s.at(k-1) << endl;
	/*
	s = { 1,2,3,4,5,6,7,8,9 };
	sq = {1,2,3,4,5,6,7,8,9};
	*/
}

Measured memory_bytes: 4872
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll m=1000000007;
int main()
{
	int h,w;
	cin>>h>>w;
    char a[h][w];
	for(int i=0;i<h;i++)
    {
    for(int j=0;j<w;j++)
    {
    cin>>a[i][j];
    }
    }
	ll dp[h][w];
	memset(dp,0,sizeof dp);
	dp[h-1][w-1]=1;
	for(int i=h-1;i>=0;i--)
	{
	for(int j=w-1;j>=0;j--)
	{
	if(a[i][j]!='#')
	{
	if(i<h-1)
	dp[i][j]=dp[i][j]+dp[i+1][j];
	if(j<w-1)
	dp[i][j]=dp[i][j]+dp[i][j+1];	
	}
	dp[i][j]=dp[i][j]%m;	
	}	
	}
	cout<<dp[0][0];
	return 0;
}

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

int n;
void dfs(string s, char mx) {
    if (s.length() == n) {
        cout << s << endl;
    } else {
        for (char c = 'a'; c <= mx; c++) {
            dfs(s + c, ((c == mx) ? mx+1 : mx));
        }
    }


}

void solve() {
    cin >> n;
    dfs("", 'a');
}

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



Measured memory_bytes: 1536
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const long long MOD = 1000000007;
using ll = long long;


int main()
{
    int N;
    std::cin >> N;
    std::vector<ll> A(N);

    std::vector<ll> ruisekiwa(N+1, 0);

    rep(i, N)
    {
        std::cin >> A[i];
        ruisekiwa[i+1] = ruisekiwa[i] + A[i];
    }

    long long ans = 0;
    rep(i, N)
    {
        //********************************************************
        // <EX>
        // in        = { 1, 3, 5, 7 }
        // ruisekiwa = { 0, 1, 4, 9, 16 }
        // i = 1, ruisekiwa = 15 = 16 - 1
        // i = 2, ruisekiwa = 12 = 16 - 4
        // i = 3, ruisekiwa = 7 = 16 - 9
        // i = 0, ruisekiwa = 0 = 16 -16
        //********************************************************
        long long sum = (ruisekiwa[N] - ruisekiwa[i+1] ) % MOD; // 頭からおしりまで - 今見ているところまで 
                                                                // iが大きくなるに従い、ruisekiwa[i+1]の大きさが増えるので
                                                                // sumの大きさは小さくなる
        ans += (A[i] * sum);
        ans %= MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 6404
# 一泊X円、N(泊数)がK泊より多ければその分だけ一泊Y円
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
# K泊より多い場合はその分だけ単価Y円を掛ける
if N >= K:
    total_price = K * X + (N - K) * Y
# K泊より少ない場合は泊数に単価X円を掛ける
else:
    total_price = N * X

print(total_price)


Measured memory_bytes: 9132
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define N 100005
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first<b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int n,m;
ll p[N],h[N],x[N],y[N];
vector<int>ed[N];
int main()
{
    faltu;
    int t=1;
   // cin>>t;
    while(t--)
    {
        ll int n,k,final=0;
        cin>>n>>k;
        ll int a[n+1];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        ll int l=1,r=1e9;
        while(l<=r)
        {
            ll int mid=(l+r)>>1;
            ll int ans=0;
            for(ll int i=0;i<n;i++)
            {
                    ll int cnt=0;
                    cnt=a[i]/mid;
                    if(a[i]%mid)cnt++;
                   if(cnt)ans+=cnt-1;
            }
            if(ans<=k)
            {
                final=mid;
                r=mid-1;
            }
            else l=mid+1;
        }
        cout<<final<<endl;
    }
}

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=200005;
int T[N],f[N],p[N],q[N],n;

int chk(int a,int b,int c){
	return a<b&&b<c||b<c&&c<a||c<a&&a<b;
}

int main(){
	read(n);
	rep(i,1,n){
		read(p[i]);
		q[p[i]]=i;
	}
	per(i,n-1,1){
		if(!T[i+1]){
			if(q[i]>q[i+1]){
				T[i]=1,f[i]=i+1;
			}
		}
		else if(chk(q[f[i+1]],q[i],q[i+1])){
			T[i]=T[i+1],f[i]=f[i+1];
		}
		else{
			T[i]=T[i+1]+1,f[i]=i+1;
		}
	}
	cout<<T[1]<<endl;
	return 0;
}

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

static inline bool IsOverflow(ull a, ull b)
{
    return a && b > std::numeric_limits<ull>::max() / a;
}

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

    constexpr ull border = (ull)10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;

    bool over = false;
    ull result = 1;
    for (int i = 0; i < n; ++i)
    {
        ull a;
        cin >> a;

        if (!a)
        {
            result = 0;
            over = false;
            break;
        }

        if (IsOverflow(result, a))
            over = true;

        result *= a;
        if (result > border)
            over = true;
    }

    if (over)
        cout << -1 << endl;
    else
        cout << result << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a[200010];// 从i可以传到a[i] 
int b[200010];// 从1到i需要传b[i]次 
int c[200010];// 从1开始传i次可以到c[i] 
bool vis[200010];
int n, x, y; //x是“循环节”长度, y是“循环头”长度 
long long k;
int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 0, j = 1;; i++, j = a[j])//i：计数器，j：枚举器 
	{
		if(vis[j])
		{
			x = i - b[j];
			y = b[j];
			break;
		}
		
		b[j] = i;
		c[i] = j;
		vis[j] = 1;
	}
	
	if(k >= x+y) k = y + (k-y)%x;//去掉循环节 
	cout << c[k];
	
	return 0;
} 

Measured memory_bytes: 6096
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

import string

def main():
    N = int(input())
    S = input()

    alf = string.ascii_uppercase

    out = ""
    for s in S:
        ind = alf.find(s)
        out += alf[(ind + N) % len(alf)]
    
    print(out)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3960
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int l[10];
	double v1, v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
		double d = 0, g;
		for(int i = 0; i < 10; ++i) {
			d += l[i];
		}
		g = d * v1 / (v1 + v2);
		int s = 0, sum = 1;
		for(int i = 0; i < 10; ++i, ++sum) {
			s += l[i];
			if(s >= g) {
				cout << sum << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1228
// C++(Clang 10.0.0)

//GCC用 ナゾです
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart(x>=0) -> x<0の時異常終了
#include <numeric>
#include <iterator>
#include <list>
#include <tuple>
#include <queue>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(ll i=(min);i<(max);i++)
#define FOReq(i,min,max) for(ll i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(ll i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(ll i=(max);i>=(min);i--)

#define all(vec) (vec).begin(),(vec).end()

const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2 || not0){;}
    return 0;
}

#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define isdiff5(a,b,c,d,e) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c) and (e)!=(a) and (e)!=(b) and (e)!=(c) and (e)!=(d))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll samepair(ll x){return x*(x-1)/2;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});
//auto count = std::count_if(v.begin(), v.end(), [](int x) { return x == 1 || x == 3; } );

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

//累積和　しゃくとり法　木構造　DP キュー　乱択アルゴリズム　嘘解法　ハッシュ　next_permulation

//課題：DP 木構造　Xor

ll probNow(){
    ll ans;ans=0;
    ll A,B;
    cin>>A>>B;
    
    
    
    for (ll i=ceil(A*12.5); i*0.08<A+1 ; i++) {
        if( floor(i*0.1)==B)OutputAndReturn0(i)
    }
    
    
    OutputAndReturn0(-1);
    return 0;
}

signed main(){
    cin.tie(0);    //cinとcoutの結び付き解除（cout時にcinの内容を吐き出さなくなる）
    ios::sync_with_stdio(false);  //coutとprintfの結び付き解除（coutとprintfを同時に使うな！）
    probNow();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, m, r; cin >> n >> m >> r;
    vector<int> cities(r);
    for (int &x : cities) {
        cin >> x;
    }
    const ll inf = (ll) 1e15;
    vector<vector<ll>> dist(n + 10,  vector<ll>(n + 10, inf));
    for (int i = 0; i < m; i++) {
        int u, v, w; cin >> u >> v >> w;
        dist[u][v] = dist[v][u] = min(dist[u][v], (ll) w);
    }
    for (int i = 1; i <= n; i++) {
        dist[i][i] = 0;
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    ll res = inf;
    sort(cities.begin(), cities.end());
    do {
        ll cur = 0;
        for (int i = 1; i < r; i++) {
            cur += dist[cities[i - 1]][cities[i]];
        }
        res = min(res, cur);
    } while (next_permutation(cities.begin(), cities.end()));
    cout << res << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define min(a,b) a<b ? a:b
// #define max(a, b) a < b ? b : a
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)

#define pb push_back
#define pi 3.14159265358979323846

// int explore(vector<vector<int>> &adj,int x,int y,vector<int> &visited)
// {
//     if(x==y)
//     return 1;
//     visited[x]=1;
//     for(int i=0;i<adj[x].size();i++)
//     {
//         if(!visited[adj[x][i]])
//         {
//             if(explore(adj,adj[x][i],y,visited))
//             return 1;
//         }
//     }
//     return 0;
// }
bool valley(int p[], int k)
{
    if (p[k] < p[k - 1] && p[k] < p[k + 1])
        return true;
    return false;
}
bool peak(int p[], int k)
{
    if (p[k] > p[k - 1] && p[k] > p[k + 1])
        return true;
    return false;
}
int gcd(int a,int b)
{
    return b? gcd(b,a%b):a;
}
int pow(int x,int p)
{
    int ctr=1;
    for(int i=0;i<p;i++)
    {
        ctr*=x;
    }
    return ctr;
}
int32_t main()
{
    IOS;
    // int t;
    // cin >> t;
    // while (t--)
    // {
           string s,k="es";
           cin>>s;
           if(s[s.size()-1]!='s')
           s.append(1,'s');
           else
           s.append(k) ;
           cout<<s;
    // }
}


Measured memory_bytes: 3660
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(1,N):
  A[i]+=A[i-1]
A=[(A[i]-i-1)%K for i in range(N)]
A=[0]+A
from collections import Counter
if K>N:
  a=Counter(A)
  ans=0
  for v in a.values():
    ans+=v*(v-1)/2
  print(int(ans))
else:
  ans=0
  d={}
  for i in range(K):
    if A[i] in d:
      ans+=d[A[i]]
      d[A[i]]+=1
    else:
      d[A[i]]=1
  for i in range(K,N+1):
    d[A[i-K]]-=1
    if A[i] in d:
      ans+=d[A[i]]
      d[A[i]]+=1
    if A[i] not in d or d[A[i]]==0:
      d[A[i]]=1
  print(ans) 


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

int main() {

  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> rev(N);
  for (int i = 0; i < N; i++) {
    rev.at(a.at(i)-1)=i+1;
  }

  for (int i = 0; i < N; i++) {
    cout << rev.at(i) << endl;
  }

}

Measured memory_bytes: 1664
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        H = 1
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

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

long f(vector<long>& C, int n, int i, long acc) {
  if (n == 3) return acc;
  else if (acc == 0 || i == 5) return 0;
  return f(C, n + 1, i + 1, acc * C[i]) + f(C, n, i + 1, acc);
}

int main() {
  int N;
  cin >> N;
  string XX = "MARCH";
  vector<long> C(XX.size(), 0);
  string S;
  for (int i = 0; i < N; i++) {
    cin >> S;
    auto tmp = XX.find(S[0]);
    if (tmp != string::npos) C[tmp]++;
  }
  cout << f(C, 0, 0, 1) << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
  if H[i+1] == H[i]-1:
    H[i+1] = H[i]
  elif H[i+1] >= H[i]:
    continue
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 20484
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int k, x;
    cin >> k >> x;

    cout << (k * 500 >= x ? "Yes" : "No") << "\n";
    return 0;
}

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

const int maxn = 3005;

long long dp[maxn][maxn][2];

int a[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        dp[i][i][0] = a[i];
        dp[i][i][1] = -a[i];
    }

    for(int len = 2; len <= n; len++)
    {
        for(int i = 0; i + len - 1 < n ; i++)
        {
            int j = i + len - 1;
            dp[i][j][0] = max(dp[i+1][j][1] + a[i], dp[i][j-1][1] + a[j]);
            dp[i][j][1] = min(dp[i+1][j][0] - a[i], dp[i][j-1][0] - a[j]);
        }
    }

    printf("%lld\n",dp[0][n-1][0]);

    return 0;
}

Measured memory_bytes: 139648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt2() (int, int) {
	return scanInt(), scanInt()
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := scanInt2()
	if a > 8 || b > 8 {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 640
#include<iostream>

inline void printNumber(int start, int end)
{
	for (int i = start; i <= end; i++) {
		std::cout << i << std::endl;
	}
}

int main()
{
	int A, B, K;
	std::cin >> A >> B >> K;

	int aMax = A + K - 1, bMin = B - K + 1;
	
	if (aMax >= bMin) {
		printNumber(A, B);
	} else {
		printNumber(A, aMax);
		printNumber(bMin, B);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll f(ll n)
{
  if (n == 1)
    return 1;
  else
    return 2 * f(n / 2) + 1;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int min(int,int);
int main(void){
  int n;
  scanf("%d",&n);
  int b[n-1];
  for(int i=0;i<n-1;i++){
    scanf("%d",&b[i]);
  }
  int a[n];
  int i,j=0;
	a[0]=b[0];
  a[n-1]=b[n-2];
  for(int i=1;i<n-1;i++){
    a[i]=min(b[i],b[i-1]);
    j+=2;
  }
  int sum=0;
  for(int i=0;i<n;i++){
  // printf("%d ",a[i]);
    sum+=a[i];
  }
  printf("%d",sum);
  return 0;
}
int min(int a, int b){
  if(a>b)return b;
  else return a;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int n;
map<string,int> m_p;
int main()
{
	cin>>n;
	rep(i,n)
	{
		string s;
		cin>>s;
		m_p[s]++;
	}
	cout<<"AC x "<<m_p["AC"]<<endl;
	cout<<"WA x "<<m_p["WA"]<<endl;
	cout<<"TLE x "<<m_p["TLE"]<<endl;
	cout<<"RE x "<<m_p["RE"]<<endl;
	return 0;
}

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

int main () {
  int N ;
  cin >> N ;
  int line[N] ,line1[N] ;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  for(int i = 0 ; i < N ; i++ ) cin >> line1[i] ;
  int ans = 0 ;
  for(int i = 0 ; i < N ; i++ ){
    if(line[i] - line1[i] > 0 ){
      ans += line[i] - line1[i] ;
    }
  }
  cout << ans <<endl ;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    double l;
    cin>>l;
    double ans=l*l*l/27;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    UnionFind Tree(n);

    for(int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        Tree.unite(x - 1,y - 1);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(Tree.same(a[i] - 1 ,i)) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  testDebbug
//
//  Created by Manikanta Nallagatla on 18/02/20.
//  Copyright © 2020 Manikanta Nallagatla. All rights reserved.
//
// testDebug.cpp : Defines the entry point for the console application.
//

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<set>
#include<functional>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <fstream>
#include <math.h>

using namespace std;



struct TreeNode
{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
struct TreeLinkNode
{
    int val;
    TreeLinkNode *left;
    TreeLinkNode *right;
    TreeLinkNode *next;
    TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}
};
struct ListNode
{
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

template <class T>
void printv1(T v)
{
    cout << v << endl;
}


template <class T>
void printv2(vector<T> v)
{
    for (auto x : v) {
        cout<<x<<endl;
    }
    cout << endl;
}

template <class T>
void printv3(vector<vector<T>> v)
{
    for (auto x : v) {
        for (auto y : x) {
            cout << y << " ";
        }cout << endl;
    }
}

void printv4(vector<string> v)
{
    for (auto x : v) {
        for (auto y:x )
        {
            cout << char(y+int('0')) << " ";
        }
        cout << endl;
    }
    cout << endl;
}

static auto magic = []() {ios_base::sync_with_stdio(false); cin.tie(nullptr); return false; }();

#define POD 1000000007
#define ll long long int




int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int r;
    cin>>r;
    cout<<2*M_PI*r<<endl;
    
    return 0;
}



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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint dp0[2005][2005];
mint dp1[2005][2005];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n+1), t(m+1);
  rep(i,n) scanf("%d", &s[i]);
  rep(i,m) scanf("%d", &t[i]);
  dp0[0][0] = 1;
  rep(i,n+1)rep(j,m+1) {
    // printf("%d %d : %lld %lld\n", i,j,dp0[i][j].x,dp1[i][j].x);
    dp0[i+1][j] += dp0[i][j];
    dp1[i][j] += dp0[i][j];
    dp1[i][j+1] += dp1[i][j];
    if (s[i] == t[j]) {
      dp0[i+1][j+1] += dp1[i][j];
    }
  }
  mint ans = dp1[n][m];
  cout << ans.x << endl;
  return 0;
}

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

int main(){
  int n;cin>>n;
  vector<vector<int>> cnt(n,vector<int>(26,0));
  for(int i=0;i<n;++i){
    string s;cin>>s;
    for(auto &&si: s){
      ++cnt[i][(int)(si-'a')];
    }
  }

  for(int h=0;h<26;++h){
    int mn = 1e9+1;
    for(int i=0;i<n;++i){
      mn = min(mn, cnt[i][h]);
    }
    char ch = 'a'+h;
    cout<<string(mn,ch);
  }
  cout<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 0;
    for (int i = 1; i < n - 1; i++){
        int x = max({s[i-1], s[i], s[i+1]});
        int y = min({s[i-1], s[i], s[i+1]});
        if (s[i] != x && s[i] != y) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Score: /200

#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int count = 0;
	int prev_col = -1;
	int continue_count = 1;
	for (int i = 0; i < N; ++i)
	{
		int col;
		cin >> col;
		if (prev_col >= 0 && prev_col == col)
		{
			++continue_count;
		}
		else
		{
			count += continue_count / 2;
			continue_count = 1;
		}
		prev_col = col;
	}
	count += continue_count / 2;
	cout << count;
}


Measured memory_bytes: 256
function Main(input){
    var arr = [,,input-0];
    for(var i=2;arr[i-2]+arr[i-1]+arr[i]!=7;i++){
        arr.push(arr[i]%2===0?arr[i]/2:3*arr[i]+1);
    }
    console.log(arr.length-1)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second
#define INF INT_MAX

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

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

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int ara[nmax];
int dp[nmax];


int solve(int pos)
{
    if(pos==1)
        return 0;
    if(pos<=0)
        return 1e9;

    int &ret = dp[pos];

    if(ret!=-1) return ret;

    int p1 = solve(pos-1) + abs(ara[pos]-ara[pos-1]);
    int p2 = solve(pos-2) + abs(ara[pos]-ara[pos-2]);

    return ret = min(p1,p2);
}

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>ara[i];

    memset(dp,-1,sizeof dp);

    cout<<solve(n)<<endl;
//
//    for(int i=1;i<=n;i++)
//        cout<<dp[i]<<" ";
//    cout<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 4608
N,M=map(int,input().split())
a=[list(map(int,input().split())) for i in range(M)]
a.sort(key=lambda x:x[1])
j=0
k=0
ans=0
for i in range(M):
  if i==0:
    k=a[i][1]
    j=k-1
    ans+=1
  else:
    if a[i][0]<=j:
      continue
    else:
      k=a[i][1]
      j=k-1
      ans+=1
print(ans)

Measured memory_bytes: 28648
n = int(input())
x = list(map(int, input().split()))
max = max(x)
min = min(x)
ans = 1000001
for i in range(min, max + 1):
    score = 0
    
    for item in x:
        score = score + ((item - i) ** 2)
    
    if score <= ans:
        ans = score

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC optimize("O3")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000*1000+5;
const ll N2      = 2000*1000*10;
const ld PI  = 3.141592653589793;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tree_set;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
int n;
int getFirstDigit(int x) 
{ 
    while (x >= 10) 
        x /= 10; 
    return x; 
} 
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    cin>>n;
    int ans(0);
    int count[10][10];
    fill(count,0);
    for (int i = 1; i <= n; ++i)
    {
        int dum = getFirstDigit(i);
        int last = i%10;
        count[dum][last]++;
    }
    for(int i =1 ; i<=9 ; i++)
    {
        for(int j = 1 ; j<=9 ; j++)
        {
            ans+=count[i][j]*count[j][i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  [a,b,angC] <- map read . words <$> getLine :: IO [Double]
  let 
    s = a*b*sin (angC/180*pi)/2
    c = sqrt $ a**2+b**2-2*a*b*cos (angC/180*pi)
    l = a+b+c
    h = s*2/a

  printf "%.8f\n" s
  printf "%.8f\n" l
  printf "%.8f\n" h

Measured memory_bytes: 4164
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e3+10;
int n,s; bitset<N*N> dp;
signed main(){
	dp[0]=1; cin>>n;
	for(int i=1,x;i<=n;i++) cin>>x,dp|=(dp<<x),s+=x;
	for(int i=(s+1)/2;;i++) if(dp[i]) return cout<<i,0;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int a,b;
  cin >> a >> b;
  if(a>=13)cout<< b << endl;
  else if(a<=5)cout<<0<<endl;
  else cout<<b/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define li long long int

using namespace std;

string a,b,c;

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

void calc()
{
	c="";
	int la,lb,i,j;
	la=a.length(); lb=b.length();
	int dp[la+1][lb+1];
	for(i=0;i<=la;i++)	dp[i][0]=0;
	for(i=0;i<=lb;i++)	dp[0][i]=0;	
	for(i=1;i<=la;i++)
	{
		for(j=1;j<=lb;j++)
		{
			if(a[i-1]==b[j-1])	dp[i][j]=1+dp[i-1][j-1];
			else	dp[i][j]=max(dp[i-1][j],dp[i][j-1]);	
		}
	}
	i=la;j=lb;int x=dp[i][j];
	
	while(x!=0)
	{
		if(a[i-1]==b[j-1]){	c=a[i-1]+c;i--;j--;}
		else
		{
			if(dp[i][j-1]>=dp[i-1][j])
				j--;
			else	i--;
		}
		x=dp[i][j];
		//cout<<"c now="<<endl<<" x="<<x<<"\n";
	}
	
}

int main()
{
    FAST();
    cin>>a>>b;
    calc();
    cout<<c;
}

Measured memory_bytes: 38832
import numpy as np

def solve():
    N = int(input())
    
    r = 1e12
    for i in range(1, int(np.sqrt(N)) + 1):
        if N % i == 0:
            r = min(r, (N / i - 1) + (i - 1))
            
    
    print(int(r))

solve()

Measured memory_bytes: 15364
#include <stdio.h>

int main(void){
	int i,e[128] = {0},r = 0,m;
	for(i = 1;i <= 12;i++){scanf("%d",&m);e[m]++;}
	for(i = 1;i <= 100;i++){
		if(e[i]%4 == 0){r+=(e[i]/4);}
	}
	if(r == 3){printf("yes\n");}else{printf("no\n");}
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [] c = new int [N];
        for(int i = 0; i < 2 * M ; i ++) {
            int a = sc.nextInt();
            c[a - 1]++;
        }
        for (int i = 0 ; i< N ; i++) {
            System.out.println(c[i]);
        }
    }
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(){
  int K,A,B;
  scanf("%d %d %d",&K,&A,&B);
  
  int L=K;
  int sw=0; 
  
 while(L<=B){ 
   
  if(A<=L){
    sw=1;
  }
   
   L=L+K;
 }  
   
  if(sw==1){  
    printf("OK\n");
  }else{
    printf("NG\n");
  }
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    int sum = 0;
    rep(i, s.size()) {
        sum += s[i] - '0';
    }
    std::cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3736
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    }

    private static int solve(int n) {
        int i = 1;
        while (true) {
            int tmp = (i + 1) * (i + 1);
            if (tmp <= n) {
                i++;
            } else {
                break;
            }
        }
        return i * i;
    }
}

Measured memory_bytes: 22612
n = input()

if n[-1]=="3" :
    print("bon")
elif n[-1]=="0" :
    print("pon")
elif n[-1]=="1":
    print("pon")
elif n[-1]=="6" :
    print("pon")
elif n[-1]=="8" :
    print("pon")
else :
    print("hon")

Measured memory_bytes: 9120
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
//#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define izryt bool
#define fi first
#define se second
#define res resize
const llint mod=1000000007;
const llint gya=500000004;//mod modで2の逆元
const llint big=1e18;
const llint red=0xE869120;
const llint pro=1002001;
int main(void){
	llint gen=1,i,j,N;
	string str;
	vector<llint>dp,ddp;
	cin>>N;
	cin>>str;
	dp.res(N+2);ddp.res(N+2);
	dp[0]=1;
	for(i=0;i<N;i++){
		ddp[0]=dp[0]+dp[1];
		ddp[0]%=mod;
		for(j=1;j<N+1;j++){
			ddp[j]=2*dp[j-1]+dp[j+1];
			ddp[j]%=mod;
		}
		swap(dp,ddp);
	}
	gen=dp[str.size()];
	for(i=0;i<str.size();i++){
		gen*=gya;
		gen%=mod;
	}
	cout<<gen<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;



int main(){
  int n,k;
  cin >> n >>k;
  vector<int> h(n);
  rep(i,n){
  cin >> h.at(i);
  }
  
  vector<int> dp(1000000, inf);
  
  rep(i,n){
    if(i == 0) {dp.at(i) = 0; continue;}
    rep(j,k+1){
      if(j == 0) {continue;}
      if(i-j < 0){break;}
      dp.at(i) = min(dp.at(i), dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
      //cout << i << " " << dp.at(i)  << endl;
    }
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 4608
import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N,a,b= map(int,input().split())
ans=0
ju=0
ans=N%(a+b)
ju=N//(a+b)
if ans<=a:
  print(a*ju+ans)
else:
  print(a*ju+a)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
typedef  long long ll;

int cmpnum(const void * n1, const void * n2)
{
  if (*(int *)n1 > *(int *)n2)
  {
    return 1;
  }
  else if (*(int *)n1 < *(int *)n2)
  {
    return -1;
  }
  else
  {
    return 0;
  }
}

int main(void)
{

  int x,n;
  int p[200];
  int tmp[300];
  int k=0;
  int i=0;
  scanf("%d %d",&x,&n);
  if(n==0){
    printf("%d\n",x);
    return 0;
  }
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  qsort(p,n,sizeof(int), cmpnum);
  for(int j=-100;j<=110;j++){

    if(p[i]!=j){
      tmp[k]=j;
      k++;
    }else if(i+1<n){
      i++;
    }
  }
  //
  // for(int i=0;i<k;i++){
  //   printf("%d ",tmp[i]);
  // }
  // puts(" ");


  int min=300;
  int min_ans;
  for(int i=0;i<k;i++){
    //  printf("%d\n",x-tmp[i]);
    if(abs(x-tmp[i])<min)
    min_ans=tmp[i];
    min=abs(x-tmp[i]);
  }

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


Measured memory_bytes: 1736
/*
この問題はABC_065_Aである
食べ物の賞味期限はあてにできない
*/
#include<iostream>
using namespace std;

int main(void){
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a <= 0){
    cout << "delicious" << '\n';
  }
  else if(b-a > x){
    cout << "dangerous" << '\n';
  }
  else{
    cout << "safe" << '\n';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    vector<string> s,t;
    cin>>n;
    rep(i,n){
        string x;
        cin>>x;
        s.push_back(x);
    }
    cin>>m;
    rep(i,m){
        string y;
        cin>>y;
        t.push_back(y);
    }
    int ans=0;
    for(auto itr:s){
        int p=count(begin(s),end(s),itr);
        int m=count(begin(t),end(t),itr);
        if(p-m>ans){
            ans=p-m;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n;
    cin>>n;
    ll ans = n * (n + 1) / 2 - n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
    LL n;
    cin>>n;
    LL ans=1;
    for(int i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256