akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var N, M int
var matrix [8][]int
var ans int

func dfs(v int, done []int) {
	//訪問中の点の他に、訪問していない点があれば、続ける
	end := true
	for i := 0; i < N; i++ {
		if done[i] != 1 && i != v {
			end = false
		}
	}
	if end {
		ans++
		return
	}

	//訪問中の点を、訪問済みにする
	done[v] = 1
	//次の候補について
	for _, nv := range matrix[v] {
		//訪問済みの場合はスキップ
		if done[nv] == 1 {
			continue
		}
		//未訪問の場合は、再帰呼び出し
		dfs(nv, done)
	}

	//次の候補が無くなったら、自分を未訪問として、おわり
	done[v] = 0
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M = nextInt(), nextInt()

	for i := 0; i < M; i++ {
		var a, b int
		a, b = nextInt(), nextInt()
		a--
		b--
		matrix[a] = append(matrix[a], b)
		matrix[b] = append(matrix[b], a)
	}

	done := make([]int, N)
	ans = 0
	dfs(0, done)

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
    while(1)
    {
        int a,b,c;

        std::cin >> a >> b;

        if (a == 0 && b == 0) {
            break;
        }

        if (a >= b) {
            c = a;
            a = b;
            b = c;
        }


        std::cout << a << " " << b << std::endl;
    }

    return 0;


}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;
// int64_t INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    ll res = INF;
    for(ll i=1; i<=ceil(sqrt(n)); i++){
        if(n%i==0){
            ll a = i;
            ll b = n/i;
            ll f = max(to_string(a).size(), to_string(b).size());
            res = min(res, f);
        }
    }
    cout << res << endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    cin >> N;
    double ans = 0;
    rep(i, N){
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") x *= 380000;
        ans += x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[[0 for i in range(13)]for j in range(4)]
for k in range(n):
    card=input().split()
    p=5
    if (card[0]=="S"):
        p=0
    elif (card[0]=="H"):
        p=1
    elif (card[0]=="C"):
        p=2
    else:
        p=3
    q=int(card[1])-1
    a[p][q]=1
for i in range(4):
    for j in range(13):
        if a[i][j]==0:
            type=""
            if i==0 :
                type="S"
            elif i==1:
                type="H"
            elif i==2:
                type="C"
            else:
                type="D"
            print("{0} {1}".format(type,j+1))

Measured memory_bytes: 5604
#include <stdio.h>

int main(void) {
        int n,m;

        scanf("%d %d",&n,&m);

        int sum, sum_n, sum_m;

        if (n == 1 || n == 0) sum_n = 0;
        else sum_n = n * (n-1) / 2;

        if (m == 1 || m == 0) sum_m = 0;
        else sum_m = m * (m-1) / 2;

        sum = sum_n + sum_m;

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

        return 0;
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, k = na()
h = na()
c = 0
for hi in h:
    if hi >= k:
        c += 1

print(c)

Measured memory_bytes: 12272
#include <iostream>
#include <vector>
#include <list>
#define POS_MAX  10000
#define GRID     40
#define GRID_NUM 250 // POS_MAX / GRID


struct pos_t {
    pos_t() {}
    pos_t(int _x, int _y) : x(_x), y(_y) {}
    pos_t(std::istream *is) { (*is) >> x >> y; }
    int x, y;
};


void process(const int AN, const int BN, const int R)
{
    std::vector<pos_t> as(AN), bs(BN);
    for (int i = 0; i < AN; ++i) as[i] = pos_t(&std::cin);
    for (int i = 0; i < BN; ++i) bs[i] = pos_t(&std::cin);

    std::list<pos_t*> bs_grid[GRID_NUM][GRID_NUM];
    for (int i = 0; i < BN; ++i)
    {
        int gx(bs[i].x / GRID), gy(bs[i].y / GRID);
        bs_grid[gx][gy].push_back(&bs[i]);
    }

    int sum(0);
    for (int i = 0; i < AN; ++i)
    {
        pos_t &a = as[i];
        int gx(as[i].x / GRID), gy(as[i].y / GRID);

        for (int dx = -1; dx <= 1; ++dx)
        {
            int tx(gx + dx);
            if (tx < 0 or tx >= GRID_NUM) continue;
            
            for (int dy = -1; dy <= 1; ++dy)
            {
                int ty(gy + dy);
                if (ty < 0 or ty >= GRID_NUM) continue;

                std::list<pos_t*> &g = bs_grid[tx][ty];
                std::list<pos_t*>::iterator it;
                for (it = g.begin(); it != g.end(); ++it)
                {
                    int dx((*it)->x - a.x), dy((*it)->y - a.y);
                    if (dx*dx + dy*dy <= 16 * R * R)
                        ++sum;
                }
            }
        }
    }

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


int main()
{
    int AN, BN, R;
    do
    {
        std::cin >> AN >> BN >> R;
        if (AN > 0 and BN > 0 and R > 0) process(AN, BN, R);
    }
    while(AN > 0);
    
    return 0;
}

Measured memory_bytes: 6600
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a,b,n;
int main()
{
    cin>>n>>a>>b;
    if((b-a)%2==0)
        cout<<"Alice\n";
    else
        cout<<"Borys\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 200003
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    lli t1,x1,y1;
    t1=0,x1=0,y1=0;
    lli t2,x2,y2;
    int flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>t2>>x2>>y2;
        lli temp=abs(x2-x1)+abs(y2-y1);
       if(temp==0)
       {
           if(abs(t2-t1)%2!=0)
               flag=1;
       }
        else
        {
           if(abs(t2-t1)%temp!=0)
        {
            flag=1;
        }  
        }
       
        t1=t2;
        x1=x2;
        y1=y2;
     }
    if(flag)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    
        
        
    
    return 0;
}    

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let h:usize = read();
    let w:usize = read();

    let map: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut ans_map: Vec<Vec<i32>> = vec![vec![0;w];h];

    for (i,s) in map.iter().enumerate() {
        for (j,c) in s.iter().enumerate() {
            if c == &'#' {
                ans_map[i][j] = -1;
                
                for local_i in i..i+3{
                    for local_j in j..j+3{
                        let i_local_i = (local_i as i32) - 1;
                        let i_local_j = (local_j as i32) - 1;
                        if i_local_i < 0 || i_local_i >= h as i32 || i_local_j < 0 || i_local_j >= w as i32{
                            continue;
                        }
                        if ans_map[local_i - 1][local_j - 1] < 0 {
                            continue;
                        }
                        ans_map[local_i - 1][local_j - 1] += 1;
                    }
                }
            }
            //println!("i{},j{},c{}",i,j,c);        
        }
    }
    for v in ans_map.iter() {
        for c in v.iter(){
            if c < &0 {
                print!("#");
            }else{
                print!("{}",c);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		while (true) {
			int num = scanner.nextInt();
			if (num == -1) {
				break;
			}
			double c = 0;
			double d = 0;
			for (int i = 1; i <= num; i++) {
				c = Math.sqrt(1 + c * c);
				if (i != num)
					d += Math.atan2(1, c);
			}
			System.out.println(Math.cos(d) * c);
			System.out.println(Math.sin(d) * c);
		}
	}
}

Measured memory_bytes: 17204
#include <stdio.h>
int main()
{
    int n,s,i;
    scanf("%d",&n);
    s=n/10;
    i=n%10;
    if(s==9||i==9){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N, M; cin >> N >> M;
	ll* A = new ll[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i]; A[i]--;
	}

	ll* C = new ll[M];
	ll* B = new ll[M];
	for (int i = 0; i < M; i++) { B[i]=0, C[i] = 0; }

	int c = -1;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] > A[i + 1]) { c++; }
		B[A[i + 1]] += (A[i + 1] + M - A[i]) % M;
	}
	for (int i = 0; i < M; i++) {
		C[i] = c;
	}
	for (int i = 0; i <= A[N - 1]; i++) {
		C[i]++;
	}
	for (int i = A[0] + 1; i < M; i++) {
		C[i]++;
	}

	ll s = 0;
	for (int i = 0; i < N - 1; i++) {
		s += min((A[i + 1] + M - A[i]) % M, 1 + A[i + 1]);
	}

	ll ans = s;

	//cout << s << endl;
	for (int i = 1; i < M; i++) {
		s -= C[i - 1];
		s += B[i - 1];
		ans = min(ans, s);
		//cout << s << endl;
	}

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

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    ll N,M;
    cin >> N >> M;
    ll ura;
    if(N != 1 && M != 1)
        ura = N*M - 4 - 2*(N-2) - 2*(M-2);
    else if(N == 1 && M == 1)
        ura = 1;
    else
        ura = max(N,M) - 2;

    cout << ura << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val xs = (1..n).map{ nextInt() - 1}
    var t = 0
    var current = 0
    while(current != 1 && t++ < n){
        current = xs[current]
    }
    print(if (current == 1) t else -1)
}

// 入力取得
fun next() = readLine()!!

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }
fun listOfDouble() = listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value: Any) {
    pw.println(value)
}

fun print(value: Any){
    pw.print(value)
}

Measured memory_bytes: 39208
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,op; cin>>n>>op; 
    string s;cin>>s;
    vi pref(n+2,0);
    for (int i=1;i<n;i++){
        if (s[i]=='C' and s[i-1] == 'A') pref[i]=1;
    }
    for (int i=1;i<n;i++)
        pref[i] += pref[i-1];
    while (op-->0){
        int l,r;
        cin>>l>>r; l--,r--;
        cout << (pref[r]-pref[l]) << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4240
def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    ht = [[0] * w for _ in range(h)]
    vt = [[0] * h for _ in range(w)]
    for i in range(h):
        st = 0
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                ht[i][st:j] = [c] * (j - st)
                st = j + 1
                c = 0
                continue
            c += 1
        ht[i][st:w] = [c] * (w - st)
    for i in range(w):
        st = 0
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                vt[i][st:j] = [c] * (j - st)
                st = j + 1
                c = 0
                continue
            c += 1
        vt[i][st:h] = [c] * (h - st)

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, ht[i][j] + vt[j][i])
    return str(ans - 1)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 140228
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
const int inf = 2147483647;
int r; 
int main()
{
	read(r);
	print(3 * r * r);
	return 0;
}

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

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

using ll = long long;
using namespace std;

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

    int n_500 = x / 500;
    int rem_500 = x % 500;

    int n_5 = rem_500 / 5;

    cout << (n_500 * 1000 + n_5 * 5) << endl;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int dp[2][1001000];

int f(string& n, int k) {
    return n[n.length() - 1 - k] - '0';
}

signed main() {
    string N;
    cin >> N;
    dp[0][0] = f(N, 0);
    dp[1][0] = 10 - f(N, 0);
    for (int i = 1; i < N.length(); ++i) {
        int fni = f(N, i);
        dp[0][i] = min(dp[0][i - 1] + fni, dp[1][i - 1] + fni + 1);
        dp[1][i] = min(dp[0][i - 1] + 10 - fni, dp[1][i - 1] + 10 - (fni + 1));
    }
    cout << min(dp[0][N.length() - 1], dp[1][N.length() - 1] + 1) << endl;
    return 0;
}


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

int P[101];

void init(int N)
{
	for (int i=0; i<N; ++i) 
	    P[i] = i;
} 

int root(int a)
{
	if(P[a]==a)   
	   return a;
	else  return(P[a]=root(P[a]));
}
 
bool is_same_set(int a,int b)
{
	return(root(a)==root(b));
}

void unite(int a,int b)
{
	P[root(a)]=root(b);
}

int main()
{
	int n;
	cin >> n;
	init(n);
	int a[101][101];
	for(int i=0;i<n;i++)
	   for(int j=0;j<n;j++)
	       cin >> a[i][j];
	int M=0;
	int cost[10100],src[10100],dst[10100];
	for(int r=0;r<n;r++)
	   for(int c=r+1;c<n;c++)
	      if(a[r][c]>-1)
	      {
	      	cost[M]=a[r][c];
	      	src[M]=r;
	      	dst[M]=c;
	      	M++;
		  }
	pair<int,int> edges[10100];
	for(int i=0;i<M;i++)
	{
		edges[i].first=cost[i];
		edges[i].second=i;
	}
	sort(edges,edges+M);
	int sum=0;
	for(int i=0;i<M;i++)
	{
		if(is_same_set(src[edges[i].second],dst[edges[i].second]))
		  continue;
		unite(src[edges[i].second],dst[edges[i].second]);
		sum+=edges[i].first;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    int sz;
    sz = s.size();
    cout << sz << endl;
}




Measured memory_bytes: 9508
#include<iostream>
#include<string>
#define rep(i, n) for ( int i = 0; i < n; i++ )
using namespace std;
#define MAX 100
/*
  4
3 0 2 5
  1
 */
class Cube{
    public:
    int f[6];
    Cube(){
	f[4] = 1; f[0] = 3;f[1] = 6; f[2] = 5; f[5] = 4; f[3] = 2;
    }
    void roll(int i, int j, int k, int l){
	int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }

    void roll_front(){ roll(0, 4, 5, 1);} // roll_x * 3;
    void roll_back(){ rep(i, 3) roll_front();}
    void roll_right(){ roll(1, 2, 4, 3);}
    void roll_left(){ rep(i, 3) roll_right();}

    void init(int top, int front){
	rep(i, 6){
	    rep(j, 4){
		if ( top == f[4] && front == f[0] ) return;
		roll(1, 2, 4, 3); //z
	    }
	    if ( i % 2 == 0 ) roll(0, 2, 5, 3);//y
	    else roll(0, 1, 5, 4);//x
	}
    }
};

void simulate(int n){
    static const int N = 205;
    int t, f;
    int T[N][N], H[N][N];
    rep(i, N) rep(j, N)	T[i][j] = H[i][j] = 0;
    
    rep(i, n){
	cin >> t >> f;
	Cube c = Cube();
	c.init(t, f);
	int pi = 100;
	int pj = 100;
	
	bool rolled = true;
	while(rolled){
	    int dir = -1;
	    static const int di[4] = {0, 1, 0, -1};
	    static const int dj[4] = {-1, 0, 1, 0};
	    static const int fd[4] = {3, 0, 2, 5};
	    static const int td[3] = {4, 5, 6};
	    rep(t, 3) rep(r, 4){
		if ( td[t] == c.f[fd[r]] && H[pi][pj] > H[pi+di[r]][pj+dj[r]]) dir = r;
	    }
	    if ( dir == 0 ){ c.roll_left(); pj--; }
	    else if ( dir == 1 ){ c.roll_front(); pi++; }
	    else if ( dir == 2 ){ c.roll_right(); pj++; }
	    else if ( dir == 3 ){ c.roll_back(); pi--; }
	    rolled = (dir != -1);	    
	}
	H[pi][pj]++;
	T[pi][pj] = c.f[4];
    }

    int cnt[7];
    rep(i, 7) cnt[i] = 0;
    rep(i, N) rep(j, N) cnt[T[i][j]]++; 
    for ( int i = 1; i <= 6; i++ ){
	if ( i > 1 ) cout << " ";
	cout << cnt[i];
    }
    cout << endl;
}

main(){
    int n;
    while( cin >> n , n) simulate(n);
}

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

int main(){
  int n;
  long int r[200000];
  long int maxv=-1000000000000;
  long int minv=1000000000000;

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

  for(int i=0; i<n; i++){
    maxv = (maxv<(r[i]-minv))?(r[i]-minv):maxv;
    minv = (minv>r[i])?r[i]:minv;
  }
  cout << maxv << endl;
}




Measured memory_bytes: 4632
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	mn := math.MaxInt32
	for i := 1; i <= n/2; i++ {
		a := ds(i) + ds(n-i)
		if mn > a {
			mn = a
		}
	}

	fmt.Println(mn)
	writer.Flush()
}

func ds(x int) int {
	ans := 0
	for x > 0 {
		ans += x % 10
		x /= 10
	}
	return ans
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    string s;cin>>s;
    string good="ATCG";
    int ans=0;
    int now=0;
    rep(i,(int)s.size()){
        bool flag=false;
        rep(j,4){
            if(s[i]==good[j])flag=true;
        }
        if(!flag)now=0;
        else {
            now++;
            ans=max(ans,now);
        }
    }
    cout<<ans<<endl;
}



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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        double a, b, x;
        cin >> a >> b >> x;

        double y = (2*x - a*a*b) / (a*a);
        double alpha;
        if (y > 0) {
            double aux = b - y;
            alpha = 180 / acos(-1) * atan(aux / a);
        } else {
            y = (2 * x) / (a * b);
            alpha = 90.0 - (180 / acos(-1) * atan(y / b));
        }
        printf("%.10f\n", alpha);
    }
}


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

const int MAXN = 1e5 + 5;
int n, k, m;
string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        n += (s[i] == '+'? 1: -1);
    cout << n;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll N;
  cin >> N;
  ll a[N];
  ll i;
  ll ans[N];
  ans[0]=0;
  ll tmp=1;
  for(i=0;i<N;i++){
    cin >> a[i];
    ans[0]+=tmp*a[i];
    tmp*=-1;
  }
  for(i=0;i<N-1;i++){
    ans[i+1]=(a[i]-ans[i]/2)*2;
  }
  for(i=0;i<N;i++){
    cout << ans[i] <<" ";
  }
  return 0;
}

Measured memory_bytes: 2816
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

int main()
{
    int h,n,sum=0;
    scanf("%d %d",&h,&n);
    int a[n],i;
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    sum+=a[i];
    }
    if(sum>=h)
    printf("Yes");
    else
    printf("No");
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <stack>
#include <numeric>
#include <time.h>
#include<iomanip>
#include<sstream>
#pragma disable:4996)
using namespace std;
const long long inf = 0x7f7f7f7f;
long long GCD(long long a, long long b) { return 0 == b ? a : GCD(b, a%b); }
const long long mod = 1e9 + 7;
const double pi = acos(-1);
int main()
{
	ios_base::sync_with_stdio(false);
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
typedef long double lb;
using namespace std;
ll gcd(ll P, ll Q){
  return Q ? gcd(Q,P % Q):P;
}
ll lcm(ll P, ll Q){
  return P / gcd(P,Q) * Q;
}
string change_big(string str){
  transform(str.begin(), str.end(), str.begin(), ::toupper);
}
string change_small(string str){
  transform(str.begin(), str.end(), str.begin(), ::tolower);
}
int main(){
  string T,P;
  cin >> T >> P;
  string S;
  S = T + T;
  ll I = P.size();
  ll SI = S.size();
  for(int i = 0; i < SI - I; i++){
    ll ans = 0;
    for(int j = 0; j < I; j++){
      if(S[i + j] == P[j]){
        ans++;
      }
    }
    if(ans == I){
      cout << "Yes" << endl;
      break;
    }
    if(i == (SI - I - 1)){
      cout << "No" << endl;
    }
  }
}



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

typedef long long ll;

ll n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ll l = 1, r = n;
    while (l < r) {
        ll m = (r - l) / 2 + l;
        if (m * (1 + m) / 2 >= n) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    cout << l << endl;

    return 0;
}



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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
void rot_90(vector<vector<T>> &cur){
  int H = cur.size();
  int W = cur[0].size();
  vector<vector<T>> rot(W,vector<T>(H));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      rot[W-1 - j][i] = cur[i][j];
    }
  }
  cur = rot;
}

signed main(){

  int H,W; cin >> H >> W;
  vector<vector<char>> table(H,vector<char>(W));
  for(int i = 0; i < H; i++){
    string s; cin >> s;
    for(int j = 0; j < W; j++){
      table[i][j] = s[j];
    }
  }

  vector<vector<int>> dp(H,vector<int>(W,0));
  for(int k = 0; k < 4; k++){
    for(int i = 0; i < H; i++){
      int cnt = 0;
      for(int j = 0; j < W; j++){
        if(table[i][j] == '.') cnt++;
        else cnt = 0;
        dp[i][j] += cnt;
      }
    }
    rot_90(table);
    rot_90(dp);
    swap(H,W);
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans = max(ans,dp[i][j]);
    }
  }
  cout << max(0LL,ans-3) << endl;

  return 0;
}


Measured memory_bytes: 92800
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	result := -1
	for i:=1; i<=1009; i++{
		if int(float64(i) * 0.08) == a && int(float64(i) * 0.1) == b{
			result = i
			break
		}
	}

	fmt.Println(result)
}

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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) { cin >> a[i]; }
    int alice = 0, bob = 0;
    sort(a, a + N, greater<int>());
    rep(i, N) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice-bob << endl;
    return 0;
}

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

A = []
for i in range(N):
    M = int(input())
    T = {}
    for _ in range(M):
        x, y = map(int, input().split())
        T[x - 1] = y
    A.append(T)

def solve(state):
    memo = {i: (state >> i & 1) for i in range(N)}
    for i, a in enumerate(A):
        for x, y in a.items():
            if state >> i & 1:
                if x in memo and memo[x] != y:
                    return False
                memo[x] = y
    return True

ans = 0
for i in range(2 ** N):
    if solve(i):
        ans = max(ans, bin(i).count("1"))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
struct dot{
	int x,y,type;
};
bool comp(dot a,dot b){
	if(a.x!=b.x)return a.x>b.x;
	else return a.y>b.y;
}
int main(){
	int n,ans=0;
	priority_queue<int,vector<int>,greater<int>>tos;
	queue<int>que;
	cin>>n;
	vector<dot>a(n*2);
	for(int i=0;i<n;i++){
		cin>>a[i].x>>a[i].y;
		a[i].type=0;
	}
	for(int i=0;i<n;i++){
		cin>>a[i+n].x>>a[i+n].y;
		a[i+n].type=1;
	}
	sort(a.begin(),a.end(),comp);
	for(int i=0;i<n*2;i++){
		if(a[i].type==1){
			tos.push(a[i].y);
		}
		else if(a[i].type==0&&!tos.empty()){
			while(!tos.empty()){
				if(a[i].y<tos.top()){
					ans++;
					tos.pop();
					break;
				}
				else{
					que.push(tos.top());
					tos.pop();
				}
			}
			while(!que.empty()){
				tos.push(que.front());
				que.pop();
			}
		}
	}
	cout<<ans<<endl;
}


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

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<int> L(M), R(M), p(Q), q(Q);
    vector<vector<int>> ac(N + 1, vector<int> (N + 1, 0));
    for(int i = 0; i < M; i++){
        scanf("%d%d", &L[i], &R[i]);
        ac[L[i]][R[i]]++;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            ac[i][j] += ac[i - 1][j];
            ac[i][j] += ac[i][j - 1];
            ac[i][j] -= ac[i - 1][j - 1];
        }
    }

    for(int i = 0; i < Q; i++){
        scanf("%d%d", &p[i], &q[i]);
        cout << ac[q[i]][q[i]] - ac[p[i] - 1][q[i]] - ac[q[i]][p[i] - 1] + ac[p[i] - 1][p[i] - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) {
        sum += a[i];
    }
    vector<ll> x(n);
    // Calc x0
    x[0] = sum;
    for (int j = 1; j < n; j += 2) x[0] -= 2*a[j];
    // Calc x1, x2, ... xn-1
    repSE(i,1,n) {
        x[i] = 2 * a[i-1] - x[i-1];
    }
    rep(i,n) cout << x[i] << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 4780
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll mod = 998244353LL;
string s;
ll red[4005], blue[4005], dp[4005][4005];

int main() {
    cin >> s;
    int len = s.size();
    for (int i = 1; i <= len; i++) {
        if (s[i-1] == '0') {
            red[i] = red[i-1] + 2;
            blue[i] = blue[i-1];
        } else if (s[i-1] == '1') {
            red[i] = red[i-1] + 1;
            blue[i] = blue[i-1] + 1;
        } else {
            red[i] = red[i-1];
            blue[i] = blue[i-1] + 2;
        }
    }

    dp[0][0] = 1;
    for (int i = 1; i <= 2 * len; i++) {
        dp[i][0] = dp[i-1][0] * (blue[min(len, i)] >= i);
        for (int j = 1; j <= i; j++) {
            // 合計i個並べたときに、赤をj個を使っている場合の数
            dp[i][j] = (dp[i-1][j] * (blue[min(len, i)] >= i-j) + dp[i-1][j-1] * (red[min(len, i)] >= j)) % mod;
        }
    }

    ll ans = 0LL;
    for (int i = 0; i <= 2 * len; i++) {
        ans = (ans + dp[2 * len][i]) % mod;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 123776
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 int recursion(vector<int>&v, int end, int k)
 {
 	//cout<<end
 	if(end==0)
 		return 0;
 	if(end<0)
 		return 1e6;
 	int ans=1e6;
 	for(int i=1;i<=k;i++)
 	{
 		//find the ans for each child node and take the minimum out of it
 		if(end-i>=0)
 		{
 			int temp=recursion(v,end-i,k);
 			if(temp!=1e6)
 				ans=min(ans,temp+abs(v[end]-v[end-i]));	
 		} 
 		
 	}
 	return ans;
 }
 int recursion_with_memo(vector<int>&v, int end, int &k, map<int,int>&memo)
 {
 	if(end==0)
 		return 0;
 	//if(end<0)
 	//	return 1e6;
 	int ans=1e6;
 	for(int i=1;i<=k;i++)
 	{
 		if(end-i>=0)
 		{
 			if(memo.find(end-i)==memo.end())
 			{
 				//calu the value
 				int temp=recursion_with_memo(v,end-i,k,memo);
 				//save the value in memo table
 				memo[end-i]=temp;
 				ans=min(ans,temp+abs(v[end]-v[end-i]));
 			}
 			else
 				ans=min(ans,memo[end-i]+abs(v[end]-v[end-i]));

 		}
 	}
 	return ans;

 }
 int bottom_up(vector<int>&v,int k)
 {
 	int n=v.size();
 	vector<int>dp(n,1e9);
 	dp[0]=0;
 	//dp[1]=abs(v[1]-v[0]);
 	for(int i=1;i<n;i++)
 	{
 		for(int j=1;j<=k;j++)
 			if(i-j>=0)
 				dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
 	}
 	//for(int i=0;i<n;i++)
 	//	cout<<dp[i]<<" ";
 	return dp[n-1];
 }
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int t,k;
	cin>>t>>k;
	vector<int>v(t);
	for(int i=0;i<t;i++)
		cin>>v[i];
	//cout<<recursion(v,t-1,k);
	//recursion with memoization 
	//map<int,int>memo;
	//int ans=1e6;
	//cout<<recursion_with_memo(v,t-1,k,memo)<<endl;
	//for(auto it:memo)
	//	cout<<it.first<<" "<<it.second<<endl;
	cout<<bottom_up(v,k);

	
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w,n;
  cin>>h>>w>>n;
  Int sr,sc;
  cin>>sr>>sc;
  string s,t;
  cin>>s>>t;
  auto NO=[](){cout<<"NO"<<endl;exit(0);};
  // top  
  {
    Int y=sr,x=sc;
    (void)y;(void)x;
    for(Int i=0;i<n;i++){
      if(s[i]=='U') y--;
      if(y<=0) NO();
      if(t[i]=='D') y++;
      if(y>h) y=h;
    }
  }
  // bottom  
  {
    Int y=sr,x=sc;
    (void)y;(void)x;
    for(Int i=0;i<n;i++){
      if(s[i]=='D') y++;
      if(y>h) NO();
      if(t[i]=='U') y--;
      if(y<=0) y=1;
    }
  }
  // left  
  {
    Int y=sr,x=sc;
    (void)y;(void)x;
    for(Int i=0;i<n;i++){
      if(s[i]=='L') x--;
      if(x<=0) NO();
      if(t[i]=='R') x++;
      if(x>w) x=w;
    }
  }
  // right  
  {
    Int y=sr,x=sc;
    (void)y;(void)x;
    for(Int i=0;i<n;i++){
      if(s[i]=='R') x++;
      if(x>w) NO();
      if(t[i]=='L') x--;
      if(x<=0) x=1;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 776
#include <algorithm>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll ad1 = t1 * a1;
  ll ad2 = t2 * a2;
  ll bd1 = t1 * b1;
  ll bd2 = t2 * b2;

  if (ad1 < bd1 && ad1 + ad2 > bd1 + bd2) {
    ll d1 = bd1 - ad1;
    ll d2 = (ad1 + ad2) - (bd1 + bd2);
    ll num = d1 / d2;
    cout << num * 2 + 1 - (d1 % d2 == 0);
  } else if (bd1 < ad1 && bd1 + bd2 > ad1 + ad2) {
    ll d1 = ad1 - bd1;
    ll d2 = (bd1 + bd2) - (ad1 + ad2);
    ll num = d1 / d2;
    cout << num * 2 + 1 - (d1 % d2 == 0);
  } else if (ad1 + ad2 == bd1 + bd2) {
    cout << "infinity" << endl;
  } else {
    cout << 0 << endl;
  }

#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
import numpy as np
# 整数の入力
c1 = np.zeros((3,3),dtype=np.int64)
c2 = np.zeros((3,3),dtype=np.int64)
# スペース区切りの整数の入力
c1[0] = np.array(map(int, raw_input().split()))
c1[1] = np.array(map(int, raw_input().split()))
c1[2] = np.array(map(int, raw_input().split()))

c2[0] = c1[0] - c1[2]
c2[1] = c1[1] - c1[2]
c2[2] = c1[2] - c1[1]

b0 = ((c2[0,0] == c2[0,1]) and (c2[0,1] == c2[0,2]))
b1 = ((c2[1,0] == c2[1,1]) and (c2[1,1] == c2[1,2]))
b2 = ((c2[2,0] == c2[2,1]) and (c2[2,1] == c2[2,2]))

if (b0 and b1 and b2):
  print 'Yes'
else:
  print 'No'

Measured memory_bytes: 16220
#include <stdio.h>

int main() {
  int n;
  char suits[52];
  int ranks[52];
  int i, j;

  int cards[4][14] = {{}};

  scanf("%d ", &n);
  for(i = 0; i < n; ++i) {
    scanf("%c %d ", &suits[i], &ranks[i]);

    if(suits[i] == 'S') {
      cards[0][ranks[i]] = 1;
    } else if(suits[i] == 'H') {
      cards[1][ranks[i]] = 1;
    } else if(suits[i] == 'C') {
      cards[2][ranks[i]] = 1;
    } else if(suits[i] == 'D') {
      cards[3][ranks[i]] = 1;
    }
  }

  for(i = 0; i < 4; ++i) {
    for(j = 1; j <= 13; ++j) {
      if(cards[i][j] == 0) {
	if(i == 0) printf("S ");
	else if(i == 1) printf("H ");
	else if(i == 2) printf("C ");
	else if(i == 3) printf("D ");
	printf("%d\n", j);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2024
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    positions = get_next_ints()

    diffs = [0 for i in range(N)]
    dist = 0
    prev_pos = 0
    for i, pos in enumerate(positions):
        dist += abs(pos - prev_pos)

        next_pos = positions[i + 1] if i + 1 < N else 0
        if prev_pos <= pos <= next_pos or prev_pos >= pos >= next_pos:
            diff = 0
        else:
            diff = min(abs(next_pos - pos), abs(prev_pos - pos)) * 2
        diffs[i] = diff
        prev_pos = pos
    dist += abs(prev_pos)
    # print(dist)
    # print(diffs)
    for diff in diffs:
        print(dist - diff)


solve()

Measured memory_bytes: 14176
n = int(input())

S = []
for i in range(n):
    S.append(input())
    
max_temp = 1
count = {}
for s in S:
    if s in count:
        count[s] += 1
        if count[s]>max_temp:
            max_temp = count[s]
    else:
        count[s] = 1
        
res = [kv[0] for kv in count.items() if kv[1] == max_temp]
res.sort()

for i in res:
    print(i)

Measured memory_bytes: 35216
#include<iostream>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
int n,p;
int a;
int odd,even;
long long ans=1;
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> p;
	for(int i=1; i<=n ;i++){
		cin >> a;
		if(a%2==0) even++;
		else odd++;
	}
	for(int i=1; i<n ;i++) ans*=2;
	if(odd==0 && p==1) ans=0;
	else if(odd==0) ans*=2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
	int main()
{
	int n, i, j, card[4][13] = {0}, rank;
	char type;
	scanf("%d", &n);
	for(i = 0; i < n + n; i++){
		scanf("%c %d", &type, &rank);
		switch(type){
			case 'S' : card[0][rank - 1] += 1;
			break;
			case 'H' : card[1][rank - 1] += 1;
			break;
			case 'C' : card[2][rank - 1] += 1;
			break;
			case 'D' : card[3][rank - 1] += 1;
			break;
		}
		rank -= rank;
	}
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(card[i][j] == 0){
					switch(i){
						case 0 : printf("S %d\n", j+1);
						break;
						case 1 : printf("H %d\n", j+1);
						break;
						case 2 : printf("C %d\n", j+1);
						break;
						case 3 : printf("D %d\n", j+1);
						break;
					}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+2,MOD=3e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll arr[M],ar[M];
ll cnt=0,cost=0,mx=0,NODE,t,par,zero=0;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
   //freopen("kamona.txt","r",stdin);
    ll a,b,c=1,x,y,d,t,sum=0,mx=MOD,i,j,ans;
    cin>>a>>b;
    for(i=a;i<b&&c<=2019;i++)
    {
        d=1;
        for(j=a+1;j<=b&&d<=2019;j++)
        {
            ans=(i*j);
            x=ans%2019;
            if(x<mx)
            {
                mx=x;
            }
            d++;
        }
        c++;
    }
    cout<<mx<<endl;


        return 0;
    }


Measured memory_bytes: 256
import heapq

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

AB_array = [list(map(int, input().split())) for _ in range(N)]

AB_array = sorted(AB_array, key=lambda x: x[0])


h = []

ab_index = 0
ans = 0
for m in range(1, M+1):
    while ab_index != N:
        if AB_array[ab_index][0] == m:
            heapq.heappush(h, -AB_array[ab_index][1])
            ab_index += 1
        else:
            break

    if len(h):
        ans += - heapq.heappop(h)

print(ans)


Measured memory_bytes: 31976