akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    ll dp[55][5000];
    int N;
    int A;
    int x[55];
    cin >> N >> A;
    REP(i,N) cin >> x[i], x[i] -= A;
    int GETA = 2500;
    memset(dp,0,sizeof(dp));
    dp[0][GETA] = 1;
    for(int i=0; i < N; i++){
        for(int s=0; s+x[i] < 5000; s++){
            if(dp[i][s]==0) continue;
            //選ばない場合
            dp[i+1][s] += dp[i][s];
            //選ぶ場合
            dp[i + 1][s + x[i]] += dp[i][s];
        }
    }
    fin(dp[N][GETA]-1);
    return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc065.contest.atcoder.jp/tasks/arc065_b>
 問題文============================================================
 N 個の都市があり、K 本の道路と L 本の鉄道が都市の間に伸びています。
 i 番目の道路は pi 番目と qi 番目の都市を双方向に結び、
 i 番目の鉄道は ri 番目と si 番目の都市を双方向に結びます。
 異なる道路が同じ 2 つの都市を結ぶことはありません。同様に、異なる鉄道が同じ 2 つの都市を結ぶことはありません。
 
 ある都市から別の都市に何本かの道路を通って到達できるとき、
 それらの都市は道路で連結しているとします。
 また、すべての都市はそれ自身と道路で連結しているとみなします。
 鉄道についても同様に定めます。
 
 全ての都市について、その都市と道路・鉄道のどちらでも連結している都市の数を求めてください。
 
 =================================================================
 
 解説=============================================================
 
 UnionFindを用いて、道路と鉄道、それぞれの集合を作っておく、
 あとは、その集合の根の値を用いて、ある頂点iに関して
 （道路の集合の根、鉄道の集合の根）　が等しいペアを数え上げれば良い
 ================================================================
 */

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,K,L; cin >> N >> K >> L;
    vector<ll> p(K),q(K),r(L),s(L);
    
    for(int i = 0; i < K;i++){
        cin >> p[i] >> q[i];
        p[i]--; q[i]--;
    }
    for(int i = 0; i < L;i++){
        cin >> r[i] >> s[i];
        r[i]--; s[i]--;
    }
    
    UnionFind pq(N),rs(N);
    for(int i = 0; i < K;i++) pq.unionSet(p[i], q[i]);
    for(int i = 0; i < L;i++) rs.unionSet(r[i], s[i]);
    map<pii,int> mp;
    for(int i = 0; i < N;i++) mp[pii(pq.root(i),rs.root(i))]++;
    for(int i = 0; i < N;i++){
        cout << mp[pii(pq.root(i),rs.root(i))] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 16640
"""
Writer: SPD_9X2
https://atcoder.jp/contests/exawizards2019/tasks/exawizards2019_e

黒か白かを同じ確率で選ぶので、どちらも絶対無くなってないなら1/2
すなわち、 1<=i<=min(B,W) では必ず1/2を出せば終わり

それ以降は、白が存在していないなら1、黒が存在していないなら0、それ以外は1/2
よって、白が空になってる確率と黒が存在していない確率を出せばよい

白が存在していない確率は、Σj番目で白が空になる確率のように累積で求める
黒も同様
それ以外は余事象
"""

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)
    return fac[n] * inv[n-r] * inv[r] % mod


B,W = map(int,input().split())
mod = 10**9+7
fac,inv = modfac(B+W+10,mod)

half = 500000004

bzero = 0
wzero = 0

for i in range(1,B+W+1):

    print ((wzero + (1-bzero-wzero) * half) % mod)

    if i >= B:
        bzero += pow(half,i,mod) * modnCr(i-1,B-1,mod,fac,inv)
        bzero %= mod
    if i >= W:
        wzero += pow(half,i,mod) * modnCr(i-1,W-1,mod,fac,inv)
        wzero %= mod



Measured memory_bytes: 55152
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

a,b=MI()

ans=['Positive','Negative','Zero']
if a>=1:
    k=0
elif a<=0 and b>=0:
    k=2
else:
    if (b-a+1)%2==1:
        k=1
    else:
        k=0
print(ans[k])


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	int N,cnt = 0,str = 0,ans = 0;
	int i = 0;
	string S;

	cin >> N;
	cin >> S;

	while (S[i] != '\0') {
		str++;
		i++;
	}
	
	for (i = 0; i < str; i++) {
		if (S[i] == 'I')
			cnt++;
		if (S[i] == 'D')
			cnt--;
		if (ans < cnt)
			ans = cnt;
	}

	cout << ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,w;
    cin>>n>>w;
    vector<ll>w1;
    vector<ll>v1;
    for(ll i=0;i<n;i++)
    {
        ll x;
        ll y;
        cin>>x>>y;
        w1.push_back(x);
        v1.push_back(y);
    }
    ll a[n+1][w+1];
      for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
                a[i][j]=0;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(w1[i-1]>w)
                break;
                if( j<w1[i-1])
                    a[i][j]=a[i-1][j];
                    else
                   {
                       a[i][j]=max(a[i-1][j-w1[i-1]]+v1[i-1],a[i-1][j]);
                       
                    }
        }
        
    }
    cout<<a[n][w];
   
    }
 
 
    
 

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n;
    string s;
    li k;
    cin>>n>>s>>k;
    k--;
    rin{
        cout<<(s[i]==s[k]?s[i]:'*');
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3600
from collections import Counter
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

MOD = 998244353

c = Counter(D)
if c[0] != 1:
    print(0)
    exit()

key = list(c.keys())
key.sort()

ans = 1
for k in key:
    if k >= 1:
        if k-1 not in c:
            print(0)
            exit()
        else:
            ans *= c[k-1] ** c[k]
            ans %= MOD

print(ans)

Measured memory_bytes: 19936
s = [int(input()) for i in range(5)]
k = int(input())
count = 0

for i in s:
    for j in s:
        if (i-j)**2 > k**2:
            print(":(")
            count+=1
            break
    if count == 1:
        break

if count == 0:
    print("Yay!")

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int a[1100][1100];
void solve(int n) {
	if(n==1) return (void)(a[1][1]=1);
	solve(n-1);
	for(int i=1;i<(1<<n-1);++i)
	for(int j=1;j<(1<<n-1);++j)
		a[i+(1<<n-1)][j]=a[i][j+(1<<n-1)]=a[i+(1<<n-1)][j+(1<<n-1)]=a[i][j];
	a[(1<<n-1)][(1<<n-1)]=1;
}
int main() {
	int n,m; rd(n),rd(m);
	solve(max(n,m));
	for(int i=1;i<(1<<n);++i,puts(""))
	for(int j=1;j<(1<<m);++j)
		putchar('0'+a[i][j]);
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
  }
  else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int M = sc.nextInt();

		int min = Integer.MIN_VALUE;
		int max = Integer.MAX_VALUE;

		for (int i = 0; i < M; i++) {
			min = Math.max(min, sc.nextInt());
			max = Math.min(max, sc.nextInt());
		}

		System.out.println(min <= max ? max - min + 1 : 0);

	}
}

Measured memory_bytes: 64692
#include<iostream>

using namespace std;

int balls[15];

bool dfs(int ball_index, int right, int left) {
    if (ball_index == 10) return true;

    int last_ball = balls[ball_index];
    if (last_ball > right) return dfs(ball_index+1, last_ball, left);
    if (last_ball > left)  return dfs(ball_index+1, right, last_ball);

    return false;
}

void solve() {
    for (int i = 0; i < 10; i++) {
        cin >> balls[i];
    }

    if (dfs(0, 0, 0)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main(int argc, char const* argv[]) {

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1152
n = int(input())
lt = lx = ly = 0
for i in range(n):
    t, x, y = map(int, input().split())
    tt = t - lt
    txy = abs(x - lx) + abs(y - ly)
    if txy > tt or tt % 2 != txy % 2:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;
template<typename T>
T gcd(T a, T b){
    return b ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    

ll f(ll x, ll c, ll d ){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}
int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;
    return 0;
}


    
    

   


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N , X;
    int L[200];

    cin >> N >> X;

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

    int dist[200];
    dist[0] = 0;
    int count = 1;
    for(int j = 1; j <= N; j++){
        dist[j] = dist[j-1] + L[j-1];   

        if(dist[j] <= X){
            count++;
        }
    }

    cout << count << endl;
    
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math

def main(N):
    A = []
    for i in range(1, int(math.sqrt(N))+1):
        if(N%i==0):
            A.append(i)
    ans = float("INF")
    for i in range(len(A)):
        ans = min(ans, F(A[i], int(N/A[i])))
    print(ans)
    
def F(A, B):
    if len(str(A))>=len(str(B)):
        return len(str(A))
    else:
        return len(str(B))

if __name__ == '__main__':
    N = int(input())
    
    main(N)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    int x,y;
    cin>>x>>y;
    if (y%2!=0) return cout<<"No",0;
    y-=x*2;
    if (y<0 || y>x*2) return cout<<"No",0;
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(string, s);
    int k = 0;
    REP(i, s.size()){
        if(k && s[i] == 'F'){
            Yes; RET;
        }else if(s[i] == 'C'){
            k=1;
        }
    }
    No;
RET;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int a, b; cin >> a >> b;
	int m = max(a, b);
	int n = min(a, b);
	ll ans = 0;

	for (int i = 1; i <= m; i++) {
		ans += n * pow(10, i-1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int h,w;
const int MX = 2000 + 5;
bool blocked[MX][MX];
int value[MX][MX];

int main(){
	cin >> h >> w;
	FOR(i,1,h){
		string s; cin >> s;
		FOR(j,1,w+1){
			if(j==w+1) blocked[i][j] = true;
			else if(s[j-1] == '#'){
				blocked[i][j] = true;
			}
		}
	}
	FOR(j,1,w) blocked[h+1][j] = true;

	FOR(i,1,h){
		bool* b_now = blocked[i];
		int* v_now = value[i];
		int r = 1, l = 1;
		while(r<=w+1){
			if(b_now[r] == true){
				int cnt = r-l;
				FOR(j,l,r-1) v_now[j] += cnt;
				r += 1; l = r;
			}else{
				r += 1;
			}
		}
	}
	FOR(i,1,w){
		int u = 1, d = 1;
		while(d<=h+1){
			if(blocked[d][i]==true){
				int cnt = d - u;
				FOR(j,u,d-1) value[j][i] += cnt-1;
				d += 1; u = d;
			}else{
				d += 1;
			}
		}
	}

	int ans = 0;
	FOR(i,1,h){
		ans = max(*max_element(value[i], value[i]+w+1), ans);
	}

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


Measured memory_bytes: 19840
S,T = input(),input()

d = [None]*26
flag = True
for s,t in zip(S,T):
    s = ord(s)-ord('a')
    t = ord(t)-ord('a')
    if d[s] is None:
        d[s] = t
    elif d[s] != t:
        flag = False
        break

if not flag:
    print('No')
elif len(set(v for v in d if v is not None)) != sum(int(v is not None) for v in d):
    print('No')
else:
    print('Yes')

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

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

    int A;
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        if (A % 2 == 0) {
            if (!(A % 3 == 0 || A % 5 == 0)) { 
                std::cout << "DENIED\n";
                return 0;
            }
        }
    }

    std::cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
def bsearch(a, n)
  min = 0
  max = a.size - 1
  while true
    mid = (max + min) / 2

    if a[mid] < n
      break if mid + 1 == min
      min = mid + 1
    elsif a[mid] > n
      break if mid - 1 == max
      max = mid - 1
    else
      return true
    end
  end
  false
end

N = gets.chomp.to_i
S = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
T = gets.chomp.split.map(&:to_i)

ans = 0
T.each do |ti|
  ans += 1 if bsearch(S, ti)
end
puts ans


Measured memory_bytes: 15632
#include<iostream>
#include<string>
typedef unsigned int u;using namespace std;typedef string::iterator s;u z=100000000;void p(u*a,u*l,u n){if(a-l)p(a+1,l,(n+=*a*10)/z),*a=n%z;}u t(u*a,u*l){u r=0;char b[11]={};if(a-l)if(!t(a+1,l)){if(*a)cout<<*a,r=1;}else sprintf(b,"%d",*a+z),cout<<b+1,r=1;return r;}void d(u*a,u*l,u*b,u n=0){if(a-l)d(a+1,l,b+1,(n+=(*a+*b))/z),*a=n%z;}int main(){u n;(cin>>n).ignore();string a,b;for(;n--;){getline(cin,a);getline(cin,b);u x[11]={},y[11]={},c=0;for(s i=a.begin();i!=a.end();p(x,x+10,*i++-48))if(++c>80)goto g;c=0;for(s i=b.begin();i!=b.end();p(y,y+10,*i++-48))if(++c>80)goto g;d(x,x+11,y);if(x[10])goto g;else if(!t(x,x+10))cout<<'0';if(0)g:cout<<"overflow";cout<<'\n';}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> al = new ArrayList<>();

		String in;
		String[] data;
		double tmp;
		while(sc.hasNext()) {
			in = sc.next();
			data = in.split(",");
			tmp = Double.parseDouble(data[1]) / Math.pow(Double.parseDouble(data[2]), 2);
			
			if(tmp >= 25)	al.add(data[0]);
		}
		
		for(String i : al)	System.out.println(i);
	}
}

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

int main(){
  int n;
  string str = "No";
  cin >> n;
  for(int i=1;i<10;i++){
    int temp = n;
    int ans1 = temp % i;
    int ans2 = temp / i;
    if(ans1 == 0 && ans2 < 10)str = "Yes";
  }
  cout << str << endl;
  return 0;
}

Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int solve(int n)
{
	for(int x=1;x<=2*n;++x)
	{
		int s=x*108/100;
		if(s==n)
			return x;
	}
	return 0;
}
int main()
{
	int n=read();
	int x=solve(n);
	if(!x)
		puts(":(");
	else
		cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    int count=0;
    int mx=0;
    for(int i=0;i<3;i++){
        if(str[i]=='R'){
            count++;
            mx=max(count,mx);
        }
        else{
            count=0;
        }
    }
    cout<<mx;
    return 0;
}

Measured memory_bytes: 3648
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0.0
	for i := 0; i < n; i++ {
		var (
			x float64
			u string
		)
		fmt.Scan(&x, &u)
		if u == "BTC" {
			x *= 380000.0
		}
		ans += x
	}
	fmt.Println(ans)
}


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

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>vec(h,vector<char>(w));
    vector<vector<bool>>out(h,vector<bool>(w,true));
    bool bou;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>vec[i][j];
        }
    }
    for(int i=0;i<h;i++){
        bou=true;
        for(int j=0;j<w;j++){
            if(vec[i][j]!='.'){
                bou=false;
                break;
            }
        }
        if(bou){
            for(int j=0;j<w;j++){
                out[i][j]=false;
            }
        }
    }
     for(int i=0;i<w;i++){
        bou=true;
        for(int j=0;j<h;j++){
            if(vec[j][i]!='.'){
                bou=false;
                break;
            }
        }
        if(bou){
            for(int j=0;j<h;j++){
                out[j][i]=false;
            }
        }
    }
    for(int i=0;i<h;i++){
    	bou=false;
        for(int j=0;j<w;j++){
            if(out[i][j]){
                cout<<vec[i][j];
                bou=true;
            }
        }
        if(bou){
        	cout<<endl;
        }
    }
}


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


bool is_MM(string MM) {
	//MMのチェック
	int mm = atoi(MM.c_str());
	//cout << mm << endl;
	if (mm >= 1 && mm <= 12) { //1～12ならOK
		return true;
	}

	return false;
}

// ABC126B - YYMM or MMYY
// https://atcoder.jp/contests/abc126/tasks/abc126_b
void ABC126B() {

	string S;
	cin >> S;

	string S1 = S.substr(0,2); //substr(開始位置, 取得文字数)
	string S2 = S.substr(2,2);

	bool is_YYMM = is_MM(S2); //後半部分がMMかどうかチェック(YY部分は何でもOK)
	bool is_MMYY = is_MM(S1); //前半部分がMMかどうかチェック(YY部分は何でもOK)

	if (is_YYMM && is_MMYY) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (is_YYMM) {
		cout << "YYMM" << endl;
	}
	else if (is_MMYY) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

int main() {
	ABC126B();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
int P[20];

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

	int ans=0;
	for(int i=1; i<N-1; i++){
		if((P[i-1]<P[i]&&P[i]<P[i+1])||(P[i+1]<P[i]&&P[i]<P[i-1])){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

	int A, B; cin >> A >> B;
	A--; B--;
	cout << (B+A-1)/A << endl;

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int x, a, b; cin >> x >> a >> b;
	if(abs(x-a)<abs(x-b)) cout << 'A' << endl;
	else cout << 'B' << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
// #include <priority_queue>
#include <algorithm>
#include <climits>

using namespace std;

int n, T, c, t;

int main() {

	cin >> n >> T;

	int ans = INT_MAX;
	for (int i = 0; i < n; ++i)
	{
		cin >> c >> t;
		if (t <= T && c < ans)
			ans = c;
	}

	if (ans == INT_MAX)
		cout << "TLE" << endl;
	else
		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  if(k==0){ cout << n*n << endl; return 0; }
  
  for(int b=k+1; b<=n; b++){
    ans += ((n-b+1)/b+1)*(b-k);
    if(n%b>=k && n%b!=b-1){ ans += n%b-(k-1); }
  }

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


Measured memory_bytes: 256
program atcoder
   implicit none
   integer A, B, C, D, X, Y
   read *, A, B, C, D
   
   X=int((A+D-1)/D)
   Y=int((C+B-1)/B)
   if (X >= Y) then
     print *,'Yes'
    else
     print *,'No'
    end if
end program atcoder

Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size();++i) if(s[i]=='1') ++cnt;
    cout<<cnt;
    return 0;
  }

Measured memory_bytes: 3616
use std::io;


/// https://beta.atcoder.jp/contests/abc082/tasks/abc082_b
fn main() {
    let mut s = read_one::<String>().chars().collect::<Vec<char>>();
    let mut t = read_one::<String>().chars().collect::<Vec<char>>();
    s.sort();
    t.sort();
    t.reverse();
    if s < t { println!("Yes"); }
    else { println!("No"); }
}


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

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

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

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

Measured memory_bytes: 4352
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
# include <unordered_map>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
unordered_map<string, int> m;
struct p
{
	string s;
	int n;
	int x, y;
	int z()
	{
		return x + y * 4;
	}
	int z(int X, int Y)
	{
		return X + Y * 4;
	}
};
int main()
{
	p f;
	f.s = "01234567";
	f.n = f.x = f.y = 0;
	queue<p> que;
	que.push(f);

	while (!que.empty())
	{
		p now = que.front(); que.pop();
		if (m.count(now.s))continue;
		m[now.s] = now.n;
		now.n++;
		if (now.x <= 2)
		{
			swap(now.s[now.z()], now.s[now.z()+1]);
			now.x++;
			que.push(now);
			now.x--;
			swap(now.s[now.z()], now.s[now.z() + 1]);
			
		}
		if (now.x >= 1)
		{
			swap(now.s[now.z()], now.s[now.z() - 1]);
			now.x--;
			que.push(now);
			now.x++;
			swap(now.s[now.z()], now.s[now.z() - 1]);
			
		}
		swap(now.s[now.z()], now.s[now.z(now.x,(now.y+1)%2)]);
		now.y++;
		now.y %= 2;
		que.push(now);
		swap(now.s[now.z()], now.s[now.z(now.x, (now.y + 1) % 2)]);
		now.y++;
		now.y %= 2;
	}

	string s;
	while (getline(cin, s))
	{
		stringstream ss(s);
		string ans;
		while (ss >> s)ans += s;
		cout << m[ans] << endl;
	}
}

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

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

    int c = 0;
    char src;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] >= 'a') {
            src = s[i];
            replace(s.begin(), s.end(), src, (char)('A' + c));
            c++;
        }
    }

    c = 0;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] >= 'a') {
            src = t[i];
            replace(t.begin(), t.end(), src, (char)('A' + c));
            c++;
        }
    }

    if (s != t) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 776
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

int main(){
    long long r, D, x;
    cin >> r >> D >> x;

    for(int i = 0; i < 10; ++i){
        x = r * x - D;
        cout << x << endl;
    }
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


N = int(input())
T = [int(input()) for _ in range(N)]

if N == 1:
    print(T[0])

else:
    LCM = lcm(T[0], T[1])
    
    for i in range(1, N-1):
        LCM = lcm(LCM, T[i+1])
    
    print(LCM)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

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

   vector<vector<int>> G(N);
   map<pair<int, int>, ll> cost;
   vector<ll> visited(N, -1LL);

   rep(i, 0, N - 1) {
     int a, b;
     ll c;
     cin >> a >> b >> c;
     a--; b--;
     cost[{a, b}] = c; cost[{b, a}] = c;
     G.at(a).emplace_back(b); G.at(b).emplace_back(a);
   }

   int Q, K;
   cin >> Q >> K;

   K--;
   queue<int> que;
   visited.at(K) = 0;
   que.push(K);

   while (!que.empty()) {
     int v = que.front();
     que.pop();
     for (int nv : G.at(v)) {
       if (visited.at(nv) != -1) continue;
       else {
         que.push(nv);
         visited.at(nv) = visited.at(v) + cost.at({v, nv});
       }
     }
   }

   vector<ll> ans(Q);
   rep(i, 0, Q) {
     int x, y;
     cin >> x >> y;
     ans.at(i) = visited.at(x - 1) + visited.at(y - 1);
   }

   rep(i, 0, Q) cout << ans.at(i) << endl;
 }


Measured memory_bytes: 21624
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int64_t H, W, h, w; cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			int K = sc.nextInt();
			if (N == 0) break;
			int[] v = new int[N];
			for (int i = 0; i < N; ++i) {
				v[i] = sc.nextInt();
			}
			int sum = 0;
			for (int i = 0; i < K; ++i) {
				sum += v[i];
			}
			int ans = sum;
			for (int i = K; i < N; ++i) {
				sum += v[i] - v[i - K];
				ans = Math.max(ans, sum);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
package main

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

func solve() {
	n := getInt()
	x := float64(n) * 100 / 108
	a, b := int(math.Ceil(x)), int(math.Trunc(x))

	ans := ":("
	if a*108/100 == n {
		ans = strconv.Itoa(a)
	} else if b*108/100 == n {
		ans = strconv.Itoa(b)
	}
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getFloat() float64 {
	f, err := strconv.ParseFloat(getString(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    cin>>x;
    long long counter=0;
    long long e=100;
    while(e<x){
    counter++;
    e=e*(1.01);
    }
    cout<<counter<<endl;
    
  return 0;
    }


Measured memory_bytes: 3596
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#define INF (1<<30)
#define EPS (double)(1e-5)
using namespace std;
int n,hx,hy,dx,dy;
int cx[22],cy[22];

double L(int x,int y){
  return sqrt(x*x+y*y);
}

bool solve(int m,int bit,double l){
  if(bit == (1<<n)-1) return true;
  for(int i = 1; i < n; i++){
    if(bit&(1<<i))continue;
    if( L(cx[m]-cx[i],cy[m]-cy[i]) + l + EPS > L(cx[i]-dx,cy[i]-dy)) return false;
  }
  for(int i = 1; i < n; i++){
    if(bit&(1<<i))continue;
    if(solve(i,bit|(1<<i),l+L(cx[m]-cx[i],cy[m]-cy[i]))) return true;
  }
  return false;
}

int main(void){
  while(cin >> n >> cx[0] >> cy[0] >> dx >> dy && n){
    n++;
    for(int i = 1; i < n; i++){
      cin >> cx[i] >> cy[i];
    }
    if( solve(0,1,0) ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
wa = [0, 0, 1]
for i in range(2, 100005):
    wa.append(wa[-1]+i)

# print(wa)
# exit()

N = int(input())

# data = set()
data = {}

ans = 0
for i in range(N):
    s_list = list(str(input()))
    s_list = sorted(s_list)
    hoge = "".join(s_list)
    data.setdefault(hoge, 0)
    data[hoge] += 1

for v in data.values():
    ans += wa[v]

print(ans)


Measured memory_bytes: 22336
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

def D(x,y,p):
    s = 0
    for i in range(n):
        s += abs(x[i]-y[i])**p
    return s**(1/p)
mugen = []
for k in range(n):
    mugen.append(abs(x[k]-y[k]))

l = [1,2,3]
a = []
for j in l :
    a.append(D(x,y,j))
a.append(max(mugen))
print(*a)



Measured memory_bytes: 5640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][] c = new char[3][3];
        for (int i=0; i<3; i++) {
            c[i] = sc.next().toCharArray();
        }

        System.out.println(solve(c));
    }

    private static String solve(char[][] c) {
        return String.valueOf(c[0][0]) + String.valueOf(c[1][1]) + String.valueOf(c[2][2]);
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{

    static void Main(string[] args)
    {
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Any(i=>i%2==0)?"Even":"Odd");
    }
}

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

typedef struct {
	int a;
	int b;
}pair_t;

int min(int a, int b) {
	if (a >= b) return b;
	else return a;
}
int main() {
	int h, n;
	pair_t pair[100000] = { 0 };
	int dp[100001] = { 0 };

	scanf("%d %d", &h, &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &pair[i].a, &pair[i].b);

	for (int i = 1; i <= h; i++) {
		dp[i] = INT_MAX;
		for (int j = 0; j < n; j++) {
			if (i - pair[j].a <= 0) {
				dp[i] = min(dp[i], pair[j].b);
			}
			else {
				dp[i] = min(dp[i], dp[i - pair[j].a] + pair[j].b);
			}
		}
	}
	printf("%d", dp[h]);
	return 0;
}


Measured memory_bytes: 1280
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
for i in range(n):
    for j in range(a[i]):
        b.append(i+1)
for i in range(h):
    c.append(b[w*i:w*(i+1)])
for i in range(h):
    if i%2==0:
        print(*c[i])
    else:
        print(*c[i][::-1])

Measured memory_bytes: 3956
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var s1, s2, s3 string
    Scanf("%s", &s1)
    Scanf("%s", &s2)
    Scanf("%s", &s3)

    Print(string(s1[0]), string(s2[1]), string(s3[2]))
}



Measured memory_bytes: 512
# coding: utf-8
K, N = map(int, input().split())
A = list(map(int, input().split()))
# print(K, N)
# print("A:", A)
A = A + [K + A[0]]
# print("A:", A)

lst = [A[i + 1] - A[i] for i in range(N)]
# print(lst)
print(K - max(lst))


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

using namespace std;



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

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

    if (b >= c) {
        if (b > d) {
            if (a >= d) {
                cout << 0;
            }
            else if (a <= c) {
                cout << d - c;
            }
            else {
                cout << d - a;
            }
        }

        else {
            if (a <= c) {
                cout << b - c;
            }
            else {
                cout << b - a;
            }
        }
    }
    else {
        cout << 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
	int h, w;
	cin >> h >> w;
	char s[55][55];
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> s[i][j];
		}
	}

	bool flag=true;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(s[i][j]=='#'){
				if(s[i-1][j]=='#' || s[i+1][j]=='#' || s[i][j-1]=='#' || s[i][j+1]=='#'){
				}else{
					cout << "No"<< endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 100007
int n;
int a[MAX];

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

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int N;
string s;
long mod=998244353;
long sum[2<<17];
long dp[2][2<<17];
main()
{
	cin>>N>>s;
	dp[0][0]=1;
	for(int i=0;i<=N;i++)
	{
		if(i!=0)
		{
			if(N%i==0&&N/i%2==1)
			{
				sum[i]=dp[1][i];
				bool flag=true;
				for(int k=0;k<N;k++)
				{
					int L=s[k]-'0';
					int R=s[k%i]-'0'^(k/i%2==1);
					if(L!=R)
					{
						if(L<R)flag=false;
						break;
					}
				}
				if(flag)(sum[i]+=dp[0][i])%=mod;
			}
		}
		if(i==N)break;
		for(int j=0;j<2;j++)
		{
			int lim=j?1:s[i]-'0';
			for(int k=0;k<=lim;k++)
			{
				(dp[j||k<lim][i+1]+=dp[j][i])%=mod;
			}
		}
	}
	long ans=0;
	for(int i=1;i<=N;i++)
	{
		if(sum[i]==0)continue;
		for(int j=i*2;j<=N;j+=i)
		{
			if(N%j==0&&N/j%2==1)(sum[j]+=mod-sum[i])%=mod;
		}
		(ans+=sum[i]*i*2)%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6276
#include "bits/stdc++.h"
using namespace std;

int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    int d,n;
    cin >> d >> n;
    if(n == 100) n = 101;
    int ans = pow(100,d) * n;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

//#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; prll(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); } } premain;


int main() {
	ll X, Y;
	cin >> X >> Y;

	if (abs(X - Y) <= 1) {
		print("Brown");
	} else {
		print("Alice");
	}

	return 0;
}


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

int main() {
	int n; cin >> n;
    vector<vector<int>> v(n, vector<int>(3));
    for(int i = 0; i < n; i++) for(int a = 0; a < 3; a++){
        cin >> v[i][a];
    }
    vector<vector<int>> dp(n, vector<int>(3,0));
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];    
    for(int i = 0; i < n-1; i++) for(int a = 0; a < 3; a++){
        dp[i+1][a] = max(dp[i][(a+1)%3], dp[i][(a+2)%3]) + v[i+1][a];
    }
    int res = 0;
    for(int a =0; a < 3; a++) res = max(dp[n-1][a], res);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 13992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

int main(){
    ll A,B,N;
    cin>>N>>A>>B;
    ll s=N/(A+B);
    ll d=N%(A+B);
    cout<<s*A+min(d,A)<<endl;
}


Measured memory_bytes: 256
#include<iostream> 
 
 
using namespace std;
bool check[1000001];
 
int main()
{
	int n, m, k;
	cin >> n >> m >> k;
 
	for (int i = 0; i <= n; i++)
	{
		for (int h = 0; h <= m; h++)
		{
			check[h*n - 2*i*h + i *m] = 1;
 
 
		}
	}
 
	if (check[k])
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return  0;
}

Measured memory_bytes: 1280
from itertools import permutations
 
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
 
i = 0
a = 0
b = 0
for s in permutations(range(1, n+1)):
    for j in range(n):
        if p[j] != s[j]:
            break
    else:
        a = i
    for j in range(n):
        if q[j] != s[j]:
            break
    else:
        b = i
    i += 1
 
print(abs(a-b))

Measured memory_bytes: 3064
import collections

n = int(input())
p = list(map(int,input().split()))
cnt = collections.Counter(p)

maxs = []
for k, v in cnt.items():
  if v > 1:
    maxs.append(k)
    
if len(maxs) > 1:
  maxs.sort()
  if cnt[maxs[-1]] > 3:
    print(maxs[-1] ** 2)
  else:
    print(maxs[-1] * maxs[-2])

else:
  print(0)

Measured memory_bytes: 18600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        System.out.print(s.charAt(0));
        System.out.print(s.length()-2);
        System.out.println(s.charAt(s.length()-1));
    }

}

Measured memory_bytes: 23764
a,b,c,k = map(int,input().split())
x = list(map(int,input().split()))
x.sort(reverse=True)
y = list(map(int,input().split()))
y.sort(reverse=True)
z = list(map(int,input().split()))
z.sort(reverse=True)
xy = []
for xx in x:
  for yy in y:
    xy.append(xx+yy)
xy.sort(reverse=True)
xy = xy[:k]
xyz = []
for yx in xy:
  for zz in z:
    xyz.append(yx+zz)
xyz.sort(reverse=True)
for i in range(k):
  print(xyz[i])

Measured memory_bytes: 148460
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, A, B; 
long long int X[114514] = {}; 
cin >> N >> A >> B; 
for (int i = 0; i < N; i++) {
  cin >> X[i]; 
  }
long long int ans = 0; 
for (int i = 0; i < N-1; i++) {
  ans += min(B, A * (X[i+1] - X[i])); 
  }
cout << ans << endl; 
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int N, T[110], M, P[110], X[110], time;

  cin >> N;
  for(int i = 0; i < N; i++) cin >> T[i];
  cin >> M;
  for(int i = 0; i < M; i++){
    cin >> P[i] >> X[i];
  }

  for(int i = 0; i < M; i++){
    time = 0;
    for(int j = 0; j < N; j++){
        if(j == P[i]-1) time += X[i];
        else time += T[j];
    }
    cout << time << endl;

  }


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
int sum,cnt,n;
bool vis[1050];
int main(){
	sum=1;
	cnt=0;
	vis[1]=1;
	for(int i=2;i<=1000;i++){
		sum=i;
		for(int j=2;;j++){
			sum=sum*i;
			if(sum>1000) break;
			else vis[sum]=1;
		}
	}
	scanf("%d",&n);
	for(int i=n;i>=1;i--){
		if(vis[i]==1){
			printf("%d\n",i);
			return 0;
		}
	}
}

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

ll H, W, N, ans[11];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main()
{
    scanf("%d%d%d", &H, &W, &N);
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        scanf("%d%d", &y, &x);
        br.insert({--y, --x}), st.insert({y, x});
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H || nx < 1 || nx > W)
                continue;
            st.insert({ny, nx});
        }
    }
    for (auto &p : st)
    {
        int y = p.first, x = p.second, cnt = 0;
        cnt += (br.find(p) != br.end());
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            cnt += (br.find({ny, nx}) != br.end());
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        printf("%lld\n", ans[i]);
}

Measured memory_bytes: 49152
#include<stdio.h>

int fact[] = {1,1,2,6,24,120,720,5040,40320};
int N;
int flag[]= {1,1,1,1,1,1,1,1,1};
int getcount(int x)
{
	int count=0;
	flag[x] = 0;
	for(int i=1;i<x;i++)
		count+=flag[i];
	return count;
}
int getrank(int P[])
{
	int j,rank=1;
	j=1;
	while(j<N)
	{
		rank += getcount(P[j])*fact[N-j];
		j++;
	} 
	return rank;
}
int abs(int x)
{
	if (x<0)
		return x*-1;
	else
		return x;
}

int main()
{
	scanf("%d",&N);
	int P[N+1];
	int Q[N+1];
	int i,rankp,rankq;
	for(i=1;i<=N;i++)
		scanf("%d",&P[i]);
	for(i=1;i<=N;i++)
		scanf("%d",&Q[i]);
	rankp = getrank(P);
	for(i=1;i<=N;i++)
		flag[i] = 1;
	rankq = getrank(Q);
	printf("%d",abs(rankp-rankq));


	
}

Measured memory_bytes: 128