akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-6;
 
#define INT_MAX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define vec vector
#define __ <<' '<<
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define N 500010

int seg[4*N], mxn;

void modify(int x, char c){
    x += mxn - 1;
    seg[x] = (1 << (c - 'a'));
    while(x > 1){
        x >>= 1;
        seg[x] = seg[x*2] | seg[x*2+1];
    }
}

int query(int l, int r, int lb, int rb, int idx){
    if(l <= lb && rb <= r) return seg[idx];
    
    int mid = (lb + rb) / 2, res = 0;
    
    if(mid >= l) res |= query(l, r, lb, mid, idx*2);
    if(mid <  r) res |= query(l, r, mid+1, rb, idx*2+1);
    return res;
}

void solve(){
    int n, m, l, r, idx, type;
    char c;
    string s;
    
    cin >> n >> s >> m;
    
    mxn = 1;
    while(mxn < n)  mxn <<= 1;
    
    rep(i, n) modify(i+1, s[i]);
    
    while(m--){
        cin >> type;
        if(type == 1){
            cin >> idx >> c;
            modify(idx, c);
        } else {
            cin >> l >> r;
            cout << __builtin_popcount(query(l, r, 1, mxn, 1)) << '\n';
        }
    }
}

int main() {
    int T = 1;
    
    //cin >> T;
    while(T--){
        solve();
    }
}


Measured memory_bytes: 4996
#include <stdio.h>
int main(){
	int max=0,a,i=0;
	double avg=0,b;
	while(scanf("%d,%lf",&a,&b)!=EOF){
		max+=a*(int)b;
		avg+=b;
		i++;
	}
	avg/=(double)i;
	printf("%d\n%d\n",max,(int)(avg+0.50));
	return 0;
}

Measured memory_bytes: 1052
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

ll d[201][201];

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r;

    REP(i,R){
        int tmp;
        cin >> tmp;
        r.push_back(tmp);
    }
    
    sort(r.begin(),r.end());

    REP(i,N+1)REP(j,N+1)d[i][j] = INF;

    REP(i,M){
        int a,b,c;
        cin >> a >> b >>c;
        d[a][b] = c;
        d[b][a] = c;
    }


    REP(i,N+1)REP(j,N+1)REP(k,N+1){
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    }

    ll ans = INF;
    do {
        ll tmp = 0;
        REP(i,R-1){
            tmp += d[r[i]][r[i+1]];
        }
        ans = min(ans,tmp);
    } while (std::next_permutation(r.begin(), r.end()));

    cout << ans << endl;

}

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

using namespace std;

static const int NMAX = 2*1e5+5;
static const int MOD = 2019;


typedef long long ll;

int main()
{
    string s;
    cin >> s;


    map<int,int> mp;
    ll ans = 0;

    int n = (int)s.length();
    int t = 0, p = 1;
    mp[0]++;
    for(int i = n-1; i>= 0; i--)
    {
        t=(t+(s[i]-'0')*p)%MOD;
        ans+=mp[t];
        mp[t]++;
        p = p * 10 % MOD;
    }
	cout << ans;
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<pair<ll,ll>> A(N);
  rep(i, N){
    ll a,b; cin >>a >>b; A[i] = {a+b, a};
  }
  sort(all(A));
  ll res = 0;
  int ai = 0, bi = N-1;
  for (int i=0; i<N; i++){
    if (i%2==0) res += A[bi--].second;
    else res -= A[bi].first - A[bi--].second;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 1792
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    A = tuple(MI())
    B = tuple(MI())
    D = [A[i] - B[i] for i in range(N)]
    if sum(D) < 0: return -1

    md = tuple(filter(lambda d:d < 0, D))
    d = sum(md)
    if d == 0: return 0
    D = sorted(D, reverse=True)
    for i in range(N):
        d += D[i]
        if d >= 0: return len(md) + i + 1
    return -1


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 18524
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
vector<int> V, C;

int main() {
  cin >> N;
  V.resize(N);
  C.resize(N);
  for (int i = 0; i < N; i++)
    cin >> V[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];

  int res = 0;
  for (int i = 0; i < N; i++)
    if (V[i] - C[i] > 0)
      res += V[i] - C[i];
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int ss;
	cin >> ss;
	string s;
	cin >> s;
	if(ss%2){
		cout << "No" << endl;return 0;
	}
	int l = ss/2;
	char t[100],v[100];
	LOOP(i,l){
		if(s[i] != s[i+l]){cout << "No" << endl;return 0;}
	}
	cout << "Yes";
	cout << endl; return 0;
}


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

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

  vector<pair<int, int> > p(n);
  for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;

  vector<pair<int, int> > q(m);
  for (int i = 0; i < m; i++) cin >> q[i].first >> q[i].second;

  for (int i = 0; i < n; i++) {
    int d = 400000000, k = -1;
    for (int j = 0; j < m; j++) {
      if (d > abs(p[i].first - q[j].first) + abs(p[i].second - q[j].second)) {
        d = abs(p[i].first - q[j].first) + abs(p[i].second - q[j].second);
        k = j + 1;
      }
    }
    cout << k << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, M;
  cin >> N >> M;
  vector <int> ac(N), pena(N);
  rep(i,M){
    int p;
    string s;
    cin >> p >> s;
    p--;  //0-indexedに直す
    if (ac[p]) continue;
    if (s == "AC"){
      ac[p] = 1;
    }else{
      pena[p] ++;
    }
  }
  int AC = accumulate(ac.begin(), ac.end(), 0);
  int PENA = 0;
  rep(i,N){
    if (ac[i]) PENA += pena[i];
  }
  cout << AC << " " << PENA << endl;
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using std::cin;
using std::cout;
const int Maxn = 2e7 + 5, Mod = 998244353;
typedef long long ll;
typedef ll arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, m;
arr fac, inv, invfac;
ll ans;
ll qp(ll x, int y)
{
	ll res = 1;
	while (y)
	{
		if (y & 1)
			res = res * x % Mod;
		x = x * x % Mod;
		res >>= 1;
	}
	return res;
}
ll C(int x, int y) { return fac[x] * invfac[y] % Mod * invfac[x - y] % Mod; }
int main()
{
	fac[0] = inv[1] = invfac[0] = 1;
	for (rg int i = 1; i <= 20000000; i++)
	{
		fac[i] = fac[i - 1] * i % Mod;
		if (i > 1)
			inv[i] = (Mod - Mod / i) * inv[Mod % i] % Mod;
		invfac[i] = invfac[i - 1] * inv[i] % Mod;
	}
	rg int tmp;
	cin >> n >> m;
	ans = 1;
	for (rg int i = 1; i < n; i++)
		ans = ans * (3 * m + i) % Mod;
	ans = ans * invfac[n - 1] % Mod;
	ans = Add(ans, -(n * C(m - 1 + n - 1, n - 1) % Mod));
	if (n > m)
	{
		tmp = min(3 * m, n);
		for (rg int i = m + 2; i <= tmp; i += 2)
			ans = Add(ans, -(C(n, i) * C((3 * m - i) / 2 + n - 1, n - 1) % Mod));
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll H[105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> H[i];
    }

    ll ans = 0;
    while (true) {
        bool update = false;
        REP(i, N) {
            if (H[i] > 0) {
                update = true;
                H[i]--;
                if (H[i + 1] == 0)
                    ans++;
            }
        }
        if (!update)
            break;
    }
    cout << ans << endl;
    return 0;
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<int> cnt(26);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (auto c : a[i])
      cnt[c - 'a']++;
  }
  int p = 0;
  if (n % 2 && m % 2) {
    int x = 0;
    while (cnt[x] % 2 == 0)
      ++x;
    --cnt[x];
    p = n / 2 + m / 2;
  } else if (n % 2) {
    p = m / 2;
  } else if (m % 2) {
    p = n / 2;
  }
  int k = 0;
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] % 2) {
      cout << "No\n";
      return 0;
    }
    if (cnt[i] % 4) {
      if (++k > p) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  ll N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
    A[i]--;
  }
  vector<ll> path;
  vector<bool> done(N, false);
  ll cur = 0;
  path.push_back(0);
  done[0] = true;
  ll last = 0;
  REP(i, N) {
    ll next = A[cur];
    if (done[next]) {
      last = next;
      break;
    }
    path.push_back(next);
    done[next] = true;
    cur = next;
  }
  vector<ll> path2;
  REP(i, path.size()) {
    if (path2.size() > 0) {
      path2.push_back(path[i]);
    }
    if (path[i] == last) {
      path2.push_back(path[i]);
    }
  }
  if (K < path.size()) {
    cout << path[K] + 1 << endl;
    return 0;
  }
  K -= path.size() - path2.size();
  K %= path2.size();
  cout << path2[K] + 1 << endl;
  return 0;
}


Measured memory_bytes: 8732
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
int l[N],r[N];

int main()
{
    int n,i,j,k,x,t1,t2,s1,s2;
    long long ans;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d%d",&l[i],&r[i]);
    sort(l,l+n+1);
    sort(r,r+n+1);
    ans=0;
    for(i=0;i<n;i++)
    {
        if(l[n-i]<=r[i])
            break;
        ans=ans+l[n-i]-r[i];
    }
    printf("%lld\n",ans*2);
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

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

n=n%500;
if(n<=a){
	System.out.println("Yes");
}else{
	System.out.println("No");
}


}}

Measured memory_bytes: 21844
import sys
readline = sys.stdin.readline

S = readline().rstrip()
T = readline().rstrip()

if len(set(T) - set(S)) > 0:
  print(-1)
  exit(0)
  
import bisect
# Tの各文字を探す
S2 = S * 2
from collections import defaultdict
# ある文字が何文字目にあるか辞書
dic = defaultdict(list)

for i in range(len(S2)):
  dic[S2[i]] += [i]

ind = -1
ans = 0
for t in T:
  # 探す文字はt
  targets = dic[t]
#  print("targets",targets,"t",t,"ind + 1",ind + 1)
  newind = targets[bisect.bisect_left(targets, ind + 1)]
#  print("t",t,"S2",S2,"newind",newind)
  ans += (newind - ind)
  if newind >= len(S):
    newind -= len(S)
  ind = newind

print(ans)

Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
int p[100001],r[100001];
void init(){for(int i=0; i<100001; i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

int main() {
  init();
  int n,w,h;
  cin >> n >> w >> h;
  P a[n];
  for(int i=0; i<n; i++) cin >> a[i].F >> a[i].S;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      if(a[i].F==a[j].F||a[i].S==a[j].S) unite(i,j);
    }
  }
  set<int> s;
  for(int i=0; i<n; i++) s.insert(find(i));
  vector<int> v;
  for(set<int>::iterator it=s.begin(); it!=s.end(); it++) v.push_back(*it);
  int sum=n-s.size(),ans=1<<30;
  map<int,int> m[4];
  for(int i=0; i<v.size(); i++)for(int j=0; j<4; j++) m[j][v[i]]=1<<30;
  for(int i=0; i<n; i++) {
    m[0][find(i)]=min(m[0][find(i)],a[i].F-1);
    m[1][find(i)]=min(m[1][find(i)],a[i].S-1);
    m[2][find(i)]=min(m[2][find(i)],w-a[i].F);
    m[3][find(i)]=min(m[3][find(i)],h-a[i].S);
  }
  for(int i=0; i<4; i++) {
    int cnt=0;
    for(int j=0; j<v.size(); j++) {
      if(m[i][v[j]]) cnt++;
    }
    ans=min(ans,sum+cnt+(int)v.size()-1);
  }
  if(v.size()==1) ans=sum;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10172
#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 << "Right" << endl;
  else if ( A+B > C+D ) cout << "Left" << endl;
  else cout << "Balanced" << endl;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    int arr[h+1][w+1];
    int dp[h+1][w+1];
    char c;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>c;
            if(c=='.'){
                arr[i][j]=1;
            }
            else{
                arr[i][j]=0;
            }
        }
    }
   /* for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }*/
    for(int i=0;i<=w;i++){
        dp[0][i]=0;
    }
    for(int i=0;i<=h;i++){
        dp[i][0]=0;
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(arr[i][j]==1){
                if(i==1&&j==1)
                    dp[i][j]=1;
                else
                    dp[i][j]= (dp[i-1][j]+dp[i][j-1])%mod;
            }
            else{
                dp[i][j]=0;
            }
        }
    }
    cout<<dp[h][w];
    return 0;
}




Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

set<int> s;

void rec(int x)
{
	if(x > 4e9)
		return;
	s.insert(x);
	int last = x % 10;
	if(last - 1 >= 0)
		rec(x * 10 + last - 1);
	rec(x * 10 + last);
	if(last + 1 <= 9)
		rec(x * 10 + last + 1);
}

int32_t main()
{
	IOS;
	for(int i = 1; i <= 9; i++)
		rec(i);
	vector<int> v;
	for(auto &it:s)
		v.push_back(it);
	int n;
	cin >> n;
	cout << v[n - 1];
	return 0;
}

Measured memory_bytes: 6644
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

const int N=100005;

int n;
bool f[50][100005];

void dfs(int x,int y)
{
	if (x>45||f[x][y]) return;
	f[x][y]=1;
	for (int i=0;i<=9;i++) dfs(x+i,(y*10+i)%n);
}

int main()
{
	scanf("%d",&n);
	dfs(0,0);
	for (int i=1;i<=45;i++)
		if (f[i][0])
		{
			printf("%d",i);
			break;
		}
	return 0;
}

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

int main(void)
{
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int score = 0;

    queue<int> cmdBuf;
    string buffer = "";
    for (int i = 0; i < N; i++)
    {

        int command = 0;
        if (T[i] == 'r')
        {
            if(i < K){
                buffer.push_back('p');
                command = P;
            } else {
                if(buffer[i-K] != 'p'){
                    buffer.push_back('p');
                    command = P;
                } else {
                    buffer.push_back('x');
                }
            }
            
        }
        else if (T[i] == 's')
        {
            if(i < K){
                buffer.push_back('r');
                command = R;
            } else {
                if(buffer[i-K] != 'r'){
                    buffer.push_back('r');
                    command = R;
                } else {
                    buffer.push_back('x');
                }
            }
        }
        else
        {
            if(i < K){
                buffer.push_back('s');
                command = S;
            } else {
                if(buffer[i-K] != 's'){
                    buffer.push_back('s');
                    command = S;
                } else {
                    buffer.push_back('x');
                }
            }
        }
        score += command;
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 3932
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// main function
int main()
{
	ll i = 0;
	ll N = 0;

	cin >> N >> i;
	cout << N - i + 1 << endl;

	cin >> N;

	return 0;
}

Measured memory_bytes: 256
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()

n = a
i = 1
while True:
  n = a*i
  if n%b == 0:
    print(n)
    break
  i += 1

Measured memory_bytes: 39024
#include <iostream>
#include <iomanip>

int main()
{
    const double PI = 3.14159265359;

    double r;

    std::cin >> r;

    std::cout << std::fixed << std::setprecision(10);
    std::cout << r * r * PI << " " << 2 * r * PI << "\n";


    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int N;
vector<int> A;

bool increment(map<int, int> &m, int num, int limit) {
	int res = ++m[num];
	if (res == limit) {
		if (num == 1) return false;
		m.erase(num);
		return increment(m, num - 1, limit);
	}
	return true;
}

bool check(int num) {
	//cerr << "check " << num << endl;
	if (num == 1) {
		bool ok = true;
		REP(i, 1, N - 1) {
			if (A[i] <= A[i - 1]) {
				ok = false;
				break;
			}
		}
		return ok;
	}

	map<int, int> m;
	REP(i, 1, N - 1) {
		if (A[i] > A[i - 1]) {
			// do nothing
		} else if (A[i] == A[i - 1]) {
			if (!increment(m, A[i], num)) return false;
		} else { // A[i] < A[i - 1]
			if (!increment(m, A[i], num)) return false;
			auto it = m.upper_bound(A[i]);
			m.erase(it, m.end());
		}
		//cerr << " i=" << i << " -> ";
		//for (auto &pr : m) cerr << pr.first << ":" << pr.second << " ";
		//cerr << endl;
	}
	return true;
}

signed main() {
	cin >> N;

	inputVector(A, N);

	int low = 0;
	int high = N;
	int mid = (low + high) / 2;
	while (high - low > 1) {
		if (check(mid)) {
			//cerr << " -> success" << endl;
			high = mid;
		} else {
			low = mid;
			//cerr << " -> failed" << endl;
		}
		mid = (low + high) / 2;
	}

	cout << high << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(a == 1)
    a = 14;
  if(b == 1)
    b = 14;
  if(a < b)
    out("Bob");
  if(a == b)
    out("Draw");
  if(a > b)
    out("Alice");
  memi;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long sum = 0;
		int max = 0;
		for(int i = 0; i < N; i++) {
			int p = sc.nextInt();
			sum += p;
			max = Math.max(max,p);
		}

		System.out.println(sum - max/2);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    puta(n*m);
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
#define l long long
#define pb push_back
void frooty()
{
	l n,m;
	cin>>n>>m;
	if(m>=n)
		cout<<"unsafe"<<"\n";
	else
		cout<<"safe"<<"\n";
}
int main()
{
	l t=1;
	//cin>>t;
	while(t--)
	{
		frooty();
	}
}

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

using namespace std;
using ll = long long;

int main() {
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(int i=0;i<x;++i) {
        cin >> a[i];
    }
    for(int i=0;i<y;++i) {
        cin >> b[i];
    }
    for(int i=0;i<z;++i) {
        cin >> c[i];
    }

    vector<ll> tmp;
    for(int i=0;i<x;++i) {
        for(int j=0;j<y;++j) {
            tmp.push_back(a[i] + b[j]);
        }
    }
    sort(tmp.begin(), tmp.end());
    reverse(tmp.begin(), tmp.end());

    vector<ll> ans;
    for(int i=0;i<min(x*y, k);++i) {
        for(int j=0;j<z;++j) {
            ans.push_back(tmp[i] + c[j]);
        }
    }
    
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());

    assert((int)(ans.size()) >= k);

    for(int i=0;i<k;++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 43240
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  cin >> N;
  vector<int> A;
  A.resize(N);
  REP(i,N){
    cin >> A[i];
  }
  sort(all(A));

  for(int i = 0; i < N - 1; i++){
    if(A[i + 1] == A[i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
   int a=0,b=0,c=0,tem,i;
   for(i=0;i<10;i++){
      scanf("%d",&tem);
      if(tem>=a){
      c=b;b=a;a=tem;
      }
      else if(tem>=b){
      c=b;b=tem;
      }
      else if(tem>=c){
      c=tem;
      }
   }
   printf("%d\n%d\n%d\n",a,b,c);
   return 0;
}

Measured memory_bytes: 600
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int res = H * W;
    res -= H * w;
    res -= W * h;
    res += w * h;
    cout << res << endl;
    return 0;
}

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

struct Unionfind {
	vector<int> parent;

	Unionfind(int N) {
		parent = vector<int>(N, -1);
	}

	int root(int x) {
		if (parent[x] < 0) return x;
		return parent[x] = root(parent[x]);
	}

	int size(int x) {
		return -parent[root(x)];
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (size(x) < size(y)) swap(x, y);
		parent[x] += parent[y];
		parent[y] = x;
		return;
	}

};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	Unionfind uni(N);
	vector<ll> ans(M);
	ans[M - 1] = (ll)N * (N - 1) / 2;
	for (int i = M - 1; i >= 1; i--) {
		ans[i - 1] = ans[i];
		if (uni.root(A[i]) != uni.root(B[i])) {
			ans[i - 1] -= (ll)uni.size(A[i]) * uni.size(B[i]);
			uni.unite(A[i], B[i]);
		}
	}
	rep(i, M) cout << ans[i] << endl;
}





Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    
    int p;
    p=n%10;
    
    if(p==3)
        cout << "bon";
        else if(p==0|| p==1||p==6||p==8)
            cout << "pon";
            else
                cout << "hon";
                
                return 0;
}

Measured memory_bytes: 3596
import sys
from collections import deque
from operator import itemgetter

def read():
    return sys.stdin.readline().rstrip()

def main():
    n = int(read())
    al = [[] for _ in range(n)]
    e = dict()
    for i in range(n - 1):
        a, b = [int(j) - 1 for j in read().split()]
        al[a].append(b)
        al[b].append(a)
        e[(a, b)] = i
    v, k = 0, 0
    for i in range(n):
        if len(al[i]) > k:
            v = i
            k = len(al[i])
    print(k)
    sn = deque([(v, 0)])
    sd = set()
    ce = dict()
    while sn:
        v, cv = sn.popleft()
        sd.add(v)
        ci = 1
        for vn in al[v]:
            if vn in sd:
                continue
            if ci == cv:
                ci += 1
            if (v, vn) in e:
                ce[(v, vn)] = ci
            else:
                ce[(vn, v)] = ci
            sn.append((vn, ci))
            ci += 1
    for k, _ in sorted(e.items(), key=itemgetter(1)):
        print(ce[k])

if __name__ == '__main__':
    main()

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

int main(){
  int k; cin >> k;
  int num; num = k/2;
  int ans;
  if(k%2 == 0){
    ans = pow(num, 2);
  }else{
    ans = num * (num + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]in=sc.intArr(n);
		int ans=0;
		for(int i=1;i<=n;i++) {
			ans+=(i%2==1 && in[i-1]%2==1)?1:0;
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 32760
A,B,M = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
x = []
y = []
c = []
M.times do |i|
  x[i],y[i],c[i] = gets.chomp.split(" ").map(&:to_i)
end

min = a.min + b.min
M.times do |i|
  tmp = a[x[i]-1] + b[y[i]-1] - c[i]
  min = tmp if tmp < min
end
puts min


Measured memory_bytes: 22020
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  map<int,int> chk;
  int d;
  for(int i = 0; i < N; i++){
    cin >> d;
    ++chk[d];
  }

  int cnt = 0;
  for(auto x: chk) ++cnt;
  
  printf("%d\n",cnt);
  return 0;
}


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

int main(){
  int A, B, C, D;
  cin>> A >> B >> C >> D;
  while(1){
    if(C-B<=0){
      cout << "Yes" << endl;
      return 0;
    }else{
      C-=B;
      if(A-D<=0){
        cout << "No" << endl;
        return 0;
      }
      A-=D;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define MAX_N 10001

int main() {
  int n, q, S[MAX_N], t, num;
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }
  num = 0;
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &t);
    for(i = 0; i < n; ++i) {
      if(S[i] == t) {
        ++num;
        break;
      }
    }
  }
  printf("%d\n", num);
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(d<b) d += 60, c--;
	if(c<a) c+=24;
	int s = (c-a)*60 + (d-b);
	printf("%d",s<e?0:s-e);
}

Measured memory_bytes: 1728
import sys
nums = int(input())
bottom = list(range(nums))
check = {}
count = 0
a = 0
for i in range(nums):
    bottom[i] = int(input())
    check[i] = 0

while True:

    if bottom[a] == 2:
        count += 1
        break
    if check[a] == 1:
        print("-1")
        sys.exit()
    check[a] = 1
    a = bottom[a] - 1
    count += 1
print(count)

Measured memory_bytes: 19044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i, 0, n) cin >> a[i];
    VL v(1000010, 0);
    sort(ALL(a));
    ll ans = 0;
    rep(i, 0, n){
        if(v[a[i]]) v[a[i]]++;
        else {
            for(ll j = a[i]; j <= 1000000; j += a[i]){
                v[j]++;
            } 
        }
    }
    for(auto e : a){
        if(v[e] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12700
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

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

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
  ll k;
  string s;
  cin >> k >> s;
  if(s.size()>k){
    cout << s.substr(0,k) << "...";
  }else{
    cout << s;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define M 1000000007
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)

//--------------------------------------------------------------

void Main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<((b-a)%2==0? "Alice":"Borys")<<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

int isPrime(int x){
    if(x < 2) return 0;
    else if(x == 2) return 1;
    if(x % 2 == 0) return 0;
    for(int i = 3; i*i <= x; i += 2){
        if(x % i == 0) return 0;
    }
    return 1;
}

int main() {
    int x;
    cin >> x;
    for(int i = x; i < 100004; i++){
        if(isPrime(i) == 1){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}


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

int main(){
       int n;
    cin>>n;
    queue<string> que;
    string s = "a";
    que.push(s);
    while(1){
        string t = que.front();
        int sz = t.size();
        if(sz==n) break;
        que.pop();
        int mx=0; 
        rep(i,sz){
            mx=max(mx,t[i]-'a');
        }
        for(int i=0;i<mx+2;i++){
            char c='a'+i;
            string ad = t+c;
            que.push(ad);
        }
    }
    while(!que.empty()){
        string t= que.front();que.pop();
        cout<<t<<endl;
    }
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;
int main()
{
    int ConvTblNum;
    while(cin >> ConvTblNum && ConvTblNum){
    map<string,string> ConvTbl;
    while(ConvTblNum--)
    {
        string a,b;
        cin >> a >> b;
        ConvTbl.insert(map<string,string>::value_type(a,b));
    }
    int ConvdNum;
    cin >> ConvdNum;
    string result="";
    while(ConvdNum--)
    {
        string c;
        cin >> c;
        auto it = ConvTbl.find(c);
        if(it!=ConvTbl.end())
        {
            c = it->second;
        }
        result += c;    
    }
    cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0;
    rep(i,0,200){
        if(i>=a&&i>=c){
            if(i>=b||i>=d) break;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define put(n) cout<<(n)<<endl;
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int H,N,F[10101];
long long dp[10101][1<<4];

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

    FOR(i,0,N){
        int x,y; 
        cin>>x>>y;
        F[y] |= (1<<x);
    }

    FOR(i,0,10101){
        FOR(j,0,(1<<4)){
            dp[i][j] = -1e9;
        }
    }

    dp[0][F[0]] = 0;

    FOR(i,0,H-1){
        FOR(state,0,(1<<4)){
            FOR(bit,0,(1<<3)){
                int next = F[i+1],cnt = 0,ok = 1;
                FOR(j,0,3){
                    if(!(bit&(1<<j))) continue;
                    if(state&(3<<j)) ok = 0;
                    if(next&(3<<j)) ok = 0;
                    next |= (3<<j);
                    cnt++;
                }
                if(!ok) continue;
                dp[i+1][next] = max(dp[i+1][next],dp[i][state]+cnt);
            }
        }
    }
    long long ans = -1e9;
    FOR(i,0,(1<<4)){ans = max(ans,dp[H-1][i]);}
    put(ans);
}




Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  unordered_map<char,int> m;
  for(int i=0;i<s.length();i++){
    m[s[i]]++;
  }
  for(int i=0;i<s.length();i++){
    if(m[s[i]]%2!=0){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}
  
  

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100];
  int n;
  int a=1;
  int b=1;
  gets(s);
  n=strlen(s);
  for(int i=0;i<n;i+=2){
  if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
    //printf("%d\n",i);
    }
    else{
      a=0;
      break;
    }
  }
  for(int j=1;j<n;j+=2){
  if(s[j]=='L' || s[j]=='U' || s[j]=='D'){
    //printf("%d\n",j);
  }
    else{
      b=0;
      break;
    }
  }
  if(a==1&&b==1){
    printf("Yes");
  }
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static final long MAX = 10000000000l;
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            long n = Long.parseLong(br.readLine());
            long min = digit(n);
            for (long i = 1; i * i <= n; i++) {
                if (n % i != 0) {
                    continue;
                }
                long j = n / i;
                long temp = 0;
                if (digit(i) > digit(j)) {
                    temp = digit(i);
                } else {
                    temp = digit(j);
                }
                if (min > temp) {
                    min = temp;
                }
            }
            System.out.println(min);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static int digit(long num) {
        return String.valueOf(num).length();
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		char C = in.next().charAt(0);
		System.out.println((char)(C + 1));

	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 21844