akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
map<string,int>mp;
char s[100009][15];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%s",s[i]);
		sort(s[i],s[i]+10);
	}
	long long ans=0;
	for(int i=1; i<=n; i++) {
		mp[s[i]]++;
	}
	for(int i=1; i<=n; i++) {
		ans+=1ll*mp[s[i]]*(mp[s[i]]-1)/2;
		mp[s[i]]=0;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12672
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int
main(int argc, char* argv[]) {
  int n, _a, i, s;
  vector<int> a;

  cin >> n;

  s = 0;
  for(i=0; i<n; i++) {
    cin >> _a;
    a.push_back(_a);
    s += _a - 1;
  }

  cout << s;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 14, 2020 13:00:21 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N, K = list(map(int, input().split()))
  A = input()[:-1]

  origin = 0
  for i in range(N-1):
    if A[i] == A[i+1]:
      origin += 1

  if A[0] == 'L':
    target = 'R'
  else:
    target = 'L'

  if A[-1] == 'L':
    A += 'R'
  else:
    A += 'L'

  lim = K
  pre = A[0]
  for i in range(1, N+1):
    # if pre == A[i]:
    #   pre = A[i]
    #   continue
    # if A[i] == target:
    #   pre = A[i]
    #   continue

    if (not(pre == A[i]) and not(A[i] == target)):
      lim -= 1
      if i == N:
        origin += 1
      else:
        origin += 2
      if lim <= 0:
        break
    pre = A[i]

  print(origin)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 73204
// Alapan
// IIITH

#include<bits/stdc++.h>
using namespace std;

// data types
#define ll long long int
#define ld long double

//funtion macros


// stl
#define lp(var,start,end) for (ll var = start; var <=end ; ++var)
#define ilp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))

#define mod 1000000007

// utility functions
ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

ll min(ll a, ll b){
	if(a<b)return a;
    return b;
}

ll power(ll x, ll y, ll m=mod){
	if(y<0){
		x = power(x,m-2);
		y = -y;
	}
	ll ans=1;
	x = x % m;
	while(y){
		if(y&1) ans = (ans*x)%m;
		y=y/2;
		x=(x*x)%m;
	}
	return ans;
}

ll factorial(ll n, ll m=mod){
    ll ans = 1;
	ll i = 1;
    while(i<=n){
        ans = (ans*i)%m;
        i++;
    }
    return ans;
}

///////////////////////////////////////////////////////////

int main(){
    ios_base::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int main() {
	int a = 0;
	cin >> a ;
	int card[108];
	for (int i = 0; i < a; i++) {
		cin >> card[i];
	}
	sort(card, card + a, greater<int>());
	int ali = 0, Bob=0;
	for (int i = 0; i < a; i++) {
		if (i % 2 == 0) {
			ali += card[i];
		}
		else { Bob += card[i]; }
	}
	cout << ali - Bob << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
hp = [list(map(int,input().split())) for i in range(n)]
hp.sort(key = lambda x:x[0]+x[1])
dp = [[10**18 for i in range(j+1)] for j in range(n+1)]
dp[0][0] = 0
for i in range(1,n+1):
  h,p = hp[i-1]
  for j in range(i+1):
    if j < i:
      dp[i][j] = dp[i-1][j]
    if j and dp[i-1][j-1] <= h:
      dp[i][j] = min(dp[i][j],dp[i-1][j-1]+p)
for i in range(n+1):
  if dp[-1][i] == 10**18:
    print(i-1)
    break
else:
  print(n)

Measured memory_bytes: 142596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int> P;
int inf = 100000000;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> vec(h ,vector<char>(w));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> vec[i][j];

    int dp[105][105];
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) dp[i][j] = inf;
    if(vec[0][0] == '.') dp[0][0] = 0;
    else                dp[0][0] = 1;

    for(int i=1;i<h;i++) {
        if(vec[i-1][0]=='.' && vec[i][0]=='#') dp[i][0] = min(dp[i][0] ,dp[i-1][0] + 1);
        else                                   dp[i][0] = min(dp[i][0] ,dp[i-1][0]);
    }

    for(int j=1;j<w;j++){
        if(vec[0][j-1]=='.' && vec[0][j]=='#') dp[0][j] = min(dp[0][j] ,dp[0][j-1] + 1);
        else                                   dp[0][j] = min(dp[0][j] ,dp[0][j-1]);
    }


    for(int i=1;i<h;i++) for(int j=1;j<w;j++){
        if(vec[i][j-1]=='.' && vec[i][j]=='#') dp[i][j] = min(dp[i][j] ,dp[i][j-1] + 1);
        else                                   dp[i][j] = min(dp[i][j] ,dp[i][j-1]);
        if(vec[i-1][j]=='.' && vec[i][j]=='#') dp[i][j] = min(dp[i][j] ,dp[i-1][j] + 1);
        else                                   dp[i][j] = min(dp[i][j] ,dp[i-1][j]);
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

ll n, a, b;

int main(){

cin >> n >> a >> b;

if(n == 1 && b != a) {cout << 0;return 0;}

if(b < a) {cout << 0;return 0;}
else if(a == b) {cout << 1;return 0;}
else {

    ll ans1 = (n - 1) * a + b;
    ll ans2 = (n - 1) * b + a;

    cout << ans2 - ans1 + 1;

}

return 0;
}



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

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

    int n, m;
    cin >> n >> m;
    int arr[n + 5];
    int sum = 0;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        sum += arr[i];
    }

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(arr[i] * 4 * m >= sum){
            cnt++;
        }
    }

    if(cnt >= m){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;

int main(const int args, const char* argv[])
{
    int nums;
    while(true)
    {
        cin >> nums;
        if(nums == 0) break;
        double tmpTotal(0);
        double tmpTotalForSD(0);
        vector<double> inputs;
        for(int i = 0; i < nums; i++)
        {
            double tmp;
            cin >> tmp;
            tmpTotal += tmp;
            inputs.push_back(tmp);
        }
        double mean = tmpTotal / nums;
        for(int i = 0; i < nums; i++)
        {
            tmpTotalForSD += pow(inputs[i] - mean, 2);
        }

        cout << setprecision(8) << fixed << sqrt(tmpTotalForSD / nums) << endl;
        
    }

    return 0;
}


Measured memory_bytes: 3260
N = int(input())
T = []
X = []
Y = []
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
flag = 0
if T[0]-abs(X[0])-abs(Y[0]) < 0 or (T[0]-abs(X[0])-abs(Y[0]))%2 != 0:
    flag = 1
for i in range(N-1):
    if T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]) < 0 or (T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]))%2 != 0:
        flag = 1
print("Yes" if flag == 0 else "No")


Measured memory_bytes: 17544
Scanf.scanf "%d %d %d %d %d" (fun n a b c d ->
    let rec loop m =
        if m = n then false else
            let q = (n - 1) - m in
            if c * q - d * m <= b - a &&
               d * q - c * m >= b - a then true else loop (m + 1)
    in
    print_endline @@ if loop 0 then "YES" else "NO"
)

Measured memory_bytes: 384
S = input()
N = len(S)
f = True
# first condition
if S[0] != "A":
    f = False
# 2nd condition
c = 0
for i in range(2, N-1):
    if S[i] == "C":
        c += 1
if c != 1:
    f = False

# 3rd cindition
for i in S:
    if i not in "AC":
        if i != i.lower():
            f = False
            break
if f:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

void m1(){
  int l,r,d;
  cin >> l >> r >> d;
  int res = 0;
  for(int i=l;i<=r;++i){
	if(i%d == 0) ++res;
	}
  print(res);
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int N; cin >> N;
    int d = N % 10;
    if (d == 3) {
        cout << "bon" << endl;
    } else if (d == 0 || d == 1 || d == 6 || d == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3608
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;

    cout << n * (n + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		System.out.println((int)Math.ceil(((double)(B-1)/(double)(A-1))));

	}
}

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

using namespace std;

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

    int a, b, c, x, y, ans;
    cin >> a >> b >> c >> x >> y;

    if (x > y)
        ans = 2 * y * c + (x - y) * min(2 * c, a);
    else
        ans = 2 * x * c + (y - x) * min(2 * c, b);
    ans = min(ans, a * x + b * y);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s,t;
  cin>>s>>t;
  string ans;
  for(int i=0;i<(int)s.size();i++){
    ans+=s[i];
    if(i<t.size()) ans+=t[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets().chomp().to_i
prices = gets().chomp().split(' ').map(&:to_i)
curr_money = 1000
buy_at, count = -1, 0

while count < n do
    if buy_at == -1
        buy_at = count
    else 
        if prices[buy_at] < prices[count]
            curr_money += (curr_money / prices[buy_at]) * (prices[count] - prices[buy_at])
            buy_at = count
        else
            buy_at = count
        end
    end
    count += 1
end
puts curr_money

Measured memory_bytes: 14232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

//　最大値注意!!
const int MAX_N = 100000;

//　選べる仕事の中で、終了時間が最も小さいものを選ぶことを繰り返す.


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(m), t(m);
    rep(i, m) cin >> s[i] >> t[i];
    pair<int, int> itv[m];

    // pairは辞書順で比較される。
    //　終了時間が早い順にしたいため、Tをfirstに、Sをsecondに入れる。
    rep(i, m) {
        itv[i].first = t[i];
        itv[i].second = s[i];
    }
    sort(itv, itv+m);

    // timeは最後に選んだ仕事の終了時間
    int answer = 0, time = 0;
    rep(i, m) {
        if(time <= itv[i].second) {
            answer++;
            time = itv[i].first;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 4796
N = int(input())
a = [int(input()) for _ in range(N)]
index = a[0] - 1
cnt = 1
flg = False
for i in range(len(a)):
    if index==1:
        print(cnt)
        flg = True
        break
    index = a[index] - 1
    cnt += 1
if flg:
    pass
else:
    print(-1)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ld long double
#define pb push_back
#define N 10000007
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
	cout<<1<<endl;
	else if(b==0)
	cout<<2<<endl;
	else if(c==0)
	cout<<3<<endl;
	else if(d==0)
	cout<<4<<endl;
	else
	cout<<5<<endl;
}


Measured memory_bytes: 3600
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

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


# ===CODE===
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def main():
    n, m = ns()

    if n < m:
        print(0)
        exit()
    else:
        n -= m
    # 分割数：N個の数をK個に分ける方法
    # 分けたものは区別できないので、3を[1,2],[2,1]のように分けるのは合わせて1カウント
    # dp[i][j] = dp[i][j-i] + dp[i-1][j] jをi個に分割する数
    # 蟻本P66

    dp = [[0 for _ in range(n + 1)] for __ in range(m + 1)]
    dp[0][0] = 1

    for i in range(1, m + 1):
        for j in range(n + 1):
            if j - i >= 0:
                dp[i][j] = dp[i - 1][j] + dp[i][j - i]
            else:
                dp[i][j] = dp[i - 1][j]
            dp[i][j] %= MOD
    print(dp[m][n])


if __name__ == '__main__':
    main()



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

string i_to_c(int a){
  int flag = 0;
  int r=100;
  string res;

  while(r>0){
    if(a>=r)flag = 1;
    if(flag){
      res.push_back('0'+a/r);
      a -= (a/r) * r;
    }
    r /= 10;
  }
  return res;
}

    

int main(){
  string str,tmp;
  int i,j,n;
  char now;
  int cnt;

  while(1){
    cin >> n;
    if(!n)break;
    cin >> str;

    for(j=0;j<n;j++){
      now = str[0];
      cnt = 1;
      for(i=1;i<str.size();i++){
	if(now == str[i]){
	  cnt++;
      }else{
	  tmp += i_to_c(cnt);
	  cnt = 1;
	  tmp.push_back(now);
	  now = str[i];
	}
      }
      tmp += i_to_c(cnt);
      tmp.push_back(now);
      str = tmp;
      tmp.clear();
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 0
x, y, a, b, c = list(map(int, input().split()))
ret = (a + b) * [0]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
Y = []
A.sort()
B.sort()
C.sort()

X = A[(a - x):]
Y = B[(b - y):]

idxA = 0
idxB = 0
idxC = c - 1
for i in reversed(range(c)):
    if idxA == x and idxB == y:
        break
    if idxA == x:
        if C[i] > Y[idxB]:
            Y[idxB] = C[i]
            idxB += 1
        else:
            break
    elif idxB == y:
        if C[i] > X[idxA]:
            X[idxA] = C[i]
            idxA += 1
        else:
            break
    elif C[i] <= min(X[idxA], Y[idxB]):
        break
    elif X[idxA] <= Y[idxB]:
        X[idxA] = C[i]
        idxA += 1
    else:
        Y[idxB] = C[i]
        idxB += 1
print((sum(X) + sum(Y)))

Measured memory_bytes: 24752
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;

  int main(){
int n,m;
cin >> n >> m;
int p[m],y[m];
rep(i,m) cin >> p[i] >> y[i];
vector<pint> v[n],a[n];
rep(i,m){
v[p[i]-1].push_back({y[i],i});
}
rep(i,n){
sort(v[i].begin(),v[i].end());
}
rep(i,n){
rep(j,v[i].size()){
a[i].push_back({v[i][j].second,j+1});
}
}
    pint t[m];
rep(i,n)sort(a[i].begin(),a[i].end());
rep(i,n){
rep(j,a[i].size()){
  t[a[i][j].first].first=i+1;
  t[a[i][j].first].second=a[i][j].second;
}
}
    rep(i,m){
      printf("%06d", t[i].first);
      printf("%06d", t[i].second);
      cout << endl;
    }
return 0;}


Measured memory_bytes: 13952
# AtCoder Beginner Contest 151: C (2020/01/12)
N, M = map(int, input().split())
ANS = [0 for i in range(N)]
PNL = [0 for i in range(N)]
p = [0 for i in range(M)]
S = ['' for i in range(M)]
for i in range(M):
    l = input().split()
    p[i] = int(l[0])
    S[i] = str(l[1])
for i in range(M):
    if ANS[p[i]-1] == 0:
        if S[i] == 'AC':
            ANS[p[i]-1] = 1
        else:
            PNL[p[i]-1] = PNL[p[i]-1] + 1
ans = 0
pnl = 0
for i in range(N):
    if ANS[i] == 1:
        ans = ans + 1
        pnl = pnl + PNL[i]
print(ans, pnl)

Measured memory_bytes: 15012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
    int n,k;cin>>n>>k;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    int g = 0;
    rep(i,n){
        g = gcd(v[i],g);
    }
    string ans = "POSSIBLE";
    if(k > *max_element(all(v)) || k%g!=0)ans = "IM"+ans;
    cout << ans << endl;
}



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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 1;
    int idx = 1;
    while (idx + k <= n) {
        idx += k - 1;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
march_dict = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}
for i in range(N):
    S = input()
    s_head = S[0]
    if march_dict.get(s_head) is not None:
        march_dict[s_head] += 1

# march_candidate = [key for key, val in march_dict.items() if val != 0]
import itertools

ans = 0
for C in itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3):
    a = march_dict[C[0]]
    b = march_dict[C[1]]
    c = march_dict[C[2]]
    ans += a * b * c
    # print(ans)
    # print(march_candidate)
print(ans)


Measured memory_bytes: 9152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

bool d[101][3];

int main() {
	int n, x, a;
	cin >> n;
	for (int i = 0; i < 3; ++i) {
		cin >> x;
		for (int j = 0; j < x; ++j) {
			cin >> a;
			d[a][i] = true;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if (!d[i][0] && d[i][2] || d[i][1] && d[i][2])
			ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
//#define no cout<<"NO"<<"\n"
#define INF (int)1e5+5
#define nax (int)1e6+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N (int)1e6+2
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern
 
 


	
signed main() {	
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);	

	int n;
	cin >> n;
	int ans = (1000 - n%1000)%1000;
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n;
int main()
{
	cin>>n;
	cout<<n*n*n<<endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<ll> A(N); for (int i = 0; i < N; ++i) cin >> A[i];
  ll ans = 0;
  ll xsum = 0, sum = 0;
  deque<int> deq;
  for (int r = 0; r < N; ++r) {
    deq.push_back(r);
    xsum ^= A[r], sum += A[r];
    while (xsum != sum) {
      int l = deq.front(); deq.pop_front();
      xsum ^= A[l], sum -= A[l];
    }
    ans += deq.size();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

ll powll(ll n, ll exp)
{
    if (exp == 1)
    {
        return n;
    }
    else if (exp == 0)
    {
        return 1;
    }

    if (exp % 2 == 0)
    {
        ll ans = powll(n, exp / 2);
        return ans * ans % MOD;
    }
    else
    {
        ll ans = powll(n, exp / 2);
        ans = ans * ans % MOD;
        return ans * n % MOD;
    }
}

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

    ll minus = 0;
    {
        ll x = 1;
        for (size_t i = n; i > (n-a); i--)
        {
            x *= i;
            x %= MOD;
        }

        ll y = 1;
        for (size_t i = 1; i <= a; i++)
        {
            y *= i;
            y %= MOD;
        }
        minus += (x * powll(y, MOD - 2));
        minus %= MOD;
    }
    {
        ll x = 1;
        for (size_t i = n; i > (n-b); i--)
        {
            x *= i;
            x %= MOD;
        }
        ll y = 1;
        for (size_t i = 1; i <= b; i++)
        {
            y *= i;
            y %= MOD;
        }
        
        minus += x * powll(y, MOD - 2);
        minus %= MOD;
    }

    ll all = powll(2, n);
    ll ans = all - minus - 1;
    cout << (ans >= 0 ? ans : MOD - abs(ans)) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a,b,c,A,B,C;
    scanf("%d %d %d",&a,&b,&c);
    A = a , B = b , C = c;
    if(A <= B){
        if(B <= C){
            a = A , b = B , c = C;
        }
        else if(B > C){
            if(A <= C){
                a = A , b = C , c = B;
            }
            else {
                a = C , b = A , c = B;
        }
        }
    }
    else if(A > B){
        if(A <= C){
            a = B , b = A , c = C;
        }
        else if(A > C){
            if(B <= C){
                a = B , b = C , c = A;
            }
            else{
                a = C , b = B , c = A;
            }
        }
    }
    printf("%d %d %d\n",a,b,c);
    }


Measured memory_bytes: 2728
//#include <stdio.h>
#include <bits/stdc++.h>
#include <climits>
using namespace std;
int main()
{   
    int n;
    cin >> n;
    bool flag=false;
    int ans=n;
    while(ans >0){
      //  cout << ans*1.08<<endl;
        if(int(ans*1.08)==n){

            cout << ans <<endl;
            flag=true;
            break;
        }
      
        ans--;
    }
    if(flag==false){
    cout <<":("<<endl;
    
    }return 0;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    var s_pls = 0.toLong()
    var s_mns = 0.toLong()
    var pls_cnt = 0.toLong()
    var mns_cnt = 0.toLong()
    for(i in 0 until n){
        s_pls += l[i]
        s_mns += l[i]
        if(i % 2 == 0){
            if(s_pls <= 0){
                pls_cnt += 1 - s_pls
                s_pls = 1
            }
            if(s_mns >= 0){
                mns_cnt += 1 + s_mns
                s_mns = -1
            }
        }
        else{
            if(s_mns <= 0){
                mns_cnt += 1 - s_mns
                s_mns = 1
            }
            if(s_pls >= 0){
                pls_cnt += 1 + s_pls
                s_pls = -1
            }
        }
    }
    println(Math.min(Math.abs(pls_cnt), Math.abs(mns_cnt)))
}

Measured memory_bytes: 53880
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

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



int n, k, a[101010];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	
	int ans = INF;
	for(int i = 0; i <= n-k; i++){
		chmin(ans, a[k+i-1]-a[i]);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 640
import sys

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


def main():
    S = input()
    n = len(S)

    ans = 0
    for i in range(n // 2):
        if S[i] != S[n - 1 - i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

void init(){

}

void solve(){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", max(0, (b+c)-a));
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
    for(int i = 0; i < test_cases_number; i++)
        solve();
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll N,X,cur,ans;
ll x[100005];


int main(void) {
	cin >> N;
	cout << "ABC" << N << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n);
  vector<int> wa(n);
  int t_ac = 0;
  int t_wa = 0;
  rep(i, m) {
    int p; string s;
    cin >> p >> s;
    p--;
    if(s == "AC") {
      ac[p]++;
      if(ac[p] > 1) continue;
      t_wa += wa[p];
    } else {
      wa[p]++;
    }
  }
  rep(i, n) {
    if(ac[i] >=1) t_ac++;
  }
  cout << t_ac << " " << t_wa << endl;
  return 0;
}

Measured memory_bytes: 4028
package main
  
import (
    "fmt"
)

func main() {
    var s []byte
    fmt.Scan(&s)
    if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ||
        s[0] == s[2] && s[1] == s[3] && s[0] != s[1] ||
        s[0] == s[3] && s[1] == s[2] && s[0] != s[1] {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    char a, b; cin >> a >> b;
    int A = a-'0';
    int B = b-'0';
    if (a <= b) {
        rep(i,B) cout << a;
    }
    else rep(i,A) cout << b;
    cout << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e15
# define LG 20  
typedef pair<int,pair<int,int> > pii;
# define INF1 (int)1e9+2
# define maxn 100005
# define offset 5

ll cf[maxn];
ll ps[maxn];
ll a[maxn];
ll sum;
ll ans;
int main()
{
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> a[i];

	for(int i=1;i<=n;i++)
	{
		cf[i]=a[i];
		cf[i]+=cf[i-1];
		if(a[i]>0)
		ps[i]=a[i];
	    ps[i]+=ps[i-1];
	    if(a[i]>0)
	    	sum+=a[i];
	}

	for(int i=1;i<=n;i++)
	{
		 if(i+k-1>n)
		 	break;
		 ll temp=cf[i+k-1]-cf[i-1];
		 temp+=(sum-(ps[i+k-1]-ps[i-1]));
		 ans=max(ans,temp);
		 temp=0;
		 temp+=(sum-(ps[i+k-1]-ps[i-1]));
		 ans=max(ans,temp);
	}

	cout << ans;

}

Measured memory_bytes: 2560
//
// Created on 2019-02-03.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    double t, x;
    cin >> t >> x;

    cout << t/x << endl;



}

Measured memory_bytes: 256
try:
    from math import gcd
except:
    from fractions import gcd

A, B, C, D = map(int, input().split())
gcm = C * D // gcd(C, D)
n = B - A + 1
n -= B // C - (A - 1) // C
n -= B // D - (A - 1) // D
n += B // gcm - (A - 1) // gcm
print(n)

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  int N = int(s.size());
  int sum(0);
  for(int i(0);i<N;i++){
    if(s[i] == 'a') continue;
    sum += 26 - (s[i]-'a');
  }
  if(sum > k){
    for(int i(0);i<N;i++){
      if(s[i]=='a') continue;
      int tmp = 26 - (s[i]-'a');
      //cout << tmp << endl;
      if(k >= tmp){
        k -= tmp;
        s[i] = 'a';
      }
    }
    s[N-1] = (char)(s[N-1] + k);
  }else{
    string ans(N,'a');
    int amari = k-sum;
    amari %= 26;
    ans[N-1] = (char)('a'+amari);
    s = ans;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
void solve() {
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);
	vector<ll> ds;
	ll k = sqrt(g + 0.1);
	rep1(i, k) {
		if (g%i == 0) {
			ds.push_back(i);
			ds.push_back(g / i);
		}
	}
	sort(ds.begin(), ds.end());
	ds.erase(unique(ds.begin(), ds.end()),ds.end());
	vector<ll> ps;
	rep(i, ds.size()) {
		ll d = ds[i];
		if (d == 1)continue;
		bool valid = true;
		rep(j, ps.size()) {
			if (d%ps[j] == 0)valid = false;
		}
		if (valid)ps.push_back(d);
	}
	cout << ps.size()+1 << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}



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

int n;
char s[500][500];
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 };
struct st {
	int a, b, c;
};
int main() {
	int d; scanf("%d", &d);
	rep(i, d) {
		scanf("%d", &n);
		memset(s, 0, sizeof(s));
		rep(j, n)rep(k, n)s[j][k] = ' ';
		queue<st>que;
		s[n - 1][0] = '#';
		que.push({ n - 1, 0,0 });
		while (!que.empty()) {
			st p = que.front(); que.pop();
			int x = p.a, y = p.b, idx = p.c;
			int nx = x + dx[idx], ny = y + dy[idx];
			int kx = nx + dx[idx], ky = ny + dy[idx];
			int jx = nx + dx[(idx + 1) % 4], jy = ny + dy[(idx + 1) % 4];
			if (0 <= nx&&nx < n && 0 <= ny&&ny < n&&s[nx][ny] == ' ') {
				if (!(0 <= kx&&kx < n && 0 <= ky&&ky < n&&s[kx][ky] == '#') && !(0 <= jx&&jx < n && 0 <= jy&&jy < n&&s[jx][jy] == '#')) {
					s[nx][ny] = '#';
					que.push({ nx,ny,idx });
					continue;
				}
			}
			idx = (idx + 1) % 4;
			nx = x + dx[idx]; ny = y + dy[idx];
			kx = nx + dx[idx]; ky = ny + dy[idx];
			jx = nx + dx[(idx + 1) % 4]; jy = ny + dy[(idx + 1) % 4];
			if (0 <= nx&&nx < n && 0 <= ny&&ny < n&&s[nx][ny] == ' ') {
				if (!(0 <= kx&&kx < n && 0 <= ky&&ky < n&&s[kx][ky] == '#') && !(0 <= jx&&jx < n && 0 <= jy&&jy < n&&s[jx][jy] == '#')) {
					s[nx][ny] = '#';
					que.push({ nx,ny,idx });
				}
			}
		}
		rep(j, n)printf("%s\n", s[j]);
		if (i != d - 1)printf("\n");
	}
}

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

int main() {
  int x;
  cin >> x;
  int ans = 10 - (x / 200);
  cout << ans << endl;
}


Measured memory_bytes: 3620
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll n, d, a;
    cin >> n >> d >> a;
    pll arr[n];
    ll soma[n];
    memset(soma, 0, sizeof soma);
    for(int i = 0; i < n; i++) {
        cin >> arr[i].F >> arr[i].S;
    }
    sort(arr, arr + n);
    ll leva = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        arr[i].S -= leva;
        arr[i].S += soma[i];
        leva -= soma[i];
        if(arr[i].S <= 0) continue;
        ll qtd = (arr[i].S + a - 1) / a;
        ans += qtd;
        leva += qtd * a;
        int l = i;
        int r = n-1;
        int sub = n;
        while(l <= r) {
            int mid = (l+r)>>1;
            if(arr[mid].F <= arr[i].F + 2 * d) {
                l = mid+1;
            }else {
                sub = mid;
                r = mid-1;
            }
        }
        if(sub == n) continue;
        soma[sub] += qtd * a;
    }
    cout << ans << endl;
}

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

int main(){
  
  int n;
  cin>>n;
  long long a[n],b[n] ;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  int key1=b[n/2-1],key2=b[n/2];
  for(int i=0;i<n;i++){
    if(a[i]<=key1) cout<<key2<<endl;
    else cout<<key1<<endl;
  }
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <iomanip>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  rep(i, N) {
    vector<ll> c(9);
    rep(i, 9) cin >> hex >> c[i];

    ll K = 0;
    rep(i, 32) {
      ll sum = 0;
      rep(j, 8) {
        sum += c[j] ^ K;
      }
      
      if((sum >> i & 1) != ((c[8] ^ K) >> i & 1)) {
        K += 1LL << i;
      }
    }
    cout << hex << K << endl;
  }
  
  return 0;
}

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

int max(  int x,int y, int z)
{
    return max( x, max(y,z));
}

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

    int a[n+1],b[n+1],c[n+1];

    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];


    a[0]=0;
    b[0]=0;
    c[0]=0;
    int dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;

    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];

    dp[2][0]= a[2] + max( dp[1][1],dp[1][2]);
    dp[2][1]= b[2] + max( dp[1][0],dp[1][2]);
    dp[2][2]= c[2] + max( dp[1][0], dp[1][1]);

    for(int i=3;i<=n;i++)
    {
        dp[i][0] = a[i]+ max( dp[i-1][1], dp[i-1][2]);


        dp[i][1] = b[i]+ max( dp[i-1][0], dp[i-1][2]);

        dp[i][2] = c[i]+ max( dp[i-1][0], dp[i-1][1]);


    }


    cout<<max( dp[n][0], dp[n][1],dp[n][2]);
}





Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s; cin >> s;
    int flag = 1;
    if(n % 2)flag = 0;
    n /= 2;
    rep(i,n)if(s[i+n] != s[i])flag = 0;
    if(flag)yn;
    return 0;
}
 
 


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

const int INF = 10000000;

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  int res = INF;

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

    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ++count;
    }

    if (res > count) res = count;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3588