akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
}


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

int main()
{
  long long A;
  string B;
  cin >> A >> B;
  long long dig1, dig2, dig3;
  dig1 = B[0] - '0';
  dig2 = B[2] - '0';
  dig3 = B[3] - '0';
  long long ans = 0;
  dig1 *= A;
  dig2 *= A;
  dig3 *= A;
  int dig2mod = dig2%10;
  int dig3mod = dig3%100;
  dig2 /= 10;
  dig3 /= 100;
  ans += dig1+dig2+dig3;
  if (dig2mod*10+dig3mod >= 100) ans++;
  cout << ans << endl;
}


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

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

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

    vector<int> sum(m + 1);
    for (int i = 1; i <= m; i++) {
        sum[i] = sum[i - 1] + i;
    }

    vector<double> exp(n);
    for (int i = 0; i < n; i++) {
        exp[i] = (double)sum[a[i]] / (double)a[i];
    }

    for (int i = 1; i < n; i++) {
        exp[i] += exp[i - 1];
    }

    double ans = 0.0;
    for (int i = k - 1; i < n; i++) {
        double res = 0.0;
        if(i == k - 1) res = exp[i];
        else {
            res = exp[i] - exp[i - k];
        }
        ans = max(ans,res);
    }
    cout << fixed << setprecision(10) <<  ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if(k - a > 0)
  {
    ans += 1*a;
    k -= a;
    if(k - b <= 0)
    {
      cout << ans << endl;
      return 0;
    }
    else
    {
      k -= b;
      if(k - c > 0)
      {
        ans += -1*c;
      }
      else
      {
        ans += -1*k;
      }
    }
  }
  else
  {
    ans += 1*k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int a[81][81];
vector<int> v[81][2];
bool vis[81][512001][2];
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++) cin >>a[i][j];
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			int x;
			cin >>x;
			a[i][j]=abs(a[i][j]-x);
		}
	}
	v[0][0].push_back(a[0][0]);
	vis[0][a[0][0]][0]=1;
	int k=0;
	for (int i=0;i<n;i++,k^=1)
	{
		for (int j=0;j<m;j++)
		{
			for (int it=0;it<v[j][k^1].size();it++)
				vis[j][v[j][k^1][it]][k^1]=0;
			v[j][k^1].clear();
		}
		for (int j=0;j<m-1;j++)
		{
			for (int it=0;it<v[j][k].size();it++)
			{
				int x=v[j][k][it];
				if (!vis[j+1][x+a[i][j+1]][k])
				{
					v[j+1][k].push_back(x+a[i][j+1]);
					vis[j+1][x+a[i][j+1]][k]=1;
				}
				if (!vis[j+1][abs(x-a[i][j+1])][k])
				{
					v[j+1][k].push_back(abs(x-a[i][j+1]));
					vis[j+1][abs(x-a[i][j+1])][k]=1;
				}
			}
		}
		if (i==n-1) break;
		for (int j=0;j<m;j++)
		{
			for (int it=0;it<v[j][k].size();it++)
			{
				int x=v[j][k][it];
				if (!vis[j][x+a[i+1][j]][k^1])
				{
					v[j][k^1].push_back(x+a[i+1][j]);
					vis[j][x+a[i+1][j]][k^1]=1;
				}
				if (!vis[j][abs(x-a[i+1][j])][k^1])
				{
					v[j][k^1].push_back(abs(x-a[i+1][j]));
					vis[j][abs(x-a[i+1][j])][k^1]=1;
				}
			}
		}
	}
	cout <<*min_element(v[m-1][k].begin(),v[m-1][k].end());
	return 0;
}

Measured memory_bytes: 83200
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string a;
    cin >> a;
    a[0]++;
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,D,X;
    cin >> N >> D >> X;
    
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    int cnt = 0;
    for(int i=0;i<N;i++){
        int j=1;
        while(j<=D){
            j += A.at(i);
            cnt++;
        }
    }
    
    cout << X + cnt << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(200);
  for(int i = 0; i < n; i++) cin >> a.at(i);

  int count = 0;
  while(true){
    // 奇数かどうか確認
    bool exist_odd = false;
    for(int i = 0; i < n; i++){
      if(a.at(i) % 2 != 0) exist_odd = true;
    }
    if(exist_odd) break;

    // ２で割る
    for(int i = 0; i < n; i++){
      a.at(i) /= 2;
    }
    count++;
  }
  cout << count << endl;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-12;


int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll X,Y;cin >> X >> Y;
	if(X%Y == 0) cout << -1;
	else cout << X;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/




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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int a,b,c,k;
   cin >> a >> b >> c >> k;
   cout << (max({a,b,c}) << k) + a+b+c - max({a,b,c}) << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    
    char const* rel = "==";
    
    if (a < b) {
        rel = "<";
    } else if (a > b) {
        rel = ">";
    }
    
    std::cout << "a " << rel << " b\n";
}


Measured memory_bytes: 3036
# E - Multiplication 4
import heapq
N, K = map(int, input().split())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7


if N == K:
    ans = 1
    for a in A:
        ans = (ans * a) % MOD
else:
    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)

    if len(neg) == N and K&1 == 1:
        neg.sort(reverse=True)
        ans = 1
        for i in range(K):
            ans = (ans * neg[i]) % MOD
    else:
        pos.sort(reverse=True)
        dbl = []
        ans = 1
        ini = 0
        rem = K
        if K&1 == 1:
            ans = (ans * pos[0]) % MOD
            ini = 1
            rem -= 1
        for i in range(0, (len(pos)-ini)//2):
            heapq.heappush(dbl, (pos[ini+i*2] * pos[ini+i*2+1])*-1)
        neg.sort()
        for i in range(0, len(neg)//2):
            heapq.heappush(dbl, (neg[i*2] * neg[i*2+1]) * -1)
        while rem > 0:
            ans = (ans * heapq.heappop(dbl) * -1) % MOD
            rem -= 2

print(ans)

Measured memory_bytes: 31800
#include <iostream>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    while(--n){
        int i;
        std::cin >> i;
        ++v[i-1];
    }
    for(const int &i: v)
        std::cout << i << '\n';
}


Measured memory_bytes: 3996
n,w=map(int,input().split())
wi=[]
vi=[]

for i in range(n):
  a,b=map(int,input().split())
  wi+=[a]
  vi+=[b]
  
dp=[[0]*(w+1) for i in range(n+1)]

for i in range(n):
  for j in range(w+1):
    if j<wi[i]:
      dp[i+1][j]=dp[i][j]
      
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-wi[i]]+vi[i])
      
print(dp[n][w])

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

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

	ll ct, ca;
	cin >> ct >> ca;


	rep(i, n - 1) {
		ll t, a;
		cin >> t >> a;
		ll k = max( (ct + t - 1) / t , (ca + a - 1) / a);
		ct = 1LL * t * k, ca = 1LL * a * k;
	}

	cout << ct + ca  << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define $ ios::sync_with_stdio(0);
#define S second
using namespace std;
using ll = long long int;
using vi = vector<pair<int, int> >;
using graph = vector<vi>;
const int MAXN = 212345;
string vs[4];
int main() {$
    for (int i = 0; i<3; ++i) {
        cin >> vs[i];
        reverse(vs[i].begin(), vs[i].end());
    }
    int cur = 0, nxt = 0; 
    while (vs[nxt].size()) {
        cur = nxt;
        nxt = vs[cur].back()-'a';
        vs[cur].pop_back();
    }
    cout << (char)('A'+nxt) << endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;


long long int power(long long int a,long long int b){
    long long int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}


int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	double n,m,T,res;

	ll int maxi=-mx,mini=mx,count=0;

	ll int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	res=n-m;

	double sum=(double)res*100.0;

	ll prob=power(2,m);

//	ll x=prob;
//
//	for(i=1;i<32;i++){
//        sum+=( (((double)i*1900.0)/(double)x));
//        x=prob*x;
//
//	}

//    for(i=1;i<=m;i++){
//        sum*=2;
//    }

	cout<<((1900*m)+sum)*prob<<endl;

}


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

long long int ar[100000000],dp[100000000];
void rec(int i, int n) {
    if(i==n) return;

    dp[i]=min(dp[i-2]+abs(ar[i-2]-ar[i]),dp[i-1]+abs(ar[i-1]-ar[i]));
    rec(i+1, n);
}

int main()
{
    ios_base::sync_with_stdio(false);
    memset(dp,0, 100000000*sizeof(dp[0]));
    long long int n,i,j,k,a,b,c;
    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    dp[1]=abs(ar[0]-ar[1]);
    rec(2,n);
    cout<<dp[n-1]<<"\n";
    return 0;
}




Measured memory_bytes: 782592
#include <iostream>
#include <vector>

using namespace std;

typedef struct {
    int y1, x1, y2, x2;
} op;

int main() {
    int h, w;
    cin >> h >> w;

    int a[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    vector<op> ops;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] % 2) {
                if (j < w - 1) {
                    a[i][j]--;
                    a[i][j+1]++;
                    op d;
                    d.y1 = i + 1;
                    d.x1 = j + 1;
                    d.y2 = i + 1;
                    d.x2 = j + 2;
                    ops.push_back(d);
                } else if (i < h - 1) {
                    a[i][j]--;
                    a[i+1][j]++;
                    op d;
                    d.y1 = i + 1;
                    d.x1 = j + 1;
                    d.y2 = i + 2;
                    d.x2 = j + 1;
                    ops.push_back(d);
                }
            }
        }
    }

    cout << ops.size() << endl;
    for (int i = 0; i < ops.size(); i++) {
        cout << ops[i].y1 << " " << ops[i].x1 << " "
             << ops[i].y2 << " " << ops[i].x2 << endl;
    }

    return 0;
}

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

struct UnionFind{
    int n;
    vector<int> p;
    vector<int> group_size;
    ll inconvenience;
    UnionFind(int n) : n(n), inconvenience((ll)n * (n - 1) / 2) {
        p.resize(n);
        group_size.resize(n);
        rep(i, n) p[i] = i;
        rep(i, n) group_size[i] = 1;
    }
    int root(int x){
        if(p[x] == x) return x;
        else return p[x] = root(p[x]);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x != y) {
            inconvenience -= (ll)group_size[y] * (n - group_size[y]);
            inconvenience -= (ll)group_size[x] * (n - group_size[x]);
            inconvenience += (ll)group_size[y] * group_size[x];

            p[y] = x;
            group_size[x] += group_size[y];
            group_size[y] = 0;
            inconvenience += (ll)group_size[x] * (n - group_size[x]);
        }
    }
    bool query(int x,int y){
        return root(x) == root(y);
    }
};

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

    vector<ll> ans(M);

    {
        UnionFind uf(N);
        for(int i = M - 1; i >= 0; i--) {
            ans[i] = uf.inconvenience;
            uf.unite(A[i] - 1, B[i] - 1);
        }
        cerr << uf.inconvenience << endl;
    }

    rep(i, M) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
const int Maxn=1e5+10;
struct EDGE{int x,y,next;}edge[Maxn*2]; int len,first[Maxn];
void ins(int x,int y){len++; edge[len].x=x; edge[len].y=y; edge[len].next=first[x]; first[x]=len;}
int N,M; int C[Maxn];
 
int u,v,opt; bool vis[Maxn];
void Find_Cir(int x,int fa,int col)
{
  C[x]=col; vis[x]=1;
  for(int k=first[x];k!=-1;k=edge[k].next)
  {
    int y=edge[k].y;
    if(x==u&&y==v) continue;
    if(y!=fa)
    {
      if(vis[y]){u=x; v=y; if(C[u]==C[v]) opt=1; else opt=0;}
      else Find_Cir(y,x,-col);
    }
  }
}
 
int G[Maxn],F[Maxn];
void Dfs(int x,int fa)
{
  F[x]=C[x];
  for(int k=first[x];k!=-1;k=edge[k].next)
  {
    int y=edge[k].y;
    if(x==u&&y==v) continue;
    if(x==v&&y==u) continue;
    if(y!=fa)
    {
      Dfs(y,x);
      F[x]+=F[y]; G[x]+=G[y];
    }
  }
}
 
int A[Maxn]; int Alen;
 
int main()
{
  int Tcase=1;
  while(Tcase--)
  {
    scanf("%d%d",&N,&M); len=0; memset(first,-1,sizeof(first));
    for(int i=1;i<=M;i++){int x,y; scanf("%d%d",&x,&y); ins(x,y); ins(y,x);}
    memset(vis,0,sizeof(vis)); memset(C,0,sizeof(C));
    u=v=0; Find_Cir(1,0,1);
    if(M==N-1)
    {
      Dfs(1,0);
      if(F[1]) printf("-1\n");
      else{int ans=0; for(int i=1;i<=N;i++) ans+=abs(F[i]); printf("%d\n",ans);}
    }
    else if(opt==1)
    {
      Dfs(1,0);
      int t=F[1],ans=0;
      if(t&1) printf("-1\n");
      else
      {
        C[u]-=t/2; C[v]-=t/2; ans+=abs(t/2); memset(F,0,sizeof F);
        Dfs(1,0); for(int i=1;i<=N;i++) ans+=abs(F[i]); printf("%d\n",ans);
      }
    }
    else if(opt==0)
    {
      Dfs(1,0);
      if(F[1]) printf("-1\n");
      else
      {
        memset(G,0,sizeof(G));
        G[u]--; G[v]++; memset(F,0,sizeof F);
        Dfs(1,0); int ans=0; Alen=0; memset(A,0,sizeof(A));
        for(int i=1;i<=N;i++)
        {
          if(G[i]==-1) A[++Alen]=F[i];
          if(G[i]==0) ans+=abs(F[i]);
          if(G[i]==1) A[++Alen]=-F[i];
        }
        sort(A+1,A+Alen+1);
        for(int i=1;i<=Alen;i++) ans+=abs(A[i]-A[(Alen+1)>>1]);
        ans+=abs(A[(Alen+1)>>1]);
        printf("%d\n",ans);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 9344
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long x = 0;
    long y = 0;
    long min = n;

    for (int i = 1; i <= Math.sqrt(n); i++) {
      if (n % i == 0) {
        x = i - 1;
        y = n/i - 1;
      }
      min = Math.min(min,x+y);
    }
    System.out.println(min);
  }
}


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

ll factorialMethod(int k){//階乗
    ll sum = 1;
    for (int i = 2; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


vector<int> x(10);
vector<int> y(10);

double distance(int i,int j){
    double xdis = (x[i] - x[j]);
    double ydis = (y[i] - y[j]);
    return pow(xdis*xdis + ydis * ydis,0.5);
}


int main() {
    int n;
    cin >> n;
    rep(i,n)cin >> x.at(i) >> y.at(i);
    vector<int> p(n,0);//permutation
    rep(i,n)p.at(i) = i;
    double ans = 0.0;
    do {
        for(int i = 0; i < n - 1; i++) ans += distance(p[i], p[i+1]);
    } while(next_permutation(p.begin(), p.end()));
    ll factrial = factorialMethod(n);
    
    //未完
    cout << fixed <<setprecision(10) << ans/factrial << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main(){
	cin >> S;
	int c=0, f=0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == 'C') c=1;
		if(c == 1 && S[i] == 'F') f=1;
	}

	if(f==1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int r, g, b;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    r = sc.nextInt();
    g = sc.nextInt();
    b = sc.nextInt();

    if((r * 100 + g * 10 + b) % 4 == 0){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main(void)
{
    int x,a,b,c;
    scanf("%d", &x);
    a = x / 500;
    b = (x - 500*a) / 5;
    printf("%d", a * 1000 + b * 5);


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll t, n, k;std::cin >> n >> k;
  vll num(10, 1), s;
  re(i, k) {
    std::cin >> t;
    num[t]--;
  }
  re(i, 10) if(num[i]==1) s.push_back(i);
  if(num[0] == 0) s.push_back(0);
  ll m = s.size();
  ll ans = 100000000000;
  re(i, m){
    re(j, m){
      re(k, m){
        re(l, m){
          re(r, m){
            ll tmp = s[i]*10000+s[j]*1000+s[k]*100+s[l]*10+s[r];
            string u  =to_string(tmp);
            bool flag = true;
            if(num[0]==0) for(int p=0;p<u.size();p++) if(u[p]=='0') flag = false;
            if(tmp>=n&&flag) ans = min(ans, tmp);
          }
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll inf=1e9;
int main(void){
    ll h,n;
    cin>>h>>n;
    vector<pair<ll,ll>> a(n);
    rep(0,i,n){
        cin>>a[i].first>>a[i].second;
    }
    ll dp[h+1];
    dp[0]=0;
    rep(1,i,h+1)dp[i]=inf;
    rep(0,i,h){
        rep(0,j,n){
            ll x=min(a[j].first+i,h),y=a[j].second;
            dp[x]=min(dp[i]+y,dp[x]);
        }
    }
    cout<<dp[h]<<endl;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int l, r, d; cin >> l >> r >> d;
    print(r / d - (l - 1) / d);

    return 0;
}

Measured memory_bytes: 3632
n = gets.chop.to_i
s = []
n.times { s << gets.chomp.to_s }
hash = s.each_with_object(Hash.new(0)){|v,o| o[v]+=1}
max = hash.values.max
bests = hash.select{|k,v| v == max}
puts bests.keys.sort

Measured memory_bytes: 53596
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

int main(void) {
    int n;
    cin >> n;
    rep1(i, n) {
        if ((int)floor(i * 1.08) == n) {
            cout << i << endl;
            return 0;
      }
    }
    cout <<":(" << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val usedAb = Array(n) { false }
    val iabList = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        Triple(it, a, b)
    }.toMutableList()
    val cdList = (1..n).map {
        val (c, d) = readLine()!!.split(' ').map(String::toInt)
        Pair(c, d)
    }.toMutableList().sortedBy { it.first }

    var ans = 0
    for ((c, d) in cdList) {
        val enableAB = iabList
                .filter { (it.second < c) && (it.third < d) && (usedAb[it.first].not()) }
                .sortedByDescending { it.third }
        if (enableAB.isNotEmpty()) {
            val (i, a, b) = enableAB[0]
            usedAb[i] = true
            ans++
        }
    }
    println(ans)
}

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

using namespace std;

int main()
{
    long long int n;
    int ans = 100;

    cin >> n;

    for (long long int i = 1; i*i <= n; i++) {
        if (!(n%i)) {
            string s, t;
            s = to_string(i);
            t = to_string(n/i);
            if (ans > max(s.size(), t.size())) {
                ans = max(s.size(), t.size());
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> vec(N);
    for (int i = 0; i < N; ++i)
        cin >> vec[i];
    long long count = 1;
    long long minmin = vec[0];
    for (int i = 1; i < N; ++i)
    {
        minmin = min(minmin, vec[i - 1]);
        if (minmin >= vec[i])
            count++;
    }
    cout << count << "\n";
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

typedef enum
{
	true = 1,
	false = 0
} bool;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

void sort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)  
       for (j = 0; j < n-i-1; j++) 
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
}

bool isupper(char a)
{
	if (a <= 'z' && a >= 'a') return false;
	return true;
}

int main()
{
	char a[100];
	scanf("%s", a);
	int n = strlen(a);
	bool oneC = false;
	if (a[0] != 'A') {puts("WA"); return 0;}
	for (int i = 1; i < n; i++)
	{
		if (isupper(a[i]))
		{
			if (a[i] == 'C' && !oneC)
			{
				oneC = true;
				if (i >= 2 && i <= n-2) continue;
				else {puts("WA"); return 0;}
			}
			else {puts("WA"); return 0;}
		}
	}
	if (oneC) puts("AC");	
	else puts("WA");
	
	return 0;
}


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

using namespace std;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N), B, C;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] > 0) {
      B.emplace_back(A[i]);
    } else {
      C.emplace_back(A[i]);
    }
  }
  int64_t res = 1;
  if (K - min((K / 2) * 2, ((int)C.size() / 2) * 2) > (int)B.size()) {
    // smaller
    int b = 0, c = 0;
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    for (int i = 0; i < K; i++) {
      if (c == (int)C.size() || (b != (int)B.size() && B[b] < abs(C[c]))) {
        res *= B[b++];
      } else {
        res *= C[c++];
      }
      res %= MOD;
    }
  } else {
    // bigger
    sort(B.begin(), B.end(), greater<int64_t>());
    sort(C.begin(), C.end());
    int b = 0, c = 0;
    vector<int64_t> BB, CC;
    for (int i = 0; i < (int)B.size(); i += 2) {
      BB.emplace_back(B[i] * B[i + 1]);
    }
    for (int i = 0; i < (int)C.size(); i += 2) {
      CC.emplace_back(C[i] * C[i + 1]);
    }
    // for (const auto &v : BB) {
    //   cout << v << (&v == &BB.back() ? '\n' : ' ');
    // }
    // for (const auto &v : CC) {
    //   cout << v << (&v == &CC.back() ? '\n' : ' ');
    // }
    for (int i = 0; i < K / 2; i++) {
      if (c == (int)CC.size() || (b < (int)BB.size() && BB[b] > CC[c])) {
        res *= BB[b++] % MOD;
      } else {
        res *= CC[c++] % MOD;
      }
      res %= MOD;
    }
    if (K % 2 == 1) {
      res *= B[2 * b];
    }
  }
  cout << ((res % MOD) + MOD) % MOD << '\n';
  return 0;
}


Measured memory_bytes: 8040
import sys
from collections import Counter
from itertools import product, combinations
from copy import deepcopy

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    D = list(map(int, input().split()))

    cnt = Counter(D)
    S_init = [0]
    T = []
    for k, v in cnt.items():
        if k == 0:
            print(0)
            exit()
        elif k == 12:
            if v >= 2:
                print(0)
                exit()
            else:
                S_init.append(k)
        else:
            if v == 1:
                T.append(k)
            elif v == 2:
                S_init.append(k)
                S_init.append(24 - k)
            else:
                print(0)
                exit()

    res = 0
    for pattern in product([0, 1], repeat=len(T)):
        S = deepcopy(S_init)
        for idx, p in enumerate(pattern):
            if p == 1:
                S.append(24 - T[idx])
            else:
                S.append(T[idx])
        score = f_inf
        for i, j in combinations(S, 2):
            gap = abs(i - j)
            score = min(score, gap, 24 - gap)
        res = max(res, score)

    print(res)


if __name__ == '__main__':
    resolve()


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

int main() {
 int n;cin>>n;
  
  if(n<105)cout<<0<<endl;
  else if(n<135)cout<<1;
  else if(n<165)cout<<2;
  else if(n<189)cout<<3;
  else if(n<195)cout<<4;
  else cout<<5;
  
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) - 1 for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    satisfaction_degrees = 0
    for i in range(N):
        satisfaction_degrees += B[A[i]]
        if i != 0:
            if A[i] == A[i-1] + 1:
                satisfaction_degrees += C[A[i] - 1]
    print(satisfaction_degrees)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,k,a[100005],dp[100005];
int main()
{
  a[0]=1000000000;
  scanf("%d%d%d",&n,&k,&a[1]);
  for(int i=2;i<=n;i++)
  {
	  scanf("%d",&a[i]);
	  dp[i]=1000000000;
     for(int j=1;j<=k;j++)
     {
     	 if(i-j>=1) dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	  }
  }
  printf("%d\n",dp[n]);
  return 0;
}
    

Measured memory_bytes: 896
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

        signed main() {
        int h,w,n;
        cin>>h>>w>>n;
        for(int i=1;i<=h+w;i++){
            for(int j=0;j<=i;j++){
                if(h*j+w*(i-j)-j*(i-j)>=n){
                    cout<<i;
                    return 0;
                }
            }
        }
        
         return 0;

        }


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b = na()
s = ns()
flag = 1
if s[a] == "-":
    for i in s[:a]:
        if i == "-":
            flag = 0
            break
    if flag:
        for i in s[a+1:]:
            if i == "-":
                flag = 0
                break
else:
    flag = 0
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define F first 
#define S second
#define ll long long
int main()
{
	int n;cin>>n;
	ll arr[n];
	
	for(int i=0;i<n;i++) cin>>arr[i];
	long long ans=0;
	pair<ll, ll> dp[n][n];
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dp[i][j]=m_p(LLONG_MAX,LLONG_MAX);
		}
	}
	
	
	for(int size=1;size<=n;size++)
	{
		for(int i=0;i+size-1<n;i++)
		{
			if(size==1)
			{
				dp[i][i]=m_p(arr[i],0);
				continue;
			}
			int start=i,end=i+size-1;
			for(int j=start;j<end;j++)
			{
				dp[start][end].F=min(dp[start][end].F,dp[start][j].F+dp[j+1][end].F);
				dp[start][end].S=min(dp[start][end].S,dp[start][j].F+dp[j+1][end].F+dp[start][j].S+dp[j+1][end].S);
			}
		}
	
	}
//	for(int i=0;i<n;i++)
//	{
//		for(int j=0;j<n;j++) cout<<dp[i][j].F<<" "<<dp[i][j].S<<"   ";
//		cout<<endl;
//	}
	cout<<dp[0][n-1].S<<endl;
	
	return 0;
}

Measured memory_bytes: 2816
from collections import defaultdict
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
ans = N
ss=set()
front=[0]*N
while len(ss)<M-1:
    cnts = defaultdict(lambda: 0)
    for i,f in enumerate(front):
        cnts[A[i][f]]+=1
    
    maxi, maxc = max(cnts.items(), key=lambda p: p[1])
    ans = min(ans, maxc)
    ss.add(maxi)
    
    for i in range(N):
        while A[i][front[i]] in ss:
            front[i]+=1
print(ans)


Measured memory_bytes: 45276
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, yaku[10000], ct=0, i, j, ans=0, flag;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  sort(a, a+n);
  for(i=1; i*i<=a[0]; i++)
    if(a[0]%i==0){
      yaku[ct]=i;
      ct++;
      if(i*i!=a[0]){
	yaku[ct]=a[0]/i;
	ct++;
      }
    }
  sort(yaku, yaku+ct);
  for(i=0; i<ct; i++){
    flag=0;
    for(j=1; j<n; j++)
      if(a[j]%yaku[i]!=0) flag++;
    if(flag==0&&ans<yaku[i])
      ans=yaku[i];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld                long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define debug(x)        cerr << #x << " = " << x << endl;
//Bitwise 
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          998244353;   //(1e9+7)
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=1e5+5;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	int n,k;
	cin>>n>>k;
	cout<<floor(log(n)/log(k))+1<<endl;
	return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k=s.size();
  for(int i=0;i<k;i++){
    for(int j=0;j<26;j++){
      if(s[i]==ALP[j]){
        s[i]=ALP[j+n];
        break;
      }
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool comp(int a,int b)
{
	return(a<b);
}
int main() {
	int a,b;
	cin>>a>>b;
	cout << std::max({a+b,a*b,a-b},comp) << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000ll
using namespace std;
string str[55];
int n;
ll mem[2][51][22][303], c[55];
bool pal(bool f, int i, int len)
{
    if(!len)return 1;
    if(!f)
    {
        int l= str[i].size()-len, r= str[i].size()-1;
        while(l<r)
        {
            if(str[i][l]!=str[i][r])return 0;
            else l++, r--;
        }
    }
    else
    {
        int l= 0, r= len-1;
        while(l<r)
        {
            if(str[i][l]!=str[i][r])return 0;
            else l++, r--;
        }
    }
    return 1;
}
bool chckl(int s1, int len, int s2)
{
    for(int j=(str[s1].size()-len), k=str[s2].size()-1; j<str[s1].size() && k>=0; j++, k--)
    if(str[s1][j]!=str[s2][k])return 0;
    return 1;
}
bool chckr(int s1, int len, int s2)
{
    for(int j=0, k= len-1; j<str[s2].size() && k>=0; j++, k--)
    if(str[s2][j]!=str[s1][k])return 0;
    return 1;
}
ll dp(bool f, int i, int len, int cnt)
{
    if(pal(f, i, len))return 0;
    if(cnt>300)return inf;
    if(mem[f][i][len][cnt]!=-1)return mem[f][i][len][cnt];
    mem[f][i][len][cnt]= inf;
    for(int j=0; j<n; j++)
    {
        if(!f)
        {
            if(str[j].size()<=len && chckl(i, len, j))mem[f][i][len][cnt]= min(mem[f][i][len][cnt], c[j]+dp(f, i, len-str[j].size(), cnt+1));
            else if(str[j].size()>len && chckl(i, len, j))mem[f][i][len][cnt]= min(mem[f][i][len][cnt], c[j]+dp(f^1, j, str[j].size()-len, cnt+1));
        }
        else
        {
            if(str[j].size()<=len && chckr(i, len, j))mem[f][i][len][cnt]= min(mem[f][i][len][cnt], c[j]+dp(f, i, len-str[j].size(), cnt+1));
            else if(str[j].size()>len && chckr(i, len, j))mem[f][i][len][cnt]= min(mem[f][i][len][cnt], c[j]+dp(f^1, j, str[j].size()-len, cnt+1));
        }
    }
    return mem[f][i][len][cnt];
}
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)cin>>str[i]>>c[i];
    memset(mem, -1, sizeof mem);
    ll res= inf;
    for(int i=0; i<n; i++)
    res= min(res, c[i]+min(dp(0, i, str[i].size(), 0), dp(1, i, str[i].size(), 0)));
    if(res==inf)res= -1;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 8992
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashMap;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();
    let mut hash = HashMap::new();
    for ch in s{
        *hash.entry(ch).or_insert(0) += 1;
    }

    if hash.len() == 2 && hash.values().all(|x| *x == 2){
        println!("Yes");
    }else{
        println!("No");
    }
}


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

using namespace std;

int main(){
    int w,a,b;
    cin >> w >> a >> b;

    if(a+w <= b){
        cout << b-(a+w) << endl;
    }
    else if(a <= b+w && b < a+w){
        cout << 0 << endl;
    }
    else if(b+w < a){
        cout << a-(b+w) << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int W,H,x,y,r; cin >>W >>H >> x >>y >>r;
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){cout << "Yes"<< endl;}
	else cout << "No"<< endl;
}


Measured memory_bytes: 3120
N=int(input())
A=[int(i) for i in input().split()]
B=[int(j) for j in input().split()]
C=[int(j) for j in input().split()]

s=0
for k in range(len(A)-1):
    if(A[k+1]-A[k]==1):
       s+=C[A[k]-1]
print(sum(B)+s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, y = 0;
  cin >> N;
  M = N;
  
  
 
  // ここにプログラムを追記
  while (N > 0) {
    y += N % 10;
    N /= 10;          
  }
  if ((M % y) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

void solve() {
    vector<int> H = vector<int>(3);
    cin >> H[0] >> H[1] >> H[2];
    sort(H.begin(), H.end());
    int H1, H2, H3;
    H1 = H[2]; H2 = H[1]; H3 = H[0];
    
    if (H2*H2+H3*H3==H1*H1) {
    	cout << "YES" << endl;

    }else cout << "NO" << endl;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		solve();
	}
}

Measured memory_bytes: 3132
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

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

    sort(A.rbegin(), A.rend());
    int i = 0, now = 0, std = A[0] / 2;
    while (i < M) {
        if (now < N && A[now] >= std) {
            A[now] /= 2;
            ++now;
            ++i;
        }
        else {
            sort(A.rbegin(), A.rend());
            std = A[0] / 2;
            now = 0;
        }
    }
    ll sum_A = 0;
    rep(i, N) sum_A += A[i];
    cout << sum_A << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main()
{
    for (int i = 0; i < 3000; ++i)
    {
        int x, y;
        if (!(std::cin >> x >> y))
        {
            break;
        }
        if (x == 0 && y == 0)
            break;
        if (x <= y)
            std::cout << x << ' ' << y << std::endl;
        else
            std::cout << y << ' ' << x << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3008
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  // val inputs = Seq("56 25 31")
  val vars = inputs.head.split(" ")
  val a = vars(0).toLong
  val b = vars(2).toLong
  val op = vars(1)

  val result = op match {
    case "+" => a + b
    case _   => a - b
  }

  println(result)
}

Measured memory_bytes: 25536