akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>

constexpr long long INFLL = 1e18;

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

int main()
{

    int n;
    cin >> n;
    vector<int> s(n);
    char temp;
    // int checkW = 0;
    // int checkR = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        if (temp == 'R')
        {

            s.at(i) = 1;
        }
        else
        {
            s.at(i) = 0;
        }
    }
    int r = n - 1;
    bool che = false;
    int count = 0;
    int i;

    for (i = 0; i < n; i++)
    {
        if (s.at(i) == 0)
        {
            while (s.at(r) == 0 && i < r)
            {
                /*
            while (s.at(r) == 0)
            {
                if (i >= r)
                {
                    che = true;
                    break;
                }
                */

                r--;
            }
            /*
        if (che)
        {
            break;
        }
        */
            // r--;
            if (r > i)
            {
                r--;
                count++;
            }
        }
    }
    /*
    if (che == false && i == 0 && r == 0)
    {
        count = 0;
    }
    */

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/
int main(){int A,B;SCAND2(A,B);PRINTD((A-1)*(B-1));}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    result = [0]*n
    wa = [0]*n
    ac = [0]*n
    for _ in range(m):
        i = input().rstrip()
        i = i.split()
        p, s = int(i[0]), i[1]
        if s=='WA':
            if result[p-1]==0:
                wa[p-1] += 1
        else:
            if result[p-1]==0:
                result[p-1] = 1
                ac[p-1] += 1
    a = sum(ac)
    b = 0 
    for i in range(n):
        if ac[i]==1:
            b += wa[i]
    print(a, b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 43100
#include<stdio.h>
int main()
{
 int score[11],win,lose,draw,point[11];
 int n,i,j,k;
 char str[11][21];
 
 for(k=0;;k++){
  scanf("%d",&n);
  if(n==0)break;
  if(k!=0)puts("");
  for(i=0;i<n;i++){
   scanf("%s",str[i]);
   scanf("%d%d%d", &win, &lose, &draw);
   score[i]=win*3+draw;
   point[i]=score[i];
  }
  for(i=0;i<n;i++){
   for(j=0;j<n;j++){
    if(point[i]>point[j]){
     point[10]=point[i];
     point[i]=point[j];
     point[j]=point[10];
    }
   }
  }
  for(i=0;i<n;i++){
   for(j=0;j<n;j++){
    if(point[i]==score[j]){
     printf("%s,%d\n",str[j],score[j]);
     score[j]=-1;
     break;
    }
   }
  }
 }
 return 0;
}

Measured memory_bytes: 0
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
b = Counter(a)
c = list(set(a))
l = len(c)
if l == 1:
    print(n)
    exit()
ans = 0
for i in range(l):
    tmp = b[c[i]]
    if i > 0 and c[i - 1] + 1 == c[i]:
        tmp += b[c[i - 1]]
    if i < l - 1 and c[i] + 1 == c[i + 1]:
        tmp += b[c[i + 1]]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 80360
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(s);
            WriteLine(s[0] + s[1]);
        }

    }

}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define mem(a,v) memset(a,v,sizeof a)
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define f first
#define s second
#define fr(i,n) for(int j=i;j<n;j++)
#define rev(a) reverse(a.begin(),a.end())
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lb(a,v) lower_bound(all(a),v)
#define ub(a,v) upper_bound(all(a),v)
#define ins(v) insert(v)
#define pb(v) push_back(v)
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define sf1(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
using namespace std;
int main() {
	int n,k,q,s=0,c=0,x;
	sf3(n,k,q);
	int arr[n+1]={};
	for(int i=1;i<=q;i++)
	{
		sf1(x);
		arr[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		arr[i]+=k;
		arr[i]-=q;
		//cout<<arr[i]<<endl;
		if(arr[i]<=0)
			puts("No");
		else
			puts("Yes");
	}
	//printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N = int(input())
P = list(map(lambda x:int(x)-1,input().split()))

costs = [0]*(N*N)
for i in range(N):
    for j in range(N):
        costs[i*N+j] = min(i,j,N-1-i,N-1-j)
exist = [1]*(N*N)

from collections import deque
ans = 0
for p in P:
    ans += costs[p]
    exist[p] = 0
    q = deque([p])
    while q:
        p = q.popleft()
        y,x = divmod(p,N)
        if x < N-1:
            np = p + 1
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if x > 0:
            np = p - 1
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if y < N-1:
            np = p + N
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if y > 0:
            np = p - N
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
print(ans)

Measured memory_bytes: 121088
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, M;cin >> N >> M;
    int ma = M;
    vector<pair<int, int>> ans;
    if(ma % 2 == 0){
        for(int i = 0;i < ma / 2;i++){
            ans.push_back({N - ma + i + 1, N - i});
        }
        for(int i = 0;i < ma / 2;i++){
            ans.push_back({i + 1, ma - i + 1});
        }
    }else{
        for(int i = 0;i < ma / 2 + 1;i++){
            ans.push_back({N - ma + i, N - i});
        }
        for(int i = 0;i < ma / 2;i++){
            ans.push_back({i + 1, ma - i});
        }
    }
    for(int i = 0;i < M;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}


Measured memory_bytes: 4208
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int n;
    cin>>n;
    int f=0;
    int t=0;
    int o=0;
    int a[100001]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%4==0){
            f++;
        }else if(a[i]%2==0){
            t++;
        }else{
            o++;
        }
    }
    if(t!=0){
        o++;
    }
    if(o<=f+1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}   



Measured memory_bytes: 640
using System;
using System.Linq;

namespace C___Rectangle_Cutting
{
    class Program
    {
        static void Main(string[] args)
        {
            var WHxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            decimal W = WHxy[0], H = WHxy[1], x = WHxy[2], y = WHxy[3];

            int flg = x == W / 2 && y == H / 2 ? 1 : 0;
            Console.WriteLine((decimal)(W * H) / 2 + " " + flg);
        }
    }
}


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

int main()
{
  int a,b,bb,c,d = 0;
  
  cin >> a;
  
  b = a/3600;
  bb = a%3600;
  cout << b << ":" ;

  c = bb / 60;
  cout << c << ":";

  d = bb%60;
  cout << d << endl;
}

  
  

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <memory.h>
using namespace std;

#define ll long long

typedef pair<int,int> P;

ll dp[501][10001];

int main() {
  int M,N;
  cin >> M >> N;
  int P[M];
  int C[N],E[N];
  for(int i = 0; i < M; i++) {
    cin >> P[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i] >> E[i];
  }

  sort(P,P+M,greater<int>());
  ll sum[M+1];
  sum[0] = 0;
  for(int i = 0; i < M; i++) {
    sum[i+1] = sum[i] + P[i];
  }
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= M; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;

  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= M; j++) {
      if(dp[i][j] == -1) continue;
      dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
      dp[i+1][min(j + C[i],M)] = max(dp[i+1][min(j + C[i],M)],dp[i][j] + sum[min(j + C[i],M)] - sum[j] - E[i]);
    }
  }
  ll MAX = 0;
  for(int i = 0; i <= M; i++) {
    MAX = max(MAX,dp[N][i]);
  }
  cout << MAX << endl;

}

Measured memory_bytes: 40440
#include<stdio.h>

int main(void)

{

   int a,b,d,r;

   double f;

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

   d = a / b;

   r = a % b;

   f = (double)a / (double)b;

   printf("%d %d %lf\n",d,r,f);

   return 0;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005;
char s[MAXN];
int n,m,q,a[MAXN],b[MAXN];
int main(){
	n=read();
	printf("0\n"); fflush(stdout);
	scanf("%s",s);
	if (s[0]=='M') m=1;
	else if (s[0]=='F') m=2;
	else return 0;
	int l=0,r=n-1,mid;
	while (l<=r) {
		mid=(l+r)/2;
		printf("%d\n",mid); fflush(stdout);
		scanf("%s",s);
		if (s[0]=='M') q=1;
		else if (s[0]=='F') q=2;
		else return 0;
		if ((q==m)==((mid&1)==0)) l=mid+1; else r=mid-1;
	}
	
	return 0;
}

/*
*/


Measured memory_bytes: 852
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	vector<int> height(10);
	for(int i=0; i<10; i++){
		cin >>height[i];
	}
	sort(height.begin(),height.end(),greater<int>());
	cout <<height[0]<<endl<<height[1]<<endl<<height[2]<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int a, b;
	cin >> a >> b;
	int n = min(a, b);
	int m = max(a, b);
	for (int i = 0; i < m; i++)
	{
		cout << n;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int Dice[] = {1,2,3,4,5,6};
void initialize_dice() {
  for(int i=1;i<=6;i++) {
    Dice[i-1] = i;
  }
}
void operation_dice(int op[]) {
  int Dice_tmp[6];
  for(int i=0;i<6;i++) {
    Dice_tmp[i] = Dice[i];
  }
  for(int i=0;i<6;i++) {
    Dice[i] = Dice_tmp[op[i]];
  }
}
void print_dice() {
  cout << "print_dice : {";
  for(int i=0;i<6;i++) {
    cout << Dice[i] << (i+1==6 ? "}" : ",");
  }
  cout << endl;
}

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

  // initialize operation array
  // Next Dice[i] = Dice[op[i]]
  int north[] = {1,5,2,3,0,4};
  int east[] = {3,1,0,5,4,2};
  int west[]= {2,1,5,0,4,3};
  int sorth[] = {4,0,2,3,5,1};
  int right[] = {0,2,4,1,3,5};
  int left[] = {0,3,1,4,2,5};

  int n;
  int score;
  while(true) {
    cin >> n;
    if(n == 0) break;

    initialize_dice();
    score = Dice[0];
    char str[6];
    for(int i=0;i<n;i++) {
      cin >> str;
      switch(str[0]) {
        case 'N':
          // cout << "North" << endl;
          operation_dice(north);
          break;
        case 'E':
          // cout << "East" << endl;
          operation_dice(east);
          break;
        case 'W':
          // cout << "West" << endl;
          operation_dice(west);
          break;
        case 'S':
          // cout << "South" << endl;
          operation_dice(sorth);
          break;
        case 'R':
          // cout << "Right" << endl;
          operation_dice(right);
          break;
        case 'L':
          // cout << "Left" << endl;
          operation_dice(left);
          break;
      } // end switch
      score += Dice[0];
      //print_dice();
    } // end for
    cout << score << endl;
  } // end while
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define INF 100000
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	vector<int> a;
	ll jud;
	int ans=0,cnt=0;
	cin >> N;
	rep(i,N){
		cin >> jud;
		if (jud <= N){
			a.push_back(jud);
		}else{
			ans++;
		}
	}
	sort(a.begin(),a.end());
	rep(i,a.size()){
		jud=1;
		while(a[i]==a[i+1]){
			jud++;
			i++;
			}
		if(jud>a[i]){
			ans += jud-a[i];
		}else if(jud<a[i]){
			ans += jud;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
x,y=map(int,input().split())

c=0
if x < 0 and y < 0:
  if abs(x) < abs(y):
    print(x-y+2)
  else:
    print(y-x)
elif x*y<=0:
  if x != 0 and y != 0:
    print(abs(x+y)+1)
  elif x == 0 and y == 0:
    print(0)
  elif x == 0:
    print(y if y > 0 else -y + 1)
  else:
    print(-x if x < 0 else x + 1)
else:
  if x > y:
    print(x - y + 2)
  else:
    print(y - x)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#define MAXN 200010
int n, k, p, a[MAXN];
char buf[MAXN], ans[2][MAXN];
std::deque<int> Q;
int main() {
	scanf("%d%d%s", &n, &k, buf + 1);
	for (int i = 1; i <= n; i++) Q.push_back(buf[i] == 'B');
	for (int i = 1; i <= 2 * n + 2; i++) {
		if (Q.front() ^ p) {
			Q.pop_front();
			p ^= 1;
			Q.push_back(p);
		} else {
			Q.pop_front();
			Q.push_front(p ^ 1);
		}
		if (i == k) {
			for (int j = 1; j <= n; j++) printf("%c", (Q[j - 1] ^ p) + 'A');
			puts("");
			return 0;
		}
		if (i > 2 * n) {
			for (int j = 1; j <= n; j++) ans[i - 2 * n - 1][j] = (Q[j - 1] ^ p) + 'A';
		}
	}
	puts(ans[~k & 1] + 1);
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int i, j, k, n;
	vi a, b;

	cin >> n;

	a.resize(n);

	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	k = a[0];

	while (1) {
		if (k == 1) {
			cout << 1;
			break;
		}
		if (n == 1) {
			cout << a[0];
			break;
		}
		b.clear();
		j = k;
		rep(i, n) {
			if (a[i] % k != 0) {
				b.push_back(a[i] % k);
				j = min(j, a[i] % k);
			}
		}
		b.push_back(k);

		a.clear();
		a = b;
		n = a.size();
		k = j;
	}

	return 0;
}

Measured memory_bytes: 1276
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
l=[0]*(10**5+1)
for i in a:
  l[i]+=1
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
  x=l[b]
  l[b]=0
  s=s-b*x+c*x
  print(s)
  l[c]+=x

Measured memory_bytes: 20868
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, N;
    cin >> H >> W >> N;

    int ans = N / max(H, W);
    if (N % max(H, W) != 0) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long A = sc.nextLong();
		long B = sc.nextLong();
		/*long dp[] = new long[1000000000];
		dp[0] = 1;
		dp[1] = 2;
		for(int i = 2; i <= K; i++) {
			long temp = (long)(dp[i - 2] / A) * B - ((long)(dp[i - 2] / A) * A);
			dp[i] = Math.max(dp[i - 1] + 1, dp[i - 2] + temp);
			//System.out.println(dp[i]);
		}*/
		
		/*
		long dp[] = new long[3];
		dp[0] = 1;
		dp[1] = 2;
		long temp = (long)(dp[0] / A) * B - ((long)(dp[0] / A) * A);
		dp[2] = Math.max(dp[1] + 1, dp[0] + temp);
		for(int i = 2; i <= K; i++) {
			if(i > 2) {
				dp[0] = dp[1];
				dp[1] = dp[2];
			}
			temp = (long)(dp[0] / A) * B - ((long)(dp[0] / A) * A);
			dp[2] = Math.max(dp[1] + 1, dp[0] + temp);
		}*/
		
		long ans = 1;
		for(int i = 0; i < K; i++) {
				if(ans < A || i == K - 1 || B - A < 2) {
					ans++;
					continue;
				} else {
					//long temp = ans / A;
					ans = ans - A + B;
					//System.out.println(ans);
					i++;
				}
		}
		
		System.out.println(ans);
	}
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll n, ans = 0;
    cin >> n;
    if(n % 2 == 0){
        ll x = 5;
        while(x <= n){
            ans += (n / x) / 2;
            x *= 5;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int N,M,C,i,j,k,l,F[20001]={0},c,tmp,tmp2;
int main()
{
	for(i=-142,c=0;i<142;i++)
			for(j=-142;j<142;j++)
				if(i*i+j*j<20000)
					F[i*i+j*j]=1;

	scanf("%d",&C);
	for(;C--;)
	{
		scanf("%d%d",&M,&N);
		tmp=(abs(M)<abs(N)?abs(N):abs(M))+1;
		for(i=-tmp,c=0;i<tmp;i++)
		{
			for(j=-tmp;j<tmp;j++)
			{
				tmp2=i*i+j*j;
				if(tmp2>0&&(M*i+N*j)%tmp2==0&&(i*N-j*M)%tmp2==0&&tmp2>0&&(M*M+N*N)%(tmp2)==0&&F[(M*M+N*N)/(tmp2)]==1)
				{
					c++;
				}
			}
		}
		puts(c>8?"C":"P");
	}
	return 0;
}

Measured memory_bytes: 660
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
for k in range(n+5):
    m = k*(k-1)//2
    #ddprint("k {} m {}".format(k,m))
    if m>n:
        break
    if m<n:
        continue
    cnt = 1
    s = [ [] for i in range(k) ]
    for i in range(k-1):
        for j in range(i+1,k):
            s[i].append(cnt)
            s[j].append(cnt)
            cnt += 1
    print('Yes')
    print(k)
    for i in range(k):
        printn(k-1)
        for j in s[i]:
            printn(' ' + str(j))
        print('')
    exit()
print('No')


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1 && B != 1){
    cout << "Alice" << endl;
  }else if (B == 1 && A != 1){
    cout << "Bob" << endl;
  }else if (A>B){
    cout << "Alice" << endl;
  }else if (A<B){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}

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

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return -1;
}

int target;

bool f(int x) {
    return x < target;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    segtree<int, op, e> seg(a);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int x, v;
            cin >> x >> v;
            seg.set(x - 1, v);
        } else if (t == 2) {
            int l, r;
            cin >> l >> r;
            cout << seg.prod(l - 1, r) << endl;
        } else {
            int x, v;
            cin >> x >> v;
            target = v;
            cout << seg.max_right<f>(x - 1) + 1 << endl;
        }
    }
}


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

using namespace std;

const int N = 200005;

int n;
int a[N], b[N];

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

	for(int i = 0; i < n; i++) scanf("%d", a + i);
	for(int i = 0; i < n; i++) scanf("%d", b + i);
	reverse(b, b + n);

	int l = 0;
	while(l < n and a[l] != b[l]) l++;

	if(l < n) {
		int r = l;
		while(r + 1 < n and a[r + 1] == b[r + 1]) r++;
		int pos = l;
		for(int i = 0; i < l and pos <= r; i++) {
			if(a[i] != b[pos] and b[i] != b[pos]) {
				swap(b[i], b[pos++]);
			}
		}
		for(int i = r + 1; i < n and pos <= r; i++) {
			if(a[i] != b[pos] and b[i] != b[pos]) {
				swap(b[i], b[pos++]);
			}
		}
		if(pos <= r) return printf("No\n"), 0;
	}

	printf("Yes\n");
	for(int i = 0; i < n; i++) {
		printf("%d%c", b[i], " \n"[i + 1 == n]);
	}
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

int n , a[N] , LOG[N] , f[2][18][N] , pos[N];

int rmq(int k , int l , int r) {
    //cout << k << ' ' << l << ' ' << r << endl;
    int j = LOG[r - l + 1];
    return min(f[k][j][l] , f[k][j][r - (1 << j) + 1]);
}

pair<int , int> cal(int l , int r) {
    int x = rmq(l & 1 , l , r);
    int y = rmq((pos[x] + 1) & 1 , pos[x] + 1 , r);
    //cout << x << ' ' << y << endl;
    return {-x , -y};
}

int main() {
    scanf("%d" , &n);
    for (int i = 0 ; i < n ; ++ i) {
        scanf("%d" , &a[i]);
        pos[a[i]] = i;
    }
    for (int i = 2 ; i <= n ; ++ i) {
        LOG[i] = LOG[i >> 1] + 1;
    }
    for (int l = 0 ; l < 2 ; ++ l) {
        for (int i = 0 ; i < n ; ++ i) {
            f[l][0][i] = (i % 2 == l) ? a[i] : 1 << 30;
        }
        for (int k = 1 ; 1 << k <= n ; ++ k) {
            for (int j = 0 ; j + (1 << k) - 1 < n ; ++ j) {
                f[l][k][j] = min(f[l][k - 1][j] , f[l][k - 1][j + (1 << k - 1)]);
            }
        }
    }
    priority_queue< pair< pair<int , int> , pair<int , int> > > Q;
    Q.push({ cal(0 , n - 1) , {0 , n - 1}});
    while (!Q.empty()) {
        auto it = Q.top(); Q.pop();
        int x = -it.first.first;
        int y = -it.first.second;
        printf("%d %d " , x , y);
        int l = it.second.first;
        int r = it.second.second;
        x = pos[x] , y = pos[y];
        if (l < x - 1) {
            Q.push({ cal(l , x - 1) , {l , x - 1}});
        }
        if (x + 1 < y - 1) {
            Q.push({ cal(x + 1 , y - 1) , {x + 1 , y - 1}});
        }
        if (y + 1 < r) {
            Q.push({ cal(y + 1 , r) , {y + 1 , r}});
        }
    }
    puts("");
}


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

using namespace std;

using ll = long long;

struct Edge {
    int to;
    ll cost;
    Edge(int to, ll cost) : to(to), cost(cost) {}
};

using Graph = vector<vector<Edge> >; //隣接リスト

const ll INF = 1e15;
// const int NONE = -1;

// sは始点、mincは最短経路のコスト、Prevは最短経路をたどる際の前の頂点
// trueなら負の閉路を検出
bool bellman_ford(int s, const Graph& graph, vector<ll>& minc/*, vector<int> Prev*/) { 
    int n = graph.size();
    minc.resize(n, INF);
    //Prev.resize(n, NONE);
    minc[s] = 0; //始点までの距離は0
    for (int i = 1; i < n; i++) {
        for (int from = 0; from < n; from++) {
            for (const Edge& e : graph[from]) {
                if (minc[from] != INF && minc[e.to] > minc[from] + e.cost) {
                    minc[e.to] = minc[from] + e.cost;
                    //Prev[e.to] = from;
                }
            }
        }
    }
 
    //負の閉路を検出
    for (int from = 0; from < n; from++) {
        for (const Edge& e : graph[from]) {
            if (minc[from] != INF && minc[e.to] > minc[from] + e.cost) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll p;
    cin >> n >> m >> p;
 
    Graph graph(n), graph_rev(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        graph[a].emplace_back(b, p - c);
        graph_rev[b].emplace_back(a, p - c);
    }
 
    vector<ll> minc_1;
    bellman_ford(0, graph, minc_1);
 
    vector<ll> minc_n;
    bellman_ford(n - 1, graph_rev, minc_n);
 
    for (int i = 0; i < n; i++) {
        for (Edge& e : graph[i]) {
            if (minc_1[i] >= INF || minc_n[e.to] >= INF) continue;
            if (minc_1[n - 1] > minc_1[i] + minc_n[e.to] + e.cost) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
 
    cout << max(-minc_1[n - 1], 0LL) << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	vector <string> v;
	for (int i = 0; i < n; i++)
	{
		string t;
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(), v.end());
	for (int j = 0; j < n; j++) {
		cout << v[j];
	}
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    string S; cin >> S;
    rep(i, S.size()) {
      if (S[i] == '?') cout << 'D';
      else cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3748
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def getn(n):
    c = 0
    while n % 2 == 0:
        n = n // 2
        c += 1
    return c


N = inp()
a = inlist()
c = 0
for i in a:
    c += getn(i)

print(c)


Measured memory_bytes: 4276
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair 
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli n,m,i,j,s=0;
	cin >> n >> m;
	vi v;
	for(i=0;i<m;i++)
	{
		cin >> j;
		s+=j;
		v.pb(j);
	}
	if(s>n)
	{
		cout << "-1" << endl;
	}else{
		cout << n-s << endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
		solve();
	return 0;
}





Measured memory_bytes: 3752
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > v(n, vector<int>(n));
    long long sum = 0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> v[i][j];
            sum += v[i][j];
        }
    }
    sum /= 2;

    for(int a=0; a<n; ++a){
        for(int b=0; b<a; ++b){
            bool isRemove = false;
            for(int c=0; c<n; ++c){
                if(a == c || b == c)
                    continue;
                if(v[a][c] + v[c][b] < v[a][b]){
                    cout << -1 << endl;
                    return 0;
                }
                else if(!isRemove && v[a][c] + v[c][b] == v[a][b]){
                    sum -= v[a][b];
                    isRemove = true;
                }
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
using namespace std;
//printf("%d %d %.5lf\n",d,r,f);
int main() {
  int i;
  int x=0;
  int y=0;
  int z=0;
 // while(1){
    scanf("%d",&i);
    while(++x <= i){
      z=0;
      y=x;
      if(x%3 == 0){
	printf(" %d",x);
      }else{
	while(y>0){
	  if(y%10 == 3 && z==0) {
	    printf(" %d",x);
	    z=1;
	  }
	  y=y/10;
	}
      }
    }
  printf("\n");
  x=0;
 // }//1
}//main



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

int main()
{
  long a, b, x, num;
  
  cin >> a >> b >> x;
  
  num = b/x - a/x;
  
  if(a%x == 0)
  {
    num++;
  }
  cout << num << endl;
  return 0;
}
  

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

ll H, W;
vector<string> S;

void solve() {
  vector<vector<ll>> L(H, vector<ll>(W));
  vector<vector<ll>> R(H, vector<ll>(W));
  vector<vector<ll>> U(H, vector<ll>(W));
  vector<vector<ll>> D(H, vector<ll>(W));

  for (int i = 0; i < H; i++) {
    L[i][0] = (S[i][0] == '.') ? 1 : 0;
    R[i][W - 1] = (S[i][W - 1] == '.') ? 1 : 0;
  }

  for (int j = 0; j < W; j++) {
    U[0][j] = (S[0][j] == '.') ? 1 : 0;
    D[H - 1][j] = (S[H - 1][j] == '.') ? 1 : 0;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (S[i][j] == '#') {
        L[i][j] = 0;
      } else {
        L[i][j] = L[i][j - 1] + 1;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = W - 2; j >= 0; j--) {
      if (S[i][j] == '#') {
        R[i][j] = 0;
      } else {
        R[i][j] = R[i][j + 1] + 1;
      }
    }
  }

  for (int i = 1; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') {
        U[i][j] = 0;
      } else {
        U[i][j] = U[i - 1][j] + 1;
      }
    }
  }

  for (int i = H - 2; i >= 0; i--) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') {
        D[i][j] = 0;
      } else {
        D[i][j] = D[i + 1][j] + 1;
      }
    }
  }

  ll res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ll tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j];
      if (S[i][j] == '.') {
        res = max(res, tmp - 3);
      } else {
        res = max(res, tmp);
      }
    }
  }
  cout << res << '\n';
}

int main() {
  cin >> H >> W;
  S.resize(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 129664
#pragma warning(disable:4996)
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<time.h>
#include<map>
#include<set>
#include<sstream>
#include<cassert>
#include<limits>
using namespace std;
const int INF = 0x3f3f3f3f;
using ll = long long;

int cntDigists(ll n){
    int digits = 1;
    while(n/10)
    {
        digits++;
        n = n/10;
    }
    return digits;
}

void p1(){
    int a,b,c;
    cin >> a >> b >>c;
    if(c-b == b-a) cout<<"YES"<<endl;
    else cout<<"NO";
}

void p2() {
    string O,E;
    cin >> O;
    cin >> E;
    string result;

    for(int i=0; i<O.size(); ++i){
        result += O[i];
        if(i < E.size())
        result += E[i];
    }

    cout << result << endl;

}

void p3(){
    int n;
    cin >> n;
    vector<string> vs(n);
    for(int i=0; i<n; ++i){
        cin >> vs[i];
    }

    vector<int> a(26,1000);
    for(auto s: vs){
        int index = 0;
        vector<int> b(26,0);
        for(auto c : s){
            b[c-'a'] +=1 ;
           // cout<< b[index] << ' ';
            ++index;
        }
        for(int i=0; i<26; ++i){
            if(b[i] < a[i]) a[i] = b[i];
        }
    }
    string res;
    for (int i = 0; i < a.size(); ++i) {
        if(a[i] && a[i] != 1000){
            for(int j=0; j<a[i]; ++j){
                res += (i+'a');
            }
        }
    }
    cout << res <<endl;
}


int main()
{
    //freopen("in.txt", "r", stdin);
    p3();
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		Deque<Integer> deque = new ArrayDeque<Integer>(2000000);
		
		for(int t = 0; t < n; t++){
			String input = sc.next();
			
			if("insert".equals(input)){
				final int x = sc.nextInt();
				
				deque.addFirst(x);
			}else if("delete".equals(input)){
				final int x = sc.nextInt();
				
				deque.remove(x);
			}else if("deleteFirst".equals(input)){
				deque.pollFirst();
			}else if("deleteLast".equals(input)){
				deque.pollLast();
			}
		}
		
		boolean first = true;
		for(int i : deque){
			System.out.print((first ? "" : " ") + i);
			
			if(first){
				first = false;
			}
		}
		System.out.println();
		
	}

}

class Scanner {
	
	private BufferedReader br;
	private StringTokenizer tok;
	
	public Scanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}
	
	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}
	
	private boolean hasNext(){
		return tok.hasMoreTokens();
	}
	
	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}
	
	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}
	
	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}
	
	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}

Measured memory_bytes: 183656
//abc077_a.cpp
//Sun Mar 11 20:39:35 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	string x;
	string y;
	cin >> x;
	cin >> y;

	if (x[0]==y[2] && x[1]==y[1] && x[2]==y[0]){
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func b2i(b bool) int8 {
	if b {
		return 1
	}
	return 0
}

func solve(io *Io) {
	a := io.NextInt()
	b := io.NextInt()

	ans := "Yay!"
	if a > 8 || b > 8 {
		ans = ":("
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpp;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pair<int, int>> vpp;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define all(n) (n).begin(), (n).end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void out(Arg1&& arg1) {
    cout << arg1 << '\n';
}

template <typename Arg1, typename ...Args>
void out(Arg1&& arg1, Args&& ...args) {
    cout << arg1 << ' ';
    out(args...);
}


template <typename T>
void outarr(vector<T> arr) {
    for (int i = 0; i < arr.size() -1; ++i) cout << arr[i] << ' ';
    cout << arr.back() << '\n';
}

template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, M; cin >> n >> M;
    ll total = 0;
    for (int i=0; i <M; ++i) {
        int v; cin >> v;
        total += v;
    }

    if (total > n) cout << -1 << endl;
    else cout << (n - total) << endl;

    return 0;
}



Measured memory_bytes: 3632
let s = read_line ()
let n, fs, i = Array.(String.length s, make 128 false, ref 97)
let f s n = Printf.printf "%s%c\n" s (Char.chr n); exit 0
let _ = String.(Char.(iter (fun c -> fs.(code c) <- true) s; if n < 26 then (while fs.(!i) do incr i done; f s !i);
  for j = n - 1 downto 0 do i := code s.[j]; while !i < 123 && fs.(!i) do incr i done; if !i < 123 then f (sub s 0 j) !i; fs.(code s.[j]) <- false done; print_endline "-1"))

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


int main() {
	
	int N, T, sum=0;
	cin >> N >> T;
	vector<int> t(N);
	for(auto &i:t) cin >> i;
	for(int i=0; i<N-1; i++){
		if(t.at(i+1)-t.at(i) <= T){
			sum+= t.at(i+1)-t.at(i);
		}
		else sum += T;
	}
	sum += T;
	
	cout << sum << endl;
	
	
	return 0;
}

Measured memory_bytes: 1024
n, a, b = gets.split.map(&:to_i)
s = gets.chomp
a += b
s.each_char{|c|
	case c
	when ?a
		if a>0
			a -= 1
			puts "Yes"
		else
			puts "No"	
		end
	when ?b
		if a>0 and b>0
			a -= 1
			b -= 1
			puts "Yes"
		else
			puts "No"
		end
	when ?c
		puts "No"
	end
}

Measured memory_bytes: 2300
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
}


Measured memory_bytes: 27180
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      	int i;
    	long number_of_people, answer;
      	long[] limit = new long[5];
      	number_of_people = Long.parseLong(sc.next());
      	for(i = 0; i < 5; i++) limit[i] = Long.parseLong(sc.next());
      	Arrays.sort(limit);
      	if(number_of_people % limit[0] == 0) answer = number_of_people / limit[0] + 4;
      	else answer = number_of_people / limit[0] + 5;
      	System.out.println(answer);
    }
}

Measured memory_bytes: 22612