akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete



main = replicateM 4 getInt >>= print . sum . map (apply2 min) . splitRec 2

Measured memory_bytes: 508
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let n = lines[0].split(' ').map( _ => parseInt(_))
    let ten = 1
    let nine = 1
    let eight = 1
    const amari = 1000000007
    
    for(let i = 0; i < n[0]; i++) {
        ten *= 10
        ten %= amari
        nine *= 9
        nine %= amari
        eight *= 8
        eight %= amari
    }

    let ans = (ten + amari - nine) % amari
    ans = (ans + eight) % amari
    ans = (ans + amari - nine) % amari

    console.log(ans)
});

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

using namespace std;

const int N = 1e6+5;

int n ;
long long sol , ext, m = 998244353 , mx = 1000000;
long long ans[N] , occ[N] , inv[N];

long long solve(int x)
{
    long long ret = 0;
    long long sum = 0;

    for(int i = x; i<=mx ; i+=x)
    {
        sum = (1LL * sum + 1LL * i * occ[i] %m ) %m;
    }
    for(int i = x ; i<=mx ; i+=x )
    {
        ret = (1LL *ret + 1LL * (i * occ[i] % m) * sum )%m;
    }
    ret = (ret * inv[x])%m;
    for(int i = x + x ; i<= mx ;i+=x)
    {
        ret -= ( 1LL *ans[i] * i %m *  inv[x] ) %m ;
        if(ret<0)
            ret+=m;
    }
    return ans[x] = ret%m;
}


int main() {
    inv[0] = inv[1] = 1;
    for(int i = 2  ;i< N;i++)
        inv[i] = ( m - (m/i) * inv[m%i] %m ) %m;
    cin>>n;
    for(int i = 0 ; i<n; ++i)
    {
        int a ;
        cin>>a;
        occ[ a ]++;
        ext = (ext+a) %m;
    }
    for(int i = 1000000;i;i--)
    {
        sol +=solve(i);
        sol%=m;
    }
    sol-=ext;
    sol*=inv[2];
    sol = (sol%m + m) %m;
    cout<<sol;
    return 0;
}



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

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n;
	cin>>n;
	int a[]={1,2,4,8,16,32,64};
	for(int i=6;i>=0;i--){
		if(a[i]<=n){
			cout<<a[i]<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  short int N,sum=1;
  cin >> N;
  vector<short int> d(N);
  short int i;
  for(i=0;i<N;++i)
    cin >> d.at(i);
  sort(d.begin(), d.end(), greater<int>());
  for(i=0;i<(N-1);++i){
    if(d.at(i)>d.at(i+1))
      ++sum;
  }
  cout << sum << endl;
}


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

int main()
{
	int n,x;
	cin >> n;
	map<int,int> mp;
	int ans = 0;
	for(int i=0; i<n; i++){
		cin >> x;
		mp[x]++;
		ans++;
		if(mp[x]==2)	ans-=2,mp[x]=0; 
	}
	cout<< ans << '\n';
	return 0; 
}

Measured memory_bytes: 4992
n = int(input())
s = list(map(int, list(input())))

ans = 0

def dfs(depth, id):
    global ans
    for i in range(10):
        for j in range(id, n):
            if i == s[j]:
                if depth < 2:
                    dfs(depth + 1, j + 1)
                else:
                    ans += 1
                break

dfs(0, 0)
print(ans)

Measured memory_bytes: 41456
N, M = map(int,input().split())
L = [0 for k in range(N)]
a = 0
p = 0
for k in range(M):
    s, t = input().split()
    if t == "WA":
        L[int(s)-1] += 1
    else:
        if L[int(s)-1] >= 0:
            a += 1
            p += L[int(s)-1]
            L[int(s)-1] = -100001
print(a,p)


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

string divide[4] = {"erase", "eraser", "dream", "dreamer"};

bool DFS(int i, string str){
  if (i == str.size()) return true;
  for (string s : divide) {
    if (str.substr(i, s.size()) == s) {
      if (DFS(i + s.size(), str)) return true;
    }
  }
  return false;
}

int main(){
  string str; cin >> str;
  cout << (DFS(0, str) ? "YES" : "NO") << endl;
  return 0;
}

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

using namespace std;

void print(vector<int32_t> v) {
    for (uint32_t i = 0; i < v.size() - 1; i++) {
        cout << v[i] << " ";
    }
    cout << v[v.size() - 1] << endl;
}

int main() {
    int32_t N;

    cin >> N;

    vector<int32_t> A(N);

    for (int32_t i = 0; i < N; i++) {
        cin >> A[i];
    }

    print(A);

    for (int32_t i = 1; i < N; i++) {
        int32_t key = A[i];
        int32_t j = i - 1;
        while (j >= 0 && A[j] > key) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = key;

        print(A);
    }

    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

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

    ll ans = 0;
    rep(i,n-1) {
        if(a[i+1]<a[i]) {
            ans += a[i] - a[i+1];
            a[i+1] = a[i];
        }
    }

    cout<< ans << endl;

 return 0;
}

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

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

  int n;
  string s, t;
  cin >> n >> s >> t;
  string res = "";
  for (int i = 0; i < n; i++) {
    res += s[i];
    res += t[i];
  }
  cout << res << '\n';
  return 0;
}

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

public class Main{

	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;

		try {
			str=bfr.readLine();
			if(str.equals("")) {
				System.exit(0);
			}

			else {
				int tate,yoko=0;
				stk=new StringTokenizer(str," ");
				tate=Integer.parseInt(stk.nextToken());
				yoko=Integer.parseInt(stk.nextToken());
				int mawari_count=0;

				int[][] kurosiro=new int[tate+2][yoko+2];

				for(int i=0; i<tate+2; i++) {
					for(int j=0; j<yoko+2; j++) {
						kurosiro[i][j]=0;
					}
				}
				String moji="";

				for(int i=0; i<tate; i++) {
					str=bfr.readLine();
					for(int j=0; j<yoko; j++) {
						moji=str.charAt(j)+"";
						if(moji.equals(".")) {
							kurosiro[i+1][j+1]=0;
						}
						else if(moji.equals("#")) {
							kurosiro[i+1][j+1]=1;
						}
					}
				}

				for(int i=1; i<=tate+1; i++) {
					for(int j=1; j<=yoko+1; j++) {
						if(kurosiro[i][j]==1) {
							if(kurosiro[i+1][j]==0) {
								mawari_count++;
							}

							if(kurosiro[i-1][j]==0) {
								mawari_count++;
							}

							if(kurosiro[i][j+1]==0) {
								mawari_count++;
							}

							if(kurosiro[i][j-1]==0) {
								mawari_count++;
							}

							if(mawari_count==4) {
								System.out.println("No");
								System.exit(0);
							}
							else {
								//なにもしない
							}
							mawari_count=0;
						}
						else {
							//なにもしない
						}
					}
				}

				System.out.println("Yes");
				System.exit(0);

			}
			stk=new StringTokenizer(str," ");

		}catch(IOException e) {

		}

	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N, M; cin >> N >> M;
  int P[M], Y[M];
  vector<vector<int>> YM(100010);
  rep(i,M){
    cin >> P[i] >> Y[i];
    YM.at(P[i]).push_back(Y[i]);
  }

  rep(i,N+1) sort(all(YM.at(i)));

  rep(i,M){
    auto x = lower_bound(all(YM.at(P[i])),Y[i]) - YM[P[i]].begin();
    printf("%06d",P[i]);
    printf("%06d\n",int(x)+1);
  }

  return 0;
}

Measured memory_bytes: 7808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputNum = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long n = inputNum[0];
            long x = inputNum[1];
            long t = inputNum[2];
            long a = ((n % x == 0)? n / x : n / x + 1) * t;
            
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 28060
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;

int main(int argc, char* argv[]){

	int R;
	scanf("%d", &R);

	double pi = M_PI;

	printf("%f\n", 2.0*(double)R*pi);

	return 0;
}





Measured memory_bytes: 3784
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int l;
    int s;
    if ( a > b ) { l = a; s = b; } 
    else { s = a; l = b; }
    for (int i = 0; i < l; i++) {
    System.out.print(s);
    }
  }
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<vector<int>> G(N);

  int a, b;
  rep(i, N-1){
    cin >> a >> b;
    a--;
    b--;
    
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(N);
  rep(i, N){
    dist[i] = -1;
  }

  queue<int> q;
  q.push(0);

  dist[0] = 0;

  while(!q.empty()){

    int v = q.front();
    q.pop();

    for(auto nv : G[v]){

      if(dist[nv] >= 0) continue;

      dist[nv] = dist[v] + 1;

      q.push(nv);

    }

  }

  int cnt_e = 0;
  int cnt_o = 0;

  rep(i, N){
    if(dist[i] % 2 == 0){
      cnt_e++;
    }else{
      cnt_o++;
    }
  }

  vector<int> p(N);
  rep(i, N) p[i] = -1;

  if(cnt_e <= N/3){

    int cnt3 = 3;
    rep(i, N){
      if(dist[i] % 2 == 0){
        p[i] = cnt3;
        cnt3 += 3;
      }
    }

    int cnt12 = 1;

    rep(i, N){
      if(dist[i] % 2 != 0){
        
        if(cnt3 > N){
          p[i] = cnt12;
          if(cnt12 % 3 == 2){
            cnt12 += 2;
          }else{
            cnt12 += 1;
          }

        }else{

          p[i] = cnt3;
          cnt3 += 3;
        }
      }
    }
    


  }else if(cnt_o <= N/3){

    int cnt3 = 3;
    rep(i, N){
      if(dist[i] % 2 == 1){
        p[i] = cnt3;
        cnt3 += 3;
      }
    }

    int cnt12 = 1;

    rep(i, N){
      if(dist[i] % 2 == 0){
        
        if(cnt3 > N){
          p[i] = cnt12;
          if(cnt12 % 3 == 2){
            cnt12 += 2;
          }else{
            cnt12 += 1;
          }

        }else{

          p[i] = cnt3;
          cnt3 += 3;
        }
      }
    }

  }else{
    
    int cnt1 = 1;
    int cnt2 = 2;
    int cnt3 = 3;

    rep(i, N){
      if(dist[i] % 2 == 0){
        
        if(cnt1 <= N){
          p[i] = cnt1;
          cnt1 += 3;
        }else{
          p[i] = cnt3;
          cnt3 += 3;
        }

      }
    }

    rep(i, N){
      if(dist[i] % 2 == 1){
        
        if(cnt2 <= N){
          p[i] = cnt2;
          cnt2 += 3;
        }else{
          p[i] = cnt3;
          cnt3 += 3;
        }

      }
    }

  }

  for(int i = 0; i < N; i++){
    cout << p[i] << " ";
  }
  cout << endl;





  return 0;
}


Measured memory_bytes: 15344
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

if abs(a-b)%2 == 0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(a+(b-a)//2)
    else:
        print(n-b+1+(b-a-1)//2)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		while(A > 0) {
			C -= B;
			if(C <= 0) {
				System.out.println("Yes");
				return;
			}
			A -= D;
		}
		System.out.println("No");
	}
}


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

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

	vector<int> a = {};
	vector<int> b = {};

	if (A % 2 == 0) {
		for (int i = 0; i < 13; i++) {
			a.push_back(25 * (A / 2) + i);
		}
	}
	else {
		for (int i = 0; i < 12; i++) {
			a.push_back(25 * ((A - 1) / 2) + 13 + i);
		}
	}

	for (int i = 0; i < 10; i++) {
		b.push_back(10 * B + i);
	}

	int ans;
	bool found = false;
	if (a.at(0) == b.at(0)) {
		ans = a.at(0);
		found = true;
	}
	else if (a.at(0) < b.at(0)) {
		for (int i = 0; i < a.size(); i++) {
			if (a.at(i) == b.at(0)) {
				ans = b.at(0);
				found = true;
				break;
			}
		}
	}
	else {
		for (int i = 0; i < b.size(); i++) {
			if (b.at(i) == a.at(0)) {
				ans = a.at(0);
				found = true;
                break;
			}
		}
	}

	if (found) {
		cout << ans << endl;
	}
	else {
		cout << "-1" << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(b%a == 0) {
    printf("%d\n",a+b);
  } else {
    printf("%d\n",b-a);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

vector<pi> gph[200005];
int n, m, k;

bool vis[200005];
lint val[200005];

lint l, r;

void dfs(int x, lint v){
	if(vis[x]){
		if(val[x] != v){
			puts("No");
			exit(0);
		}
		return;
	}
	vis[x] = 1;
	val[x] = v;
	if(x <= n) l = max(l, v);
	else r = min(r, v);
	for(auto &i : gph[x]){
		dfs(i.first, v + i.second);
	}
}


int main(){
	cin >> n >> m >> k;
	for(int i=0; i<k; i++){
		int x, y, v;
		scanf("%d %d %d",&x,&y,&v);
		gph[x].push_back(pi(y+n, v));
		gph[y+n].push_back(pi(x, -v));
	}
	for(int i=1; i<=n+m; i++){
		if(!vis[i]){
			l = -1e18, r = 1e18;
			dfs(i, 0);
			if(l > r) return !puts("No");
		}
	}
	puts("Yes");
}



Measured memory_bytes: 12928
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int MAX,n,a1,b1,a,b[100],i,cnt;
	scanf("%d %d %d %d",&n,&a1,&b1,&a);
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	sort(b,b+n);
	MAX=a/a1;
	cnt=0;
	for(i=n-1;i>=0;i--){
		a+=b[i];
		a1+=b1;
		MAX=max(MAX,a/a1);
	}
	printf("%d\n",MAX);
	return 0;
}


Measured memory_bytes: 2772
fun main(args:Array<String>?): Unit {
    val (_, t, e) = readLine()!!.trim().split(' ').map(String::toInt)
    val x = readLine()!!.trim().split(' ').map(String::toInt)
    println(x.indices.find{ (t / x[it] * x[it]) in t - e .. t + e || (t / x[it] * x[it] + x[it]) in t - e .. t + e}?.let{it + 1} ?: - 1)
}


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

int main(){
  int N, ans;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(int i=0; i<N; ++i){
    cin >> A[i];
  }
  for(int i=0; i<N; ++i){
    cin >> B[i];
  }
  for(int i=0; i<N-1; ++i){
    cin >> C[i];
  }
  ans = accumulate(B.begin(), B.end(), 0);
  for(int i=0; i<N; ++i){
    if(A[i+1] == A[i] + 1){
      ans += C[A[i] - 1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
V = [int(v) for v in input().split()]

ans = 0
for i in range(min(N+1,K+1)):
  que1 = V[:i]
  for j in range(min(N+1-i,K+1-i)):
    que2 = que1 + V[N-j:]
    que2.sort()
    for k in range(min(K+1-i-j,i+j+1)):
      ans = max(ans,sum(que2[k:]))
print(ans)


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

int main(){
  string s;
  cin >> s;
  int n0,n1;
  n0=count(&s[0],&s[s.size()-1]+1,'0');
  n1=count(&s[0],&s[s.size()-1]+1,'1');
  
  if(n0<n1)cout << n0*2;else cout << n1*2;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long calcNumOfCombination(long n, long r){
    long num = 1;
    const int MOD = 1000000007;
    for(long i = 1; i <= r; i++){
        num = num * (n - i + 1);
        num%=MOD;
        num = num*modinv(i,MOD)%MOD;
    }
    return num;
}


int main()
{
    long n,a,b;
    std::cin >> n >> a >> b;
    long sum=1;
    long MOD = 1000000000+7;
    long keta=std::floor(log(n)/log(2)+1);
    long tempn=n;
    long kaizyo=2;
    int bit;
    for(long i=0; i<keta; i++){
        bit=tempn&1;
        if(i==0 ){
if(bit==1){
            sum*=kaizyo*bit;
}
        }else{
            kaizyo=kaizyo*kaizyo;
            kaizyo%=MOD;
if(bit==1){
            sum*=kaizyo*bit;
            sum%=MOD;
        }
}
        tempn=tempn>>1;
    }
    sum-=1;
    sum%=MOD;
    if(sum<0){
        sum+=MOD;
    }
        
    long minnum=std::max(a,b);
    long combination=1;
    for(long i=1; i<=minnum; i++){
        combination*=(n-i+1);
        combination%=MOD;
        combination=combination*modinv(i,MOD)%MOD;
        if(i==a || i==b){
            sum-=combination;
            sum%=MOD;
            if(sum<0){
                sum+=MOD;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dp[111][5][5][5];
int N = 100;
char chars[] = {'\0', 'A', 'C', 'G', 'T'};
int ints[100] = {};
long long rec(int pos, int b3, int b2, int b1) {
  long long &res = dp[pos][b3][b2][b1];
  char c1, c2, c3;
  c3 = chars[b3], c2 = chars[b2], c1 = chars[b1];

  if (res != -1) {
    return res;
  }
  if (pos == N) {
    return res = 1;
  }

  if (c2 == 'A' && c1 == 'G') {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['G'])
      + rec(pos + 1, b2, b1, ints['T']);
  } else if (c2 == 'A' && c1 == 'C') {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['C'])
      + rec(pos + 1, b2, b1, ints['T']);
  } else if (c2 == 'G' && c1 == 'A') {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['G'])
      + rec(pos + 1, b2, b1, ints['T']);
  } else if (c3 =='A' && c2 == 'G') {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['G'])
      + rec(pos + 1, b2, b1, ints['T']);
  } else if (c3 =='A' && c1 == 'G') {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['G'])
      + rec(pos + 1, b2, b1, ints['T']);
  } else {
    res = rec(pos + 1, b2, b1, ints['A'])
      + rec(pos + 1, b2, b1, ints['C'])
      + rec(pos + 1, b2, b1, ints['G'])
      + rec(pos + 1, b2, b1, ints['T']);
  }
  res %= 1000000007;
  return res;
}

int main() {
  ints['A'] = 1;
  ints['C'] = 2;
  ints['G'] = 3;
  ints['T'] = 4;
  cin >> N;
  for (int i = 0; i < 111; i++) {
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 5; k++) {
        for (int l = 0; l < 5; l++) {
          dp[i][j][k][l] = -1;
        }
      }
    }
  }
  cout << rec(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
  int mountain[10] = {};

  for(int i=0;i<10;i++){
    scanf("%d",&mountain[i]);
  }
  sort(mountain,mountain+10,greater<int>());
  for(int i=0;i<3;i++){
    printf("%d\n",mountain[i]);
  }


  return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  int64_t ans = 0;
  for (int64_t i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) {
      ans++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc153c()
}

fun abc153c() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val hList = readLine()!!.split(' ').map { it.toLong() }

    val answer = hList.sorted().take(Math.max(0, n - k)).sum()

    println(answer)
}


Measured memory_bytes: 83436
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;
 
inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

const int N = 100005;
int n, xi[N], L, q, nxt[N][25];

int main(){
	n = read();
	REP(i, 1, n) xi[i] = read();
	L = read(), q = read();
	int r = 1;
	REP(i, 1, n){
		while (r < n && xi[r + 1] - xi[i] <= L) ++r;
		nxt[i][0] = r;
	}
	for (int j = 1; (1 << j) <= n; ++j)
		for (int i = 1; i + (1 << j) - 1 <= n; ++i)
			nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
	REP(i, 1, q){
		int x = read(), y = read();
		if (x > y) swap(x, y);
		LL ans = 0;
		PER(j, 19, 0) if (nxt[x][j] && nxt[x][j] < y){
			x = nxt[x][j];
			ans += (1ll << j);
		}
		if (x == y) cout << ans << endl;
		else cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;
long long int mpown(long long int m, int n);
long long int bign=1000000007;
int bitCount(int bits);
int main()
{
    int q;
    cin >> q;
    long long int a,b;
    long long int minb=0;
    multiset<long long int> left;
    multiset<long long int> right;
    left.insert(bign);
    right.insert(bign);
    int kind;
    int pos;
    long long int move;
    for(int i=0;i<q;i++){
        cin >> kind;
        // cout << (*left.begin())*(-1) <<"," << *right.begin() << endl;
        if(kind==1){
            cin >> a >>b;
            minb += b;
            if((*left.begin())*(-1) <= a && a<=*right.begin()){
                left.insert(-a);
                right.insert(a);
                // cout << "111" << endl;
            }else if(a<(*left.begin())*(-1)){
                left.insert(-a);
                left.insert(-a);
                move=(*left.begin())*(-1);
                left.erase(left.begin());
                right.insert(move);
                minb += (move-a);
                // cout << move << endl;
            }else if(a>*right.begin()){
                right.insert(a);
                right.insert(a);
                move = (*right.begin());
                right.erase(right.begin());
                left.insert(-move);
                minb += (a-move);
                // cout << move << endl;
            }
            // minb+= b;
            // as.insert(a);


        }else{
            cout << (*left.begin())*(-1) << " " << minb << endl;
            // // cout << "a" << endl;
            // pos=(as.size()-1)/2;
            // auto itr=as.begin();
            // for(int j=0;j<pos;++j){
            //     ++itr;
            // }

            // if(as.size()&1){
            //     cout << *itr << " " << minb << endl;            
            // }else{
            //     long long int mina=*itr;
            //     ++itr;
            //     long long int sa=(*itr)-mina;
            // }
                
            

        }
    }
    return 0;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;	
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m,o[200001],w[200001];
int main(void){
	register int i,x,y;
	n=read(),m=read();
	for(i=1;i<=m;++i)
		x=read(),y=read(),x==1?o[y]=1:0,y==n?w[x]=1:0;
	for(i=2;i<n;++i)
		if(o[i]&&w[i]){
			puts("POSSIBLE");
			return 0;
		}
	puts("IMPOSSIBLE");
	return 0;
}

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

int main() {
  int X1,X2,Y1,Y2;
  cin >> X1 >> Y1 >> X2 >> Y2;
  int A = X2-X1;
  int B = Y2-Y1;
  int X3 = X2-B;
  int Y3 = Y2+A;
  int X4 = X3-A;
  int Y4 = Y3-B;
  cout << X3 << " " << Y3 << " " << X4 << " " << Y4 << endl;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

const char* strs = "abcdefghijklmnopqrstuvwxyz.?! ";

int main()
{
	char str[256];
	while(scanf("%s", str) != EOF){
		int n = strlen(str);
		char output[256] = {0};
		bool ok = true;
		for(int i=0; i<n; i+=2){
			if(i+1 == n){
				ok = false;
				break;
			}
			int a = str[i] - '1';
			int b = str[i+1] - '1';
			if(a<0 || 6<=a || b<0 || 5<=b){
				ok = false;
				break;
			}
			output[i/2] = strs[a*5+b];
		}
		
		puts(ok ? output : "NA");
	}
	
	return 0;
}

Measured memory_bytes: 0
n,a,b = map(int,input().split())
s = input()
al = [-1]*n
for i in range(n):
  if s[i] == 'a':
    if a+b > 0:
      a -= 1
      al[i] = 1
    else:
      al[i] = 0
  elif s[i] == 'b':
    if b > 0 and a+b > 0:
      b -= 1
      al[i] = 1
    else:
      al[i] = 0
  else:
    al[i] = 0
for t in al:
  if t == 1:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define N 1000009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
int a[N],b[N];
int main(){
    int i,j,n,m,t,k,x,y;
    sd2(n,k);
    for(i=0;i<n; i++){
        sd(a[i]);
    }
    fill(b,b+N,INF);
    b[0]=0;
    for(i=1; i<n; i++){
        for(j=1; j<=min(k,i); j++){
            b[i] = min(b[i],b[i-j]+abs(a[i]-a[i-j]));
        // tr2(i,b[i]);
        }
    }
    tr(b[n-1]);
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    int ans = 0;
    if(a <= c){
        if(c <= b) ans = min(b, d) - c;
    }else{
        if(a <= d) ans = min(b, d) - a;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		long N=scan.nextLong();
		long a=(long) Math.sqrt(N);
		int ans=100000000;
		for(int i=1;i<a+1;i++) {
			long b=1000000000;
			long c=1000000000;
			if(N%i==0) {
				b=N/i;
				c=i;
			}
			
			int lb=String.valueOf(b).length();
			int lc=String.valueOf(c).length();
			if(Math.max(lb,lc)<ans){
				ans=Math.max(lb,lc);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34900
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.length() == 3) reverse(all(s));
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

long long powMod(long long x, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if ((n & 1) == 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

/*
  階乗計算（MODで割った余りで返す）
*/

class Factorial {
    private:
        vector<long long> fac;
    public:
        Factorial();
        Factorial(long long n_max);
        void initialization(long long n_max);
        long long getFactorial(long long n);
};

Factorial::Factorial() {}
Factorial::Factorial(long long n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (long long i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
void Factorial::initialization(long long n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (long long i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
long long Factorial::getFactorial(long long n) {
    return fac[n];
}

/*
  MOD計算
*/
// 割り算のための逆元を求める（mod m での a の逆元）
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u % m;
}

/*
    順列と組み合わせ (P, C, H)
*/

class PCH {
    private:
        Factorial fact;
    
    public:
        PCH(long long n_max);
        long long P(long long n, long long r);
        long long C(long long n, long long r);
        long long H(long long n, long long r);
};
PCH::PCH(long long n_max) {
    fact.initialization(n_max);
}
long long PCH::P(long long n, long long r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD;
}

long long PCH::C(long long n, long long r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

long long PCH::H(long long n, long long r) {
    return C(n - 1 + r, r);
}

int main() {

  int K;
  cin >> K;
  string S;
  cin >> S;
  int N = S.length();

  PCH pch(N + K);

  ll ans = 0;

  for (int k = N; k <= N + K; k++) {
    ll count = 1;
    count *= pch.C(k - 1, N - 1);
    count *= powMod(25, k - N, MOD);
    count %= MOD;
    count *= powMod(26, N + K - k, MOD);
    count %= MOD;
    ans += count;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 21592
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main(){

  int H,W;
  cin>>H>>W;
  long long dp[H+1][W+1];
  for(int i = 0;i<=H;i++) for(int j=0;j<=W;j++) dp[i][j] = 0;

  vector<string> a(H);
  for(int i=0;i<H;i++) cin>>a[i];


  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){

      if(i==1&& j==1){
      dp[1][1] =1;
    }else if(a[i-1][j-1]=='.'){
        dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod ;
      }else{
        dp[i][j]=0;
      }
    }
  }

  cout<<dp[H][W] % mod;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll x;
	scanf("%lld",&x);
	ll b=sqrt(x);
	ll ans=1;
	rep(i,2,b+1){
		ll t=i*i;
		while(t<=x){
			ans=max(ans,t);
			t*=i;
		}
	}
	printf("%lld",ans);
}

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

using namespace std;


int main(){
    string s;
    int k;
    cin >> s >> k;
    for(int i=0;i<s.size();i++){
        if(s[i] == '1' && k == i+1)break;
        if(s[i] != '1'){
            cout << s[i];
            return 0;
        } 
    }
    cout << '1';
    return 0;
}


Measured memory_bytes: 256
S = input()
S = list(S)

judge = 'Yes'

for i in range(len(S)) :
  if (i+1)%2 == 0 :
    if S[i] == 'R' :
      judge = 'No'
    else :
      judge = judge
  if (i+1)%2 == 1 :
    if S[i] == 'L' :
      judge = 'No'
    else :
      judge = judge

print(judge)


Measured memory_bytes: 2940
fn main() {
    proconio::input! {
        n: usize,
        city: [(i64, i64, i64); n]
    };
    let mut dist_v = vec![vec![0; 1<<n]; n];
    let mut dist_h = vec![vec![0; 1<<n]; n];
    for i in 0..1<<n {
        for j in 0..n {
            dist_v[j][i] = city[j].0.abs().min(city[j].1.abs());
            dist_h[j][i] = city[j].0.abs().min(city[j].1.abs());
            for k in 0..n {
                if i&(1<<k) == 0 { continue }
                dist_v[j][i] = dist_v[j][i].min((city[k].0-city[j].0).abs());
                dist_h[j][i] = dist_h[j][i].min((city[k].1-city[j].1).abs());
            }
            dist_v[j][i] *= city[j].2;
            dist_h[j][i] *= city[j].2;
        }
    }
    let mut res = vec![1000000000000000000; n+1];
    for i in 0..1<<n {
        let idx = (i as u64).count_ones() as usize;
        let mut j = i;
        loop {
            let mut cur = 0;
            for k in 0..n {
                cur += dist_v[k][j].min(dist_h[k][i^j]);
            }
            res[idx] = res[idx].min(cur);
            if j == 0 { break; }
            j = i&(j-1);
        }
        (i as u64).count_ones();
    }
    for &v in &res { println!("{}", v) }
}


Measured memory_bytes: 9696
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y; cin >> x >> y;
  if(abs(x - y) >= 2) cout << "Alice" << endl;
  else cout << "Brown" << endl;
  return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, fr;
    cin >> s;
    lli q, r = 0;
    cin >> q;
    while(q--)
    {
        lli t;
        cin >> t;
        if(t == 1)
            r = r ^ 1;
        else
        {
            lli f;
            string c;
            cin >> f >> c;
            if(f == 1)
            {
                if(r == 0)
                    fr = fr+ c;
                else
                    s = s + c;
            }
            else
            {
                if(r == 1)
                    fr = fr + c;
                else
                    s = s + c;
            }
            
        }
    }
    reverse(fr.begin(), fr.end());
        fr = fr + s;
    if(r)
        reverse(fr.begin(), fr.end());
    cout << fr << endl;
}


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

using namespace std;
typedef pair<int, int> pii;


int main(void) {
  int n, q;
  while (cin >> n >> q, n) {
    vector< pair<pii, string> > v;
    for (int i = 0; i < n; i++) {
      string name;
      int a, b;
      cin >> name >> a >> b;
      v.push_back(make_pair(pii(b - a, b), name));
    }
    sort(v.begin(), v.end());

    for (int i = 0; i < q; i++) {
      int y;
      cin >> y;

      int l = 0, r = n;
      while (r - l > 0) {
        int m = (l + r) / 2;
        int a = v[m].first.first, b = v[m].first.second;
        if (y <= a) r = m;
        else if (y > b) l = m + 1;
        else l = m, r = m;
      }

      if (l < n && v[l].first.first < y && v[l].first.second) {
        cout << v[l].second << " " << y - v[l].first.first << endl;
      } else {
        cout << "Unknown\n";
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int len = 100010;
int n,x,a,b;

int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> x >> a >> b;
    n = -a+b;
    if (n>x) cout << "dangerous" << endl;
    else {
        if (n<=0) cout << "delicious" << endl;
        else cout << "safe" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int n = s1.size(),f=0;
	for(int i=0;i<n;i++){
		if(s1[i]!=s2[i]){
			f=1;
			break;
		}
	}
	if(f==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{

    int n;  cin >> n;

    int x = 1, y = 1, z = 1, fn = 0;

    int* arr = new int[n+1];
    for (int i = 0; i <= n; i++){
        arr[i] = 0;
    }

    while (true){

        while (true){

            while (true){

                fn = x*x + y*y + z*z + x*y + y*z + x*z;
                z++;

                if (fn <= n){
                    arr[fn]++;
                } else {
                    break;
                }
            }

            y++; z = 1;
            fn = x*x + y*y + z*z + x*y + y*z + x*z;

            if (fn <= n){
                continue;
            } else {
                break;
            }
        }

        x++; y = 1; z = 1;
        fn = x*x + y*y + z*z + x*y + y*z + x*z;

        if (fn <= n){
            continue;
        } else {
            break;
        }
    }

    for (int i = 1; i <= n; i++){
        cout << arr[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	if(a>0&&b>0) cout<<"Positive";
	if(a<0&&b<0) (b-a)%2==0?cout<<"Negative":cout<<"Positive";
	if(a<0&&b>0) cout<<"Zero";
	return 0;
}

Measured memory_bytes: 256
import sys
def s():
 n=int(input())+1
 e=list(map(lambda x:x.split(),sys.stdin))
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


Measured memory_bytes: 5720
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n, a, b = [int(item) for item in input().split()]
ans = 10**20

diff = abs(a - b)
if diff % 2 == 0:
    ans = diff // 2
    print(ans)
else:
    if a > b:
        a, b = b, a
    left = a
    left += (b - left) // 2
    right = n - b + 1
    right += (n - right - a) // 2
    print(min(left, right))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    string s, t; cin >> s >> t;
    int same = t.length();
    for (int i = 0; i <= s.length() - t.length(); i++) {
        int tmp = 0;
        rep(j,t.length()) {
            if (s[i+j] == t[j])
                tmp++;
        }
        same = min(same, (int)t.size() - tmp);
    }

    cout << same << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
// MACROS
#define int long long int 
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define fori(a,b) for(int i = a; i < b; i++)
#define forj(a,b) for(int j = a; j < b; j++)
#define rofi(a,b) for(int i = a; i >= b; i--)
#define rofj(a,b) for(int j = a; j >= b; j--)
#define pb push_back
#define mp make_pair

void solve(){
    int n;
    cin>>n;
    int arr[n];
    int totx=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        totx^=arr[i];
    }
    int newa[n];
    for(int i=0;i<n;i++){
        newa[i]=arr[i]^totx;
    }
    for(int i=0;i<n;i++){
        cout<<newa[i]<<" ";
    }
    cout<<"\n";
}

int32_t main(){
    FASTIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    #ifndef ONLINE_JUDGE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
    #endif

    return 0;
}

Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int a[100000];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	int dir = 0;
	int cnt = 1;
	for (int i = 1; i < n; ++i) {
		if (dir == 1) {
			if (a[i] < a[i - 1]) {
				dir = 0;
				++cnt;
			}
		} else if (dir == -1) {
			if (a[i] > a[i - 1]) {
				dir = 0;
				++cnt;
			}
		} else {
			if (a[i] < a[i - 1]) {
				dir = -1;
			} else if (a[i] > a[i - 1]) {
				dir = 1;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
using namespace std;

vector<long int> sieve(long int n){
    long int arr[n+1];
    for(long int i = 0; i <= n;++i){
        arr[i] = 1;
    }
    arr[0] = 0;
    arr[1] = 0;
    long int p= 2;
    while(p <= n){
        if(arr[p]){
            for(long int i = p*2; i <=n; i+=p){
                arr[i] = 0;
            }
        }
        p++;
    }
    vector<long int> ans;
    for(long int i = 2; i < n ; i++){
        if(arr[i]){
            ans.push_back(i);
        }
    }
    return ans;
    }
int main(){
    long long int a;
    string b;
    cin>>a>>b;
    b.erase(1,1);
    long long int c = stoi(b);
    long long int ans = a*c;
    cout<<ans/100<<endl;
}

Measured memory_bytes: 3572