akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*******************??????********************/
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {//??????
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {//??????
	return real(conj(a)*b);
}

struct L : public vector<P> {//??????
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;
struct C {//???
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {//??????????????????
	b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L& l,const L& m){
	//non-parallel || sameline
	return abs(cross(l[1]-l[0],m[1]-m[0])) > EPS || abs(cross(l[1]-l[0],m[0]-l[0])) < EPS;
}
bool intersectLS(const L& l,const L& s){
	// s[0] is left of l,s[1] is right of l
	return cross(l[1]-l[0],s[0]-l[0]) * cross(l[1]-l[0],s[1]-l[0]) < EPS;
}
bool intersectSS(const L &s, const L &t) {
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
		ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectLP(const L& l,const P& p){
	return abs(cross(l[1]-p,l[0]-p)) < EPS;
}
bool intersectSP(const L& s,const P& p){
	return abs(s[0]-p)+abs(s[1]-p) - abs(s[1]-s[0]) < EPS;// triangle inequality
}
// ??´???????????????
bool orthogonalLL(const L &l1, const L &l2){
	return (dot(l1[0]-l1[1], l2[0]-l2[1]) <= EPS && dot(l1[0]-l1[1], l2[0]-l2[1]) >= -EPS);
}
// ??????????????????
bool parallelLL(const L &l1, const L &l2){
	return (cross(l1[0]-l1[1], l2[0]-l2[1]) <= EPS && cross(l1[0]-l1[1], l2[0]-l2[1]) >= -EPS);
}

P projection(const L& l,const P& p){
	double t = dot(p-l[0],l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
P reflection(const L& l,const P& p){
	return p + 2. * (projection(l,p) - p);
}
double distanceLP(const L& l,const P& p){
	return abs(p - projection(l,p));
}
double distanceLL(const L& l,const L& m){
	return intersectLL(l,m) ? 0 : distanceLP(l,m[0]);
}
double distanceLS(const L& l,const L& s){
	if(intersectLS(l,s)) return 0;
	return min(distanceLP(l, s[0]),distanceLP(l, s[1]));
}

int main(void){
	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		vector<P> p(4);
		int x,y;
		for(int j=0;j<4;j++){
			cin >> x >> y;
			p[j] = P(x,y);
		}
		L l0(p[0],p[1]),l1(p[2],p[3]);
		if(intersectSS(l0,l1))cout << 1 << endl;
		else cout << 0 << endl;

	}

	return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,M,R;
int r[10];
int a,b,c;
struct edge{int from,to,cost;};
int dist[200][200];
int main(){
    cin >> N >> M >> R;
    //init()
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            dist[i][j] = MM;
        }
    }
    for(int i = 0; i < R; i++){
        cin >> r[i];
        r[i]--;
    }
    sort(r,r+R);
    for(int i = 0; i < M; i++){
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }
    for(int id = 0; id < N; id++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                dist[i][j] = min(dist[i][j],dist[i][id]+ dist[id][j]);
            }
        }
    }
    int ans = MM;
    sort(r,r+R);
    do {
        int sum = 0;
        for(int i = 1; i < R; i++){
            sum += dist[r[i-1]][r[i]];
        }
        ans = min(sum,ans);
    } while(next_permutation(r,r+R));
    cout << ans << endl;
}



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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

    bool dp[k + 1];

    rep(i, k + 1) dp[i] = 0;

    for (int i = 1; i <= k; i++)
    {
        rep(j, n)
        {
            if (i - a[j] >= 0)
                dp[i] |= !dp[i - a[j]];
        }
    }

    if (dp[k])
        OP("First");
    else
        OP("Second");

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(){
  long int c,s,count=0;
  scanf("%ld %ld",&s,&c);
  if(s>c/2){
    printf("%ld",c/2);
  }else{
    count=s;
    c=c-2*s;
    while(c>=4){
      count++;
      c=c-4;
    }
    printf("%ld",count);
  }   
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#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 INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 繰り返し二乗法 (xのy乗) */
ll binpow(ll x, ll y)
{
	ll res = 1LL;
	x %= MOD;
	while (y) {
		if (y & 1) res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

int main()
{
	ll N, K;
	cin >> N >> K;

	vector<ll> powRes(K + 1, 0);
	REPN(i, 1, K + 1) {
		powRes[i] = binpow(K / i, N);
	}

	vector<ll> cmbNum(K + 1, 0);
	for (ll i = K; i >= 1; i--) {
		ll jufukuNum = 0;
		for (ll j = i * 2; j <= K; j += i) {
			jufukuNum += cmbNum[j];
			jufukuNum %= MOD;
		}
		ll cmbOne = powRes[i] - jufukuNum + 2 * MOD;
		cmbNum[i] = cmbOne % MOD;
	}

	ll ans = 0;
	REPN(i, 1, K + 1) {
		ans += cmbNum[i] * i;
		ans %= MOD;
	}

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


Measured memory_bytes: 4736
n = int(input())
w = [int(i) for i in input().split(" ")]

s1 = w[0]
s2 = sum(w) - s1
mi = abs(s1 - s2)

for t in range(1, n - 1):
    s1 += w[t]
    s2 -= w[t]
    if abs(s1 - s2) < mi:
        mi = abs(s1 - s2)

print(mi)

Measured memory_bytes: 3060
import math
N = int(input())
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


class SegmentTree():
    def m(self, v1, v2):  # ***monoid***
        return gcd(v1, v2)

    def __init__(self, array):
        m = self.m
        e = self.e = 0  # ***identity element***
        size = self.size = 10**5  # ***limit for array size***
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


ST = SegmentTree(A)
ans = 0
for i, a in enumerate(A):
    ST.modify(i, ST.e)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


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

int main(){
  int n, d;
  cin >> n >> d;
  ll cnt=0;
  rep(i,n){
    double x, y;
    cin >> x >> y;
    double val= pow(x*x+y*y,0.5);
    if(val <= d) cnt+=1;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4480
N, K = [int(n) for n in input().split()]
#dice = [int(n) for n in input().split()]
evs = [(1 + int(n))/2 for n in input().split()]
cumsum = [0]

for i in range(1,N+1):
    cumsum.append(cumsum[i-1] + evs[i-1])

k_cum = [cumsum[i+K] - cumsum[i] for i in range(N-K+1)]

print(max(k_cum))

Measured memory_bytes: 23588
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	int n, a, b;
	string s;
	cin >>n>>a>>b>> s;
	int all = a + b;
	vector<bool> stu(n);
	for (int i = 0; i < n; ++i){
		if (s[i] == 'a'){
			if (all){
				--all;
				stu[i] = true;
			}
			else{
				stu[i] = false;
			}
		}
		else if (s[i] == 'b'){
			if (all && b){
				--all; --b;
				stu[i] = true;
			}
			else{
				stu[i] = false;
			}
		}
		else{
			stu[i] = false;
		}
	}
	for (int i = 0; i < n; ++i){
		if (stu[i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
int N,K,C;
char*S;
int R[2<<17];
char buf[2<<17],out[3<<19];sz;outsz;
main()
{
	read(0,buf,2<<17);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		K=K*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		C=C*10+k-'0';
	}
	S=buf+sz;
	int now=K;
	for(int i=N;i-->0;)
	{
		if(S[i]=='o')
		{
			R[i]=now--;
			i-=C;
		}
	}
	now=0;
	for(int i=0;i<N;i++)
	{
		if(S[i]=='o')
		{
			if(R[i]==++now)
			{
				int t=i+1;
				if(t<10)out[outsz++]=t+'0';
				else if(t<100)
				{
					out[outsz++]=t/10+'0';
					out[outsz++]=t%10+'0';
				}
				else if(t<1000)
				{
					out[outsz++]=t/100+'0';
					out[outsz++]=t/10%10+'0';
					out[outsz++]=t%10+'0';
				}
				else if(t<10000)
				{
					out[outsz++]=t/1000+'0';
					out[outsz++]=t/100%10+'0';
					out[outsz++]=t/10%10+'0';
					out[outsz++]=t%10+'0';
				}
				else if(t<100000)
				{
					out[outsz++]=t/10000+'0';
					out[outsz++]=t/1000%10+'0';
					out[outsz++]=t/100%10+'0';
					out[outsz++]=t/10%10+'0';
					out[outsz++]=t%10+'0';
				}
				else
				{
					out[outsz++]=t/100000+'0';
					out[outsz++]=t/10000%10+'0';
					out[outsz++]=t/1000%10+'0';
					out[outsz++]=t/100%10+'0';
					out[outsz++]=t/10%10+'0';
					out[outsz++]=t%10+'0';
				}
				out[outsz++]='\n';
			}
			i+=C;
		}
	}
	write(1,out,outsz);
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define GI int
#define UL unsigned int
#define ULL unsigned long long int
#define LI long int
#define LL long long
#define LF double
#define LLF long double
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define rFOR(a,b,c) for(a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define IOF ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	IOF
    LL a,b,c,d,x,y,ans;
    cin>>a>>b>>c>>d;
    ans=b*d;
    ans=max(ans,a*c);
    ans=max(ans,b*c);
    ans=max(ans,a*d);
    if((ans<0)&&(a*b<0||c*d<0))cout<<0<<endl;
    else cout<<ans<<endl;


return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a, b;

    cin >> a >> b;

    ll ans = 0;

    while (ans <= 10000)
    {
      if (ll(ans*0.08) == a && ll(ans*0.1) == b){
        cout << ans << endl;
        return 0;
      }
      ans++;
    }
    
  	cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#if 0
はじめ、cを0~N-1で解いていたが、途中で0~Nで解くべきことに気が付いた。
また、c-C[i]>=0の時の、最小値の比較対象をc-C[j] (j <= i)の時も考えていたため解けなかったが、日を置いたら誤りに気が付いて解くことができた。
#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, M;
int C[25];
int cnt[25][50010];

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> C[i];
  sort(C, C+M);
  for (int i = 0; i < M; i++) {
    for (int c = 0; c <= N; c++) {
      if (i == 0)
        cnt[i][c] = c;
      else if (c == 0)
        cnt[i][c] = 0;
      else if (c-C[i] < 0)
        cnt[i][c] = cnt[i-1][c];
      else {
        cnt[i][c] = min(1 + cnt[i][c-C[i]], cnt[i-1][c]);
      }
    }
  }
  cout << cnt[M-1][N] << endl;
}



Measured memory_bytes: 7068
// Problem : A - Can't Wait for Holiday
// Contest : AtCoder Beginner Contest 146
// URL : https://atcoder.jp/contests/abc146/tasks/abc146_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  cout.precision(16);
  cout << fixed;
  
  map<string, int> a = {
    {"SUN", 1},
    {"MON", 2},
    {"TUE", 3},
    {"WED", 4},
    {"THU", 5},
    {"FRI", 6},
    {"SAT", 7}
  };
  
  string s;
  cin >> s;
  
  cout << 7 - a[s] + 1;
}


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

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    for (auto &e : a) {
        std::cin >> e;
        e = (e + k - 1) % k;
    }

    if (k == 1) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::vector<i64> s { 0 };
    for (auto e : a) s.push_back((s.back() + e) % k);

    std::map<i64, i64> cnt;
    for (int i = 1; i < std::min(k, n + 1); i++) {
        cnt[s[i]]++;
    }

    i64 ret = 0, j = std::min(k, n + 1);
    for (int i = 0; i < n; i++) {
        ret += cnt[s[i]];
        cnt[s[i + 1]]--;
        if (j <= n) cnt[s[j++]]++;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 15984
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int ans = 0;
            for (int i = 0; i < s.length() / 2; i++) {
                if (s.charAt(i) != s.charAt(s.length() - i - 1)) {
                    ans++;
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
using std::cin;
using std::cout;

int A,B,K;

auto main()->int
	{
    cin >> A >> B >> K;
    unsigned int checkNum = (A < B ? A : B);
    unsigned int count = 0;
    int ans = 1;
    while(count != K && checkNum != 0)
    	{
        if((A % checkNum) == 0)
        	{
            if((B % checkNum) == 0)
            	{
                ans = checkNum;
                ++count;
                }
            }
        --checkNum;
        }
    cout << ans << '\n';
    return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int partition(int A[], int p, int r) {
    int x = A[r], y;
    int i = p-1, j;
    for (j=p; j<r; j++) {
        if (A[j]<=x) {
            i++;
            y = A[j];
            A[j] = A[i];
            A[i] = y;
        }
    }
    i++;
    A[r] = A[i];
    A[i] = x;

    return i;
}

int main() {
    int A[MAX];
    int n, i, j;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    i = partition(A, 0, n-1);
    for (j=0; j<n; j++) {
        if (j>0) {
            if (j==i) printf(" [%d]", A[j]);
            else printf(" %d", A[j]);
        } else {
            if (j==i) printf("[%d]", A[j]);
            else printf("%d", A[j]);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2980
N = int(input())
Lpos = []
INF = 10 ** 9 + 7
for i in range(N):
    Lpos.append(list(map(int, input().split())))
Lpos.sort(key=lambda x: x[0])
Lpos.sort(key=lambda x: x[1] + x[0])

endpos = -INF
cnt = 0
for i in range(N):
    if Lpos[i][0] - Lpos[i][1] >= endpos:
        cnt += 1
        endpos = Lpos[i][0] + Lpos[i][1]
print(cnt)


Measured memory_bytes: 31940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
    {
    static void Main(string[] args)
        {
        string[] temp=System.Console.ReadLine().Split(' ');
        int N_EdgeNum = int.Parse(temp[0]);
        int M_NewArcNum = int.Parse(temp[1]);
        int ArcNum = N_EdgeNum - 1 + M_NewArcNum;
        List<int>[] upper =Enumerable.Range(0, N_EdgeNum + 1).Select(_ => new List<int>()).ToArray();
        List<int>[] lower = Enumerable.Range(0, N_EdgeNum + 1).Select(_ => new List<int>()).ToArray();
        bool[] hasparent = new bool[N_EdgeNum + 1];
        for (int i = 0; i < ArcNum; i++)
        {
            temp = Console.ReadLine().Split(' ');
            var a = int.Parse(temp[0]);
            var b = int.Parse(temp[1]);
            upper[b].Add(a);
            lower[a].Add(b);
        }
        int root = Enumerable.Range(1, N_EdgeNum).First(x => upper[x].Count == 0);
        Queue<int> queue = new Queue<int>();
        queue.Enqueue(root);
        while (queue.Count > 0)
        {
            var p = queue.Dequeue();
            foreach (var child in lower[p])
            {
                if (upper[child].Count == 1)
                {
                    queue.Enqueue(child);
                }
                else
                {
                    upper[child].Remove(p);
                }
            }
        }
        upper[root].Add(0);
        var answer = string.Join(Environment.NewLine, upper.Skip(1).Select(u => u[0]));
        Console.WriteLine(answer);
    }
    }


Measured memory_bytes: 43060
#include<stdio.h>
char s[222222];
char st[222222];int top;
int main(){
	scanf("%s",s);
	top=0;
	for(int i=0; s[i]; i++)
		if(top > 0 && s[i] == 'T' && st[top-1] == 'S')
			--top;
		else
			st[top++] = s[i];
	printf("%d\n",top);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x, y, temp;

		for (int in_counta = 0; in_counta <3000; in_counta++) {
			x = scanner.nextInt();
			y = scanner.nextInt();

			if (x == 0 && y == 0) {
				scanner.close();
				break;
			}

			if (x > y) {
				temp = x;
				x = y;
				y = temp;
			}

			System.out.println(x + " " + y);
		}
	}
}



Measured memory_bytes: 35444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int la=0, lb=0, lc=0;
    rep(i,0,n) {
        int a,b,c;
        cin >> a >> b >> c;
        int na = a+max(lb,lc);
        int nb = b+max(la,lc);
        int nc = c+max(la,lb);
        la=na;
        lb=nb;
        lc=nc;
    }
    int ans=max(la,max(lb,lc));
    cout<<ans<<"\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
#define N 100010
int main(){
    int n,m,c;cin>>n>>m>>c;
    int b[m];rep(i,m)cin>>b[i];
    int a[n][m];
    rep(i,n)rep(j,m)cin>>a[i][j];
    int cnt=0;
    rep(i,n){
        int tmp=c;
        rep(j,m){
            tmp+=b[j]*a[i][j];
        }
        if(tmp>0)cnt++;
    }
    co(cnt);
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0, x, mn = 1<<30; i < n; ++i)
	{
		cin >> x;
		mn = min(mn, x);
		ans += mn >= x;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 7;
int n;
int b[N];
int pos[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n;
	FOR(i, 1, n + 1)
	{
		cin >> b[i];
		pos[i] = i;
	}
	
	vector<int> ans;
	FOR(it, 0, n)
	{
		bool fnd = 0;
		RFOR(i, n + 1, 1)	
			if (b[i] == pos[i])
			{
				ans.PB(b[i]);
				FOR(j, i, n + 1)
					pos[j]--;
				
				fnd = 1;
				break;
			}
		
		if (!fnd)
		{
			cout << -1;
			return 0;
		}
	}
	
	reverse(ALL(ans));
	for(auto i: ans)
		cout << i << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int h = rint, w = rint, k = rint;
	
	bool[][] xf;
	foreach(i; 0 .. h){
		xf ~= readln.chomp.to!(char[]).map!(x => x == '#').array;
	}
	
	bool[] has = new bool[](h);
	foreach(i; 0 .. h) foreach(j; 0 .. w) if(xf[i][j]) has[i] = 1;
	
	int[][] ans = new int[][](h, w);
	int c = 0;
	foreach(i; 0 .. h){
		if(!has[i]) continue;
		bool f = 0;
		c += 1;
		foreach(j; 0 .. w){
			if(xf[i][j]){
				if(f != 0) c += 1;
				 f = 1;
			 }
			ans[i][j] = c;
		}
	}
	int[] rs = new int[](h);
A:	foreach(i; 0 .. h){
		if(has[i]) continue;
		foreach(i2; i .. h) if(has[i2]){
			rs[i] = i2;
			continue A;
		}
		foreach_reverse(i2; 0 .. i) if(has[i2]){
			rs[i] = i2;
			continue A;
		}
	}
	
	foreach(i; 0 .. h){
		if(has[i]) continue;
		foreach(j; 0 .. w) ans[i][j] = ans[rs[i]][j];
	}
	
	foreach(i; 0 .. h){
		ans[i].map!(to!string).array.join(" ").writeln;
		}
}


Measured memory_bytes: 8700
#include <stdio.h>

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int c[20];
	int dp[50001];
	for (int i = 0; i < m; i++) {
		scanf("%d", &c[i]);
	}
	dp[0] = 0;
	dp[1] = 1;
	for (int k = 2; k <= n; k++) {
		int min = 999999;
		//int mini = -1;
		for (int l = 0; l < m; l++) {
			if (k - c[l] >= 0) {
				if (min > dp[k - c[l]]) {
					min = dp[k - c[l]];
					//mini = l;
				}
			}
		}
		dp[k] = min + 1;
	}
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 2104
import sys
def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
list_n = [0, -1, 1]
for i in range(2, 101):
  list_n.append(-i)
  list_n.append(i)
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
x = [0] * N
for i in range(0, N):
    x[i] = p[i] - X
for i in list_n:
    if my_index(x, i) == -1:
        print(X+i)
        break

Measured memory_bytes: 9224
#include <iostream>
using i64 = long long;

int main() {
    int n;
    i64 p, ret = 0;
    std::cin >> n >> p;
    for (int i = 1; i < n; i++) {
        i64 c;
        std::cin >> c;
        if (c < p) ret += p - c;
        else p = c;
    }

    std::cout << ret << std::endl;

    return 0;
}


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

int n, m;
int ans = 0;
vector<vector<int>> path;
void move(vector<int> p){
    if(p.size() == n) {
        ans++;
        return;
    }

    for (auto i : path[p[p.size() - 1]]) {
        vector<int> tmp = p;
        bool flg = true;
        for (int j : tmp) {
            if(j == i) {
                flg = false;
                break;
            }
        }
        if(not flg) continue;
        tmp.push_back(i);
        move(tmp);
    }
}

int main(){
    cin >> n >> m;

    path.assign(n, vector<int>(0));
    for (auto i = 0; i < m; i++) {
        int start, end;
        cin >> start >> end;

        path[start - 1].push_back(end - 1);
        path[end - 1].push_back(start - 1);
    }

    vector<int> start(0);
    start.push_back(0);
    move(start);

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

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

char march[5] = {'M', 'A', 'R', 'C', 'H'};
set<string> name;
int cnt[5];

int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        string s; cin >> s;
        auto it = name.find(s);
        for(int j=0;j<5;j++){
            if(s[0] == march[j] && it == name.end()){
                cnt[j]++; name.emplace(s);
            }
        }
    }

    lint ans = 0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++)
            for(int k=j+1;k<5;k++) ans += 1LL * cnt[i] * cnt[j] * cnt[k];
    }

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

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  int ans = abs(A[0] - A[N - 1]);
  cout << ans << endl;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2700
n=int(input())
cnt=0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for i in range(1,n+1)[::2]:
  if len(make_divisors(i)) == 8:
    cnt += 1
print(cnt)
  

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair


void solve() {
  int n;
  cin >> n;
  cout << (n-2) * 180 << endl;
}

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

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

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

using namespace std;

int a, b, ans;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main(){
	int n;
	cin >> n;
	vector<int> p(n),q(n);
	rep(i,0,n) cin >> p[i];
	rep(i,0,n) q[i] = p[i];

	sort(q.begin(),q.end());

	bool crit(false);
	
	int ihan(0);
	rep(i,0,n){
		if(q[i]!=p[i]) ihan ++;
	}

	if(ihan==0 || ihan==2) crit = true;

	if(crit) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

//#define int long long
int MOD = 1000000007;
typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst) :
		src(src), dst(dst){ }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void visit(const Graph & g, int v, int u,
	Edges& brdg, vector< vector<int> >& tecomp,
	stack<int>& roots, stack<int>& S, vector<bool>& inS,
	vector<int>& num, int& time) {
	num[v] = ++time;
	S.push(v); inS[v] = true;
	roots.push(v);
	FOR(e, g[v]) {
		int w = e->dst;
		if (num[w] == 0)
			visit(g, w, v, brdg, tecomp, roots, S, inS, num, time);
		else if (u != w && inS[w])
			while (num[roots.top()] > num[w]) roots.pop();
	}
	if (v == roots.top()) {
		brdg.push_back(Edge(u, v));
		tecomp.push_back(vector<int>());
		while (1) {
			int w = S.top(); S.pop(); inS[w] = false;
			tecomp.back().push_back(w);
			if (v == w) break;
		}
		roots.pop();
	}
}
void bridge(const Graph& g, Edges& brdg, vector< vector<int> >& tecomp) {
	const int n = g.size();
	vector<int> num(n);
	vector<bool> inS(n);
	stack<int> roots, S;
	int time = 0;
	REP(u, n) if (num[u] == 0) {
		visit(g, u, n, brdg, tecomp, roots, S, inS, num, time);
		brdg.pop_back();
	}
}signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int a, b;
	Graph g(N);
	Edge ed(1, 1);
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		ed.src = a; ed.dst = b;
		g[a].push_back(ed);
		ed.src = b; ed.dst = a;
		g[b].push_back(ed);
	}
	Edges eds;
	vector<vector<int> > vv;
	bridge(g, eds, vv);
	cout << eds.size() << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int Q = sc.nextInt();

		char[] c = sc.next().toCharArray();
		int[] counts = new int[N];
		int[] results = new int[Q];
		boolean aFlag = false;
		int count = 0;
		for (int j = 0; j < N; j++) {
			if (c[j] == 'A') {
				aFlag = true;
			} else if (aFlag) {
				if (c[j] == 'C') {
					count++;
				}
				aFlag = false;
			}
			counts[j] = count;
		}
		for (int i = 0; i < Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int forL = counts[l-1];
			int forR = counts[r-1];

			results[i] = forR - forL;

		}

		for (int k : results) {
			System.out.println(k);
		}
	}

}

Measured memory_bytes: 85132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,h,c=0;
    vector<ll>v,u;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        cin>>h;
        v.push_back(h);
    }
    for(ll i=0; i+1<n; i++)
    {
        if(v[i]>=v[i+1])
        {
            c++;

        }
        else if(v[i]<v[i+1])
        {
            u.push_back(c);
            c=0;
        }
    }
    u.push_back(c);
    sort(u.begin(),u.end());
    cout<<u[u.size()-1]<<endl;
    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
  ll n;
    cin >> n;
    vector<ll> c(26, 1);
    for(ll i = 0; i < n; i++)
    {
        char a;
        cin >> a;
        c[a - 'a']++;
    }

    ll ans = 1L;
    int mod = 1e9 + 7;
  for(ll i = 0; i < 26; i++)
    {
        ans = ans * c[i] % mod;
    }
    cout << (ans - 1) % mod << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      int n=sc.nextInt();
	      int a=sc.nextInt();
	      int b=sc.nextInt();
	      int c=a-b;
	      long h[]=new long[n];
	      
	      for(int i=0;i<n;i++) {
	        h[i]=sc.nextLong();
	      
	      }
	        int l=0;
	        int u=(int) 1e9;
	        while(u>l+1) {
	          int k=(u+l)/2;
	          long sum=0;
	          for(long i:h) {
	            long d=i-1l*b*k;
	            if(d>0) {
	              sum+=(d+c-1)/c;
	            }
	          }
	          if(sum>k) {
	            l=k;
	          }else {
	            u=k;
	          }
	        }
	        System.out.println(u);
	 
	}


static long nCr(int n, int r, 
    int p) 
{ 


if (r == 0) 
return 1; 


int[] fac = new int[n + 1]; 
fac[0] = 1; 

for (int i = 1; i <= n; i++) 
fac[i] = fac[i - 1] * i % p; 

return (fac[n] * modInverse(fac[r], p) 
% p * modInverse(fac[n - r], p) 
% p) 
% p; 
} 
static long modInverse(int n, int p) 
{ 
    return pow(n, p - 2)%mod; 
} 
static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
} 
}




Measured memory_bytes: 60500
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll i = 0; i < n; i++) cin >> b[i];
  for(ll i = 0; i < n-1; i++) cin >> c[i];
  
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ans += b[a[i]-1];
    if(a[i-1]+1 == a[i]) ans += c[a[i]-2];
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            string S =Console.ReadLine();
            char a;
            char b;
            char c;
            char d;

            a = S[0];
            b = S[1];
            c = S[2];
            d = S[3];

           
            if (a == b && a == c && a == d || b == a && b == c && b == d || c == a && c == b && c == d || d == a && d == b && d == c )
            {
                Console.WriteLine("No");
            }
            else if (a == b && c == d || a == c && b == d || a == d && b == c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }


int main(void) {
	int n; cin >> n;
	vector<char> v;
	char a; cin >> a;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		char b; cin >> b;
		if (a != b)ans++;
		a = b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }

        int cur = 0;
        long sum = 0;
        for (int i = 0; i < n-1; i++) {
            int next = t[i+1];
            int diff = Math.min(T, next - cur);
            cur = next;
            sum += (long)diff;
        }
        sum += T;
        System.out.println(sum);
    }
}

Measured memory_bytes: 62768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = new int[n];
            for (int i = 0; i < n; i++) p[i] = int.Parse(Console.ReadLine());

            int max = p.Sum() - p.Max() / 2;


            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11348
import itertools,math,bisect,pprint,sys
n, a, b = map(int, raw_input().split())
x = map(int, raw_input().split())
res = 0
for i in range(n-1):
    c = (x[i+1]-x[i])*a
    if c > b:
        res += b
    else:
        res += c
print res

Measured memory_bytes: 11380
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

namespace {

}

// N, W, S, Eが入っていればよい。
int main()
{
	string S;

	cin >> S;

	if (count(S.cbegin(), S.cend(), 'N') > 0 && count(S.cbegin(), S.cend(), 'S') == 0){
		cout << "No";
		return 0;
	}
	if (count(S.cbegin(), S.cend(), 'S') > 0 && count(S.cbegin(), S.cend(), 'N') == 0){
		cout << "No";
		return 0;
	}
	if (count(S.cbegin(), S.cend(), 'W') > 0 && count(S.cbegin(), S.cend(), 'E') == 0){
		cout << "No";
		return 0;
	}
	if (count(S.cbegin(), S.cend(), 'E') > 0 && count(S.cbegin(), S.cend(), 'W') == 0){
		cout << "No";
		return 0;
	}
	cout << "Yes";
	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner scanner;

	public static void main(String[] args) {
		scanner = new Scanner(System.in);

		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		while(a < 0 || a > 100);
		while(b < 0 || b > 100);
		while(c < 0 || c > 100);
		if(a < b && b < c) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}




Measured memory_bytes: 26248
function Main(input) {
  input = input.split("\n");
  var N = input[0].split(" ")[0];
  var D = input[0].split(" ")[1];
  var ans = Math.ceil(N/(D*2+1));


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064