akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}

void solve() {
    lli n, m, ans = 0;
    cin >> n >> m;

    priority_queue<lli> q;

    for (int i = 0; i < n; ++i) {
        lli x;
        cin >> x;
        q.push(x);
    }

    while (m--) {
        lli top = q.top();
        q.pop();
        q.push(top / 2);
    }

    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;
}

int main()
{
    IOS;
    //comment it out
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

int main(){
	int a,b,c,max;
	int x;
	scanf("%d %d %d", &a,&b,&c);
	scanf("%d", &x);
	
	max=a>b&&a>c?a:b>a&&b>c?b:c;
	if(a==max){
		a=0;
	}
	
	else if(b==max){
		b=0;
	}
	else c=0;
	
	for(int i=0; i<x; i++){
		max*=2;
	}
	printf("%d\n", max+a+b+c);
	
	
	return 0;
}

Measured memory_bytes: 128
import Foundation

let DEBUG = false

struct Point {
    var x: Double
    var y: Double
}

func dprint(_ str: String) {
    if DEBUG {
        print(str)
    }
}

// pからangle度回転した座標を求める
func calcMovePoint(_ p: Point, _ angle: Double) -> Point {
    let rad = angle * Double.pi / 180
    let x = p.x * cos(rad) - p.y * sin(rad)
    let y = p.x * sin(rad) + p.y * cos(rad)
    return Point(x: x, y: y)
}

let words = readLine()!.components(separatedBy: " ")
let A = Double(words[0])!
let B = Double(words[1])!
let H = Double(words[2])!
let M = Double(words[3])!

dprint("\(A) \(B) \(H) \(M)")

let angle_a = 360 / 12 * H + (360/12/60*M)
let angle_b = 360 / 60 * M

dprint("\(angle_a) \(angle_b)")

let na = calcMovePoint(Point(x: 0, y: A), angle_a)
let nb = calcMovePoint(Point(x: 0, y: B), angle_b)
dprint("na: \(na)")
dprint("nb: \(nb)")

let dx = abs(na.x - nb.x)
let dy = abs(na.y - nb.y)
let dc = sqrt(dx * dx + dy * dy)
print(dc)



Measured memory_bytes: 15204
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
    }
    SORT(a);

    int mx = *lower_bound(a.begin(), a.end(), a[N - 1] / 2);
    int mn;
    REP(i, N) if (a[i] == mx) mn = a[i - 1];

    int ans;
    abs((double)a[N - 1] / 2 - mx) < abs((double)a[N - 1] / 2 - mn) ? ans = mx
                                                                    : ans = mn;

    std::cout << a[N - 1] << " " << ans << '\n';

    return 0;
}

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

int main(void){
	int a,b,c,d,t;
	while(cin>>a>>b){
		t=a+b;
		
		c=t/1;
		if(c>=1) d=1;
		
		c=t/10;
		if(c>=1) d=2;
		
		c=t/100;
		if(c>=1) d=3;
		
		c=t/1000;
		if(c>=1) d=4;
		
		c=t/10000;
		if(c>=1) d=5;
		
		c=t/100000;
		if(c>=1) d=6;
		
		c=t/1000000;
		if(c>=1) d=7;
		
		cout<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import heapq
N = int(input())
v = list(map(int,input().split()))
heapq.heapify(v)
while len(v) > 1:
    v1 = heapq.heappop(v)
    v2 = heapq.heappop(v)
    heapq.heappush(v,(v1+v2)/2)
print(heapq.heappop(v))

Measured memory_bytes: 38384
#include <iostream>
#include <string>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s;
    cin >> t;

    int slen = s.length();
    s += s;
    int nxt[s.length()][26];
    for (int i = 0; i < 26; i++) {
        nxt[s.length()-1][i] = -1;
    }
    for (int i = s.length() - 2; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            nxt[i][j] = nxt[i+1][j];
        }
        nxt[i][s[i+1]-'a'] = i + 1;
    }

    if (nxt[0][t[0]-'a'] == -1) {
        cout << -1 << endl;
        return 0;
    }

    long long ans = s[0] == t[0] ? 0 : nxt[0][t[0]-'a'];
    for (int i = 1; i < t.length(); i++) {
        int c = nxt[ans%slen][t[i]-'a'];
        if (c == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans += c - (ans % slen);
    }

    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 21100
#include<bits/stdc++.h>
using namespace std;
int main (){
  int S,a,b;
  cin>>S;
  a=S/100;
  b=S-100*a;
  if((a>12||a==0)&&(b>12||b==0)){
    cout<<"NA"<<endl;
  }
  else if((a>12||a==0)&&12>=b&&b>0){
    cout<<"YYMM"<<endl;
  }
  else if(12>=a&&a>0&&(b>12||b==0)){
    cout<<"MMYY"<<endl;
  }
  else if(12>=a&&a>0&&12>=b&&b>0){
    cout<<"AMBIGUOUS"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[4020][4020];
typedef pair<int, int>pii;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>vec;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		vec.push_back(make_pair(za, zb));
		dp[2010 - za][2010 - zb]++;
	}
	for (int i = -2000; i <= 2000; i++)
	{
		for (int j = -2000; j <= 2000; j++)
		{
			dp[2010 + i][2010 + j] += dp[2010 + i - 1][2010 + j] + dp[2010 + i][2010 + j - 1];
			dp[2010 + i][2010 + j] %= mod;
		}
	}
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		ans += dp[2010 + vec[i].first][2010 + vec[i].second];
		ans %= mod;
	}
	invinit();
	for (int i = 0; i < num; i++)
	{
		ans += mod - com(vec[i].first * 2 + vec[i].second * 2, vec[i].first * 2);
		ans %= mod;
	}
	ans *= (mod + 1) / 2;
	ans %= mod;
	printf("%lld\n", ans);
}

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


int main(){
    string str; cin >> str;
    int n = str.length();
    vector<int> ans;
    vector<string> rlset;
    string temp = "";
    char prev = 'R';

    for(int i = 0; i < n; i++){
        if(prev == 'L' && str[i] == 'R'){
            rlset.push_back(temp);
            temp = "";
        }
        temp += str[i];
        prev = str[i];
    }
    rlset.push_back(temp);

    int rl, lr;
    //for(int i = 0; i < rlset.size(); i++) cout << rlset[i] << ' ';
    //cout << "\n";
    int temp_id;
    for(int i = 0; i < rlset.size(); i++){
        for(int j = 0; j < rlset[i].length(); j++){
            if(rlset[i][j] == 'R' && rlset[i][j+1] == 'L'){
                for(int k = 0; k < j; k++) ans.push_back(0);
                if(rlset[i].length()%2 == 0){
                    rl = rlset[i].length()/2;
                    lr = rlset[i].length()/2;
                }else if(j%2 == 0){
                    rl = (rlset[i].length()+1)/2;
                    lr = (rlset[i].length()-1)/2;
                }else{
                    rl = (rlset[i].length()-1)/2;
                    lr = (rlset[i].length()+1)/2;
                }
                ans.push_back(rl);
                ans.push_back(lr);
                for(int k = j+2; k < rlset[i].length(); k++) ans.push_back(0);
            }
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << ' ';
    cout << "\n";
}


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

int main() {
  string S;
  string T;
  cin >> S;
  cin >> T;
  int a = S.size();
  char B = T.at(a);
  if(S + B == T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int N, M;
int* A;
int num_elements;

void Push(int);
void ChangeTop();
void swapInt(int *, int *);

int main()
{
	int i, inValue;
	num_elements = 0;

	scanf("%d %d", &N, &M);
	A = (int*)malloc(sizeof(int) * N);
	for (i = 0; i < N; i++) {
		scanf("%d", &inValue);
		Push(inValue);
	}

	for (i = 0; i < M; i++) {
		ChangeTop();
	}

  long long ans = 0L;
	for (i = 0; i < N; i++)
		ans += A[i];

	printf("%lld\n", ans);

	free(A);
	return 0;
}

void Push(int value)
{
	A[num_elements++] = value;

	int ptr = num_elements - 1;
	for (; ptr > 0;) {
		int parentPtr = (ptr - 1) / 2;
		if (A[ptr] < A[parentPtr]) {
			break;
		}
		else {
			swapInt(&(A[ptr]), &(A[parentPtr]));
			ptr = parentPtr;
		}
	}
}

void ChangeTop()
{
	A[0] /= 2;

	int ptr = 0;
	int ltPtr, rtPtr, cmpPtr;
	for (; ptr < num_elements - 1;) {
		ltPtr = 2 * ptr + 1; if (ltPtr >= num_elements) break;
		rtPtr = ltPtr + 1; if (rtPtr >= num_elements) rtPtr = ltPtr;
		if (A[ltPtr] > A[rtPtr]) cmpPtr = ltPtr; // 左と右の大きいほうと比較・交換
		else cmpPtr = rtPtr;
		if (A[ptr] > A[cmpPtr]) {
			break; // A[ptr]のほうが大きければ交換終了
		}
		else {
			swapInt(&(A[ptr]), &(A[cmpPtr]));
			ptr = cmpPtr;
		}
	}
}

void swapInt(int *a, int *b)
{ int tmp = *a; *a = *b; *b = tmp; }


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            string s;
            cin >> s;
            if(s == "snuke"){
                cout << (char)('A' + j) << i + 1 << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
 
int main()
{
int a,i,j,k;
 scanf("%d",&a);
  if(a>0 && a<=100)
  {
  for(i=1;i<=9;i++)
  {
  for(j=1;j<=9;j++)
  {
  k=i*j;
    if(k==a)
    {
    printf("Yes");
      exit(0);
    }
  
   if(i==9 && j==9 && k!=a)
       printf("No");
  }
  }
  }
  }


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x,y=map(int, input().split())
    if (2*y-x)%3!=0 or (2*x-y)%3!=0:
        print(0)
    else:
        a=(2*y-x)//3
        b=(2*x-y)//3
        c=a+b

        def cmb(n, r, p):
            if (r < 0) or (n < r):
                return 0
            r = min(r, n - r)
            return fact[n] * factinv[r] * factinv[n - r] % p

        p = 10 ** 9 + 7
        N = c
        fact = [1, 1]  # fact[n] = (n! mod p)
        factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        inv = [0, 1]  # factinv 計算用

        for i in range(2, N + 1):
            fact.append((fact[-1] * i) % p)
            inv.append((-inv[p % i] * (p // i)) % p)
            factinv.append((factinv[-1] * inv[-1]) % p)

        print(cmb(c, min(a,b), p))
resolve()

Measured memory_bytes: 118764
r,c=map(int,input().split())
ans=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
	temp=list(map(int,input().split()))
	for j in range(c):
		ans[i][j]=temp[j]
	ans[i][c]=sum(temp)
for i in range(c+1):
	for j in range(r):
		ans[r][i]+=ans[j][i]
for i in range(r+1):
	for j in range(c+1):
		print(ans[i][j],end="")
		if j==c:
			print("")
		else:
			print(" ",end="")


Measured memory_bytes: 6744
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n,a,mins = INF;
	cin >> n;
	rep(i, 5) {
		cin >> a;
		mins = min(mins, a);
	}
	cout << fixed << setprecision(0)<< ceil((double)n / mins) + 4 << endl;
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int a[10100] = {0};
    int ans;
    for(int x = 1; x <= 100;x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                ans = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                if(ans > 10000) continue;
                a[ans]++;
            }
        }
    }   
    rep(i, n) cout << a[i] << endl;
    return 0;
}

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

int gcd(int a, int b) {
   int c;
   if ( a <= b ) {
       c = a;
       a = b;
       b = c;
   }
    
   if ( b == 0 ) return a;

   return gcd(b, a%b);
}

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

    cout << gcd(a, b) << endl;;
    
    return 0;
}


Measured memory_bytes: 3104
import bisect
n = int(input())
A = [int(a) for a in input().split()]
A.sort()
A_abs = [abs(ab) for ab in A]
A_abs.sort()
sum_abs = sum(A_abs)

wh = bisect.bisect_left(A, 0)
dev2 = wh % 2
if dev2 == 0:
  print(sum_abs)
else:
  print(sum_abs - 2 * A_abs[0])


Measured memory_bytes: 14464
n = int(input())
a = list(map(int, input().split()))

# dp[i][k] 列iを選択し、k個持っているときの最大値
# kは(i-1)//2 or i//2 or (i+1)//2
# それぞれki=0,1,2とする。
# 最大でも4マス前まで(oxxxo)
# iが奇数
# dp[i+2][0]=Ai + max(dp[i][0], dp[i][1], dp[i-1][1],  dp[i-2][2])
# dp[i+2][1]=dp[i+2][0]
# dp[i+2][2]=Ai + max(dp[i][2])
# iが偶数
# dp[i+2][0]=0
# dp[i+2][1]=Ai + max(dp[i][1], dp[i][2], dp[i-1][2])
# dp[i+2][2]=dp[i+2][1]

dp = [[0 for i in range(3)] for j in range(n)]
ans = 0

dp[0][2] = a[0]
ans = dp[0][2]
dp[1][0] = 0
dp[1][1] = a[1]
dp[1][2] = a[1]
ans = max([ans, dp[1][1]])

if n == 2:
    print(ans)
else:
    for i in range(2, n):
        if (i + 1) % 2 == 0:
            dp[i][0] = 0
            dp[i][1] = a[i] + max(dp[i - 2][1], dp[i - 3][2])
            dp[i][2] = dp[i][1]
        else:
            if i > 2:
                dp[i][0] = a[i] + max(dp[i - 2][0], dp[i - 3][1], dp[i - 4][2])
            else:
                dp[i][0] = a[i] + dp[i - 2][0]
            dp[i][1] = dp[i][0]
            dp[i][2] = a[i] + dp[i - 2][2]
        
    if n % 2 == 0:
        print(max(dp[-1][1],dp[-2][2]))
    else:
        print(max(dp[-1][0],dp[-2][1],dp[-3][2]))

Measured memory_bytes: 53728
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[214];
signed main() {
	cin >> n;
	rep(i, 2 * n)cin >> a[i];
	sort(a, a + 2 * n);
	int ans = 0;
	rep(i, n) {
		ans += a[i * 2];
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

char b;

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

    cin >> b;

    if (b == 'A') cout << "T\n";
    else if (b == 'T') cout << "A\n";
    else if (b == 'C') cout << "G\n";
    else cout << "C\n";

    return 0;
}



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

#define PI 3.141592653589793238462643383279
int main(){
	int n,m,a,b;
	cin >> n >> m;
	vector<int> v(n+1,100001);
	vector<set<int>> mat(n+1);
	while(m--){
		cin >> a >> b;
		mat[a].insert(b);
		mat[b].insert(a);
	}
	set<int> visited;
	visited.insert(1);
	queue<int> current;
	for(int x:mat[1]) {
		current.push(x);
		v[x]=1;
		visited.insert(x);
	}
	
	int node;
	while(!current.empty()){
		node =current.front();
		current.pop();
		for(int x:mat[node]) {
			//cout << node << ": " << x << endl;
			if(visited.count(x)==0) {
				current.push(x);
				v[x] = node;
				visited.insert(x);
			}
		}
	}
	//for(int i=0;i<=n;i++) cout << i << ": " << v[i] << endl;
	for(int i=2;i<=n;i++) {
		if(v[i]==100001) {cout << "No"; return 0;}
		
	}
	cout << "Yes" << endl;
	for(int i=2;i<=n;i++) {
		cout << v[i] << endl;
		
	}
		

	
	
}


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

int main()
{
	vector<int> vec(3);
	for (auto i = vec.begin(); i != vec.end(); i++)
	{
		cin >> *i;
	}

	vector<int> result_vec = { 5,7,5 };
	int resultcounter = 0;
	for (auto i = result_vec.begin(); i != result_vec.end(); i++)
	{
		for (auto j = vec.begin(); j != vec.end(); j++)
		{
			if (*i == *j)
			{
				*j = 1;
				resultcounter++;
				break;
			}
		}
	}

	if (resultcounter == 3)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**4)
def input():
	return sys.stdin.readline()[:-1]

class BellmanFord():
	def __init__(self, adj, start, size):
		self.adj = adj
		self.start = start
		self.size = size
		self.dist = [10**30 for _ in range(self.size)]
		self.dist[self.start] = 0

	def solve(self):
		for _ in range(self.size-1):
			for x in range(self.size):
				for y, w in self.adj[x]:
					if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
						if self.dist[y] > self.dist[x] + w:
							self.dist[y] = self.dist[x] + w
		for x in range(self.size):
			for y, w in self.adj[x]:
				if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
					if self.dist[y] > self.dist[x] + w:
						return False

		return True

	def GetDistance(self, goal):
		return self.dist[goal]

n, m, p = map(int, input().split())
adj = [[] for _ in range(n)]
adj_rev = [[] for _ in range(n)]

for _ in range(m):
	a, b, c = map(int, input().split())
	adj[a-1].append((b-1, -c+p))
	adj_rev[b-1].append(a-1)

s_reachable = [False for _ in range(n)]
s_reachable[0] = True
g_reachable = [False for _ in range(n)]
g_reachable[n-1] = True

def dfs_s(x):
	for v, w in adj[x]:
		if not s_reachable[v]:
			s_reachable[v] = True
			dfs_s(v)
	return

def dfs_g(x):
	for v in adj_rev[x]:
		if not g_reachable[v]:
			g_reachable[v] = True
			dfs_g(v)
	return

dfs_s(0)
dfs_g(n-1)

bf = BellmanFord(adj, 0, n)
if not bf.solve():
	print(-1)
else:
	print(max(-bf.GetDistance(n-1), 0))

Measured memory_bytes: 62684
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]

def insertion_sort(A, N):
    print(' '.join(str(_) for _ in A))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(' '.join(str(_) for _ in A))

insertion_sort(A, N)


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
	int x, y, flag = 0;
	cin >> x >> y;
	
	for(int i = 0; i < x+1; i++){
		if(2 * i + 4 * (x-i) == y){
			cout << "Yes" << endl;
			flag = 1;
			break;
		}
	}
	
	if(flag == 0) cout << "No" << endl;
	

	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<i64> A;

i64 calc(i64 x) {
  i64 ans = 0;
  rep(i,1,N) ans += abs(A[i] - x);
  return ans;
}

int main() {
  cin >> N;
  A.resize(N + 1);
  rep(i,1,N) cin >> A[i], A[i] -= i;

  i64 l = -1e10;
  i64 r = 1e10;

  while(r - l > 10) {
    i64 a = (l * 2 + r) / 3;
    i64 b = (l + r * 2) / 3;
    if(calc(a) < calc(b)) r = b;
    else l = a;
  }
  i64 MIN = l;
  i64 VAL = calc(MIN);
  for(int i = l;i <= r;i++) {
    i64 B = calc(i);
    if(VAL > B) {
      MIN = i;
      VAL = B;
    }
  }
  cout << VAL<< endl;
}


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


def main():
    costs = [int(input()) for _ in range(5)]
    mods = [cost % 10 for cost in costs if cost % 10 != 0]

    real_cost = []
    for cost in costs:
        if cost % 10 != 0:
            real_cost.append(cost + 10 - (cost % 10))
        else:
            real_cost.append(cost)
    total = sum(real_cost)
    if len(mods) != 0:
        min_mod = min(mods)
        print(total - (10 - min_mod))
    else:
        print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

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

int div_up(int a, int b)
{
    return (a + b - 1) / b;
}

int main()
{
    int d, g, p[11], c[11];

    cin >> d >> g;

    REP(i, d)
    cin >> p[i] >> c[i];

    int res = INT_MAX;

    for (int i = 0; i < 1 << d; i++)
    {
        int sum = 0;
        int cnt = 0;
        REP(j, d)
        {
            if (i & (1 << j))
            {
                sum += 100 * (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
        }

        if (sum >= g)
        {
            res = min(res, cnt);
            continue;
        }

        REP(j, d)
        {
            if (i & (1 << j))
                continue;

            if (sum + 100 * (j + 1) * (p[j] - 1) < g)
                continue;

            res = min(res, cnt + div_up(g - sum, 100 * (j + 1)));
        }
    }

    cout << res << endl;

    return 0;
}

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

int main(){
  int n,a;
  cin>>n>>a;
  int x[n];
  rep(i,0,n){
    cin>>x[i];
    x[i]-=a;
  }
  sort(x,x+n);
  int b=lower_bound(x,x+n,0)-x;
  int c=upper_bound(x,x+n,0)-x;
  int s=0;
  rep(i,0,b){
    s-=x[i];
  }
  ll d[b+1][s+1];
  rep(i,0,s+1){
    d[0][i]=0;
  }
  d[0][0]=1;
  rep(i,0,b){
    rep(j,0,s+1){
      if(j>=(-x[i])){
        d[i+1][j]=d[i][j]+d[i][j+x[i]];
      }
      else{
        d[i+1][j]=d[i][j];
      }
    }
  }
  
  int t=0;
  rep(i,c,n){
    t+=x[i];
  }
  ll e[n-c+1][t+1];
  rep(i,0,t+1){
    e[0][i]=0;
  }
  e[0][0]=1;
  rep(i,0,n-c){
    rep(j,0,t+1){
      if(j>=x[c+i]){
        e[i+1][j]=e[i][j]+e[i][j-x[c+i]];
      }
      else{
        e[i+1][j]=e[i][j];
      }
    }
  }
  
  ll ans=0;
  rep(i,0,min(s,t)+1){
    ans+=d[b][i]*e[n-c][i];
  }
  rep(i,0,c-b){
    ans*=2;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 1280
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    P = LI_()
    C = LI()

    ans = -INF
    for i in range(N):
        # iを含むサイクルの探索
        cycle = []
        c = i
        while True:
            c = P[c]
            cycle.append(c)
            if c == i:
                break
        len_cycle = len(cycle)
        # print(i, cycle, [C[j] for j in cycle])

        # 最大スコアの探索
        score = 0
        cycle_score_total = sum([C[j] for j in cycle])
        cycle_score_cum = list(itertools.accumulate([C[j] for j in cycle]))
        # 終了地点をjと決める
        for j in range(min(len_cycle, K)):
            score = cycle_score_cum[j]
            if cycle_score_total > 0:
                score += (K - j - 1) // len_cycle * cycle_score_total
            # print(j, score)
            ans = max(score, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


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


using namespace std;
 
int main(){
 long int N,C,K;
 long int ans = 0;

 cin >> N >> C >> K;
 vector<int> T(N);
long int count = 1;
for(int i = 0; i < N; i++) {cin >> T[i];}

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

long int tt = -1;
long int cnt = 0;
 for(int i = 0; i < N; i++){
   if(T[i] <= tt && cnt + 1 <=C){
     cnt++;
   }else{
     ans++;
     tt = T[i] + K;
     cnt = 1;
   }
 
   }
 

 cout << ans;



}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];
int b[maxn];

int n,k;


int check(int x)
{
    for(int i=1;i<=n;i++)
    {
        b[i]=a[i];
    }
    int cnt=0;
     for(int i=1;i<=n;i++)
     {
         int temp=ceil(a[i]/(double)x);
         temp--;
         cnt+=temp;

     }
     if(cnt>k)
        return 0;
     else
        return 1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ans=1e9;
    int l=1,r=1e9;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
        }
        else
            l=mid+1;
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			string s;
			cin>>s;
			if(s=="snuke"){
				cout<<(char)('A'+j-1)<<i;
				return 0;
			} 
		}
	}
}


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

int main(){
long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
cin >> n >> m >> l;
for(int i = 0; i < n; i++){
  for(int j = 0; j < m; j++){
    cin >> a[i][j];
  }
}
for(int i = 0; i < m; i++){
  for(int j = 0; j < l; j++){
    cin >> b[i][j];
  }
}
for(int i = 0; i < n; i++){
  for(int j = 0; j < m; j++){
    for(int k = 0; k < l; k++){
      c[i][k] += a[i][j] * b[j][k];
    }
  }
}
for(int i = 0; i < n; i++){
  for(int j = 0; j < l; j++){
    cout << (j == 0 ? "": " ") << c[i][j];
  }
  cout << endl;
}
}


Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int r = sc.nextInt();
        int ans = 0;
        if(num < 10){
            ans = 100 * (10 - num);
            ans = ans + r;
        }else{
            ans = r;
        }
       
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n ==7 || n == 9) cout << "hon" << '\n';
    else if(n == 3) cout << "bon" << '\n';
    else cout << "pon" << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200005],b[200005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int x1=b[n/2],x2=b[n/2+1];
	for(int i=1;i<=n;i++){
		if(a[i]<=x1)
			printf("%d\n",x2);
		else
			printf("%d\n",x1);
	}
	return 0;
} 

Measured memory_bytes: 3712
#include <stdio.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

typedef struct {
  int parent;
  int left;
  int right;
} Node;

Node node[26];

int getSibling(int id) {
  int p = node[id].parent;
  if (p == -1) return -1;

  return node[p].left == id ? node[p].right : node[p].left;
}

int getDegree(int id) {
  int cnt = 0;
  
  if (node[id].right != -1) cnt++;
  if (node[id].left != -1) cnt++;

  return cnt;
}

int getHeight(int id, int h) {
  int left;
  int right;
  if (id == -1) {
    return h - 1;
  }
  
  left = node[id].left;
  right = node[id].right;
  h += 1;
  return MAX(getHeight(left, h), getHeight(right, h));
}

int getDepth(int id, int d) {
  if (node[id].parent != -1) {
    return getDepth(node[id].parent, ++d);
  }
  else {
    return d;
  }
}

char *getType(int id) {
  if (node[id].parent == -1) {
    return "root";
  }
  else if (node[id].left == -1 && node[id].right == -1) {
    return "leaf";
  }
  else {
    return "internal node";
  }
}

void printNode(int id) {
  printf("node %d: ", id);
  printf("parent = %d, ", node[id].parent);
  printf("sibling = %d, ", getSibling(id));
  printf("degree = %d, ", getDegree(id));
  printf("depth = %d, ", getDepth(id, 0));
  printf("height = %d", getHeight(id, 0));
  printf(", %s", getType(id));
  printf("\n");
}

int main() {
  int n, id, left, right;
  int i;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    node[i].parent = -1;
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &id, &left, &right);
    node[id].left = left;
    node[id].right = right;
    if (left != -1) {
      node[left].parent = id;
    }
    if (right != -1) {
      node[right].parent = id;
    }
    
  }

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

  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int n, k, i;
	ll tmp;
	vector<ll> hp;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> tmp;
		hp.push_back(tmp);
	}

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

    for (i = 0; i < k; i++) {
		if (n - i - 1 >= 0)
			hp[n - i - 1] = 0;
	}

	tmp = 0;
	for (i = 0; i < hp.size(); i++)
		tmp += hp[i];

	cout << tmp << endl;
	
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, x;
  int ans = 0;
  
  cin >> a >> b >> c >> x;
  
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(i * 500 + j * 100 + k * 50 == x)
          ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main extends App {
  val N = readInt()
  val ls = for (_ <- 0 until N) yield {
    readInt
  }
  var maxv = -2000000000
  var minv = ls.head

  for (i <- 1 until N) {
    maxv = scala.math.max(maxv, ls(i) - minv)
    minv = scala.math.min(minv, ls(i))
  }

  println(maxv)
}


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

struct card{
  char cha;
  char value;
};

//card C[36];
//card D[36];

void BubbleSort(struct card C[],int n){
  int i, j, save;
  card trade;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
	trade = C[j];
	C[j] = C[j-1];
	C[j-1] = trade;
      }
    }
  }
}

void SelectionSort(struct card D[], int n){
  int i, j, min;
  card trade;
  for(i=0;i<n;i++){
    min = i;
    for(j=i;j<n;j++){
      if(D[j].value < D[min].value){
	min = j;
      }
    }
    trade = D[i];
    D[i] = D[min];
    D[min] = trade;
  }
}

int stableornot(struct card C[], struct card D[], int n){
  int i;
  for(i=0;i<n;i++){
    if(C[i].cha != D[i].cha){
      return 0;
    }
  }
  return 1;
}

void print(struct card A[], int n){
  for(int i = 0;i<n;i++){
    if(i>0)cout << " ";
    cout << A[i].cha << A[i].value;
  }
  cout << endl;
}


int main(){
  card C[100], D[100];
  int N;
  char ch;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> C[i].cha >> C[i].value;
  }
  
  for(int i=0;i<N;i++)D[i] = C[i];
  
  BubbleSort(C, N);
  SelectionSort(D, N);

  print(C, N);
  cout << "Stable" << endl;
  print(D, N);
  if(stableornot(C, D, N)){
      cout << "Stable" << endl;
    }else{
      cout << "Not stable" << endl;
    }

    return 0;
}


  
    

      /*int main(){
  int i, n;
  card C[100], D[100];
  char ch;

  scanf("%d",&n);
  printf("check0\n");


  for(i=0;i<n;i++){
    scanf("%c%d",&C[i].cha, &C[i].value);
    D[i] = C[i];
  }
  printf("check1\n");

  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c%d",C[i].cha, C[i].value);
  }
  BubbleSort(n);
  printf("check2\n");
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c%d",D[i].cha, D[i].value);
  }
  SelectionSort(n);
  printf("check3\n");

  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c%d",C[i].cha, C[i].value);
  }
  printf("\nStable\n");

  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%c%d",D[i].cha, D[i].value);
  }
  if(stableornot(n)) printf("\nStable\n");
  else printf("\nNot Stable\n");
  

  return 0;
}
      */



Measured memory_bytes: 3068
#include <stdio.h>

void call(int n) {
  int i = 1;
  while (++i <= n) {
    int x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    while (x) {
      if (x % 10 == 3) {
        printf(" %d", i);
        break;
      }
      x /= 10;
    }
  }
  printf("\n");
}

int main() {
  int n;
  scanf("%d", &n);
  call(n);
  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	ll n;
	cin >> n;
	cout << n / 11 * 2 + (n % 11 + 5) / 6;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 1000000007;


const int MAX_N = 100;
int p[MAX_N];

bool you[MAX_N+2];

int solve(int X,int N){
	FOR(i,N)	you[p[i]] = true;
	int ret = INF, x = INF;
	FOR(i,102){
		if(you[i])	continue;
		if(ret > abs(i-X)){
			x = i;
			ret = abs(i-X);
		}
	}
	if(ret > abs(X+1)){
		ret = X+1;
		x = -1;
	}

	return x;
}


int main(){
	int X,N; cin >> X >> N;
	FOR(i,N)	cin >> p[i];

    int ans = solve(X,N);
    printf("%d\n",ans);
}





Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << (a*b <= c * d?c*d:a*b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int SIZE = 1010;
const int MOD = 1e9 + 7;
const int INF = -1;

char tab[SIZE][SIZE];
int dp[SIZE][SIZE];
int h, w;

    void input(){
        cin >> h >> w;
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++){
                cin >> tab[i][j];
            }
        dp[1][1] = 1;
    }

signed main(){

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

    input();

    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            if(tab[i][j] != '#'){
                dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= MOD;
            }    
        
cout << dp[h][w] % MOD;
return 0;
}

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

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

    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<int> A(n);
        REP(i, n) cin >> A[i];
        sort(A.begin(), A.end());
        if(n - 2 <= 0){
            cout << 0 << endl;
            continue;
        }
        int total = 0;
        REP(i, n - 1){
            if(i) total += A[i];
        }
        cout << total / (n - 2) << endl;
    }

    return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int plan1 = n * a;
  int plan2 = b;
  
  if (plan1 < plan2) {
    cout << plan1 << endl;
  } else {
    cout << plan2 << endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
  sort(vec.begin(),vec.end(),greater<int>());
  
  cout << vec.at(0)*10 + vec.at(1) + vec.at(2);
}
  

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

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

    int n,ans = 0;
    cin >> n;
    vector<long long> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    long long s = 0;
    vector<long long> v;
    rep(i,n){
        if (a[i] < b[i]){
            s+=b[i]-a[i];
            ans++;
        }
        else v.emplace_back(a[i]-b[i]);
    }
    if (ans){
        sort(v.begin(),v.end(),greater<>());
        long long ds = 0;
        rep(i,v.size()){
            s-=v[i];
            ans++;
            if (ds >= s) break;
        }
        if (ds < s) cout << -1 << "\n";
        else cout << ans << "\n";
    }
    else cout << 0 << "\n";
}

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

int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2-d1<0){
        cout << '1';
    }else{
        cout << "0";
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var mozi = Console.ReadLine().Split(' ');
            List<string> atama = new List<string>();

            for(var x = 0;x < mozi.Length;x++)
            {
                var aaa = mozi[x];
                atama.Add(aaa[0].ToString().ToUpper());
            }

            Console.WriteLine(atama[0] + atama[1] + atama[2]);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

int main() {
	int n,x;
	int a[200005];
	cin >> n;
	memset(a,0,sizeof(a));
	for (int i=2; i<=n; i++) {
		cin >> x;
		a[x]++;
	}
	for (int i=1; i<=n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4416
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{
	ll W, H;
	cin >> W >> H;

	priority_queue<pair<int, bool>,vector<pair<int,bool>>,greater<pair<int,bool>>> s;

	for (int i = 0; i < W; i++) {
		int p;
		cin >> p;
		s.push({ p,0 });
	}
	for (int i = 0; i < H; i++) {
		int q;
		cin >> q;
		s.push({ q,1 });
	}

	int x = 0, y = 0;
	ll cost = 0;

	while (!s.empty()) {
		auto t = s.top();
		s.pop();

		if (t.second == 0) {
			cost += t.first * (H - y + 1);
			x++;
		}
		else {
			cost += t.first * (W - x + 1);
			y++;
		}
		cerr << t.first << " " << cost << endl;
	}

	cout << cost << endl;

	return 0;
}


Measured memory_bytes: 2420
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

bool s(int n){
    int a=n%10;
    while(n){
        if(n%10!=a)return 0;
        n/=10;
    }
    return 1;
}

signed main (){
    int a,b;
    cin>>a>>b;
    cout<<a-b+1<<endl;

    
}
/*
1-21-2
*/


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();
		HashMap<Integer, Integer> oddMap = new HashMap<>();
		HashMap<Integer, Integer> evMap = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (i % 2 == 0) {
				int count = 1;
				if (evMap.containsKey(x)) {
					count = evMap.get(x) + 1;
				}
				evMap.put(x, count);
			} else {
				int count = 1;
				if (oddMap.containsKey(x)) {
					count = oddMap.get(x) + 1;
				}
				oddMap.put(x, count);
			}
		}
		int oddMax = 0;
		int oddMaxNum = 0;
		int oddNext = 0;
		int oddNextNum = 0;
		for (int x : oddMap.keySet()) {
			int count = oddMap.get(x);
			if (oddMax < count) {
				oddNext = oddMax;
				oddNextNum = oddMaxNum;
				oddMax = count;
				oddMaxNum = x;
			} else if (oddNext < count) {
				oddNext = count;
				oddNextNum = x;
			}
		}
		int evMax = 0;
		int evMaxNum = 0;
		int evNext = 0;
		int evNextNum = 0;
		for (int x : evMap.keySet()) {
			int count = evMap.get(x);
			if (evMax < count) {
				evNext = evMax;
				evNextNum = evMaxNum;
				evMax = count;
				evMaxNum = x;
			} else if (evNext < count) {
				evNext = count;
				evNextNum = x;
			}
		}
		int ans;
		if (oddMaxNum == evMaxNum) {
			ans = n - Math.max(oddMax + evNext, oddNext + evMax);
		} else {
			ans = n - oddMax - evMax;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66544
#include <iostream>

int main() {
    char b;
    std::cin >> b;

    std::string result;
    if (b == 'A') {
        result = "T";
    } else if (b == 'T') {
        result = "A";
    } else if (b == 'G') {
        result = "C";
    } else if (b == 'C') {
        result = "G";
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations
ne, no = map(int,input().split())
even, odd = [i for i in range(1,2*(ne+1)) if i % 2 == 0], [i for i in range(1,2*no) if i % 2 != 0]
lst = even + odd
c = 0
for i in combinations(lst,2):
    if sum(i) % 2 == 0:
        c += 1
print(c)


Measured memory_bytes: 3060