akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < E.size(); ++i)
    cout << O[i] << E[i];
  if (O.size() > E.size())
    cout << O[E.size()];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case %d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))

using namespace std;

//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

int main()
{

//    freopen("in.txt","r",stdin);
//	  freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    int k;
    cin>>k;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        ans+=2*min(a,abs(k-a));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,M;
    scanf("%d%d",&N,&M);
    int a,total=0;
    for (int i=0;i<M;i++){
        scanf("%d",&a);
        total+=a;
    }
    if (total>N){
        printf("-1\n");
    }else{
        printf("%d\n",N-total);
    }
    return 0;
}


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

int n;
char str[110000];
int ans = 1;

int main() {
	scanf("%d", &n);
	scanf("%s", str + 1);
	for(int i = 2; i <= n; ++i)
		if(str[i] != str[i - 1])	++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp
// Insertion Sort

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main(){
  int n;cin>>n;
  vector<int> num(n);

  for(int i=0;i<n;++i)
    cin>>num.at(i);
 
  // Insertion Sort
  for(int i=1;i<=n;++i){
    for(int k=0;k<n;++k){
      cout << num.at(k);
      if(k!=n-1)cout << " ";
    }
    cout << endl;

    if(i==n) break;
    int key = num.at(i);
    int j = i-1;

    while(j>=0 and num.at(j) > key){
      num.at(j+1) = num.at(j);
      j--;
      num.at(j+1) = key;
    }

  }

   return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
N = int(input())
S = str(input())
ans = ""
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(len(S)):
    for j in range(len(abc)):
        if S[i] == abc[j]:
            ans += abc[(j+N)%26]
            break
print(ans)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

from math import factorial
mod = 10**9+7
def nCr(fact, inv, n, r):
    return fact[n] * inv[r] * inv[n-r] % mod

def main():
    X, Y = map(int, input().split())
    if Y < (X/2) or Y > (2*X):
        print(0)
        return
    if (Y+X) % 3 != 0:
        print(0)
        return
    n = (X+Y)//3
    m = (2*Y-X)//3

    N = n
    fact = [1]
    for i in range(1, N+1):
        fact.append(fact[i-1] * i % mod)
    inv = [0] * (N+1)
    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N, 0, -1):
        inv[i-1] = inv[i] * i % mod

    print(nCr(fact, inv, n, abs(n-m)) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define tests int t1234;cin>>t1234;for(int i1234=1;i1234<=t1234;i1234++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mods (1000000007)
const int N=1000010;

int32_t main() {
    fastio;
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,61){
        int d[n];
        rep(j,n){
            d[j]=a[j]&(1LL<<i);
        }
        int z[n];
        for(int j=n-1;j>=0;j--){
            if(j==n-1)z[j]=0;
            else z[j]=z[j+1];
            if(d[j]==0)z[j]++;
        }
        rep(j,n-1){
            if(d[j]==(1LL<<i)){
                int rr=(z[j+1]*(d[j]%mods))%mods;
                ans=(ans+rr)%mods;
            }
            else{
                int rr=((n-j-1-z[j+1])*((1LL<<i)%mods))%mods;
                ans=(ans+rr)%mods;
            }
        }
    }
    cout<<ans%mods<<endl;


}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> odd(100001, 0), evn(100001, 0);
  REP(i, n / 2) {
    int o, e;
    cin >> o >> e;
    odd.at(o)++;
    evn.at(e)++;
  }
  int mo_cnt = 0, me_cnt = 0, mo, me, so_cnt = 0, se_cnt = 0;
  REP(i, 100000) {
    if (mo_cnt < odd.at(i+1)) {
      mo_cnt = odd.at(i+1);
      mo = i+1;
    }
    if (me_cnt < evn.at(i+1)) {
      me_cnt = evn.at(i+1);
      me = i+1;
    }
  }
  REP(i, 100000) {
    if (so_cnt < odd.at(i+1) && i +1!= mo) {
      so_cnt = odd.at(i+1);
    }
    if (se_cnt < evn.at(i+1) && i +1!= me) {
      se_cnt = evn.at(i+1);
    }
  }
  if (me == mo)
    cout << min(n - mo_cnt - se_cnt, n - so_cnt - me_cnt) << "\n";
  else
  cout << n-mo_cnt-me_cnt << "\n";
    return 0;
}


Measured memory_bytes: 1024
// 2011/08/24 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		char brd[3][3];
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				cin >> brd[i][j];
				if(brd[i][j]=='0')	// ¶
					return 0;
			}
		}

		if(brd[0][0]!='+'&&brd[0][0]==brd[0][1]&&brd[0][1]==brd[0][2])
			cout << brd[0][0] << endl;
		else if(brd[1][0]!='+'&&brd[1][0]==brd[1][1]&&brd[1][1]==brd[1][2])
			cout << brd[1][0] << endl;
		else if(brd[2][0]!='+'&&brd[2][0]==brd[2][1]&&brd[2][1]==brd[2][2])
			cout << brd[2][0] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][0]&&brd[1][0]==brd[2][0])
			cout << brd[0][0] << endl;
		else if(brd[0][1]!='+'&&brd[0][1]==brd[1][1]&&brd[1][1]==brd[2][1])
			cout << brd[0][1] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][2]&&brd[1][2]==brd[2][2])
			cout << brd[0][2] << endl;
		else if(brd[0][0]!='+'&&brd[0][0]==brd[1][1]&&brd[1][1]==brd[2][2])
			cout << brd[0][0] << endl;
		else if(brd[0][2]!='+'&&brd[0][2]==brd[1][1]&&brd[1][1]==brd[2][0])
			cout << brd[0][2] << endl;
		else
			cout << "NA" << endl;
	}
}

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

const int MAXN = 200001;
struct Edge{
    int end , upEd;
}Ed[MAXN];
bool vis1[MAXN] , vis2[MAXN];
int LTK1[MAXN] , LTK2[MAXN] , cnt[MAXN] , head[MAXN] , N , M , K , cntEd , cntLTK;
struct Queue{
    int arr[MAXN] , hd , tl;
    inline void init(){
        hd = tl = 0;
    }
    inline bool empty(){
        return hd == tl;
    }
    inline void push(int a){
        arr[tl++] = a;
    }
    inline void pop(){
        hd++;
    }
    inline int front(){
        return arr[hd];
    }
}q;
map < pair < int , int > , int > m;

inline void addEd(int a , int b){
    Ed[++cntEd].end = b;
    Ed[cntEd].upEd = head[a];
    head[a] = cntEd;
}

inline void bfs1(int dir){
    q.init();
    q.push(dir);
    cntLTK++;
    vis1[dir] = 1;
    while(!q.empty()){
        int t = q.front();
        q.pop();
        LTK1[t] = cntLTK;
        for(int i = head[t] ; i ; i = Ed[i].upEd)
            if(!vis1[Ed[i].end]){
                vis1[Ed[i].end] = 1;
                q.push(Ed[i].end);
            }
    }
}

inline void bfs2(int dir){
    q.init();
    while(!q.empty())
        q.pop();
    q.push(dir);
    cntLTK++;
    vis2[dir] = 1;
    while(!q.empty()){
        int t = q.front();
        q.pop();
        LTK2[t] = cntLTK;
        for(int i = head[t] ; i ; i = Ed[i].upEd)
            if(!vis2[Ed[i].end]){
                vis2[Ed[i].end] = 1;
                q.push(Ed[i].end);
            }
    }
}

int main(){
    cin >> N >> M >> K;
    for(int i = 1 ; i <= M ; i++){
        int a , b;
        scanf("%d%d" , &a , &b);
        addEd(a , b);
        addEd(b , a);
    }
    for(int i = 1 ; i <= N ; i++)
        if(!vis1[i])
            bfs1(i);
    memset(head , 0 , sizeof(head));
    cntLTK = cntEd = 0;
    for(int i = 1 ; i <= K ; i++){
        int a , b;
        scanf("%d%d" , &a , &b);
        addEd(a , b);
        addEd(b , a);
    }
    for(int i = 1 ; i <= N ; i++)
        if(!vis2[i])
            bfs2(i);
    for(int i = 1 ; i <= N ; i++)
        m[make_pair(LTK1[i] , LTK2[i])]++;
    for(int i = 1 ; i <= N ; i++)
        printf("%d " , m.find(make_pair(LTK1[i] , LTK2[i]))->second);
    return 0;
}

Measured memory_bytes: 16768
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,h[100003];
	int ans = 0,beg = 0;
	int cnt = 0;

	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&h[i]);
	for (int i = 0; i + 1 < n; ++i)
	{
		if(h[i] < h[i + 1]){
			ans = ((ans < cnt) ? cnt : ans);
			beg = i + 1;
			cnt = 0;
		}
		else  ++cnt;
		// printf("h[i = %d]: %3d, h[i + 1 = %d]: %3d, ans: %3d, cnt: %3d\n",
		// 	i, h[i], (i + 1), h[i + 1], ans, cnt);
	}
	printf("%d\n", ((ans < cnt) ? cnt : ans));
	return 0;
}

Measured memory_bytes: 512
n,ma,mb=map(int,input().split())
abc = [list(map(int,input().split())) for _ in range(n)]
suma = sum([abc[i][0] for i in range(n)])+1
sumb = sum([abc[i][1] for i in range(n)])+1
dp = [[[5000 for j in range(sumb)]for i in range(suma)]for k in range(n+1)]
for i in range(n+1):
    dp[i][0][0] = 0
for k in range(n):
    for i in range(suma):
        for j in range(sumb):
            if i>=abc[k][0] and j>=abc[k][1]:
                dp[k+1][i][j] = min(dp[k][i][j],dp[k][i-abc[k][0]][j-abc[k][1]]+abc[k][2])
            else:
                dp[k+1][i][j]=dp[k][i][j]

flag = 0
res = 5000
for i in range(1,500):
    if ma*i >=suma or mb*i >= sumb:
        break
    res = min(res,dp[n][ma*i][mb*i])
    flag = 1
if res != 5000:
    print(res)
else:
    print("-1")

Measured memory_bytes: 64092
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long i64;
typedef pair<i64, i64> pii;

const int MAX_N = 140000;
const i64 INF = 0x3f3f3f3f3f3f3f3fLL;

int val[MAX_N], ch[MAX_N][2], num[MAX_N];
bool flag;
i64 LIM;

inline void chmin(i64 &x, i64 y) {
  if (x > y) x = y;
}

void merge(vector<pii> &a, vector<pii> &b, vector<pii> &c) {
  static vector<pii> t1, t2;
  static pii st[MAX_N];
  
  int top = 0;
  t1.clear(), t2.clear();
  for (int i = b.size() - 1, l = 0, r = c.size() - 1; i >= 0; --i) {
    while (l < c.size() && c[l].second + b[i].second > LIM) l++;
    while (r >= 0 && c[r].first + b[i].second > LIM) r--;
    i64 temp = INF;
    if (l < c.size()) chmin(temp, c[l].first);
    if (r >= 0) chmin(temp, c[r].second);
    if (temp != INF) t1.push_back(make_pair(b[i].first, temp));
  }
  reverse(t1.begin(), t1.end());
  for (int i = 0, l = 0, r = c.size() - 1; i < b.size(); ++i) {
    while (l < c.size() && c[l].second + b[i].first > LIM) l++;
    while (r >= 0 && c[r].first + b[i].first > LIM) r--;
    i64 temp = INF;
    if (l < c.size()) chmin(temp, c[l].first);
    if (r >= 0) chmin(temp, c[r].second);
    if (temp != INF) t2.push_back(make_pair(b[i].second, temp));
  }
  reverse(t2.begin(), t2.end());
  int l1 = 0, l2 = 0;
  while (l1 < t1.size() && l2 < t2.size()) {
    if (l1 == t1.size()) top++, st[top] = t2[l2++];
    else if (l2 == t2.size()) top++, st[top] = t1[l1++];
    else if (t1[l1] < t2[l2]) top++, st[top] = t1[l1++];
    else top++, st[top] = t2[l2++];
  }
  for (int i = 0; i < t1.size(); ++i) st[++top] = t1[i];
  for (int i = 0; i < t2.size(); ++i) st[++top] = t2[i];
  
  sort(st + 1, st + top + 1);
  
  for (int i = 1; i <= top; ++i) {
    if (i != 1 && a.back().second <= st[i].second) continue;
    a.push_back(st[i]);
  }
}

vector<pii> vec[MAX_N];

void dfs(int u) {
  vec[u].clear();
  if (!num[u]) {
    vec[u].push_back(make_pair(0, 0));
    return;
  }
  
  int v1 = ch[u][0], v2 = ch[u][1];
  dfs(ch[u][0]), dfs(ch[u][1]);
  for (int i = 0; i < vec[v1].size(); ++i)
    vec[v1][i].first += val[v1], vec[v1][i].second += val[v1];
  for (int i = 0; i < vec[v2].size(); ++i)
    vec[v2][i].first += val[v2], vec[v2][i].second += val[v2];
  
  if (vec[v1].size() > vec[v2].size()) swap(v1, v2);
  
  if (flag) merge(vec[u], vec[v1], vec[v2]);
  if (!vec[u].size()) flag = 0;
}

bool check(i64 mid) {
  LIM = mid, flag = 1;
  dfs(1);
  return flag;
}

int N;

int main() {
  scanf("%d", &N);
  for (int i = 2, u; i <= N; ++i) {
    scanf("%d%d", &u, &val[i]);
    ch[u][num[u]++] = i;
  }

  i64 l = 0, r = 20000000000LL, res = 0;

  while (l <= r) {
    i64 mid = (l + r) >> 1;
    if (check(mid)) res = mid, r = mid - 1;
    else l = mid + 1;
  }

  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 20084
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
int n;
vector<int> p[333];
bool vis[333];

int check(int x){
    memset(vis, false, sizeof(vis));
    int res = 0;
    queue<int> q;
    for (int i = 0; i < n; i++){
        if (x&1) q.push(i+1), vis[i+1] = true, res++;
        x >>= 1;
    }
    while (!q.empty()){
        int a = q.front();
        q.pop();
        for (int i = 0; i < p[a].size(); i++){
            int t = p[a][i];
            if (t <= n){
                if (vis[t+n]) return -1;
                if (!vis[t]) q.push(t);
                vis[t] = true;
            }
            else {
                if (vis[t-n]) return -1;
                vis[t] = true;
            }
        }
    }
    return res;
}

int main(){
    cin >> n;
    int a, x, y;
    for (int i = 1; i <= n; i++){
        cin >> a;
        while (a--){
            cin >> x >> y;
            if (!y) x += n;
            p[i].push_back(x);
        }
    }
    int ans = 0;
    for (int i = 0; i <= (1<<n)-1; i++){
        ans = max(ans, check(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int p[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> p[i];
    p[i]--;
  }
  bool same[100010];
  for (auto i = 0; i < N; ++i) {
    same[i] = (p[i] == i);
  }
  same[N] = false;
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    if (same[i] && same[i+1]) {
      ++ans;
      same[i] = false;
      same[i+1] = false;
    } else if (same[i]) {
      ++ans;
      same[i] = false;
    }
  }
  cout << ans << endl;
}


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

int n, m, k;

void solve(int) {
  int64 a, b, n;
  cin >> a >> b >> n;
  n = min(n, b - 1);
  cout << a * n / b - a * (n / b) << '\n';
}

void precalc() {
}

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




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
string S;

void input(){
    cin >> n;
    cin >> S;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    /*'W'の累積和はs[i]*/
    int s[n] = {};
    int t[n] = {};
    if (S[0] == 'W') s[0] = 1;
    for(int i=1;i<n;i++){
        if (S[i] == 'W'){
            s[i] = s[i-1] + 1;
        }
        else s[i] = s[i-1];
    }
    for(int i=0;i<n;i++) t[i] = ((i+1)-s[i]);
    /*'E'の累積和はt[i]*/
    int ans = INF;
    ans = min(ans, t[n-1]-t[0]);
    ans = min(ans, s[n-2]);
    for(int i=1;i<n-1;i++) ans = min(ans, s[i-1]+(t[n-1]-t[i]));
    cout << ans << endl;
}

Measured memory_bytes: 2964
#include<stdio.h>

int main(void) {
	char acNumber[4];
	unsigned char i;
	char cYorN = 0;

	//3桁の整数を入力
	scanf("%s", acNumber);
	//いずれかの桁に7を含むか調べる
	for (i = 0;i < 3;i++) {
		if (acNumber[i] == '7') {
			cYorN = 1;
		}
	}
	//7が含まれるならYes,含まれないならNoを出力
	if (cYorN == 1) {
		printf("\nYes\n");
	}
	else {
		printf("\nNo\n");
	}

	return 0;
}

Measured memory_bytes: 2060
n = gets.to_i
s = gets.chomp
max = 0

for i in 0..n-1
	a = s[0,i]
	b = s[i..n]
	score = 0

	('a'..'z').map do |c|
		score += a.include?(c) && b.include?(c) ? 1 : 0
	end


	if max < score
		max = score
	end
end
puts max

Measured memory_bytes: 3836
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var array = new int[2, N];
        for (int i=0;i<2;++i)
        {
            var line=Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            for (int j=0;j<N;++j) array[i, j] = line[j];
        }
        var ans = 0;
        for (int i=0;i<N;++i)
        {
            var total = 0;
            for (int j=0;j<=N;++j)
            {
                if (j <= i) total += array[0, j];
                else total += array[1, j - 1];
            }
            if (ans < total) ans = total;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
s = list(input())
ans = 0
if s[0] == "A":
    ans += 1
C_ind = []
for i in range(2,len(s)-1):
    if s[i] == "C":
        C_ind.append(i)
if len(C_ind) == 1:
    ans += 1
    del s[C_ind[0]]

S = "".join(s[1:])

if S.islower():
    ans += 1

if ans == 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();

        int ans = 0;
        double minDiff = Double.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int h = sc.nextInt();
            double temp = (double) T - (((double) h) * 0.006);
            double diff = Math.abs((double) A - temp);
            if (minDiff > diff) {
                minDiff = diff;
                ans = i + 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24276
#include<stdio.h>
int A,B,C,X[105][105],Y[105][105],i,j,k;
long long t;
int main()
{
    scanf("%d%d%d",&A,&B,&C);
    for(i=0;i<A;i++)
        for(j=0;j<B;j++)
            scanf("%d",&X[i][j]);
    for(i=0;i<B;i++)
        for(j=0;j<C;j++)
            scanf("%d",&Y[i][j]);
    for(i=0;i<A;i++)
    {
        for(j=0;j<C;j++)
        {
            for(k=t=0;k<B;k++)
                t+=X[i][k]*Y[k][j];
            printf("%lld%s",t,j==C-1?"\n":" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int pre1[maxn],pre2[maxn],ans1[maxn],ans2[maxn];
int find(int pre[],int x)
{
    return pre[x]==x?pre[x]:pre[x]=find(pre,pre[x]);
}
int join(int x,int y,int pre[])
{
    int fx=find(pre,x);
    int fy=find(pre,y);
    pre[fx]=fy;
}
int main()
{
    int n,m1,m2,x,y;
    cin>>n>>m1>>m2;
    for(int i=1;i<=n;i++)pre1[i]=pre2[i]=i;
    for(int i=1;i<=m1;i++)
    {
        cin>>x>>y;
        join(x,y,pre1);
    }
    for(int i=1;i<=m2;i++)
    {
        cin>>x>>y;
        join(x,y,pre2);
    }
    for(int i=1;i<=n;i++)
    {
        find(pre1,i);
        find(pre2,i);
    }
    map<pair<int,int>,int>a;
    for(int i=1;i<=n;i++)a[make_pair(pre1[i],pre2[i])]++;
    for(int i=1;i<=n;i++){
        cout<<a[make_pair(pre1[i],pre2[i])];
        if(i!=n)cout<<" ";
        else cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 13568
#define MAX 10000001
#include <iostream>
using namespace std;

bool table[MAX];
void makePrime(void) {

    table[0] = false;
    table[1] = false;
    for(int i = 2; i < MAX; i++) {
        table[i] = true;
    }
    for(int i = 2; i < MAX; i++) {
        if(table[i]) {
            for(int j = i+i; j < MAX; j+=i) {
                table[j] = false;
            }
        }
    }
}

int main(void){
    // Your code here!
    makePrime();

    int answer[MAX];

    for(int i = 13; i < MAX; i++) {
        if(table[i-8] && table[i-6] && table[i-2] && table[i]) {
            answer[i] = i;
        } else {
            answer[i] = answer[i-1];
        }
    }

    int n;
    while(cin >> n) {
        if(n == 0) break;
        cout << answer[n] << endl;
    }   
}



Measured memory_bytes: 51924
#include <iostream>

using namespace std;

int main() {
    int N, M; cin >> N >> M; int A, sum = 0;
    for (int i = 0; i < M; i++) cin >> A, sum += A;
    cout << ((N-sum >= 0) ? N-sum : -1) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N, ans=1;
  string color;
  cin >> N >> color;
  for(int i=0;i<N-1;i++){
    if(color[i] != color[i+1]){
      ans++;
    }  
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T,typename... Args>
void err(istream_iterator<string>it,T a,Args... args)
{
	cerr<<*it<<"= " <<a<<" ";
	err(++it,args...);
}
void solve()
{
   int n; cin>>n;
   vector<int>h(n);
   rep(i,0,n-1) cin>>h[i];
   int res=0;
   vector<int>m(n);
   m[0]=h[0];
   if(n>1)
   {
   	rep(i,1,n-1)
   	m[i]=max(m[i-1],h[i]);
   }
   rep(i,0,n-1)
   {
   	if(m[i]==h[i])
   	res++;
   }
   cout<<res<<"\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  while(t--)
  {
	 solve();
  }
  return 0;
}




Measured memory_bytes: 256
#!/usr/bin/python

def main():
    A, B = [int(x) for x in input().split()]
    if divisor(A, B) == True:
        print(A + B)
    else:
        print(B - A)

def divisor(A, B):
    if B % A == 0: return True 
    return False


if __name__ == "__main__":
    main()

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

template <class T>
void print(vector<T> V) {
    for (T v : V) cout << v << " ";
    cout << endl;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<double> probs;
    for (ll i = 1; i <= N; i++) {
        if (i >= K) {
            probs.push_back(1.);
            continue;
        }
        auto isOk = [&](ll mid) { return i * pow(2, mid) >= K; };
        ll ok = K, ng = 0;
        while (ok - ng > 1) {
            ll mid = (ok + ng) >> 1;
            if (isOk(mid))
                ok = mid;
            else
                ng = mid;
        }
        probs.push_back(1. / pow(2, ok));
    }
    cout << fixed << setprecision(10);
    cout << accumulate(probs.begin(), probs.end(), 0.) / N << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>  
int a[10001];
using namespace std;
int main()
{
  int b,c,d;
  cin>>a[1]>>a[2]>>a[3];
  sort(a+1,a+3+1);
  if(a[2]-a[1]==a[3]-a[2])	
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;  		 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C,c[3];
  while(1){
    scanf("%d%d",&A,&B);
    if(A == 0 && B == 0)break;
    C = B-A;
    if(C >= 1000){
      c[2] = C / 1000;
      C = C - c[2]*1000;
    }
    else c[2] = 0;
    if(C >= 500){
      c[1] = C / 500;
      C = C - 500;
    }
    else c[1] = 0;
    if(C >= 100){
      c[0] = C / 100;
    }
    else c[0] = 0;

    printf("%d %d %d\n",c[0],c[1],c[2]);
  }

  return 0;
}
    

Measured memory_bytes: 600
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const A = parseInt(arr[0]);
    const B = parseInt(arr[1]);
    const C = parseInt(arr[2]);
    console.log(A < B + C ? B + C - A : 0);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m),r(m);
    rep(i,m) cin>>l[i]>>r[i];
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    
    cout << max(0, r[0]-l[m-1]+1) << endl;
    
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
lst = []
for _ in range(N):
    lst.append(list(map(int, input().split())))

ret = 0    
for x in sorted(lst):
    a, b = x[0], x[1]
    for y in range(b):
        M -= 1
        ret += a
        if  M == 0:
            print(ret)
            exit(0)

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

using namespace std;

int main(){
	int n;
	cin>>n;string s;cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
		s[i]-='A';
	for(int i=0;i<len;i++){
		s[i]+=n;
		s[i]%=26;
	}
	for(int i=0;i<len;i++) putchar(s[i]+'A');
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string

	fmt.Scanf("%s", &n)

	total := 0
	for i := 0; i < len(n); i++ {
		t, _ := strconv.Atoi(n[i : i+1])
		total = total + t
	}
	if total%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

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

int main() {
    int n = ri();
	s64 k; cin >> k;
	s64 a[n];
	INPUT(a);

	int num[50] = { 0 };
	FOR(i,n) {
		FOR(j,50) {
			if (a[i] & (1LL << j)) num[j]++;
		}
	}

	s64 res = 0;
	FOR(j,50) {
		if (k & (1LL << j)) {
			res += (1LL << j) * max(num[j], n - num[j]);
		} else res += (1LL << j) * num[j];
	}
	FOR(j,50) {
		if (k & (1LL << j)) {
			s64 new_k = k;
			new_k &= ~(1LL << j);
			FOR(l,j) new_k |= (1LL << l);

			s64 cur = 0;
			FOR(l,50) {
				if (new_k & (1LL << l)) {
					cur += (1LL << l) * max(num[l], n - num[l]);
				} else cur += (1LL << l) * num[l];
			}
			res = max(res, cur);
		}
	}

	cout << res << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
// #define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll len(ll n) {
  ll ret = 0;
  while (n > 0) {
    ret++;
    n /= 10;
  }
  return ret;
}

void solve() {
  ll n; cin >> n;
  ll ans = 10000000;
  for (ll d = 1; d * d <= n; d++) {
    if (n % d != 0) continue;
    ans = min(ans, max(len(n / d), len(d)));
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])
 

Measured memory_bytes: 13980
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;


int main() {
	int n;
	cin >> n;
	vi p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i]; p[i]--;
	}
	vl sum(n);
	ll s = 1000000001;
	for (int i = n - 1; i >= 0; i--) {
		sum[p[i]] = s; s--;
	}
	vl a(n + 1); a[n] = 1000000001;
	vl b(n + 1); b[n] = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i + 1] + b[i + 1] > sum[i]) {
			b[i] = b[i + 1] + 1;
			a[i] = sum[i] - b[i];
		}
		else {
			a[i] = a[i + 1] - 1;
			b[i] = sum[i] - a[i];
		}
	}
	for (int i = 0; i < n; i++)cout << a[i] << " "; cout << endl;
	for (int i = 0; i < n; i++)cout << b[i] << " "; cout << endl;
}



Measured memory_bytes: 1152
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    h, w = getList()
    lis = []
    for i in range(h):
        lis.append(getList())
    ans = []
    # print(lis)
    # 右に寄せる
    for i in range(h):
        for j in range(w-1):
            a = lis[i][j]
            if a % 2 == 1:
                ans.append([i+1, j+1, i+1, j+2])
                lis[i][j+1] += 1

    # 下に寄せる
    for i in range(h-1):
        a = lis[i][-1]
        if a % 2 == 1:
            ans.append([i+1, w, i+2, w])
            lis[i+1][-1] += 1
    print(len(ans))
    for an in ans:
        print(*an)

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

int main() {
    string s;
    cin >> s;
    
    if(s == "SAT") {
        cout << "1" << endl;
    } else if(s == "FRI") {
        cout << "2" << endl;
    } else if(s == "THU") {
        cout << "3" << endl;
    } else if(s == "WED") {
        cout << "4" << endl; 
    } else if(s == "TUE") {
        cout << "5" << endl;
    } else if(s == "MON") {
        cout << "6" << endl;
    } else {
        cout << "7" << endl;
    }
    return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long llint;
const int Maxn = 200000 + 10;
int n; llint A[Maxn],sum[Maxn],ans = 1ll<<60;

llint calc(int l,int r){return sum[r] - sum[l-1];}
llint getans(llint a,llint b,llint c,llint d){
	llint F[5]; F[1] = a; F[2] = b; F[3] = c; F[4] = d;
	sort(F+1,F+5);
	return F[4] - F[1];
}
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++) sum[i] = sum[i-1] + A[i];
	int l=2,r=4;
	for(int i=3;i<n;i++){
		while(abs(calc(1,l-1) - calc(l,i-1)) > abs(calc(1,l) - calc(l+1,i-1))) l++;
		while(abs(calc(i,r-1) - calc(r,n)) > abs(calc(i,r) - calc(r+1,n))) r++;
		llint ret = getans(calc(1,l-1),calc(l,i-1),calc(i,r-1),calc(r,n));
		if(ret < ans) ans = ret;
	}
	printf("%lld\n",ans);
}

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

Measured memory_bytes: 3456
H, W, K = map(int, input().split())

mod = 10 ** 9 + 7

dp = [0] * W
dp[0] = 1

pattern = []
for i in range(1 << (W - 1)) :
    if '11' in bin(i) :
        continue
    pattern.append(i)

for _ in range(H) :
    dp_ = [0] * W
    for p in pattern :
        for i in range(W) :
            if i != W - 1 and p & (1 << i) :
                dp_[i+1] += dp[i]
                dp_[i+1] %= mod
            elif i != 0 and p & (1 << (i - 1)) :
                dp_[i-1] += dp[i]
                dp_[i-1] %= mod
            else :
                dp_[i] += dp[i]
                dp_[i] %= mod
    
    dp = dp_
    
print(dp[K-1])

Measured memory_bytes: 41072
#include<stdio.h>
#include<math.h>
int main(void){
  
  //変数の受け取り
  long int N;
  scanf("%ld", &N);
  
  //ルートNから何で割り切れるかを探す
  long int a, b;
  long int i = sqrt(N);
  while(i > 0){
    //割り切れたら
    if( (N%i) == 0 ){
      a = i;
      b = N / i;
      break;
    }
  	i--;
  }
  
  //結果を出力
  printf("%ld\n", (a-1 + b-1) );

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <numeric>
#include <string>
using namespace std;
long lcm(long a, long b){return (a*b/__gcd(a,b));}
int main()
{
    long a,b;
    cin >> a >> b;
    cout << lcm(a,b);
    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 vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    if (n % 2 == 1) {
        cout << "No" << endl;
        return;
    }
    REP(i, n) {
        if (i % 2 == 0) {
            if (s[i] != 'h') {
        cout << "No" << endl;
        return;
            }
        } else {
            if (s[i] != 'i') {
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, x[MX], l[MX];
ii p[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n) {
		cin >> x[i] >> l[i];
		p[i] = {x[i] - l[i], x[i] + l[i]};
	}

	sort(p, p + n, [&] (const ii &x, const ii &y) {
		return x.se < y.se;
	});

	int to = -2e9, res = 0;
	forn (i, n) {
		if (to <= p[i].fi) {
			to = p[i].se;
			res++;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 5056
#include<cstdio>
#include<iostream>
using namespace std;
const int N=2e5+5;
int n,m,x,y,xx,yy,mx,f[N],s[N];
int get(int x)
{
	if (f[x]==x) return x;
	return f[x]=get(f[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) f[i]=i,s[i]=1;
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		xx=get(x),yy=get(y);
		if (xx!=yy)
		{
			if (s[xx]<s[yy]) f[xx]=yy,s[yy]+=s[xx]; else f[yy]=xx,s[xx]+=s[yy];
		}
	}
	for (int i=1;i<=n;i++) if (get(i)==i) mx=max(mx,s[i]);
	printf("%d",mx); 
	return 0;
}

Measured memory_bytes: 5388
n = int(input())
L = [list(map(int, input().split())) for _ in range(n-1)]
for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        if t <= L[j][1]:
            s = L[j][1]
        else:
            if t % L[j][2]:
                s = t + L[j][2] - (t % L[j][2])
            else:
                s = t
        t = s + L[j][0]
    print(t)
print(0)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[]) {
  int count, total;
  char buf[BUFSIZ];

  scanf("%d %d", &count, &total);
  total = total / 1000;

  for(int c1k = 0;c1k <= count;c1k ++) {
    for(int c5k = 0;c5k <= count-c1k;c5k ++) {
      int c10k = count-c1k-c5k;
      if(c10k*10+c5k*5+c1k == total) {
        printf("%d %d %d\n", c10k, c5k, c1k);
        exit(0);
      }
    }
  }
  puts("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 128
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
C = Counter(A)
ans = {}
cal = sum([b*(b-1)//2 for b in C.values()])
for a, b in C.items():
    ans[a] = cal - (b-1)
for a in A:
    print(ans[a])

Measured memory_bytes: 35228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int h = std.nextInt();
        int w = std.nextInt();
        int[][] table = new int[h + 2][w + 2];

        for (int i = 1; i <= h; i++) {
            String line = std.next();
            for (int j = 1; j <= w; j++) {
                int color = (line.charAt(j - 1) == '#') ? 1 : 0;
                table[i][j] = color;
            }
        }

        boolean enable = true;

        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                int color = table[i][j];
                if (color == 1) {
                    int left = table[i][j - 1];
                    int right = table[i][j + 1];
                    int top = table[i - 1][j];
                    int bottom = table[i + 1][j];
                    int aroundColor = left | right | top | bottom;
                    if (aroundColor == 0) {
                        enable = false;
                        break;
                    }
                }
            }
        }

        if (enable) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int M = sc.nextInt();
    int D = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 2; i <= M; i++) {

      for (int A = 2; A < 10; A++) {
        if (i % A != 0) {
          continue;
        }
        int B = i / A;
        if (B < 10 && 1 < B) {
          if ((A * 10 + B) <= D) {
            count++;
          }
        }
      }
      
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a;
  cin >> a;
  //if(x=='a'||x=='i'||x=='u'||x=='e'||x=='o')){cout << "vowel" << endl;}
  //else{cout << "consonant" << endl;}
  //int x = a*b;
  //int y = c*d;
  if(a<1200){cout << "ABC" << endl;}
  //else(y<x){cout < x << endl;}
  else{cout << "ARC" << endl;}
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

      int b = scan.nextInt();

      int c = scan.nextInt();

    if(a<=b&&b<=c){
           System.out.println(a+" "+b+" "+c);
      } else if(a<=c&&c<=b){
           System.out.println(a+" "+c+" "+b);
      } else if(b<=a&&a<=c){
           System.out.println(b+" "+a+" "+c);
      } else if(b<=c&&c<=a){
           System.out.println(b+" "+c+" "+a);
      } else if(c<=a&&a<=b){
           System.out.println(c+" "+a+" "+b);
      } else if(c<=b&&b<=a){
           System.out.println(c+" "+b+" "+a);}
   }
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    lli N;
    cin >> N;
    for (lli i = N; i > 0; i--) {
        lli t = i * (i + 1) / 2;
        if (t == N) {
            cout << i << endl;
            N -= i;
        }
        else if (t < N) {
            cout << i + 1 << endl;
            N -= (i + 1);
        }
    }
    return 0;
}

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

int main() {
  int N, n;
  int fn = 0;
  cin >> N;
  n = N;
  while(n > 0){
    fn += (n % 10);
    n /= 10;
  }
  if(N % fn == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("#"*20)

Measured memory_bytes: 7740