akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	ll num, i;
	string ans = "";
	cin >> num;
	while (num > 0) {
		num--;
		int a = num % 26;
		num /= 26;
		char c = 'a' + a;
		ans += c;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
	return 0;
}

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

long long n, a, b;

long long solve();

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

  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(a == b) return 0;
  if(a > b) swap(a, b);
  long long res = (long long)1e18 + 2, now;
  if((b - a) % 2 == 0) return (b - a) / 2;
  now = a - 1;
  res = min(res, now + (b - now + 1) / 2);
  now = n - b;
  res = min(res, now + (n - a - now + 1) / 2);
  return res;
}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
ans = -float("inf")
for i in range(1,1<<10):
    jo = []
    ben = 0
    for j in range(10):
        jo.append(i%2)
        i = i//2
    for j in range(N):
        both = [0 for k in range(10) if F[j][k] == jo[k] == 1]
        ben += P[j][len(both)]
    ans = max(ans,ben)
print(ans)

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

signed main(void)
{
	ll a, b, c, d;
	ll ans;
	cin >> a >> b >> c >> d;
	ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
N = int(input())
arr = []
for _ in range(N):
    a,b = map(int,input().split())
    arr.append([a,b,a+b])
arr = sorted(arr,key = lambda x:x[2])
takahasi = 0
aoki = 0
i = 0
while arr:
    tmp = arr.pop()
    if i%2 == 0:
        takahasi += tmp[0]
    else:
        aoki += tmp[1]
    i += 1
print(takahasi-aoki)

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

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

void go(int a, int b, int c, int k) {
    if (c > b && b > a) {
        cout << "Yes";
        exit(0);
    }
    if (!k)
        return;
    go(2 * a, b, c, k - 1);
    go(a, 2 * b, c, k - 1);
    go(a, b, 2 * c, k - 1);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    go(a, b, c, k);
    cout << "No";
    return 0;
}

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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;
#define MP make_pair
#define pll pair<long long , long long >
#define pii pair<int, int>

template<class T>
void chmax(T&a, const T&b){if(a < b)a = b;}
template<class T>
void chmin(T&a, const T&b){if(a > b)a = b;}

int main(){
  int n,x; cin >> n >> x;
  vector<int>l(n);
  for(auto&&e : l)cin >> e;
  int pos = 0;
  for(int i = 1; i < n + 1; ++i){
    pos += l[i - 1];
    if(pos > x){cout << i << endl;return 0;}
  }
  cout << n + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n), b(n), c(n);
    REP(i, n)   cin >> a[i];
    REP(i, n)   cin >> b[i];
    REP(i, n)   cin >> c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    ll res=0;
    REP(i, n){
        ll body=b[i];
        auto aitr = lower_bound(ALL(a), body);
        auto citr = upper_bound(ALL(c), body);
        if(citr==c.end()) continue;
        res += ((aitr-a.begin()))*(c.end()-citr);
    }
    cout << res << endl;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */



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

    int n, m; cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    ll X=0, Y=0;
    rep(i, n){
        X += i*x[i];
        chmod(X);
        X -= (n-1-i)*x[i];
        chmod(X);
    }

    rep(i, m){
        Y += i*y[i];
        chmod(Y);
        Y -= (m-1-i)*y[i];
        chmod(Y);
    }

    ll ans=X*Y;
    chmod(ans);
    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main()
{
  string str;
  ll cnt = 0;
  ll temp = 0;

  cin >> str;
  str += 'S';

  for (const auto& e: str) {

    if (e == 'R') {

      temp++;

    } else {

      if (temp > cnt) {

        cnt = temp;

      }

      temp = 0;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int n,c,k;
	cin>>n>>c>>k;
	vi x(n);
	rep(i,0,n)cin>>x[i];
	sort(all(x));
	int cnt=c;
	int last=-1;
	int ans=0;
	for(auto t:x){
		if(cnt==c or last+k<t){
			ans++;
			last=t;
			cnt=0;
		}
		cnt++;
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k,r,s,p,cnt=0;
	string t;

	cin>>n>>k>>r>>s>>p;
	cin>>t;
   
   for(int i=0;i<n;i++)
   {
     if((i+k)<n){ if(t[i]==t[i+k] && t[i]=='x')
      {
      	continue;
      }
      
      else if(t[i]==t[i+k])
       { t[i+k]='x';
         if(t[i]=='r')
           cnt=cnt+p;
         if(t[i]=='s')
           cnt=cnt+r;
         if(t[i]=='p')
         	cnt=cnt+s;
       }
       else if(t[i]!=t[i+k])
       {
         if(t[i]=='r')
           cnt=cnt+p;
         else if(t[i]=='s')
           cnt=cnt+r;
         else if(t[i]=='p')
         	cnt=cnt+s;
       }}
       else { if(t[i]=='r')
           cnt=cnt+p;
         if(t[i]=='s')
           cnt=cnt+r;
         if(t[i]=='p')
         	cnt=cnt+s;
           
       }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 512
/**
 * https://atcoder.jp/contests/abc096/tasks/abc096_c
 */
fun main() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    var sList = Array<String>(h) { i -> "" }
    for (i in 0 until h) {
        sList[i] = readLine()!!
    }

    if (sList.toList().all { !it.contains('#')}) {
        print("Yes")
        return
    }

    val dx = arrayOf(0, -1, 1, 0)
    val dy = arrayOf(-1, 0, 0, 1)

    for (i in 0 until h) {
        for (j in 0 until w) {
            if (sList[i][j] == '#') {
                var count = 0
                for (k in 0 until 4) {
                    val di = i + dy[k]
                    val dj = j + dx[k]

                    if (di < 0 || di > h - 1) {
                        continue
                    }

                    if (dj < 0 || dj > w - 1) {
                        continue
                    }

                    if (sList[di][dj] == '#') {
                        count += 1
                    }
                }
                if (count == 0) {
                    print("No")
                    return
                }
            }


        }
    }

    print("Yes")
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
    if (a+b>c+d){
      cout<< "Left" <<endl;
    }  
    else if (a+b==c+d) {
      cout<< "Balanced"<<endl;
    }
    else{
      cout<< "Right" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, a, b, bt, at;

	while (cin >> n){
		at = bt = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a < b) bt += a + b;
			else if (b < a) at += a + b;
			else {
				at += a;
				bt += b;
			}
		}
		if (n != 0) cout << at << " " << bt << endl;
	}
	return (0);
}

Measured memory_bytes: 2944
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	int ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0, sum = 0;
	//new
	int n;
	int can[1000],up[1000],can2[1000],un[1000];
	cin >> n;
	rep(i, n) {
		cin >> can[i];
		if (i == 0)up[i] = can[i];
		else up[i] = up[i - 1] + can[i];
	}
	rep(i, n) {
		cin >> can2[i];
		sum += can2[i];
	}
	rep(i, n) {
		if (i == 0)un[0] = sum;
		else {
			un[i] = un[i - 1] - can2[i - 1];
		}
	}
	rep(i, n) {
		maxi = max(maxi,up[i]+un[i]);
	}
	cout << maxi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll knapsack(ll W, ll w[], ll c[], ll n)
{
    ll k[n+1][W+1];
    for(ll i=0; i<=n; i++)
    {
        for(ll wt=0; wt<=W; wt++)
        {
            if(i==0 || wt==0)
                k[i][wt]=0;
            else if(w[i-1]<=wt)
            {
                k[i][wt]=max(c[i-1]+k[i-1][wt-w[i-1]], k[i-1][wt]);
            }
            else
            {
                k[i][wt]=k[i-1][wt];
            }
        }
    }
    return k[n][W];
}

int main()
{
    ll n, w;
    cin >> n >> w;
    ll weight[n], value[n];
    for(ll i=0; i<n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    cout << knapsack(w, weight, value, n) << endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;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> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

ll gcd(ll a,ll b) { return a?gcd(b%a,a):b; }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
int solve() {
    int X=IN,Y=IN;
    if(X%Y==0) return -1;
    return (lcm(X,Y)/X-1)*X;
}
signed main() {
    cout<<solve()<<endl;
    return 0;
}


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

int main(){
    long long ans = 1001;
    string s, t;
    cin >> s >> t;
    
    long long count = 0;
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] != t[j]) count++;
        }
        ans = min(ans, count);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3620
import math
A, B = map(int,input().split())

count = 0

for n in range(10000):
    za = n*0.08
    zb = n*0.1
    count += 1
    if A == math.floor(za) and B == math.floor(zb):
        print(n)
        break


if count == 10000:
    print(-1)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define ppb pop_back
#define ppf pop_front
#define W 1
#define B 2
#define G 3
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int row[]={-1,0,1,0};
int col[]={0,1,0,-1};

const ll N=60;
const ll M=1e7+19;

ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m


vector<pair<pair<string,int>,int> > vec;

int main()
{
    
    fast_in_out;
    
   int n;
   cin>>n;
   ig;
   
   For(i,0,n)
   {
       int x;
       string str;
       cin>>str>>x;
       ig;
       
       
       vec.pb(mp(mp(str,-x),i+1));
       
   }
   
   Sort(vec);
   
   For(i,0,n)
   cout<<vec[i].second<<endl;
    
    return 0;
}



//CoU Algo Marathon 01(BFS,DFS) [Cloned]

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int H,W;

    cin >> H >> W;

    vector<vector<char>> pic(H + 2,vector<char>(W + 2));

    for(int i = 0; i < pic.size(); i++){
        for(int j = 0; j < pic.at(i).size(); j++){
            if(i == 0 || i == (pic.size() - 1)){
                pic.at(i).at(j) = '#';
            }else{
                if(j == 0 || j == (pic.at(i).size() - 1)){
                    pic.at(i).at(j) = '#';
                }else{
                    cin >> pic.at(i).at(j);
                }
            }
        }
    }

    for(int i = 0; i < pic.size(); i++){
        for(int j = 0; j < pic.at(i).size(); j++){
            cout << pic.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
//Shell Sort

#include<stdio.h>
int main(){
    int n, i, j, k, v, x;
    int cnt=0, m=0;
    int A[1000000];
    int G[1000000];
  
    scanf("%d",&n);
    
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    
    G[0] = 1;

    for(i = 1; G[i-1] <= n; i++){
        m++;
        G[i] = G[i-1] * 3 + 1;
        if(m>100) break;
    }
  
    for(i = 0; i < m/2; i++){
        x = G[i];
        G[i] = G[m-i-1];
        G[m-i-1] = x;
    }
    
    for(i = 0; i < m; i++){
        for(j = G[i]; j < n; j++){
            v = A[j];
            k = j - G[i];
            while(k >= 0 && A[k] > v){
                A[k+G[i]] = A[k];
                k = k - G[i];
                cnt++;
            }
            A[k+G[i]] = v;
        }
    }
    
    printf("\n%d\n", m);
    for(i = 0; i < m; i++){
        printf("%d ", G[i]);
    }
    printf("\n%d\n", cnt);
    for(i = 0; i < n; i++){
        printf("%d\n", A[i]);
    }
    return 0;
}

Measured memory_bytes: 6000
# -*- coding: utf-8 -*-


def main():
    from math import ceil

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    sum_a = sum(a)
    sum_b = sum(b)
    operation_count = sum_b - sum_a

    # 数列bの合計は数列aの合計よりも大きい必要がある
    if operation_count >= 0:
        # KeyInsight
        # https://img.atcoder.jp/apc001/editorial.pdf
        # 条件を満たすために，少なくとも何回操作が必要か?
        # ai < biのとき少なくとも[(bi - ai) / 2]回，+2する必要がある
        # ai > biのとき少なくともai - bi回，+1する必要がある
        # 操作回数より大きくなければYes
        two_count = 0
        one_count = 0

        for ai, bi in zip(a, b):
            if ai > bi:
                one_count += ai - bi
            elif ai < bi:
                two_count += ceil((bi - ai) / 2)

        if one_count <= operation_count and two_count <= operation_count:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while (N) {
        N /= K;
        ans++;
    }
    write(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int W,H,x,y,r; 
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r); 
 if (W>=x+r && H>=y+r && r<=x && r<=y && x>=0 && y>=0){ printf("Yes\n");
     
 } 
 else { printf("No\n");
     
 }
 return 0;

    
}



Measured memory_bytes: 2124
import java.util.Scanner;
/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());

    if (x < a) {
      System.out.println(0);
    } else {
      System.out.println(10);
    }

  }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL l,r,d;
        cin>>l>>r>>d;
        if(l%d==0 &&r%d==0){
            cout<<(r/d)-(l/d)+1<<endl;
        }
        else if(l%d!=0 &&r%d!=0){
            cout<<(r/d)-(l/d)<<endl;
        }
        else if(l%d!=0 &&r%d==0) {
          cout<<(r/d)-(l/d)<<endl;
        }
        else{
            cout<<(r/d)-(l/d)+1<<endl;
        }
    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    string a[H];
    char ans[H+2][W+2];

    for(int i = 0; i < H; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < H+2; i++) {
        for(int j = 0; j < W+2; j++) {
            ans[i][j] = '#';
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            ans[i+1][j+1] = a[i][j];
        }
    }
    for(int i = 0; i < H+2; i++) {
        for(int j = 0; j < W+2; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
def gyakugen( a, m ):
  b = m
  x, y = 1, 0
  while b>0:
    q = a // b
    a, b = b, a-q*b
    x, y = y, x-q*y
  return x if x>0 else x+m

m=10**9+7
n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in range(1,n):
  g=gcd(a[i],l)
  l=(a[i]//g)*l
b=0
for i in range(n):
  b=(b+gyakugen(a[i],m))%m
print((b*(l%m))%m)

Measured memory_bytes: 6076
#include <iostream>
using namespace std;
int n,a,b,arr[100005];
bool check(int mid)
{
	long long add=0;
	for (int i=0;i<n;i++)
	{
		if (arr[i]>1LL*mid*b)
		add+=(arr[i]-mid*b+a-b-1)/(a-b);
	}
	return (add<=mid);
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=0;i<n;i++)
	scanf("%d",&arr[i]);
	int st=0,en=1e9;
	while (st!=en)
	{
		int mid=(st+en)/2;
		if (check(mid))
		en=mid;
		else
		st=mid+1;
	}
	printf("%d",st);
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int t = 1;
int d[100], f[100];
int a[100][100];
int N;
void dfs(int cur) {
 d[cur] = t;
 t++;
 for (int i=0; i<N; i++) {
  if (a[cur][i] == 1 && d[i] == 0) {
   dfs(i);
  }
 }
 f[cur] = t;
 t++;
}

int main() {
 cin >> N;
 for (int i=0; i<N; i++) {
  for (int j=0; j<N; j++) {
   a[i][j] = 0;
  }
  d[i] = 0;
  f[i] = 0;
 }
 for (int i=0; i<N; i++) {
  int u, k;
  cin >> u >> k;
  for (int j=0; j<k; j++) {
   int v;
   cin >> v;
   a[u-1][v-1] = 1;
  }
 }
 for (int i=0; i<N; i++) {
  if (d[i] == 0) { dfs(i); }
 }
 for (int i=0; i<N; i++) {
  cout << i+1 << " " << d[i] << " " << f[i] << endl;
 }
}



Measured memory_bytes: 3120
class Selection_sort:
    def __init__(self):
        self.swap_num=0
    
    def sort(self,data):
        for i in range(len(data)):
            mini=i
            for j in range(i+1,len(data)):
                if(data[j] < data[mini]):
                    mini=j
            if(mini!=i):
                data[i],data[mini]=data[mini],data[i]
                self.swap_num+=1
        return data






n=int(input())
data=list(map(int,input().split()))
selection_sort=Selection_sort()
print(" ".join(list(map(str,selection_sort.sort(data)))))
print(selection_sort.swap_num)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=2e5+5;
int n,a[N],b[N],a1[N],b1[N];
bool present(int k) {
	int x=(1<<k),tmp=2*x;
	fw (i,0,n) {
		a1[i]=a[i]%tmp;
		b1[i]=b[i]%tmp;
	}
	//fw (i,0,n) cout<<a1[i]<<" "<<b1[i]<<"\n";
	sort(a1,a1+n); sort(b1,b1+n);
	int cnt=0;
	fw (i,0,n) {
		int lst=lower_bound(b1,b1+n,2*x-a1[i])-b1-1,prev=lower_bound(b1,b1+n,x-a1[i])-b1;
		cnt+=(lst-prev+1);
		lst=lower_bound(b1,b1+n,4*x-a1[i])-b1-1,prev=lower_bound(b1,b1+n,3*x-a1[i])-b1;
		cnt+=(lst-prev+1);
	}
	//cout<<"cnt="<<cnt<<"\n";
	return cnt&1;
}
signed main() {
	//in("aome.inp");
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	fw (i,0,n) cin>>a[i];
	fw (i,0,n) cin>>b[i];
	/*
	For each of the 28 bits we are required to check if it will be on by the end of the sum.
	Consider 2 ^ k. MOD every element by 2 ^ (k + 1). Now, a[i] + b[j] will contain an 1 - bit at
	k if:
	2 ^ k <= a[i] + b[j] < 2 ^ (k + 1) (No bits at the 2 ^ (k + 1) position is received)
	Or 3 * 2 ^ k <= a[i] + b[j] < 4 * 2 ^ k (1 bit is found at 2 ^ (k + 1). Erasing it cause us
	to get to the above equation)
	Don't think I'm missing anymore conditions.
	*/
	int ans=0;
	fw (i,0,29) {
		if (present(i)) {
			//cout<<"Bit "<<i<<" is present\n";
			ans|=(1<<i);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
program ccc
implicit none

integer :: l, i, x, x1, x2, res1, res2
character(10**5+1) :: s, s1, s2

read*, s
s=trim(s)
l=len_trim(s)

res1=0
res2=0
do i=1,l,2
s1(i:i)='0'
s1(i+1:i+1)='1'
s2(i:i)='1'
s2(i+1:i+1)='0'
end do

s1=trim(s1(1:l))
s2=trim(s2(1:l))

do i=1,l
read(s(i:i),*) x
read(s1(i:i),*) x1
read(s2(i:i),*) x2
if(x==x1) res1=res1+1
if(x==x2) res2=res2+1
end do

write(*,'(i0)') min(res1,res2)

end program

Measured memory_bytes: 804
#include<iostream>
#include<map>
#include<vector>
#include<sstream>
#include<cstdio>
#include<string>
using namespace std;
#define DIR 1
#define FILE 2
#define ARB 3
#define REP(i,b,e) for(int i=b;i<e;i++)
#define rep(i,n) REP(i,0,n)
class Tree{
public:
  int type;
  string myname;
  map<string,Tree* > M;
  Tree(){type=DIR;M.clear();myname="";}
};

void get_path(string a,vector<string>&b){
  rep(i,a.size())if (a[i]=='/')a[i]=' ';
  stringstream sin(a);
  while(sin>>a)b.push_back(a);
}

void get_query(string a,vector<pair<string,int> > & b){
  REP(i,1,a.size()){
    string t;
    while(i<a.size() && a[i] != '/')t+=a[i++];
    b.push_back(make_pair(t,DIR) );
  }
  if ( b.size() == 0)return;
  string t="index.html";
  if ( a[a.size()-1]=='/')b.push_back(make_pair(t,FILE) );
  else b[b.size()-1].second =ARB;
}

void make_tree(Tree *a,vector<string>&b,int &p){
  if (b.size()==p){return;}
  Tree *next=a->M[b[p]];
  if ( next == 0){
    next = new Tree;
    next->myname=b[p];
    a->M[b[p]]=next;
    next->type = p+1==b.size()?FILE:DIR;
    make_tree(next,b,++p);
  }else make_tree(next,b,++p);  
}

Tree* Find_Page(Tree *a,vector<pair<string,int> >&b,int &p,Tree *prev){
  Tree *ret=a;
  while(p < b.size()){
    if (b[p].first == "."){p++;continue;}
    else if ( b[p].first ==".."){p++;return prev;}
    //exceptional case "index.html"
    Tree *next = a->M[b[p].first];
    if ( next == 0 || (next->type&b[p].second )==0  )return NULL;
    ret = Find_Page(next,b,++p,a);
    if ( ret == NULL)return NULL;
  }

  if (ret->type == FILE)return ret;
  ret = ret->M["index.html"];
  if ( ret == 0 || ret->type !=FILE)return NULL;
  return ret;
}

void solve(string *q,Tree *root){
  Tree *data[2];
  rep(i,2){
    vector<pair<string,int> > a;
    int p=0;
    data[i]=NULL;
    get_query(q[i],a);
    data[i]=Find_Page(root,a,p,NULL);
    if (  data[i] == NULL){puts("not found");return;}
  }
  if (data[0] == data[1] )puts("yes");
  else puts("no");
}

main(){
  int n,q;
  while(cin>>n>>q &&n){
    Tree root;
    string t;
    vector<string> a;
    int p=0;
    rep(i,n)cin>>t,get_path(t,a),make_tree(&root,a,p=0),a.clear();
    rep(i,q){
      string in[2];
      cin>>in[0]>>in[1];
      solve(in,&root);
    }
  }
  return false;
}

Measured memory_bytes: 0
import sys
import collections as cc
import bisect as bi
I=lambda:list(map(int,input().split()))
n,=I()
ar=[I() for i in range(n)]
tf=0
for i in range(n-3+1):
	if ar[i][0]==ar[i][1] and ar[i+1][0]==ar[i+1][1] and ar[i+2][0]==ar[i+2][1]:
		tf=1
print("Yes" if tf else "No")


Measured memory_bytes: 67108
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long long ans = 0;
bool comp(const string &a, const string &b) {
	return a.size() > b.size();
}
struct trie {
	int cs[26];
	trie* child[26];
	trie() {
		fill_n(cs, 26, 0);
		for (int i = 0; i < 26; ++i) child[i] = NULL;
	}
	int update(string &s) {
		if (s.empty()) return 0;
		if (s.size() == 1) ans += cs[s[0] - 'a'];
		char c = s.back();
		s.pop_back();
		if (child[c - 'a'] == NULL) child[c - 'a'] = new trie();
		int mask = child[c - 'a'] -> update(s);
		mask |= 1 << (c - 'a');
		for (int i = 0; i < 26; ++i) {
			if (mask & (1 << i)) ++cs[i];
		}
		s.push_back(c);
		return mask;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N;
	cin >> N;
	string S[N];
	for (int i = 0; i < N; ++i) cin >> S[i];
	sort(S, S + N, comp);
	trie T;
	for (int i = 0; i < N; ++i) T.update(S[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 373720
h1,h2 = map(int,input().split())
k1,k2 = map(int,input().split())
a,b,c,d = map(int,input().split())

def f(x,y):
    return a*x + b*y + c*(x//10) + d*(y//20)

H,K = f(h1,h2), f(k1,k2)
ans = 'even'
if H>K:
    ans = 'hiroshi'
elif H<K:
    ans = 'kenjiro'
print(ans)

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

const int N = 1e5 + 5;
const int M = N * 2;

int fir[N] , ne[M] , to[M] , cnt , dp[N] , n , m  , x , y , du[N]  , A[N] , fa[N];

void add(int x , int y) {
  ne[++ cnt] = fir[x];
  fir[x] = cnt;
  to[cnt] = y;
  ++ du[x];
}

void link(int x , int y) {
  add(x , y);
  add(y , x);
}

#define Foreachson(i , x) for(int i = fir[x];i;i = ne[i])

void dfs(int x , int f) {
  fa[x] = f;
  Foreachson(i , x) {
    int V = to[i];
    if(V == f)
      continue;
    A[x] -= A[V];
    dfs(V , x);
  }
}

#define Cannot exit(puts("NO") * 0)

void calc(int x , int f) {
  if(du[x] == 1) {
    dp[x] = A[x];
    return;
  }

  if(A[x] > 0) {
    Cannot;
  }

  vector <int> cxt;
  cxt.clear();
  
  Foreachson(i , x) {
    int V = to[i];
    if(V == f)
      continue;
    calc(V , x);
    cxt.push_back(dp[V]);
  }
  sort(cxt.begin() , cxt.end());
  int now = 0;
  for(int i = 0;i < (int) cxt.size() - 1;++ i) {
    now = now + cxt[i];
  }
  if(now + cxt.back() >= (-A[x]) * 2 && now >= (-A[x])) {
    dp[x] = now + cxt.back() + A[x] * 2;
    A[fa[x]] -= A[x];
  }
  else Cannot;
}

int main() {
  scanf("%d" , &n);
  for(int i = 1;i <= n;++ i)
    scanf("%d" , &A[i]);
  for(int i = 1;i < n;++ i) {
    scanf("%d%d" , &x , &y);
    link(x , y);
  }
  if(n == 2) {
    if(A[1] == A[2])
    puts("YES");
    else Cannot;
    return 0;
  }
  int rt = 0;
  for(int i = 1;i <= n;++ i) {
    if(du[i] >= 2) {
      rt = i;
      break;
    }
  }
  dfs(rt , 0);
  calc(rt , 0);
  if(dp[rt]) Cannot;
  puts("YES");
}


Measured memory_bytes: 10368
n,k,s=map(int,input().split())
ans=[0]*n
if s!=10**9:
    for i in range(k):
        ans[i]=s
    for i in range(k,n):
        ans[i]=10**9
else:
    for i in range(k):
        ans[i]=s
    for i in range(k,n):
        ans[i]=1
print(*ans)


Measured memory_bytes: 10708
import java.util.*;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }

    int N;
//    int[] d;
    private void run() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        List<Integer> d = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            d.add(i, scanner.nextInt());
        }
        if(N % 2 == 1) {
            System.out.println(0);
            return;
        }
        // sort
        d.sort(Comparator.naturalOrder());
        int index = N / 2;
        int a = d.get(index);
        int b = d.get(index-1);

        System.out.println(a-b);
    }

}

Measured memory_bytes: 60380
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
#define LL long long
#define N 10000
#define Inf 0x7fffffff
int a[102][102];
int main()
{
    ios::sync_with_stdio(false);
    int n,m,i,j;
    int co1=0;
    char x;
    while(cin>>n>>m)
    {
    	memset(a,0,sizeof(a));
    	for(i=0;i<n;i++)
        {
        	for(j=0;j<m;j++)
            {
      	        cin>>x;
      	        if(x=='#')
               	{
               		a[i][j]=1;
				}
             	else
      	        {
      	        	a[i][j]=0;
      	         	++co1;
				}
	        }
	
	        if(co1==m)
	            a[i][0]=-2;	
			co1=0;
		}
	    for(i=0;i<m;i++)
	    {
	    	co1=0;
	    	for(j=0;j<n;j++)
	    	{
	    		if(a[j][i]!=1)
	    		{
               		co1++;
	            }
			}
			if(co1==n)
	        for(j=0;j<n;j++)
	        if(a[j][i]!=-2)
	        a[j][i]=-1;
		}

		for(i=0;i<n;i++)
		{
			if(a[i][0]==-2)
			continue;
			for(j=0;j<m;j++)
			{
				if(a[i][j]==1)
				cout<<'#';
				else if(a[i][j]==0)
				cout<<'.';
			}
			cout<<endl;
		}
		
	}
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a = n / 500;
        n -= 500*a;
        int b = n / 5;
        System.out.println(a*1000 + b*5);
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


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

	ll s = 0;

	rep(i, m) {
		ll a;
		cin >> a;
		s += a;
	}

	if (s > n)cout << "-1" << endl;
	else cout << n - s << endl;

}

Measured memory_bytes: 3640
from collections import deque
import sys

n=int(input())
A=deque([])
for i in range(n):
  S=input()
  if S[0]=='0':
    if S[2]=='0':
      A.appendleft(S[4:])
    elif S[2]=='1':
      A.append(S[4:])
  elif S[0]=='1':
    print(A[int(S[2:])])
  elif S[0]=='2':
    if S[2]=='0':
      A.popleft()
    if S[2]=='1':
      A.pop()






Measured memory_bytes: 34508
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	static FastScanner scan = new FastScanner();

	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);

		int n = scan.nextInt();
		int[] b = new int[n];
		Arrays.fill(b, 100000);

		int a;
		for (int i = 0; i < n - 1; i++) {
			a = scan.nextInt();
			b[i] = Math.min(b[i], a);
			b[i + 1] = Math.min(b[i + 1], a);
		}

		out.println(Arrays.stream(b).sum());
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 27220
N = int(input())
L = list(map(int, input().split()))
L.sort()

from bisect import bisect_left

cnt = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        t = L[i] + L[j]
        idx = bisect_left(L, t, j + 1, len(L))
        cnt += max(0, idx - j - 1)
print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>

using namespace std;

#define MAX_ORDER 80

void alignOrder(std::string& input1, std::string& input2);
int myAtoi(const char c);
void briefMyItoa(int num, char* dst);
void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output);
bool overflowCheck(const std::string& output);

int main(void)
{
  int n;
  std::string input1, input2;
  std::string output;

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> input1;
    std::cin >> input2;

    alignOrder(input1, input2);
    addTwoInputs(input1, input2, output);
    if (overflowCheck(output)) {
      std::cout << output << std::endl;
    }
    else {
      std::cout << "overflow" << std::endl;
    }
  }

  return 0;
}

void alignOrder(std::string& input1, std::string& input2)
{
  if (input1.size() == input2.size()) {
    return;
  }
  if (input1.size() < input2.size()) {
    std::swap(input1, input2);
  }
  int distance = input1.size() - input2.size();
  for (int i = 0; i < distance; i++) {
    input2.insert(0, "0");
  }
  return;
}

int myAtoi(const char c)
{
  return c - '0';
}

void briefMyItoa(int num, char* dst)
{
  if (num < 10) {
    dst[0] = '0' + num;
    dst[1] = '\0';
  }
  else {
    dst[0] = num / 10 + '0';
    dst[1] = num % 10 + '0';
    dst[2] = '\0';
  }
}

void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output)
{
  int outputOrder = input1.size() + 1;
  output.resize(outputOrder);

  bool advance = false;
  for (int i = outputOrder - 2; i >= 0; i--) {
    int num1 = myAtoi(input1[i]);
    int num2 = myAtoi(input2[i]);
    int sum = num1 + num2;
    if (advance) {
      sum++;
    }
    char sumStr[10];
    briefMyItoa(sum, sumStr);
    if (sumStr[1] == '\0') {
      output[i + 1] = sumStr[0];
      advance = false;
    }
    else {
      output[i + 1] = sumStr[1];
      advance = true;
    }
    if (i == 0) {
      if (advance) {
        output[0] = '1';
      }
      else {
        output = output.substr(1);
      }
    }
  }
}

bool overflowCheck(const std::string& output)
{
  if (output.size() > MAX_ORDER) {
    return false;
  }
  return true;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

/*sortの仕方
 * ■ string s の場合
 * 昇順: sort(s.begin(), s.end())
 * 降順:  sort(s.rbegin(), s.rend())
 *
 * ■ int a[N] の場合
 * 昇順: sort(a, a+N)
 * 降順: 不明
 */

int alph2int(char character) {
    int x = character - 'a';
    return x;
}


int main(){
    int N;
    cin >> N;
    long long x[N], y[N], h[N];
    for (int i=0; i<N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    long long Cx, Cy, H;
    Cx = 0; Cy = 0; H = 0;

    int flag = 0;
    for (int i=0; i<N; i++) {
        if (h[i] != 0) {
            flag++;
            break;
        }
    }
    if (flag == 0) {
        for (Cx=0; Cx<=100; Cx++) {
            for (Cy=0; Cy<=100; Cy++) {
                int d = 0;
                for (int i=0; i<N; i++) {
                    if (Cx == x[i] && Cy == y[i]) {
                        d++;
                        break;
                    }
                }
                if (d == 0) {
                    cout << Cx << " " << Cy << " " << 1 << endl;
                    return 0;
                }
            }
        }
    }


    for (Cx=0; Cx<=100; Cx++) {
        for (Cy=0; Cy<=100; Cy++) {
            for (int i=0; i<N; i++) {
                if (h[i] != 0) {
                    H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy);
                    break;
                }
            }

            for (int k=0; k<N; k++) {
                if (h[k] == 0) {
                    if ( H - abs(x[k]-Cx) - abs(y[k]-Cy) > 0 ) {
                        break;
                    }
                } else {
                    long long H_temp = h[k] + abs(x[k]-Cx) + abs(y[k]-Cy);
                    if (H != H_temp) {
                        break;
                    }
                }

                if (k == N-1) {
                    cout << Cx << " " << Cy << " " << H << endl;
                    return 0;
                }
            }
        }
    }

    return 1;
}

Measured memory_bytes: 256
import math
K = int(input())
sumval = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        f = math.gcd(a,b)
        for c in range(1, K+1):
            g = math.gcd(f,c)
            sumval += g
print(sumval)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	vl v(n);
	for(ll&num : v) cin >> num;
	
	int prev=v[0];
	ll ans=0;
	
	for(int i=1; i<n; ++i) {
		if(v[i]>=prev) prev=v[i];
		else {
			ans+=abs(v[i]-prev);
			v[i]=prev;
			prev=v[i];
		}
	}
	
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int a,b,c;cin >> a >> b >> c;
    for(int i=a;i<=a*b;i+=a){
        if(i%b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll n;
    cin>>n;
    vector<ll>a(n),aa(n);
    rep(i,0,n){
        cin>>a.at(i);
        aa.at(i)=a.at(i)-(i+1);
    }
    ll b;
    sort(all(aa));
    if(n%2==0)b=aa.at(n/2);
    else b=aa.at((n-1)/2);
    ll sum=0;
    rep(i,0,n){
        sum+=(abs(aa.at(i)-b));
    }
    cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 3328
#include <iostream> //üoÍ
#include <vector>   //®Izñ

using namespace std;

int main(){
	int a;
	while(cin >> a){
		int b, i;
		cin >> b;
		a += b;
		
		for(i=0;a>0;i++){
			a /= 10;
		}
		
		cout << i << endl;
	}
	
	
	return 0;
	
}

Measured memory_bytes: 0
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000009
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


char s[N];
int main(){
    int n,t,i,j,m,k;
    scanf("%s%d",s,&m);
    n=strlen(s);
    rep(i,0,n){
        j=s[i]-'a';
        if(j){
            k=26-j;
            if(m>=k)m-=k,s[i]='a';
        }
    }
    if(m){
        m%=26;
        j=s[n-1]-'a';
        j=(j+m)%26;
        s[n-1]=j+'a';
    }
    puts(s);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;

int N;

void solve() {
    cin >> N;
    int K = 0;
    int x;
    for (x = 1; K < N; K += x, x += 1) ;

    if (K != N) {
        cout << "No\n";
        return;
    }

    cout << "Yes\n";
    cout << x << "\n";

    vector<vector<int>> ans = vector<vector<int>>(x+1);

    int cnt = 1;
    K = 0;

    for (int i = 1; K < N; K += i, i += 1) {
        for (int j = 1; j <= i; j += 1) {
            ans[j].push_back(cnt);
            ans[i+1].push_back(cnt);
            cnt += 1;
        }
    }

    for (int i = 1; i <= x; ++i) {
        cout << ans[i].size() << " ";
        for (auto j: ans[i]) {
            cout << j << " ";
        }
        cout << "\n";
    }
}

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

    solve();
}


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

int main()
{
	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	for(int i =0;i<n;i++)
	{
		cin>>a[i];
	}
	ll lcm = a[0]/2;
	for(int i = 1;i<n;i++)
	{
		a[i]/=2;
		ll g = __gcd(a[i],lcm);
		ll p = lcm;
		lcm = a[i]/g*lcm;
		if(
			lcm>m||
			(lcm/p)%2==0||
			(lcm/a[i])%2==0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	cout << (m+lcm)/(2*lcm) << endl;
}


Measured memory_bytes: 3988