akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;

ll powmod(ll x, ll n, ll m = MOD) {
    ll ans = 1;
    while(n) {
        if(n & 1) {
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}
int invmod(int x, int m = MOD) {
    return powmod(x, m - 2);
}

int ncr(int n, int r) {
    int num = 1, den = 1;
    rep(i, 1, r) {
        den = (den * i) % MOD;
        num = (num * (n - i + 1)) % MOD;
    }
    return num * invmod(den) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = powmod(2, n) - 1 - ncr(n, a) - ncr(n, b);
    ans = (ans % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}


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

const int nm = 2e5;
int n, m, ans = 0;
ll k, x[nm + 1], y[nm + 1];

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

	for (int i = 0; i <= n; ++i) {
		int inf = -1, sup = m + 1;
		while (sup - inf > 1) {
			int mid = (inf + sup) / 2;
			if (x[i] + y[mid] <= k)
				inf = mid;
			else
				sup = mid;
		}
		if (inf < 0)
			continue;
		ans = max(i + inf, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6756
#include<stdio.h>

int main () {
	int matrix[3][3];
	char x;
	
	for (int i = 0 ; i < 3 ; i++) {
		for (int j = 0 ; j < 3 ; j++) {
			scanf("%d", &matrix[i][j]);
		}
	}
	int n;
	scanf("%d", &n);
	int angka[n];
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &angka[i]);
		for (int j = 0 ; j < 3 ; j++) {
			for (int k = 0 ; k < 3 ; k++) {
				if (angka[i] == matrix[j][k]) {
					matrix[j][k] = x;
				}	
			}
		}
	}
	
	int counter[8] = {0};
	int akhir = 2;
	for (int i = 0 ; i < 3 ; i++) {
		if(matrix[i][0] == x)  {
			++counter[0];
		}
		if(matrix[i][2] == x) {
			++counter[1];
		}
		if(matrix[0][i] == x) {
			++counter[2];
		}
		if(matrix[2][i] == x) {
			++counter[3];
		}
		if(matrix[i][i] == x) {
			++counter[4];
		}
		if(matrix[i][akhir--] == x) {
			++counter[5];
		}
		if(matrix[1][i] == x) {
			++counter[6];
		}
		if(matrix[i][1] == x) {
			++counter[7];
		}
	}
	int flag = 0;
	for(int i = 0 ; i < 8 ; i++) {
		if(counter[i] == 3) {
			flag = 1;
		}
	}
	printf("%s\n", (flag == 1) ? "Yes" : "No") ;
	return 0;
}

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

int main(){
int n;
string s1="AC",s2="WA",s3="TLE",s4="RE",m;
int c1=0,c2=0,c3=0,c4=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>m;
    if(m==s1)c1++;
    else if(m==s2)c2++;
    else if(m==s3)c3++;
    else if(m==s4)c4++;

}
cout<<s1<<" x "<<c1<<endl<<s2<<" x "<<c2<<endl<<s3<<" x "<<c3<<endl<<s4<<" x "<<c4;

    return 0;
}



Measured memory_bytes: 3612
import sys
readline = sys.stdin.readline

inf = 10**9+7
def calc(W1, W2):
    H = len(W1)
    cost = [[0]*(1+H) for _ in range(1+H)]
    for i in range(H):
        for j in range(H):
            cost[i+1][j+1] = cost[i][j] + (1 if W1[i] == W2[j] else 0)
    dp = [[inf]*(1+H) for _ in range(1+H)]
    dp[H][H] = 0
    for s in range(2*H, 0, -1):
        for i1 in range(max(0, s-H), 1+min(s, H)):
            i2 = s - i1
            c = dp[i1][i2] + cost[i1][i2]
            if i1:
                dp[i1-1][i2] = min(dp[i1-1][i2], c)
            if i2:
                dp[i1][i2-1] = min(dp[i1][i2-1], c)
    return dp[0][0]

H, W = map(int, readline().split())

G = [list(map(lambda x:ord(x)-97, readline().strip())) for _ in range(H)]
G = list(map(list, zip(*G)))        
ans = 0
for i in range(W-1):
    ans += calc(G[i], G[i+1])
print(ans)

Measured memory_bytes: 113244
#include <stdio.h>
     
    int main(void)
    	{
    		int P,Q,R,a,b,c;
    		
    		scanf("%d %d %d", &P, &Q, &R);
    		a = P + R;
    		b = P + Q;
    		c = Q + R;
    		if (b <= a) 
    		{
    			if (b <= c) {
    				printf("%d", b);
    			}
    			else
    			{
    				printf("%d", c);
    			}
    		}
    		else 
    		{
    			if (a <= c) {
    				printf("%d", a);
    			}
    			else {
    				printf("%d", c);
    			}
    		}
    		return 0;
    	}

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

const int N = 4010;

std::vector <int> vec;

int a, b, n;
int ans[N];
char s[N];

int main(){
	scanf("%d%d", &a, &b);
	n = a + b;
	int need = b + 1;
	if (a <= b){
		return printf("Impossible\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		if (!vec.size()){
			vec.push_back(i);
			if ((int) vec.size() >= need){
				break;
			}
			continue;
		}
		printf("? %d %d\n", i, vec.back());
		fflush(stdout);
		scanf("%s", s);
		if (s[0] == 'Y'){
			vec.push_back(i);
			if ((int) vec.size() >= need){
				break;
			}
		}
		else{
			-- need;
			vec.pop_back();
		}
	}
	int honest = vec.front();
	for (int i = 0; i < n; ++ i){
		printf("? %d %d\n", honest, i);
		fflush(stdout);
		scanf("%s", s);
		ans[i] = s[0] == 'Y';
	}
	printf("! ");
	for (int i = 0; i < n; ++ i){
		printf("%d", ans[i]);
	}
	return printf("\n"), 0;
}

Measured memory_bytes: 848
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto k = readln.chomp.to!int;

  auto x = [
       [0, 1],
    [0, 1, 2],
    [1, 2, 3],
    [2, 3, 4],
    [3, 4, 5],
    [4, 5, 6],
    [5, 6, 7],
    [6, 7, 8],
    [7, 8, 9],
    [8, 9]
  ];
  int cnt;
  int a;

  auto num = new int[](10);
  void calc(int i) {
    if (i == a) {
      cnt++;
      if (cnt == k) {
        writefln("%(%s%|%)", num[0..a]);
      }
    } else {
      foreach (c; x[num[i-1]]) {
        num[i] = c;
        calc(i+1);
        if (cnt == k) {
          break;
        }
      }
    }
  }

  a:while (true) {
    a++;
    foreach (i; 1..10) {
      num[0] = i;
      calc(1);
      if (cnt == k) {
        break a;
      }
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  scanf("%d",&i);
  
  if(i%10 == 2 || i%10 == 4 || i%10 == 5 || i%10 == 7 || i%10 == 9){
    printf("hon");
  }
  else if (i%10 == 0 || i%10 == 1 || i%10 == 6 || i%10 ==8 ){
   	printf("pon"); 
  }
  else if (i%10 == 3){
    printf("bon");
  }
  
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<bool>first(n+1,false),last(n+1,false);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		if(a==1)first.at(b)=true;
		if(a==n)last.at(a)=true;
		else if(b==n)last.at(a)=true;
	}
	int i=1;
	while(i<=n&&(!first.at(i)||!last.at(i)))++i;
	cout<<(i<=n?"POSSIBLE"s:"IMPOSSIBLE"s)<<"\n"s;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
    if c != 1 && d != 1 {
        if a != b {
            if c != d {
                cResult := calcCount(a, b, c)
                dResult := calcCount(a, b, d)
                var cdResult int
                cdResult = calcCount(a, b, lcm(c, d))
                res := cResult + dResult - cdResult
                fmt.Println(b - a + 1 - res)
            } else {
                fmt.Println(b - a + 1 - calcCount(a, b, c))
            }
        } else {
            if a%c == 0 {
                fmt.Println(0)
            } else if a%d == 0 {
                fmt.Println(0)
            } else {
                fmt.Println(1)
            }
        }
    } else {
        fmt.Println(0)  
    }

}

func calcCount(head int, tail int, num int) int {
	headMod := head % num
	if headMod != 0 {
		headMod = num - headMod
	}
	tailMod := tail % num
	store := tail - head + 1 - tailMod - headMod
	if store <= 0 {
		store = 0
	}
    if num > tail{
        return 0
    } else {
	res := store/num + 1
        return res
    }
}

func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a int, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }
    int ans = 0;
    
    rep(si, h) rep(sj, w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, -1));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j]>=0) return;
            dist[i][j] = x;
            q.emplace(i, j);
        };
        update(si, sj, 0);
        //cout << "aaa" << endl;
        while(!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(dir, 4) {
                int nx = i + dx[dir];
                int ny = j + dy[dir];
                if (nx<0 || nx>=h || ny<0 || ny>=w) continue;
                if (s[nx][ny]=='#') continue;
                update(nx, ny, dist[i][j]+1);
            }
        }
        
        rep(i, h) rep(j, w) {
            if (dist[i][j]>ans) ans = dist[i][j];
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static final long INF = Long.MAX_VALUE >> 2;
    public static long[] dp = new long[110000]; //制約に応じてテーブル規模を調節する
    public static long[] steps = new long[110000];//制約に応じてテーブル規模を調節する
    public static int K = 0;
    public static void main(String[] args) throws Exception {
    for(int i=0;i<110000;++i)dp[i] = INF;
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       K = sc.nextInt();
       for(int i=0;i<N;i++){
           steps[i] = sc.nextLong();
       }
       long result = rec(N-1);
       System.out.println(result);
    }
       //最初に考えたやり方
    //   for(int i=0;i<N;i++){
    //       if(i == 0){
    //           dp[i] = 0;
    //       }else if(i == 1){
    //           dp[i] = height(steps[0],steps[1]);
    //       }else{
    //           if(K == 1){
    //               dp[i] = dp[i - 1] + height(steps[i],steps[i-1]);
    //           }else{
    //             for(int j=1;j<=i && j<=K;j++){
    //             dp[i] = chmin(dp[i] ,dp[i-j] + height(steps[i],steps[i-j]));
    //             }
    //           }
    //       }
    //   }
    
     //こっちの方が記述しやすい(貰うDP)
    //  for(int i=0;i<N;i++){
    //      if(i == 0){
    //          dp[i] = 0;
    //      }else{
    //         for(int j=1;j<=i && j<=K;j++){
    //             dp[i] = chmin(dp[i],(dp[i-j] + height(steps[i],steps[i-j])));
    //         }
    //      }
    //  }
    
    //別解1(配るDP)
    // dp[0] = 0;
    // for(int i=0;i<N;i++){
    //         for(int j=1;j<=K;j++){
    //             dp[i + j] = chmin(dp[i+j],dp[i] + height(steps[i] , steps[i + j]));
    //         }
    // }
    //   System.out.println(dp[N - 1]);
    // }
    
    //別解2(メモ化再帰)
    public static long rec(int i){
        if(dp[i] < INF)return dp[i]; //メモがあればそれを返す  
        if(i == 0)return 0; //
        long res = INF;
        for(int j=1;j<=i && j<=K;j++){
            res = chmin(res,rec(i-j) + height(steps[i],steps[i-j]));
        }
        dp[i] = res;
        return res;
    }
    
    public static long height(long h1,long h2){
        return Math.abs(h1 - h2);
    }
    
    public static long chmin(long a , long b){
        return Math.min(a,b);
    }
}


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

int main() {
    long long h, w;
    long long ans = 0;
    cin >> h >> w;
    ans += ((h - (h%2)) * (w - (w%2)))/2;
    if (h==1 || w==1) {
        cout << 1 << endl;
        return 0;
    }
    if (h%2 == 1) {
        ans += w/2;
    }
    if (w%2 == 1) {
        ans += h/2;
    }
    if (h%2 == 1 && w%2 == 1) {
        ans++;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
//白日依山尽
#define usn using namespace std 
#define it int main()
//黄河入海流
#define ci(i,n) cin>>i>>n
#define co(ans) cout<<ans<<endl
#define st string
//欲穷千里目
usn;
it
{st i,n;
 ci(i,n);
 if(i=="H")
{co(n);
}
 else
{if(n=="H")
 co("D");
 else
 co("H");
}
//更上一层楼
return 0;
}


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


#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const int inf = 2e18+5;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin>>n;
  int h[n+1];
  ll dp[n+1];
  loop(i,1,n+1){
    cin>>h[i];
    dp[i]=inf;
  }
  dp[1]=0;
  loop(i,1,n-1){
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  dp[n]=min(dp[n],dp[n-1]+abs(h[n]-h[n-1]));
  cout<<dp[n];
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
	// 入力
	long L, R;
	cin >> L >> R;
	
	// 2019の余りの最大の値
	long answer = 2018;
	if (R - L >= 2019)
	{
		// 2019の倍数があるため、最小値の余り0が確定する
		answer = 0;
	}
	else {
		for (long i = L; i <= R; i++)
		{
			for (long j = i + 1; j <= R; j++)
			{
				// 最小値の更新
				answer = min((i * j) % 2019, answer);
				if (answer == 0)
				{
					// 余りが0になった時点で最小値
					break;
				}
			}
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

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

using pii = std::pair<int, int>;
using std::priority_queue;

using std::vector;
char str[2][2020];
pii move[2020];
int len;
bool check[2020];

int main(void) {
	scanf("%s %s", str[0], str[1]);
	len = strlen(str[0]);
	for (int i = 0; i < len; i++) {
		str[0][i] -= '0';
		str[1][i] -= '0';
	}
	for (int i = 0; i < len; i++) {
		if (str[1][i] == 1) {
			break;
		}
		if (i == len - 1) {
			for (int j = 0; j < len; j++) {
				if (str[0][j] == 1) {
					break;
				}
				if (j == len - 1) {
					printf("0");
					return 0;
				}
			}
			printf("-1");
			return 0;
		}
	}
	for (int i = 0; i < len; i++) {
		for (int j = 0; j < len; j++) {
			if (str[1][(i + j) % len] == 1) {
				move[i].second = j;
				break;
			}
		}
		for (int j = 0; j < len; j++) {
			if (str[1][(i - j + len) % len] == 1) {
				move[i].first = j;
				break;
			}
		}
	}
	int ans = 2000000000;
	for (int i = 0; i < len; i++) {
		int temp_ans = 0;
		vector<pii> t_v;
		priority_queue<pii> pq;
		for (int j = 0; j < len; j++) {
			check[(i + j) % len] = false;
			if (str[0][(i + j) % len] != str[1][j]) {
				temp_ans++;
				if (str[0][(i + j) % len] == 1) {
					t_v.push_back(pii(move[(i + j) % len].first, (i + j) % len));
					pq.push(pii(move[(i + j) % len].second, (i + j) % len));
					check[(i + j) % len] = true;
				}
			}
		}
		sort(t_v.begin(), t_v.end());
		int temp_val = 2000000000;
		if (t_v.size() == 0) {
			temp_val = std::min(i, len - i);
		}
		else {
			for (int j = -1; j < (int)(t_v.size()); j++) {
				int left;
				if (j != -1) {
					check[t_v[j].second] = false;
					left = t_v[j].first;
				}
				else {
					left = 0;
				}
				while (!pq.empty() && !check[pq.top().second]) {
					pq.pop();
				}
				int right;
				if (pq.empty()) {
					right = 0;
				}
				else {
					right = pq.top().first;
				}
				temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
			}
		}
		temp_ans += temp_val;
		ans = std::min(temp_ans, ans);
	}

	printf("%d", ans);

	return 0;
}

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 3000 + 10;
int T;

double dp[N][N];
int n;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

    while (cin >> n)
    {
        clr(dp, 0);
        dp[0][0] = 1;
        double p;

        for (int i = 0; i < n; i++)
        {
            cin >> p;
            for (int j = 0; j <= i; j++)
            {
                dp[i + 1][j] += dp[i][j] * (1 - p);
                dp[i + 1][j + 1] += dp[i][j] * (p);
            }
        }
        double ans = 0;
        for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i];
        printf("%.9lf\n", ans);
    }

    return 0;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	string s;
	cin >> s;
	if(s.back() == 's'){
		cout << s << "es" << nl;
	}   
	else {
		cout << s << 's' << nl;
	}
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,k;cin>>n>>k;
  vector<int> A(n+1);
  for(int i=1;i<=n;++i)cin>>A[i];
  for(int i=k+1;i<=n;++i){
    if(A[i]>A[i-k])cout<<"Yes\n";
    else cout<<"No\n";
  }
  
  return 0;
}
//2020.07.25 20:09:20


Measured memory_bytes: 3984
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
b = list(li())

cnt = 0

for i in range(n+1):
    for j in range(i-1, i+1):
        if j < 0 or j >= n:
            continue

        if b[j] == 0:
            continue

        elif a[i] <= b[j]:
            cnt += a[i]
            b[j] -= a[i]
            a[i] = 0
            break

        else:
            cnt += b[j]
            a[i] -= b[j]
            b[j] = 0


print(cnt)


Measured memory_bytes: 19376
#include <stdio.h>

int main() {
    int i,j;
    int minj;
    int N;
    int count=0;
    int temp;
    int data[110];
    int flag = 0;

    scanf("%d",&N);

    for(i = 0; i < N; ++i){
        scanf("%d", &data[i]);
    }

    for(i = 0; i < N ; ++i){
        minj = i;
        flag = 0;
        for(j = i ; j < N ; ++j) {
            if (data[minj] > data[j]) {
                minj = j;
                flag = 1;
            }
        }
        if(flag == 1) {
            temp = data[i];
            data[i] = data[minj];
            data[minj] = temp;
            count++;
        }
    }
    for(i = 0; i < N-1; ++i){
        printf("%d ",data[i]);
    }
    printf("%d",data[N-1]);
    putchar('\n');
    printf("%d\n",count);
    return 0;
}


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

using namespace std;


// //This refers to a priority queue that takes out the largest integer/variable.
// priority_queue<int> cueMax;

// //This refers to a priority queue that takes out the smallest number/variable.
// priority_queue<int, vector<int>, greater<int>> cuMin;

int N, M;
priority_queue<int> cueMax;

int main() {

    cin >> N >> M;
    for (int i=0; i<N; i++){
        int A;
        cin >> A;
        cueMax.push(A);
    }

    for (int i=0;i<M; i++){
        int largest = cueMax.top();
        cueMax.pop();
        int product = largest/2;
        cueMax.push(product);
    }

    long long result = 0;

    while (!cueMax.empty()){
        result += cueMax.top();
        cueMax.pop();
    }

    cout << result;

    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e5+9;
int main()
{
    FASTINOUT;
    ll x,a,b,c;
    cin>>x>>a>>b>>c;
    vector<char>ans;
    bool bb=1;
    string s[x];
    for (int i=0; i<x; i++)
        cin>>s[i];
    for (int i=0; i<x; i++)
    {
        if (s[i]=="AB")
        {
            if (a==1&&b==1&&c==0&&i+1<x&&s[i+1]=="AC")
            {
                a++;
                b--;
                ans.push_back('A');
            }
            else if (a==1&&b==1&&c==0&&i+1<x&&s[i+1]=="BC")
            {
                b++;
                a--;
                ans.push_back('B');
            }
            else if (a>b)
            {
                b++;
                a--;
                ans.push_back('B');
                if (a<0)
                    bb=false;
            }
            else
            {
                a++;
                b--;
                ans.push_back('A');
                if (b<0)
                    bb=false;
            }
        }
        else if (s[i]=="AC")
        {
            if (a==1&&c==1&&b==0&&i+1<x&&s[i+1]=="AB")
            {
                a++;
                c--;
                ans.push_back('A');
            }
            else if (a==1&&c==1&&b==0&&i+1<x&&s[i+1]=="BC")
            {
                c++;
                a--;
                ans.push_back('C');
            }
            else if (a>c)
            {
                c++;
                a--;
                ans.push_back('C');
                if (a<0)
                    bb=false;
            }
            else
            {
                a++;
                c--;
                ans.push_back('A');
                if (c<0)
                    bb=false;
            }
        }
        else
        {
            if (a==0&&b==1&&c==1&&i+1<x&&s[i+1]=="AC")
            {
                c++;
                b--;
                ans.push_back('C');
            }
            else if (a==0&&b==1&&c==1&&i+1<x&&s[i+1]=="AB")
            {
                b++;
                c--;
                ans.push_back('B');
            }
            else if (c>b)
            {
                b++;
                c--;
                ans.push_back('B');
                if (c<0)
                    bb=false;
            }
            else
            {
                c++;
                b--;
                ans.push_back('C');
                if (b<0)
                    bb=false;
            }
        }
    }
    if (bb)
    {
        cout<<"Yes\n";
        for (int i=0; i<x; i++)
            cout<<ans[i]<<endl;
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 6920
import Control.Applicative
import Control.Monad

main = do
    n:x:_ <- map read .words <$> getLine ::IO[Int]
    if (n > 0 || x > 0) 
      then do 
        putStrLn $ show (length [(a,b,c)| c <- [3..n], b <- [2..c-1], a <- [1..b-1], a+b+c == x ])
        main
      else return()

Measured memory_bytes: 4948
#include<iostream>
#include<stack>
#include<cstdlib>

using namespace std;
int main(){
  char x[100];
  int i=0,a,b,temp=0;
  stack<int>sta;

  while(cin >> x){
    if(sta.size() >= 2){
      temp=1;
      a = sta.top();
      sta.pop();
      b = sta.top();
      sta.pop();
      //cout << b << " " << a << endl;
    }
    
    if(x[0] == '+'){
      sta.push(a+b);
      temp=0;
    } else if(x[0] == '-'){
      sta.push(b-a);
      temp=0;
    } else if(x[0] == '*'){
	sta.push(a*b);
	temp=0;
    } else if(x[0] == '/'){
      sta.push(b/a);
      temp=0;
    }else {
      if(temp == 1){
	sta.push(b);
	sta.push(a);
	temp=0;
      }

      sta.push(atoi(x));

    }
    //cout << "! " << sta.size() << endl;
    // cout << sta.size() << endl;
  }

  cout << sta.top() << endl;
  return(0);
}

Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

P equation(const string &str, int pos=0);
P factor(const string &str, int pos = 0);
P term(const string &str, int pos = 0);

P equation(const string &str, int pos){
	P res = factor(str,pos);
	while(str[res.second] == '+' || str[res.second] == '-'){
		P res_ = factor(str,res.second+1);
		if(str[res.second] == '+') res.first += res_.first;
		else res.first -= res_.first;
		res.second = res_.second;
	}
	return res;
}

P factor(const string &str, int pos) {
	P res = term(str, pos);
	while (str[res.second] == '*' || str[res.second] == '/') {
		P res_ = term(str, res.second+1);
		if(str[res.second] == '*') res.first *= res_.first;
		else res.first /= res_.first;
		res.second = res_.second;
	}
	return res;
}

P term(const string &str, int pos) {
	if(str[pos] == '('){
		P res = equation(str,pos+1);
		res.second += 1;
		return res;
	} else {
		int val = 0;
		while(isdigit(str[pos])){
			val = val * 10 + (str[pos++]-'0');
		}
		return P(val,pos);
	}
}


int main(){
	string str;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>str;
		P res = equation(str);
		cout << res.first << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  long long x,y;
  cin>>x>>y;
  if(abs(y-x)>=2) cout<<"Alice"<<endl;
  else cout<<"Brown"<<endl;
  return 0;
}


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

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int c = n * m - 2 * k;
  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <= m; y++) {
      if ((2 * x - n) * (2 * y - m) == c) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#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 ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;

	vector<int> deg(n);
	for(int i = 1; i < n; ++i){
		int x;
		cin >> x;
		--x;
		deg[x]++;
	}

	for(auto &x : deg) cout << x << "\n";

	return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
  	int n = s.size();
    for(int i = 0; i < 15 - n; i++) s += 'o';
    
    int cnt = 0;
    for(int i = 0; i < 15; i++) {
        if(s.at(i)=='o') cnt++;
    }
    if(cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if (x==y) {
			System.out.println(0);
			return ;
		}
		if (x==-y) {
			System.out.println(1);
			return ;
		}
		long count =0;
		if (x<0&&y<0) {
			if (x>y) {
				count =Math.abs(x-y)+2;
			} else {
				count =Math.abs(x-y);
			}
		} else if ((x>0&&y<0)||(x<0&&y>0)) {
			count = Math.abs(Math.abs(x)-Math.abs(y))+1;
		} else if (x>0&&y>0) {
			count =Math.abs(x-y);
			if (x>y) {
				count +=2;
			}
		}else if (x==0) {
			count +=Math.abs(y);
			if (y<0) {
				count ++;
			}
		} else {
			count +=Math.abs(x);
			if (x>0) {
				count ++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 35652
import copy

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)

n ,m = ips()
a = iprow()
s = 0
for i in range(n-1):
    if a[i+1]-a[i]>=m:
        s+=m
    else:
        s+=a[i+1]-a[i]

print(s+m)

Measured memory_bytes: 25664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll l=x/d;
	if(l>=k){
		cout <<x-d*k;
		return 0;
	}
	k-=l;
	if(k%2==0){
		cout << x%d;
	}
	else{
		cout << d-x%d;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int A,B,K;
    cin >> A >> B >> K;
    for(int i = 0; i < K; i++) {
        if(i%2 == 0) {
            A/=2;
            B+=A;
        }
        else {
            if(B%2 == 1) {
                B--;
            }
            B-=B/2;
            A+=B;
        }
    }
    cout << A << " " << B << endl;
}



Measured memory_bytes: 256
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

key = []

n.times do |i|

  row = [a[i], i]

  key << row

end


key =  key.sort



tmp = []

n.times do |i|
  tmp << key[i][1] + 1
end

puts tmp.join(' ')



Measured memory_bytes: 20592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

size_t f(size_t x) {
    size_t a = 100;
    size_t c = 0;
    while (a < x) {
        a = static_cast<size_t>(a * 1.01);
        ++c;
    }
    return c;
}

int main() {
    size_t x = input();
    cout << f(x) << endl;
    return 0;
}


Measured memory_bytes: 3640
/*AOJproblem #2006*/

#include<stdio.h>
#define NUM 2014 //入力文字数のmax

void print_message(const char* input)
{
    static const char button1[] = {'.', ',', '!', '?', ' '};
    static const char button2[] = {'a', 'b', 'c'};
    static const char button3[] = {'d', 'e', 'f'};
    static const char button4[] = {'g', 'h', 'i'};
    static const char button5[] = {'j', 'k', 'l'};
    static const char button6[] = {'m', 'n', 'o'};
    static const char button7[] = {'p', 'q', 'r', 's'};
    static const char button8[] = {'t', 'u', 'v'};
    static const char button9[] = {'w', 'x', 'y', 'z'};
    static const char* buttons[] = {button1, button2, button3, button4, button5, button6, button7, button8, button9};//各ボタンの先頭のポインタの配列
    static const int syuuki[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};//それぞれのボタンを何回押すと一周するか


    int i = 0;
    while (1) {
        while (input[i] == '0') {
            ++i;
        }
        //i++;
        if (input[i] == '\0') break;
        
        char c = input[i];
        int count = 0;//何回連続して同じ文字を入力するか

        while (input[i + ++count] != '0'){//'0'が入力されるまでカウント
            //count++;
        }
        i += count;
        printf("%c", buttons[c - '1'][(count - 1) % (syuuki[c - '1'])]);
    }

    printf("\n");
}

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

    while (n--) {
        char input_str[NUM + 1] = {0};
        scanf("%s", input_str);
        print_message(input_str);
    }

	return 0;
}

Measured memory_bytes: 1000
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
using namespace std;
int s[1000],b[1000];
int main(){
	int n,ans=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> s[i];
		b[s[i]]=1;
	}
	for(int i=1;i<=100;i++){
		ans+=b[i];
	}
	cout << ans;
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;

struct dsu0 {
    vector<int> par, siz;
    int n;
    int cc;
    int largest;
    void init(int n) {
	assert(n>0);
	this->n=n;
	cc=n;
	par.resize(n+10);siz.resize(n+10);
	for (int i=0; i<n; i++) par[i]=i,siz[i]=1;
	largest=1;
    }
    int parent(int x) {
	assert(x>=0 && x<n);
	return par[x]==x?x:par[x]=parent(par[x]);
    }
    bool join(int x, int y) {
	x=parent(x);y=parent(y);
	if (x==y) return false;
	cc--;
	if (siz[x]<siz[y]) swap(x,y);
	siz[x]+=siz[y];par[y]=x;
	largest=max(largest,siz[x]);
	return true;
    }
};

int n;
const int N = 1e5;

dsu0 dsu;

int row[maxn], col[maxn];


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

    cin>>n;
    dsu.init(N+N);
    
    for (int i=0; i<n; i++) {
	int x, y;
	cin>>x>>y;
	--x;
	--y;
	dsu.join(x,y+N);
    }

    for (int i=0; i<N; i++) {
	row[dsu.parent(i)]++;
    }
    for (int i=N; i<N+N; i++) {
	col[dsu.parent(i)]++;
    }

    ll res = 0;
    for (int i=0; i<N+N; i++) {
	res += 1ll*row[i]*col[i];
    }

    res -= n;
    cout<<res<<endl;
    return 0;
}


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

#define DEBUG if(0)
#define lli long long int
const int maxN = 1e4 + 1, mod = 100000007;

int main()
{
  lli a, b, c, k, ans = 0;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
  if (a > k)
  {
    printf("%lld\n", k);
    return 0;
  }
  else ans += a, k -= a;
  if (b > k) 
  {
    printf("%lld\n", ans);
    return 0;
  }  
  else k -= b;
  if (c > k) 
  {
    printf("%lld\n", ans - k);
    return 0;
  }
  else printf("%lld\n", ans - c);
  return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    string w;
    cin >> w;
    transform(w.begin(), w.end(), w.begin(), ::tolower);
    int cnt = 0;
    for (string t; cin >> t && t != "END_OF_TEXT";) {
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        if (t == w) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}



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

int main() {
    long long N,Q;
    cin >> N;
    vector <long long> A(N);
    vector <long long> num(100000+1, 0);
    for (long long i=0; i<N; i++) {
        cin >> A.at(i);
        num.at(A.at(i))++;
    }
    cin >> Q;
    vector <long long> ans(Q+1,0);
    for (long long i=0; i<N; i++) ans.at(0)+=A.at(i);
//    ans.at(0) = accumulate(A.begin(), A.end(), 0);
    for (long long i=1; i<=Q; i++) {
        ans.at(i) = ans.at(i-1);
        long long B,C;
        cin >> B >> C;
        ans.at(i) += (num.at(B)*(C-B));
        num.at(C) += num.at(B);
        num.at(B) = 0;
    }
    for (long long i=1; i<=Q; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 5620
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

import sys
input = sys.stdin.buffer.readline

n, q = map(int, input().split())
clst = list(map(int, input().split()))
lr = []
for i in range(q):
    l, r = map(int, input().split())
    lr.append([l, r, i])
lr.sort(key=lambda x:x[1])
bit = Bit(n)
pos = 0
last = [-1 for _ in range(n)]
ans = [-1 for _ in range(q)]
for i, c in enumerate(clst):
    bit.add(i + 1, 1)
    if last[c - 1] != -1:
        bit.add(last[c - 1] + 1, -1)
    last[c - 1] = i
    while lr[pos][1] == i + 1:
        l = lr[pos][0]
        r = lr[pos][1]
        ans[lr[pos][2]] = bit.sum(r) - bit.sum(l - 1)
        pos += 1
        if pos == q:
            break
    if pos == q:
        break
    
print(*ans, sep="\n")


Measured memory_bytes: 243884
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local S, W = read.nn()
if W >= S then
    print("unsafe")
else
    print("safe")
end

Measured memory_bytes: 2632
class Dice
 
  def initialize( given_ary )
    @ary = given_ary
  end
 
  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end
 
  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end
 
  def checkall( givendice )
    4.times do
      self.roll( "E" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    3.times do
      self.roll( "N" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    return false
  end
 
  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end
 
  def top
    @ary[ 0 ]
  end
 
  def front
    @ary[ 5 ]
  end
 
  def right
    @ary[ 2 ]
  end
 
  def vals
    @ary
  end
 
  def compare( givendice )
    4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
    3.times do
      self.roll( "N" )
      if identical( givendice )
        return true
      end
      4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
 
    end
    false
 
  end
 
  def identical( givendice )
    @ary.zip( givendice.vals ).map{ | x, y | ( x - y ).abs }.inject(:+) == 0
  end
 
end
 
dices = Array.new()
gets.to_i.times do
  dices << Dice.new( gets.split.map(&:to_i) )
end
result = ""
dices.each do | outer |
  dices.each do | inner |
    if outer === inner
      next
    end
    if outer.checkall( inner )
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 8900
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
char c[200005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	V<int> v;
	int n,cnt=0;
	cin>>n;
	FOR(i,1,n)cin>>c[i];
	FOR(i,1,n){
		if(c[i]=='R')v.PB(i),cnt++;
	}
	if(cnt==n){
		cout<<0;RE 0;
	}
	int ans=cnt,p=0;
	FOR(i,1,n){
		if(c[i]=='W'){
			gmin(ans,p+cnt);
			if(v.empty()||v.back()<i){
				break;
			}else{
				cnt--;p++;
				swap(c[i],c[v.back()]);
				v.pop_back();
			}
		}else{
			cnt--;
		}
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 4472
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val s=(1..n).map{ readLine()!! }
	
	if(s.map{ it.last() }.dropLast(1)==s.map{ it.first() }.drop(1)
		&& s.distinct().size == n ){
		println("Yes")
	}else{
		println("No")
	}
}

Measured memory_bytes: 33760
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
vector<int> adj[100005];
int indeg[100005];
int par[100005];
int main(){
     int a,b;
     cin>>a>>b;
     int k=50;
     int p=a-1;
     cout<<100<<" "<<100<<"\n";
     for(int i=1;i<=k;i++){
          for(int j=1;j<=2*k;j++){
               if(i%2==1&&j%2==0&&p>0)cout<<".",p--;
               else cout<<"#";
          }
          cout<<endl;
     }
     p=b-1;
     for(int i=k+1;i<=2*k;i++){
          for(int j=1;j<=2*k;j++){
               if(i%2==0&&j%2==0&&p>0)cout<<"#",p--;
               else cout<<".";
          }
          cout<<"\n";
     }



}
 
 
 
 

























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

bool isSingleChar(string s) {
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != s[0]) {
			return false;
		}
	}
	return true;
}

int main() {
	string S;
	cin >> S;
	int ans = INT_MAX;
	for (int i = 0; i < S.size(); i++) {  // S[i]に合わせに行く
		string s = S;
		int cnt = 0;
		while (!isSingleChar(s)) {
			for (int j = 0; j < s.size() - 1; j++) {
				s[j] = (s[j] == S[i] ? s[j] : s[j + 1]);
			}
			s.pop_back();
			cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256