akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    rep(i, 2) {
        if((c[i][1] - c[i][0] != c[i + 1][1] - c[i + 1][0]) || (c[i][2] - c[i][1] != c[i + 1][2] - c[i + 1][1])) {
            No();
        }
    }
    rep(i, 2) {
        if((c[1][i] - c[0][i] != c[1][i + 1] - c[0][i + 1]) || (c[2][i] - c[1][i] != c[2][i + 1] - c[1][i + 1])) {
            No();
        }
    }
    Yes();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll fmemo[100002];
ll imemo[100002];
ll ifmemo[100002];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll fact(ll n){
    if(n == 0) return 1;
    if(fmemo[n]) return fmemo[n];
    return fmemo[n] = n * fact(n - 1) % MOD;
}

ll ifact(ll n){
    if(n == 0) return 1;
    if(ifmemo[n]) return ifmemo[n];
    return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
}

ll com(ll n, ll k){
    if(k > n) return 0;
    if(k == n || k == 0) return 1;
    return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    for(ll i = 1; i <= 100001; i++){
        imemo[i] = modpow(i, MOD - 2);
    }
    for(int i = 1; i <= k; i++){
        cout << com(k - 1, i - 1) * com(n - k + 1, i) % MOD << endl;
    }
}

Measured memory_bytes: 1152
s = int(input())
mod = 10**9 + 7
a = [0] * (2001)
a[3] = a[4] = a[5] = 1
for i in range(6, s + 1):
    a[i] = a[i - 1] + a[i - 3]
    a[i] %= mod
print(a[s])


Measured memory_bytes: 63504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



signed main() {
	string S; cin >> S;
	int rem = 15;
	REP(i, S.size()) {
		if (S[i] == 'x')rem--;
	}
	if (rem >= 8) {
		print("YES");
	}
	else print("NO");
}


Measured memory_bytes: 256
N = input()
while True:
    dic = {}
    for i in range(N):
        lis = raw_input().split()
        dic[lis[0]] = [3*int(lis[1])+int(lis[3]), N-i]
    
    for k, v in sorted(dic.items(), key=lambda x: (x[1][0], x[1][1]), reverse=True):
        print '%s,%s' % (k, v[0])

    N = input()
    if N == 0: break
    print

Measured memory_bytes: 4228
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 6, M = 6;

char cc[N][M + 1];

int main() {
	int n, m, k; cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> cc[i];
	int ans = 0;
	for (int bi = 0; bi < 1 << n; bi++)
		for (int bj = 0; bj < 1 << m; bj++) {
			int x = 0;
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					if (bi & 1 << i || bj & 1 << j)
						continue;
					if (cc[i][j] == '#')
						x++;
				}
			if (x == k)
				ans++;
		}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652
def resolve():
    x, y = list(map(int, input().split()))
    groups = [[1, 3, 5, 7, 8, 10, 12],
              [4, 6, 9, 11],
              [2]]
    for group in groups:
        if x in group and y in group:
            print("Yes")
            return
    print("No")
    


if '__main__' == __name__:
    resolve()

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

using namespace std;
#define all(x) (x).begin(),(x).end()

using gragh = vector<vector<int>>;
vector<int> color;

bool dfs(const gragh &edge_gragh,int v,int cur=0){
    color[v] = cur;
    for(auto next_v:edge_gragh[v]){
        if (color[next_v]!=-1){
            if(color[next_v]==cur) {
                return false;
            }
            continue;
        }
        if(!dfs(edge_gragh,next_v,1-cur)) return false;
    }
    return true;
}


int main() {

    int N;
    int M;
    cin>>N>>M;

    gragh edge_gragh(N);
    for (int i = 0; i < M; ++i) {
        int A,B;
        cin>>A>>B;
        A--;
        B--;
        edge_gragh[A].push_back(B);
        edge_gragh[B].push_back(A);
    }

    color.assign(N,-1);
    bool is_bipartite = true;
    for(int v=0;v<N;++v){
        if(color[v]!= -1) continue;
        if(!dfs(edge_gragh,v)){
            is_bipartite = false;
        }
    }

    if (is_bipartite){
        long long sum = accumulate(all(color),0LL);
        long long ans =sum * ((long long)N-sum) - (long long)M;
        cout<<ans<<endl;
    }else{
        long long ans =(((long long)N * ((long long)N - 1)) / 2) - (long long)M;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6528
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

a, b = input().split()
N = int(a + b)

LIM = 10 ** 6
for i in range(1, LIM):
    tmp = i * i
    if tmp == N:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin>>s;
int max,count;
max=0;
count=0;
for(int i=0; i<s.length();i++){

	if(s[i]=='R'){
		count++;
		if(max<count){
			max=count;
		}

	}
	else
		count=0;
}
cout<<max;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

int n, m, l;
vector<P>e[305];

P shortest[305][305];

signed main() {
	cin >> n >> m >> l;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		if (c <= l) {
			e[a].push_back({ b,c });
			e[b].push_back({ a,c });
		}
	}
	//cout << endl;

	rep(i, n) {
		rep(j, n) shortest[i][j] = { INF,INF };
		shortest[i][i] = { 0,0 };
		priority_queue<pair<P, int>, vector<pair<P, int>>, greater<pair<P, int>>> que;
		que.push({ {0,0},i });
		while (!que.empty()) {
			pair<P, int> now = que.top();
			//cout << i <<" {"<< now.first.first << "," << now.first.second << "} " <<now.second<< endl;
			que.pop();
			if (shortest[i][now.second] < now.first) {
				continue;
			}
			rep(j, e[now.second].size()) {
				P next;
				if (now.first.second + e[now.second][j].second <= l) {
					next = { now.first.first,now.first.second + e[now.second][j].second };
				}
				else {
					next = { now.first.first + 1, e[now.second][j].second };
				}
				if (next < shortest[i][e[now.second][j].first]) {
					shortest[i][e[now.second][j].first] = next;
					que.push({ next, e[now.second][j].first });
				}
			}
		}
	}

	int q;
	cin >> q;
	rep(i, q) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		if (shortest[a][b].first == INF) cout << -1 << endl;
		else cout << shortest[a][b].first << endl;
	}


	return 0;
}

Measured memory_bytes: 5688
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL n,a[15],cnc = 0;

void dfs(LL dep,LL num){
	if(dep >= n){
		cnc ++;
		for(LL i = 0;i < n;i ++) cout << (char)(a[i] + 'a' - 1);
		cout << '\n'; 
		return;
	}
	for(LL i = 1;i <= num + 1;i ++){
		a[dep] = i;
		dfs(dep + 1,max(num,i));
		a[dep] = 0;
	}
}

int main(){
	cin >> n; a[0] = 1;
	dfs(1,1);
//	cout << cnc << endl;
	return 0;
}

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

int main() {
    int n, v[100000];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", v + i);
    int odd_cnt[100001] = {0}, max_cnt = 0, second = 0;
    int use_num = -1;
    for (int i = 0; i < n; i += 2) {
        odd_cnt[v[i]]++;
        if (max_cnt < odd_cnt[v[i]]) {
            if (use_num != v[i]) {
                second = max_cnt;
            }
            use_num = v[i];
            max_cnt = odd_cnt[v[i]];
        } else if (second < odd_cnt[v[i]]) {
            second = odd_cnt[v[i]];
        }
    }
    int cnt[100001] = {0}, use_num2 = -1, second2 = 0, max_cnt2 = 0;
    for (int i = 1; i < n; i += 2) {
        cnt[v[i]]++;
        if (max_cnt2 < cnt[v[i]]) {
            if (use_num2 != v[i]) {
                second2 = max_cnt2;
            }
            use_num2 = v[i];
            max_cnt2 = cnt[v[i]];
        } else if (second2 < cnt[v[i]]) {
            second2 = cnt[v[i]];
        }
    }

    if (use_num == use_num2) {
        printf("%d\n", n - max(max_cnt+second2, max_cnt2+second));
    } else {
        printf("%d\n", n - (max_cnt + max_cnt2));
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 3e5 + 5;
int t;


int main()
{
	//freopen("in.txt", "r", stdin);
	int a, b, c;
	while (cin >> a >> b >> c)
	{
		if (a + b + c >= 22)puts("bust");
		else puts("win");
	}
	return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 1;
		for (int i = 2; i <= n; i++) {
			int tem = i * i;
			while (tem <= n) {
				ans = Math.max(ans, tem);
				tem *= i;
			}
		}
		System.out.println(ans);
	}
}

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

const int kN = 100'000 + 5;
const int kMod = 1'000'000'000 + 7;
int x[kN], y[kN];

int f(int *a, int n) {
    int sum = 0, res = 0;
    for (int i = 0; i < n; ++i) {
        a[i] = (a[i] % kMod + kMod) % kMod;
        int add = (1LL * a[i] * i + kMod - sum) % kMod;
        (res += add) %= kMod;
        (sum += a[i]) %= kMod;
    }
    return res;
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    for (int i = 0; i < m; ++i) scanf("%d", &y[i]);
    int ans = 1LL * f(x, n) * f(y, m) % kMod;
    printf("%d\n", ans);
    return 0;
}


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

double solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
    }
    vector<double> s(N+1);
    double m = 0;
    for ( int i = 0; i < N; i++ ) {
        s[i+1] = s[i] + (1+P[i]);
        if ( i >= K-1 ) {
            double x = s[i+1] - s[i+1-K];
            if ( m < x ) m = x;
        }
    }
    double ans = m / (double)(2);
    return ans;
}

int main() {
    cout.setf(ios::fixed);
    cout.precision(16);
    
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int dp[101][10001], weight[101], v[101];

int main()
{
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; ++i)cin >> v[i] >> weight[i];
	for (int i = 0; i < n; ++i){
		for (int j = 0; j <= w; ++j){
			if (j < weight[i])dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - weight[i]] + v[i]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}


Measured memory_bytes: 7004
#include <stdio.h>
int main(){
	int n,i,j,m,f;
	char a[100],b[100],x;
	while(1){
	scanf("%d ",&n);
	if(n==0){
		break;
        }

	for(i=0;i<n;i++){
		scanf("%c %c ",&a[i],&b[i]);
	}
	
	scanf("%d ",&m);
	for(i=0;i<m;i++){
		scanf("%c ",&x);
		f=0;
		for(j=0;j<n;j++){
		 if(x==a[j]){
			printf("%c",b[j]);
			f=1;
			break;
		 }
	    }
	 if(f==0){
	    printf("%c",x);
	 }
	}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1004
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)
N, M = map(int, input().split())
a = [int(i)//2 for i in input().split()]
x = 1
for i in range(N):
  x = lcm(x, a[i])
for i in range(N):
  if (x//a[i])%2==0:
    print(0)
    exit()
num = M//x
print(num//2 if num%2==0 else num//2+1)


Measured memory_bytes: 16316
//  AOJ Algorithms and Data Structures I - Dynamic Programming - Matrix Chain Multiplication
// s 2013 0925 1640
// e 

/* 2014 0329 1621

イメージ的には
---------------------
|M11|M12|M13|   |   | 
---------------------
|   |M22|M23|   |   | 
---------------------
|   |   |M33|   |   |  
---------------------
|   |   |   |M44|   |
---------------------
|   |   |   |   |M55|
---------------------

-------------------
|r1|r2|r3|r4|r5|r6|
-------------------

この二つを作って使う

*/


#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;


//コストの計算 costを参照渡しで持ってきて、直接入れる
// s eはstart end の略でcostの配列添え字
void cal_cost(vector< vector<int> >& cost, vector<int> r, int s, int e){
	int ans;
	int k; //切る場所 (k=2 なら、　1|234 )

	if(s==e){ cost[s][e]=0; } //Miiのコストは0
	else{
		cost[s][e]=2000000000; //最小値求めるためのセンチネル　数値は適当
		for(k=s+1; k<=e; k++){
			ans = cost[s][k-1] + cost[k][e] + r[s]*r[k]*r[e+1];
			if(ans<cost[s][e]) cost[s][e] = ans;
		}
	}
}


//http://algorithms.blog55.fc2.com/blog-entry-66.html
//このホームページ見て正解っぽく動的計画法で書いてみる版
int DP_myself( vector< vector<int> > A, int n){
	int i, diff;

	//最終的な出力は最小コストだけでいいので、かけ算の順番は保存しない。するとしたら、cost配列を構造体にして、ルーツの保存しとけば、それでたどれると思う
	// (cost[][]の使い方)  M_ijのコストをcost[i][j]に入れる (M11, M22等はコスト0)
	vector< vector<int> > cost(n,vector<int>(n)); //Mijにかかるコスト（最少）

	//行とか列の長さを入れる配列
	vector<int> r(n+1);

	//rを埋めてく
	for(i=0;i<n;i++){
		r[i]=A[i][0];
	}
	r[n]=A[n-1][1];

	//costを埋めていく(右斜め下に進んで。ピラミッド状に)
	for(diff=0; diff<n; diff++){
		for(i=0; i+diff<n; i++){
			// デバッグ用printf("%d,%d,%d\n", diff,i,i+diff);
			cal_cost(cost, r, i, i+diff); //コストの計算
		}
		
	}

	cout << cost[0][n-1] << endl;

	return 0;
}


int main(){
	int i;
	int n;
	int num_multi=0;
	
	cin >> n;
	//dequeやlistでなくても、途中の要素の削除できるんでvectorでいい。
	// C++で2次元配列を動的に確保する方法 http://samidarehetima.blog9.fc2.com/blog-entry-95.html
	//連鎖行列はA[0][] ~ A[n-1][] まで。
	vector<vector<int> > A(n,vector<int>(2)); //[][0]=r, [][1]=c
	for(i=0;i<n;i++){
		cin >> A[i][0];
		cin >> A[i][1];
	}


	DP_myself(A,n);

    return 0;
}

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

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

int main() {
  int a, b;
  std::cin >> a >> b;
  std::cout << (a + b) % 24 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s1[20]="CODEFESTIVAL2016";
char s[20];
int main()
{
	int ans=0;
	scanf("%s",s);
	for(int i=0;i<16;i++)
		ans+=(s[i]!=s1[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define debug 0

int d[202][202];
int m[202][202];
int queX[40806];
int queY[40806];

int w,h;
int ans;

void draw(){
	if(debug){
		for(int i=0;i<=h*2;i++){
			for(int j=0;j<=w*2;j++){
				if(d[j][i]==1)cout<<"#";
				else cout<<" ";
			}
			cout<<endl;
		}
		cout<<endl;
	}
}

void push(int X,int Y,int num){
	m[X][Y]=num;
	queX[queX[0]+1]=X;
	queY[queY[0]+1]=Y;
	queY[0]++;
	queX[0]++;
}
void pop(){
	queX[1]++;
	queY[1]++;
}
void reset(){
	for(int i=0;i<=h*2;i++)for(int j=0;j<=w*2;j++)d[j][i]=0;
	for(int i=0;i<=h*2;i++)for(int j=0;j<=w*2;j++)m[j][i]=-1;
	for(int i=0;i<=w*2;i++)d[i][0]=d[i][h*2]=1;
	for(int i=0;i<=h*2;i++)d[0][i]=d[w*2][i]=1;
	for(int i=2;i<=h*2-2;i+=2)for(int j=2;j<=w*2-2;j+=2)d[j][i]=1;
	queX[0]=queY[0]=1;//2から追加/最後に追加した場所=1
	queX[1]=queY[1]=1;//2を放出/最後に放出した場所=1
	push(2*w-1,2*h-1,0);
}
void scan(){
	for(int i=1;i<=h*2-1;i++){
		if(i%2)for(int j=1;j<w;j++)cin>>d[j*2][i];
		else for(int j=1;j<=w;j++)cin>>d[j*2-1][i];
	}
	draw();
}
void cal(){
	int PX[4]={0,1,0,-1};
	int PY[4]={1,0,-1,0};
	
	for(;queX[0]>queX[1];pop()){
		//cout<<"*"<<queX[queX[1]+1]<<" "<<queY[queY[1]+1]<<" *"<<queX[0]<<" "<<queY[1]<<endl;
		for(int i=0;i<4;i++){
			if(d[queX[queX[1]+1]+PX[i]][queY[queY[1]+1]+PY[i]]==0){
				if(m[queX[queX[1]+1]+PX[i]][queY[queY[1]+1]+PY[i]]<0)push(queX[queX[1]+1]+PX[i],queY[queY[1]+1]+PY[i],m[queX[queX[1]+1]][queY[queY[1]+1]]+1);
			}
		}
	}
}
int main(){	
	while(cin>>w>>h,w){
		reset();
		scan();
		cal();
		if(m[1][1]<0)cout<<0<<endl;
		else cout<<m[1][1]/2+1<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1280
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-19 21:03:06
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    double pi = 3.14159265358979;
    int r;
    cin >> r;

    double ans = pi*2*r;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        ll N;cin>>N;
        if(N==0) break;
        cout<<floor(0.99999999+log10(N)/log10(3))<<endl;
        
        break;
    }
    
}



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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   int n;
   cin >> n;
   vector<ll>v(100000);
   vector<int>a(n);
   rep(i, 0, n)cin >> a[i];
   ll ans = 1;
   rep(i, 0, n){
       ll p = a[i];
       if(p==0){
           v[p]++;
           ans *= (4-v[p]);
           ans %= mod;
       }else{
           v[p]++;
           ans *= min(v[p-1],v[p-1]+1-v[p]);
           ans %= mod;
       }
       //cout << ans << endl;
   }
   cout << ans << endl;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int main(){
    fast();
    long long a , b , c , d ;
    cin >> a >> b >> c >> d ;
    long long ans1 = a * c ;
    long long ans2 = a * d ;
    long long ans3 = b * c ;
    long long ans4 = b * d ;
    long long ans = (long long)(max(ans1,max(ans2,max(ans3,ans4))));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n,k;
 cin>>n>>k;
 ll total=(n*(n+1))/2;
 ll loop=n-k+1;
 ll start=k-1;
 ll endd=n-k;
 ll cnt=0,ans=0;
 while(cnt<loop)
 {
  ll aa=(start*(start+1))/2;
  ll bb=total-(endd*(endd+1))/2;
  ans=((ans%INF)+(bb-aa+1)%INF)%INF;
  start++;
  endd--;
  cnt++;

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

}


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

using namespace std;

typedef long long ll;
const int N = (int) 2e5 + 7;
int n;
int a[N];
int u[N];
bool valid[N];

ll k;
vector <int> p[N];

int rep(int num) {
        return num % n;
}

vector <int> cy;

void add_cy(int x) {
        if (valid[x]) {
                cy.push_back(x);
        }
}

vector <int> sol;
set <int> cur;

void ins(int x) {
        if (cur.find(x) == cur.end()) {
                sol.push_back(x);
                cur.insert(x);
        } else {
                int deleted = -1;
                while (deleted != x) {
                        deleted = sol.back();
                        sol.pop_back();
                        cur.erase(deleted);
                }
        }
}

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

        cin >> n >> k;

        for (int i = 0; i < n; i++) {
                cin >> a[i];
                p[a[i]].push_back(i);
        }

        for (int i = 1; i < N; i++) {
                int sz = (int) p[i].size();
                if (sz > 0) {
                        for (int j = 0; j + 1 < sz; j++) {
                                u[p[i][j]] = rep(p[i][j + 1] + 1);
                        }
                        u[p[i].back()] = rep(p[i][0] + 1);
                        valid[p[i].back()] = 1;
                }
        }

        cy.push_back(n);
        add_cy(0);
        int now = u[0];

        while (now != 0) {
                add_cy(now);
                now = u[now];
        }

        int sz = (int) cy.size();
        k %= sz;

        for (int i = cy[k]; i < n; i++) {
                ins(a[i]);
        }

        for (auto &it : sol) {
                cout << it << " ";
        }
        cout << "\n";

        return 0;
}


Measured memory_bytes: 25208
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int a,b,k;
    cin >> a >> b >> k;

    int x = __gcd(a,b);
    for(int i=x; i>=1; i--){
        if(x%i==0){
            k--;
            if(k==0){
                cout << i << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

def get_size(s):
    return size[get_root(s)]

def update_size(x, y, s):
    size[get_root(s)] = x + y

n, m = map(int, input().split())
c = (n * (n - 1)) // 2
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
ans = [c]
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c)
for i in range(m - 1, -1, -1):
    print(ans[i])

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

int N;
int odd_cnt;

void agc010a() {
  if (odd_cnt % 2 == 0) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return;
}

int main() {
  odd_cnt = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 1) {
      odd_cnt++;
    }
  }
  agc010a();
  return 0;
}

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

int H, A, n;
string ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> H >> n;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        A += c;
    }
}

void solve(){
    ans = "No";
    if(A >= H)
        ans = "Yes";
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  switch(N%10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl; break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl; break;
      
    case 3:
      cout << "bon" << endl;
  }

}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 3596
#
import sys
import math
import numpy as np
import itertools


a = input()
b = int(input())
x = [a[i:i+1] for i in range(len(a))]
#print(x)
for i in range(len(a)):
    if i % b == 0 :
        print(x[i], end='')
print()


Measured memory_bytes: 12496
using System;
using System.Linq;

class Program {
    private static int Main() {
        while( true ) {
            var input = Console.ReadLine();
            var n = int.Parse( input );

            if( n == 0 ) { break; }

            input = Console.ReadLine();
            var values = input.Split( ' ' );
            // intの配列にする
            var intValues = values.Select<string, int>( _ => int.Parse( _ ) );
            // 平均値算出
            var m = intValues.Average();
            // 標準偏差算出
            var a = Math.Sqrt( intValues.Sum( _ => Math.Pow( _ - m, 2 ) ) / n );
            Console.WriteLine( a );
        }

        return 0;
    }
}

Measured memory_bytes: 7972
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	long int a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << '0' << endl;
	else
		cout << min(min(a*b, b*c), c*a) << endl;

	return 0;
}

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

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n";
#define print(a) for(auto x : a) cout << x << " "; cout << "\n";

const int inf = 1e18 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
    int h, a;
    cin >> h >> a;
    int ans = (h % a == 0) ? h / a : h / a + 1;
    cout << ans << endl;
}

int32_t main()
{
    DESYNC
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			int i = 0;
			int i2 = 0;

			// ??\??????0,0?????¨???
			if ((H==0) && (W==0)) break;
				
			for(i=0; i<H; i++){
				//?\???°????????¨???
				if (i%2==1) {
					for(i2=0; i2<W; i2++) {
						if ((i2%2) == 1) System.out.print("#");
						else System.out.print(".");
					}
				}
				//??¶??°????????¨???
				else {
					for(i2=0; i2<W; i2++) {
						if ((i2%2) == 1) System.out.print(".");
						else System.out.print("#");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
		
	}

}

Measured memory_bytes: 34576
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2+5;
const int K = 1e5+5;

const int mod = 1e9+7;

int n;
int k;
int ar[N];
long long dp[N][K];
long long prefix[K];
// no of ways when you are at index i and left j with you
// possible transitions dp[i][j]


long long get(int l , int r){
    return (prefix[r] - prefix[l - 1] + mod + mod) % mod;
}

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
    }
    prefix[0] = 1;
    for(int i = 1; i <= k; i++){
        prefix[i] = prefix[i - 1];
    }
    dp[n + 1][0] = 1;
    for(int i = n; i >= 1; i--){
        for(int j = k; j >= 0; j--){
            dp[i][j] += get(j - min(ar[i] , j) , j);
            dp[i][j] %= mod;
        }
        for(int j = 0; j <= k; j++){
            if(j == 0){
                prefix[0] = dp[i][0];
                continue;
            }
            prefix[j] = prefix[j - 1] + dp[i][j];
            prefix[j] %= mod;
        }
    }
    printf("%d\n" , dp[1][k]);
}


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

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

typedef long long int ll;

int read_int()
{
    int a;
    scanf("%d", &a);
    return a;
}

int read_lint()
{
    ll a;
    scanf("%lld", &a);
    return a;
}

int read_float()
{
    float a;
    scanf("%f", &a);
    return a;
}

int read_double()
{
    double a;
    scanf("%lf", &a);
    return a;
}

#define N 200010

ll a[N];

int greater(const void *arg1, const void *arg2)
{
    return *(int *)arg1 < *(int *)arg2;
}

int main()
{
    ll n = read_lint();

    for (int i = 0; i < n; i++)
    {
        a[i] = read_lint();
    }

    qsort(a, n, sizeof(ll), greater);

    ll ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        ans += a[(i + 1) / 2];
        // printf("%lld %lld\n", a[i], ans);
    }
    printf("%lld\n", ans);

    return 0;
}

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

using namespace std;

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

    vector<pair<long long, int>> G[N];
    vector<int> color(N, 0);
    // 0 not colord. 1 colored black. 2 colored white
    for(int i=0;i<N-1;i++) {
        int u,v,w; cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(make_pair(v,w%2));
        G[v].push_back(make_pair(u,w%2));
    }

    stack<pair<int,int>> Q;
    Q.push(make_pair(0,0));
    while(!Q.empty()) {
        auto q = Q.top(); Q.pop();
        int node = q.first;
        int dist = q.second;

        if(color[node] != 0) continue;
        color[node] = dist%2 + 1;

        for(auto n : G[node]) {
            Q.push(make_pair(n.first, dist + n.second));
        }
    }

    for(auto c : color) {
        cout << c-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

char M[8][8];

void printRotate(int n) {
  const static int s90n[4] = {0,1,0,-1};
  const static int c90n[4] = {1,0,-1,0};
  n = (4-n);
  rep(y, 8) {
    rep(x, 8) {
      int nx = x*c90n[n] - y*s90n[n];
      int ny = x*s90n[n] + y*c90n[n];
      if(n == 1 || n == 2) nx += 7;
      if(n == 2 || n == 3) ny += 7;
      cout << M[ny][nx];
    }
    cout << endl;
  }
}

void solve() {
  rep(i, 3) {
    cout << (i+1) * 90 << endl;
    printRotate(i+1);
  }
}

main() {
  rep(i, 8) rep(j, 8) cin >> M[i][j];
  solve();
}

Measured memory_bytes: 0
import numpy
H, W = [int(i) for i in input().split()]
A = numpy.array([list(input().strip()) for _ in range(H)])

row_space = []
col_space = []

for k, row in enumerate(A):
    if '#' not in row:
        row_space.append(k)

A_rot = numpy.rot90(A, k=-1)
for k, row in enumerate(A_rot):
    if '#' not in row:
        col_space.append(k)

A = numpy.delete(A, row_space, axis=0)
A = numpy.delete(A, col_space, axis=1)
ans = '\n'.join([''.join(row) for row in A])
print(ans)

Measured memory_bytes: 21264
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
// #define N 100005 
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
    	int i;
    	ll dp[2001]={0};dp[0]=1;
    	repf(i,3,2001) 
    	{
			for(int j=3; i-j>=0 && j<2001; j++) 
			dp[i]=(dp[i]+dp[i-j]);
			dp[i]%=mod;
		}
		int n;cin>>n;
		if(n<3) cout<<0;
		else cout<<dp[n];
    }
    return 0;
} 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define MAXN 200200

ll a[MAXN], b[MAXN], suma, sumb, reza;

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
    suma += a[i];
    sumb += b[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      ll C = suma - a[i] + (a[i] - b[i]);
      reza = max(reza, C + max(0LL, C - (sumb - b[i])));
    }
  }
  cout << reza;
  return 0;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
INF=10**9+7
n,m=map(int,input().split())
x_list=list(map(int,input().split()))
y_list=list(map(int,input().split()))
X=0
plus=0
for i in range(n-1):
    plus=(plus+(x_list[i+1]-x_list[i])*(i+1))%INF
    X=(X+plus)%INF
Y=0
plus=0
for i in range(m-1):
    plus=(plus+(y_list[i+1]-y_list[i])*(i+1))%INF
    Y=(Y+plus)%INF
ans=(X*Y)%INF
print(ans)
    
    


Measured memory_bytes: 74468
function Main(input){
	input = input.split(" ").map(Number);
	var arr = new Array(101).fill(0);
	for(var i=input[0];i<input[1];i++){
		arr[i]++;
	}
	for(i=input[2];i<input[3];i++){
		arr[i]++;
	}
	var sum = 0;
	for(i=0;i<=100;i++){
		if(arr[i] == 2) sum++;
	}
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	if (s == "keyence") {
		cout << "YES" << endl; return 0;
	}
	int n = s.size();
	rep(i, n) {
		FOR(j, i, n) {
			string tmp = "";
			rep(k, n) {
				if (k < i || j < k)tmp += s[k];
			}
			if (tmp == "keyence") {
				cout << "YES" << endl; return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int ar[n][2];
	bool v[n];
	for(int i=0;i<n;i++){
		cin>>ar[i][0]>>ar[i][1];
		if(ar[i][0]==ar[i][1])v[i]=true;
		else
		v[i]=false;
	}
	bool ok = false;
	for(int i=0;i<n-2;i++){
		if(v[i]&&v[i+1]&&v[i+2]){
			ok = true;
		}
	}
	if(ok)
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3648
unittest
{
	assert( [ "1 3" ].parse.expand.solve == 3 );
	assert( [ "0 1" ].parse.expand.solve == 0 );
	assert( [ "32 21" ].parse.expand.solve == 58 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ap = input.front.split.to!( long[] );
	return tuple( ap[ 0 ], ap[ 1 ] );
}

auto solve( long a, long p )
{
	return ( a * 3 + p ) / 2;
}


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

using namespace std;

void solve()
{
	vector<int> Vec(100);
	int n;
	while(cin >> n)
	{
		++Vec[n];
	}
	int max = 0;
	for(int i = 0; i < Vec.size(); ++i)
	{
		if(max < Vec[i])
		{
			max = Vec[i];
		}
	}
	for(int i = 0; i < Vec.size(); ++i)
	{
		if(max == Vec[i])
		{
			cout << i << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    int k,x;cin>>k>>x;
    for (int i = x-(k-1); i <=x; i++)
    {
        /* code */
        cout<<i<<' ';
    }
    for (int i = x+1; i <=x+(k-1) ; i++)
    {
        /* code */
        cout<<i<<' ';
    }
    
    

}

Measured memory_bytes: 256
X=int(input())
l2=[1,4,8,16,32,64,128,256,512]
l3=[9,27,81,243,729]
l5=[25,125,625]
l6=[36,216]
l7=[49,343]
l10=[100,1000]
le=[n*n for n in range(11,32)]
l=l2+l3+l5+l6+l7+l10+le
m=max([i for i in l if i<=X])
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

ll a[3005];
ll dp[3005][3005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,0,n)
    cin>>a[i];
  for(ll s=n-1;s>=0;s--){
    for(ll e=s;e<n;e++){
      if(s==e){
        dp[s][e]=a[s];
        continue;
      }
      dp[s][e]=max(a[s]-dp[s+1][e],a[e]-dp[s][e-1]);
    }
  }
  ll ans=dp[0][n-1];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 70016
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}
static inline void read(ll &x) { cin>>x;}

ll ar[1<<10];
ll vis[1<<20], cnt[1<<20], mark[1<<20], cas[1<<20];

int main(){
	fastio;
	ll n; cin>>n;
	FER(i, 0, n){
		ll x; cin>>x;
		vis[x]++;
	}
	FER(i, 0, 1e6+1) if(vis[i] > 1) {
		// trace(i, vis[i], n);
		n-=vis[i];
		cas[i] = 1;
		vis[i] = 0;
		// n -= vis[i];
	}
	// trace(n);
	FER(i, 1, 1e6+1){
		if(!vis[i] and !cas[i]) continue;
		for(ll j = 2*i; j <= 1e6; j+=i){
			if(vis[j] and mark[j] == 0){
				n--;
				mark[j]++;
			} 
			cnt[j]++;
		}
	}
	cout<<n<<"\n";

	return 0;
}


Measured memory_bytes: 19248
### Pythonのバージョンが3.4.3なのでmath.gcd(*, *)がエラーとなるらしい。
import fractions
import math

def prime_factorization(n):
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n > s:
        ans.append([n, 1])

    return(ans)


A, B = [int(a) for a in input().split()]

# d = gcd(A, B) = p_1^(e_1) + p_2^(e_2) + ... + p_k^(e_k)
# と素因数分解できる場合、答えは k + 1
d = fractions.gcd(A, B)
pf = prime_factorization(d)
print(len(pf) + 1)

Measured memory_bytes: 28636