akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;

int main() {
  string a;
  cin >> a;
  if (a == "ARC") {
    cout << "ABC";
  } else {
    cout << "ARC";
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;
typedef long long ll;
map<char,int> m;
map<string,int> name;
ll a[10];

int main()
{
    int n,sum;
    while(cin>>n)
    {
        m.clear();
        name.clear();
        sum=0;
        string str;
        while(n--)
        {
            cin>>str;
            if(name[str])
                continue;
            else
                name[str]++;
            char c=str[0];
          //  cout<<c<<endl;
            if(!m[c])
            {
                m[c]++;
               // cout<<sum<<endl;
               // cout<<c<<endl;
               // cout<<m[c]<<endl;
            }

            else
            {
                m[c]++;
                //cout<<sum<<endl;
               // cout<<c<<endl;
               // cout<<m[c]<<endl;
            }

           // cout<<sum<<endl;
        }
        //cout<<sum<<endl;
        int i=0;
        if(m['M']) ++sum,a[++i]=m['M'];
        if(m['A']) ++sum,a[++i]=m['A'];
        if(m['R']) ++sum,a[++i]=m['R'];
        if(m['C']) ++sum,a[++i]=m['C'];
        if(m['H']) ++sum,a[++i]=m['H'];
        ll ans=0;
        if(sum==3)
        {
            ans=a[1]*a[2]*a[3];
        }
        else if(sum==4)
        {
            ans=a[1]*a[2]*a[3]+a[1]*a[2]*a[4]
            +a[1]*a[3]*a[4]+a[2]*a[3]*a[4];
            //cout<<ans<<endl;
        }
        else if(sum==5)
        {
            ans=a[1]*a[2]*a[3]+
            a[1]*a[2]*a[4]+
            a[1]*a[2]*a[5]+
            a[1]*a[3]*a[4]+
            a[1]*a[3]*a[5]+
            a[1]*a[4]*a[5]+
            a[2]*a[3]*a[4]+
            a[2]*a[3]*a[5]+
            a[2]*a[4]*a[5]+
            a[3]*a[4]*a[5];
            //cout<<ans<<endl;

        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 11392
#include<stdio.h>
#define ABC 1000

int main(void)
{
   int a[ABC],b[ABC],sum[ABC];
   int i,q;
   char kigou[ABC];
   
   for(i=0;i>=0;++i){
      scanf("%d %c %d", &a[i], &kigou[i], &b[i]);
      
      if(kigou[i]=='?'){
         break;}
         
      else if(kigou[i]=='+'){
         sum[i] = a[i]+b[i];}
         
      else if(kigou[i]=='-'){
         sum[i] = a[i]-b[i];}
         
      else if(kigou[i]=='*'){
         sum[i] = a[i]*b[i];}
         
      else if(kigou[i]=='/'){
         sum[i] = a[i]/b[i];}
   }
   
   for(q=0;q<i;q++){
      printf("%d\n", sum[q]);}
      
   return 0;
}


Measured memory_bytes: 2052
#include <cstdio>

int main(void){
		int H, W;
		scanf("%d %d", &H, &W);
		while(H != 0 || W != 0){
				for(int i = 0; i < H; i++){
						if(i == 0 || i == H - 1){
								for(int j = 0; j < W; j++){
										printf("#");
								}
								printf("\n");
						}else{
								for(int j = 0; j < W; j++){
										if(j == 0 || j == W - 1)printf("#");
										else printf(".");
								}
								printf("\n");

						}
				}
				printf("\n");
				scanf("%d %d", &H, &W);
		}

		return 0;
}



Measured memory_bytes: 2592
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



int main()
{

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll a, b;
		cin >> a >> b;

		if (a > b) {
			swap(a, b);
		}

		if (a == b) {
			cout << 2 * a - 2 << endl;
		}
		else if (a + 1 == b) {
			cout << 2 * a - 2 << endl;
		}
		else {
			ll l = 0;
			ll r = b;
			ll mid = (l + r) / 2;
			
			while (l != mid) {
				if (mid * mid < a * b) {
					l = mid;
				}
				else {
					r = mid;
				}

				mid = (l + r) / 2;
			}

			ll c = l;
			if (c * (c + 1) >= a* b) {
				cout << 2 * c - 2 << endl;
			}
			else {
				cout << 2 * c - 1 << endl;
			}
		}
	}

}  



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

int n, m;

int main () 
{
	cin >> n >> m;
  
	int arr[n], sum = 0, s = m;
  
	for (int i = 0; i < n; i++) 
    {
		cin >> arr[i];
		sum += arr[i];
	}
  
	for (int i = 0; i < n; i++) 
    {
		if (m == 0) 
        {
			break;
		}
      
		if (arr[i] * 4 * s >= sum) m--;
	}
	cout << (m == 0 ? "Yes" : "No") << endl;
	return 0;
}


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

int main(void) {
  for (ll N, W; cin >> N >> W, N && W;) {
    vector<ll> V(N);
    REP(i, 0, N) cin >> V[i];

    map<ll, ll> cnt;
    REP(i, 0, N) {
      ll t = V[i] / W;
      cnt[t]++;
    }

    vector<pair<ll, ll>> bars;
    ll r = -1;
    for (auto p : cnt) {
      bars.push_back(pair<ll, ll>(p.second, p.first));
      r = max(r, p.first);
    }
    sort(bars.begin(), bars.end(), greater<pair<ll, ll>>());

    double ans = 0.01;
    ll h0 = bars[0].first, c0 = r;
    REP(i, 0, bars.size()) {
      double h = (double) bars[i].first / h0;
      double c = (double) (c0 - bars[i].second) / c0;
      ans += h * c;
    }
    printf("%.15lf\n", ans);
  }
}


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

int main(){
    vector<int> R1(3), R2(3), R3(3);
    for(int i=0;i<3;i++) cin >> R1[i];
    for(int i=0;i<3;i++) cin >> R2[i];
    for(int i=0;i<3;i++) cin >> R3[i];

    int N;
    cin >> N;

    vector<int> B(N);

    for(int i=0;i<N;i++) cin >> B[i];

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            if(R1[j] == B[i]) R1[j] = 1000;
            if(R2[j] == B[i]) R2[j] = 1000;
            if(R3[j] == B[i]) R3[j] = 1000;
        }
    }

    string ans = "No";

    if(R1[0] == 1000 & R1[1] == 1000 & R1[2] == 1000) ans = "Yes";
    if(R2[0] == 1000 & R2[1] == 1000 & R2[2] == 1000) ans = "Yes";
    if(R3[0] == 1000 & R3[1] == 1000 & R3[2] == 1000) ans = "Yes";
    if(R1[0] == 1000 & R2[0] == 1000 & R3[0] == 1000) ans = "Yes";
    if(R1[1] == 1000 & R2[1] == 1000 & R3[1] == 1000) ans = "Yes";
    if(R1[2] == 1000 & R2[2] == 1000 & R3[2] == 1000) ans = "Yes";
    if(R1[0] == 1000 & R2[1] == 1000 & R3[2] == 1000) ans = "Yes";
    if(R1[2] == 1000 & R2[1] == 1000 & R3[0] == 1000) ans = "Yes";


    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 256
def abs(a, b)
  if a >= b
    return a - b
  else
    return b - a
  end
end
S = gets.chomp.split("")
min = 753
i = 0
while i + 2 < S.length
  a = 100 * S[i].to_i +  10 * S[i+1].to_i + S[i+2].to_i
  min = [min, abs(753, a)].min
  i += 1
end
puts min


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
lli dp[2005][2005];
int n;
vector<pair<lli,lli>> a;
lli fill(lli l,lli r){
    // print(l,r);
    if(dp[l][r]!=-1) return dp[l][r];
    int i = n - 1 - (r - l);
    if(l==r){
        dp[l][r] = abs(l - a[i].S) * a[i].F;
        return dp[l][r];    
    }
    
    dp[l][r] = max(fill(l+1,r) + abs(l - a[i].S) * a[i].F, fill(l,r-1) + abs(r - a[i].S) * a[i].F);
    // print(l, r, dp[l][r]);
    return dp[l][r];
}
int main()
{
    
    cin>>n;
    memset(dp,-1,sizeof(dp));
    a.resize(n);
    lli x;
    fori(n){
        cin>>x;
        a[i]=mp(x,i);
    }
    sort(a.rbegin(),a.rend());

    cout<<fill(0,n-1)<<endl;


}

Measured memory_bytes: 35152
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
	const int c[8][8] = {
		{1,2,1,2,1,4,1,4},
		{1,2,1,4,1,4,1,2},
		{1,4,1,2,1,2,1,4},
		{1,4,1,4,1,2,1,2},
		{2,1,2,1,4,1,4,1},
		{2,1,4,1,4,1,2,1},
		{4,1,2,1,2,1,4,1},
		{4,1,4,1,2,1,2,1},
	};

	while(1) {
		int p[8];
		int min = -1;
		int k;

		for(int i = 0; i < 8; i++)
			cin >> p[i];
		
		if(cin.eof()) break;

		for(int i = 0; i < 8; i++) {
			int count = 0;

			for(int j = 0; j < 8; j++)
				count += ((p[j] - c[i][j] > 0) ? p[j] - c[i][j] : 0);
			
			if(min == -1 || count < min) {
				min = count;
				k = i;
			}
		}

		for(int j = 0; j < 7; j++)
			cout << c[k][j] << " ";
		cout << c[k][7] << endl;
	}
	return 0;
}

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

const int mod = 1000*1000*1000+7;
const int MAXN = 100*1000+5;

void fix(int& a) {
    while(a < 0) a += mod;
    while(a >= mod) a -= mod;
}
int mul(int a, int b) { return 1LL * a * b % mod; }
int add(int a, int b) {
    fix(a), fix(b);
    a += b;
    fix(a);
    return a;
}
int mpow(int a, int n) {
    if(n == 0) return 1;
    int x = mpow(a, n/2);
    x = mul(x, x);
    if(n%2) x = mul(a, x);
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(k+1);
    int ans = 0;
    for(int i = k; i >= 1; i--) {
        cnt[i] = mpow(k/i, n);
        for(int j = 2; i*j <= k; j++) {
            cnt[i] = add(cnt[i], -cnt[i*j]);
        }
        ans = add(ans, mul(i, cnt[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3692
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextInt();
        double b = sc.nextInt();
        double x = sc.nextInt();
        double n = x/(double)a;
        double l;
        if (x>=a*a*(double)b/2){
            l = 2*(a*b-n)/a;
            b=a;
            a=l;
            l=b;
        }else {
            l = 2*n/b;
            a=b;
        }
        double d = Math.acos(Math.sqrt((l*l)/(l*l+a*a)));
        System.out.println(d/Math.PI*180);
    }
}


Measured memory_bytes: 35896
#include <iostream>
using namespace std;
int main() {
   int n;
   int b, f, r, v;
   int room[4][3][10];
   for (int j = 0; j < 4; j++){
       for (int k = 0; k < 3; k++){
           for (int l = 0; l < 10; l++){
               room[j][k][l] = 0;
           }
       }
   }
   cin >> n;
   for (int i = 0; i < n; i++)
   {
       cin >> b >> f >> r >> v;
       room[b-1][f-1][r-1] += v;
   }
   for (int j = 0; j < 4; j++){
       for (int k = 0; k < 3; k++){
           for (int l = 0; l < 10; l++){
               cout <<" " << room[j][k][l];
           }
           cout << endl;
       }
       if(j != 3){for (int m = 0; m < 20; m++){
           cout << "#";
       }
       cout << endl;}
   }
   return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    return *(int*)a-*(int*)b;
}

int main(void) {
    int n, y, i, j, k;
    scanf("%d%d", &n, &y);
    for (i=0;i<=n;i++) {
        for (j=0;j<=n-i;j++) {
            k = n - i - j;
            if (10000*i + 5000*j + 1000*k == y) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
##petite_prig   ono takaki

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    X=LI()
    M=I()
    A=LI_()

    exist=[0]*2021
    for i,x in enumerate(X):
        exist[x]+=1

    for a in A:
        where = X[a]
        if exist[where+1] or where == 2019:
            continue
        else:
            exist[where+1]+=1
            exist[where]-=1
            X[a]+=1
    print(*X,sep="\n")

if __name__ == '__main__':
    main()


Measured memory_bytes: 6412
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{ 
  int n, s, t;
  bool a[300001];
  vector<int> vec;
  fill(a, a+300001,true);
  a[1] = false;


  for(int i = 0; 7*i <= 300001; i++){
    s = 7*i+1;
    t = 7*i+6;
    if(a[s]){
      vec.push_back(s);
      for(int j = s+s; j <= 300001; j += s){
	a[j] = false;
      }
    }
    if(a[t]){
      vec.push_back(t);
      for(int j = t+t; j <= 300001; j += t){
	a[j] = false;
      }
    }
  }

  while(cin>>n && n > 1){
    cout << n << ":";
    for(int i = 0; i < vec.size(); i++){
      if(n%vec[i] == 0){
	cout << " " << vec[i];
      }
    }
    cout << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

#define mp make_pair

int n;
int arr[100005];
vector<pair<ll, ll> >ops;
ll res;

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

        sort(arr, arr + n);
        ops.clear();

        for(int i = 1; i + 1 < n; i++)
        {
            if(arr[i] <= 0)
            {
                ops.push_back(mp(arr[n - 1], arr[i]));
                arr[n - 1] -= arr[i];
            }
            else
            {
                ops.push_back(mp(arr[0], arr[i]));
                arr[0] -= arr[i];
            }
        }
        res = arr[n - 1] - arr[0];
        ops.push_back(mp(arr[n - 1], arr[0]));
        cout << res << endl;
        for(int i = 0; i < ops.size(); i++)
        {
            cout << ops[i].first << ' ' << ops[i].second << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree = 
//  tree<key, val, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;

int n, m, k;
int a[11];

void solve(int test)
{
  for (int i = 0; i < 4; ++i) {
    int x; cin >> x; a[x] = 1;
  }
  if (a[1] && a[7] && a[9] && a[4])
    cout << "YES\n";
  else
    cout << "NO\n";
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cerr << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000005;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n)cin >> h[i];
	//dp[i] i着くまでに最小のコスト
	int dp[100001];

	fill(dp,dp+n,INF);
	dp[0]=0;
	
	for(int i = 1;i<n;i++)
	{
		for(int j = max(0,i-k);j<i;j++)
		{
			dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m, k = list(map(int, readline().split()))
    MM = 998244353

    ans = 0
    com = 1

    for i in range(k + 1):
        l = n - i
        x = pow(m - 1, l - 1, MM)
        ans += m * x * com
        ans %= MM
        com *= n - (i + 1)
        com *= pow(i + 1, MM - 2, MM)
        com %= MM

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67588
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()
    ans = [0 for _ in range(n)]
    for x in range(1, 101):
        x2 = x**2
        for y in range(1, 101):
            xy = x * y
            y2 = y ** 2
            for z in range(1, 101):
                t = x2 + y2 + z**2 + xy + y*z + z*x
                if t <= n:
                    ans[t-1] += 1

    return "\n".join(map(str, ans))


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68028
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,k;
	cin >> n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++)
		cin >> a[i];
	n = 0;
	for(int pos=1;pos != 2;n++){
		if(a[pos] == -1){
			n = -1;
			break;
		}
		k = a[pos];
		a[pos] = -1;
		pos = k;
	}
	cout << n << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		sc.close();

		// for (int i = A; i < B+1; i++) {
		// if(i%C!=0&&i%D!=0)
		// cnt++;
		// };
		// とやると10^18なのでたぶんTLE
		// BまでのCの倍数の数:NbC
		// Dの倍数の数:NbD
		// CDの倍数の数:NbCD
		// B-(NbC+NbD-NbCD)って話だと思う
		// 同様にA-1までのCの倍数の数:NaC

		// 入力例2に助けられたC*Dに公約数があるとそれで重複する
		// NbCDは最小公倍数の倍数
		// 最小公倍数はC*D/最大公約数
		// これでもO(C)でやったらTLEでは
		// ユークリッドの互除法がいいらしい

		// long maxKouyakusu = 1;
		// for (int i = 2; i < C + 1; i++) {
		// if (C % i == 0 && D % i == 0)
		// maxKouyakusu = i;
		// }
		// System.out.println(maxKouyakusu);
		long smaller;
		long r_i;
		long r_i1;
		long t_A = C;
		long t_B = D;
		if (t_A >= t_B) {
			smaller = t_B;
			r_i = t_A - t_B;
			r_i1 = t_B;
		} else {
			smaller = t_A;
			r_i = t_B - t_A;
			r_i1 = t_A;
		}
		while (r_i != 0) {
			t_A = smaller;
			t_B = r_i;
			r_i1 = r_i;
			if (t_A >= t_B) {
				smaller = t_B;
				r_i = t_A - t_B;
			} else {
				smaller = t_A;
				r_i = t_B - t_A;
			}
		}

		long NbC = B / C;
		long NbD = B / D;
		long NbCD = B / (C * D / r_i1);

		long NaC = (A - 1) / C;
		long NaD = (A - 1) / D;
		long NaCD = (A - 1) / (C * D / r_i1);

		long ans = B - NbC - NbD + NbCD - (A - 1 - NaC - NaD + NaCD);

		System.out.println(ans);

	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    cin >> A;
    int ans = INF;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            ans = min(ans, A[N - 1] - A[0]);
        } else {
            ans = min(ans, K - (A[i + 1] - A[i]));
        }
    }
    cout << ans << endl;
}


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

int main(){
    long long n,m,v,p,ans;
    cin>>n>>m>>v>>p;
    vector<long long>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end(),std::greater<long long>());
    a.erase(a.begin(),a.begin()+p-1LL);
    a.push_back(-1000000000LL);
    long long ng=n-(p-1),ok=0LL,mid;
    while(abs(ok-ng)>1LL){
        mid=(ok+ng)/2LL;
        long long final_score=a[mid]+m,tmp=0LL;
        if(a[0]>final_score){ng=mid;continue;}
        for(int i=0;i<mid;i++)tmp+=final_score-a[i];
        tmp+=m*p+m*((n-(p-1LL))-mid-1LL);
        if(m*v<=tmp)ok=mid;
        else ng=mid;
    }
    cout<<p-1LL+ok+1LL<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,t[105],u;
long long gcd(long long a,long long b)
{
	if(b==0)
	{
		return a;
	}
	return gcd(b,a%b);
}
long long lcm(long long x,long long y)
{
	return x/gcd(x,y)*y;
}
int main()
{
	scanf("%llu",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%llu",&t[i]);
	}
	if(n==1)
	{
		printf("%llu",t[1]);
	}else
	{
		u=lcm(t[1],t[2]);
		for(int i=3;i<=n;i++)
		{
			u=lcm(u,t[i]);
		}
		printf("%llu",u);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N;
    ll A,B,K;
    set<ll> S;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>K;
    REP(i,K){
        if(A+i<=B)S.insert(A+i);
        if(A<=B-i)S.insert(B-i);
    }
    for(auto x:S){
        cout<<x<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int dfs(int node)
{
	vector<int> c;
	for (int u:v[node])
	c.push_back(dfs(u));
	sort(c.begin(),c.end(),greater<int>());
	int ret=0;
	for (int i=0;i<c.size();i++)
	ret=max(ret,c[i]+i+1);
	return ret;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=2;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		v[a].push_back(i);
	}
	printf("%d",dfs(1));
}

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

using namespace std;

int n;
long long L, a[100005];

int main() {
    int id = 0;
    cin >> n >> L;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i < n; i++) {
        if(a[i] + a[i + 1] >= L) id = i;
    }
    if(id == 0) return printf("Impossible\n"), 0;
    printf("Possible\n");
    for(int i = 1; i < id; i++) printf("%d\n", i);
    for(int i = n - 1; i > id; i--) printf("%d\n", i);
    printf("%d\n", id);
    return 0;
}

//09:08:00

Measured memory_bytes: 1536
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] field = new char[h][];
		for (int i = 0; i < h; i++) {
			field[i] = sc.next().toCharArray();
		}
		Num[][] hors = new Num[h][w];
		for (int i = 0; i < h; i++) {
			Num num = new Num();
			for (int j = 0; j < w; j++) {
				if (field[i][j] == '#') {
					num = new Num();
					hors[i][j] = num;
					num = new Num();
				} else {
					num.add();
					hors[i][j] = num;
				}
			}
		}
		Num[][] vars = new Num[h][w];
		for (int i = 0; i < w; i++) {
			Num num = new Num();
			for (int j = 0; j < h; j++) {
				if (field[j][i] == '#') {
					num = new Num();
					vars[j][i] = num;
					num = new Num();
				} else {
					num.add();
					vars[j][i] = num;
				}
			}
		}
		int max = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int x = hors[i][j].getVal() + vars[i][j].getVal() - 1;
				if (max < x) {
					max = x;
				}
			}
		}
		System.out.println(max);
	}
	
	static class Num {
		int val;
		
		public Num() {
			val = 0;
		}
		
		public void add() {
			val++;
		}
		
		public int getVal() {
			return val;
		}
	}
}


Measured memory_bytes: 314420
#include <bits/stdc++.h>
using namespace std;
int main(){
string a,b;
bool flag=false;
cin >> a >> b;
int num = stoi(a+b);
  for(int i=0;i<1001;i++){
  int p=i*i;
  if(p==num)flag=true;}
if(flag)cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int p;
	int total = 0;

	cin >> n;
	p = n;
	while (1) {
		total += (n % 10);
		n /= 10;
		if (n == 0) {
			break;
		}
	}
	if (p%total == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  cin >> n;
  long long int ans;
  ans = n*n*n;
  cout << ans << endl;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q,l,r, x, y, u, v, n, m;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll flag=0;
    while(a>0 and c>0)
    {
      if(flag)
      { 
        a-=d;
      }
      else{
        c-=b;
      }
      flag=1-flag;
    }

    if(a<=0)
    cout<<"No";
    else
    cout<<"Yes";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10644
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;

	bool flag = false;
	int len = (int)S.size();
	for (int i = 0; i < len; i++) {
		if (S[i] == T[0]) {
			for (int j = 0; j < len; j++) {
				if (S[(i + j) % len] != T[j]) break;
				if (j == len - 1) flag = true;
			}
		}
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a[1100],b,m,n,i,j=0,k=0,l=0,p=5000,x=0,y=0,z=0;
    char s[1000],ss[1000],c;

    scanf("%d %d",&n,&x);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        y=a[i]+y;
        if(a[i]<p) p=a[i];
    }
    z=x-y;
    z=z/p;
    printf("%d\n",z+n);
    return 0;
}

Measured memory_bytes: 128
from math import gcd

N = int(input())
A = list(map(int, input().split()))

g_all = A[0]
for a in A[1:]:
    g_all = gcd(g_all, a)

if g_all > 1:
    print('not coprime')
    quit()

def min_div(n):
    if n <= 1:
        return []
    elif n == 2:
        return [0, 1, 2]
    D = [0] * (n+1)
    D[1] = 1
    D[2::2] = [2] * (n//2)
    len_list = (n + 1) // 2
    len_sqrt = int(len_list ** 0.5) + 1
    flags = [True] * len_list
    for i in range(1, len_sqrt):
        if flags[i]:
            p = i*2 + 1
            start = (p ** 2) // 2
            for j in range(start, len_list, p):
                flags[j] = False
                D[j*2 + 1] = p
    
    for i in range(1, len_list):
        if flags[i]:
            p = i*2 + 1
            D[p] = p
    
    return D

D = min_div(10**6)
appeared = [False] * (10**6 + 1)
for a in A:
    if a == 1:
        continue
    s = set()
    while a != D[a]:
        d = D[a]
        if appeared[d]:
            print('setwise coprime')
            quit()
        s.add(d)
        a //= d
    
    if appeared[a]:
        print('setwise coprime')
        quit()
    
    for d in s:
        appeared[d] = True
    
    if a != 1:
        appeared[a] = True

print('pairwise coprime')

Measured memory_bytes: 200816
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    Int T; cin >> T;
    Int ans = 0;
    bool first = true;
    while (T) {
        if (T <= 3) {
            ans += T;
            break;
        } else if (T % 3 == 0) {
            T -= 3;
            ans += 3;
        } else if (T % 3 == 1 && first) {
            T -= 1;
            ans += 1;
        } else if (T % 3 == 1 && !first) {
            T -= 4;
            ans += 4;
        } else if (T % 3 == 2) {
            T -= 2;
            ans += 2;
        }
        first = false;
        T /= 3;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3204
S=input()
hoge=S[2:-1]
result=False
if S[0]=="A":
    if "C" in hoge:
        a=S[1:hoge.find("C")+2]+S[hoge.find("C")+3:]
        if a==a.lower():
            result=True
if result==True:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

    int n, m, res1, res2, z;

    scanf("%d %d", &n, &m);

    if(n!=1){
        res1 = n*(n-1)/2;
    }else{
        res1 = 0;
    }

    if(m!=1){
        res2 =m*(m-1)/2;
    }else{
        res2 = 0;
    }

    z = res1 +res2;

    printf("%d\n", z);

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int k, a, b;

    cin >> k >> a >> b;
    for(; a <= b; a ++)
        if(!(a % k))
        {
            cout << "OK" << endl;
            return 0;
        }
    cout << "NG" << endl;

    return 0;
}


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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	
	if (a > b || (n == 1 && a != b)) {
		cout << 0 << endl;
		return 0;
	}
	
	long long mmax = (n - 1) * b + a;
	long long mmin = (n - 1) * a + b;
	
	cout << 1 + mmax - mmin << endl;
	return 0;
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;



int main(){
    llint H;
    cin>>H;

    llint count=1;
    llint ans=1;
    while(H>1){
        H/=2;
        count*=2;
        ans+=count;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        sc.close();

        if (a + b + 1 >= c) {
            System.out.println(b + c);
        } else {
            System.out.println(a + b * 2 + 1);
        }
    }
}


Measured memory_bytes: 22868
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let k = read::<usize>();

    let mut substrings = BTreeSet::new();

    for l in 0..s.len() {
        let mut chars = vec![s[l]];
        for r in l + 1..s.len() + 1 {
            substrings.insert(chars.clone());
            if r - l == k {
                break;
            }
            if r <= s.len() - 1 {
                chars.push(s[r]);
            }
        }
    }
    for ch in substrings.iter().nth(k - 1).unwrap() {
        print!("{}", ch);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s = line.Trim().Split(' ');
            var a = int.Parse(s[0]);
            var b = int.Parse(s[1]);
            Console.WriteLine((a + b).ToString().Length);
        }
    }
}

Measured memory_bytes: 9140
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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 / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

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

    return 0;
}

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

int main() {
    int64_t N, r = 0, b = 0, g = 0, ans;
    string S = " ";
    cin >> N;
    for (int i = 0; i < N; i++) {
        char s;
        cin >> s;
        if (s == 'R') r++;
        else if (s == 'B') b++;
        else g++;
        S += s;
    }
    ans = r * b * g;
    for (int i = 1; i <= N - 2; i++) {
        for (int j = i + 1; j <= N - 1; j++) {
            if (S[i] != S[j]) {
                int k = 2 * j - i;
                if (k <= N && S[j] != S[k] && S[k] != S[i]) {
                    ans--;
                }
            }
        }
    }
/*    for (int i = 1; i <= N - 2; i++) {
        for (int j = i + 1; j <= N - 1; j++) {
            if (S[i] != S[j]) {
                for (int k = j + 1; k <= N; k++) {
                    if (j - i != k - j) {
                        if (S[j] != S[k] && S[k] != S[i]) {
                            ans++;
                        }
                    }
                }
            }
        }
    }*/
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import numpy as np

x = int(input())
flag = False
for a in range(-200,200):
  for b in range(-200,200):
    if a<=b:
      break
    a_5 = np.power(a,5)
    b_5 = np.power(b,5)
    if a_5 - b_5 == x:
      flag =True
      print(a,b)
      break
  if flag:
    break


Measured memory_bytes: 27092
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
}


Measured memory_bytes: 36016
#include <iostream>
#define INF 100000000000
using namespace std;
int main(void){
  int N, K;
  std::cin >> N >> K;
  int h[N];
  for(int i = 0; i < N; i++) std::cin >> h[i]; 
  int dp[N];
  for(int i = 0; i < N; i++) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < N; i++){
  for(int j = 1; j <= min(K, N-i-1); j++){
    dp[i+j] = min(dp[i+j], dp[i]+ abs(h[i]-h[i+j]));
  }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

K = input_int()

if K < 10:  # 1桁の数はすべてlun_lun
    print(K)
else:  # 桁数の小さいものからlun_lun数を生成し，queueに加えていく
    dq = deque([i for i in range(1, 10)])
    count = 0
    while True:
        x = dq.popleft()
        count += 1
        if count == K:
            print(x)
            exit()
        d = x % 10
        if d != 0:
            dq.append(10 * x + d - 1)
        dq.append(10 * x + d)
        if d != 9:
            dq.append(10 * x + d + 1)

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

int main()
{
	int n, t;
	vector<int> vec;

	cin >> n >> t;

	int y;
	for (int i = 0; i < n; i++)
	{
		cin >> y;
		vec.push_back(y);
	}

	int ans = 0; 
	for (int i = 1; i < vec.size(); i++)
	{
		if (t >= vec[i] - vec[i - 1])
		{
			ans = ans + (vec[i] - vec[i - 1]);
		}
		else
		{
			ans = ans + t;
		}
	}

	ans = ans + t;
	cout << ans;

	return 0;
}

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

int main() {
 int N = 0;
 cin >> N;

 string ans;
 int cnt = 0;

 for(int i = 1; i < 10; i++) {
	if(N % i == 0 && (N / i) < 10) {
		cnt++;
	}
	if(cnt > 0) {
		ans = "Yes";
		continue;
	}
 } 

 if(cnt == 0) {
	ans = "No";
 }

 cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int h, n;cin>>h>>n;
  fr(i, n){
   int a;cin>>a;
   h -= a;
  }
  cout << (h > 0 ?"No":"Yes") << endl;

  return 0;
}

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

int main(void){
    ll x, k, d, ans;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d >= k){
            ans = x - k * d;
    } else {
            k -= x / d;
            if(k % 2 == 0){
                    ans = x - d * (x / d);
            } else {
                    ans = d * (x / d + 1) - x;
            }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int parent[25];
int left[25];
int right[25];

void preorder(int node){
    if(node == -1) return;
    printf(" %d", node);
    preorder(left[node]);
    preorder(right[node]);
}

void inorder(int node){
    if(node == -1) return;
    inorder(left[node]);
    printf(" %d", node);
    inorder(right[node]);
}

void postorder(int node){
    if(node == -1) return;
    postorder(left[node]);
    postorder(right[node]);
    printf(" %d", node);
}

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        parent[i] = -1;
    for(int i=0; i<n; i++){
        int id, l, r;
        scanf("%d%d%d", &id, &l, &r);
        left[id] = l;
        right[id] = r;
        if(l != -1) parent[l] = id;
        if(r != -1) parent[r] = id;
    }
    int root = 0;
    for(;root < n; root++)
        if(parent[root] == -1)
            break;
    puts("Preorder");
    preorder(root);
    puts("");
    puts("Inorder");
    inorder(root);
    puts("");
    puts("Postorder");
    postorder(root);
    puts("");
}



Measured memory_bytes: 2040
// R I S E
/* Dedication has no limitation 
                   - Ulisses Jr.
*/
// 16 MAY  2019
#include <bits/stdc++.h>
using namespace std;

int main()
{ int n;
 cin >> n;
 vector<int> v(n);
 vector<int> c(n);
 
 for(int i=0; i<n; i++){
   cin >> v[i];
 }
 
for(int i=0; i<n; i++){
   cin >> c[i];
 }
 
 int sum = 0;
 for(int i=0; i<n; i++){
   if(v[i] >= c[i]){sum+=v[i]-c[i];}
 }
 cout << sum << endl;

return 0;

}




 

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    string s; cin>>s;
    int K; cin>>K;
    vector<string> Kth(K); REP(i,K) Kth[i] = "zzzzz";
    REP(left,s.size()) {
        for (int right=left+1; right-left<=K; right++) {
            REP(i,K) {
                auto tmp = s.substr(left,right-left);
                if (tmp==Kth[i]) break;
                if (tmp<Kth[i]) {
                    Kth.insert(Kth.begin()+i,tmp);
                    Kth.pop_back();
                    break;
                }
            }
        }
    }
    cout<<Kth[K-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#define J -1
using namespace std;

int main()
{
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;

  if(x-r<0||y-r<0||x+r>W||y+r>H) cout << "No" <<endl;
  else cout << "Yes" <<endl;
  return 0;
}

Measured memory_bytes: 3120
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;


int main(void){
	long long N, M, x[1000], y[1000], z[1000];
	long long sgn_x, sgn_y, sgn_z;
	long long c, ans;
	long long t[1000];

	scanf("%lld %lld", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
	}

	/*±x[i]±y[i]±z[i]という形の8通りの和それぞれについて、大きいほうからM個の和を計算する*/

	ans = 0;
	for (int sgn = 0; sgn < 8; sgn++) {
		sgn_x = (sgn % 2) * 2 - 1;
		sgn_y = ((sgn / 2) % 2) * 2 - 1;
		sgn_z = ((sgn / 4) % 2) * 2 - 1;

		for (int i = 0; i < N; i++) {
			t[i] = sgn_x * x[i] + sgn_y * y[i] + sgn_z * z[i];
		}
		sort(t, t + N);
		c = 0;
		for (int j = 0; j < M; j++) {
			c = c + t[N - 1 - j];
		}
		if (ans <= c) { ans = c; }
	}

	printf("%lld\n", ans);

}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
char toupper(char c);
char toupper(char c)
{
    return (c - 0x20);
}

using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a != c)
    {
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
	int biao=0,lena;
	cin>>a;
	lena=a.size();
	for(int i=0;i<lena;++i)
	{if(a[i]=='C')
	biao=1;
	if(a[i]=='F'&&biao==1)
	{cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256