akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		String str ="";
		//??°?????????
		while(true){
			//???????????????????????????
			str = sc.next(); 
			//"-"????????????????????????
			if(str.equals("-")){
				break;
			}
			//??°????????????
			int num = sc.nextInt();
			
			//??????????????°???????????£?????????
			for(int i = 0;i< num;i++){
				int h = sc.nextInt();
				//
				str = str.substring(h)+str.substring(0,h);
			}
			//??¨???
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 26528
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,m,i;
string a;
bool flag;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m>>a;
    flag = true;
    if(a[n] == '-'){
        rep(i,0,n) if(!(a[i] >= '0' and a[i] <= '9')){
            flag = false;
            break;
        }
        rep(i,n + 1,m + n + 1) if(!(a[i] >= '0' and a[i] <= '9')){
            flag = false;
            break;
        }
    }
    else
        flag = false;
    cout<<(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000 + 7)

ll dp[500001][13];

int main(void)
{
    string S;
    cin >> S;
    ll base = 1;
    dp[0][0] = 1;
    REP(i, S.size()) {
        int j = S.size() - i - 1;
        REP(k, 10)
        {
            if (S[j] == '?' || S[j]-'0' == k) {
                REP(l, 13){
                    dp[i + 1][(l + base * k) % 13] = (dp[i + 1][(l + base * k) % 13] + dp[i][l]) % MOD;
                }
            }
        }
        base = (base * 10) % 13;
    }
    cout << dp[S.size()][5] << endl;
}


Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll n, a, b; cin >> n >> a >> b;
	ll x[100001];
	repe(i, 1, n)cin >> x[i];
	ll ans;
	rep(i, 1, n) {
		ans += min((x[i + 1] - x[i])*a, b);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int n;
  double sum = 0.0,a;

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> a;
    sum += a;
  }
  cout << (int)(sum/n) << endl;

  return 0;
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}
int dp[500][500];
int pre[500];
int zeno(int i,int j){
	if(i==j)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	dp[i][j]=1e18;
	int sum=pre[j]-pre[i-1];
	for(int k=i;k<j;k++){
       mins(dp[i][j],zeno(i,k)+zeno(k+1,j)+pre[j]-pre[i-1]);
	}
	return dp[i][j];
}
int solve(){
 mem1(dp);
 int n;cin>>n;
 int a[n+1];rep3(n)cin>>a[i+1];
 for(int i=1;i<=n;i++)pre[i]+=pre[i-1]+a[i];
 cout<<zeno(1,n)<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef sieve
    sieve();
    #endif
    #ifdef ncr
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 2304
import math
Q = int(input())

li = [0]
cnt = 0
for i in range(3, 10**5+1, 2):
  flag = True
  for j in range(2, int(math.sqrt(i))+1):
    if i % j == 0:
      flag = False
  if flag:
    for j in range(2, int(math.sqrt((i+1)//2)+1)):
      if ((i+1)//2) % j == 0:
        flag = False
  if flag:
    cnt += 1
  li.append(cnt)
  
for i in range(Q):
  l, r = map(int, input().split())
  if l == 1:
    ans = li[r//2]
  else:
    ans = li[r//2] - li[l//2-1]
  print(ans)

Measured memory_bytes: 9588
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, c, A[CMax], ats, pap1, pap2, pap3;
pair<int, pair<int, int> > pap, ppap;
multiset< pair<int, pair<int, int> > > laidos;
multiset< pair<int, pair<int, int> > >::iterator it, pit;

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

    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &pap1, &pap2, &pap3);
        laidos.insert(make_pair(pap1, make_pair(pap3, 1)));
        laidos.insert(make_pair(pap2, make_pair(pap3, -1)));
    }

    pap1 = 0;
    pap2 = 0;
    pap3 = 0;
    for (it = laidos.begin(); it != laidos.end(); ++it){
        pap = *it;
        if (pap3 < pap.first){
            pap1 -= pap2;
            pap2 = 0;
        }
        pap1 += pap.second.second;
        ats = max(ats, pap1);

        pit = it;
        ++pit;
        if (pap.second.second == -1 && pit != laidos.end()) {
            ppap = *pit;
            if (ppap.second.first != pap.second.first) {
                pap1++;
                pap2++;
                pap3 = pap.first;
            }
        }

    }

    printf("%d\n", ats);
}


Measured memory_bytes: 12800
package main

import (
	"fmt"
)

func main() {
	var s string

	fmt.Scan(&s)

	n := 0

	for i := 0; i < len(s); i++ {
		n = (n + int(s[i] - '0')) % 9
	}

	if n == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3172
// Written By NewbieChd
#include <cstdio>
#include <cctype>
#include <vector>
#define int long long
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 200003, delta = 100000;
vector <int> g[maxN];
int id[maxN];
bool vis[maxN];

int cntOdd, cntEven, cntEdge;
void dfs(int x, bool f) {
    vis[x] = 1;
    f ? ++cntOdd : ++cntEven;
    for (auto y : g[x]) {
        ++cntEdge;
        if (!vis[y])
            dfs(y, f ^ 1);
    }
}

signed main() {
    int n = read(), i, x, y, cntNode = 0, ans = 0;
    for (i = 1; i <= n; ++i) {
        x = read(), y = read() + delta;
        if (!id[x])
            id[x] = ++cntNode;
        if (!id[y])
            id[y] = ++cntNode;
        x = id[x], y = id[y], g[x].push_back(y), g[y].push_back(x);
    }
    for (i = 1; i <= cntNode; ++i)
        if (!vis[i])
            cntOdd = cntEven = cntEdge = 0, dfs(i, 0), ans += cntOdd * cntEven - (cntEdge >> 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
/*
	int N,M;
	cin >> N >> M;
	
	char Russia[50][50];

	vector<int> checker[3];

	int co,un,ter;

	int nuru[48][48];

	for(int i=0;i<N;i++) {
		for(int j=0;j<M;j++){
			cin >> Russia[i][j];

			if(Russia[i][j] == 'W'){
				co++;
				checker[0].push_back(co);
			}
			if(Russia[i][j] == 'B'){
				un++;
				checker[1].push_back(un);
			}
			if(Russia[i][j] == 'R'){
				ter++;
				checker[2].push_back(ter);
			}
		}
		co = un = ter = 0;
	}

	for(int white=0; white<N-2; white++) {

		for(int shiro=0; shiro<white; shiro++){
			nuru[white][50] += checker[1][shiro] + checker[2][shiro];
		}

		for(int bluered=1; bluered<N-1; bluered++){

			for(int aoaka=white; aoaka<bluered; aoaka++){

				if (bluered + aoaka < N){
					nuru[white][bluered] += (checker[0][aoaka]+checker[2][aoaka]) + (checker[0][bluered+aoaka]+checker[1][bluered+aoaka]);
				}
				else{
					nuru[white][bluered] += checker[0][aoaka]+checker[2][aoaka];
				}

			}
		}
	}

	sort(nuru,nuru+250);

	cout << nuru[0][0] << endl;
*/

	int N;
	cin >> N;

	string S;
	cin >> S;

	int answer[200001];
	for(int h=0;h<N+1;h++){
		answer[h] = 0;
	}

	int kari = 0;

	for(int j=0;j<N;j++){
		if(S[j] == '.'){
			kari++;
		}
	}

	//cout << kari << endl;
	
	answer[0] = kari;

	for(int k=0;k<N;k++){
		if(S[k] == '.'){
			kari--;
		}    
		else if(S[k] == '#'){
			kari++;
		}
		answer[k+1] = kari;
	}

	sort(answer,answer+N+1);

	cout << answer[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1412
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  map<char, int> amap;
  bool ok = true;
  for(int i=0;i<S.size();++i){
    if(amap[S[i]]>0) ok = false;
    amap[S[i]]++;
  }
  if(ok) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}



Measured memory_bytes: 3580
// A - Rotation
#include<iostream>
using namespace std;
string InvertString(string a)
{
	string result;
	for(int i = a.length() - 1; i >= 0; --i)
	{
		result += a.at(i);
	}
	return result;
}

int main()
{
	string a, b;
	cin >> a;
	cin >> b;
	
	string c = InvertString(b);
	if(a == c)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	int n;
	cin >> n;
	if (n >= 1000) { cout << "ABD" << endl; }
	else { cout << "ABC" << endl; }
}

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

int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        else if (x < y)
            cout << x << " " << y << "\n";
        else
            cout << y << " " << x << "\n";
    }
    return 0;
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef long long int lli;
const lli mod = 1e9+7;
using namespace std;

int main()
{

    double n;cin>>n;

    n=(double)(n*n*n)/(double(27));
    cout<<setprecision(12)<<n;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int l, m;
    char n;
    while (cin >> l >> n >> m)
    {
        if (n == '?') break;
        if (n == '+')
        {
            cout << l + m << endl; 
        }
        else if (n == '-')
        {
            cout << l - m << endl; 
        }
        else if (n == '*')
        {
            cout << l * m << endl; 
        }
        else if (n == '/')
        {
            cout << l / m << endl; 
        }
        
    }

    
	return 0;
}


Measured memory_bytes: 3132
using System;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int S, W;
            string[] str = Console.ReadLine().Split(' ');
            S = int.Parse(str[0]);
            W = int.Parse(str[1]);
            if (S > W) Console.WriteLine("safe");
            else Console.WriteLine("unsafe");
        }
    }
}


Measured memory_bytes: 27528
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int D = sc.nextInt();

		double cnt = 0;
		long type = (long)Math.pow(N,M);

		long pat = 0;
		if(D==0) pat = N;
		else pat = 2*(N-D);
		
		System.out.println((double)(pat*(M-1))/Math.pow(N,2));
		
	}

}

Measured memory_bytes: 23892
let N =
    stdin.ReadLine()
    |> int
let A =
    stdin.ReadLine().Split()
    |> Array.map int

let dists =
    A
    |> Array.indexed
    |> Array.groupBy (fun (_,v) -> v)
    |> Array.map (fun (k,vs) -> (k,vs.Length))
    |> Array.fold (fun state (k,v) ->
        Array.set state (k-1) v
        state) (Array.create N 0)
let sum =
    dists
    |> Array.fold (fun state v -> state+int64(v)*(int64(v)-1L)/2L) 0L

A
|> Array.iter (fun v ->
    let ans = sum + 1L - int64(dists.[v-1])
    stdout.WriteLine ans)

Measured memory_bytes: 87472
infinity=2**35
def merge(A,left,mid,right):
  global cnt

  L=A[left:mid]
  R=A[mid:right]
  L.append(infinity)
  R.append(infinity)
  
  i=0
  j=0

  for k in range(left,right):
    cnt+=1
    if L[i]<=R[j]:
      A[k]=L[i]
      i+=1
    else:
      A[k]=R[j]
      j+=1



def mergeSort(A,left,right):
  if (left+1)<right:
    mid=(left+right)//2
    mergeSort(A,left,mid)
    mergeSort(A,mid,right)
    merge(A,left,mid,right)


n=int(input())
A=list(map(int,input().split()))
cnt=0

mergeSort(A,0,n)

print(*A)
print(cnt)



Measured memory_bytes: 63424
#include <stdio.h>
int main(){
    int a[12]={3,1,3,2,3,2,3,3,2,3,2,3},n,m;
    while(1){
        scanf("%d%d",&n,&m);
        if(n==0)return 0;
        
        for(int i=0;i<n-1;i++){
            m+=a[i];
        }
        m+=3;
        m%=7;
        switch(m){
            case 1:
                printf("Monday\n");
                break;
            case 2:
                printf("Tuesday\n");
                break;
            case 3:
                printf("Wednesday\n");
                break;
            case 4:
                printf("Thursday\n");
                break;
            case 5:
                printf("Friday\n");
                break;
            case 6:
                printf("Saturday\n");
                break;
            case 0:
                printf("Sunday\n");
                break;
        }
    }
    
}

Measured memory_bytes: 2576
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    string S, T;
    cin >> S >> T;
    
    int ans = 0;
    
    for(int i = 0; i < S.size(); i++){
        if(S[i] != T[i]) ans++;
    }
    
    cout << ans << endl;
}


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

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

	string s;
	cin >> s;
	if(s=="Sunny") cout << "Cloudy";
	else if(s=="Rainy") cout << "Sunny";
	else cout << "Rainy";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF=1e9+7;
const int maxn=100001;
const double pi = acos(-1.0);
const int mod=1e9+7;
using lb=long double;
int n;
int a[10001];
int main()
{
    int a,x,y;
    cin>>a>>x>>y;
    if(abs(a-x)>=abs(a-y))
        cout<<"B\n";
    else
        cout<<"A\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector< vector<char> > a(h, vector<char>(w));
    vector<int> mh(h, 0);
    vector<int> mw(w, 0);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                mh[i] = 1;
                mw[j] = 1;
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        if (mh[i] == 0) continue;
        for (int j = 0; j < w; ++j) {
            if (mw[j] == 0) continue;
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
lis = [list(map(int, input().split())) for i in range(N)]
lis.sort(key = lambda x: x[1])
time = 0
flag = 1
for i in range(N):
  time += lis[i][0]
  if time > lis[i][1]:
    flag = 0
    print('No')
    break
if flag == 1:
  print('Yes')

Measured memory_bytes: 53728
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N;
    string name;
    cin >> N;
    if(N < 1000){
        name = "ABC";
    }else{
        name = "ABD";
    }
    cout << name << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

class Edge{
public:
    int to;
    long long cost;
    Edge(int v, long long c = 1): to(v), cost(c){}
    ~Edge(){}
    bool operator<(const Edge& e) const{return cost < e.cost;}
};

bool Bellman_Ford(std::vector<std::vector<Edge> > &edge, int N,
    int start, std::vector<long long> &dist, ll &ans)
{
    // initialize
    long long infty = 1e+16;
    dist.clear();
    for(int i=0; i<N; i++) dist.push_back(infty);
    dist[start] = 0;

    std::vector<long long> cpy(dist);

    // update
    for(int i=0; i<2*N; i++){
        for(int u=0; u<N; u++){
            if(dist[u] == infty) continue;
            for(Edge& e: edge[u]){
                if(dist[u] + e.cost < cpy[e.to]){
                    cpy[e.to] = dist[u] + e.cost;
                }
            }
        }
        for(int i=0; i<N; i++) dist[i] = cpy[i];
        if(i == N-1) ans = dist[N-1];
    }

    return false;
}

int main()
{
    int N, M;
    cin >> N >> M;
    Vvec<Edge> graph(N);
    for(int i=0; i<M; i++){
        int u, v;
        ll c;
        cin >> u >> v >> c; u--; v--;
        graph[u].emplace_back(v, -c);
    }

    ll ans = 0;
    vector<ll> dist;
    Bellman_Ford(graph, N, 0, dist, ans);
    
    if(ans == dist[N-1]) cout << -ans << endl;
    else cout << "inf\n";
}

Measured memory_bytes: 384
#coding: utf-8
#!/home/nicetacks/.pyenv/shims/python3

s = input()

while "BC" in s:
    s = s.replace("BC", "D")

ret  = 0
numA = 0
for i in range(len(s)):
    if s[i] == "A":
        numA += 1
    elif s[i] == "D":
        ret += numA
    else:
        numA = 0

print(ret)



Measured memory_bytes: 9276
#include <stdio.h>
int main() {
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        if(x > y) {
            printf("%d %d", y, x);
        } else {
            printf("%d %d", x, y);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll H;cin>>H;
    ll ans = 0;
    ll cnt = 1;
    while(H >= cnt){
        ans += cnt;
        cnt *= 2;
    }
    cout<<ans<<endl;
}

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

bool ifnprime[100000];

void set(){
    ifnprime[0] = ifnprime[1] = 1;
    for(int n = 2; n * n < 100000; n++){
        if( !ifnprime[n] ){
            int j = n*n;
            while( j < 100000 ){
                ifnprime[j] = 1;
                j += n;
            }
        }
    }
}

int main(){
    int m;
    set();
    while( cin >> m ){
        for(int i = m-1; i >= 0; i-- ){
            if( !ifnprime[i] ){
                cout << i << ' ';
                break;
            }
        }
        for(int i = m+1; i < 100000; i++){
            if( !ifnprime[i] ){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1256
//
//  main.cpp
//  競技20190629

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1000000007;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%lld ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int tekitou(){
    int N,X;
    cin>>N>>X;
    int L[N];
    inarray(L, 0, N);
    int D[N+1];D[0]=0;
    FOR(i, 0, N+1){
        D[i+1]=D[i]+L[i];
    }
    //printintN(D, N+1);
    FOR(i, 0, N+1){
        if(D[i]>X)OutputAndReturn(i);
    }
    OutputAndReturn(N+1);
    
    return 0;
}
signed main(){
    assert(1);
    tekitou();
    //Ap();
    //Bp();
    //Cp();
    //Dp();
    //Ep();
    //Fp();
    return 0;
}


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

int main(){
    int a, b, i=0;
    cin >> a >> b;
    if(b==100){
        while(true){
            if(a*1000+b==i*i){
                cout << "Yes" << endl;
                goto END;
            }
            i++;
            if(i*i>100100){
                goto NO;
            }
        }
    }else if(b>=10){
        while(true){
            if(a*100+b==i*i){
                cout << "Yes" << endl;
                goto END;
            }
            i++;
            if(i*i>100100){
                goto NO;
            }
        }
    }else if(b<10){
        while(true){
            if(a*10+b==i*i){
                cout << "Yes" << endl;
                goto END;
            }
            i++;
            if(i*i>100100){
                goto NO;
            }
        }
    }
NO:
    cout << "No" << endl;
END:
    return 0;
}

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

vector<string> ss(5);
vector<int> vv(5);
int num[13];

vector<string> split(const string &s, char delimiter)
{
	vector<string> ret;
	size_t now = 0, find;
	while ((find = s.find_first_of(delimiter, now)) != string::npos)
	{
		ret.push_back(string(s, now, find - now));
		now = find + 1;
	}
	ret.push_back(string(s, now, s.size() - now));
	return ret;
}
bool isFourCard(vector<int> vv)
{
	for (int i = 0; i < 13; i++)
	{
		if (num[i] == 4)return true;
	}
	return false;
}
bool isFullhouse(vector<int> vv)
{
	for (int i = 0; i < 12; i++)
	{
		for (int j = i + 1; j < 13; j++)
		{
			if (num[i] + num[j] == 5)return true;
		}
	}
	return false;
}
bool isStraight(vector<int> vv)
{
	for (int i = 0; i < 10; i++)
	{
		int j = i % 13;
		int count = 0;
		while (num[j] == 1)
		{
			count++;
			j = (j + 1) % 13;
		}
		if (count == 5)return true;
	}
	return false;
}
bool isThreeCard(vector<int> vv)
{
	for (int i = 0; i < 13; i++)
	{
		if (num[i] == 3)return true;
	}
	return false;
}
bool isTwoPair(vector<int> vv)
{
	int count = 0;
	for (int i = 0; i < 13; i++)
	{
		if (num[i] == 2)count++;
	}
	return count == 2;
}
bool isOnePair(vector<int> vv)
{
	for (int i = 0; i < 13; i++)
	{
		if (num[i] == 2)return true;
	}
	return false;
}
string judge(vector<int> vv)
{
	if (isFourCard(vv))
	{
		return "four card";
	}
	else if (isFullhouse(vv))
	{
		return "full house";
	}
	else if (isStraight(vv))
	{
		return "straight";
	}
	else if (isThreeCard(vv))
	{
		return "three card";
	}
	else if (isTwoPair(vv))
	{
		return "two pair";
	}
	else if (isOnePair(vv))
	{
		return "one pair";
	}
	return "null";
}
int main()
{
	string s;
	while (cin >> s)
	{
		ss = split(s, ',');
		for (int i = 0; i < 14; i++)num[i] = 0;
		for (int i = 0; i < 5; i++)
		{
			stringstream str;
			str << ss[i];
			str >> vv[i];
			num[vv[i] - 1]++;
		}
		sort(vv.begin(), vv.end());
		cout << judge(vv) << endl;
	}
	return 0;
}

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

int main(void){
  string s,t; cin>>s>>t;
  if( s.length() < t.length()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  // S'文字列に既にtが含まれている場合、?を全てaに置換
  for( int i=(s.length()-t.length()); i>=0; --i){
    bool is_restorable = true;
    for( int j=0; j<t.length(); ++j){
      if( s[i+j] != t[j] ){
        is_restorable = false;
        break;
      }
    }
    if( is_restorable ){
      replace(s.begin(), s.end(), '?', 'a');
      cout << s << endl;
      return 0;
    }
  }
  // S'文字列に既にtが含まれていない場合
  for( int i=(s.length()-t.length()); i>=0; --i){
    bool is_restorable = true;
    for( int j=0; j<t.length(); ++j){
      if( s[i+j] != '?' && s[i+j] != t[j]){
        is_restorable = false;
        break;
      }
    }
    if( is_restorable ){
      for( int j=0; j<t.length(); ++j){
        s[i+j] = t[j];
      }
      replace(s.begin(), s.end(), '?', 'a');
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << 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++)
const int N = 100100;

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

  vector<int> to[N];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> ans[N];
  queue<int> que;
  que.push(1);

  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (!to[v].empty()) {
      for (int nv : to[v]) {
        if (ans[nv].empty()) {
          ans[nv].push_back(v);
          que.push(nv);
        }
      }
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for (int i = 2; i < n + 1; i++) cout << ans[i].at(0) << endl;
  return 0;
}

Measured memory_bytes: 15124
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto l = aryread();
    l.sort();
    long ans;
    foreach (i; 0 .. n)
    {
        foreach (j; i + 1 .. n)
        {
            foreach (k; j + 1 .. n)
            {
                if ((l[i] == l[j]) || (l[j] == l[k]) || (l[i] == l[k]))
                {
                    continue;
                }
                else
                {
                    if (l[i] + l[j] > l[k])
                    {
                        ans += 1;
                    }
                }
            }
        }
    }
    writeln(ans);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

ll SumXor(ll n) {
    ll now = n;
    ll res = n;

    while (now < 0 or now%4 != 0) {
        --now;
        res ^= now;
    }

    return res;
}

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

    ll A, B; cin >> A >> B;

    if (A > 0) cout << (SumXor(A-1) ^ SumXor(B)) << "\n";
    else cout << SumXor(B) << "\n";
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

char S[30], T[30];
int cnt[200];

int main() {

	scanf("%s", S);
	int n = strlen(S) - 1;
	For(i, 0, n) cnt[S[i] - 'a']++;

	if (n != 25) {
		For(j, 0, 25) if (!cnt[j]) { S[n + 1] = j + 'a'; break; }
		S[n + 2] = '\0';
	} else {
		For(i, 0, n) T[i] = S[i];
		if (!next_permutation(S, S + n + 1)) { puts("-1"); return 0; }
		For(i, 0, n) if (S[i] > T[i]) { S[i + 1] = '\0'; break; }
	}

	puts(S);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int n[3];

    cin >> n[0] >> n[1] >> n[2];

    sort(n, n + 3);

    int A = n[2];
    int B = n[1];
    int C = n[0];

    int ans;

    if ((B - C) % 2 == 0)
    {
        ans = (B - C) / 2 + (A - B);
    }
    else
    {
        ans = (int)((B - C) / 2) + (A - B) + 2;
    }

    cout << ans << endl;

    return 0;
}

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

int kmax;
int n, k;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    
    kmax = (n - 1) * (n - 2) / 2;
    if( k > kmax ){
        cout << "-1\n";
        return 0; 
    }
    
    cout << n - 1 + kmax - k << "\n";
    for(int i = 2; i <= n; i++)
        cout << "1 " << i << "\n";
    
    for(int x = 2; x <= n; x++){
        for(int y = x + 1; y <= n; y++){
            if(k == kmax)
                break;
            k++;
            cout << x << " " << y << "\n";
        }
        if(k == kmax)
            break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define inf 1<<28
using namespace std;

int main()
{

  while(1){
    int T,t[101],n,a,b;
    int d[101];
    for(int i=0;i<101;i++)d[i]=inf;
    cin>>T;
    if(T==0)break;
    for(int i=0;i<T;i++)cin>>t[i];
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      a--;
      d[a]=min(d[a],b);
    }

    int dp[101][31];
    for(int i=0;i<101;i++)for(int j=0;j<31;j++)dp[i][j]=inf;
    dp[0][0]=0;
    for(int k=0;k<100;k++){
      for(int i=0;i<T;i++){
        if(t[(i+1)%T]<=d[k+1])dp[k+1][(i+1)%T]=min(dp[k+1][(i+1)%T],dp[k][i]);
        dp[k+1][0]=min(dp[k+1][0],dp[k][i]+1);
      }
    }
    int ans=inf;
    for(int i=0;i<T;i++)ans=min(ans,dp[100][i]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int N;
int A[1050][1050];

int used[1050];

int child[1050];

int p[1050];

int sign = 0;

queue<int> Q[1050];

void UPDATE(int Z) {
	if (Q[Z].size() == 0) {
		child[Z] = 1030;
	}
	else {
		int next = Q[Z].front();
		Q[Z].pop();
		child[Z] = next;
	}
}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N - 1; j++) {
			cin >> A[i][j];
			Q[i].push(A[i][j]);
		}
	}

	for (int i = 1; i <= N; i++) {
		int y = Q[i].front();
		Q[i].pop();
		child[i] = y;
	}

	int ans = 0;

	int cnt = 0;

	while (1) {

		for (int i = 1; i <= N; i++) { used[i] = 0; }

		int sign = 0;
		for (int i = 1; i <= N; i++) {
			if (child[child[i]] == i && used[i]==0 && used[child[i]]==0) { 
				cnt++;
				int Y = child[i];
				UPDATE(Y);
				UPDATE(i);
				used[Y] = 1;
				used[i] = 1;
				sign = 1;
				}
		}

		if (sign == 0) { ans = -1; break; }

		ans++;

		if (cnt == (N*(N - 1)) / 2) { break; }

		

	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int,int>;

vector<int> bfs(const int& n, const vector<vector<int>>& g) {
    vector<int> res(n+1,-1);
    queue<P> q1;
    queue<P> q2;

    q1.emplace(1,0);
    q2.emplace(n,0);

    for (int i=0; i<n; i++) {
        while(!q1.empty() && q1.front().second == i) {
            int u,c;
            tie(u,c) = q1.front(); q1.pop();
            if (res[u] > 0) continue;
            res[u] = 1;
            for (auto v : g[u]) q1.emplace(v,c+1);
        }

        while(!q2.empty() && q2.front().second == i) {
            int u,c;
            tie(u,c) = q2.front(); q2.pop();
            if (res[u] > 0) continue;
            res[u] = 2;
            for (auto v : g[u]) q2.emplace(v,c+1);
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n+1);
    for (int i=0; i<n-1; i++) {
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> color = bfs(n,g);
    map<int,int> mp;
    for (int i=1; i<=n; i++) mp[color[i]]++;
    debug(color);

    bool ans = mp[1] > mp[2];

    cout << (ans? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n;cin>>n;
    string WorE;
    vector<ll> a(n);
    cin>>WorE;

    for(i=0;i<n;i++){
        if(WorE[i]=='W'){
            a[i]=1;
        }else{
            a[i]=0;
        }
    }

    pre_process(a,sum);//累積和の作成(wならば1)

    ll min=300001,ans;
    for(i=1;i<=n;i++){
        ans=query(0,i-1,sum)+(n-i-query(i,n,sum));//累積和で左側と右側の0 1の違いに注意して出力
        if(ans<min){min=ans;}
    }

    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 5380
package main

import (
  "fmt"
  "math"
)

func main() {
  var r int

  fmt.Scanf("%d", &r)

  ans := createAnswer(r)
  fmt.Println(ans)
}

/**
**/
func createAnswer(r int) (ans float64) {
  pi := math.Pi
  ans = float64(2) * float64(r) * pi

  return ans

}

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

int main() {
    int n, l;
    cin >> n >> l;
    string s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s, s + n);
    for (int i = 0; i < n; i++) cout << s[i];
    cout << endl;
    return 0;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    string s; cin >> s;
    int q; cin >> q;
    bool rev = false;
    deque<char> ans;
    for (auto& i : s) {
        ans.push_back(i);
    }
    s.clear();
    while (q--) {
        int t; cin >> t;
        if (t == 1) 
            rev ^= true;
        else {
            int f; cin >> f;
            char c; cin >> c;
            if (rev) {
                if (f == 1)
                    ans.push_back(c);
                else
                    ans.push_front(c);
            }
            else {
                if (f == 1)
                    ans.push_front(c);
                else
                    ans.push_back(c);
            }
        }
        // cerr << "rev = " << rev << " ans = " << ans << '\n'; 
    }
    while (!ans.empty()) {
        s.pb(ans.back());
        ans.pop_back();
    }
    if (!rev) reverse(all(s));
    cout << s << "\n";
}

Measured memory_bytes: 1168
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007

using namespace std;



int main(int argc, char* argv[])
{
    long n,k;
    char str[16]={0};
    scanf("%ld", &n);
    scanf("%s", str);
    scanf("%ld", &k);

    long i;
    for(i=0; i<n; i++) {
        if(str[i]!=str[k-1]) {
            str[i]='*';
        }
    }
    printf("%s\n", str);

    return 0;
}


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

int main()
{
	int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int s=0;
    for(int i=0;i<k;i++)
        s+=a[i];
    cout<<s;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int n, a, b, c;
std::vector<std::string> s;
std::vector<char> ans;

bool func(int t, int i, int j, int k) {
    if (t == n) return true;
    if (s[t] == "AB") {
        if (i == 0 && j == 0) return false;
        if (j > 0 && func(t + 1, i + 1, j - 1, k)) {
            ans.push_back('A');
            return true;
        }
        if (i > 0 && func(t + 1, i - 1, j + 1, k)) {
            ans.push_back('B');
            return true;
        }
    }
    if (s[t] == "BC") {
        if (j == 0 && k == 0) return false;
        if (k > 0 && func(t + 1, i, j + 1, k - 1)) {
            ans.push_back('B');
            return true;
        }
        if (j > 0 && func(t + 1, i, j - 1, k + 1)) {
            ans.push_back('C');
            return true;
        }
    }
    if (s[t] == "AC") {
        if (k == 0 && i == 0) return false;
        if (i > 0 && func(t + 1, i - 1, j, k + 1)) {
            ans.push_back('C');
            return true;
        }
        if (k > 0 && func(t + 1, i + 1, j, k - 1)) {
            ans.push_back('A');
            return true;
        }
    }
    return false;
}


int main() {
    std::cin >> n >> a >> b >> c;
    s.resize(n);
    for (int i = 0; i < n; i++) std::cin >> s[i];
    a = std::min(a, 5);
    b = std::min(b, 5);
    c = std::min(c, 5);
    bool ret = func(0, a, b, c);
    std::cout << (ret ? "Yes" : "No") << std::endl;
    if (ret) {
        std::reverse(ans.begin(), ans.end());
        for (int i = 0; i < n; i++) {
            std::cout << ans[i] << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14520
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#include <fstream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  char C[3];
  FOR(i,0,3){
    cin>>C[i];
  }
  sort(C,C+3);
  if(C[0]=='a'&&C[1]=='b'&&C[2]=='c'){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


Measured memory_bytes: 256
#n = int(input())
s = input()
#arr = list(map(int, input().split()))
#i, j = map(int, input().split())
#x, y, z = map(int, input().split())
#i, j, k , l = map(int, input().split())

if (s.isupper()):
	print('A')
else:
	print('a')

Measured memory_bytes: 9020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	if (s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int mon[2][11],y1,y2,yy,i,j,k,d1,d2;
	int n,y,m,d;
	y1=0;	y2=0;
	for(i=1;i<=10;i++)	{
		if(i%2==0)	mon[0][i]=19;
		else mon[0][i]=20;
		mon[1][i]=20;
		y1+=mon[0][i];
		y2+=mon[1][i];
	}
//	printf(" %d %d\n",y1,y2);
	scanf("%d",&n);
	d1=0;
	for(j=1;j<1000;j++)	{
		if(j%3!=0)	d1+=y1;
		else d1+=y2;
	}
	d1++;
	for(i=0;i<n;i++)	{
		scanf("%d %d %d",&y,&m,&d);
		d2=0;
		yy=y-1;
		d2=y2*(yy/3)+y1*(yy-yy/3);
		if(y%3==0)	{
			for(j=1;j<m;j++)	{
				d2+=mon[1][j];
			}
		}
		else {
			for(j=1;j<m;j++)	{
				d2+=mon[0][j];
			}
		}
		d2+=d;
		printf("%d\n",d1-d2);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll a,b,v,w,t;
  cin  >> a>> v >> b >> w >> t;
  if(v<=w){
    cout<<"NO"<<endl;
    return 0;
  }
  ll dt  = v-w;
  ll dx = abs(a-b);
  ll time = dx/dt + (dx%dt !=0);
    if(time <=t){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
    int K, S;
    int X, Y, Z;
    int res;
    cin >> K >> S;
    for(X=0; X<=K; X++){
        for(Y=0; Y<=K; Y++){
            Z=S-X-Y;
            if(0<=Z && Z<=K) res++;
        }
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 100005;
int k;
vector<ll> depth(n);
vector<vector<pp>> tree(n,vector<pp>());

void dfs(int i,int before,ll d){
  depth.at(i) = d;
  for(auto j:tree.at(i)){
    if(j.first==before) continue;
    dfs(j.first,i,d+j.second);
  }
}  
 
int main() {
  cin >> n;
  rep(i,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    --a;--b;
    tree.at(a).push_back(make_pair(b,c));
    tree.at(b).push_back(make_pair(a,c));
  }
  int q,k;
  cin >> q >> k;
  --k;
  dfs(k,-1,0);
  rep(i,q){
    int x,y;
    cin >>x >> y;
    --x;--y;
    cout << depth.at(x) + depth.at(y) << endl;
  }
  //rep(i,n) cout << depth.at(i) << endl;
  return 0;
}




Measured memory_bytes: 12800