akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

template<typename T>
inline int cmin(T &x, T y) {
	return x > y ? x = y, 1 : 0;
}

const int MAXN = 1009, MAXW = 5009;

int n, w[MAXN];
struct Edge { 
	int ver, nxt; 
} e[MAXN];
int head[MAXN], tot = 0;

inline void Add(int x, int y) {
	e[++tot].ver = y, e[tot].nxt = head[x], head[x] = tot;
}

int f[MAXN], g[MAXW];

void Dfs(int x) {
	for (int i = head[x]; i; i = e[i].nxt) {
		int y = e[i].ver;
		Dfs(y); // 要先知道所有儿子节点的信息 
	}
	
	memset(g, 0x3f, sizeof g);
	g[0] = 0;
	for (int i = head[x]; i; i = e[i].nxt) {
		int y = e[i].ver;
		for (int j = w[x]; ~j; --j) {
			int trans = INF; // 特判 j = 0 的情况 
			if (j >= w[y])
				cmin(trans, g[j - w[y]] + f[y]);
			if (j >= f[y])
				cmin(trans, g[j - f[y]] + w[y]);
			g[j] = trans;
		}
	}
	for (int i = 0; i <= w[x]; ++i)
		cmin(f[x], g[i]);
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		int f;
		scanf("%d", &f);
		Add(f, i);
	}
	for (int i = 1; i <= n; ++i)
		scanf("%d", &w[i]); 

	memset(f, 0x3f, sizeof f);

	Dfs(1);

	puts(f[1] == INF ? "IMPOSSIBLE" : "POSSIBLE");

	return 0;
}

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

int main() {
	int answer = 1000;
	string s, t;
	cin >> s >> t;
	for (int i = 0, moves; (i + t.size() - 1) < s.size(); ++i) {
		moves = 0;
		for (int j = 0; j < t.size(); ++j) {
			if (s[i + j] != t[j])
				++moves;
		}
		if (answer > moves)
			answer = moves;
	}
	cout << answer << endl;
	return 0;
}


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

struct word{
	char s[32];
	int count;
	int appear;
};
struct word w[1000];
void init(int i)
{
	w[i].appear = 0;

}
void appear(int i)
{
	for(int l=0;l<i;l++){
		bool flag = false;
		if(w[i].s[0]==w[l].s[0]){
			flag = true;
			for(int m=1;m<32;m++){
				if(w[i].s[m]!=w[l].s[m])
					flag = false;
			}
		}
		if(flag)
			w[i].appear++;
	}
}
void l(int i)
{
	for(int l=0;l<32;l++){
		if(w[i].s[l] != 0)
			w[i].count++;
	}
}
int main()
{
	int i=0;
	while(cin >> w[i].s){
		init(i);
		appear(i);
		l(i);
		i++;
	}
	int remi=0,remj=0;
	for(int j=1;j<i;j++){
		if(w[j].appear>w[remi].appear)
			remi = j;
		if(w[j].count>w[remj].count)
			remj = j;
	}
	cout << w[remi].s << " " << w[remj].s << endl;
	return 0;
}

Measured memory_bytes: 0
import sys
from string import digits

def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    place = dict((i, list()) for i in digits)
    for i in range(n):
        place[s[i]].append(i)

    l = [None] * n
    l[0] = set()
    for i in range(1, n):
        l[i] = l[i-1] | set([s[i-1]])
    
    r = [None] * n
    r[n-1] = set()
    for i in range(n-2, -1, -1):
        r[i] = r[i+1] | set([s[i+1]])

    res = set()
    for j in digits:
        p = place[j]
        if not p:
            continue
        for i in digits:
            for k in digits:
                for c in p:
                    if not k in r[c]:
                        break
                    if not i in l[c]:
                        continue
                    res.add((i, j, k))
                    break
    print(len(res))

if __name__ == '__main__':
    main()

Measured memory_bytes: 49652
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jan 12 21:01:44 2019
//
package main

import (
	"fmt"
	"sort"
)

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	no1, no2, no3 := 0, 0, 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		if B < a {
			no3++
		} else if A < a {
			no2++
		} else {
			no1++
		}
	}

	fmt.Println(min(no1, no2, no3))
}


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

int main(){
  int n;
  cin >> n;
  int abNum = 0;
  int aNum = 0;
  int bNum = 0;
  int mNum = 0;
  for(int i=0; i<n; i++){
    string str;
    cin >> str;
    for(int j=0; j<str.length()-1; j++){
      if(str[j] == 'A' && str[j+1] == 'B') abNum++;
    }
    if(str[0] == 'B' && str[str.length()-1] == 'A') mNum++;
    else if(str[str.length()-1] == 'A') aNum++;
    else if(str[0] == 'B') bNum++;
  }
  if(n == 1) cout << abNum << endl;
  else{
    if(aNum != 0 || bNum != 0){
      cout << abNum + min(aNum, bNum) + mNum << endl;
    }else{
      if(mNum != 0) cout << abNum + mNum - 1 << endl;
      else cout << abNum << endl;
    }
  }
  return 0;
}
  

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


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

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

	return 0;
}


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

using namespace std;

int main() {

	long n,m;
	cin >> n >> m;

	vector<vector<long>> a(n, vector<long>(2));
	vector<vector<long>> c(m, vector<long>(2));

	for (long i = 0; i < n; i++) {
		cin >> a[i][0] >> a[i][1];
	}
	for (long i = 0; i < m; i++) {
		cin >> c[i][0] >> c[i][1];
	}

	for (long i = 0; i < n; i++) {
		long mindis = 1000000000;
		long cp = 0;
		for (long j = 0; j < m; j++) {
			if (abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])<mindis) {
				mindis = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]);
				cp = j + 1;
			}
		}
		cout << cp << endl;
	}

	return 0;

}

Measured memory_bytes: 256
use std::io;


fn main() {
    let (a, b, c, d) = {
        let i = read::<usize>();
        (i[0], i[1], i[2], i[3])
    };

    if a + b < c + d { println!("Right"); }
    else if a + b > c + d { println!("Left"); }
    else { println!("Balanced"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
string a, d = "";
cin >> a;
char b = a[0];
for (auto c : a){
if (c != b){
d += c;
b = c;
}
}
cout << d.length() + 1 << "\n";
return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n%2){
        n--;
        cout << n*(n-1)/2 - n/2 + n << "\n";
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                if(i+j==n-1) continue;
                cout << i+1 << " " << j+1 << "\n";
            }
        }
        for(int i = 0; i < n; i++) {
            cout << n+1 << " " << i+1 << "\n";
        }
    }
    else{
        cout << n*(n-1)/2 - n/2 << "\n";
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                if(i+j==n-1) continue;
                cout << i+1 << " " << j+1 << "\n";
            }
        }
    }



    return 0;
}

Measured memory_bytes: 3620
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): #高速素因数分解 m[n]=nを割ることの出来る最小の素数
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): #b[n]=nを割ることの出来る最小の素数　の配列を生成　エラトステネスの篩
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    count=0
    for i in range(1,n):
        count+=(n-1)//i
    print(count)





if __name__ == "__main__":

    main()


Measured memory_bytes: 72904
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
#define int ll
#define el '\n'
template<class T> bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<pii>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n; cin>>n;
int ans=0,p=1e9;
for(int i=1;i<n;++i){
	int t; cin>>t;
	ans+=min(t,p);
	p=t;
}
ans+=p;
cout<<ans<<el;

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
int A[20], B[20],C[20];
int main(void){
    cin >> N;
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N-1) cin >> C[i];

    int res = 0, b = -1;
    REP(i,N){
        res += B[i];
        if(A[i] - b == 1) res += C[b-1];
        b = A[i];
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
(N, K, Q) = map(int, input().split())
A = []
for _ in range(Q):
  A.append(int(input()))

l = K-Q
points = [l for _ in range(N)]
for a in A:
  points[a-1] += 1
  
for k in ["Yes" if point>0 else "No" for point in points ]:
  print(k)

Measured memory_bytes: 11240
program main
  implicit none
  integer(8) :: ab, i
  character(6) :: sa, sb, sab
  read(*, *) sa, sb
  sab = trim(sa) // trim(sb)
  read(sab, *) ab
  ! do i = 1, 1000
  !   if (i * i == ab) then
  !     write(*, "(a)") "Yes"
  !     stop 0
  !   end if
  ! end do
  ! write(*, "(a)") "No"
  if (nint(ab ** 0.5_8) ** 2 == ab) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
end program main


Measured memory_bytes: 256
from collections import Counter

while True:
    n , x = map(int,input().split())
    qq = []
    ans = 0
    if n==0 and x==0:
        break
    else:
        for i in range(1,min(n+1,x+1)):
            for j in range(1,i):
                if i != j:
                    for k in range(1,j):
                        if j != k and i+j+k == x:
                            ans += 1
    print(ans)


Measured memory_bytes: 5996
#include <stdio.h>

int A[500000];
int h; /* ヒープサイズ */

void maxHeapify(int*, int);
void buildMaxHeap(int*);

int main()
{
  int i,key;
  
  scanf("%d",&h); /* ヒープのサイズ */

  /* 初期化 */
  for(i = 0;i < h+1;i++){
    A[i] = -2000000001;
  }

  /* とりあえず、配列Aに値を入れる */
  for(i = 1;i < h+1; i++){
    scanf("%d",&key);
    A[i] = key;
  }

  buildMaxHeap(A);

  /* 出力 */
  for(i = 1;i < h+1;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int *A,int i)
{
  int l,r,largest,tmp;

  l = 2*i;
  r = 2*i+1;

  /* 左の子、自分、右の子で値が最大のノードを選ぶ */
  if(l <= h && A[l] > A[i]) largest = l; /* 左の子が自分より大きい場合 */
  else largest = i; /* 自分が左の子より大きい場合 */

  if(r <= h && A[r] > A[largest]) largest = r; /* 右の子がlargestより大きい場合 */
  
  if(largest != i){ // iの子の方が値が大きい場合
    tmp = A[i];     // A[i]とA[largest]を交換
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest); //再帰的に呼び出し
  }
}

void buildMaxHeap(int *A)
{
  int i;
  for(i = h/2 ;i >= 1; i--){
    maxHeapify(A,i);
  }
}

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

int main(){
    double H,W,N,M;
    cin >> H >> W >> N;
    M = max(H, W);
    H = ceil(N/M);
    cout << H << endl;
}



Measured memory_bytes: 256
N, M = map(int,input().split())
MOD = 10**9 + 7
if abs(N - M) > 1: ans = 0
else:
    if N == M:
        ans = 2
    else: ans = 1
    for i in range(1, M+1):
        ans *= i
        ans %= MOD
    for i in range(1, N+1):
        ans *= i
        ans %= MOD
print(ans)   

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


// 素数判定O(√n)
bool is_prime(int n){
  for (int i=2; i*i<=n; i++) if (n%i==0) return false;
  return n != 1;
}

// 約数の列挙O(√n)
vector<int> divisor(int n){
  vector<int> res;
  for (int i=1; i*i<=n; i++){ if (n%i==0){ res.push_back(i); if (i != n/i) res.push_back(n/i); } }
  return res;
}

// 素因数分解O(√n)
void prime_factor(int n, map<int,int> &res){
  for (int i=2; i*i<=n; i++){ while (n%i==0){ res[i]++; n/=i; } }
  if (n!=1) res[n]+=1;
}

int main() {
  int n; cin >>n;
  map<int, int> factor;
  rep(i, n) prime_factor(i+1, factor);
  ll res = 1;
  for (auto p : factor){
    res = res * (p.second + 1) % MOD;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin

FORMAT = ('node {0.id}: parent = {0.parent}, depth = {0.depth},'
          ' {0.kind}, {0.childs}').format


class Node(object):
    def __init__(self, node):
        self.depth = 0
        self.parent = -1
        self.id = node[0]
        self.degree = node[1]
        self.kind = 'internal node' if node[1] else 'leaf'
        self.childs = node[2:]

    def __str__(self):
        return FORMAT(self)


def calc_depth(tree, i):
    for j in tree[i].childs:
        tree[j].depth += 1
        calc_depth(tree, j)


n = int(stdin.readline())
tree = [-1] * n
#assert 1 <= n <= 100000
for _ in range(n):
    node = Node([int(s) for s in stdin.readline().split()])
    i = node.id
    node.parent = tree[i]
    for j in node.childs:
        if isinstance(tree[j], int):
            tree[j] = i
        else:
            tree[j].parent = i
    tree[i] = node

for i in range(n):
    calc_depth(tree, i)

for i, node in enumerate(tree):
    if node.parent == -1:
        node.kind = 'root'
    print(node)

Measured memory_bytes: 138968
# -*- coding: utf-8 -*-
N,T = map(int,input().split())

ret = 10**5
for _ in range(N):
    c,t = map(int, input().split())
    if t<=T:
        ret = min(ret, c)

if ret==10**5:
    print("TLE")
else:
    print(ret)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

int main()
{
  int n;
  cin >> n;
  if (n % 1000 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1000 - n % 1000 << endl;
  }
  return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n,k;
    cin >> n>>k;
    vector<int> d(10);
    //int min_d = 10,max_d=0,min_d_not_zero=10;
    REP(i, k) {
        int x;
        cin >> x;
        d[x] = 1;
    }
    string ans="";

    FOR(num,n,100000){
        string s = to_string(num);
        //cout << s << "\n";

        REP(i,SZ(s)){
            int x = s[i] - '0';
            if(d[x]==1){
                break;
            }
            if(i==SZ(s)-1){
                cout << s << "\n";
                return 0;
            }
        }
    }

    cout << "a" << "\n";
    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++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int N;
    cin >> N;
    double balance;
    for (int i=0; i<N; i++){
        double x;
        string u;
        cin >> x >> u;

        if (u=="BTC"){
            balance += x*380000.0;
        }
        else balance += x;
    }
    cout << balance << endl;
}

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

int main(){
    int n;
    cin >> n;
    ll t[n],a[n];
    for(int i = 0;i < n;i ++){
        cin >> t[i] >> a[i];
        if(i && (t[i]<t[i-1] || a[i]<a[i-1])){
            ll x = max((t[i-1]/t[i]+min((ll)1,t[i-1]%t[i])),(a[i-1]/a[i]+min((ll)1,a[i-1]%a[i])));
            t[i] *= x;
            a[i] *= x;
        }
    }
    cout << t[n-1]+a[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  string a,b;
  cin>>a>>b;
  cout << (a[0]==b[0]) + (a[1]==b[1]) + (a[2]==b[2]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
ll a,b,c; 
int main(){
// 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c;
	ll s = (c - b - a);
	if(s>=0 && s * s > 4 * a * b) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

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

int main()
{
  string N;

  cin >> N;

  int sum = 0;

  for (int i = 0; i < N.length(); i++)
  {
    sum += N.at(i) - '0';
  }

  if (sum % 9 == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3720
#include<stdio.h>

int main(){
  long int a[5],n,i,min=1000000000000000;
  scanf("%ld\n",&n);
  for(i=0;i<5;i++){
    scanf("%ld\n",&a[i]);
    if(a[i]<min){
      min=a[i];
    }
  }
  printf("%ld",(n-1)/min+5);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
struct edge{int t,ne;}e[N];
int head[N],cnt,f[N],n,m,xx=1,yy,fa[N],col[N],sum[N],inc[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
void adde(int a,int b){
	e[++cnt]=(edge){b,head[a]};head[a]=cnt;
}
void dfs(int x,int f){
	sum[x]=col[x]=-col[f];fa[x]=f;
	run(x)if(v!=f)dfs(v,x),sum[x]+=sum[v];
}
int main(){
	read(n,m);
	rep(i,1,n)f[i]=i;
	rep(i,1,m){
		int x,y;read(x,y);
		if(getf(x)!=getf(y))f[getf(x)]=getf(y);else{
			xx=x;yy=y;continue;
		}
		adde(x,y);adde(y,x);
	}col[0]=-1;
	dfs(xx,0);
	ll ans=0;
	if(yy==0){
		if(sum[xx])return puts("-1"),0;
		rep(i,1,n)ans+=abs(sum[i]);
		return printf("%lld\n",ans),0;
	}
	vector<int>cir;
	for(int i=yy;i;i=fa[i])cir.pb(sum[i]),inc[i]=1;
	///
	if(cir.size()&1){
		if(sum[xx]&1)return puts("-1"),0;
		rep(i,1,n)if(inc[i])ans+=abs(sum[i]-sum[xx]/2);else ans+=abs(sum[i]);
		return printf("%lld\n",ans),0;
	}
	if(sum[xx])return puts("-1"),0;
	sort(cir.begin(),cir.end());
	rep(i,1,n)if(inc[i])ans+=abs(sum[i]-cir[cir.size()/2]);else ans+=abs(sum[i]);
	printf("%lld\n",ans);
}

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

using namespace std;
int main()
{
  int n,a[100],flag=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }

  for(int i=0;i<n;i++)
  {
      if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0)
      {
          flag=1;
          break;
      }

  }
  if(flag==1)
    cout<<"DENIED";
  else
    cout<<"APPROVED";

   return 0;
}






Measured memory_bytes: 3544
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;

int main()
{
    string st;
    cin >> st;
    int sl=0;
    int l = 0;
    int r = st.length()-1;
    bool kt = true;

    while (l < r)
    {
      if (st[l] == 'x' && st[r] != 'x')
      {
           l++;
           sl++;
      }
      else
      if (st[l]!= 'x' && st[r] == 'x')
      {
          r--;
          sl++;
      }
      else
      if (st[l] == st[r])
      {
          l++;
          r--;
      }
      else
        {
          kt = false;
          break;
        }
    }
    if (kt==false) cout << -1;
    else cout << sl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmax(T& a,const T b){if(a<b)a=b;}
char name[105][40],sname[105][40];
int se[105],ss[105],e[105],s[105];
int dp[2][1005][3][105];
int Limit,N,M,X;
int main()
{
	while(1)
	{
		scanf("%d %d %d %d",&Limit,&N,&M,&X);
		if(Limit==0&&N==0&&M==0&&X==0)break;
		for(int i=0;i<N;i++)scanf("%s %d %d",sname[i],&se[i],&ss[i]);
		for(int i=0;i<M;i++)scanf("%s %d %d",name[i],&e[i],&s[i]);
		memset(dp,-1,sizeof(dp));
		dp[0][0][0][0]=0;
		int ans=0;
		for(int i=0;i<N+M;i++)
		{
			memset(dp[(i+1)%2],-1,sizeof(dp[(i+1)%2]));
			for(int j=0;j<=Limit;j++)
			{
				if(i<N)
				{
					for(int k=0;k<3;k++)
					{
						if(dp[i%2][j][k][0]==-1)continue;
						chmax(dp[(i+1)%2][j][k][0],dp[i%2][j][k][0]);
						if(j+se[i]>Limit||k>=2)continue;
						chmax(dp[(i+1)%2][j+se[i]][k+1][0],dp[i%2][j][k][0]+ss[i]);
					}
				}
				else
				{
					int idx=i-N;
					for(int k=1;k<3;k++)
					{
						for(int l=0;l<=M;l++)
						{
							if(dp[i%2][j][k][l]==-1)continue;
							chmax(dp[(i+1)%2][j][k][l],dp[i%2][j][k][l]);
							if(j+e[idx]>Limit||l>=M)continue;
							chmax(dp[(i+1)%2][j+e[idx]][k][l+1],dp[i%2][j][k][l]+s[idx]);
						}
					}
				}
			}
		}
		for(int j=0;j<=Limit;j++)
		{
			for(int k=1;k<3;k++)
			{
				for(int l=X;l<=M;l++)
				{
					chmax(ans,dp[(N+M)%2][j][k][l]);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vector<ll> a(n), sum(n+1);
    rep(i, 0, n) cin >> a[i];
    sum[0] = 0;
    rep(i, 0, n) sum[i+1] = sum[i] + a[i];
    ll ans = 0;
    map<ll, ll> mem;
    rep(i, 0, n+1) {
        ans += mem[sum[i]];
        mem[sum[i]]++;
    }
    cout << ans << endl;
    return 0;   
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){

  string a,b;
  cin >> a >> b;
    bool ans = false;
 for(int i = 0; i < a.size(); i++){
    if(a == b){
        ans = true;
        break;
    }
    a = a.back()+a.substr(0,a.size()-1);
    //cout << a << endl;
 }
 if(ans)cout << "Yes" << endl;
 else cout << "No" << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x,y,x1;
    int j=0;
    int N;
    cin >> x >> y;
     N=x;
     x=4*x;
    for(int i=0;i<N+1;i++){
     x1=x-2*i;
      if(x1==y){
        cout << "Yes" << endl;
        j=1;
    }
    }
    if(j!=1)cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

bool h[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, M;
  cin >> N >> M;

  ll H[N + 1];
  for (ll i = 1; i <= N; i++) {
    cin >> H[i];
  }

  ll A, B;
  for (ll i = 0; i < M; i++) {
    cin >> A >> B;

    if (H[A] == H[B]) {

      h[A] = true;
      h[B] = true;
      continue;
    }
    if (H[A] < H[B]) {
      h[A] = true;
    }
    if (H[A] > H[B]) {
      h[B] = true;
    }
  }

  ll c = 0;
  for (ll i = 1; i <= N; i++) {
    if (!h[i])
      c++;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 4520
use std::io;
use std::str::FromStr;

struct Remark {
    person: u64,
    honest: bool
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let n: usize = input();
    let mut remarks: Vec<Vec<Remark>> = Vec::new();

    for _ in 0..n {
        remarks.push(Vec::new());
    }

    for i in 0..n {
        let a: usize = input();
        for _ in 0..a {
            let (person, honest)= input_tuple();
            remarks[i].push(Remark {person: person - 1, honest: honest == 1});
        }
    }

    let mut max = 0;
    for bit in 0..1<<n {
        let mut honests: Vec<usize> = Vec::new();
        let mut not_honests: Vec<usize> = Vec::new();
        for i in 0..n {
            if bit & (1<<i) != 0 {
                honests.push(i);
            } else {
                not_honests.push(i);
            }
        }
        let mut valid = true;
        for honest in &honests {
            let mut flag = true;
            for remark in &remarks[*honest] {
                if remark.honest {
                    if not_honests.contains(&(remark.person as usize)) {
                        flag = false;
                    }
                } else {
                    if honests.contains(&(remark.person as usize)) {
                        flag = false;
                    }
                }
            }
            if !flag {
                valid = false;
                break;
            }
        }
        if valid {
            if honests.len() > max {
                max = honests.len();
            }
        }
    }
    println!("{}", max);
}


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

using namespace std;

struct UF
{
	UF *parent;
	long rank, b;
	UF() :parent(nullptr), rank(1), b(0) {}
	UF &Find() {
		if (parent == nullptr)
			return *this;
		return *(parent = &parent->Find());
	}
	int Union(UF &n) {
		auto &r = Find(), &nr = n.Find();
		if (&r == &nr) return 0;
		if (r.rank < nr.rank) r.parent = &nr, nr.rank += r.rank, nr.b += r.b;
		else nr.parent = &r, r.rank += nr.rank, r.b += nr.b;
		return -1;
	}
} u[444][444];
int main() {
	int h, w;
	cin >> h >> w;
	string s[444];
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (int j = 0; j < w; j++)
			if (s[i][j] == '#')
				u[i][j].b = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i&&s[i][j] != s[i - 1][j])
				u[i][j].Union(u[i - 1][j]);
			if (j&&s[i][j] != s[i][j - 1])
				u[i][j].Union(u[i][j - 1]);
		}
	}
	set<UF *> a;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			a.insert(&u[i][j].Find());
	long r = 0;
	for (auto p : a)
		r += p->b*(p->rank - p->b);
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    scanf("%lld",&a)
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;	//dung trong sai so
ll const Base=1e9+7;
ll arr[1000000],mark[1000000];

ll Solves(){
	//INPUT;
	ll n,k,cnt=0,ans=0,x,a,b,c;
	// PROCESSING IN HERE
	sc2(arr[0],arr[1]); sc(arr[2]);
	if(arr[0]&1 or arr[1]&1 or arr[2]&1)re cout<<0,0;
	
	fu(i,1,5e7){
		a=arr[1]/2+arr[2]/2;
		b=arr[0]/2+arr[2]/2;
		c=arr[0]/2+ arr[1]/2;
		arr[0]=a; arr[1]=b; arr[2]=c;
		if(arr[0]&1 or arr[1]&1 or arr[2]&1)re cout<<i,0;
	}
	cout<<-1;
	re 0;
}


int main(){
	Solves();
}

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

const int MOD = 1000000007;
const int INF = 1000000007;
const int N = 200002;
const int logN = 20;

int n, m, k;

int main() {
  cin >> n >> m >> k;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (i*(m-j) + j*(n-i) == k) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}

//1 3 3 4 4 6 100 200


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

int main(void){
  ll A, B;
  cin >> A >> B;

  // B-A+1 = 0 (mod 4)
  //  -> Aが偶数
  //  -> Aが奇数
  // B-A+1 = 1 (mod 4)
  //  -> Aが偶数
  //  -> Aが奇数

  ll pc = B-A+1;
  ll ret = 0;
  if(pc%4 == 0){
    if(A%2==0) ret = 0;
    else ret ^= A^(B-2)^(B-1)^B;
  }else if(pc%4 == 1){
    if(A%2==0) ret ^= B;
    else ret ^= A;
  }else if(pc%4 == 2){
    if(A%2==0) ret ^= (B-1)^B;
    else ret ^= A^B;
  }else if(pc%4 == 3){
    if(A%2==0) ret ^= (B-2)^(B-1)^B;
    else ret ^= A^(B-1)^B;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
     
int main() {
  int N;
  std::cin >> N;
     
  std::cout << "?";
  for(int i = 0; i < N; i++){
    std::cout << " " << i + 1;
  }
  std::cout << std::endl;

  std::string s1;
  std::cin >> s1;
     
  int st = 0;
  int dr = N;
  while(dr > st+1) {
    int mij = (st + dr) / 2;
     
    std::cout << "?";
    for(int i = 0; i < N; i++){
      std::cout << " " << mij + i + 1;
    }
    std::cout << std::endl;
     
    std::string s2;
    std::cin >> s2;
    if (s1 == s2) {
      st = mij;
    } else {
      dr = mij;
    }
  }
     
  std::vector<int> Red(2 * N, -10);
  Red[st] = (s1 == "Red");
  Red[st + N] = !Red[st];
     
  std::string si = "?";
  std::string so = "?";
  for(int i = 0; i < 2*N; i++){
    if(i == st || i == st + N) continue;

    if(st < i && i < st + N) {
      si = si + " " + std::to_string(i + 1);
    } 
    else {
      so = so + " " + std::to_string(i + 1);
    }
  }
     
  for(int i = 0; i < 2*N; i++){
    if(i == st || i == st + N) continue;

    if(st < i && i < st + N) {
      std::cout << so;
    } 
    else {
      std::cout << si;
    }

    std::cout << " " << i + 1 << std::endl;
     
    std::string s1;
    std::cin >> s1;
    if(s1 == "Red"){
      Red[i] = 1;
    }
    else{
      Red[i] = 0;
    }
  }
     
  std::cout << "! ";
  for(int i = 0; i < 2*N; i++){
    if(Red[i]){
      std::cout << "R";
    }
    else{
      std::cout << "B";
    }
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k;
        return 0;
    }    
    if(k<=(a+b)){
        cout<<a;
        return 0;
    }
    else{
        ll x = k-a-b;
        cout<<a-x;
    }

    return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int> ite(n);

    for(int i=0; i<n; i++)cin>>ite[i];

    int sum =0;

    sort(ite.begin(),ite.end());

    for(int i=0; i<n; i++){ 

        if(i==n-1) sum += (ite[i] / 2);

        else sum += ite[i];
    }

    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 256
## main

n = gets.strip.to_i

name = gets.strip
nmlen = name.length
nm0 = name[0]
nm1 = name[1]

count = 0

n.times do
  old = gets.strip
  olen = old.length
  found = false

  for i in (0...olen)
    next if old[i] != nm0

    for j in ((i + 1)...olen)
      next if old[j] != nm1

      d = j - i
      found = true

      for k in (2...nmlen)
        if old[i + d * k] != name[k]
          found = false
          break
        end
      end

      if found
        count += 1
        break
      end
    end

    break if found
  end
end

puts count

Measured memory_bytes: 6112
#include <stdio.h>
int main(void)
{
int n, x;
int i = 1;

scanf("%d",&n);

while(n >= i){

if(i % 3 == 0 || i % 10 == 3)
   printf(" %d",i);

else if(i / 10){
   x = i / 10;
   while(x){
     if(x % 10 == 3){
     printf(" %d",i);
     break;
     }
     else
     x /= 10;
     }
   }
i++;
}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include<iostream>

using namespace std;

int main(){
  string S;

  cin >> S;

  int a[26]; 
  for(int i = 0 ; i < 26 ; i++ )
    a[i] = 0;
  
  for(int i = 0 ; i < S.size() ; i++ ){
    //cout << int(S[i]) - 97 << endl;
    a[int(S[i]) - 97 ]++;
  }
  
  for(int i = 0 ; i < 25 ; i++){
    if(a[i] > 1){
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
l = gets.chomp.split
n.times do |i|
    l[i] = l[i].to_i
end

if n >= 3
    l.sort!
    count = 0
    combis = l.combination(3).to_a
    combis.each do |combi|
        next if combi.uniq.count != 3
        a = combi[0]
        b = combi[1]
        c = combi[2]
        count += 1 if a + b > c && b + c > a && c + a > b
    end
    puts count
else
    puts 0
end


Measured memory_bytes: 29796
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int keta(int n);

int main()
{
	int i=0,count=0;
	int a[1000],b[1000],c[1000];
	int answer[1000];
	while(1){
		if(scanf("%d %d",&a[i],&b[i])==EOF){
			break;
		}
		c[i]=a[i]+b[i];
		answer[i]=keta(c[i]);
		i++;
		count++;
	}
	for(i=0; i<count; i++){
		printf("%d\n",answer[i]);
	}
	return 0;
}

int keta(int n)
{
	int result=0;
	if(n==0){
		return 1;
	}
	while(n!=0){
		n/=10;
		result++;
	}
	return result;
}

Measured memory_bytes: 612
#include <iostream>

using namespace std;

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

    int R[n];
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }
    int max_R = 1;
    int max_val = 1 - 1e9;

    for (int i = n - 2; i >= 0; i--) {
        if (R[i+1] > max_R) max_R = R[i+1];
        int val = max_R - R[i];
        if (val > max_val) max_val = val;
    }

    cout << max_val << endl;

    return 0;
}

Measured memory_bytes: 3888
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(std::string S){
  int ret = 0;
  for (int i = 0; i < S.size()/2; i++) {
    if (S[i] != S[S.size()-1-i]) {
      ret++;
    }
  }
  std::cout << ret << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

struct Card {char suit, value;};

void bubble(struct Card A[],int N){
	for(int i=0;i<N;i++){
		for(int j=N-1;j>=i;j--){
			if(A[j].value<A[j-1].value){
				Card t=A[j]; A[j]=A[j-1]; A[j-1]=t;
			}
		}
	}
}

void selection(struct Card A[],int N){
	for(int i=0;i<N;i++){
		int minj=i;
		for(int j=i;j<N;j++){
			if(A[j].value<A[minj].value) minj=j;
		}
		Card t=A[i]; A[i]=A[minj]; A[minj]=t;
	}
}

void print(struct Card A[],int N){
	for(int i=0;i<N;i++){
		if(i) cout<<" ";
		cout<<A[i].suit<<A[i].value;
	}
	cout<<endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
	for(int i=0;i<N;i++){
		if(C1[i].suit!=C2[i].suit) return false;
	}
	return true;
}

int main(){
	Card C1[100],C2[100];
	int N;
	
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>C1[i].suit>>C1[i].value;
		C2[i]=C1[i];
	}
	
	bubble(C1,N);
	selection(C2,N);
	
	print(C1,N);
	cout<<"Stable"<<endl;
	print(C2,N);
	if(isStable(C1,C2,N)){
		cout<<"Stable"<<endl;
	}else{
		cout<<"Not stable"<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3104
N = int(input())

keys = [i for i in range(1, N+1)]
values = [0] * N
count_dict = dict(zip(keys, values))

for x in range(1, 110):
    for y in range(x, 110):
        for z in range(y, 110):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n > N:
                break
            if x == y and y == z:
                count_dict[n] += 1
            elif x != y and x != z and y != z:
                count_dict[n] += 6
            else:
                count_dict[n] += 3

for v in count_dict.values():
    print(v)

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


int main(){
    int K; string S; cin >> K >> S;
    int N = S.size();
    rep(i, min(K, N)){
        cout << S[i];
    }
    if(S.size()>K){
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll K, A, B, ans;
  cin >> K >> A >> B;
  if (A + 2 >= B || K < A) {
    ans = K + 1;
  } else {
    K -= A - 1;
    ans = A + (B - A) * (K / 2) + K % 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
typedef int64_t ll;
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; }




int main() {
	string S, T; cin >> S >> T;
	bool ans = false;
	for (int i = 0; i < S.size(); i++)
	{
		if (S == T) {
			ans = true;
			break;
		}
		S = S.back() + S.substr(0, S.size() - 1);
	}
	if (ans)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> D(K);

	for (int i = 0; i < K; i++) {
		cin >> D.at(i);
	}

	int ans = N;
	bool cdt = false;

	while (!cdt) {
		cdt = true;
		for (int i = 0; i < K; i++) {
			int a = ans;
			while (a > 0) {
				if (a % 10 == D.at(i)) cdt = false;
				a /= 10;
			}
		}
		ans++;
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 256