akhauriyash/Code-Regression huggingface dataset:
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 206;

int n, m, K, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, a[N * N], col[N][N];
bool u[N][N];

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

	cin >> n >> m;
	cin >> K;
	forn(i, 1, K) {
        cin >> a[i];
	}
	forn(i, 0, n + 1) u[i][0] = u[i][m + 1] = 1;
	forn(i, 0, m + 1) u[0][i] = u[n + 1][i] = 1;

    int cur = 1, x = 1, y = 1, dir = 0;
    while (true) {
        a[cur]--;
        u[x][y] = 1;
        col[x][y] = cur;
        if (u[x + dx[dir]][y + dy[dir]]) dir = (dir + 1) % 4;
        if (u[x + dx[dir]][y + dy[dir]]) break;
        x += dx[dir];
        y += dy[dir];
        if (!a[cur]) ++cur;
    }
    forn(i, 1, n) {
        forn(j, 1, m) {
            cout << col[i][j] << " ";
        }
        cout << "\n";
    }

	return 0;
}


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

int main(){
    int N,sum = 0,max = 0;
    cin >> N;
    int a[3][N+1];
    for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= N; j++){
            cin >> a[i][j];
        }
    }
    int k = 1;//曲がるときのx座標
    while(k <= N){
        sum = 0;
        for(int j = 1; j <= N; j++){
            if(k > j) sum += a[1][j];
            else if(k == j) sum += a[1][j] + a[2][j];
            else  sum += a[2][j];
            if(sum > max) max = sum;
        }
        k++;
    }
    cout << max << endl;
    return 0;
}

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

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

L = sorted(L, key=lambda x: x[1])
#print(L)

calc = 0

ans = "Yes"

for i in range(len(L)) :
    a,b = L[i]
    calc += a
    if calc > b :
        ans = "No"
        break
print(ans)

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

#define ll long long
#define eb emplace_back
#define nl '\n'
#define deb(x) cerr << #x" = " << x << nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

bool pal(string s)
{
    string p = s;
    reverse(s.begin(), s.end());
    return p == s;
}
int32_t main()
{
    string s; cin >> s;
    int n = s.size();
    if(pal(s) && pal(s.substr(0, n / 2)) && pal(s.substr(n / 2 + 1))) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF 100006
#define MOD 1000000007

int n;
int mem[INF];

int rec(int sum)
{
	if(sum>n)
	{
		return 0;
	}
	if(sum==n)
	{
		return 1;
	}
	if(mem[sum]!=-1) return mem[sum]%MOD;
	int tot=0;
	for(int i=3;i<=n;i++)
	{
		int next=sum+i;
		if(next>n)
		{
			break;
		}
		tot=((tot%MOD)+(rec(next)%MOD))%MOD;
	}
	return mem[sum]=tot%MOD;
}

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    memset(mem,-1,sizeof(mem));
    cin >> n;
    int ans=rec(0);
    cout << ans%MOD << "\n";
}


Measured memory_bytes: 4000
#include <stdio.h>

int main(){
    double r;
    double s,l;
    double p = 3.141592653589;
    scanf("%lf", &r);
    
    s = r*r*p;
    l = 2*p*r;
    
    printf("%f %f\n",s,l);
    
    return 0;
}
    

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 154-d
int main() {
    int n, k;
    cin >> n >> k;

    int p;
    vector<double> v;
    double s, d, val;
    double sum = 0;
    rep(i, 0, n) {
        cin >> p;
        s   = p * (p + 1);
        d   = 2 * p;
        val = s / d;
        sum += val;

        v.push_back(sum);
    }

    double mx = v[k - 1];
    for (int i = 0; i + k < n; i++) {
        mx = max(mx, v[i + k] - v[i]);
    }

    printf("%lf\n", mx);
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    vector<string> res;
    map<string, int> mp;

    rep(i, N) {
        mp[S[i]]++;
    }

    int ma = -1;

    for (auto&& p : mp) {
        ma = max(ma, p.second);
    }

    for (auto&& p : mp) {
        if (p.second == ma) res.push_back(p.first);
    }

    sort(all(res));

    rep(i, res.size()) cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 30452
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]


# 穴あけ
for i in range(3):
    for j in range(3):
        if (A[i][j] in B):
            A[i][j] = True
        else:
            A[i][j] = False


for i in range(3):
    if A[i][0] and A[i][1] and A[i][2]:
        print("Yes")
        exit()

    if A[0][i] and A[1][i] and A[2][i]:
        print("Yes")
        exit()

if A[0][0] and A[1][1]and A[2][2]:
    print("Yes")
    exit()

if A[2][0] and A[1][1] and A[0][2]:
    print("Yes")
    exit()

print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0)
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
 } 

Measured memory_bytes: 256
n = int(input())
h = [0] + list(map(int, input().split())) + [0] * 10

INF = 1 << 60
dp = [INF] * (n + 10)

dp[1] = 0

for i in range(1, n):
    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]))

print(dp[n])

Measured memory_bytes: 13980
#include <map>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[200009];
int main() {
	scanf("%d", &n);
	map<long long, int> d;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		d[sum] = i + 1;
	}
	int ret = 0; long long sum2 = 0;
	for (int i = 0; i < n; i++) {
		if (d[sum2] > i) ret = max(ret, d[sum2] - i);
		sum2 += a[i];
	}
	printf("%d\n", ret);
	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n) cin >> c[i];
  sort(ALL(a));
  sort(ALL(c));
  ll ans = 0;
  REP(i, n) {
    ll k = b[i];
    ll l = lower_bound(ALL(a), k) - a.begin();
    ll r = c.end() - upper_bound(ALL(c), k);
    ans += l * r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, A, B;

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

  if((B - A) % 2 == 1) cout << "Borys" << endl;
  else cout << "Alice" << endl;

  return 0;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    print(
        sum(
            [
                sum([b[i] * j for i, j in enumerate(map(int, input().split()))]) + c > 0
                for _ in range(n)
            ]
        )
    )


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
using System;
using System.Linq;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	int L = s.Length;
	
    	// dp[桁, 未満確定, leading 0, 7出現済, 5出現済, 3出現済, 7/5/3 以外含む]
	long[,,,,,,] dp = new long[10,2,2,2,2,2,2];
	dp[0,0,1,0,0,0,0] = 1;

	for (int i = 0; i < L; i++)
	{
	    int D = s[i] - '0';
	    for (int j = 0; j < 2; j++)
	    {
		for (int k = 0; k < 2; k ++)
		for (int f7 = 0; f7 < 2; f7++)
		{
		    for (int f5 = 0; f5 < 2; f5++)
		    {
			for (int f3 = 0; f3 < 2; f3++)
			{
			    for (int fv = 0; fv < 2; fv++) // violatio flag
			    {
				for (int d = 0; d <= ((j == 1) ? 9 : D); d++)
				{
				    int nj = (j == 1 || d < D) ? 1 : 0;
				    int nk = (k == 1 && d == 0) ? 1 : 0;
				    int nf7 = (f7 == 1 || d == 7) ? 1 : 0;
				    int nf5 = (f5 == 1 || d == 5) ? 1 : 0;
				    int nf3 = (f3 == 1 || d == 3) ? 1 : 0;
				    int nfv = (fv == 1 || (d != 7 && d != 5 && d != 3)) ? 1 : 0;
				    if (k == 1 && d == 0) nfv = 0;
				    dp[i+1,nj,nk,nf7,nf5,nf3,nfv] += dp[i,j,k,f7,f5,f3,fv];
				}
			    }
			}
		    }
		}
	    }
	}

	WriteLine(dp[L,0,0,1,1,1,0] + dp[L,1,0,1,1,1,0]);
    }
}



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

using namespace std;

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

int main(){
	string s,t;
	int a,b;
	string u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(s==u) a--;
	else b--;

	cout << a << " " << b << endl; 

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]

    for i in range(n):
        if i == 0:
            if a_list[i] % 2 == 0:
                tmp = 2
                continue
            else:
                tmp = 1
                continue
        if a_list[i] % 2 == 0:
            tmp *= 2

    print(3**n - tmp)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807/2;
const int MOD = 1000000007;
const int N_MAX = pow(10,5);

int main() {
  int N; cin >> N;
  int h[N]; rep(i, N) cin >> h[i];
  int dp[N_MAX] = {};
  for (int i=1; i<=N; i++) {
    if (i==1) dp[1] = abs(h[1]-h[0]);
    else dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;


long long gcd(long long a, long long b) {
	while (a%b != 0) {
		auto temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

int main() {
	long long A, B, C, D; cin >> A >> B >> C >> D;
	long long mul = C * D / gcd(max(C, D), min(C, D));
	if (A == 1) {
		cout << B - (B / C) - (B / D) + (B / mul) << endl;
	} else {
		auto a_minor = A - 1;
		auto sub = a_minor - (a_minor / C) - (a_minor / D) + (a_minor / mul);
		auto ans = B - (B / C) - (B / D) + (B / mul);
		cout << ans - sub << endl;
	}
}


Measured memory_bytes: 256
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())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)


def lcm(a,b):
    return (a // gcd(a,b)) * b


def func(n, c, d):
    cdlcm = lcm(c,d)
    return n//c + n//d - n//cdlcm

a,b,c,d = li()

print((b-a+1) - (func(b,c,d) - func(a-1,c,d)))

Measured memory_bytes: 3064
#include <stdio.h>
#define inf 10e8

int main(void) {
  int i, j, k, l, h, w, dx[4] = {0, -1, 1, 0}, dy[4] = {1, 0, 0, -1};
  scanf("%d%d", &h, &w);
  int a[h][w], dp[h][w][h * w + 1];
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) scanf("%d", &a[i][j]);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) for(k = 0; k <= h * w; ++k) dp[i][j][k] = inf;
  dp[0][0][0] = 0;
  for(i = 1; i <= h * w; ++i) {
    for(j = 0; j < h; ++j) for(k = 0; k < w; ++k) {
      for(l = 0; l < 4; ++l) if(j + dy[l] >= 0 && j + dy[l] < h && k + dx[l] >= 0 && k + dx[l] < w) if(dp[j][k][i] > dp[j + dy[l]][k + dx[l]][i - 1] + a[j][k] * (-1 + 2 * i)) dp[j][k][i] = dp[j + dy[l]][k + dx[l]][i - 1] + a[j][k] * (-1 + 2 * i);
    }
  }
  /*for(i = 0; i < h; ++i) {
   for(j = 0; j < w; ++j) printf("%d ", dp[i][j][3]);
   printf("\n");
  }*/
  int ans = inf;
  for(i = 0; i <= h * w; ++i) if(ans > dp[h - 1][w - 1][i]) ans = dp[h - 1][w - 1][i];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5884
use std::collections::HashMap;

macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let mut m = HashMap::new();
    for c in s.chars() {
        m.insert(c, true);
    }

    for c in "abcdefghijklmnopqrstuvwxyz".to_string().chars() {
        if !m.contains_key(&c) {
            println!("{}", c);
            return;
        }
    }
    println!("None")
}


Measured memory_bytes: 4352
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var sum = 0;
  for(var i = 0; i < N; i++){
    sum += list[i];
  }
  var mae = 0;
  var ato = 0;
  for(var i = 0; i < N; i++){
    mae += list[i];
    if(sum / 2 <= mae){
      break;
    }
  }
  for(var i = N - 1; i >= 0; i--){
    ato += list[i];
    if(sum / 2 <= ato){
      break;
    }
  }
  myout(Math.min(mae - (sum - mae),ato - (sum - ato)));
}

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


int main(){
    int a, b, c, d;
    cin >>a >> b >> c >>d;
    
    if(a+b > c+d) cout << "Left" << endl;
    else if (a+b < c+d) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    

    return 0;
}
    

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

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

int main(){
  ll N;
  cin >> N;
  vector<vector<ll>> dist(N, vector<ll>(N));
  ll sum = 0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      cin >> dist[i][j];
      sum += dist[i][j];
    }
  bool ans = true;
  set<P> iran;
  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++){
        if(i == j)
          continue;
        if(dist[i][j] > dist[i][k] + dist[k][j])
          ans = false;
        else if(dist[i][j] == dist[i][k] + dist[k][j] && k!=i && k!=j){
          iran.insert(P(i, j));
        }
      }
  if(ans){
    for(auto x : iran){
      ll f, t;
      tie(f, t) = x;
      sum -= dist[f][t];
    }
    cout << sum/2 << endl;
  }else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
                values[i] = i + 1;
            }
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",", 2);
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int tmp;
                tmp = values[a];
                values[a] = values[b];
                values[b] = tmp;
            }

            for (int i = 0; i < values.length; i++) {
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 25924
#include<iostream>
#include<string>
#include<sstream>
#include<stack>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main()
{
	string s;
	stringstream ss;
	stack<double> stack;
	double a, b;

	cout<<setprecision(6);
	cout<<setiosflags(ios::fixed);

	while (getline(cin, s)) {
		ss.str(s);
		while (ss>>s) {
			if ( atoi(s.c_str()) ){
				stack.push( atof(s.c_str()) );
			} else {
				b = stack.top();
				stack.pop();
				a = stack.top();
				stack.pop();
				if (s=="+") stack.push(a+b);
				else if (s=="-") stack.push(a-b);
				else if (s=="*") stack.push(a*b);
				else if (s=="/") stack.push(a/b);
			}
		}
		cout<<stack.top()<<endl;
		stack.pop();
		ss.clear();
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
char ans[maxn];
string str[maxn];
int n;
void dfs(int i,int a,int b,int c) 
{
    if(i>n) 
	{
       	cout << "Yes\n";
        for(int i=1;i<=n;i++) 
			cout << ans[i] << endl;
        exit(0);
    }
    if(str[i]=="AB") 
	{
        if(a) ans[i]='B',dfs(i+1,a-1,b+1,c);
        if(b) ans[i]='A',dfs(i+1,a+1,b-1,c);
    }
    else if(str[i]=="AC") 
	{
        if(a) ans[i]='C',dfs(i+1,a-1,b,c+1);
        if(c) ans[i]='A',dfs(i+1,a+1,b,c-1);
    }
    else 
	{
        if(b) ans[i]='C',dfs(i+1,a,b-1,c+1);
        if(c) ans[i]='B',dfs(i+1,a,b+1,c-1);
    }
}
signed main()
{
	ios::sync_with_stdio(0);
	int a,b,c;
	cin >> n>> a >> b >> c;
	for(int i=1;i<=n;i++)
		cin >> str[i];
	dfs(1,a,b,c);
	cout << "No";
	return 0;
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
#define MAXN 1000001 
ll spf[MAXN]; 
ll hash1[MAXN] = { 0 }; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i = 2; i < MAXN; i++) 
        spf[i] = i; 
    for (int i = 4; i < MAXN; i += 2) 
        spf[i] = 2; 
    for (int i = 3; i * i < MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j = i * i; j < MAXN; j += i) 
                if (spf[j] == j) 
                    spf[j] = i; 
        } 
    } 
} 
void getFactorization(ll x) 
{ 
    ll temp; 
    while (x != 1) { 
        temp = spf[x]; 
        if (x % temp == 0) { 
            hash1[spf[x]]++; 
            x = x / spf[x]; 
        } 
        while (x % temp == 0) 
            x = x / temp; 
    } 
} 
bool check(ll x) 
{ 
    ll temp; 
    while (x != 1) { 
        temp = spf[x]; 
        if (x % temp == 0 && hash1[temp] > 1) 
            return false; 
        while (x % temp == 0) 
            x = x / temp; 
    } 
    return true; 
} 
bool pairco(ll arr[], ll n) 
{ 
    sieve(); 
  
    for (int i = 0; i < n; i++) 
        getFactorization(arr[i]); 
    bool ans=true;
    for (int i = 0; i < n; i++) 
        if (!check(arr[i])) 
            return false; 
    return true; 
} 
void solve()
{
    ll n; cin>>n;
    ll v[n];
    rep(i,n)
    {
        cin>>v[i];
    }
    ll g=v[0];
    rep(i,n) g=gcd(g,v[i]);
    if(g==1)
    {
        if(pairco(v,n)) cout<<"pairwise coprime";
        else cout<<"setwise coprime";
    }
    else cout<<"not coprime";
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
 //  cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 26980
#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))
S = sum(A[1:])
ret = 0
MOD = 10**9 + 7
for i in range(N-1):
    ret += (A[i] * S) % MOD
    S -= A[i+1]

print(ret%MOD)


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

struct Card{char suit, value;};

void bubble(struct Card A[], int N)
{
  for(int i=0; i<N-1; i++)
  {
    for(int j=N-1; j>i; j--)
    {
      if(A[j].value < A[j-1].value)
      {
        Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N)
{
  for(int i=0; i<N-1; i++)
  {
    int minj = i;
    for(int j=i+1; j<N; j++)
    {
      if(A[j].value < A[minj].value)
        minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N)
{
  for(int i=0; i<N; i++)
  {
    if(i) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N)
{
  for(int i=0; i<N; i++)
  {
    if(C1[i].suit != C2[i].suit)
      return false;
  }
  return true;
}
int main()
{
  Card C1[100], C2[100];
  int N;
  char ch;
  cin >> N;
  for(int i=0; i<N; i++)
  {
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0; i<N; i++)
  {
    C2[i] = C1[i];
  }
  bubble(C1,N);
  selection(C2,N);
  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1, C2,N))
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;
  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define adrep(i,s,n) for (int i=(s);i<(n);i++)
using namespace std;
typedef long long ll;


  
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(){


  string S;
  cin>>S;
  

 
  int plus=stringcount(S,'o');
  
  int cost=700+100*plus;
  cout<<cost;
  
}





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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> a(n+1);
  rep(i, n+1) {
    cin>>a[i];
  }
  dump(a);
  vector<int> b(n);
  rep(i, n) {
    cin>>b[i];
  }
  dump(b);

  int res = 0;
  rep(i, n){
    int r = b[i];
    int d = min(a[i], r);
    res += d;
    r -= d;
    a[i] -= d;

    d = min(a[i+1], r);
    res += d;
    r -= d;
    a[i+1] -= d;
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1792
from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque


def read():
    return int(input())


def readmap():
    return map(int, input().split())


def readlist():
    return list(map(int, input().split()))


N, K = readmap()
A = readlist()
ind1 = A.index(1)

ans = 100000
for k in range(max(0, ind1 - K + 1), ind1 + 1):
    left = int(math.ceil(k / (K - 1)))
    right = max(0, int(math.ceil((N - k - K) / (K - 1))))
    ans = min(ans, left + right + 1)

print(ans)

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

n = len(s)
ans = 0

for i in range(n-1):
  if s[i] == s[i+1]:
    if s[i] == 1:
      s[i+1] = 0
      ans += 1
    else:
      s[i+1] = 1
      ans += 1
print(ans)

Measured memory_bytes: 3956
A, B, C, D = map(int, input().split())
cnt = 0
while True:
  if cnt == 0:
    C -= B
    cnt = 1
    if C <= 0:
      print('Yes')
      break
  elif cnt == 1:
    A -= D
    cnt = 0
    if A <= 0:
      print('No')
      break

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL, *x = root, *z;
    z = (Node*)malloc(sizeof(Node));
    z -> key = k;
    z -> right = NIL;
    z -> left = NIL;
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x -> left;
        }
        else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == NIL) root = z;
    else{
        if(z -> key < y -> key){
            y -> left = z;
        }
        else{
            y -> right = z;
        }
    }
    return;
}

void inParse(Node *u){
    if(u == NIL)return;
    inParse(u -> left);
    cout << " " << u -> key;
    inParse(u -> right);
}

void preParse(Node *u){
    if(u == NIL)return;
    cout << " " << u -> key;
    preParse(u -> left);
    preParse(u -> right);
}

int main() {
    int n, x;
    string q;
    cin >> n;
    rep(i, n){
        cin >> q;
        if(q == "insert"){
            cin >> x;
            insert(x);
        }
        else {
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        cout<<pow(n,3)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	
	int ans = 1;
	int num = n;
	num -= k;
	ans += num / (k - 1);
	if (num % (k - 1)) {
		ans++;
	}
	cout << ans << endl;
}

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

const int N=2e5+5;
long long a[N];
long long ans,maxn;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        maxn=max(maxn,a[i]);
        if(maxn>a[i]) ans+=maxn-a[i];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    cin>>A>>B;
    cout<<(A * 2 <= B && B <= A * 4 && B%2 == 0 ? "Yes" : "No")<<endl;
}

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

vector<int64_t> prime_factor(int64_t n){
    vector<int64_t> ret;
    for(int64_t i=2; i*i<=n; i++){
        if(n % i == 0){
            while(n % i == 0) n /= i;
            ret.push_back(i);
        }
    }
    if(n > 1) ret.push_back(n);
    return ret;
}

int main(){
    int64_t A, B;
    cin >> A >> B;
    map<int64_t, int> mp;
    for(int64_t a : prime_factor(A)) mp[a]++;
    for(int64_t a : prime_factor(B)) mp[a]++;
    int ans = 1;
    for(auto& p : mp) if(p.second == 2) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
S=input()
R=0
G=0
B=0
for s in S:
    if s=='R':
        R+=1
    elif s=='G':
        G+=1
    elif s=='B':
        B+=1
r=0
g=0
b=0
l=len(S)
mix=0
for i in range(l):
    for j in range(i,l):
        k = 2*j-i
        if k >= l:
            break
        #print(i,j,k)
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            mix+=1
            
print(R*G*B-mix)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
pair<string,pll> Sp[111];
ll i, j, k;
int main(){
    scanf("%lld", &N);
    
    fornum(i,0,N){
        ll p;
        cin >> Sp[i].first >>p;
        Sp[i].second.first = -p;
        Sp[i].second.second = i + 1;

    }
    sort(Sp, Sp + N);
    fornum(i,0,N){
        printf("%lld\n", Sp[i].second.second);
    }
    return 0;
}

Measured memory_bytes: 256
function main(input) {
    const inp = input.split(' ')  
    
    if (inp[0] >= 10 || inp[1] >= 10) {
      console.log(-1)
    } else {
      console.log(inp[0] * inp[1])
    }
  }
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int n;
int a[200001],b[200001];
int main(){
	cin>>n;
	FOR(i,0,n) cin>>a[i];
	FOR(i,0,n) cin>>b[i];
	int ans=0;
	FOR(j,0,30){
		int c=0;
		FOR(i,0,n) c^=(a[i]>>j);
		FOR(i,0,n) c^=(b[i]>>j);
		c&=1;
		c&=n;
		vint v;
		FOR(i,0,n) v.push_back(a[i]%(1<<j));
		sort(all(v));
		int k=0;
		FOR(i,0,n){
			k+=v.end()-lower_bound(all(v),(1<<j)-b[i]%(1<<j));
		}
		//cout<<k<<" "<<c<<endl;
		(c^=k)&=1;
		ans+=c<<j;
	}
	//cout<<endl;
	co(ans);
}


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

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

    int count = 0;
    if (a == '1') {
        count++;
    }
    if (b == '1') {
        count++;
    }
    if (c == '1') {
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 1005

int V; //頂点数
vector<int> G[NUM]; //グラフの隣接リスト表現
int match[NUM]; //マッチングのペア
bool used[NUM]; //DFSですでに調べたかのフラグ

//fromとtoを結ぶ辺をグラフに追加する
void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}

//増加パスをDFSで探す(node_idのペアを探す)
int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)|| //隣接するノードに、まだペアが存在しない
				(used[pair_id] == false && dfs(pair_id) == true)){

			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1; //ペアなしにしておく
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){ //node_idにペアがいない場合
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){ //増加パスが存在する場合
				ret++;
			}
		}
	}
	return ret;
}


int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	int from,to;
	int tmp;

	for(int i = 0; i < N; i++){

		to = i;
		scanf("%d",&tmp);
		for(int k = 0; k < tmp; k++){

			scanf("%d",&from);
			from--;
			add_edge(from,M+to);
		}
	}

	V = N+M;

	if(bipartie_matching() == M){

		printf("Bob\n");

	}else{

		printf("Alice\n");
	}

	return 0;
}



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

int main() {
    using namespace std;
    unsigned long M, D;
    cin >> M >> D;
    unsigned long ans{0};
    for(unsigned long i = 4; i <= M; ++i)for(unsigned long j = 2; j < 10; ++j)if(i % j == 0 && i / j < 10 && i / j >= 2 && (i / j) * 10 + j <= D)++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    string str;
    cin >> str;
    if(str.size()==2)   cout << str;
    else{
        for(int i=2;i>=0;i--) cout << str[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 768
// http://drken1215.hatenablog.com/entry/2019/05/19/224500
//参考にさせて頂いた解説
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

const ll INF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;
Graph G;
int N;

vector<int> res;

void DFS(int v,int p,int c){
    res[v]=c;
    for(auto e:G[v]){
        if(e.first==p)continue;//次頂点が親である場合スルー
        if(e.second & 1) DFS(e.first,v,1-c);//e.second&1はbitで奇数判定を行っている。奇数の時は色を変えている。
        else DFS(e.first,v,c);//奇数でないためcolorはそのまま
    }
}

int main(){
    cin>>N;
    G.assign(N,vector<Edge>());
    //入力受け取り
    for(int i=0;i<N-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }
    res.assign(N,0);
    DFS(0,-1,1);//0は頂点を選択するため、-1は親がないため、1は色をつけるため。
    for(auto v: res) cout<<v<<endl;
    return 0;
}

//a=97,z=122

//頂点に色を設定し、そこから行ける頂点の辺の距離が偶数であれば、同色を設定し、奇数であれば、違う色？
//辺と頂点のリンクの仕方はどうしよう？

Measured memory_bytes: 8960
#include <stdio.h>

int main() {
  long int n;
  scanf("%ld", &n);
  long int t[5];
  long int min = 10000000000000000;
  for(int i=0; i<5; i++) {
    scanf("%ld", &t[i]);
    if (t[i] < min) min = t[i];
  }
  long int g;
  if(n % min > 0) g = (n/min)+1;
  else g = n/min;
  printf("%ld\n", g+4);

  return 0;
}


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

using namespace std;
int a[55],b[55];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++)
        cin >> b[i];
    int x=0,y=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            x+=a[i];
            y+=b[i];
        }
    }
    cout << x-y;
    return 0;
}


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

string result[4] = {"AC", "WA", "TLE", "RE"};

int main() {
    int N;
    cin >> N;
    int cnt[4] = {};
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < 4; j++) {
            if (S == result[j]) cnt[j]++;
        }
    }
    for (int i = 0; i < 4; i++) {
        cout << result[i] << " x " << cnt[i] << endl;
    }
}

Measured memory_bytes: 3628
import numpy as np

X, N = (int(x) for x in input().split())
if N == 0:
    print(X)
else:
    p = np.array([int(x) for x in input().split()])
    x_arange = set(np.arange(-100, 101))
    p_x = set(np.array(p - X))
    sub_list = list(x_arange - p_x)
    sub_abs_list = np.abs(np.array(sub_list))

    min_sub = min(sub_abs_list)
    if (X - min_sub) not in p:
        print(X - min_sub)
    else:
        print(X + min_sub)

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

int main(){
    int N;
    cin>>N;
    int P[N];
    int max=0;
    for(int i=1;i<=N;++i){
        cin>>P[i];
        if(max<=P[i])
            max=P[i];
    }

    

    int sum=0;
    for(int i=1;i<=max;++i){
        int sumi=0;
        for(int j=1;j<=N;++j){
            int su=0;
            su=(P[j]-i)*(P[j]-i);

            sumi+=su;
        }
        if(i==1){
            sum=sumi;
        }
        
        if(sum>=sumi){
            sum=sumi;
        }
    }
    cout<<sum<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main(){
  ll a,b;
  cin >> a >> b;
  b-=a;
  if(b+a == 1){
    cout << 0 << endl;
  }
  else if(b+a<a){
    cout << 1 << endl;
  }
  else if(b%(a-1)==0){
    cout << b/(a-1)+1 << endl;
  }
  else{
    cout << b/(a-1)+2 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m;
ll aa[1005][1005];

int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	for (ll i = 1; i <= b; i++)
	{
		for (ll j = 1; j <= a; j++)
		{ aa[i][j] = 1; }
	}
	for (ll i = h; i > b; i--)
	{
		for (ll j = w; j > a; j--)
		{ aa[i][j] = 1; }
	}
	for (ll i = 1; i <= h; i++)
	{
		for (ll j = 1; j <= w; j++)
		{ cout << aa[i][j]; }
		cout << '\n';
	}
	return 0;
}


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

#define lli long long unsigned int
#define REP(i,n) for(lli i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

lli calc(lli num,lli b){
	lli sum = 0;
	lli s = 1;
	for(lli i=0;i<=b;i++){
		s*=2;
	}
	lli shalf = s/2;
	sum = num/s * shalf;
	if(num%s >=shalf)sum+=(num%s-shalf+1);

	return sum;
}

int main(){

	lli x,y;
	cin>>x>>y;

	/*各桁を見る*/
	lli ans = 0;
	if(x==0 && y==0){
		cout<<0<<endl;
		return 0;
	}
	else{
	REP(i,63){
		if(x==0)x=1;
		lli xbit = calc(x-1,i);
		lli ybit = calc(y,i);
		lli bitDiff = ybit-xbit;
		if(DEBUG)cout<<"i="<<i<<"xb="<<xbit<<"yb="<<ybit<<endl;
		if(bitDiff % 2)ans |= ((lli)1<<i);
	}
	}

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

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

const int N = 2e5 + 10;

int a[N];
int n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int op = 0, desire = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] == desire) {
            desire++;
            continue;
        }
        else {
            op++;
            continue;
        }
    }
    if (op >= n) {
        printf("-1\n");
        return 0;
    }
    else {
        printf("%d\n", op);
        return 0;
    }
    return 0;
}

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

int main(){
    const int64_t mod = (int64_t)pow(10, 9) + 7;
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> first(n+1, 0);
    first[0] = 0;
    vector<int64_t> last(n+1, 0);
    for (auto i = 1; i <= n; i++) {
        first[i] = first[i - 1] + i;
    }
    last[0] = n;
    for (auto i = 1; i <= n; i++) {
        last[i] = last[i - 1] + (n - i);
    }
//    for (auto i = 0; i <= n; i++) {
//        cout << first[i] << " " << last[i] << endl;
//    }

    int64_t ans = 0;
    for (auto i = k - 1; i <= n; i++) {
//        cout << first[i] << " " << last[i] << " " << (last[i] - first[i] + 1) << endl;
        ans = (ans + (last[i] - first[i] + 1)) % (mod);
    }

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

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n; cin>>n;
    int p[n];
    int count = 0;
    rep(i,n){
        cin>>p[i];
        if(i+1 == p[i]) count++; 
    }
    rep(i,n-1){
        if((i+1 == p[i])&&(i+2 == p[i+1])){
            count--;
            i++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,v,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a;
cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3612