akhauriyash/Code-Regression huggingface dataset:
// AOJ ALDS1_4_A Linear Search
// 2018.4.27 bal4u

#include <stdio.h>

// 数値のハッシュ関数
#define HASHSIZ 25013
int hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(int n)
{
	int *p;
	
	n++; p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(int n)
{
	int *p;
	
	n++; p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return;
		if (++p == hashend) p = hash;
	}
	*p = n;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int n, q, C;

	n = in();
	while (n--) insert(in());

	C = 0;
	q = in();
	while (q--) if (lookup(in())) C++;
	
	printf("%d\n", C);
	return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        sort(ALL(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto p : mp){
        if(1 < p.second){
            ll i = p.second;
            ans += (ll)(i * (i - 1)) / 2;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11412
int main(void){

  int N,i;
  long long x;
  long long a[100000];
  long long total=0;

  scanf("%d %lld",&N,&x);
  a[0]=0;
  for(i=1;i<N+1;i++){
  	scanf("%lld",&a[i]);
  }
  for(i=1;i<=N;i++){
    if(a[i]+a[i-1]>x){
      	total+=a[i]+a[i-1]-x;
    	a[i]=x-a[i-1];
    }
  }
  
  printf("%lld\r\n",total);
  
  return 0;
}

Measured memory_bytes: 2488
n = int(input())
data = []
for i in range(n):
    a,b = map(int,input().split())
    data.append([a,b])

data.sort(key = lambda x: x[1])
temp = True
now = 0
for i in range(n):
    if now + data[i][0] > data[i][1]:
        temp = False
        break
    else:
        now += data[i][0]
if temp:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T>

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

ll gcd(ll a,ll b){
  if (a%b==0) return(b);
  else return(gcd(b,a%b));
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

vector<int> bfs(vvi L,int S){ //List,Start
  vector<int> v(L.size(),-1);
  v[S]=0;
  queue<int> q;
  q.push(S);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:L[a]){
      if (v[x]==-1){
        v[x]=v[a]+1;
        q.push(x);
      }
    }
  }
  return v;
}

void initialize(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
}

/////////////////////////////////////////

int main(){
  initialize();
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(N*A,B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int r;
	scanf("%d",&r);
	if(r<1200){
		printf("ABC\n");
	}
	else if(r<2800){
		printf("ARC\n");
	}
	else{
		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 128
use std::io;


fn main() {
    let mut abc = read::<usize>();
    abc.sort();
    println!("{}", abc[0] * abc[1] / 2);
}


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

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

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

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

Measured memory_bytes: 4352
N=parse(Int,readline())
S=chomp(readline())
ans=1145141
L=[0]
R=[0]
now=0
for i=1:N
	if S[i]=='W'
		now+=1
	end
	push!(L,now)
end
now=0
for i=N:-1:1
	if S[i]=='E'
		now+=1
	end
	push!(R,now)
end
reverse!(R)
for i=1:N
	ans=min(ans,L[i]+R[i+1])
end
println(ans)


Measured memory_bytes: 157740
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] A = new String[3];
		for(int i = 0; i < 3; i++){
			A[i] = sc.next();
		}
		System.out.println(ans(A));
	}
	public static String ans(String[] A){
		return String.valueOf(A[0].charAt(0)) + String.valueOf(A[1].charAt(1)) + String.valueOf(A[2].charAt(2));
	}
}


Measured memory_bytes: 23636
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


class SegmentTree:
    def __init__(self, n, ide_ele, op, init_val=[]):
        self.n = 2 ** (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.op = op
        self.seg = [ide_ele] * 2 * self.n
        if init_val:
            for i in range(n):
                self.seg[i + self.n - 1] = init_val[i]
            for i in range(self.n - 2, -1, -1):
                self.seg[i] = self.op(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, k, x):
        k += self.n - 1
        self.seg[k] = x
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.op(self.seg[k * 2 + 1], self.seg[k * 2 + 2])

    def query(self, p, q):
        # qは含まない
        if q <= p:
            return self.ide_ele
        p += self.n - 1
        q += self.n - 2
        res = self.ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = self.op(res, self.seg[p])
            if q & 1 == 1:
                res = self.op(res, self.seg[q])
            p = p // 2
            q = (q - 2) // 2
        if p == q:
            res = self.op(res, self.seg[p])
        else:
            res = self.op(self.seg[p], self.op(res, self.seg[q]))
        return res

    def display(self):
        return self.seg[self.n - 1: -1]
    
    def query_point(self, p):
        return self.seg[p + self.n - 1]


n, m = LI()
lrc_list = sorted(LIR(m))
st = SegmentTree(n, INF, min)
st.update(0, 0)
for l, r, c in lrc_list:
    l_dist = st.query(l - 1, r)
    st.update(r - 1, min(st.query_point(r - 1), l_dist + c))
    # dis = st.display()

if st.query_point(n - 1) == INF:
    print(-1)
else:
    print(st.query_point(n - 1))






Measured memory_bytes: 91868
#include<iostream>
#include<cstdio>
using namespace std;
#define INF 1000000000
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int mp[21][21],w,h;
int sx,sy,gx,gy;
int ans;
bool valid(int x,int y){
  return 0<=x&&x<h&&0<=y&&y<w;
}
void rec(int x,int y,int di,int depth){
  if(depth>=min(11,ans))return;
  int nx=x+dx[di],ny=y+dy[di];
  if(!valid(nx,ny)||mp[nx][ny]==1)return;
  while(valid(nx,ny)&&mp[nx][ny]==0){nx+=dx[di];ny+=dy[di];}
  if(!valid(nx,ny)){
    return;
  }else if(mp[nx][ny]==1){
    mp[nx][ny]=0;
    for(int i=0;i<4;i++)rec(nx-dx[di],ny-dy[di],i,depth+1);
    mp[nx][ny]=1;
  }else if(mp[nx][ny]==3){
    ans=depth;
  }
  return;
}
int main(){
  while(cin>>w>>h&&w*h!=0){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>mp[i][j];
        if(mp[i][j]==2){sx=i;sy=j;mp[i][j]=0;}
        if(mp[i][j]==3){gx=i;gy=j;}
      }
    }
    ans=INF;
    for(int i=0;i<4;i++){
      rec(sx,sy,i,1);
    }
    cout<<((ans==INF)?-1:ans)<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e7 + 5;

ll val[nax], n;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	for(ll i = 2; i * i < nax; i++){
		for(ll j = i * i; j < nax; j += i){
			if(j == i * i){
				val[j]++;
			}
			else{
				val[j] += 2;
			}
		}
	}
	cin >> n;
	ll ans = 1;
	for(ll i = 2; i <= n; i++){
		ans += i * (val[i] + 2);
	}
	cout << ans << '\n';
	
}


Measured memory_bytes: 81756
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x float64
	fmt.Scan(&a, &b, &x)

	var r float64
	if a*a*b < 2*x {
		r = math.Pow(a, 3) / (2*(math.Pow(a, 2)*b) - 2*x)
	} else {
		r = 2 * x / (a * math.Pow(b, 2))
	}
	d := 90.0 - (math.Atan(r) * 180.0 / math.Pi)

	fmt.Println(d)
}


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

int main(){
  rep(i, 5){
    int x; cin >> x;
    x--;
    if(x!=i) cout << i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1299710
using namespace std;
int main() {
	bool prime[N];
	for (int i = 2; i < N; ++i) prime[i] = true;
	for (int i = 2; i*i < N; ++i)
		if (prime[i])
			for (int j = 2; i*j < N; ++j) prime[i*j] = false;
	vector<int>primeList;
	for (int i = 2; i < N; ++i)
		if (prime[i]) primeList.push_back(i);
	int n;
	while (cin >> n && n) {
		int pos=0;
		while (primeList[pos] < n) ++pos;
		if (primeList[pos] == n) cout << "0" << endl;
		else  cout << primeList[pos] - primeList[pos - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 4528
a,b = list(map(int, input().split()))

answered=False
ans = 0 
for i in range(1,1500):
    if int(0.08*i)==a and int(0.10*i)==b:
        answered=True
        print(i)
        break
    else:
        continue    

if answered ==False:
    print('-1')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long n,x;
int main()
{
    cin>>n;
    x=n;
    while (1)
    {
        if (x%n==0&&x%2==0)
        {
            cout<<x;
            return 0;
        }
        x+=x;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, a[3];
string ans, s[N];

main () {
	cin >> n >> a[0] >> a[1] >> a[2];
	for (int i = 1; i <= n; ++i)
		cin >> s[i];

	for (int i = 1; i <= n; ++i) {
		int i1, i2, i3;
		i1 = s[i][0] - 'A';
		i2 = s[i][1] - 'A';

		for (char c = 'A'; c <= 'C'; ++c)
			if (c != s[i][0] && c != s[i][1]) {
				s[i] += c; 
				i3 = c - 'A';	
			}

		if (a[i1] > a[i2]) {
			--a[i1];
			++a[i2];
			ans += s[i][1];
		} else if (a[i1] < a[i2] || a[i1] > 1 && a[i2] > 1 || a[i3] > 0 || i == n || s[i].substr(0, 2) == s[i + 1]) {
			++a[i1];
			--a[i2];
			ans += s[i][0];
		} else {
			if ((s[i][0] == s[i + 1][0] && s[i][2] == s[i + 1][1]) || (s[i][0] == s[i + 1][1] && s[i][2] == s[i + 1][0])) {
				++a[i1];
				--a[i2];
				ans += s[i][0];
			} else {
				--a[i1];
				++a[i2];
				ans += s[i][1];
			}
		}
		
		if (a[i1] < 0 || a[i2] < 0) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes\n";
	for (auto x : ans)
		cout << x << endl;
}





Measured memory_bytes: 10068
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:k:_) <- map read . words <$> getLine :: IO [Int]
  hs <- map read . words <$> getLine :: IO [Int]
  print $ solve n k hs


solve n k hs = length . filter (>= k) $ hs 


Measured memory_bytes: 17916
#include <stdio.h>
#include <string.h>

int x, y;
int map[32][32];
int dp[32][32];

int solve(void)
{
    int i, j;
    int sum;

    memset(dp, 0, sizeof(int) * 32 * 32);

    for (j = 1; j <= x; ++j) dp[1][j] = !map[1][j];

    for (i = 1; i <= y - 1; ++i){
        for (j = 1; j <= x; ++j){
            switch (map[i][j]){
            case 0:
                dp[i + 1][j] += dp[i][j];
                if (map[i + 1][j - 1] != 2) dp[i + 1][j - 1] += dp[i][j];
                if (map[i + 1][j + 1] != 2) dp[i + 1][j + 1] += dp[i][j];
                break;
            case 1:
                dp[i][j] = 0;
                break;
            case 2:
                dp[i + 2][j] += dp[i][j];
                break;
            }
        }
    }

    sum = 0;
    for (j = 1; j <= x; ++j){
        if (map[y][j] != 1) sum += dp[y][j];
        if (map[y + 1][j] != 1) sum += dp[y + 1][j];
    }

    // for (i = 1; i <= y + 1; ++i){
    //     for (j = 1; j <= x; ++j){
    //         printf("%3d", dp[i][j]);
    //     }
    //     puts("");
    // }

    return sum;
}

int main(void)
{
    int i, j;

    while (scanf("%d %d", &x, &y), x){
        for (i = 1; i <= y; ++i){
            for (j = 1; j <= x; ++j) scanf("%d", map[i] + j);
        }
        printf("%d\n", solve());
    }

    return 0;
}

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

//文字列のバブルソート

int main() {
    string s,t;
    char tmp;
    cin >>s>>t;

    for (int i = 0; i < s.size() - 1; i++) {
        for (int j = s.size() - 1; i < j; j--) {
            if (s.at(i) > s.at(j)) {
                tmp = s.at(i);
                s.at(i) = s.at(j);
                s.at(j) = tmp;
            }
        }
    }

    for (int i=0;i<t.size()-1;i++){
      for (int j=t.size()-1; i<j; j--){
        if (t.at(i) <t.at(j)){
          tmp = t.at(i);
          t.at(i) = t.at(j);
          t.at(j) = tmp;
        }
      }
    }
  if (s<t){
    cout<<"Yes"<<endl;
  } else {
    cout <<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

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

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

using lli = long long int;

std::vector<std::vector<lli>> Dist, Dist2;


int main(void){
    int n; scanf("%d", &n);
    Dist.resize(n, std::vector<lli>(n));
    REP(i, n) REP(j, n) scanf("%lld", &Dist[i][j]);
    Dist2 = Dist;
    REP(k, n) REP(i, n) REP(j, n) chmin(Dist[i][j], Dist[i][k] + Dist[k][j]);
    if(Dist != Dist2){ puts("-1"); return 0; }

    lli res = 0;
    REP(x, n) FOR(y, x+1, n){
        bool chosen = true;
        REP(z, n) if(z != x and z != y and Dist[x][y] >= Dist[x][z] + Dist[z][y]){
            chosen = false;
            break;
        }
        if(chosen) res += Dist[x][y];
    }
    printf("%lld\n", res);

    
  
    return 0;
}

Measured memory_bytes: 1912
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

ll inf=(ll)2e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m;
const int N=2e5+10;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,k,u,v;
    ll x,a,b,c,d,y,p,z;
    cin >> n;
    if(n>=400&&n<=599){
        cout << 8 << el;
    }
    else if(n>=600&&n<=799){
        cout << 7 << el;
    }
    else if(n>=800&&n<=999){
        cout << 6 << el;
    }
    else if(n>=1000&&n<=1199){
        cout << 5 << el;
    }
    else if(n>=1200&&n<=1399){
        cout << 4 << el;
    }
    else if(n>=1400&&n<=1599){
        cout << 3 << el;
    }
    else if(n>=1600&&n<=1799){
        cout << 2 << el;
    }
    else{
        cout << 1 << el;
    }
    return 0;
}






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

int main() {
    char b;
    cin >> b;
    if(b == 'A'){
        cout << 'T' << endl;
    }
    else if(b == 'C'){
        cout << 'G' << endl;
    }
    else if(b == 'G'){
        cout << 'C' << endl;
    }
    else if(b == 'T'){
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#define MAX 9
using namespace std;
char ChangeCase(char c){
	if( islower( c ) )
		return toupper( c );
	else if( isupper( c ) )
		return tolower( c );
	else
		return '\0';
}
struct piece{
	char c[4];
};
struct puzzle{
	piece pieces[MAX][4];
	bool bUsed[MAX];
	piece pzl[MAX];
	puzzle(){ for(int i = 0; i < MAX; ++i) bUsed[i]=false; }
	void CreateRotations(){
		for(int i = 0; i < MAX; ++i){
			for(int j = 1; j < 4; ++j){
				for(int k = 0; k < 4; ++k){
					pieces[i][j].c[k] = pieces[i][0].c[(j+k)%4];
				}
			}
		}
	}
};
void solve( puzzle &p, int depth, int pos, int &ans ){
	const int cp[] = {1,5,7,3};
	const int ccp[] = {2,8,6,0};
	const int cfp[] = {1,5,3,1};
	const int csp[] = {5,7,7,3};
	const int cfpp[] = {1,2,2,3};
	const int cspp[] = {0,1,3,0};

	switch( depth ){
		case 0:
			for(int i = 0; i < MAX; ++i){
				for(int j = 0; j < 4; ++j){
					p.bUsed[i] = true;
					p.pzl[4] = p.pieces[i][j];
					solve( p, 1, 0, ans );
					p.bUsed[i] = false;
				}
			}
			break;
		case 1:
			for(int i = 0; i < MAX; ++i){
				if( !p.bUsed[i] ){
					for(int j = 0; j < 4; ++j){
						if( p.pzl[4].c[pos] == ChangeCase( p.pieces[i][j].c[(pos+2)%4] ) ){
							p.bUsed[i] = true;
							p.pzl[ cp[pos] ] = p.pieces[i][j];
							solve( p, pos<3?1:2, (pos+1)%4, ans );
							p.bUsed[i] = false;
						}
					}
				}
			}
			break;
		case 2:
			for(int i = 0; i < MAX; ++i){
				if( !p.bUsed[i] ){
					for(int j = 0; j < 4; ++j){
						if( p.pzl[ cfp[pos] ].c[ cfpp[pos] ] == ChangeCase( p.pieces[i][j].c[(cfpp[pos]+2)%4] ) &&
							p.pzl[ csp[pos] ].c[ cspp[pos] ] == ChangeCase( p.pieces[i][j].c[(cspp[pos]+2)%4] ) ){
							p.bUsed[i] = true;
							p.pzl[ ccp[pos] ] = p.pieces[i][j];
							if( pos == 3 ){
								++ans;
								//cout << ans << endl;
							}else{
								solve( p, 2, pos+1, ans );
							}
							p.bUsed[i] = false;
						}
					}
				}
			}
			break;
	}
}

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

	for(int i = 0; i < n; ++i){
		int ans = 0;
		puzzle p;
		for(int j = 0; j < MAX; ++j){
			string s;
			cin>>s;
			for(int k = 0; k < 4; ++k){
				p.pieces[j][0].c[k] = s[k];
			}
		}
		p.CreateRotations();

		solve( p, 0, 0, ans );

		printf("%d\n", ans);
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    vvi adj(N);
    for (int i=0;i<N-1;i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vi depths(N, -1);
    depths[0] = 0;

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

    while(!bfs.empty()) {
        int cur = bfs.front();
        bfs.pop();

        for (int nbr : adj[cur]) {
            if (depths[nbr] == -1) {
                depths[nbr] = depths[cur] + 1;
                bfs.push(nbr);
            }
        }
    }

    vi odd;
    vi even;

    for (int i=0;i<N;i++) {
        if (depths[i] % 2 == 0) even.push_back(i);
        else odd.push_back(i);
    }

    vb used(N+1, false);
    vi perm(N, -1);

    if (odd.size() <= N / 3) {
        for (int i=0;i<odd.size();i++) {
            perm[odd[i]] = 3*(i+1);
            used[3*(i+1)] = true;
        }
    } else if (even.size() <= N / 3) {
        for (int i=0;i<even.size();i++) {
            perm[even[i]] = 3*(i+1);
            used[3*(i+1)] = true;
        }
    } else {
        for (int i=1;i<=N;i+=3) {
            perm[odd[(i-1)/3]] = i;
            used[i] = true;
        }
        for (int i=2;i<=N;i+=3) {
            perm[even[(i-2)/3]] = i;
            used[i] = true;
        }
    }

    int ind = 1;
    for (int i=0;i<N;i++) {
        if (perm[i] == -1) {
            while (used[ind]) ind++;
            perm[i] = ind;
            used[ind] = true;
        }
    }
    
    for (int i=0;i<N;i++) cout << perm[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 16880
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int MAXN = 73;
typedef long long LL;
const LL MOD = 1000000007;
int N, M, minLen[MAXN], Belong[MAXN], Last[MAXN];
char S[MAXN];
LL Data[MAXN][MAXN], C[MAXN][MAXN], Fact[MAXN], factIne[MAXN], Ine[MAXN], Ans;
vector<int> Seq;
inline void Init()
{
	for(int I = 0; I <= 70; ++I)C[I][0] = 1;
	for(int I = 1; I <= 70; ++I)
		for(int J = 1; J <= I; ++J){
			C[I][J] = C[I - 1][J] + C[I - 1][J - 1];
			if(C[I][J] >= MOD)C[I][J] -= MOD;
		}
	Fact[1] = 1;
	Ine[1] = Ine[0] = 1;
	factIne[1] = factIne[0] = 1;
	for(int I = 2; I <= 70; ++I){
		Fact[I] = Fact[I - 1] * I % MOD;
		Ine[I] = (LL)(MOD - MOD / I) * Ine[MOD % I] % MOD;
		factIne[I] = (LL)factIne[I - 1] * Ine[I] % MOD;
	}
}
inline bool Check()
{
	memset(Belong, -1, sizeof(Belong));
	memset(Last, 0, sizeof(Last));
	int Size = Seq.size(), P = 0;
	if(!Size)return false;
	for(int I = 1; I <= M; ++I){
		if(S[I] == 'r'){
			Belong[I] = P;
			Last[P] = I;
			++P;
			if(P == Size)break;
		}
	}
	if(P < Size)return false;
	P = 0;
	while(!Seq[Size - 1] && Size)--Size;
	if(!Size)return true;
	for(int I = 1; I <= M; ++I){
		if(S[I] == 'b' && I > Last[P]){
			Belong[I] = P;
			++P;
			if(P == Size)break;
		}
	}
	if(P < Size)return false;
	int Free = 0;
	for(int I = M; I; --I){
		if(Belong[I] == -1)++Free;
		else if(S[I] == 'b'){
			int Need = Seq[Belong[I]] + 1 - 2;
			if(Need > Free)return false;
			Free -= Need;
		}
	}
	return true;
}
inline void Calc(int Len, vector<LL> V)
{
/*	cout<<"Working..."<<endl;
	for(int I = 1; I <= N; ++I)cout<<V[I]<<" ";
	cout<<endl;*/
	LL Now = 0;
	int Size = Seq.size();
	for(int X = Len; X <= N; ++X){
		int Left = N - (Size - 1) - X;
		Now += (LL)V[X] * C[Left + Size][Size] % MOD;
		if(Now >= MOD) Now -= MOD;
	}
	int Cnt[MAXN] = {0};
	for(int I = 0; I < Size; ++I)++Cnt[Seq[I]];
	Now = Now * Fact[Size] % MOD;
	for(int I = 0; I <= M; ++I)
		if(Cnt[I] > 1)Now = Now * factIne[Cnt[I]] % MOD;
	Ans += Now;
	if(Ans >= MOD)Ans -= MOD;
}
void Dfs(int Len, int Rest, int maxSpace, vector<LL> V, bool needCalc, int Tot)
{
	if(needCalc && Check())Calc(Tot, V);
	if(Len < 0)return;
	Dfs(Len - 1, Rest, maxSpace, V, 0, Tot);
	if(Len + 1 > Rest || minLen[Len] > maxSpace)return;
	vector<LL> newV(MAXN);
	for(int I = 0; I <= N; ++I){
		if(V[I]){
			for(int J = I + minLen[Len]; J <= N; ++J){
				newV[J] += (LL)V[I] * Data[Len][J - I] % MOD;
				if(newV[J] >= MOD)newV[J] -= MOD;
			}
		}
	}
	Seq.push_back(Len);
	Dfs(Len, Rest - Len - 1, maxSpace - minLen[Len] - 1, newV, 1, Tot + minLen[Len]);
	Seq.pop_back();
}
int main()
{
	Init();
	scanf("%d%d", &N, &M);
	scanf("%s", S + 1);
	for(int I = 1; I <= N; ++I)
		Data[0][I] = 1;
	minLen[0] = 1;
	for(int I = 1; I <= N; ++I){
		int T[5] = {I * 2 - 1, I * 2, I * 2, I * 2 + 1};
		minLen[I] = T[0];
		if(T[0] > N)break;
		for(int J = 0; J < 5; ++J)
			for(int K = T[J]; K <= N; ++K){
				Data[I][K] += C[K - 1][T[J] - 1];
				if(Data[I][K] >= MOD) Data[I][K] -= MOD;
			}
	}
	vector<int> V1;
	vector<LL> V2(MAXN);
	V2[0] = 1;
	Dfs(N / 2 + 1, M, N, V2, 0, 0);
	cout << (Ans + 1) % MOD << endl;
	return 0;
}


Measured memory_bytes: 384
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int rec(int n)
{
	if(n==0) return 1;
	else if(n<0) return 0;
	return rec(n-4)|rec(n-7);
}

int main(){ FastIO;

ll n,i,j,k;cin>>n;
string res="";
i=0;
if(n==0) cout<<0;
else{

while(n!=0)
{
	if(abs(n)%(ll)pow(2,i+1)!=0)
	{
		res+="1";
		if(i%2==0){
			n-=(ll)pow(2,i);
		}
		else n+=(ll)pow(2,i);
	}
	else
	{
		res+="0";
	}
	i++;
}
for(i=res.length()-1;i>-1;i--)
{
	cout<<res[i];
}
}
return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i){
        cin >> vec.at(i);
    }
    int a = vec.at(n - 1);
    vector<int> v(n);
    for(int i = n - 1; i >= 0; --i){
        v.at(i) = a - vec.at(i);
        a = max(a, vec.at(i));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int z = 1;
    for(int i = 0; i < n - 1; ++i){
        if(v.at(i) == v.at(i + 1)){
            z++;
        }
        else{
            break;
        }
    }
    cout << z << nl;
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
awk '$0=NR%2FS$NF' RS=\ |sort|uniq -c|sort -n|awk 's+=$1{$2?(b=a)>(a=$1)*(c=$3):(e=d)>(d=$1)*(f=$3)}END{print s-(c~f?a+e<b+d?b+d:a+e:a+d)}'

Measured memory_bytes: 11780
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>

int main() {
  using namespace std;
  namespace mp = boost::multiprecision;
  using Bint = mp::cpp_int;

  Bint UB = pow(Bint(10), 80);
  int n;
  cin >> n;
  while (n--) {
      Bint a, b;
      cin >> a >> b;
      Bint c = a + b;
      if (a >= UB || b >= UB || c >= UB) {
          cout << "overflow";
      } else {
          cout << c;
      }
      cout << endl;
  }
}



Measured memory_bytes: 3220
#include <iostream>
#include <numeric>
#include <algorithm>
#include <string>
#include <vector>

int main(void)
{
  std::string S;
  std::cin >> S;

  std::vector<std::string> checker;

  size_t pos = 0;
  for(size_t i = 2, end = S.size(); i < end; i+=2, pos+=1){
    checker.push_back(S.substr(0, i));
  }

  for(auto it = checker.rbegin(), end=checker.rend(); it != end; ++it){
    if(it->substr(0, it->size()/2) == it->substr(it->size()/2)){
      std::cout << it->size() << std::endl;
      return 0;
    }
  }
  return -1;
}






Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := map[int]int{}
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}

	var ans int
	for k, v := range m {
		if k != v {
			if k > v {
				ans += v
			} else {
				ans += v - k
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8960
# -*- coding; utf 8 -*-
# Guidebook
# 2019. 5/28
# 市名をアルファベット順
# 同じ市内なら点数が高い順
# 出力は与えられた番号 (1 origin)


class Guidebook(object):
    def __init__(self, num, city, score):
        self.num = num
        self.city = city
        self.score = score


def print_number(N, guidebook):
    for i in range(N):
        print(guidebook[i].num)


def score_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if guidebook[j].score < guidebook[j+1].score:
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


def city_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if str(guidebook[j].city) > str(guidebook[j+1].city):
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


if __name__ == '__main__':
    N = int(input()) # number of restaurants
    guidebook = []
    for i in range(N):
        s, p = input().split()
        restaurant = Guidebook(i+1, s, int(p))
        guidebook.append(restaurant)

    score_sort(N, guidebook)
    city_sort(N, guidebook)
    print_number(N, guidebook)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  string s;
  cin>>s;
  for(int i=s.size()-1;i>=0;i--)cout<<s[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3012
#include <cstdio>
int N, kmp[200001], G = 1;
char s[200002];
long long L, R, len[666], ans[666][26], O[26];
void Calc(long long x, int f)
{
	for (int i = G; i; i--)
		if (len[i] <= x)
		{
			x -= len[i];
			for (int j = 0; j < 26; j++)
				O[j] += f * ans[i][j];
		}
	for (int i = 1; i <= x; i++)
		O[s[i] - 'a'] += f;
}
int main()
{
	scanf("%s", s + 1);
	while (s[N + 1])
		N++;
	scanf("%lld%lld", &L, &R);
	for (int i = 2; i <= N; i++)
	{
		int ans = kmp[i - 1];
		while (ans && s[ans + 1] != s[i])
			ans = kmp[ans];
		if (s[ans + 1] == s[i])
			kmp[i] = ans + 1;
		else
			kmp[i] = 0;
	}
	int E = N;
	while (E + E >= N)
		E = kmp[E];
	N -= E;
	if (kmp[N] << 1 >= N || kmp[N] == 0)
	{
		int T = N - kmp[N];
		for (int i = 1; i <= T; i++)
			O[s[i] - 'a'] += (R + T - i) / T - (L - 1 + T - i) / T;
		for (int i = 0; i < 26; i++)
			printf("%lld%c", O[i], " \n"[i == 25]);
		return 0;
	}
	len[0] = N - kmp[N];
	len[1] = N;
	for (int i = 1; i <= N - kmp[N]; i++)
		ans[0][s[i] - 'a']++;
	for (int i = 1; i <= N; i++)
		ans[1][s[i] - 'a']++;
	while (len[G - 1] + len[G] <= R)
	{
		len[G + 1] = len[G - 1] + len[G];
		for (int i = 0; i < 26; i++)
			ans[G + 1][i] = ans[G - 1][i] + ans[G][i];
		G++;
	}
	Calc(R, 1);
	Calc(L - 1, -1);
	for (int i = 0; i < 26; i++)
		printf("%lld%c", O[i], " \n"[i == 25]);
	return 0;
}


Measured memory_bytes: 1152
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n,m,k,a[200005],b[200005];

int main()
{
	FIO;
	cin >> n >> m >> k;
	rep(i,1,n) cin >> a[i];
	rep(i,1,m) cin >> b[i];
	LL c2 = 0, t1 = 0, t2 = 0;
	rep(i,1,m) {
		if(t2+b[i] <= k) {
			c2 = i;
			t2 += b[i];
		}
		else break;
	}
	LL ans = c2;
	rep(i,1,n) {
		if(t1+a[i] > k) break;
		t1 += a[i];
		while(t1+t2 > k) {
			t2 -= b[c2];
			c2--;
		}
		ans = max(ans, i+c2);
		// cout << i << " " << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<int> wa(N+1, 0), ac(N+1, 0);
    for (int i = 0; i < M; ++i) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            ac[p] = 1;
        } else if (ac[p] != 1) {
            ++wa[p];
        }
    }
    for (int i = 1; i < N + 1; ++i) {
        if (ac[i] == 1) {
            ++ac[0];
            wa[0] += wa[i];
        }
    }
    printf("%d %d\n", ac[0], wa[0]);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    
    int n, i, j, k, v;
    int a[100];
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
        scanf("%d", &a[i]);
    
    for(i = 0; i < n; i++){
        printf("%d", a[i]);
        if(i != n - 1)
            printf(" ");
    }
    printf("\n");
    
    for(i = 1; i < n; i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && v < a[j]){
            a[j+1] = a[j];
            --j;
        }
        a[j + 1] = v;
        for(k = 0; k < n; k++){
            printf("%d", a[k]);
            if(k != n - 1)
                printf(" ");
        }
        printf("\n");
    }
}

Measured memory_bytes: 1848
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]);
        int B = int.Parse(s[1]);
        Console.WriteLine((A + B) % 24);
    }

}


Measured memory_bytes: 11092
#include <stdio.h>

void bubblesort(int *N,int len){
    
    int i,j;
    int temp;
    for(i=0; i<len; i++){
        for(j=len-1; j>i; j--){
            if(N[j] < N[j-1]){
                temp = N[j];
                N[j] = N[j-1];
                N[j-1] = temp;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
    int N=0;
    int L[200];
    int i;
    int sum=0;
    //N本設定
   scanf("%d",&N);
    //L入力
   for(i=0;i<2*N;i++){
        scanf("%d",&L[i]);
   }

    
    //ソート降順
    bubblesort(L,2*N);

    //奇数ごとにとって足す
    for(i=0;i<2*N;i+=2){
        
        sum+=L[i];
        
    }
    
    //sum表示
    printf("%d\n",sum);
    
    
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
char str[N];
int ret[N] = {0};

int main() {
    scanf("%s", str);
    int len = strlen(str);
    int i = 0, j = 0, k = 0;
    int left, right, tmp, sum;
    for(i=0;i<len;i++) {
        if(str[i] == 'R') {
            j ++;
            continue;
        }else {
            left = i - 1;
            right = i;
            while(i < len && str[i] == 'L') {
                i ++;
                k ++;
            }
            tmp = max(j, k) - 1;
            sum = j + k;
            if(sum % 2 == 0) {
                ret[left] = ret[right] = sum / 2;
            }else if(j < k) {
                if(tmp % 2 == 1) {
                    ret[left] = (sum + 1) / 2;
                    ret[right] = (sum - 1) / 2;
                }else {
                    ret[left] = (sum - 1) / 2;
                    ret[right] = (sum + 1) / 2;
                }
            }else {
                if(tmp % 2 == 1) {
                    ret[left] = (sum - 1) / 2;
                    ret[right] = (sum + 1) / 2;
                }else {
                    ret[left] = (sum + 1) / 2;
                    ret[right] = (sum - 1) / 2;
                }
            }
            j = 0, k = 0;
            i --;
        }
    }
    printf("%d", ret[0]);
    for(i=1;i<len;i++) {
        printf(" %d", ret[i]);
    }
    printf("\n");
}

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

int r,g,b;

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


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  string o,e,s;
  s=o;
  s+=e;
  cin>>o>>e;
  if (o.size()>e.size())
  {
    rep(i,o.size())
    {
      if(i==o.size()-1)
      {
        cout<<(o[i]);
      }else
      {
        cout<<(o[i]);
        cout<<(e[i]);
      }
    }
  }else
  {
    rep(i,o.size())
    {
      cout<<(o[i]);
      cout<<(e[i]);
    }
  }

  
  
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.stream.IntStream;

import javax.script.ScriptException;

public class Main {

	/** 時間帯の数 */
	private static final Integer TIME = 10;

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextLine();
			// 各店舗の営業時間帯の配列
			int[] f = new int[n];
			IntStream.range(0, n).forEach(i -> f[i] = Integer.parseInt(scanner.nextLine().replaceAll(" ", ""), 2));
			// 利益の配列
			int[][] p = new int[n][TIME + 1];
			IntStream.range(0, n)
					.forEach(i -> IntStream.rangeClosed(0, TIME).forEach(j -> p[i][j] = scanner.nextInt()));
			System.out.println(IntStream.range(1, pow(2, TIME)).map(i -> calcResult(i, n, f, p)).max().getAsInt());
		}
	}

	/**
	 * nのmべき乗を返す
	 * 
	 * @param n
	 * @param m
	 * @return nのmべき乗
	 */
	private static int pow(int n, int m) {
		int result = 1;
		while (m > 0) {
			if (1 == (m & 1)) {
				result *= n;
			}
			n *= n;
			m >>= 1;
		}
		return result;
	}

	/**
	 * 現在の営業時間帯で得られる利益を計算する
	 * 
	 * @param t 現在の営業時間帯
	 * @param n 店舗の数
	 * @param f 各店舗の営業時間帯
	 * @param p 利益の配列
	 * @return 現在の営業時間帯で得られる利益
	 */
	private static int calcResult(int t, int n, int[] f, int[][] p) {
		return IntStream.range(0, n).map(i -> p[i][sameCount(t, f[i])]).sum();
	}

	/**
	 * 2つの店舗の営業時間帯が同じものカウントを計算する
	 * 
	 * @param t1 営業時間帯1
	 * @param t2 営業時間帯2
	 * @return 2つの店舗の営業時間帯が同じものカウント
	 */
	private static int sameCount(int t1, int t2) {
		return Integer.bitCount(t1 & t2);
	}
}


Measured memory_bytes: 29916
import numpy as np

N, M, X = map(int, input().split())

C = [0] * N
A = np.zeros((N, M), np.int64)
for i in range(N):
    Y = [int(k) for k in input().split()]
    C[i] = Y[0]
    A[i, :] = Y[1:]
ans = float('inf')
for bits in range(1 << N):
    sum = 0
    U = np.zeros(M, np.int64)
    for i in range(N):
        if (bits >> i) & 1:
            sum += C[i]
            U += A[i, :]
    if np.count_nonzero(U >= X) == M:
        ans = min(ans, sum)
print(ans if ans != float('inf') else -1)

Measured memory_bytes: 27288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int main() 
{
	int N , X;
	cin >> N >> X;
	int L[100] = {0};
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}
	int distance = 0;
	int cnt = 1;
	for (int i = 0; i < N; i++)
	{
		distance += L[i];
		if (distance <= X)
		{
			cnt++;
		}
	}

	cout << cnt << endl;

	
}

Measured memory_bytes: 256
N = int(input()) + 1
Ans = []
def dfs(depth, p):
    if depth==0:
        Ans.append(p)
        if len(Ans) == N:
            print(p)
            exit()
        return
    if p!=0:
        for digit in range(max(0, p%10-1), min(10, p%10+2)):
            dfs(depth-1, p*10+digit)
    else:
        for digit in range(10):
            dfs(depth-1, p*10+digit)
dfs(10, 0)


Measured memory_bytes: 13244
#include <stdio.h>

int main(void)
{
	int h,m,s,S;
	int amari;
	scanf("%d",&S);
	h=S/3600;
	amari=S%3600;
	m=amari/60;
	amari=amari%60;
	s=amari;
	printf("%d:%d:%d\n",h,m,s);
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli Q, H, S, D;
    cin >> Q >> H >> S >> D;
    lli N;
    cin >> N;
    Q *= 4;
    H *= 2;
    lli lit1 = min(Q, min(H, S));
    lli price = 0;
    if (2 * lit1 <= D)
    {
        cout << lit1 * N << endl;
    }
    else
    {
        cout << (int)(N / 2) * D + (N % 2) * lit1 << endl;
    }
    return 0;
}


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

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0 ; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int b[3]{};
	for (b[0] = 0; b[0] <= 100; b[0]++) {
		for (b[1] = 0; b[1] <= 100; b[1]++) {
			for (b[2] = 0; b[2] <= 100; b[2]++) {
				int c[3] = {a[0][0] - b[0], a[0][1] - b[0], a[0][2] - b[0]};
				for (int i = 0; i < 3; i++) {
					for (int j = 0; j < 3; j++) {
						if (a[i][j] != b[i] + c[j]) {
							goto next;
						}
					}
				}
				cout << "Yes" << endl;
				return 0;
				next:;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
import string 
def convertbase26(N):
    n=26
    X=N-1
    if (int(X//n)):
        return convertbase26(int(X//n))+string.ascii_lowercase[X%n]
    return string.ascii_lowercase[X%n]


N=int(input())
rank=1
base=0
"""
while(1):
    base=26**(rank)+1
    if base>N:
        break
    N-=26**(rank-1)
"""
print( convertbase26(N) )

Measured memory_bytes: 9924
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
using ll = long long;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a;
	rep(i, n) {
		int a0;
		cin >> a0;
		a.push_back(a0);
	}

	sort(all(a));

	vector<pair<int, int>> bc;
	int b, c;
	rep(i, m) {
		cin >> b >> c;
		bc.push_back(make_pair(b, c));
	}
	sort(all(bc), compareSecond);

	vector<int> a0(n, 0);
	int index = 0;
	rep(i, m) {
		rep(j, bc[i].first) {
			a0[index] = bc[i].second;
			index++;
			if (index >= n) {
				break;
			}
		}
		if (index >= n) {
			break;
		}
	}
	ll ans = 0;
	rep(i, n) {
		ans += max(a[i], a0[i]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;

const int N = 3001;
const int mod = 998244353;

int n, s;
int a[N];
ll dp[N][N];

int main(){
    IOS

    cin >> n >> s;
    FOR(i,1,n){
        cin >> a[i];
    }
    dp[0][0] = 1;
    FOR(i,1,n){
        FOR(j,0,s){
            dp[i][j] = (dp[i][j] + 2 * dp[i-1][j]) % mod;
            if(j + a[i] <= s){
                dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i-1][j]) % mod; 
            }
        }
    }
    cout << dp[n][s];

    return 0;
}

Measured memory_bytes: 73852