akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

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

    if ((A + B) > 16) {
        printf(":(\n");
    } else {
        int lastPiece = 0;
        int i = 0;
        int add = 0;
        while (i < 16) {
            add = 1;
            if (A > 0 && lastPiece != 1) {
                A--;
                i++;
                lastPiece = 1;
                add = 0;
            }
            if (B > 0 && lastPiece != 2) {
                B--;
                i++;
                lastPiece = 2;
                add = 0;
            }

            if (add == 1) {
                i++;
                lastPiece = 0;
            }
        }

        printf("%s\n", A > 0 || B > 0 ? ":(" : "Yay!");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

map<ll,ll> mp[15][130][3];

void solve(int& sm,ll& mul,string& s)
{
    sm = 0,mul = 1;
    rep(i,len(s)){
        sm += (s[i]-'0');
        mul *= (s[i]-'0')+1;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int keta = len(s);
    int sm;
    ll mul;
    solve(sm,mul,s);
    mp[0][0][0][1] = 1;
    rep(i,keta){
        rep(j,sm+1){
            each(it,mp[i][j][0]){
                rep(k,min(sm+1-j,10)){
                    if(k < s[i]-'0'){
                        mp[i+1][j+k][1][it.fi*(k+1)] += it.se;
                    }else if(k == s[i]-'0'){
                        mp[i+1][j+k][0][it.fi*(k+1)] += it.se;
                    }else{
                        mp[i+1][j+k][2][it.fi*(k+1)] += it.se;
                    }
                }
            }
            srep(k,1,3){
                each(it,mp[i][j][k]){
                    rep(l,min(sm+1-j,10)){
                        mp[i+1][j+l][k][it.fi*(l+1)] += it.se;
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i,sm){
        rep(j,3){
            each(it,mp[keta][i][j]){
                ans += it.se;
            }
        }
    }
    rep(i,3){
        each(it,mp[keta][sm][i]){
            if(it.fi >= mul){
                break;
            }
            ans += it.se;
        }
    }
    ans += mp[keta][sm][1][mul];
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 55496
#include <bits/stdc++.h>
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 fi first
#define sc second
#define rep(i,x) for(int i=0;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())
#define mod 1000000007
int a,b,c,x[100005][3];
int p[100005];
bool comp1(const int&q,const int&w){
	return x[q][0]-x[q][1] > x[w][0]-x[w][1];
}
priority_queue<int>U,D;
ll sumu[100005],sumd[100005];
int main(){
	cin >> a >> b >> c;
	for(int i=0;i<a+b+c;i++){
		cin>>x[i][0]>>x[i][1]>>x[i][2];
		p[i]=i;
	}
	sort(p,p+a+b+c,comp1);
	ll S = 0;
	for(int j=0;j<a+b+c;j++){
	    int i = p[j];
		U.push(x[i][2]-x[i][0]); S+=x[i][0]-x[i][2];
		if(U.size() > a){
			S += U.top(); U.pop();
		}
		if(j<a-1) sumu[j] = -1e18;
		else{
			sumu[j] = S;
		}
	}
	S = 0;
	for(int j=a+b+c-1;j>=0;j--){
	    int i = p[j];
		D.push(x[i][2]-x[i][1]); S+=x[i][1]-x[i][2];
		if(D.size() > b){
			S += D.top(); D.pop();
		}
		if(D.size()<b) sumd[j] = -1e18;
		else{
			sumd[j] = S;
		}
	}
	ll ret = -1e18;
	for(int i=1;i<a+b+c;i++){
		ret = max(ret,sumu[i-1]+sumd[i]);
	}
	for(int i=0;i<a+b+c;i++) ret += x[i][2];
	cout << ret << endl;
}

Measured memory_bytes: 3852
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  int count = 0;
  for(int i = 0; i < m; i++){
    bool all = true;
    for(int j = 0; j < n; j++){
      bool exist = false;
      for(int l = 0; l < k[j]; l++){
        if(a[j][l] == (i + 1)){
          exist = true;
          break;
        }
      }
      if(!exist){
        all = false;
        break;
      }
    }
    if(all) ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,L;
  double moto;
  cin >> N >> L;
  
  moto = N*(2*L+N-1)/2;
    
  
  if(L>=0)
    cout << moto-L << endl;
  else if(L+N-1<=0)
    cout << moto-(L+N-1)<< endl;
  else{
    cout << moto << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string ans="No";
    
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n) ans="Yes";
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;

typedef vector< int > vi;

vi mat;
int N, L, idx;
string S;

vi press(vi a, vi b)
{
  for(int i = 0; i < N * N; i++) b[i] = a[b[i]];
  return (b);
}


vi fact(vi &v, int k)
{
  vi ret = mat;
  while(k > 0) {
    if(k & 1) ret = press(ret, v);
    v = press(v, v);
    k /= 2;
  }
  return (ret);
}

int num()
{
  int ret = 0;
  while(idx < S.size() && isdigit(S[idx])) {
    ret = ret * 10 + S[idx++] - '0';
  }
  return (ret);
}

vi sequence()
{
  if(idx == S.size() || S[idx] == ')') return (mat);
  vi ret = mat;
  if(S[idx] == '(') {
    ++idx;
    vi get = sequence();
    ++idx;
    ret = fact(get, num());
  } else if(S[idx] == 'L') {
    ++idx;
    int rep = num() - 1;
    for(int i = 0; i < N; i++) ret[rep * N + i] = rep * N + (i + 1) % N;
  } else if(S[idx] == 'R') {
    ++idx;
    int rep = num() - 1;
    for(int i = 0; i < N; i++) ret[rep * N + i] = rep * N + (i + N - 1) % N;
  } else if(S[idx] == 'U') {
    ++idx;
    int rep = num() - 1;
    for(int i = 0; i < N; i++) ret[i * N + rep] = (i + 1) % N * N + rep;
  } else {
    ++idx;
    int rep = num() - 1;
    for(int i = 0; i < N; i++) ret[i * N + rep] = (i + N - 1) % N * N + rep;
  }
  return (press(ret, sequence()));
}

int main()
{
  cin >> N >> L;
  cin >> S;

  mat.resize(N * N);
  iota(begin(mat), end(mat), 0);
  auto ret = sequence();

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(j > 0) cout << " ";
      cout << ret[i * N + j] + 1;
    }
    cout << endl;
  }
}

Measured memory_bytes: 16040
# -*- coding: utf-8 -*-
import sys
import fractions

def lcm(a,b):
    return a / fractions.gcd(a,b) * b

for s in sys.stdin:
    a,b = map(int,s.split())
    gcd_ab = fractions.gcd(a,b)
    lcm_ab = lcm(a,b)

    print gcd_ab,lcm_ab

Measured memory_bytes: 5880
import java.util.Scanner;

abstract class Main {

	public static void main(String[] args) {

		// 標準入力
		Scanner sc = new Scanner(System.in);

		// char型に変換
		String words = sc.nextLine();
		char ch[] = words.toCharArray();

		// char型の数だけ回す
		for (int i = 0; i < ch.length; i++) {

			//
			if (Character.isUpperCase(ch[i])) {
				ch[i] = Character.toLowerCase(ch[i]);
			} else {
				ch[i] = Character.toUpperCase(ch[i]);
			}
		}

		for (char chage : ch) {
			System.out.print(chage);
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 17372
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    long current = 1, count;
    foreach(e; a)
    {
        if(e == current)
            current++;
        else
            count++;
    }
    if(current == 1 && count > 0)
        writeln(-1);
    else
        writeln(count);
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 11664
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    ll sum = 0;
    for (int i = 0; i < N; i++) sum += A[i] * (i % 2 == 0 ? 1 : -1);
    vector<ll> res(N);
    res[0] = sum / 2;
    for (int i = 1; i < N; i++) {
      res[i] = A[i - 1] - res[i - 1];
    }
    for (ll x : res) cout << 2 * x << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long int k, x,s,b;
	cin >> k >> x;
	s = x - k + 1;
	b = x + k - 1;
	for (long long int i = s; i <= b; i++) {
		cout << i << " ";
	} 

}

Measured memory_bytes: 256
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	ll int n,i,k,s=1;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>k;
		if(s == k)
		{
			s++;
		}
	}
	if(s == 1)	cout<<-1;
	else
	cout<<n-s+1;
	return 0;
}

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

def main():
    ans = 0
    if k!= 0:
        for b in range(k+1,n+1):
            for q in range((n-k)//b+1):
                ans += min(b-k,n-b*q-k+1)
        print(ans)
        return
    else:
        print(n*n)
        return

if __name__ == "__main__":
    main()

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

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

  if (a!=b && b==c) cout << a << endl;
  else if (a==b && b!=c) cout << c << endl;
  else cout << b << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n, x; cin >> n >> x;

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

    sort(a, a+n);

    int cnt = 0;
    for(int i=0; i<n; i++){
        if(a[i] <= x){
            x -= a[i];
            cnt++;
        }
    }

    if(x > 0 && cnt == n){
        cnt--;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
show_flg=True


n=I()
for i in range(int(n**0.5),0,-1):
    if n%i==0:
        a,b=i,n//i
        break


print(a+b-2)


Measured memory_bytes: 40552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> h(n+1);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  int cnt=0;
  bool flag=true;;
  while(flag){
    flag=false;
    for(int i=0;i<n;i++){
      if(h[i]!=0){
        h[i]--;
        if(h[i+1]==0){
          cnt++;
        }
        flag=true;
      }
    }
  }
  cout << cnt << endl;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

ll D;

ll Es[20];

PLL calc(int n,int f){
	int m=n/2;
	ll bas=(Es[n-m]-1)*(Es[m]-1);
	if(f)return MP(-bas,bas-Es[n-1]+Es[m-1]);else return MP(-bas,bas);
}

ll dfs(int tot,int now,ll lft){
	if(now<=tot-now+1){
		if(lft)return 0;
		else if(tot&1)return 10;else return 1;
	}
	PLL inter=calc(now-(tot-now),now==tot);
	if(lft<inter.fi*Es[tot-now]||lft>inter.se*Es[tot-now])return 0;
	ll ans=0,bas=Es[now-1]-Es[tot-now];
	REP(i,-9,9){
		int can=min(i+9,9)-max(i,(int)(now==tot))+1;
		if(can)ans+=dfs(tot,now-1,lft+bas*i)*can;
	}
	return ans;
}

void Work(){
	ll ans=0;
	REP(i,1,18)ans+=dfs(i,i,D);
	cout<<ans<<endl;
}

void Init(){
	Es[0]=1;REP(i,1,18)Es[i]=Es[i-1]*10;
	read(D);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 256
s=input()
t="abcdefghijklmnopqrstuvwxyz"
if s==t[::-1]:
  print(-1)
  exit(0)
if len(s)<26:
  for ti in t:
    if not ti in s:
      print(s+ti)
      exit(0)
else:
  for i in range(25):
    if s[-i-2]<s[-1-i]:
      t=s[:-i-2]
      u=sorted(list(s[-i-2:]))
      print(t+u[u.index(s[-2-i])+1])
      exit(0)


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(6,[["khabarovsk",-20, 1], ["moscow",-10, 2], ["kazan",-50, 3], ["kazan",-35, 4], ["moscow",-60, 5], ["khabarovsk",-40, 6]])
    3
    4
    6
    1
    5
    2
    >>> print_ans(10, [["yakutsk", -10, 1 ], ["yakutsk", -20, 2 ], ["yakutsk", -30, 3 ], ["yakutsk", -40, 4 ], ["yakutsk", -50, 5 ], ["yakutsk", -60, 6 ], ["yakutsk", -70, 7 ], ["yakutsk", -80, 8 ], ["yakutsk", -90, 9 ], ["yakutsk", -100,10]])
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    """
    ans = sorted(ar)
    for a in ans:
        print(a[2])

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = []
    for i in range(N):
        s, p = input().rstrip().split()
        p = int(p)
        ar.append([s, -p, i + 1])
    print_ans(N, ar)




Measured memory_bytes: 12468
n = gets.to_i

d = 1
while n > 26**d
  n -= 26**d
  d += 1
end

n -= 1
s = Array.new(d, 0)
for i in 0..(d-1)
  idx = d-1-i
  s[i] = n / (26**idx)
  n -= (26**idx)*s[i]
end

s.each do |cn|
  print (("a").ord+cn).chr
end
puts ""

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ( A + B == C + D ){
    cout << "Balanced" << endl;
  }
  else if ( A + B > C + D){
    cout << "Left" << endl;
  }
  else if ( A + B < C + D){
    cout << "Right" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C,X,Y,ans=0,temp=0;
  cin >>A>>B>>C>>X>>Y;
  X*=2,Y*=2;
  //全てABピザ
  long long Z=max(X,Y);
  ans=Z*C;
  //X<YでAをすべてABピザ
  if(X<Y){
    temp+=X*C;
    temp+=(Y-X)/2*B;
    if((Y-X)%2!=0) temp+=B;
    ans=min(ans,temp);
  }
  else{
    temp+=Y*C;
    temp+=(X-Y)/2*A;
    if((X-Y)%2!=0) temp+=A;
    ans=min(ans,temp);
  }
  //すべてAorBピザ
  temp=X/2*A+Y/2*B;
  if(X%2!=0) temp+=A;
  if(X%2!=0) temp+=B;
  ans=min(ans,temp);
  if(X%2!=0) temp-=A;
  if(X%2!=0) temp-=B;
  temp+=C;
  ans=min(ans,temp);
  cout <<ans <<endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
using namespace std;
using ll = long long;
using ld = long double;
const int mod = 1e9+7;
const int mxn = 3e6+6;
char s[mxn];
ll fact[mxn], inverse_fact[mxn];

ll fpow(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b&1ll) ans*=a, ans%=mod;
		a*=a; a%=mod;
		b/=2;
	}
	return ans;
}

void build() {
	fact[0] = inverse_fact[0] = 1;
	for(int i=1; i<mxn; i++) {
		fact[i] = fact[i-1]*i%mod;
		inverse_fact[i] = fpow(fact[i], mod-2);
	}
}

ll C(ll n, ll r) {
	assert(n>=r);
	return fact[n]*inverse_fact[r]%mod*inverse_fact[n-r]%mod;
}

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

	build();
	ll k; cin>>k>>s;
	ll n = strlen(s);


	ll ans = 0;
	for(ll i=n; i<=n+k; i++) {
		ll tmp = C(i-1, n-1);
		tmp*=fpow(25, i-n); tmp%=mod;
		tmp*=fpow(26, n+k-i); tmp%=mod;
		ans+=tmp; ans%=mod;
	}

	cout << ans << '\n';


	return 0;
}

Measured memory_bytes: 50988
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if ((x >= r && (x + r) <= W) && (y >= r && (y + r) <= H)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26228
#include <cstdio>
#include <algorithm>

using namespace std;

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n, a, b;
    scanf ("%d %d %d", &n, &a, &b);

    if ((b - a) & 1) printf ("Borys\n");
    else printf ("Alice\n");

    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
h = list(map(int,input().split()))
count = [0 for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    count[b-1] = count[b-1] + 1
  elif h[a-1] < h[b-1]:
    count[a-1] = count[a-1] + 1
  else:
    count[a-1] = count[a-1] + 1
    count[b-1] = count[b-1] + 1
sum = 0
for i in range(n):
  if count[i] == 0:
    sum = sum + 1
print(sum)


Measured memory_bytes: 20136
#include <stdio.h>
#define MAX 1000

int getLargestSquare(int, char G[MAX][MAX]);

main(){
  int size, i, j;
  char map[MAX][MAX];

  while(1){
    scanf("%d", &size);
    if(size==0) break;

    getchar();
    for(i=0;i<size;i++){
      for(j=0;j<size;j++){
	scanf("%c", &map[i][j]);
      }
      getchar();
    }

    printf("%d\n", getLargestSquare(size,map));
  }
  return 0;
}

int getLargestSquare(int size, char G[MAX][MAX]){
  int W[MAX][MAX];
  int i, j, maxWidth, min;

  for(i=0;i<size;i++){
    if(G[0][i]=='*') W[0][i]=0;
    else W[0][i]=1;
    if(G[i][0]=='*') W[i][0]=0;
    else W[i][0]=1;
  }

  maxWidth=0;
  for(i=1;i<size;i++){
    for(j=1;j<size;j++){
      if(G[i][j]=='*'){
	W[i][j]=0;
      }
      else{
	if(W[i-1][j-1]<=W[i-1][j] && W[i-1][j-1]<=W[i][j-1]){
	  W[i][j]=W[i-1][j-1]+1;
	}
	else if(W[i-1][j]<=W[i-1][j-1] && W[i-1][j]<=W[i][j-1]){
	  W[i][j]=W[i-1][j]+1;
	}
	else W[i][j]=W[i][j-1]+1;
	if(maxWidth<W[i][j]) maxWidth=W[i][j];     
      }
    }
  }
  return maxWidth;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  cout << (n+1)*n/2 << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n;

	cin>> n;

	if(n==111) cout<< "999" << endl;
	if(n==119) cout<< "991" << endl;
	if(n==191) cout<< "919" << endl;
	if(n==199) cout<< "911" << endl;
	if(n==911) cout<< "199" << endl;
	if(n==919) cout<< "191" << endl;
	if(n==991) cout<< "119" << endl;
	if(n==999) cout<< "111" << endl;


}

Measured memory_bytes: 256
h,w = sorted(list(map(int,input().split())))
if h % 3 == 0 or w % 3 == 0:
  ans = 0
else:
  c1 = ((w//3+1)*h)-((w-1-w//3)*(h//2))
  c2 = ((w-w//3)*(h-h//2))-(w//3*h)
  c3 = h
  c4 = ((h//3+1)*w)-((h-1-h//3)*(w//2))
  c5 = ((h-h//3)*(w-w//2))-(h//3*w)
  ans = min(c1,c2,c3,c4,c5)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  char a,b;
  cin >> a >> b;
  if(a=='H' && b=='H') cout << 'H' << endl;
  if(a=='H' && b=='D') cout << 'D' << endl;
  if(a=='D' && b=='H') cout << 'D' << endl;
  if(a=='D' && b=='D') cout << 'H' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=1e5+5;
int n,k,a[N];
ll f[N],invf[N];
ll C(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main()
{
    f[0]=invf[0]=invf[1]=1;
    for(int i=1;i<N;i++)
        f[i]=f[i-1]*i%mod;
    for(int i=2;i<N;i++)
        invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++)
        invf[i]=invf[i]*invf[i-1]%mod;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(n-i>=k-1)
        ans=(ans-a[i]*C(n-i,k-1)%mod)%mod;
    for(int i=n;i>=1;i--)
        if(i-1>=k-1)
        ans=(ans+a[i]*C(i-1,k-1)%mod)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 2176
n, k = [int(i) for i in input().split()]
cnt = [0] * int(10e5)
for i in range(n):
    a, b = [int(i) for i in input().split()]
    cnt[a] += b

for i in range(1, len(cnt)):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]


Measured memory_bytes: 12860
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int N, K;
const int maxn = 3e5 + 5;
int d[maxn], tot;

int main(){
    cin >> K >> N;
    if(K % 2){
        long long now = 0;
        int i;
        for(i = 1;i <= N;i++){
            now = now * K + 1;
            if(now > (N - i)){
                break;
            }
        }
        //cout << i << endl;
        for(int j = N;j >= i;j--){
            d[++tot] = (K + 1) / 2;
        }
        long long diff = (now - (N - i) + 1) / 2;
        //cout << diff << " " << now << endl;
        //cout << diff << " " << now << endl;
        while(diff > 0){
            diff--;
            if(diff == 0){
                break;
            }
            now = now / K;
            for(int digit = 1;digit <= K;digit++){
                if(1LL * now * digit >= diff){
                    d[++tot] = digit;
                    diff -= now * (digit - 1);
                    break;
                }
            }
        }
        for(int i = 1;i <= tot;i++){
            printf("%d%c", d[i], i == tot ? '\n' : ' ');
        }
    }else{
        for(int i = 1;i <= N;i++){
            if(i == 1){
                printf("%d", K / 2);
            }else{
                printf("%d", K);
            }
            printf("%c", i == N ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 3456
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	int L;
	int res = 0;
	int res1 = 0;

	for (int i = 0; i < N; i++) {
		cin >> L;
			res1 += L;
			res = max(res, L);
	}

	res1 = res1 - res;
	
	if (res1 <= res) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int p[1<<17],s,i,n;
main(){for(i=2;i<1<<17;i++)for(s=2;!p[i]&&i*s<1<<17;p[i*s++]++);for(;scanf("%d",&n),n;printf("%d\n",s))for(i=2,s=0;(!p[i])?s+=i,n--:n,n;i++);}

Measured memory_bytes: 0
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

cost = [[0] * C for _ in range(3)]
for p in range(C):
    for i in range(N):
        for j in range(N):
            #グループごとにかかるコストの計算
            cost[(i+j)%3][p] += D[c[i][j]][p]

res = 10 ** 9
p = [0] * 3
for p[0] in range(C):
    for p[1] in range(C):
        if p[0] == p[1]:
            continue
        for p[2] in range(C):
            if p[2] == p[0] or p[1] == p[2]:
                continue
            tmp = 0
            for i in range(3):
                tmp += cost[i][p[i]]
            res = min(res, tmp)

print(res)
                


Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int count, A, B;
  cin >> A >> B;
  count = 0;
  int one, ten, hundred, thousand, ten_thousand;
  
  for ( int i = A ; i <= B ; i++ )
  {
    one = i % 10;
    ten = ( i % 100 - one ) / 10;
    hundred = ( i % 1000 - one - 10*ten ) / 100;
    thousand = ( i % 10000 - one - 10*ten - 100*hundred ) / 1000;
    ten_thousand = ( i - 1000*thousand - 100*hundred - 10*ten - one) / 10000;
    //cout << one << endl << ten << endl << hundred << endl << thousand << endl << ten_thousand << endl;
    if ( one != ten_thousand )
      continue;
    if ( ten != thousand )
      continue;
    
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int x = ni();
    int y = ni();
    int z = ni();

    System.out.println(z + " " + x + " " + y);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 38056
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type Point struct {
	x, y int
}

func distance(a, b Point) float64 {
	x := a.x - b.x
	y := a.y - b.y
	return math.Sqrt(float64(pow(x, 2) + pow(y, 2)))
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	ps := make([]Point, N)
	for i := 0; i < N; i++ {
		x := sc.nextInt()
		y := sc.nextInt()
		ps[i] = Point{x, y}
	}
	var sum float64 = 0
	seen := make([]bool, N)
	visitedPoints := []Point{}
	var search func(index int)
	search = func(index int) {
		visitAll := true
		for i := 0; i < N; i++ {
			if !seen[i] {
				visitAll = false
			}
		}
		if visitAll {
			for i := 0; i < N-1; i++ {
				sum += distance(visitedPoints[i], visitedPoints[i+1])
			}
			return
		}
		for i, _ := range ps {
			if seen[i] {
				continue
			}
			seen[i] = true
			visitedPoints = append(visitedPoints, ps[i])
			search(i)
			seen[i] = false
			visitedPoints = visitedPoints[0 : len(visitedPoints)-1]
		}
	}

	for i := 0; i < N; i++ {
		seen[i] = true
		visitedPoints = append(visitedPoints, ps[i])
		search(i)
		seen[i] = false
		visitedPoints = visitedPoints[0 : len(visitedPoints)-1]
	}
	var divisor float64 = 1
	for i := N; i > 0; i-- {
		divisor *= float64(i)
	}
	fmt.Println(sum / divisor)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int num=0;
    int count_a = 0;
    int count_b = 0;
    int count = 0;
    cin >> num;
    vector<int> number;
    vector<int> number2;    
    for(int i = 0; i < num; i++){
      number.push_back(i + 1);
    }
    number2=number;
    int a[num]={0};
    int b[num]={0};

    for(int i = 0; i < num; i++){
      int tmp;
      cin >> tmp;
      a[i] = tmp;
    }

    for(int i = 0; i < num; i++){
      int tmp;
      cin >> tmp;
      b[i] = tmp;
    }    

    do{
      count++;
      int flag = 0;
      for(int i = 0; i < num; i++){

        if(a[i] != number[i]){
          flag=-1;
        }
        
        if(i == num - 1 && flag == 0) count_a = count;
      }

    }while(next_permutation(number.begin(),number.end()));

    count = 0;

    do{
      count++;
      int flag = 0;
      for(int i = 0; i < num; i++){

        if(b[i] != number2[i]){
          flag = -1;
        }

        if(i == num - 1 && flag == 0) count_b = count;
      }
      
    }while(next_permutation(number2.begin(),number2.end()));
    
cout << abs(count_a -count_b) <<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,k,n,m,a[10],sum,s,len,pi;
    while(scanf("%d%d",&n,&m)==2)
    {
        sum=0;
        for(k=n;k<=m;k++)
        {
            s=k,len=0,pi=1;
            while(s)
            {
                a[len++]=s%10;
                s=s/10;
            }
            for(i=0,j=len-1;i<len/2;i++,j--)
            {
                if(a[i]!=a[j])
                {
                    pi=0;
                    break;
                }
            }
            if(pi==1)
                sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

int main(){
int n,d,x;
cin >> n >> d >> x;
vector<int>a(n);
int eat =0;
for(int i=0;i<n;i++){
    cin >> a.at(i);
    eat++;
    int j =1;
    while(j<=d){
    if(d>=a.at(i)*j+1){
        eat++;
    }
    else{
        break;
    }
    j++;
    }
    
}
cout << eat+x << endl;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<vector<char>> ban(305,vector<char>(305));

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    string S;cin >> S;
    vector<int> black(N+1);
    vector<int> white(N+1);
    //白は前から累積和
    for(int i = 0;i<N;i++){
        white.at(i+1) += white.at(i);
        if(S.at(i) == '.') white.at(i+1)++;
    }
    //黒は後ろから累積和
    for(int i = N;i>0;i--){
        black.at(i-1) += black.at(i);
        if(S.at(i-1) == '#') black.at(i-1)++;
    }
    int ans = 100100100;
    for(int i = 0;i<=N;i++){
        int white_count = i;
        int needto_change = white_count-white.at(i);
        needto_change += N-white_count-black.at(i);
        //cout << white_count << " " << needto_change << endl;
        ans = min(ans,needto_change);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int x = 0;
    rep(i,n){
        if(s[i] == 'I')x++;
        if(s[i] == 'D')x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

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

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl;

char change(char k){
  if(k=='A'){return 'a';}
  if(k=='B'){return 'b';}
  if(k=='C'){return 'c';}

  return k;
}

//----------------------------------------------------------------
int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k-1] = change(s[k-1]);

  prt(s);


}


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

struct Position {
    int id = 0;
    int distance = 0;
};

bool id_sort(const Position &a, const Position &b) {
    return (a.id < b.id);
}

bool distance_sort(const Position &a, const Position &b) {
    return (a.distance > b.distance);
}

int main() {
    int n, m;
    int ans = 0;
    int count = 0;
    int l = -1, r = -1;
    
    cin >> n >> m;
    vector<Position> pos(m);
    vector<int> start(n);
    
    for (int i = 0; i < m; i++) {
        cin >> pos[i].id;
    }
    
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    
    sort(pos.begin(), pos.end(), id_sort);
    start[0] = pos[0].id;
    
    for (int i = 1; i < m; i++) {
        pos[i].distance = pos[i].id - pos[i - 1].id;
    }
    
    sort(pos.begin(), pos.end(), distance_sort);
    
    for (int i = 0; i < (n - 1); i++) {
        if (pos[i].id != start[0]) {
            start[i + 1] = pos[i].id;
        }
    }
    
    sort(pos.begin(), pos.end(), id_sort);
    sort(start.begin(), start.end());
    
    for (int i = 0; i < m; i++) {
        if ((count < n) && (start[count] == pos[i].id)) {
            if (count > 0) {
                ans += r - l;
            }
            
            count++;
            l = pos[i].id;
        }
        
        r = pos[i].id;
        
        if (i == (m - 1)) {
            ans += r - l;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){
    
    ll N, M;
    cin >> N >> M;
    V v(N + 1, 0);
    ll a = 0, b = 0;
    rep(i, M){
        ll p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            if(v[p] >= 0){
                a++;
                b += v[p];
                v[p] = -1;
            }
        }
        else{
            if(v[p] >= 0)v[p]++;
        }
    }
    cout << a << " " << b << endl;
        
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
vll d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sortc(string &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  ll n;
  cin >> n;
  vs s(n);
  for (ll i = 0; i < n; i++) cin >> s[i];
  sorts(s);
  vector<pair<ll, string>> ans(0);
  for (ll i = 0; i < n; i++) {
    ll cnt = 0;
    string t = s[i];
    while (t == s[i]) {
      cnt++;
      i++;
      if (i == n) break;
    }
    i--;
    pair<ll, string> x = make_pair(cnt, t);
    ans.push_back(x);
  }
  sort(ans.begin(), ans.end());
  vs ans2(0);
  ll m = ans.size() - 1;
  while (ans[ans.size() - 1].first == ans[m].first) {
    ans2.push_back(ans[m].second);
    m--;
  }
  for (ll i = 0; i < ans2.size(); i++) {
    cout << ans2[ans2.size() - 1 - i] << endl;
  }
}

Measured memory_bytes: 21872