akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

struct FenwickTree {
    int length;
    vector<int> node;
    FenwickTree (int N) : length(N), node(length + 1, 0) {}
    void add(int idx, int val) {
        ++idx;
        while (idx <= length) {
            node[idx] += val;
            idx += (idx & (-idx));
        }
    }
    int getsum(int idx) {
        int ans = 0;
        while (idx) {
            ans += node[idx];
            idx -= (idx & (-idx));
        }
        return ans;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    FenwickTree FT(n);
    REP(_, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (!com) FT.add(x - 1, y);
        else cout << FT.getsum(y) - FT.getsum(x - 1) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3100
use strict;
use warnings;
use utf8;
use v5.18;

use List::Util qw(max);

my $x   = <STDIN>;
my $ans = 0;

for my $b ( 1 .. 1000 ) {
    for my $p ( 2 .. 10 ) {
        my $t = $b**$p;

        # print "$b ** $p = $t\n" if $t <= $x;
        $ans = max( $ans, $t ) if $t <= $x;
    }
}

print "$ans\n";


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
int main(){
//  freopen("test.in","r",stdin);
//  freopen("test.out","w",stdout);
	int n,number=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) 
	cin>>a[i];
	sort(a,a+n);
	for(int i =0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]>=a[j]+a[k]||a[j]>=a[i]+a[k]||a[k]>=a[i]+a[j]) 
				break;
				number++;
			}
		}
	}
	cout<<number;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

static vector<vector<int>> memo(1000, vector<int>(1000, -1));

class question {
public:
	string S;
	
	void ans() {
		cin >> S;
		int N = S.size();
		vector<int> sum(N + 1);
		sum[0] = 0;
		REP(i, N) {
			sum[i + 1] = sum[i];
			if (S[i] == 'B') sum[i + 1]++;
		}
		ll res = 0;
		REP(i, N) {
			if (S[i] == 'W') {
				res += sum[i];
			}
		}
		cout << res << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}



Measured memory_bytes: 5268
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int ball = sc.nextInt();
		int color = sc.nextInt();
		System.out.print((int)Math.pow(color - 1,ball - 1) * color);
	}
}

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first 
#define ss second

int ans=0;
vector<pair<int,int>> strt[200005];
vector<pair<int,int>> fin[200005];
int n,m1;

struct stnode
{
    int ma;
};
stnode st[800005];
int  lazy[800005]={0};
void merge(stnode &f,stnode &n1,stnode &n2)
{
    f.ma=max(n1.ma , n2.ma);
}
void build(int node ,int l ,int r)
{
    lazy[node]=0;
    if(l==r)
    {
        st[node].ma=0;
        return ; 
    }
    int m=(l+r)/2;
    build(2*node , l, m);
    build(2*node + 1, m+1 ,r);
    merge(st[node],st[2*node],st[2*node +1]);
}
void propogate(int node,int l,int r)
{
    st[node].ma+=lazy[node];
    //cout<<node<<" "<<st[node].ma<<"\n";
    if(l!=r)
    {
        lazy[node*2]+=lazy[node];
        lazy[2*node+1]+=lazy[node];
    }
    lazy[node]=0;
}
void update(int node,int l,int r,int tl,int tr,int val)
{
    //lazy[node]+=val;
    //cout<<node<<" "<<l<<" "<<r<<" "<<tl<<" "<<tr<<" "<<val<<"\n";
    if(lazy[node]!=0)
        propogate(node,l,r);
    if(r<tl || l>tr)
        return;
    if(l>=tl && r<=tr)
    {
        lazy[node]+=val;
        propogate(node,l,r);
        return;
    }
    int mid=(l+r)/2;
    update(2*node,l,mid,tl,tr,val);
    update(2*node+1,mid+1,r,tl,tr,val);
    merge(st[node],st[2*node],st[2*node +1]);
}
stnode query(int node, int L, int R, int i, int j)
    {
        //cout<<node<<" "<<L<<" "<<R<<" "<<i<<" "<<j<<"\n";
        if(lazy[node]!=0)
            propogate(node, L, R);
        if(j<L || i>R)
        {
            //cout<<node<<" jhc\n";
            return stnode();
        }
        if(i<=L && R<=j)
        {
            //cout<<node<<" "<<st[node].ma<<"\n";
            return st[node];
        }
        int M = (L + R)/2;
        if(j<=M)
            return query(node*2 , L, M, i, j);
        if(i>M)
            return query(node*2 +1, L, M, i, j);

        stnode left=query(node*2, L, M, i, j);
        stnode right=query(node*2 + 1, M + 1, R, i, j);
        stnode cur;
        merge(cur, left, right);
        return cur;
    }
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m1;
    for(int i=0;i<m1;i++)
    {
        int l,r,val;
        cin>>l>>r>>val;
        strt[l].push_back({r,val});
        fin[r].push_back({l,val});
    }
    int cursum=0;
    build(1,1,n);
    for(int i=1;i<=n;i++)
    {
        //cout<<i<<" ";
        int dp=0;
        for(auto &k:strt[i])
            cursum+=k.second;
        //cout<<cursum<<" ";
        dp=query(1,1,n,1,i).ma;
        ans=max(ans,dp + cursum);
        update(1,1,n,i,i,dp + cursum);
        //cout<<query(1,1,n,1,1).ma<<" ";
        for(auto &k:fin[i])
        {
            cursum-=k.second;
            update(1,1,n,k.first,i-1,k.second);
        }
        update(1,1,n,i,i,-cursum);
        //cout<<ans<<"\n";
        //cout<<i<<"\n";
    }
    cout<<ans;

} 

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n);
    for (auto &i:a) {
        cin >> i;
    }
    sort(begin(a), end(a));
    reverse(begin(a), end(a));
    vector<ll> pref(n);
    pref[0] = a[0];
    for (int i = 1; i < n; ++i) {
        pref[i] = pref[i - 1] + a[i];
    }
    auto check = [&](int pos) {
      if (pos < p) {
          return true;
      }
      if (a[pos] + m < a[p - 1]) {
          return false;
      }
      ll sum;
      if (p == 1) {
          sum = pref[pos - 1];
      } else {
          sum = pref[pos - 1] - pref[p - 2];
      }
      return 1ll * (a[pos] + m) * (pos - p + 1) >= sum + 1ll * m * (v - (p + n - 1 - pos));
    };
    int left = 0, right = n - 1;
    while (left != right) {
        int mid = (left + right + 1) / 2;
        if (check(mid)) {
            left = mid;
        } else {
            right = mid - 1;
        }
    }
    cout << left + 1;
    return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, INF))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "YES" : "NO");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  vecll r(n), c(n);
  rep(i,n){
    cin >> r[i] >> c[i];
  }

  ll INF = 1e18;
  vecll2(dp, n, n);

  rep(i,n){
    dp[i][i]=0;
  }

  REP(num,2,n+1){
    rep(i,n-num+1){
      REP(k,i,i+num-1){
        ll tmp = dp[i][k] + dp[k+1][i+num-1] + r[i]*c[k]*c[i+num-1];
        chmin(dp[i][i+num-1], tmp);
      }
    }
  }

  prt(dp[0][n-1]);
}



Measured memory_bytes: 3152
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;


bool used[1001001];
int dist[1001001];
vector<int> adj[1001001];
 
void impossible() { cout << "-1\n"; exit(0); }
 
int dfs(int i) {
    used[i] = true;
    int ans = 0;
    for (int j : adj[i]) {
        if (used[j] && dist[j] == 0) {
	    impossible();
	} else if (used[j]) {
	    ans = max(ans, dist[j]);
	} else {
	    ans = max(ans, dfs(j));
	}
    }
    return dist[i] = ans + 1;
}
 
int n;
int nd(int i, int j) { if (i < j) swap(i, j); return i * n + j; }
void addedge(int i1, int j1, int i2, int j2) {
    adj[nd(i1, j1)].push_back(nd(i2, j2));
}
 
int main() {
    cin >> n;
    int a[n][n-1];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n-1; j++) cin >> a[i][j], a[i][j]--;
    for (int i = 0; i < n; i++)
        for (int j = 1; j < n-1; j++) addedge(i, a[i][j-1], i, a[i][j]);
 
    int ans = -1;
    for (int i = 0; i < n; i++) {
        int v = nd(i, a[i][0]);
        if (!used[v]) dfs(v);
        ans = max(ans, dist[v]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 48128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

int n,a,b,c;
vector<vector<int>>l;

int rec(int i,int j,int comb=0,int suma=0,int sumb=0,int sumc=0){
    if(i==n){
        if(suma&&sumb&&sumc)return comb+abs(suma-a)+abs(sumb-b)+abs(sumc-c);
        else return 1e5;
    }
    if(!j){
        if(suma)comb+=10;
        suma+=l[i][j];
    }
    if(j==1){
        if(sumb)comb+=10;
        sumb+=l[i][j];
    }
    if(j==2){
        if(sumc)comb+=10;
        sumc+=l[i][j];
    }
    int res=1e5;
    rep(j,4){
        chmin(res,rec(i+1,j,comb,suma,sumb,sumc));
    }
    return res;
}

void solve(){
    cin>>n>>a>>b>>c;
    l.resize(n,vector<int>(3));
    int x,ans=1e5;
    rep(i,n){
        cin>>x;
        rep(j,3)l[i][j]=x;
    }
    rep(i,4)chmin(ans,rec(0,i));
    cout<<ans<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$c=floor($n/2)-1;
$ans=0;
$i=0;
while($i<=$c){
  if($s[$i]!=$s[$n-$i-1]){
    ++$ans;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		ArrayList<Integer> sam = new ArrayList<Integer>();
		sam.add(a);
		sam.add(b);
		sam.add(c);
		Collections.sort(sam);
//		for(int i =0;i<sam.size();i++){
//			System.out.println(sam.get(i));
//		}
		if(sam.get(2)==sam.get(1)+sam.get(0)){
			System.out.println("Yes");
		}else System.out.println("No");
		sc.close();
	}
}


Measured memory_bytes: 9812
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

int n,m;
bool graph[55][55];
bool visited[55];

void dfs(int y, int x) {
    if (visited[y]) return;
    visited[y] = true;
    for (int i = 0; i < n; ++i) if (graph[y][i]) dfs(i, y);
    return;
}

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    int c = 0;
    vector<int> a(m);
    vector<int> b(m);
    for (int i = 0; i < m; ++i) for (int j = 0; j < m; ++j) graph[i][j] == false;
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) visited[j] = false;
        graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = false;
        dfs(0, 0);
        bool nallv = false;
        for (int i = 0; i < n; ++i) if (!visited[i]) nallv = true;
        if (nallv) c++;
        graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
    }
    cout << c << std::endl;
    return 0;
}

Measured memory_bytes: 256
/**
  * @file pd.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-09-23
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 262144
#define M ((int)1e9+7)
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int inv(int k, int m)
{
    int a=k,b=m,ca=1,cb=0;
    while(b)
    {
        int t=a%b, ct=ca-cb*(a/b);
        a = b, ca = cb;
        b = t, cb = ct;
    }
    return (ca + m) % m;
}

int main()
{
    int n,m,ans=1;
    scanf("%d%d",&n,&m);
    for(int i=2;i*i<=m;++i)
    {
        if(m%i) continue;
        int c=0;
        while(m%i==0)
        {
            m/=i;
            ++c;
            ans = (lli)ans * (n+c-1) % M;
            ans = (lli)ans * inv(c,M) % M;
        }
        dbg_pri("poi 1: %d %d\n",i,ans);
    }
    if(m!=1) ans = (lli)ans * n % M;
    printf("%d\n",ans);
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int k, t;
    cin >> k >> t;

    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        cin >> a[i];
    }
    int mx = 0;
    int total = 0;
    for (int i = 0; i < t; i++) {
        total += a[i];
        mx = max(mx, a[i]);
    }
    total -= mx;
    cout << max(0, mx - total - 1) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int arr[] = {
				1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
		};
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		System.out.println(arr[K - 1]);
	}
}


Measured memory_bytes: 23124
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
 
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
 
int n, k;
bool dp[2002][10001];
bool good[2002][10001];
int vis[2002];
string s[2002];
vector <int> which;
vector <int> pos;
vector <int> next_which;
vector <int> next_pos;
 
char getBest()
{
	char ret = 'z';
	for (int i = 0; i < which.size(); i++)
	{
		ret = min(ret, s[which[i]][pos[i]]);
	}
	return ret;
}
 
void updateNext(char c, int remain)
{
	mem(vis, 0);
	next_which.clear();
	next_pos.clear();
	int firstFinish = n + 1;
	int rate = which.size() / 4000;
	rate = 0;
	int sz = which.size();
	for (int i = 0; i < sz; i += (rate + 1))
	{
		if (s[which[i]][pos[i]] == c)
		{
			if (pos[i] == s[which[i]].length() - 1)
			{
				firstFinish = min(firstFinish, which[i]);
			}
			else
			{
				vis[which[i]] = 1;
				next_which.push_back(which[i]);
				next_pos.push_back(pos[i] + 1);
			}
		}
	}
	for (int i = firstFinish + 1; i <= n; i++)
	{
		if (vis[i])continue;
		if (good[i][remain])
		{
			next_which.push_back(i);
			next_pos.push_back(0);
		}
	}
	which = next_which;
	pos = next_pos;
}
 
void solve()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> s[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[n + 1][0] = true;
	for (int i = n; i >= 1; i--)
	{
		for (int j = 0; j <= k; j++)
		{
			if (dp[i + 1][j] == true)
			{
				dp[i][j] = true;
			}
			if (j - (int)s[i].length() >= 0 && dp[i + 1][j - (int)s[i].length()])
			{
				dp[i][j] = true;
			}
		}
	}
	memset(good, false, sizeof(good));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (s[i].length() <= j && dp[i + 1][j - (int)s[i].length()])
			{
				good[i][j] = true;
			}
		}
	}
	int remain = k;
	for (int i = 1; i <= n; i++)
	{
		if (good[i][remain])
		{
			which.push_back(i);
			pos.push_back(0);
		}
	}
	string ret;
	for (int i = 1; i <= k; i++)
	{
		char c = getBest();
		remain--;
		updateNext(c, remain);
		ret += c;
	}
	cout << ret << endl;
}
 
int main()
{
	solve();
	return 0;
}

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

string s;
int w;

int main(void){
  // Here your code !

  cin >> s;
  scanf("%d", &w);

  for (int i = 0; i < s.size(); ++i) {
    if (i % w == 0) printf("%c", s[i]);
  }

  printf("\n");

  return 0;
}


Measured memory_bytes: 256
/*input
2 3
2 55
2 77
2 99
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

vector<pii> v[maxn];
string ans[maxn];


string tos(int n){
	string ret;
	REP(i,6){
		ret.pb(char('0'+n%10));
		n/=10;
	}
	reverse(ALL(ret));
	return ret;
}

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(MP(y,i));
	}
	REP(i,n+1) sort(ALL(v[i]));

	REP(i,n+1){
		REP(j,SZ(v[i])){
			int id=v[i][j].S;
			//cout<<id<<' '<<i<<' '<<j<<'\n';
			ans[id]=tos(i)+tos(j+1);
		}
	}
	REP(i,m) cout<<ans[i]<<'\n';
	return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);

  int b[4] = {0};

  for (int i = 0; i < 4; i++) {
    b[i] = N % 10;
    N /= 10;
  }

  if (b[0] == b[1] && b[1] == b[2]) {
    printf("Yes");
  } else if (b[1] == b[2] && b[2] == b[3]) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    ll n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))

class UnionFind(object):

    def __init__(self, N):
        self.tree = [i for i in range(N)]
        self.rank = [0] * (N + 1)
        self.size = [1] * N  # 頂点iの属する連結成分の大きさ
        self.blocksize = [0] * N

    def find(self, x):
        if self.tree[x] == x:
            return x
        else:
            self.tree[x] = self.find(self.tree[x])  # 経路圧縮
            return self.tree[x]

    def block(self, x, y):
        if not self.has_same_parent(x, y):
            return
        self.blocksize[x] += 1
        self.blocksize[y] += 1

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        # ランクを考慮しない場合はどちらが親になっても良い
        if self.rank[x] < self.rank[y]:
            self.tree[x] = y
            self.size[y] += self.size[x]
        else:
            self.tree[y] = x
            self.size[x] += self.size[y]

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def has_same_parent(self, x, y):
        return self.find(x) == self.find(y)


N, M, K = MI()
uf = UnionFind(N)
nl = [set() for _ in range(N)]
for _ in range(M):
    A, B = MI()
    nl[A - 1].add(B - 1)
    nl[B - 1].add(A - 1)
    uf.unite(A - 1, B - 1)

for _ in range(K):
    C, D = MI()
    uf.block(C - 1, D - 1)


ans = []
for i in range(N):
    a = uf.size[uf.find(i)] - len(nl[i]) - uf.blocksize[i] - 1
    ans.append(str(a))
print(' '.join(ans))

Measured memory_bytes: 126112
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (c > a - b) {
            int result = c - (a - b);
            System.out.println(result);
        } else {
            System.out.println(0);
        }
        sc.close();
    }
}

Measured memory_bytes: 22996
p = 10
N = int(input())
r = 0
while N>=p**(2*r):
    r += 1
r -= 1
if N < p**(2*r+1):
    print(N-p**(2*r) + 1 + (p**(2*r)-1)//(p+1))
else:
    print((p**(2*(r+1))-1)//(p+1))

Measured memory_bytes: 3060
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    for j in range(N-i+1):
        k=(N-i-j)
        if i*10000+j*5000+k*1000 == Y:
            flag=True 
            break
    if flag:
        break
print("{} {} {}".format(i,j,k) if flag else "-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(ll i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

int main()
{
	ll N;
	cin >> N;

	vector<int> nums;
	for (ll X = 2; X * X <= N; ++X)
	{
		int num = 0;
		while (true)
		{
			if (N % X != 0) break;
			N /= X;
			++num;
		}
		
		if (num != 0) nums.push_back(num);
	}

	if (N != 1) nums.push_back(1);

	int COUNT = 0;
	for (auto num : nums)
	{
		int i = 1;
		while (true)
		{
			if (num < i) break;
			num -= i;
			++i;
			++COUNT;
		}
	}

	cout << COUNT << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//入力した数値を変数に格納
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(0 <= a && a < b && b < c && c<=100){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();

		if ((x + r) <= W && (x - r) >= 0 && (y + r) <= H && (y - r) >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26248
import sys
M,K=map(int,input().split())
if 2**M<=K:
    print(-1)
    sys.exit()
if M==1:
    if K==0:
        print(0,0,1,1)
    else:
        print(-1)
    sys.exit()
L=[i for i in range(2**M)]
L+=[0]
M=[i for i in range(2**M-1,0,-1)]
L+=M
#print(L)
for i in range(len(L)):
    L[i]^=K
print(' '.join(map(str,L)))

Measured memory_bytes: 94860
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll fact[1000000], fact_inv[1000000];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}
int main(){
  ll N,M,K;cin>>N>>M>>K;
  ll A,B;
  ll i,j,k,l;
  //x軸とy軸で別々に考える
  //残りの点の選び方(N*M-2)C(K-2)
  fact[0]=1;
        // 階乗の計算
	rep(i,N*M) fact[i+1]=fact[i]*(i+1)%mod;
	fact_inv[M*N]=power(fact[M*N], mod-2);
        // 逆元の計算
	for(i=N*M-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%mod;
  //2点の距離dにする選び方は(N-d)*M**2
  ll Res=comb(N*M-2,K-2);
  //cout<<Res<<endl;
  ll x=0,y=0;
  repn(i,N-1){
    x+=i*(N-i)*M*M;
    if(x>mod) x%=mod;
  }
  repn(i,M-1){
    y+=i*(M-i)*N*N;
    if(y>mod) y%=mod;
  }
  ll ans=x+y;
  //cout<<x<<" "<<y<<endl;
  ans*=Res;
  ans%=mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    ll n,a,b,k;
    cin >> n >> a >> b >> k;
    
    COMinit();

    ll ans = 0;

    rep(ii,n+1){
        ll i = ii;
        ll kk = k - a*i;
        if(kk<0)break;
        if(kk%b==0 && kk/b<=n){
            ll j = kk/b;
            ll tmp = COM(n,i);
            tmp *= COM(n,j);
            tmp %= MOD;
            ans += tmp;
            ans %= MOD;
        }
    }

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


Measured memory_bytes: 12160
import java.util.Scanner;

fun main (args : Array<String>) {
  val MOD = 1_000_000_000 + 7
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val A = LongArray(N)
    var nextSum = 0L
    
    for (i in A.indices) {
      A[i] = input.nextLong()
      nextSum += A[i]
    }
    
    var ans = 0L
    for (i in A.indices) {
      nextSum -= A[i]
      ans += A[i] * (nextSum % MOD)
      ans %= MOD
    }
    
    println(ans)
  }
}

Measured memory_bytes: 61364
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

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

    Abra_Ka_Dabra

    map<char, int> x;
    char n;
    while(cin>>n) x[n]++;
    bool flag = true;
    for(auto i=x.begin(); i!=x.end(); i++){
        if(i->second & 1) flag = false;
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3620
#%%
n, l = map(int, input().split())
a = list(map(int, input().split()))

flag = False
for i in range(n-1):
    if a[i] + a[i+1] >= l:
        flag = True
        pos = i
if flag:
    print('Possible')
    for i in range(n-1):
        if i < pos:
            print(i+1)
        elif i == pos :
            break
    for i in range(n-2, -1, -1):
        if i > pos :
            print(i+1)
        elif i == pos :
            break
    print(pos+1)
else:
    print('Impossible')


#%%


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

signed main() {
    int a[5], k;
    
    for ( int i = 0; i < 5; i++ ) {
        cin >> a[i];
    }
    cin >> k;
    sort(a, a + 5);
    
    cout << (a[4] - a[0] > k ? ":(\n" : "Yay!\n");
    return (0);
}

Measured memory_bytes: 3544
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nw = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var dic = new Dictionary<int, List<int>>();
        for(var i = 0; i < nw[0]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            if (dic.ContainsKey(input[0]))
                dic[input[0]].Add(input[1]);
            else dic[input[0]] = new List<int> { input[1] };
        }
        var kee = dic.Keys.ToList();
        for (var i = 0; i < kee.Count; i++)
            dic[kee[i]] = dic[kee[i]].OrderByDescending(v => v).ToList();
        var min = kee.Min();
        var keys = Enumerable.Range(0, 4).Select(v => v + min).ToArray();
        foreach (var ke in keys)
        {
            if (!dic.ContainsKey(ke))
                dic[ke] = new List<int>();
        }
        var res = 0L;
        for (var i = 0; i <= nw[0]; i++)
        {
            if (i > dic[keys[0]].Count) break;
            for (var j = 0; j <= nw[0]; j++)
            {
                if (j > dic[keys[1]].Count) break;
                for (var h = 0; h <= nw[0]; h++)
                {
                    if (h > dic[keys[2]].Count) break;
                    for (var k = 0; k <= nw[0]; k++)
                    {
                        if (k > dic[keys[3]].Count) break;
                        var ar = new[] { i, j, h, k };
                        var weight = 0L;
                        var va = 0L;
                        for (var i1 = 0; i1 < 4; i1++)
                        {
                            weight += (long)keys[i1] * ar[i1];
                            va += dic[keys[i1]].Take(ar[i1]).Sum();
                        }
                        if (weight <= nw[1])
                            res = Max(res, va);
                    }
                }
            }
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 17608
import sys
sys.setrecursionlimit(10000)


def solve():
    N, K = list(map(int, input().split()))

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)


Measured memory_bytes: 4212
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	char x;
	cin>>x;
	if(x>='a'&&x<='z')
		cout<<"a";
	else
		cout<<"A";
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

int main(){
	long long n,a,b;
	cin>>n>>a>>b;
	long long ans=n%(a+b);
	n-=ans;
	if(ans>a)ans=a;
	n/=(a+b);
	n*=a;
	cout<<ans+n;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String str = sc.next();
      int count = 0;
	  if(str.substring(0,1).equals("o")) count++;
      if(str.substring(1,2).equals("o")) count++;
      if(str.substring(2,3).equals("o")) count++;
      System.out.println(700 + 100*count);
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
ll N;
ll ans=1e9;
ll black[200005];
ll white[200005];
char prev;
string S;
int main(void)
{
  black[0]=0;
  white[0]=0;
  cin >> N;
  cin >> S;
  for(int i=0;i<N;i++)
    {
      if(S[i]=='#')
	{
	  black[i+1]=black[i]+1;
	  white[i+1]=white[i];
	}
      else if(S[i]=='.')
	{
	  white[i+1]=white[i]+1;
	  black[i+1]=black[i];
	}
    }
  white[N+1]=white[N];
  black[N+1]=black[N];
  for(int i=0;i<=N;i++)
    {
      ans=min((black[i]-black[0])+(white[N+1]-white[i+1]),ans);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
		sc = bufio.NewScanner(strings.NewReader(`
		5 2 2
		ccccc
	`))
		//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	n, a, b := nextInt(), nextInt(), nextInt()
	s := next()

	passCount := 0
	fcount := 0

	for i := 0; i < n; i++ {
		var ans string = "No"
		if s[i:i+1] == "a" && passCount < a+b {
			ans = "Yes"
			passCount++
		} else if s[i:i+1] == "b" && passCount < a+b && fcount < b {
			ans = "Yes"
			passCount++
			fcount++
		}
		fmt.Fprintln(out, ans)
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

class Point {
public:
int x, y;
Point(int myX, int myY) {
        x = myX;
        y = myY;
}
Point() {
        x = 0;
        y = 0;
}

int md(Point cp) {
        return abs(x - cp.x) + abs(y - cp.y);
}
};

int main(int argc, char const *argv[]) {
        int n, m;
        cin >> n >> m;
        vector<Point> student, checkpoint;
        for (auto i = 0; i < n + m; ++i) {
                int x, y;
                cin >> x >> y;
                if (i < n) {
                        student.emplace_back(Point(x,y));
                }
                else {
                        checkpoint.emplace_back(Point(x,y));
                }
        }
        vector<int> shortest(student.size(),1);
        for (auto i = 0; i < student.size(); ++i) {
          int length = student[i].md(checkpoint[0]);
          for (auto j = 1; j < checkpoint.size(); ++j) {
            if (student[i].md(checkpoint[j]) < length) {
              shortest[i] = j + 1;
              length = student[i].md(checkpoint[j]);
            }
          }
        }
        for (auto& x : shortest) {
          cout << x << endl;
        }
        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 sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define sq(x) ((x)*(x))
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17

#define maxn 300005
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;

i64 a[maxn] ;

int main()
{
    i64 n ;
    scanf("%lld",&n) ;

    for(int i=1 ; i<=n ; i++)
    {
        scanf("%lld",&a[i]) ;
    }

    sort(a+1,a+n+1) ;

    int cutOff = 1 ;

    for(int i=2 ; i<n ; i++) if( a[i] <=0 ) cutOff = i ;

    i64 ans = 0LL ;
    for(int i=1 ; i<=cutOff ; i++) ans -= a[i] ;
    for(int i=cutOff+1 ; i<=n ; i++) ans += a[i] ;

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

    i64 cur = a[1] ;

    for(int i=cutOff+1 ; i<n ; i++)
    {
        printf("%lld %lld\n", cur , a[i] ) ;
        cur -= a[i] ;
    }

    printf("%lld %lld\n" , a[n],cur ) ;
    cur = a[n]-cur ;

    for(int i=2 ; i<=cutOff ; i++)
    {
        printf("%lld %lld\n",cur,a[i]) ;
        cur -= a[i] ;
    }

    return 0 ;
}


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

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

int main(){

	int A, B;




	scanf("%d %d", &A, &B);

	if ((A + B) >= (A - B) && (A + B) >= (A*B)){
		printf("%d\n", A + B);
	}
	else if ((A + B) <= (A - B) && (A - B) >= (A*B)){
		printf("%d\n", A - B);
	}
	else{
		printf("%d\n", A*B);
	}

	return 0;

}
    

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

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

int culc(int *a,int n){
	int i;
	int msmall;
	int m;
	int cnt;
	int ans;
	
//	for(i=0;i<n;i++)	printf(" %d",a[i]);
//	printf("\n");
	
	msmall=0;
	for(i=0;i<n;i++){
		if((a[msmall]>a[i] || a[msmall]==0) && a[i]!=0)	msmall=i;
	}
	
//	printf("  %d %d\n",msmall,a[msmall]);
	
	cnt=0;
	for(i=0;i<n;i++){
		if(a[i]!=0)	cnt++;
	}
	
	if(cnt==1)	return a[msmall];
	
	for(i=0;i<n;i++){
		if(i!=msmall)	a[i]%=a[msmall];
	}
	
	ans=culc(a,n);
	
	return ans;
}

int main(){
	int N;
	int i;
	int ans;
	
	scanf("%d",&N);
	
	int Ai[N];
	
	for(i=0;i<N;i++){
		scanf("%d",&Ai[i]);
	}
	
	ans=culc(Ai,N);
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<string> vs;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        vs.push_back(s);
    }
    sort(vs.begin(),vs.end());
    long long cnt=0;
    int conti=0;
    for(int i=1;i<n;i++){
        if(vs[i]==vs[i-1]){
            ++conti;//2
            cnt+=conti;//3
        }else{
            conti=0;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5876
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,A,B,C;
   cin>>a;
   cin>>b;
   cin>>c;

   A=min(a,min(b,c));
   C=max(a,max(b,c));
   B=a+b+c-A-C;

   cout<< A <<" "<< B <<" "<< C << endl;

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  int n,i;
  long long int sum=0;
  cin>>n;
  long long int T[n+2],B[n+1];
  FORE(i,1,n+1)
  {
      cin>>T[i];
  }
  FORE(i,1,n)
  {
      cin>>B[i];
  }
  for(i=1;i<=n;i++)
  {
   if(B[i]>T[i])
          {
              sum+=T[i];
              B[i]-=T[i];T[i]=0;if(B[i]>T[i+1])
              {
                  sum+=T[i+1];
                  B[i]-=T[i+1];
                  T[i+1]=0;
              }else{sum+=B[i];
              T[i+1]-=B[i];
              B[i]=0;}
          }else{sum+=B[i];T[i]-=B[i];}
  }
  cout<<sum;




	 return 0;
}


Measured memory_bytes: 1792
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

def cnt_digits(N):
    digits = 1
    while N>=10:
        N /= 10
        digits += 1
    return digits

N = int(input())

ans = cnt_digits(N)

for A in range(1, int(math.sqrt(N))+1):
    if N % A != 0:
        continue
    B = N//A

    tmp = max(cnt_digits(A), cnt_digits(B))
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 12492
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= 9; i++)
        {
            if (n % i == 0 && n / i <= 9)
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
  ll N,x,sum=0,e=0;
  cin>>N>>x;
  ll A[N];
  for(ll i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  if(A[0]>x) A[0]=x;
  for(ll i=1;i<N;i++){
    if(A[i-1]+A[i]>x){
      ll a=A[i-1]+A[i]-x;
      A[i]-=a;
    }
  }
  for(ll i=0;i<N;i++) e+=A[i];
  cout<<sum-e<<endl;
}

Measured memory_bytes: 1024