akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, K, D;
    cin >> X >> K >> D;
    // 絶対値として計算する
    X = abs(X);
    // 正の絶対値を最小にするための移動回数
    int t = X / D;
    // 移動回数はtとKの最小値となる
    X -= min(t, K) * D;
    K -= min(t, K);
    // 残りの移動回数が偶数なら、行って戻る操作を繰り返せば移動不要
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        // 負の方向へ1回移動する
        cout << abs(X - D) << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long cnt=0;
int main(){
  long long n; cin >> n;
  vector<int> L(n);
  for(int i=0;i<n;i++) cin >> L[i];
  
  sort(L.begin(), L.end());
  
  for(int k=2;k<n;k++){
    for(int i=0;i<k-1;i++){
      for(int j=i+1;j<k;j++){
        if(L[i] + L[j] <= L[k]) cnt++;
        else continue;
      }
    }
  }
  cout << n*(n-1)*(n-2)/6 - cnt << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int a,b;
    cin >> a >> b;
    if(a>9||b>9){
        cout << -1 << endl;
    }else{
        cout << a*b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define foe(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef double ld;
typedef long long L;
typedef vector<int> VI;
typedef pair<int,int> pa;
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
const int N=1e5+11;
int n,a[N];
int main(){
#ifdef flukehn
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
#endif
	cin>>n;
	rep(i,1,n)cin>>a[i];
	int dl=1;
	rep(i,1,n)if(a[i]){
			dl=0;
			break;
		}
		if(dl){
		puts("Yes");
			return 0;
		}
	if(n%3){
		puts("No");
	}else{
		map<int,int> f;
		rep(i,1,n)f[a[i]]++;
		int fl=1,t=0;
		for(auto p:f){
			if(p.second%(n/3))fl=0;
			else{
				rep(i,1,p.second*3/n)a[++t]=p.first;
			}
		}
		fl &= (a[1]^a[2]^a[3]) == 0;
		if(fl)puts("Yes");else puts("No");
	}
}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  vector<int> ans;
  for(int i=0;i<n;i++){
    for(int j=b.size()-1;j>=0;j--){
      if(b[j]==j+1){
        ans.push_back(j+1);
        b.erase(b.begin()+j);
        break;
      }
    }
  }
  if(ans.size()!=n){
    cout << -1 << endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    cout << ans[n-1-i] << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> P(10);
	iota(P.begin(), P.end(), 0);
	for (int i = 0; i < K; ++i) {
		int D;
		cin >> D;
		P.erase(remove(P.begin(), P.end(), D), P.end());
	}
	int ans = numeric_limits<int>::max();

	queue<string> q;
	q.push("");
	while (!q.empty()) {
		auto x = q.front();
		q.pop();
		if (x.length() >= 6) {
			continue;
		}
		for (auto y : P) {
			string z = (char)('0' + y) + x;
			auto n = stoi(z);
			if (n < N) {
				q.push(z);
			}
			else {
				ans = min(ans, n);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
N, M = [int(t) for t in input().split()]
l = [[0]*2 for i in range(M)]

l_max = 0
r_min = N
for i in range(M):
    L, R = [int(t) for t in input().split()]
    l_max = L if l_max < L else l_max
    r_min = R if r_min > R else r_min

ans = r_min-l_max+1 if r_min >= l_max else 0
print(ans)


Measured memory_bytes: 13300
N=int(input())
S=[]
for i in range(N):
    S.append(input())
S.sort()
T=sorted(set(S))

cnt=0
i=0
cnt_array=[0]*(len(T))
while cnt<len(T) and i<N:
    if S[i]==T[cnt]:
        cnt_array[cnt]+=1
        i+=1
    else:
        cnt+=1

M=max(cnt_array)
for i in range(len(T)):
    if cnt_array[i]==M:
        print(T[i])

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

int main(){
    int N, a, b;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P.at(i);
    for (int i = 0; i < N; i++) cin >> Q.at(i);
    vector<int> num(N);
    for (int i = 1; i <= N; i++) num.at(i-1) = i;
    int cnt = 1;
    do{
        if (num == P) a = cnt;
        if (num == Q) b = cnt;
        cnt++;
    } while (next_permutation(num.begin(), num.end()));
    cout << abs(b-a) << endl;
}

Measured memory_bytes: 256
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);}

Measured memory_bytes: 524
import sys
import math


class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y


class Vector:
    def __init__(self, p1, p2):
        self.vx = p2.x - p1.x
        self.vy = p2.y - p1.y

    def length(self):
        return math.sqrt(self.vx ** 2.0 + self.vy ** 2.0)

    def degree(self, other):
        theta = math.acos((self.vx * other.vx + self.vy * other.vy)/(self.length() * other.length()))
        return theta

    def show(self):
        return "Vector(%f, %f)" % (self.vx, self.vy)


def solv(points):
    p0 = points[0]
    for p in points[1:]:
        if p.y < p0.y:
            p0 = p
    v1 = Vector(Point(0.0, 0.0), Point(1.0, 0.0))
    p1 = p0
    t = [p1]
    while True:
        min_deg = math.pi
        next_p = None
        next_v = None
        points2 = list(points)
        points2.remove(p1)
        for p2 in points2:
            v2 = Vector(p1, p2)
            deg = v1.degree(v2)
            if deg < min_deg:
                min_deg = deg
                next_p = p2
                next_v = v2
        if next_p == p0:
            break
        p1 = next_p
        t.append(p1)
        v1 = next_v
    return len(points) - len(t)



while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    points = []
    for i in range(n):
        x, y = map(float, sys.stdin.readline().split(','))
        points.append(Point(x, y))
    print solv(points)

Measured memory_bytes: 4496
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> P(M);
    vector<string> S(M);
    rep(i, 0, M) cin >> P[i] >> S[i];
    vector<int> cnt(N, 0);
    vector<bool> ac(N, false);
    rep(i, 0, M) {
        if (S[i] == "WA" && !ac[P[i] - 1]) {
            ++cnt[P[i] - 1];
        }
        else {
            ac[P[i] - 1] = true;
        }
    }
    int acc = 0, penalty = 0;
    rep(i, 0, N) {
        if (ac[i]) {
            ++acc;
            penalty += cnt[i];
        }
    }
    cout << acc << ' ' << penalty << endl;
    return 0;
}

Measured memory_bytes: 6528
import sys

n, k = map(int, input().split())

x = set()

for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))

	for s in a: 
		x.add(s)
result = 0

for i in range(1, n + 1):
	if not i in x:
		result += 1

print(result)




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

int main(){
  int n;cin >> n;
  if(n == 1)cout << "Hello World" << endl;
  else {int a,b;cin >> a >> b;cout << a+b << endl;}
  return 0;
}


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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

int main(){
  int n;cin>>n;
  vector<int> a(n);
  int pos=0, sum=0;
  for(int i=0;i<n;i++){
  	cin>>a[i];
    sum+=abs(a[i]-pos);
    pos=a[i];
  }
  sum+=abs(a[n-1]);
  // cout<<sum<<endl;
  for(int i=0;i<n;i++){
  	int s=(i==0?0:a[i-1]), t=a[i], u=(i==n-1?0:a[i+1]);
    if((s-t)*(u-t)<=0)cout<<sum<<endl;
    else if((t-s)*(u-s)<0)cout<<sum-2*abs(s-t)<<endl;
    else cout<<sum-2*abs(u-t)<<endl;
  }
}


Measured memory_bytes: 1664
n = gets.to_i
point = [0] * n
(n*(n-1)/2).times{
    a, b, c, d = gets.split.map &:to_i
    if c > d
        point[a-1] += 3
    elsif c < d
        point[b-1] += 3
    else
        point[a-1] += 1
        point[b-1] += 1
    end
}
puts (1..n).map{|i| point.sort.reverse.index(point[i-1]) + 1}

Measured memory_bytes: 6208
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
template<class T> inline bool chmax( T &a, const T &b ) {return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int INF=1e9;
int n, m;
vector<int> a;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    a.resize(m);
    REP(i,m) cin >> a[i];
    if ( n>=m ) {
        cout << 0 << '\n';
        return 0;
    }
    vector<int> v;
    sort(ALL(a));
    REP(i,m-1) {
        v.PB(a[i+1]-a[i]);
    }
    sort(ALL(v));
    int ans=a.back()-a[0];
    REP(i,n-1) {
        ans-=v[m-1-i-1];
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << (w * h) / 2 << ' ';
	cout << (x == w / 2 && y == h / 2) * 1;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int i,j,n;

   scanf("%d",&n);
   for(i=1;i<10;i++){
      for(j=1;j<10;j++){
         if(n==i*j){
            printf("Yes\n");
            i=12;
         }
      }
   }
   if(i!=13)
      printf("No\n");
return 0;
}


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

using namespace std;

int main()
{
    string a;
    cin >> a;
    bool al = false;
    for(int i= 0; i <3; i++)
    {
        if(a[i] == '7')
            al =true;
    }
    if(al == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

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

    string s;
    cin >> s;
    if (s == "SUN") {
        cout << "7";
    } else if (s == "MON") {
        cout << "6";
    } else if (s == "TUE") {
        cout << "5";
    } else if (s == "WED") {
        cout << "4";
    } else if (s == "THU") {
        cout << "3";
    } else if (s == "FRI") {
        cout << "2";
    } else if (s == "SAT") {
        cout << "1";
    }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    int p[N]; rep(i, N){int temp; cin >> temp; temp--; p[i] = temp;}
    int A[N], B[N];
    A[0] = N; B[0] = N*N;
    rep(i, N){
        if(i == 0) continue;
        A[i] = A[i-1] + N; B[i] = B[i-1] - N;; 
    }
    rep(i, N){
        B[p[i]] += i;
    }
    rep(i, N) cout << A[i] << " "; cout << endl;
    rep(i, N) cout << B[i] << " "; cout << endl;
    //int C[N]; rep(i, N) C[i] = A[p[i]] + B[p[i]];
    //rep(i, N) cout << C[i] << " "; cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll d,r,n,p;
    p=0;
    string s;
    cin>>n>>s;
    for(int i=1;i<n;i++){
    	if(s[i]=='E')p++;
    }
    d=p;
    for(int i=1;i<n;i++){
    	if(s[i-1]=='W')p++;
    	if(s[i]=='E')p--;
    	d=min(d,p);
    }
    cout <<d<<endl;
}



Measured memory_bytes: 900
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int A, B, C, D;
int main() {
  while (cin >> A >> B >> C >> D) {
	cout << min(A, B) + min(C, D) << endl;
  }
}

















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



int main(){
    int n; //山の個数、奇数
    cin >> n;

    vector<long long int> rains(n); //雨の量、偶数
    for(int i=0; i<n; i++) cin >> rains[i];

    vector<long long int> ans(n); //答え

    /* 山１に降った雨を求める */
    for(int i=0; i<n; i++){
        if(i%2 == 0) ans[0] += rains[i];
        else ans[0] -= rains[i];
    }

    /* 山２以降に降った雨の量を求める */
    for(int i=1; i<n; i++) ans[i] = rains[i-1]*2 - ans[i-1];

    /* 表示 */
    for(int i=0; i<n; i++) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2944
from collections import defaultdict
H, W = map(int, input().split())
a = [input() for i in range(H)]
C = defaultdict(int)
for s in a:
    for c in s:
        C[c] += 1
m = [0]*4
for k in C:
    m[C[k]%4] += 1
if H&1 and W&1:
    if m[1]+m[3] == 1 and m[2] <= H//2+W//2-m[3]:
        print('Yes')
    else:
        print('No')
elif H&1==0 and W&1==0:
    if all([C[x]%4==0 for x in C]):
        print('Yes')
    else:
        print('No')
else:
    if H&1:
        H, W = W, H
    if m[1] == m[3] == 0 and m[2] <= H//2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int LL;
const int MAXN = 101010;
int n;
LL a[MAXN], C, b[MAXN];
LL rema[MAXN], remb[MAXN];

int main(){
    scanf("%d%lld", &n, &C);
    for(int i = 1; i <= n; i ++)
        scanf("%lld%lld", &a[i], &b[i]);
    a[n+1] = C;
    LL ans = 0, rec = 0;
    for(int i = 1; i <= n; i ++){
        rec = rec + b[i] - (a[i] - a[i-1]);
        ans = max(rec, ans);
        rema[i] = max(rema[i-1], rec);
    }
    rec = 0;
    for(int i = n; i > 0; i --){
        rec = rec + b[i] - (a[i+1] - a[i]);
        ans = max(ans, rec);
        remb[i] = max(remb[i+1], rec);
    }
    rec = 0;
    for(int i = 1; i <= n; i ++){
        rec = rec + b[i] - (a[i] - a[i-1]);
        ans = max(ans, rec+remb[i+1]-a[i]);
    }
    rec = 0;
    for(int i = n; i > 0; i --){
        rec = rec + b[i] - (a[i+1] - a[i]);
        ans = max(ans, rec+rema[i-1]-(C-a[i]));
    }
    printf("%lld", ans);
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,a,b,t[1000],cnt=0;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)cin>>t[i];
    sort(t,t+n);
    if(t[0]<a||t[0]>=b)cnt++;
    for(int i=1;i<n;i++){
        if((t[i]<a||t[i]>=b)&&t[i]!=t[i-1])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long s;
long long l, h;

long long maxN = 1000000000;
long long step = 1000000000 - 1;

int main()
{
	scanf("%lld", &s);
	
	int d = s / step;
	if (d > maxN)
		d = maxN;
		
	l = d * (maxN - 1);
	h = l + maxN;
	
	long long leftHeight = d;
	long long rightHeight = s - l;
	
	long long x1 = 0;
	long long y1 = leftHeight;
	long long x2 = 1;
	long long y2 = 0;
	long long x3 = maxN;
	long long y3 = rightHeight;
	
	printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N;
const long long NMAX=100010;
long long h[NMAX];
long long dp[NMAX];

long long rec(int i){
    if(dp[i]<LLONG_MAX) return dp[i];
    if(i==0) return 0;

    long long res = LLONG_MAX;
    chmin(res, rec(i-1)+abs(h[i]-h[i-1]));
    if(i>1) chmin(res, rec(i-2)+abs(h[i]-h[i-2]));

    return dp[i] = res;
}
int main()
{
    cin >> N;
    REP(i, N) cin>>h[i];
    REP(i, N) dp[i] = LLONG_MAX;

    rec(N-1);

    cout << rec(N-1) << endl;

   return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cassert>

using namespace std;
std::vector<int64_t> numbers;
vector<vector<int>> graph;
std::vector<bool> used;

std::pair<bool, int64_t> Dfs(int v) {
    used[v] = true;

    std::vector<int64_t> elements;
    int64_t mx = 0;
    int64_t sum = 0;
    for (const auto& el : graph[v]) {
        if (used[el]) continue;
        auto pr = Dfs(el);
        if (!pr.first) {
            return {false, 0};
        }
        elements.push_back(pr.second);
        mx = max(mx, pr.second);
        sum += pr.second;
        assert(pr.second >= 0);
    }
    if (elements.empty()) {
        return {true, numbers[v]};
    }
    int64_t mn_can = min(sum - mx, sum / 2);
    if (mn_can + (sum - mn_can * 2) > numbers[v]) {
        return {false, 0};
    }
    if (sum < numbers[v]) {
        return {false, 0};
    }
    auto sm = sum - numbers[v];
    if (sm > mn_can) {
        return {false, 0};
    }
    sum -= 2 * sm;
    return {true, sum};
}

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    graph.resize(n);
    used.resize(n);
    used.assign(n, 0);
    numbers.resize(n);
    for (auto& el : numbers) {
        cin >> el;
    }
    for (int i = 0; i < n - 1; i++) {
        int x;
        int y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    if (n == 2) {
        cout << ((numbers[0] == numbers[1]) ? "YES" : "NO") << endl;
        return 0;
    }
    int v = 0;
    for (int i = 0; i < n; i++) {
        if (graph[i].size() > 1) {
            v = i;
        }
    }
    auto ans = Dfs(v);
    if (ans.first == true && ans.second == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 16512
#include<iostream>
#include<map>
#include<string>
#include<cstdio>
typedef unsigned long long ll;
const ll inf = 1e18; 
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll ans=1,temp,t;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		cin>>temp;
		if(temp==0)
		{
			cout<<0<<endl;
			return 0;
		}
		if(inf/temp<ans)
			flag=1;
		else
			ans*=temp;
	}
	if(flag)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3660
n=int(input())
p=list(map(int,input().split()))
p.append(0)
pp=list(map(int,input().split()))
c=0
for i in range(n):
    if p[i]>=pp[i]:
        c+=pp[i]
    elif p[i+1]>=pp[i]-p[i]:
        c=c+pp[i]
        pp[i] = pp[i]-p[i]
        p[i+1] = p[i+1]-pp[i]
    else:
        c=c+p[i]+p[i+1]
        p[i+1]=0
print(c)




Measured memory_bytes: 81892
// atcoder/aising2020/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int a, b, d;
  while (cin >> a >> b >> d) {
    int cnt = 0;
    for (int i = a; i <= b; ++i) {
      cnt += (i % d == 0);
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
import math

N=int(input())
X=list(map(int, input().split()))
ans=sum(X)/N
p1=math.ceil(ans)
p2=math.floor(ans)
s1=0
s2=0
for i in range(N):
    s1+=(X[i]-p1)**2
    s2+=(X[i]-p2)**2
print(min(s1, s2))

Measured memory_bytes: 38384
let tuple s =
  let split = Str.split (Str.regexp_string " ") in
  let nth = split s |> List.map float_of_string |> List.nth in
  (nth 0,nth 1,nth 2,nth 3,nth 4,nth 5);;

let () =
  let n = read_int () in
  let rec loop = function
      0 -> ()
    | i -> let (x1,y1,x2,y2,x3,y3) = read_line () |> tuple in
           let a = 2.*.(x1-.x2) and
               b = 2.*.(y1-.y2) and
               c = 2.*.(x1-.x3) and
               d = 2.*.(y1-.y3) and
               e = x1*.x1 -. x2*.x2 +. y1*.y1 -. y2*.y2 and
               f = x1*.x1 -. x3*.x3 +. y1*.y1 -. y3*.y3 in
           let g = a*.d -. b*.c in
           let x = (e*.d -. b*.f)/.g and
               y = (a*.f -. e*.c)/.g in
           let r = sqrt( (x-.x1)**2. +. (y -. y1)**2.) in
           Printf.printf "%.3f %.3f %.3f\n" x y r;loop (i-1)
  in loop n

Measured memory_bytes: 2364
s=[]
a=[]
gets.each_char.with_index{|c,i|if$*!=s&&c[?/]
x=s.pop
y=i-x
y+=a.pop[1]while a[-1]&&x<a[-1][0]
a.push [x,y]
end
s.push i if c[?\\]}
p(0,0)|exit if !A=a.transpose[1]
p A.reduce :+
puts [A.size,A]*" "

Measured memory_bytes: 6292
def main():
  def con(m,n):
    ln = len(str(n))
    return m * 10 ** ln + n
  n = int(input())
  lst = [int(input()) for i in range(n)]
  lst.sort()
  lst = lst[0:4]
  save = []
  for i in lst:
    for j in lst:
      if i != j:
        save.append(con(i, j))
  save.sort()
  print(save[2])
  
main()


Measured memory_bytes: 5936
import sys
# import collections
# import math
# import bisect
# import re
# import itertools


def primeNums(n):
    from math import floor, sqrt
    sieve = set(range(2, n + 1))
    if 2 in sieve:
        not_prime = set(range(2 * 2, n + 1, 2))
        sieve -= not_prime
    for i in range(3, floor(sqrt(n)) + 1, 2):
        if i in sieve:
            not_prime = set(range(i * 2, n + 1, i))
            sieve -= not_prime
    return sieve

limit = 10 ** 5
prime_table = [0 for _ in range(limit + 1)]
for p in primeNums(limit):
    prime_table[p] = 1

like_2017_table = [0 for _ in range(limit + 1)]
for i in range(3, limit + 1, 2):
    if prime_table[i] and prime_table[(i + 1) // 2]:
            like_2017_table[i] = 1

s = [0 for _ in range(limit + 1)]
for i in range(limit):
    s[i+1] = s[i] + like_2017_table[i+1]

def main():

    q = int(sys.stdin.readline().rstrip())
    m = map(int, sys.stdin.read().split())

    for l, r in zip(m, m):
        res = s[r] - s[l-1]
        print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22552
import java.util.HashMap;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int m=in.nextInt();
			if((n|m)==0)
				return;
			int f[][]=new int [n+1][n+1];
			HashMap<Integer, Integer> map=new HashMap<Integer,Integer>();
			for(int i=0;i<m;i++)
			{
				int a=in.nextInt();
				int b=in.nextInt();
				f[a][b]++;
				f[b][a]++;
			}
			
			for(int i=1;i<=n;i++)
			{
				if(f[1][i]!=0)
				{
					map.put(i, 1);
					for(int j=2;j<=n;j++)
					{
						if(f[i][j]!=0)
							map.put(j, 1);
					}
				}
			}
			System.out.println(map.size());
		}
	}
}

Measured memory_bytes: 14000
#include <stdio.h>
#include<string>
#include<iostream>
using namespace std;
int base[4];
int point;
int out_count;

void format(){
	int i;
	for(i=3;i--;){
		base[i]=0;
	}
	point=0;
	out_count=0;
}

void hit(){
	int i;
	for(i=3;i>0;i--){
		if(base[i-1]==1){
			base[i]=1;
			base[i-1]=0;
		}
	}
	
	
	if(base[3]==1){
		point++;
		base[3]=0;
	}
	base[0]=1;
}

void homerun(){
	int i;
	for(i=3;i--;){
		if(base[i]==1){
			point++;
			base[i]=0;
		}
	}
	point++;
}


int main(){
	format();
	int n;
	scanf("%d",&n);
	
	string s;
	while(n){
		cin >> s;
		
		if(s=="OUT"){
			out_count++;
		}else if(s=="HIT"){
			hit();
		}else if(s=="HOMERUN"){
			homerun();
		}else{
			printf("error");
		}
		
		if(out_count==3){
			printf("%d\n",point);
			n--;
			format();
		}
		
		
	}
	
	return 0;
}

Measured memory_bytes: 1248
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class CSentou {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i, N) {
      cin >> t[i];
    }
    int ans = T;
    rep(i, N - 1) ans += min(T, t[i + 1] - t[i]);
    cout << ans << endl;
  }
};


signed main() {
  CSentou solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	int cnt = 0;
	rep(i, n) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
struct edge{
	int to,next,w;
}e[20000002];
int n,m,head[300002],ans,cnt,sum,s;
inline void add(re int x,re int y,re int w){
	e[++cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt;
	e[cnt].w=w;
}
struct node{
    int pos,dis;
    bool operator <(const node x)const{
        return dis>x.dis;
    }
}h[300002];
priority_queue <node> q;
bool v[300002];
inline int pos(re int x,re int y){
	return x*(sum+1)+y;
}
inline void dis(re int s){for(re int i=1;i<=pos(n,sum);++i)h[i].dis=1e18,h[i].pos=i;
    h[s].dis=0;
    q.push(h[s]);
    while(!q.empty()){
        while((h[q.top().pos].dis<q.top().dis)){q.pop();if(q.empty())break;
        }
        if(q.empty())break;
        node tmp=q.top();
        q.pop();
        for(re int i=head[tmp.pos];i;i=e[i].next){
            if((tmp.dis+e[i].w)<h[e[i].to].dis){
                h[e[i].to].dis=tmp.dis+e[i].w;
                q.push(h[e[i].to]);
            }
        }
     
    }
}
signed main(){
	n=read();m=read();s=read();
	sum=5000;
	for(re int i=1,x,y,a,b;i<=m;++i){
		x=read();y=read();a=read();b=read();
		for(re int j=a;j<=sum;++j)add(pos(x,j),pos(y,j-a),b),add(pos(y,j),pos(x,j-a),b);
	}
	for(re int x,y,i=1;i<=n;++i){
		x=read();y=read();
		for(re int j=0;j<=sum;++j){
		add(pos(i,j),pos(i,min(j+x,sum)),y);if(j)add(pos(i,j),pos(i,j-1),0);}
	}
	dis(pos(1,min(s,sum)));
	for(re int i=2;i<=n;++i)printf("%lld\n",h[pos(i,0)].dis);
}

Measured memory_bytes: 45752
N=int(input())
F=[[0]*10]*N
ans=-10e+9
for i in range(N):
    F[i]=list(map(int,input().split()))
    
P=[[0]*10]*N
for i in range(N):
    P[i]=list(map(int,input().split()))

for i in range(1,2**10):
    total=0
    bit=[0]*10
    for j in range(10):
        if(i>>j&1):
            bit[j]=1
    for j in range(N):
        tmp=0
        for k in range(10):
            if(bit[k]==1 and bit[k]==F[j][k]):
                tmp+=1
        total+=P[j][tmp]
    ans=max(ans,total)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n+1],i;
    for(i=0; i<n; i++) scanf("%d",&arr[i]);
    sort(arr, arr+n);
    arr[n]=arr[n-1]+1;
    int ans=0,c=1;
    for(i=0;i<n;i++)
    {
        if(arr[i]!=arr[i+1])
        {
            if(arr[i]<c) ans+=fabs(c-arr[i]);
            else if(arr[i]>c) ans+=c;
            //printf("%d %d\n",arr[i],c);
            c=1;
        }
        else c++;
    }
    //if(c>1) ans+=fabs(arr[i]-c);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
import std.stdio, std.conv, std.string;

void main()
{
    auto D = readln().strip.to!int;
    switch(D)
    {
        case 25:
            writeln("Christmas");
        break;
        case 24:
            writeln("Christmas Eve");
        break;
        case 23:
            writeln("Christmas Eve Eve");
        break;
        case 22:
            writeln("Christmas Eve Eve Eve");
        break;
        default:
        break;
    }
}


Measured memory_bytes: 256
// Subscribers

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n, a, b;

int main() {
    cin >> n >> a >> b;

    if (a + b <= n) {
        cout << min(a, b) << " " << 0 << endl;
    } else {
        cout << min(a, b) << " " << a + b - n << endl;
    }

    return 0;
}


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

int main(void){
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> v(m);
	vector<pair<int,int>> range(n);
	rep(i,n)range[i]={i,i};
	rep(i,m)cin>>v[i].first>>v[i].second;
	sort(v.begin(),v.end());
	rep(i,m){
		int y=v[i].second;
		range[y-1].second=range[y].second;
		range[y].first=range[y-1].first;
	}
	cout<<range[0].second-range[0].first+1;
	rep1(i,n-1)cout<<" "<<range[i].second-range[i].first+1;
	cout<<endl;
	return 0;
}

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

int main() {
    int x, y;
    
    while (true) {
        cin >> x >> y;
        if (x == 0 and y == 0) break;
        if (x < y) cout << x << ' ' << y << '\n';
        else cout << y << ' ' << x << '\n';
    }

    return 0;
}


Measured memory_bytes: 2992
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int p=1e9+7;
int n;
long long f[1200000],m,s[1200000];
int main(){
	scanf("%d",&n);
	m=n-1;m=m*m%p;
	f[n]=n;
	/*fd(i,n-1,1){
		f[i]=(f[i+1]+m)%p;
		fo(j,2,n) if (i+j+1<=n) f[i]+=f[i+j+1];else f[i]++;
		f[i]%=p;
		//printf("%d:%lld\n",i,f[i]);
	}*/
	s[n]=n;
	fd(i,n-1,1){
		f[i]=(f[i+1]+m)%p;
		if (i<n-1) f[i]=(f[i]+i+1)%p;else f[i]=(f[i]+n-1)%p;//!!!!!!!!!!
		if (i+3<=n) f[i]=(f[i]+s[i+3])%p;//!!!!!!!!!!!!!  f[i+3]..f[i+n+1]  f[n+1]..f[i+n+1]=1
		s[i]=(s[i+1]+f[i])%p;
		//printf("%d:%lld\n",i,f[i]);
	}
	printf("%lld\n",f[1]);
	return 0;
}

Measured memory_bytes: 18560
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    vector<int> A(3);
    
    rep(i,3){
        cin>>A[i];
    }
    
    sort(A.begin(),A.end());
    int ans=abs(A[0]-A[1])+abs(A[1]-A[2]);
    cout<<ans<<endl;
    
  
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define bit_cnt(n) (__builtin_popcountll(n))
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  printf("%.10f\n",a/b);
  return 0;
}


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

int cpp(int a, int b)
{
	if (b == 0)
		return a;
	else
		return cpp(b, a % b);
}
int main()
{
	int m, temp;
	unsigned long long int mama, cc;
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin >> temp;
		if (!i)
			mama = temp;
		else
		{
			if (mama >= temp)
			{
				cc = cpp(mama, temp);
				mama = (mama * temp) / cc;
			}
			else
			{
				cc = cpp(temp,mama);
				mama = (mama * temp) / cc;
			}
		}
	}
	cout << mama << endl;
	return 0;
}




Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(A[i] == B[i] && B[i] == C[i] && C[i] == A[i]) continue;
    else if(A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) ans += 2;
    else ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(A <= 8 && B <= 8 ? "Yay!" : ":(");
	}
}

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

namespace AtCoder.Abc
{
    class A_168_Therefore
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string N = Console.ReadLine();
            string a = N.Substring(N.Length - 1, 1);

            if (a == "3")
            {
                Console.WriteLine("bon");
            }
            else if (a == "0" || a == "1" || a == "6" || a == "8")
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

int main()
{
	long long d,t,s;
	scanf("%lld%lld%lld",&d,&t,&s);
	long long sum=t*s;
	if(sum>=d)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 3820
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		string S = GetString();
		int w = GetInt();
		var sb = new StringBuilder();
		for(int i = 0; i < S.Length; i += w)
			sb.Append(S[i].ToString());
		Console.WriteLine(sb);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int a, b, c;

int main() {
    scanf("%d%d%d",&a,&b,&c);
    printf("%d",max(0,c-(a-b)));
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N-1);
  for(int i = 0;i<N-1;i++){
    cin >> A.at(i);
  }
  vector<int> B(N,0);
  for(int i = 0;i<N-1;i++){
    B.at(A.at(i)-1)++;
  }
  for(int i = 0;i<N;i++){
    cout << B.at(i) << endl;
  }

}

Measured memory_bytes: 4792
h,w = map(int, input().split())

a = [input() for i in range(h)]

row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i] == True:
        for j in range(w):
            if col[j] == True:
                print(a[i][j],end = '')
        print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

int n, k;

void input() {
  scanf("%d %d", &n, &k);
}

void solve() {
  ll ans = 0;
  ll m = 0;
  ll x = 0;
  for (int i = 1; i <= n; i++) {
    if ((i % k) == 0)
      m++;
  }
  ans += (m * m * m);
  if (k % 2 == 0) {
    for (int i = 1; i <= n; i++) {
      if ((i % k) == (k / 2))
        x++;
    }
    ans += (x * x * x);
  }
  printf("%lld\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
l=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in range(3):
    if x in l[i]:
        a=i
for j in range(3):
    if y in l[j]:
        b=j
print('Yes' if a==b else 'No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 100005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

bool a[10];
int main()
{
    int n;
    cin >> n;
    int ans = 0, qq = 0, tem;
    while(n--)
    {
        cin >> tem;
        if(tem < 400) a[0] = true;
        else if(tem < 800) a[1] = true;
        else if(tem < 1200) a[2] = true;
        else if(tem < 1600) a[3] = true;
        else if(tem < 2000) a[4] = true;
        else if(tem < 2400) a[5] = true;
        else if(tem < 2800) a[6] = true;
        else if(tem < 3200) a[7] = true;
        else qq++;
    }
    for(int i = 0; i < 8; ++i)
    {
        if(a[i]) ans++;
        //cout << a[i] << " ";
    }
    //cout << endl;
    int maxx;
    if(qq)
        maxx = ans+qq;
    else
        maxx = ans;
    if(ans == 0) ans = 1;
    if(maxx == 0) maxx = 1;
    cout << ans << " " << maxx;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main(void){

  //char s[11];
  int a,b,c = 0;
  scanf("%d %d %d", &a, &b, &c);


  if((a-b)<c) printf("%d", c-a+b);
  else printf("0");
  
  return 0;
}

  



Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
int main()
{
    string s;
    cin>>s;
    int arr[26]={0};
    for(int i=0;i<s.length();i++)
    {

        arr[s[i]-'A']=arr[s[i]-'A']+1;
    }

    for(int i=0;i<26;i++)
    {
        if(arr[i]!=0&&arr[i]!=2)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";



}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    rep(i, S.size()) if (S[i] == 'x') cnt += 1;
    if (cnt > 7) cout << "NO" << endl;
    else cout <<"YES" << endl;
    return 0;
}

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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    int N;
    cin >> N;
    int a = 1000000000, b = 1000000000;
    for (int i = 0; i < N; i++)
    {
        int A, B;
        cin >> A >> B;
        if (b >= B)
        {
            a = A;
            b = B;
        }
    }
    cout << a + b << endl;
}

Measured memory_bytes: 256
import sys
from math import gcd
input = sys.stdin.readline
n = int(input())
fish = dict()
zero = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == 0:
        if b == 0:
            zero += 1
            continue
        else:
            b = -1
    elif b == 0:
        a = 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0 and b < 0:
            a = -a
            b = -b
        elif b < 0:
            a = -a
            b = -b

    if (a, b) not in fish:
        fish[(a, b)] = 1
    else:
        fish[(a, b)] += 1

ans = 1
pair = []
mod = 10**9+7
while fish:
    key, value = fish.popitem()
    a, b = key
    if a < 0:
        if (b, -a) in fish:
            pair.append((value, fish[(b, -a)]))
            fish.pop((b, -a))
        else:
            ans *= pow(2, value, mod)
    elif b == 0:
        if (0, -1) in fish:
            pair.append((value, fish[(0, -1)]))
            fish.pop((0, -1))
        else:
            ans *= pow(2, value, mod)

    else:
        if (-b, a) in fish:
            pair.append((value, fish[(-b, a)]))
            fish.pop((-b, a))
        else:
            ans *= pow(2, value, mod)

for a, b in pair:
    temp = 1
    temp += pow(2, a, mod)-1
    temp += pow(2, b, mod)-1
    ans *= temp
    ans %= mod


print((ans+zero-1)%mod)


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

int main(){
  unsigned long n; cin >> n;
  unsigned long a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  
  sort(a,a+n);
  
  //cout << a[n/2 + 1] - a[n/2] << endl;
  cout << a[n/2] - a[n/2 -1] << endl;
  return 0;
}

Measured memory_bytes: 1024