akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     // static int dx[]={1,-1,0,0};
     //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

    //  int n=sc.nextInt();  
    // int n=sc.nextInt(), m=sc.nextInt();  
    // int h=sc.nextInt();  
    long h=sc.nextLong();
    long w=sc.nextLong();
    long ans=1L<<61;

    if(h%3==0 || w%3==0){
        ans=0;
    }
    else{
        long x=h/2,y=h/2;
        if(h%2==1)x++;
        if(h>1)for( int i=1; i<w; i++ ){
            long d[]={ i*h ,(w-i)*x,(w-i)*y};
            sort(d);
            ans=min(ans, d[2]-d[0]);
            d[0] = i*h;
            d[1] = (w-i)/2 * h;
            d[2] = (w-i)/2 * h;
            if((w-i)%2==1)d[1] = (1 + (w-i)/2 )* h; 
            sort(d);
            ans=min(ans, d[2]-d[0]);
               
        }

        x=w/2; y=w/2;
        if(w>1)if(w%2==1)x++;
        for( int i=1; i<h; i++ ){
            long d[]={ i*w ,(h-i)*x,(h-i)*y};
            sort(d);
            ans=min(ans, d[2]-d[0]);
            d[0] = i*w;
            d[1] = (h-i)/2 * w;
            d[2] = (h-i)/2 * w;
            if((h-i)%2==1)d[1] = (1 + (h-i)/2) * w;
            sort(d);
            ans=min(ans, d[2]-d[0]);
        }
    }


    out.println(ans);
    out.flush();
}

static void rep(int x, long d){

}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 30420
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)

long long find(long long a,long long x){
	if(a==-1)return 0;
	return a/x+1;
}

int main(){
	long long a,b,x;
	cin>>a>>b>>x;
	
				
	cout<<find(b,x)-find(a-1,x)<<endl;
	
	
	
	
	return 0;
}


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

int main() {
  int N,K,A;
  map<int,int> balls;
  cin >> N >> K;
  for(int i=0; i<N ; i++){
    cin >> A;
    if(balls[A]==0) balls[A] = 1;
    else balls[A]++;
  }
  if(balls.size() <= K){
    cout << 0 << endl;
    return 0;
  }
  
  int vbal[balls.size()];
  int i=0;
  for(auto iter=balls.begin(); iter != balls.end(); iter++){
    vbal[i]=iter->second;
    i++;
  }
  sort(vbal, vbal+i);
  int ans=0;
  for(int j=0; j<i-K; j++){
     ans = ans + vbal[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    string s;
    R(s);
    int v=0;
    REP(i,SZ(s)){
        v+=(s[i]-'0');
    }
    W(v%9?"No":"Yes");
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3852
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())

ans = 0
for i in range(n - 1):
    d, m = divmod(aaa[i], 2)
    ans += d
    if m and aaa[i + 1]:
        aaa[i + 1] -= 1
        ans += 1
ans += aaa[-1] // 2
print(ans)


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = stdIn.nextInt();
			sum += W[i];
		}
		int min = sum;
		
		for(int i = 0; i < N; i++) {
			int sum1 = 0;
			for(int j = 0; j <= i; j++) {
				sum1 += W[j];
			}
			if(Math.abs(sum1-(sum-sum1)) < min) {
				min = Math.abs(sum1-(sum-sum1));
			}
		}
		System.out.println(min);

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    vector<pair<int ,int>> p(n);
    int a, b;
    rep(i, n){
        cin >> a >> b;
        p[i].second = a;
        p[i].first = b;
    }
    Sort(p);
    int t = 0;
    bool flag = true;
    rep(i, n){
        t += p[i].second;
        if(t > p[i].first) flag = false;
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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


const int mod = 1e+9 + 7;

int main()
{
    int N;
    string S1, S2;
    cin >> N;
    cin >> S1 >> S2; 

    /* |--
     * |--  なら *2 通り 
     * || 
     * ||   なら *2 通り
     * ----
     * ---- なら *3 通り
     * --|
     * --|  なら *1 通り
     */
    long ans;
    int i = 0;
    bool vertical;  // 前のドミノが縦向きに置かれているかどうか
    if( S1[i] == S1[i+1] ) ans = 6, vertical = false, i = 2;
    else                   ans = 3, vertical = true,  i = 1;
    
    for( int j = i; j < N; ++j ){
        if( vertical ){  // 前のドミノが | と置かれているとき
                         //            |
            ans *= 2;
            if( S1[j] == S1[j+1] && j+1 < N ) vertical = false, ++j;
            else                              vertical = true;
        }else{           // 前のドミノが -- と置かれているとき
            if( S1[j] == S1[j+1] && j+1 < N ) ans *= 3, vertical = false, ++j;
            else                              ans *= 1, vertical = true;   
        }
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, 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
#main code here!
    #https://note.nkmk.me/python-union-find/

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
    
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n,m=MI()
    uf=UnionFind(n)
    for i in range(m):
        a,b=MI()
        a-=1
        b-=1
        uf.union(a,b)
    ans=0
    for x in uf.roots():
        ans=max(ans,uf.size(x))
    print(ans)
        
            
        
if __name__=="__main__":
    main()


Measured memory_bytes: 83044
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingQueue;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		LinkedBlockingQueue<Integer> cards = new LinkedBlockingQueue<Integer>();
		for (int i = 1; i <= n * 2; i++)
			cards.offer(i);
		int m = sc.nextInt();
		for (int i = 0; i < m; i++)
		{
			int k = sc.nextInt();
			if (k == 0)
			{
				Integer tmp[] = new Integer[n*2];
				tmp = (Integer[]) cards.toArray(tmp);
				cards.clear();
				for (int j = 0; j < n; j++)
				{
					cards.offer(tmp[j]);
					cards.offer(tmp[j+n]);
				}
			}
			else
			{
				for (int j = 0; j < k; j++)
				{
					int a = cards.poll();
					cards.offer(a);
				}
			}
		}
		for (int i = 0; i < n * 2; i++)
		{
			System.out.println(cards.poll());
		}
	}
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int ans = 1;
    ans *= k;
    for(int i=1;i<n;i++){
        ans*=k-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 06.07.2020 09:33:31       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  cout << 15 - a - b - c - d - e << '\n';
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x=0;
    string s;
    cin>>n>>s;
    int max=0;
    for (int i=0;i<n;i++) {
        if (s.at(i)=='I') {
            x++;
        } else {
            x--;
        }
        if (x>max) {
            max=x;
        }
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
/* ex4_2
	kanon */

#include <stdio.h>
#include <math.h>

int main(void)
{

    //与えられる値を入れる数を宣言
    double length_a,length_b,hour,minute;

    //変数に値を入力する
    scanf("%lf %lf %lf %lf",&length_a,&length_b,&hour,&minute);
  
    //radianの計算
    double radian=(hour+minute/60)*(360/12)-minute*(360/60);
    radian/=180;
    radian*=M_PI;
  	//余弦定理を行う
    double ans=pow(length_a,2)+pow(length_b,2)-2*length_a*length_b*cos(radian);
    ans=sqrt(ans);

    printf("%.10lf",ans);

    return 0;
}


Measured memory_bytes: 2508
{-# LANGUAGE RankNTypes #-}
    
import Control.Monad.State
import Control.Monad.ST
import Data.Array.ST
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S

main :: IO ()
main = readLine >>= main'
    where
        main' [n, m] = replicateM m (head <$> readLine) >>= print . solve n

solve :: Int -> [Int] -> Int
solve n as = runST (initialize >>= stAction)
    where
        initialize :: ST s (Table s Int a)
        initialize = newArray (0, n + 2) Nothing

        s = S.fromList as
        
        stAction = evalMemo calc 0

        calc f i
            | i > n = return 0
            | i == n = return 1 
            | S.member i s = return 0
            | otherwise = add <$> f (i + 1) <*> f (i + 2)

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

infixl 6 `add`
infixl 7 `mul`

add :: Int -> Int -> Int
add x y = val $ x + y

mul :: Int -> Int -> Int
mul x y = val $ x * y

inv :: Int -> Int
inv x = pow x $ modVal - 2

pow :: Int -> Int -> Int
pow b e
    | e == 0 = 1
    | odd e = mul b . pow b $ e - 1
    | otherwise = mul v v
    where
        v = pow b $ e `div` 2

val :: Int -> Int
val = (`mod` modVal)

modVal :: Int
modVal = 10 ^ 9 + 7

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)
        
isPrime :: Int -> Bool
isPrime n = check primes
    where
        check (x : xs)
            | x == n = True
            | x > n = False
            | otherwise = check xs

type Table s a b = STArray s a (Maybe b)
type Memo s a b = a -> StateT (Table s a b) (ST s) b

evalMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s b
evalMemo f k = evalStateT (memoizeFix f k)

runMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s (b, Table s a b)
runMemo f k = runStateT (memoizeFix f k)

memoizeFix :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> forall s. Memo s a b
memoizeFix f k = get >>= (\arr -> lift (readArray arr k) >>= maybe (f (memoizeFix f) k >>= ((<$) <*> (lift . writeArray arr k . Just))) return)

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

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

    int A[N + 2];
    A[0] = A[N + 1] = 0;
    for (unsigned int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    unsigned int total_price = 0;
    for (unsigned int i = 0; i < N + 1; ++i) {
        total_price += abs(A[i + 1] - A[i]);
    }

    for (unsigned int i = 1; i <= N; ++i) {
        unsigned int reduced_price_i = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]) - abs(A[i + 1] - A[i - 1]);
        unsigned int total_price_i = total_price - reduced_price_i;
        cout << total_price_i << "\n";
    }

    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
    int A;
    int B;
    int coin;
    int i;

    scanf("%d %d", &A, &B);

    coin = 0;
    for(i = 0; i < 2; i++) {
    if(A >= B) {
        coin += A;
        A -= 1;
    } else {
        coin += B;
        B -=1;
    }
    }

    printf("%d\n", coin);

    return 0;
}

Measured memory_bytes: 128
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> V(N), C(N), total(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    rep(i, N) total[i] = V[i] - C[i];
    sort(All(total),greater<int>());
    int ans = 0;
    rep(i,N) ans += ((total[i]>0)? total[i]:0);
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
num = list(map(int,input().split()))

target = num[0]
kosuu = num[1]
ans = target

if(kosuu != 0):
    forbidden = sorted(list(map(int,input().split())))

    for i in range(kosuu+1):
        upper = target + i
        lower = target - i
        if not lower in forbidden:
            ans = lower
            break
        if not upper in forbidden:
            ans = upper
            break

print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> v[100001];
int dist[100001];
bool visited[100001];
void dfs(int u){
	if(visited[u]) return;
	visited[u]=true;
	for(int i=0;i<v[u].size();i++){
		if(!visited[v[u][i].first]){
			dist[v[u][i].first]=dist[u]+v[u][i].second;
			dfs(v[u][i].first);
		}
	}
}
int main() {
	memset(visited,false,sizeof(visited));
	int n;
	cin>>n;
	vector<int> poss;
	for(int i=0;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		z=z%2;
		poss.push_back(i+1);
		v[x].push_back(make_pair(y,z));
		v[y].push_back(make_pair(x,z));
	}
	dfs(1);
	int color[n+1];
	memset(color,0,sizeof(color));
	for(int i=1;i<=n;i++){
		if(dist[i]%2==0) color[i]=1;
	}
	for(int i=1;i<=n;i++) cout<<color[i]<<'\n';
}

Measured memory_bytes: 8824
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	vector<pair<int, int>> task;
	int n;
	cin >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		task.emplace_back(b, a);
	}
	sort(All(task));
	int sum = 0;
	bool flag = true;
	for (auto v : task) {
		sum += v.second;
		if (sum > v.first) {
			flag = false;
			break;
		}
	}
	if (flag)cout << "Yes";
	else { cout << "No"; }
	ed;
	return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

const int kMaxN = 100;

int N;
char S[kMaxN];
string ans;

int main() {
  cin >> N;
  REP(i, N) { cin >> S[i]; }

  ans = "Three";
  REP(i, N) {
    if (S[i] == 'Y') {
      ans = "Four";
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

vector<edge> G[101];
bool isUsed[101];

void solve()
{
	int n;
	cin >> n;
	vector< vector<int> > data((n), vector<int>(n));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			int c;
			cin >> data[i][j];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			if (data[i][j] != -1)
			{
				edge e1, e2;
				e1.to = j;
				e1.cost = data[i][j];
				e2.to = i;
				e2.cost = data[j][i];
				G[i].push_back(e1);
				G[j].push_back(e2);
			}
		}
	}
	memset(isUsed, 0, sizeof(isUsed));
	int ans = 0;
	priority_queue < P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		if (isUsed[v])
		{
			continue;
		}
		isUsed[v] = true;
		ans += p.first;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			pque.push(P(e.cost, e.to));
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1484
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

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

  if( b - a == c - b ){
cout << "YES" << endl;
  }else{
cout << "NO" << endl;
  }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		Map<Integer,Integer> map = new HashMap<>();
		for(int i = 0;i < N;i++) {
			map.put(i+1, A[i]);
		}
		Map<Integer,Integer> resultMap = map.entrySet().stream()
				.sorted(Map.Entry.<Integer,Integer>comparingByValue())
				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,(e1,e2)->e1,LinkedHashMap::new));
		for(Map.Entry<Integer, Integer> sorted : resultMap.entrySet()) {
			System.out.print(sorted.getKey() + " ");
		}
	}
}

Measured memory_bytes: 73176
import math
n = int(input())
sosu = {2:0, 3:0, 5:0, 7:0, 11:0, 13:0, 17:0, 19:0, 23:0, 29:0, 31:0, 37:0, 41:0, 43:0, 47:0, 53:0, 59:0, 61:0, 67:0, 71:0, 73:0, 79:0, 83:0, 89:0, 97:0, 101:0, 103:0, 107:0, 109:0, 113:0, 127:0, 131:0, 137:0, 139:0, 149:0, 151:0, 157:0, 163:0, 167:0, 173:0, 179:0, 181:0, 191:0, 193:0, 197:0, 199:0, 211:0, 223:0, 227:0, 229:0, 233:0, 239:0,241:0, 251:0, 257:0, 263:0, 269:0, 271:0, 277:0, 281:0, 283:0, 293:0, 307:0, 311:0, 313:0, 317:0, 331:0, 337:0, 347:0, 349:0, 353:0, 359:0, 367:0, 373:0, 379:0, 383:0, 389:0, 397:0, 401:0, 409:0, 419:0, 421:0, 431:0, 433:0, 439:0, 443:0, 449:0, 457:0, 461:0, 463:0, 467:0, 479:0, 487:0, 491:0, 499:0, 503:0, 509:0, 521:0, 523:0, 541:0, 547:0, 557:0, 563:0, 569:0, 571:0, 577:0, 587:0, 593:0, 599:0, 601:0, 607:0, 613:0, 617:0, 619:0, 631:0, 641:0, 643:0, 647:0, 653:0, 659:0, 661:0, 673:0, 677:0, 683:0, 691:0, 701:0, 709:0, 719:0, 727:0, 733:0, 739:0, 743:0, 751:0, 757:0, 761:0, 769:0, 773:0, 787:0, 797:0, 809:0, 811:0, 821:0, 823:0, 827:0, 829:0, 839:0, 853:0, 857:0, 859:0, 863:0, 877:0, 881:0, 883:0, 887:0, 907:0, 911:0, 919:0, 929:0, 937:0, 941:0, 947:0, 953:0, 967:0, 971:0, 977:0, 983:0, 991:0, 997:0}
for i in range(2, n + 1):
    k = i
    for j in sosu:
        while k % j == 0:
            sosu[j] += 1
            k //= j
        if k == 1:
            continue
ans = 1
for i in sosu:
    ans = ans * (sosu[i] + 1) % (10**9 + 7)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626

 using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;




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

void swap(int &a,int &b){
    int temp = a;
    a = b;
    b = temp;
}

long long binpow(unsigned long long a, unsigned long long b,
                 unsigned long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}


int main(){
   // std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vi arr(n);
    scanVec(arr,n);
    int rsum = 0;
    for(auto it : arr){
      rsum+=it;
    }
    int ans = INF;
    int lsum = 0;
    for(int i = 0;i < n;i++){
      lsum+=arr[i];
      rsum-= arr[i];
      ans = min(ans,abs(rsum - lsum));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int c1,c5,c10,c50,c100,c500;
        cin>>c1>>c5>>c10>>c50>>c100>>c500;
        if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
                cout<<"1"<<endl;
        }
        else{
                cout<<"0"<<endl;
        }
        return 0;
}

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

int main()
{
  int X,N;
  cin >> X >> N;
  if(N == 0) cout << X << endl;
  else{
    vector<int> p(N);
    for(int i = 0;i < N;i++){
      cin >> p[i];
    }
    bool count = false;
    for(int i = 0;i < 100;i++){
      for(int j = 0;j <= 1;j++){
        int z = X - i*pow(-1,j);
        bool ans = true;
        for(int l = 0;l < N;l++){
          if(z == p[l]){
            ans = false;
          }
        }
        if(ans){
          cout << z << endl;
          count = true;
          break;
        }
      }
      if(count) break;
    }
  }
}


Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;

typedef pair<int,int> P;

int n;
P p[2][20100];
char d;
vector<P> g[20100];
int vis[20100];

void add_edge(int u,int v,int col){
  g[v].push_back(P(u,col));
  g[u].push_back(P(v,col));
}

int md(P a, P b){
  return abs(a.first-b.first) + abs(a.second-b.second);
}

bool dfs(int v,int col){
  if(vis[v]>=0)return (vis[v]==col);
  vis[v] = col;

  for(int i=0;i<g[v].size();i++){
    if(!dfs(g[v][i].first,col^g[v][i].second))return false;
  }
  return true;
}

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

  while(cin >> n,n){
    for(int i=0;i<n;i++){
      cin >> p[0][i].first >> p[0][i].second >> d;
      p[1][i].first = p[0][i].first + (d=='x');
      p[1][i].second = p[0][i].second + (d=='y');
    }
    
    for(int i=0;i<n;i++)g[i].clear();

    int gs = 0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(md(p[0][i],p[0][j])<=3){
	  bool f = true;
	  for(int ii=0;f,ii<2;ii++){
	    for(int jj=0;f,jj<2;jj++){
	      if(md(p[ii][i],p[jj][j])==1){
		add_edge(i,j,ii!=jj); gs += 2;
		f = false;
	      }
	    }
	  }
	}
      }
    }

    bool flag = true;
    memset(vis,-1,sizeof(vis));

    for(int i=0;i<n;i++){
      if(vis[i]<0)flag &= dfs(i,0);
      if(!flag)break;
    }
    cout << (flag?"Yes":"No") << endl;
  }
}

Measured memory_bytes: 3316
import sys
from itertools import groupby, chain
def input(): return sys.stdin.readline().rstrip()


def trans(l_2d):
    return [list(x) for x in zip(*l_2d)]


def lamp(arr):
    count = [[] for i in range(len(arr))]
    for i in range(len(arr)):
        lamps = []
        for key, value in groupby(arr[i]):
            n = int(len(list(value)))
            if key == '.':
                lamps += [n]*n
            else:
                lamps += [0]*n
        count[i] = lamps
    return count


def main():
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    tate = lamp(s)
    yoko = lamp(trans(s))
    ans=0
    for hh in range(h):
        for ww in range(w):
            ans=max(ans,tate[hh][ww]+yoko[ww][hh]-1)
    print(ans)
        


if __name__ == '__main__':
    main()


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

int main()
{
  int a, b, c;
  cin >> a >> b>> c;
  int ans;
  ans = 100 * a + 10 * b + c;
  if (ans % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 384
def no():
    print(-1)
    exit()


s = input()
n = len(s)

if s[-1] == "1":
    no()

s = s[:-1]

if s != s[::-1]:
    no()

if s[0] == "0":
    no()

li = [0]
adj = [[] for _ in range(n + 1)]
for v, e in enumerate(s, 1):
    if e == "1":
        for u in li:
            adj[u].append(v)
        li = []

    li.append(v)

adj[n-1].append(n)

for u, vs in enumerate(adj[1:], 1):
    for v in vs:
        print(u, v)


Measured memory_bytes: 20304
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


template<class T>
T gcd(T a,T b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(a%b,b);
}

bool solve(){
  ll n,c;cin>>n>>c;
  ll D[c][c];
  rep(i,c)rep(j,c)cin>>D[i][j];
  rep(i,c)D[i][i]=0;
  ll map[n][n];
  rep(i,n)rep(j,n){
    cin>>map[i][j];
    map[i][j]--;
  }
  ll ans=INF;

  //割って3になるのをcで塗る
  ll dp[3][c];
  rep(m,3)rep(x,c){
    dp[m][x]=0;
    rep(i,n)rep(j,n){
      if((i+j)%3==m){
        dp[m][x]+=D[map[i][j]][x];
      }
    }
  }

  rep(p,c)rep(q,c)rep(r,c){
    if(p==q or q==r or r==p)continue;
    ans=min(ans,dp[0][p]+dp[1][q]+dp[2][r]);
  }  
  cout<<ans<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <math.h>

int main(void) {
    int a, b, x;
    double da, db, dx, height, theta;

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

    da = (double)a;
    db = (double)b;
    dx = (double)x;

    if (da*da*db/2 <= dx) {
        height = 2*dx/(da*da)-db;
        theta = atan((db-height)/da);
    }else {
        height = 2*dx/(da*db);
        theta = atan(db/height);
    }
    printf("%.10f\n", theta*180/M_PI);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	
	public static int gcd(int a, int b) {
		if(a == 0) {
			return b;
		}
		if(b == 0) {
			return a;
		}
		if(a >= b) {
			return gcd(b, a % b);
		}
		else if(b >= a) {
			return gcd(a, b % a);
		}
		
		return 1;
	}
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		System.out.println(gcd(s.nextInt(), s.nextInt()));
		
	}

}



Measured memory_bytes: 26200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, ll> cnt;
  ll ans = 0;
  repr(i, n - 1) {
    ans += cnt[a[i] + i];
    cnt[i - a[i]]++;
  }
  cout << ans << '\n';





  
  return 0;
}

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

string str[2000];

const int MAXN=2e4+5;
int z[MAXN];
string s,ss;
void Zvalue(int len){
   z[0]=len;
   int l=0,r=0,x;
   for(int i=1;i<len;i++){
      if(r<i||z[i-l]>=r-i+1){
         r<i?x=i:x=r+1;
         while(x<len&&ss[x]==ss[x-i])  x++;
         z[i]=x-i;if(i<x){l=i;r=x-1;};
      }
      else
         z[i]=z[i-l];
   }
   z[len]=0;
}

bool dp[2001][10001];
bool can[10001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>str[i];
	dp[n][0]=true;
	for(int i=n-1;i>=0;i--)
		for(int j=0;j<=k;j++)
			dp[i][j]=(dp[i+1][j]|(j<str[i].size()?false:dp[i+1][j-str[i].size()]));
	int now=0;
	can[0]=true;
	for(int i=0;i<n;i++){
		ss=str[i]+'@'+s;
		int len=str[i].size();
		Zvalue(ss.size());
		int mn=-1;
		for(int j=0;j<=now;j++){
			if(!can[j]||(str[i].size()+j>k)||!dp[i+1][k-str[i].size()-j])	continue;
			if(mn==-1){
				if(j==now)	mn=j;
			/*	else if(z[len+j+1]==len)
					mn=j;
				else if(z[len+j+1]<len&&ss[z[len+j+1]]<ss[len+j+1+z[len+j+1]])	mn=j;*/
				else if(z[len+j+1]<len&&(len+j+1+z[len+j+1]==ss.size()||ss[z[len+j+1]]<ss[len+j+1+z[len+j+1]]))	mn=j;
			}
			else{
				if(z[len+mn+1]>=j-mn){
					if(z[j-mn]==len-(j-mn))
						mn=j;
					else if(str[i][z[j-mn]]<str[i][j-mn+z[j-mn]])
						mn=j;
				}
				else if(s[z[len+mn+1]+mn]<str[i][z[len+mn+1]])
					mn=j;
			}
		}
		if(mn!=-1){
			int tmp=mn+z[len+mn+1];
			ss=str[i]+'@'+s.substr(0,mn)+str[i];
			Zvalue(ss.size());
			for(int j=tmp+1;j<=10000;j++)
				can[j]=false;
			for(int j=k;j>=0;j--)
				if((can[j]&&dp[i+1][k-j])||(j-len>=0&&can[j-len]&&dp[i+1][k-j]&&z[j+1]==len))
						can[j]=true;
				else
					can[j]=false;

			can[mn+str[i].size()]=true;
			s=s.substr(0,mn);
			s+=str[i];
			now=mn+str[i].size();
		}
	}
	cout<<s<<endl;
}



Measured memory_bytes: 21120
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
char a[1005], b[1005];
int main()
{
	scanf("%s %s",a,b);
	int lena = strlen(a);
	int lenb = strlen(b);
	if(lena > lenb)
	{
		printf("GREATER\n");
		return 0;
	}
	else if(lena < lenb)
	{
		printf("LESS\n");
		return 0;
	}
	else 
	{
		int flag = 0;
		for(int i = 0;i < lena;i++)
		{
			if(a[i] > b[i])
			{
				printf("GREATER\n");
				flag = 1;
				return 0;
			}
			else if(a[i] < b[i])
			{
				printf("LESS\n");
				flag = 1;
				return 0;
			}
		}
		if(flag == 0) printf("EQUAL\n");
	}
	return 0;
}


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

int main(){
    int T;
    cin >> T;
    for(int t=0;t<T;++t){
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3664
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= print . solve

solve :: String -> Int
solve = (* 2) . count 0 . map length . group
    where
        count acc (w : x : y : zs) 
            | w > x = count (acc + x) $ (w - x + y) : zs
            | w < x = count (acc + w) $ (x - w) : y : zs
            | otherwise = count (acc + w) $ y : zs
        count acc [x, y] = acc + min x y
        count acc _ = acc

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 7548
n,m=map(int,input().split())
a=list(map(int, input().split()))
th=sum(a)/(4*m)
a=sorted(a)[::-1]
c=0
f=False
for i in a:
  if i>=th:
    c+=1
  if c>=m:
    f=True
    break
if f:
  print('Yes')
else:
  print('No')

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

using namespace std;

int id[10];
int x[10];
int y[10];

double distance(int id1, int id2) {
  double dx = x[id1] - x[id2];
  double dy = y[id1] - y[id2];
  return sqrt(dx * dx + dy * dy);
}

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

  int fac = 1;
  for (int i = 0; i < n; ++i) {
    id[i] = i;
    scanf("%d%d", x + i, y + i);
    fac *= (i + 1);
  }

  double ans = 0.0;
  do {
    for (int i = 1; i < n; ++i) {
      ans += distance(id[i - 1], id[i]);
    }
  } while (next_permutation(id, id + n));

  printf("%.9lf", ans / fac);
  return 0;
}

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

int main() {
  long H, W;

  std::cin >> H;
  std::cin >> W;

  std::vector<std::vector<bool>>
    C(H+2, std::vector<bool>(W+2));

  for (size_t x=0; x<W+2; x++) {
    C[0][x] = false;
  }
  for (size_t y=1; y<H+1; y++) {
    C[y][0] = false;
    for (size_t x=1; x<W+1; x++) {
      char c;
      std::cin >> c;
      if (c == '#')
        C[y][x] = true;
      else
        C[y][x] = false;
    }
    C[y][W+1] = false;
  }
  for (size_t x=0; x<W+2; x++) {
    C[H+1][x] = false;
  }

  bool ans = true;

  for (size_t y=1; y<H+1; y++) {
    for (size_t x=1; x<W+1; x++) {
      if (! C[y][x]) continue;
      if (! (C[y-1][x] | C[y+1][x] |
             C[y][x-1] | C[y][x+1])) {
        ans = false;
        break;
      }
    }
    if (! ans) break;
  }

  std::cout << (ans ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = [0] * N
for i in range(N):
    x, l = map(int, input().split())
    A[i] = (x - l, x + l)
A = sorted(A, key=lambda x: x[1])

last = -INF
ans = 0
for l, r in A:
    if l < last:
        continue
    ans += 1
    last = r
print(ans)
    



Measured memory_bytes: 25160
n=int(input())
a=list(map(int, input().split()))
temp=[]
count=0
for i in a:
    if i%2 == 0:
        temp.append(i)
for j in temp:
    if j%3==0:
        count +=1
    elif j%5==0:
        count+=1
if count== int(len(temp)):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define R register
#define MN 200005
typedef long long ll;
namespace IO{
	inline int read(){
		R int x; R bool f; R char c;
		for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
		for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
		return f?-x:x;
	}
}
namespace sol{
	int n,v[MN]={-1};ll ans;
	void main(){
		n=IO::read();
		for (R int i=1; i<=n; ++i)
			if (v[i-1]+1<(v[i]=IO::read())) return (void)(puts("-1"));
		for (R int i=1; i<=n; ++i)
			if (v[i]>=v[i+1]||i==n) ans+=v[i];
		printf("%lld\n",ans);
	}
}
int main(){sol::main();return 0;}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll x, y;
	cin >> x >> y;
	ll p = 4 * x - y;
	ll q = y - 2 * x;
	if (p % 2 || q % 2 || p < 0 || q < 0) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
	return 0;
}































Measured memory_bytes: 3648