akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
  string line;
  vector<vector<int> > d;
  int size = 0;
  while (getline(cin, line)) {
    vector<int> tmp;
    string::size_type b = 0, e = 0;
    do {
      e = line.find_first_of(",", b);
      tmp.push_back(atoi(line.substr(b, e-b).c_str()));
      b = e + 1;
    } while (e != string::npos);
    d.push_back(tmp);
    size = max(size, (int)tmp.size());
  }

  vector<vector<int> > dp(d.size()+1, vector<int>(size, 0));
  dp[0][0] = d[0][0];
  for (int i = 0; i < d.size(); ++i) {
    for (int j = 0; j < d[i].size(); ++j) {
      if (d[i].size() < d[i+1].size()) {
	dp[i+1][j] = max(dp[i+1][j], dp[i][j]+d[i+1][j]);
	dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+d[i+1][j+1]);
      } else {
	if (j-1 >= 0)
	  dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j]+d[i+1][j-1]);
	if (j < d[i+1].size())
	  dp[i+1][j] = max(dp[i+1][j], dp[i][j]+d[i+1][j]);
      }
    }
  }

  cout << dp[d.size()-1][0] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
 
 
int main() {
    int N;
    cin >> N;
    vector<string> W(N);

    for (int i = 0; i < N; i++) cin >> W[i];
    
    string ans = "Yes";
    for (int i = 0; i < N; i++) {
        if (i != 0 && W[i-1][W[i-1].size()-1] != W[i][0]) {
            ans = "No";
            break;
        }
        for (int j = 0; j < i; j++) {
            if (W[i] == W[j]) {
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b,n=map(int,input().split())
# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr
# afac=factorization(a)
# bfac=factorization(b)
# print(afac,bfac)

if b>n:
    print(math.floor(a*n/b))
    quit()
print(math.floor(a*(b-1)/b))

Measured memory_bytes: 68260
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
#ifdef _MSC_VER
    freopen("e.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    vector<pair<int, int>> sx(n), sy(m);
    for (int i = 0; i < n; i++) {
        sx[i].second = i;
    }
    for (int i = 0; i < m; i++) {
        sy[i].second = i;
    }
    set<pair<int, int>> a;
    for (int i = 0; i < c; i++) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        ++sx[x].first;
        ++sy[y].first;
        a.insert(make_pair(x, y));
    }
    sort(sx.rbegin(), sx.rend());
    sort(sy.rbegin(), sy.rend());
    int ret = 0;
    for (const auto& gx : sx) {
        for (const auto& gy : sy) {
            int d = a.count(make_pair(gx.second, gy.second));
            ret = max(ret, gx.first + gy.first - d);
            if (d == 0) {
                break;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 21968
#include<iostream>
using namespace std;
 
int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  K--;
  if (S[K] == 'A') S[K] = 'a';
  if (S[K] == 'B') S[K] = 'b';
  if (S[K] == 'C') S[K] = 'c';
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(string, s);
    int ans = INF;
    FOR(i, 1,s.size()) if(s[i-1] != s[i]) ans = min(ans, max(i, (int)s.size()-i));
    OUTL(ans==INF?s.size():ans);
RET;}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> c(n + 1);
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		c[a]++;
	}
	sort(c.rbegin(), c.rend());
	int ans = 0;
	for (int i = k; i < n; i++) {
		if (c[i] == 0)
			break;
		ans += c[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int K;
    cin >> K;
    string S;
    cin >> S;
    
    int num = 0;
    if(S.size() > K){
        num = S.size() - K;
        S.erase(K);
        S = S + "...";
    }
    
    cout << S << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
	b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
void solve()
{
// Dont apply return before taking all the input of particular test case
/* carry operation
int cr=1;
int y=k-1;
while(cr)
{
char op=str[y];
op++;
if(op<='9') cr=0;
else op='0';
str[y]=op;
y--;
}
return;
}
*/
void solve()
{
string s; cin>>s;
if(s[3]==s[2] && s[4]==s[5])
cout<<"Yes\n";
else
cout<<"No\n";
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
	int n,x;
    int l[100];
    int count = 1;
    int check = 0;

    cin >> n >> x;
    for(int i=0;i<n;i++){
       cin >> l[i];
    }
    for(int i=0;i<n;i++){
       check += l[i];
       if(check>x){
           break;
       }
      count++;
    }
    cout << count << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAXH 102
#define MAXW 102
#define MOD  100000

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

int W, H;
int dp[MAXH][MAXW][2][2];

int rec(int x, int y, int r, int d) {
  int i, nx, ny, nr;
  if(dp[y][x][r][d] != -1) return dp[y][x][r][d];
  if(x == W-1 && y == H-1) return dp[y][x][r][d] = 1;
  dp[y][x][r][d] = 0;
  for(i = 0; i < 2; ++i) {
    if(r && d != i) continue;
    nx = x + dx[i];
    ny = y + dy[i];
    nr = (d != i);
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    dp[y][x][r][d] = (dp[y][x][r][d] + rec(nx, ny, nr, i)) % MOD;
  }
  return dp[y][x][r][d];
}

int main() {
  int i, j, k, l;
  while(scanf("%d %d", &W, &H) != EOF) {
    if(W == 0 && H == 0) break;
    for(i = 0; i < H; ++i) {
      for(j = 0; j < W; ++j) {
	for(k = 0; k < 2; ++k) {
	  for(l = 0; l < 2; ++l) {
	    dp[i][j][k][l] = -1;
	  }
	}
      }
    }
    printf("%d\n", ( rec(0,0,1,0) + rec(0,0,1,1) ) % MOD);
  }
  return 0;
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int []C_array = new int [N];
       int []S_array = new int [N];
       int []F_array = new int [N];

       for(int i = 0; i < N-1; i++){
           HairetuKakunou(i,sc.nextInt(),sc.nextInt(),sc.nextInt(),C_array,S_array,F_array);
       }
       
       for(int i = 0; i < N; i++){
           int t = 0;
           for(int j = i; j < N-1; j++){
               if (t < S_array[j]){
                   t = S_array[j];
               } else if(t%F_array[j] == 0){
                   
               }else{
                   t = t + F_array[j] - t % F_array[j];
               }
               t += C_array[j];
           }
           System.out.println(t);
       }
    }
    
    private static void HairetuKakunou(int i, int C, int S, int F,int []C_array,int []S_array,int []F_array){
        C_array[i] = C;
        S_array[i] = S;
        F_array[i] = F;
    }
    
}

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

int main() {
  string s;
  int K;
  cin >> s>>K;
  int n=s.size();


  long ans1=0;
  int tmp1=999;
  string jtd1=s;
  for(int i=0;i<n-1;i++){
    if(jtd1[i]==jtd1[i+1]) {
      ans1++;
      jtd1[i+1]= tmp1%10;
      tmp1 --;
  }
}
if(K==1){
  cout<<ans1<<endl;
  return 0;
}

long ans2=0;
int tmp2=999;
string jtd2 = s+s;
int n2=jtd2.size();
for(int i=0;i<n2-1;i++){
  if(jtd2[i]==jtd2[i+1]) {
    ans2++;
    jtd2[i+1]= tmp2%10;
    tmp2 --;
}
}

if(K==2){
  cout<<ans2<<endl;
  return 0;
}

long ans3=0;
int tmp3=999;
string jtd3 = s+s+s;
int n3=jtd3.size();
for(int i=0;i<n3-1;i++){
  if(jtd3[i]==jtd3[i+1]) {
    ans3++;
    jtd3[i+1]= tmp3%10;
    tmp3 --;
}
}

if(K==3){
  cout<<ans3<<endl;
  return 0;
}

long ans4=0;
int tmp4=999;
string jtd4 = s+s+s+s;
int n4=jtd4.size();
for(int i=0;i<n4-1;i++){
  if(jtd4[i]==jtd4[i+1]) {
    ans4++;
    jtd4[i+1]= tmp4%10;
    tmp4 --;
}
}

if(K==4){
  cout<<ans4<<endl;
  return 0;
}

long d1 = ans2-ans1;
long d2 = ans3-ans2;
long d3 = ans4-ans3;

if(d1==d2) cout<<(ans2-ans1)*(K-1)+ans1<<endl;
else{
  if(K%2==1){
  long m1=d1*((K)/2);
  long m2=d2*((K)/2);
  //cout<<m1<<endl;
  //cout<<m2<<endl;
  long tans=m1+m2+ans1;
  cout<<tans<<endl;
}
else{
  long m1=d1*((K)/2);
  long m2=d2*((K-1)/2);
  cout<<m1<<endl;
  cout<<m2<<endl;
  long tans=m1+m2+ans1;
  cout<<tans<<endl;
}

}


}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

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

pub fn prime_factors(number: u128) -> HashMap<u128, u128> {
    let limit = number;
    let mut number = number; 
    let mut prime_numbers: HashMap<u128, u128> = HashMap::new();
    let mut candidate = 2;

    while number > 1 {
        if candidate * candidate > limit {
            prime_numbers.insert(limit, 1);
            return prime_numbers;
        }
        while number % candidate == 0 {
            let n = prime_numbers.entry(candidate).or_insert(0);
            *n += 1;
            number /= candidate;
        }
        candidate += 1;
    }
    return prime_numbers;
}

fn main() {
    let mut n: u128 = input();
    let prime_nums = prime_factors(n);

    // println!("{:?}", prime_nums);

    let mut ans = 0;
    for c in prime_nums.values() {
        let mut c_buf = *c;
        let mut i = 1;
        let mut count = 0;
        while c_buf >= i {
            c_buf -= i;
            i += 1;
            count += 1;
        }
        ans += count;
    }
    println!("{}", ans);
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        MSG("Possible")
    } else {
        MSG("Impossible")
    }
}


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

int main(){
	long long unsigned int a, b, r, gcd, lcm, x, y;
	while(cin >> a >> b){
		r = 1;
		x = a;
		y = b;
		while(r = x % y){
			x = y;
			y = r;
		}

		gcd = y;
		lcm = a * b / gcd;	
	
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
using ll = long long;
using namespace std;
const int AMAX = 100000;
ll cnt[AMAX + 1];
int main() {
	int N;
	ll K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		int A, B;
		cin >> A >> B;
		cnt[A] += B;
	}
	for (int ans = 1; ans <= AMAX; ++ans) {
		if (K <= cnt[ans]) {
			cout << ans << endl;
			break;
		}
		K -= cnt[ans];
	}
	return 0;
}


Measured memory_bytes: 1024
def main(input_str):
    input_list = list(input_str)
    count = 0
    if input_list[0] == "0":
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("0")
            else:
                ans.append("1")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    else:
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("1")
            else:
                ans.append("0")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    return count


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


Measured memory_bytes: 49712
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
    }

    let even = n / 2;
    let odds = n - even;
    println!("{}", odds as f64 / n as f64);
}


Measured memory_bytes: 4352
import Control.Monad
import Control.Applicative
readDigits = map read <$> words <$> getLine :: IO [Int]
main = do
    [n,m] <- readDigits
    matrix <- replicateM n $ readDigits
    vector <- replicateM m $ readLn :: IO [Int]
    putStr $ unlines [show . sum $ zipWith (*) m vector | m<-matrix]
                                                                           

Measured memory_bytes: 7452
#include<bits/stdc++.h>
#define  lnt long long int
#define dbl double
using namespace std;
//lnt arr1[300000],arr2[300000];
//vector<int> v;
//int mergesort(int a,int b)
//{
//    //cout<<a<<"asdfghjkl"<<b<<endl;
//    if(a==b)
//    {
//        return 0;
//    }
//    mergesort(a,(a+b)/2);
//    mergesort((a+b)/2+1,b);
//
//    //cout<<a<<"ab"<<b<<endl;
////    for(int i=a;i<=b;i++)
////    {
////
////        cout<<v[i]<<" ";
////    }
//    //cout<<endl;
//    int s1=a,s2 = (a+b)/2+1;
//    int l1 = (a+b)/2;
//    int l2 = b;
//    int arr1[l1-s1+1];
//    int k1 = l1-s1+1,k2 = l2-s2+1;
//    int arr2[l2-s2+1];
//
//    for(int i=s1;i<=l1;i++)
//    {
//        arr1[i-s1] = v[i];
//        //cout<<i<<":"<<i-s1;
//    }
//    //cout<<endl;
//    for(int i=s2;i<=l2;i++)
//    {
//        //cout<<i<<":"<<i-s2;
//        arr2[i-s2] = v[i];
//    }
//    //cout<<endl;
//    int i;
//    s1=0;s2=0;
//    for(i=a;i<=b;i++)
//    {
//        if(s1>=k1||s2>=k2)
//        {
//            break;
//        }
//        //cout<<"11111";
//        if(arr1[s1]<arr2[s2])
//        {
//            v[i]=arr1[s1];
//            s1++;
//        }
//        else
//        {
//            v[i]=arr2[s2];
//            s2++;
//        }
//        //cout<<v[i]<<" ";
//
//    }
//    for(int j=s1;j<k1;j++)
//    {
//        v[i]=arr1[j];
//        i++;
//        //cout<<v[i]<<" ";
//
//
//    }
//    for(int j=s2;j<k2;j++)
//    {
//        v[i]=arr2[j];
//        i++;
//        //cout<<v[i]<<" ";
//    }
//    //cout<<endl;
//}
lnt ch[1000000]={0};
lnt check[1000000]={0};
map<lnt,vector<lnt> > m;
lnt c[1000000];
lnt ans=0;

int main()
{
    lnt n;
    cin>>n;
    queue <lnt> q;

    vector< pair<lnt,lnt> > v;
    for(lnt i=0;i<n-1;i++)
    {
        lnt a,b;
        cin>>a>>b;
        a--;
        b--;

        m[a].push_back(b);
        m[b].push_back(a);
        v.push_back(make_pair(a,b));

    }

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

        cin>>c[i];
    }

    sort(c,c+n);
    lnt valc[n]={0};
    lnt f=0;
    for(int i=0;i<n-1;i++)
    {

        ans+=c[i];


    }
    lnt s[n]={0};
    ch[0]=1;
    q.push(0);
    lnt y=n-1;
    while(q.size()!=0)
    {

        int w=q.front();
        //cout<<w<<endl;
        s[w] = c[y];
        y--;
        q.pop();
        for(int j=0;j<m[w].size();j++)
        {
            if(ch[m[w][j]]==0)
            q.push(m[w][j]);
            ch[m[w][j]]=1;
        }
    }

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



}


Measured memory_bytes: 6012
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod= 998244353;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

ll n,sum,a[N],m;
int main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
    ll c=0;
    for(int i=1;i<=n;i++) {
        if(a[i]*4*m>=sum) c++;
    }
    if(c>=m) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
using llong = long long;

llong n, k;
llong a[16];

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

    llong ans = 1ll << 60ll;
    for (int i = 0; i < (1 << n); i++) {
        bitset<16> s(i);
        if (s.count() < k) continue;

        llong x = 0;
        llong maxv = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] && a[j] <= maxv) {
                x += maxv - a[j] + 1;
                maxv += 1;
            }
            else {
                maxv = max(maxv, a[j]);
            }
        }

        ans = min(ans, x);
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
  char b;
  scanf("%c",&b);
  
  if(b=='A'){
    b='T';
  }else if(b=='T'){
    b='A';
  }else if(b=='C'){
    b='G';
  }else{
    b='C';
  }
  
  printf("%c\n",b);
  
  return 0;
}

Measured memory_bytes: 256
s = input()

s_ = s[:len(s)//2]
_s = s[1+len(s)//2:]

if s_ != _s:
  print('No')
  quit()


if (len(s)//2)%2==0:
  a = s_[:len(s_)//2]
  b = s_[len(s_)//2:][::-1]
  c = _s[:len(_s)//2]
  d = _s[len(_s)//2:][::-1]
  # print(a,b,c,d)
  if a == b:
    if c == d:
      print('Yes')
      quit()

  print('No')

if (len(s)//2)%2==1:
  a = s_[:len(s_)//2]
  b = s_[1+len(s_)//2:][::-1]
  c = _s[:len(_s)//2]
  d = _s[1+len(_s)//2:][::-1]
  # print(a,b,c,d)
  if a == b:
    if c == d:
      print('Yes')
      quit()

  print('No')

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
 
main(){	
	int x1,x2,x3,x4,y1,y2,y3,y4;
 
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	
	printf("%d\t%d\t%d\t%d",x2-y2+y1,y2+x2-x1,x1-y2+y1,y1+x2-x1);
	
}

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

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << " " << max(0, a+b - n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> b;
  tools::read(b, N);

  for (i64 i = 0; i < N; ++i) {
    if (b[i] > i + 1) goto FAILED;
  }

  {
    std::list<i64> answers;
    for (const i64& b_i : b) {
      answers.insert(std::next(answers.begin(), b_i - 1), b_i);
    }

    for (const i64& answer : answers) {
      std::cout << answer << std::endl;
    }
  }
  return 0;

FAILED:
  std::cout << -1 << std::endl;
  return 0;
}

Measured memory_bytes: 256
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))

m = {'a': sa, 'b': sb, 'c': sc}
ans = {'a': 'A', 'b': 'B', 'c': 'C'}
turn = 'a'
while True:
  if len(m[turn]) == 0:
    break
  next_turn = m[turn][0]
  next_l = m[turn][1:]
  m[turn] = next_l
  turn = next_turn
print(ans[turn])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,ww;
int w[105],v[105];
int dp[110][110][305];
int w1;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n>>ww;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	w1=w[1];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			for(int mov=0;mov<=3*i;mov++)
			{
				if(j>=1&&mov>=w[i]-w[1])
				    dp[i][j][mov]=max(dp[i-1][j][mov],dp[i-1][j-1][mov-w[i]+w[1]]+v[i]);
				else dp[i][j][mov]=dp[i-1][j][mov];
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=3*n;j++)
		{
			long long we=(long long)i*w[1]+j;
			if(we<=ww)ans=max(ans,dp[n][i][j]);
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end()
#define chmin(x, y) x = min(x, y) 
using namespace std;
//using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));
const int INF = 1001001001;

//関数：
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N, M, L;
	cin >> N >> M >> L;
	vvec dist(N, vec(N, INF));
	rep(i, N) dist[i][i] = 0;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		dist[a][b] = dist[b][a] = c;
	}

	rep(k, N)rep(i, N)rep(j, N) chmin(dist[i][j], dist[i][k]+dist[k][j]);

	vvec dist2(N, vec(N, INF));
	rep(i, N) dist2[i][i] = 0;
	rep(i, N)rep(j, N) {
		if(dist[i][j] <= L) dist2[i][j] = 1;
	}

	rep(k, N)rep(i, N)rep(j, N) chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);

	int Q; cin >> Q;
	rep(i, Q) {
		int s, t; cin >> s >> t;
		--s; --t;
		int ans = dist2[s][t] - 1;
		if(dist2[s][t] == INF) ans = -1;
		cout << ans << endl;
	}
	return 0;
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k;
    cin >> n >> k;
    int a[n];
    input(a,n);
    int dp[n+1];
    memset(dp,0,sizeof(0));
    dp[n]=0;
    dp[n-1]=abs(a[n-2]-a[n-1]);
    for(int i=n-2;i>0;i--){
      dp[i]=INT_MAX;
      for(int j=i+1;j<=i+k&j<=n;j++)
        dp[i]=min(dp[i],dp[j]+abs(a[j-1]-a[i-1]));
    }
    cout << dp[1] ;
}

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

int main(){
  deque<char> s;
  string ss; cin >> ss;
  rep(i,ss.size()) s.push_back(ss.at(i));
  int q; cin >> q;

  bool sento = 0; //0なら順1なら逆

  rep(i,q) {
    int  t; cin >> t;
    if(t == 1) sento = !sento;
    if(t == 2) {
      int f; cin >> f;
      char c; cin >> c;

      if(!sento) {
        if(f == 1) s.push_front(c);
        if(f == 2) s.push_back(c);
      }else {
        if(f == 2) s.push_front(c);
        if(f == 1) s.push_back(c);
      }
    }
  }

  if(sento) reverse(s.begin(), s.end());

  string sss;
  for(char p : s) sss.push_back(p); 
  cout << sss << endl;
}



Measured memory_bytes: 1412
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=int(np.sum((A>>i)&1))
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)

Measured memory_bytes: 68848
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

//171B

int main(){
    string s,t;
    cin>>s>>t;
    int a=0;

    rep(i,s.length()){
        if(s[i]==t[i]){
            a++;
        }
    }
    cout<<s.length()-a<<endl;
}

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

using namespace std;

#define ll long long

void solve() {
    ll n;
    cin >> n;
    string a[n];
    for (ll i = 0; i < n; ++i) cin >> a[i];
    vector <vector <vector <ll> > > cnt(10, vector <vector <ll> > (19, vector <ll> (19)));
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll val = 0;
        int cntz = 0;
        if (a[i].find('.') != string::npos) {
            cntz = a[i].size() - 1 - a[i].find('.');
        }
        ll st = 1;
        for (int j = a[i].size() - 1; j >= 0; --j) {
            if (a[i][j] == '.') continue;
            val += st * (a[i][j] - '0');
            st *= 10;
        }
        int c2 = 0, c5 = 0;
        while (val % 2 == 0) {
            val /= 2;
            ++c2;
        }
        while (val % 5 == 0) {
            val /= 5;
            ++c5;
        }
        ++cnt[cntz][min(18, c2)][min(18, c5)];
    }
    for (int i = 0; i < 10; ++i) {
        for (int i1 = 0; i1 < 10; ++i1) {
            for (int j = 0; j < 19; ++j) {
                for (int j1 = 0; j1 < 19; ++j1) {
                    for (int k = 0; k < 19; ++k) {
                        for (int k1 = 0; k1 < 19; ++k1) {
                            if (i + i1 <= min(j + j1, k + k1)) {
                                if (i == i1 && j == j1 && k == k1) {
                                    ans += cnt[i][j][k] * (cnt[i][j][k] - 1);
                                }
                                else {
                                    ans += cnt[i][j][k] * cnt[i1][j1][k1];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans / 2;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 9948
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;
LL A[5];

int main()
{
	scanf("%lld %lld %lld", &A[0], &A[1], &A[2]);
	sort(A, A + 3);

	if (A[0] % 2 == 0 || A[1] % 2 == 0 || A[2] % 2 == 0) printf("0\n");
	else {
		printf("%lld\n", A[0] * A[1]);
	}
	
	return 0;
}


Measured memory_bytes: 256
solve :: [(String, Int)] -> [(String, Int)]
solve existList = filter (\x -> x `notElem` existList) allList
	where
		allList = [(suit, num) | suit <- ["S", "H", "C", "D"], num <- [1..13]]

myPut :: [(String, Int)] -> IO ()
myPut ansList = do
	putStr $ unlines . map unwords . map (\(a,b) -> [a, show b]) $ ansList

main = do
	_ <- getLine
	text <- getContents
	myPut $ solve $ map (\[a,b] -> (a, read b :: Int)) . map words . lines $ text

Measured memory_bytes: 3972
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;

#define MAX 25

class Task{
public:
  int d, lim;
  Task(int d=0, int lim=0): d(d), lim(lim){}
  bool operator < ( const Task &t) const{
    if ( lim == t.lim ) return d < t.d;
    return lim < t.lim;
  }
};

main(){
  int n;
  Task T[MAX];
  while( cin >> n && n ){
    assert( 1 <= n && n <= 25 );
    for ( int i = 0; i < n; i++ ){
      cin >> T[i].d >> T[i].lim;
      assert( 1 <= T[i].d  && T[i].d <= 100);
      assert( 1 <= T[i].lim  && T[i].lim <= 365);
    }
    sort( T, T + n );
    bool success = true;
    int cur = 0;
    for ( int i = 0;  i < n; i++ ){
      cur += T[i].d;
      if ( T[i].lim < cur ) success = false;
    }
    if ( success ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; ++i)

int main() {
    vector<int> flightTime(3);
    rep(i, 3) cin >> flightTime[i];
    sort(flightTime.begin(), flightTime.end(), less<int>());

    cout << flightTime[0] + flightTime[1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		
		if(y%2==0 && 2*x<=y && y<=4*x) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 35672
<?php
list($a,$b,$C)=explode(' ',trim(fgets(STDIN)));
$c=deg2rad($C);
$h=$b*sin($c);

echo $a*$h/2
,PHP_EOL
,$a+$b+sqrt(pow($a-$b*cos($c),2)+pow($h,2))
,PHP_EOL
,$h
;

Measured memory_bytes: 15648
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=0
for i in range(1,n+1):
    x=n//i
    ans+=i*x*(x+1)//2
print(ans)

    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 67064
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 1000010
#define MAX_V 900010
using namespace std;
ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(n+1-i)*inv[i]%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
main(){
    string s,t;
    cin>>s>>t;
    int a[N]={},b[N]={};
    rep(i,s.size()){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }
    sort(a,a+26);
    sort(b,b+26);
    bool flag=true;
    rep(i,26){
        if(a[i]!=b[i])flag=false;
    }
    cout<<(flag?"Yes":"No");
}

Measured memory_bytes: 8584
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL color[SIZE][11][2];
LL c[SIZE];
LL solve2() {
	EFOR(me, 1, N) {
		REP(i, 10) {
			for (auto you : edges[me]) {
				MX(color[me][i][1], color[you][i + 1][0]);
			}
		}

	}
	EFOR(me, 1, N) {
		REP(i, 11) {
			MX(color[me][i][0], color[me][i][1]);
	//		cout << me << " " << i << " " << color[me][i][0] << endl;
		}

	}
	return 0;
}
LL solve() {
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		edges[a].pb(b);
		edges[b].pb(a);

	}
	cin >> Q;
	EFOR(i, 1, Q) {
		int v, d;
		cin >> v >> d >> c[i];
		color[v][d][0] = i;
	}
	REP(i, 12) {
		solve2();
	}
	EFOR(i, 1, N) {
		LL ans = 0;
		REP(j, 11) MX(ans, color[i][j][0]);
	//	cout << ans << endl;
		cout << c[ans] << endl;
	}

	return	0;
}





//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 39028
#include<iostream>
#include<string>
#include<algorithm>
#define MAXN 200001
using namespace std;
typedef long long ll;

int N;
char a[MAXN];
int ans,tmp;
int center;
int l, rw, rb;
string pre, sur;
bool flg;

void changeCenter() {

}

int main() {
	cin >> N;

	//白の数
	l = 0;
	rw = 0;
	rb = 0;
	flg = false;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] == '.') {
			if (flg) {
				rw++;
				if (rw >= rb) {
					center = i;
					l += rb;
					rb = 0;
					rw = 0;
					flg = false;
				}
			}
		}
		else {
			rb++;
			if (!flg) {
				center = i;
				flg = true;
			}
		}

	}


	cout << l+rw << endl;
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define x first
#define y second
const int N = 1001;

vector<pair<int,int> > vp[2][2];
int n;
pair<int,int> po[N];
int ds(int x, int y){
	return x*x + y*y;
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		cin >> po[i].x >> po[i].y;
		vp[po[i].x <= 0][po[i].y <= 0].push_back(po[i]);
	}
	pair<int,int> rec = {0, 0};
	for(int i = 0 ; i < 2 ; i ++)
		for(int j = 0 ; j < 2 ; j ++){
			int _x = 0, _y = 0;
			for(pair<int,int> px: vp[i][j])
				_x += px.x, _y += px.y;
			if(ds(_x, _y) > ds(rec.x, rec.y)) rec = {_x, _y};
		}
	srand(time(NULL));
	int test = 300000;
	while(test --){
		random_shuffle(po, po + n);
		int _x = 0, _y = 0;
		for(int i = 0 ; i < n ; i ++)
			if(ds(_x + po[i].x, _y + po[i].y) > ds(_x, _y))
				_x += po[i].x, _y += po[i].y;
		if(ds(_x, _y) > ds(rec.x, rec.y)) rec = {_x, _y};
	}
	cout << setprecision(14) << sqrt(rec.x*rec.x + rec.y*rec.y) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(15);

    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    F0R(i,n+1)
        cin >> a[i];
    F0R(i,n)
        cin >> b[i];
    ll tot=0;
    F0R(i,n)
    {
        // cout << "i: " << i << endl;
        if(a[i]<b[i])
        {
            b[i]-=a[i];
            tot+=a[i];
            a[i]=0;
        }
        else
        {
            a[i]-=b[i];
            tot+=b[i];
            b[i]=0;
        }
        // cout << "REACHED HERE" << endl;
        if(b[i]>0)
        {
            // cout << a[i+1] << " " << b[i] << endl;
            if(b[i]>a[i+1])
            {
                b[i]-=a[i+1];
                tot+=a[i+1];
                a[i+1]=0;
            }
            else
            {
                a[i+1]-=b[i];
                tot+=b[i];
                b[i]=0;
            }
        }
    }
    cout << tot << endl;
        
    return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"

using namespace std;
typedef long long ll;


int power_int(int a, int b)
{
  int x = 1;
  while (b > 0)
  {
    x *= a;
    b--;
  }
  return x;
}

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n + 1; i++)
  {
    string s = to_string(i);
    int size = s.size();
    bool ch3 = false;
    bool ch5 = false;
    bool ch7 = false;
    bool ch0 = true;
    for (int k = 0; k < size; k++)
    {
      if (s[k] == '1' || s[k] == '2' || s[k] == '4' || s[k] == '6' || s[k] == '8' || s[k] == '9')
      {
        i += power_int(10, size - 1 - k);
        i = min(i, n);
      }
    }
    s = to_string(i);
    size = s.size();
    for (int j = 0; j < size; j++)
    {
      if (s[j] == '3')
      {
        ch3 = true;
      }
      else
      if (s[j] == '5')
      {
        ch5 = true;
      }
      else
      if (s[j] == '7')
      {
        ch7 = true;
      }
      else
      {
        ch0 = false;
        break;
      }
    }
    if (ch3 && ch5 && ch7 && ch0)
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

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

int main() {
	int a,b,p=0;
	cin>>a>>b;
	if(a>b)
	p=a+a-1;
	else if(b>a) p=b+b-1;
	else p=2*a;
	cout<<p;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <array>
#include <string>
#include <map>
#include <cmath>
//#include <iomainp>
using namespace std;

#define DB(x)
#define rep(i, n) for(int i = 0;i < n;i++)


int getIntSp(){
    string str;
    getline(cin,str,' ');
    return stoi(str);
}

int getIntLF(){
    string str;
    getline(cin,str);
    return stoi(str);
}



int main()
{
    int N;
    cin >> N;
    vector<int> vec;
    rep(i,N){
        int a;
        cin >> a;
        vec.push_back(a);
    }
    
    int counter = 1;
    int num = 0;
    rep(i,vec.size()){
        if(vec[i] != counter){
            num++;
        }else{
            counter++;
        }
    }
    if( 0 == vec.size() - num ){
        cout << -1 << endl;
    }else{
        cout << num << endl;
    }
    return 0;
}




Measured memory_bytes: 1400
#include <stdio.h>

int main() {
  char s[4];
  scanf("%s", s);

  if(s[0] == s[1] && s[1] != s[2] && s[0] != s[2]) puts("Yes");

  else if(s[0] != s[1] && s[1] != s[2] && s[0] == s[2]) puts("Yes");

  else if(s[0] != s[1] && s[1] == s[2] && s[0] != s[2]) puts("Yes");

  else puts("No");

  return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll solve(vector<ll>a,bool flag){
  ll ret = 0;
  ll cur = 0;
  for(int i = 0; i < n; i++, flag ^= 1){
    cur += a[i];
    if(flag){
      if(cur >= 0){
        int tmp = cur + 1;
        cur = -1;
        ret += tmp;
      }
    }
    else{
      if(cur <= 0){
        int tmp = abs(cur) + 1;
        cur = 1;
        ret += tmp;
      }
    }

  }
return ret;
}
int main(){
  cin >> n;
  vector<ll>a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  cout << min(solve(a,0), solve(a,1)) << endl;




}


Measured memory_bytes: 2560
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

constexpr ll MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  VI as(n), bs(m);
  FOR(a,as) {
    cin >> a;
  }
  FOR(b,bs) {
    cin >> b;
  }
  VI popa(n * m + 1, 0), popb(n * m + 1, 0);
  FOR(a,as) {
    popa[a]++;
  }
  FOR(b,bs) {
    popb[b]++;
  }
  ll ans = 1;
  ll useda = 0;
  ll usedb = 0;
  for(int i = n * m; i > 0; i--) {
    if (popa[i] > 1 || popb[i] > 1) {
      ans = 0;
      break;
    }
    if (popa[i] == 1) {
      useda++;
      if (popb[i] == 1) {
        usedb++;
      } else {
        ans = (ans * usedb) % MOD;
      }
    } else {
      if (popb[i] == 1) {
        usedb++;
        ans = (ans * useda) % MOD;
      } else {
        ll space = useda * usedb;
        ll cap = space - (n * m - i);
        if (cap <= 0) {
          ans = 0;
          break;
        }
        ans = (ans * cap) % MOD;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
    #include<string.h>
     
    int main(void){
      
      long long int t = 0;
      long long int a = 0;
      long long int k = 0;
      
      scanf("%ld %ld %ld",&t,&a,&k);
      
      if(k<t)
        printf("%ld %ld",t-k,a);
      else if((k-t)<a){
        printf("%ld %ld",0,a-(k-t));
      }
      else
        printf("0 0");
     
      return 0;
    }

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==1 && b==0 && c==0){
        cout << "Close" << endl;
    }
    else if(a==0 && b==1 && c==0){
        cout << "Close" << endl;
    }
    else if(a==1 && b==1 && c==0){
        cout << "Open" << endl;
    }
    else if(a==0 && b==0 && c==1){
        cout << "Open" << endl;
    }
    else if(a==0 && b==0 && c==0){
        cout << "Close" << endl;
    }
}


Measured memory_bytes: 3104
def main():
	s = input()
	cnt = 0
	prev =0
	ans = 0
	i = len(s)-1
	while i>=0:
		if s[i]=='C' and s[i-1]=='B':
			cnt = cnt+1
			i = i-2
		else:
			if s[i]=='A':
				ans = ans+cnt
			else:
				cnt = 0
			i = i-1
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 73292