akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
int L=0,A,B,C,D,E=0,K=0,J=0;
scanf("%d\%d\n%d\n%d\n%d",&L,&A,&B,&C,&D);
if(A%C==0){
K=A/C;
}else{
A=A/C;
K=A+1;
}
if(B%D==0){
J=B/D;
}else{
B=B/D;
J=B+1;
}
if(K>J){
L=L-K;
}else if(J>K||K==J){
L=L-J;
}
printf("%d\n",L);
return(0);
}


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

int main( void )
{
    char c[6];
    rep(i,6)
        cin >> c[i];
    
    bool ans = true;
    rep(i,3)
        if( c[i] != c[5 - i] )
            ans = false;
    
    if ( ans )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    string s;
    cin>>s;
    vector<int> c(26,0);
    rep(i,s.size()){
        c[s[i]-'a']++;
    }
    
    rep(i,26){
        if(c[i]==0){
            cout<<(char)(i+'a')<<endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import math

n=int(input())
codes=[list(map(int,input().split()))for j in range(n)]

distance=0
for i in  range(n):
  for j in range(i+1,n):
    distance +=math.sqrt((codes[i][0]-codes[j][0])**2+(codes[i][1]-codes[j][1])**2)
print(distance*2/n)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9;


ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int main() {
    string s, t; cin >> s >> t;
    for(int i=s.size()-t.size()+1; i>=0; --i){
        if(s[i]==t[0]||s[i]=='?'){
            for(int j=0; j<t.size(); ++j){
                //cout << 11 << endl;
                if(s[i+j]!=t[j]&&s[i+j]!='?') break;
                if(j==t.size()-1) {
                    for(int k=0; k<t.size(); ++k){
                        s[i+k]=t[k];
                    }
                    for(int k=0; k<s.size(); ++k){
                        if(s[k]=='?') s[k]='a';
                    }
                    cout << s << endl;
                    return 0;
                }
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
G = [[] for i in range(N+1)]
for i in range(N-1):
  a,b = map(int,input().split())
  G[a].append(b)
  G[b].append(a)
c = list(map(int,input().split()))
c.sort()
M = sum(c)-c[-1]

score = [0 for i in range(N+1)]

seen = [False for i in range(N+1)]
seen[1] = True
score[1] = c.pop()
d = deque([1])
while len(d)>0:
  v = d.pop()
  for i in G[v]:
    if seen[i] == False:
      seen[i] = True
      score[i] = c.pop()
      d.append(i)
###
print(M)
print(*score[1:])

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

typedef long long ll;

map<ll,ll>bb;


ll sol(ll x)
{
    if(x<=0) return 0;
    if(bb[x]) return bb[x];

    ll sum=0;
    ll div = x/2;

    bb[div] = sol(div);
    sum = 1+bb[div]+bb[div];

    return sum;
}

int main()
{
    ll x;cin>>x;

    ll p = sol(x);

    cout<<p<<endl;

}


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;
using P=pair<int,int>;

int main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int pre=-999;
    rep(i,n){
        if(pre<=a[i]-1) pre=a[i]-1;
        else if(pre<=a[i]) pre=a[i];
        else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		char res = Math.abs(x-a) < Math.abs(x-b) ? 'A' : 'B';
		System.out.println(res);
	}
}


Measured memory_bytes: 23764
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
t = list(t)
ans = 0
for i in range(n):
    if t[i] == 'r':
        ans += p
    elif t[i] == 's':
        ans += r
    elif t[i] == 'p':
        ans += s
for i in range(k, n):
    if t[i] == t[i - k]:
        if t[i] == 'r':
            t[i] = 'x'
            ans -= p
        elif t[i] == 's':
            t[i] = 'x'
            ans -= r
        elif t[i] == 'p':
            t[i] = 'x'
            ans -= s
print(ans)

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

using namespace std;
using ll = long long;

int main(void){
    int N, A, B;
    cin >> N >> A >> B;
    
    vector<ll> h(N);
    for(auto& it:h) cin >> it;

    A = A - B;

    auto f = [&](ll t){
        ll x = 0;
        for(auto& it : h){
            if(it > t*B) x += (it-t*B + A-1)/A;
        }
        return x <= t;
    };
   
    ll  lb = 0, ub = 1e10, mid;
    while(ub-lb > 1){
        mid = lb + (ub-lb)/2;
        if(f(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;

    return 0;
}

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

#define N 1000

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

	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
		cout << a * b << endl;
	}
	else {
		cout << -1;
	}

	return 0;
}

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

int main(void)
{
	char num_str[1002];
	int num;
	long sum =0;
	int i;
	char tmp;
	
	while (1)
	{
		fgets(num_str, sizeof(num_str), stdin);
		
		if (num_str[0] == '0') break;
		for(i = 0; i < strlen(num_str)-1; i++)
		{
			tmp = num_str[i];
			num = atoi(&tmp);
			sum = sum + num;
		}
		printf("%ld\n",sum);
		
		sum = 0;
		memset(num_str, 1002, 0);
	}
	return 0;
}

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

int main(){
  int n,m;

  while(cin >> n >> m , n + m){
    vector<int> v;
    int a;

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

    int size = v.size();
    for(int i = 0 ; i < size ; i++){
      for(int j = 0 ; j < size ; j++){
	v.push_back(v[i]+v[j]);
      }
    }
    
    sort(v.begin(),v.end());

    int ans = 0;
    for(int i = 0 ; i < v.size() ; i++){
      int want = m - v[i];
      int l = 0,r = v.size()-1;

      if(want < 0) continue;

      while(r - l > 1){
	int mid = (l+r) /2;
	if(v[mid] >= want){
	  r = mid;
	}
	else{
	  l = mid;
	}
	if(v[l] + v[i] <= m){
	  ans = max(ans,v[l]+v[i]);
	}
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 9188
N = int(input())
A = [0]+[int(i) for i in input().split()]+[0]
S = sum([abs(A[i]-A[i+1]) for i in range(N+1)])
for i in range(1,N+1):#地点A[i(1~N)]にいかなくなる
    pre = A[i-1]
    cur = A[i]
    nex = A[i+1]
    if pre<=cur<=nex or nex<=cur<=pre:
        print(S)
    else:
        d = abs(cur-pre) + abs(nex-cur) - abs(pre-nex)
        print(S-d)

Measured memory_bytes: 14048
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = [int(input()) for _ in range(N)]

cnt11=0
cnt12=0
cnt13=0
cnt21=0
cnt22=0
cnt23=0
cnt31=0
cnt32=0
cnt33=0

for i in range(N):
    if b[i]==A11:
        cnt11+=1
    elif b[i]==A12:
        cnt12+=1
    elif b[i]==A13:
        cnt13+=1
    elif b[i]==A21:
        cnt21+=1
    elif b[i]==A22:
        cnt22+=1
    elif b[i]==A23:
        cnt23+=1
    elif b[i]==A31:
        cnt31+=1
    elif b[i]==A32:
        cnt32+=1
    elif b[i]==A33:
        cnt33+=1
    else:
        pass

bingo=0
if  (cnt11>0 and cnt12>0 and cnt13>0)or(cnt11>0 and cnt21>0 and cnt31>0)or(cnt11>0 and cnt22>0 and cnt33>0)or(cnt12>0 and cnt22>0 and cnt32>0)or(cnt13>0 and cnt22>0 and cnt31>0)or(cnt13>0 and cnt23>0 and cnt33>0)or(cnt21>0 and cnt22>0 and cnt23>0)or(cnt31>0 and cnt32>0 and cnt33>0):
    bingo+=1
if bingo>0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
ll A, B, C;
vll L;

ll rec(int i, ll a, ll b, ll c)
{
    if (i == N)
    {
        if (a == 0 || b == 0 || c == 0) return INF;

        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    
    ll ans = INF;
    chmin(ans, rec(i + 1, a       , b       , c       )     );
    chmin(ans, rec(i + 1, a + L[i], b       , c       ) + 10);
    chmin(ans, rec(i + 1, a       , b + L[i], c       ) + 10);
    chmin(ans, rec(i + 1, a       , b       , c + L[i]) + 10);

    return ans;
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    in1(N);
    in3(A, B, C);

    L.resize(N);
    inN(L, N);

    outl(rec(0, 0, 0, 0));

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30

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

struct edge {
    int from,to;
    int cost;

    edge(int t,int c) : to(t),cost(c) {}
    edge(int f,int t,int c) : from(f),to(t),cost(c) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

vector<edge> G[100005];
int d[100005];
bool event[100005];

void dijkstra(int s,int n) {
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+n,INF);

    d[s] = 0;
    que.push(P(0,s));

    while(que.size()) {
        P p = que.top();
        que.pop();

        int v = p.second;
        if(d[v] < p.first) continue;

        rep(i,G[v].size()) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
        
    vector<int> v(n);
    memset(event,0,sizeof(event));
    rep(i,n) {
        G[i].clear();
        cin >> v[i];

        if(v[i] == 0) continue;
        event[i] = true;
    }

    rep(i,n) {
        if(v[i] == 0) continue;
        int next = i + v[i];
        if(next <= n-1) {
            G[i].push_back(edge(next,0));
        }
    }

    rep(i,n) {
        if(event[i]) continue;

        REP(j,1,7) {
            int next = i+j;
            if(next <= n-1) {
                G[i].push_back(edge(next,1));
            }
        }
    }

    dijkstra(0,n);
    cout << d[n-1] << endl;
    return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s ;
	cin >> s ;
	int left = 0 ;
	int right = s.size() - 1 ;
	int ans = 0 ;
	while(right > left) {
		if(s[right] == s[left]){
			left ++ ;
			right -- ;
			continue;
		}
		//片方だけx
		if(s[right] == 'x' && s[left] != 'x'){
			right -- ;
			ans ++ ;
			continue;
		}
		if(s[right] != 'x' && s[left] == 'x'){
			left ++;
			ans ++ ;
			continue;
		}
		if(s[right] != s[left] ){
			puts("-1");
			return 0 ;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,M,K;
int A[SIZE],B[SIZE];
int AS[SIZE],BS[SIZE];

struct Item{
    int i;
    int b;
    int score;
    bool operator < (const Item& that) const {
        return score > that.score;
    }
};

void solve() {
    cin>>N>>M>>K;
    REP(i,N)cin>>A[i];
    REP(i,M)cin>>B[i];
    int ans = 0;
    REP(i,N) {
        if (i) {
            AS[i] = AS[i-1] +A[i];
        } else {
            AS[i] = A[i];
        }
        if (AS[i]<=K) {
            chmax(ans, i+1);
        }
    }
    REP(i,M) {
        if (i) {
            BS[i] = BS[i-1] +B[i];
        } else {
            BS[i] = B[i];
        }
        if (BS[i]<=K) {
            chmax(ans, i+1);
        }
    }
    REP(i,N) {
        int remain = K-AS[i];
        if (remain<B[0]) {
            break;
        }
        int l=0, r=M;
        REP(i,20) {
            int m = (l+r)/2;
            if (BS[m]<=remain) l=m;
            else r=m;
        }
        chmax(ans,i+l+2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9860
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, c;
int a[1000][100];
int b[50][50];
int d[3][50];
signed main() {
	cin >> n >> c;
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			d[(i + j + 2) % 3][a[i][j]]++;
		}
	}
	int ans = Inf;
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			for (int z = 1; z <= c; z++) {
				if (i == j || i == z || j == z) continue;
				int sum = 0;
				for (int k = 1; k <= c; k++) {
					sum += b[k][i] * d[0][k];
					sum += b[k][j] * d[1][k];
					sum += b[k][z] * d[2][k];
				}
				if (sum == 1) {
					ans = 1;
				}
				ans = min(ans, sum);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

#define MOD 1000000007

int main(void){
  int i,j;
  long ans=1;

  int n;
  scanf("%d",&n);

  char str[2*n+1];
  scanf(" %s",str);

  int arr[2*n];
  for(i=0;i<2*n;i++){
    if(str[i]=='W'){
      arr[i]=0;
    }else{
      arr[i]=1;
    }
  }

  int line=0;
  for(i=0;i<2*n;i++){
    if(line==0&&arr[i]==0){
      printf("0\n");
      return 0;
    }else if((line+arr[i])%2==0){
      ans=(ans*line)%MOD;
      line--;
    }else{
      line++;
    }
  }

  if(line!=0){
    printf("0\n");
  }else{
    for(i=2;i<=n;i++){
      ans=(ans*i)%MOD;
    }
    printf("%ld\n",ans);
  }

  return 0;
}


Measured memory_bytes: 1152
from collections import deque
n,u,v=map(int,input().split())
g=[set([]) for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].add(b)
    g[b].add(a)

leaf=[]
for i in range(1,n+1):
    if(len(g[i])==1):
        leaf.append(i)

d_u=[-1 for _ in range(n+1)]
d_v=[-1 for _ in range(n+1)]

def bfs(start,d):
    d[start]=0
    q=deque([start])

    while(len(q)>0):
        qi=q.popleft()
        di=d[qi]

        next_qi=g[qi]
        for i in next_qi:
            if(d[i]==-1):
                d[i]=di+1
                q.append(i)

    return d


d_u=bfs(u, d_u)
d_v=bfs(v, d_v)


if(u in leaf and list(g[u])[0]==v):
    print(0)
else:
    ans=0
    for li in leaf:
        if(d_u[li]<d_v[li]):
            ans=max(ans,d_v[li]-1)
    print(ans)


Measured memory_bytes: 41040
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/dp/tasks/dp_a
 * Frog 1
 */
public class Main {

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

			int[] dp = new int[n];
			dp[0] = 0;
			for (int i = 0; i < n; i++) {
				if (i == 0) {
					dp[i] = 0;
				} else if (i == 1) {
					dp[i] = Integer.MAX_VALUE;
					dp[i] = mindp(dp[i], dp[i-1] + Math.abs(h[i]-h[i-1]));
				} else {
					dp[i] = Integer.MAX_VALUE;
					dp[i] = mindp(dp[i], dp[i-1] + Math.abs(h[i]-h[i-1]));
					dp[i] = mindp(dp[i], dp[i-2] + Math.abs(h[i]-h[i-2]));
				}
			}

			System.out.println(dp[n-1]);
		}
	}

	public static int mindp(int a, int b) {
		if (a > b) {
			a = b;
		}
		return a;
	}
}


Measured memory_bytes: 49100
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        if(s.charAt(0)=='o') ans++;
        if(s.charAt(1)=='o') ans++;
        if(s.charAt(2)=='o') ans++; 
        System.out.println(700+100*ans);
    }
}


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

int a,b,c,d,e,f,tmp,ansa,ansb;
double ans;
bool vis[101000];

int main()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for (int i=0;i<=(f/100)/a;i++)
		for (int j=0;j<=(f/100)/b;j++)
		{
			if (a*i*100+b*j*100>f) continue;
			if (vis[a*i+b*j]) continue;
			if (i==0 && j==0) continue;
			vis[a*i+b*j]=1;
			tmp=min(f-(a*i*100+b*j*100),(a*i+b*j)*e);
			for (int k=0;k<=tmp/c;k++)
				for (int l=0;l<=tmp/d;l++)
				{
					if (k*c+l*d>tmp) continue;
					if ((double)(k*c+l*d)/(a*i*100+b*j*100+k*c+l*d)>ans)
					{
						ans=(double)(k*c+l*d)/(a*i*100+b*j*100+k*c+l*d);
						ansa=k*c+l*d;
						ansb=a*i*100+b*j*100;
					}
				}
		}
	if (ansa==0) printf("%d %d\n",100*a,0); else
	printf("%d %d\n",ansb+ansa,ansa);
	return 0;
} 

Measured memory_bytes: 256
import networkx as nx

N=int(input())
*A,=map(int,input().split())
INF = 10**20

G = nx.DiGraph()
G.add_nodes_from(range(N+2))
for i in range(N):
  if A[i]<0:
    G.add_edge(0,i+1,capacity=-A[i])
    G.add_edge(i+1,N+1,capacity=0)
  else:
    G.add_edge(0,i+1,capacity=0)
    G.add_edge(i+1,N+1,capacity=A[i])
  
for i in range(1,N//2+1):
  for j in range(i,N+1,i):
    G.add_edge(i,j,capacity=INF)
    
flow_value,flow_dict = nx.maximum_flow(G,0,N+1)
print(sum(filter(lambda x: x>0,A))-flow_value)

Measured memory_bytes: 54112
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    set<int> st;
    REP(i,3){
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;

    return 0;
}

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


def main():
    sc = Scan()
    N = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0
    flag = 0
    for i in range(N):
        if S[i] == "A":
            flag = 1
        elif flag == 1 and S[i] == "B":
            flag = 2
        elif flag == 2 and S[i] == "C":
            count = count + 1
            flag = 0
        else:
            flag = 0

    print(count)


def dfs(N):
    global dp
    if N <= 0:
        return 1

    if dp[N] > -1:
        return dp[N]
    ans = 0
    for i in range(1, 7):
        ans += dfs(N-i)
    dp[N] = ans
    return ans


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()


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

int i,n,ans;
int a[100007];

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, c, k;
  cin >> a >> b >> c>>k;
  int m = max(a, max(b, c));
  cout << m*pow(2,k) + a + b + c - m << endl; 

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define f first 
#define s second
#define fw(i,start,end) for(lli i=start;i<end;++i)
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
        char a[10];
        cin>>a;
        if(a[2]==a[3] && a[4]==a[5])
        cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
        
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let (a, b, c, d) = scan!(i64, i64, i64, i64);
    let n = b - a + 1;
    let m = c * d / gcd(c, d);
    println!(
        "{}",
        (n) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / m - (a - 1) / m)
    )
}


Measured memory_bytes: 4352
import sys
import numpy as np

def main():
    x, y, z, K = map(int, sys.stdin.readline().split())
    abc = np.array(sys.stdin.read().split(), dtype=np.int64)
    a = abc[:x]
    b = abc[x:x + y]
    c = abc[x + y:x + y+ z]

    ab = np.sort(np.array([a[i] + b for i in range(x)]).reshape(-1))[::-1][:K]
    res = np.sort(np.array([c[i] + ab for i in range(z)]).reshape(-1))[::-1][:K]

    print('\n'.join(map(str, res)))

if __name__ == "__main__":
    main()

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

int main (){
  int A, B, ans;
  cin >> A >> B;
  
  if(A < 6){
    ans = 0;
  }else if(6 <= A && A <= 12){
    ans = B / 2;
  }else{
    ans = B;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Measured memory_bytes: 16284
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]

l = []
r = []

for i in range(m):
  l.append(a[i][0])
  r.append(a[i][1])

ans = min(r)-max(l)+1  
 
if ans <= 0:
  print(0)
else:
  print(ans)

Measured memory_bytes: 72280
N,W = map(int,input().split())
L = []
for _ in range(N):
    A,B = map(int,input().split())
    L.append((A,B))

dp = [[10**12+1 for i in range(10 ** 5 + 100)] for i in range(N + 10)]

for i in range(N):
    dp[i][0] = 0
for i in range(N ):
    for j in range(10 ** 5 + 10):
        if W >= dp[i][j] + L[i][0]:
            dp[i + 1][j + L[i][1] ] = min(dp[i][j] + L[i][0], dp[i + 1][j + L[i][1]])
        dp[i + 1][j] = min(dp[i][j],dp[i + 1][j])


for j in reversed(range(10** 5 + 10)):
    if dp[N][j] != 10**12 + 1:
        print(j)
        quit()


Measured memory_bytes: 181512
import sys
readline = sys.stdin.readline
MOD = 10**9+7
N = int(readline())

dp1 = [0]*(N+3)
Dp1 = [0]*(N+3)
dp2 = [0]*(N+3)
Dp2 = [0]*(N+3)
dp1[0] = 1
Dp1[0] = 1
dp2[0] = N-1
Dp2[0] = N-1
dp1[1] = N-1
dp2[1] = (N-1)**2
dp1[2] = N-1
dp2[2] = (N-1)**2
Dp1[1] = Dp1[0] + dp1[1]
Dp2[1] = Dp2[0] + dp2[1]
Dp1[2] = Dp1[1] + dp1[2]
Dp2[2] = Dp2[1] + dp2[2]
for i in range(3, N+1):
    dp1[i] = (dp1[i-1] + Dp1[i-3] - 1) % MOD
    dp2[i] = (dp2[i-1] + Dp2[i-3]) % MOD
    Dp1[i] = (Dp1[i-1] + dp1[i]) % MOD
    Dp2[i] = (Dp2[i-1] + dp2[i]) % MOD
print((Dp1[N-1] + Dp2[N-1]) % MOD)                 


Measured memory_bytes: 71660
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		str = str.replaceAll("^2019/", "");
		str = str.replaceAll("/.*$", "");
		if(Integer.parseInt(str) > 4) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

  if(K % 2 == 0){
    cout << K*K/4 << endl;
  }else{
    cout << (K*K - 1)/4 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			@SuppressWarnings("rawtypes")
			HashSet[] set = new HashSet[n + 1];
			for (int i = 1; i <= n; i++) {
				int m = sc.nextInt();
				set[i] = new HashSet<Integer>();
				for (int j = 0; j < m; j++) {
					int p = sc.nextInt();
					set[i].add(p);
				}
			}
			int k = sc.nextInt();
			int[] list = new int[k];
			for (int i = 0; i < k; i++) {
				list[i] = sc.nextInt();
			}
			int ans = 0;
			for (int i = 1; i <= n; i++) {
				boolean flag = true;
				for (int j = 0; j < k; j++) {
					if (!set[i].contains(list[j])) {
						flag = false;
						break;
					}
				}
				if (flag) {
					if (ans == 0)
						ans = i;
					else {
						ans = -1;
						break;
					}
				}
			}
			if (ans == 0)
				ans = -1;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 16000
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = readInts >>= print . showAnswer . solve

type Input  = [Int]
type Output = Int

solve :: Input -> Output
solve [a,b,c]
  | a*c < b = c
  | otherwise = b `div` a

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    A = LI()
    a = sorted(A,reverse=True)

    high = a[0] * 2
    low = 0
    while high > low + 1:
        mid = (high + low) // 2

        cnt = 0
        j = N - 1
        for i in range(N):
            while a[i] + a[j] < mid:
                j -= 1
                if j < 0: break
            else:
                cnt += (j+1)
                continue
            break
        if cnt <= M:
            high = mid
        else:
            low = mid

    s = [a[0]]
    for i in range(1,N):
        s.append(s[-1]+a[i])

    ans = 0
    cnt = 0
    m = a[0] * 2
    j = N - 1
    for i in range(N):
        while a[i] + a[j] < low:
            j -= 1
            if j < 0: break
        else:
            ans += a[i] * (j+1) + s[j]
            cnt += j + 1
            m = min(m,a[i] + a[j])
            continue
        break

    print(ans - (cnt-M) * m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 91492
import java.util.Scanner;

public class Main {
	public static int selectionSort(int A[], int N) {
		int count = 0;
		for (int i = 0; i < N; i++) {
			int minj = i;
			int oki;
			for (int j = i; j < N; j++) {
				if (A[j] < A[minj]) {
					minj = j;
				}
			}
			if(i!=minj) {
				oki = A[minj];
				A[minj] = A[i];
				A[i] = oki;
				count++;
				}
		}
		return count;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scanner.nextInt();
		}
		int count=selectionSort(A,N);
		for(int i=0;i<N;i++) {
			if(i!=N-1) {
			System.out.print(A[i]+" ");
		}else {
			System.out.println(A[i]);
		}
			}
		System.out.println(count);

	}

}



Measured memory_bytes: 26408
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!int;
    auto tmp = readln.split.to!(int[]);
    auto D = tmp[0], X = tmp[1];
    writeln(N.iota.map!(_ => cast(int)ceil(D / readln.chomp.to!float)).sum + X);
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);
vvi WF;

void floyd(int n) {
	REP(k, n)REP(i, n) {
		if (WF[i][k] == INF) continue;
		REP(j, n) {
			if (WF[k][j] == INF) continue;
			WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j]);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	WF = vvi(10, vi(10, 0));
	REP(i, 10)REP(j, 10)cin >> WF[i][j];
	floyd(10);
	int ans = 0;
	REP(i, H) {
		REP(j, W) {
			int a;
			cin >> a;
			if (a == -1)continue;
			ans += WF[a][1];
		}
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: usize = sc.read();
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut ans = k;
    for i in 0..n {
        let left = if i == 0 {
            a[0] + k - a[n - 1]
        } else {
            a[i] - a[i - 1]
        };
        let right = if i + 1 == n {
            k - a[n - 1] + a[0]
        } else {
            a[i + 1] - a[i]
        };

        ans = cmp::min(ans, k - left);
        ans = cmp::min(ans, k - right);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		
		Stack <Integer> S = new Stack <> ();
		
		S.push(a);
		int min = a%10;
		
		if (b%10<min && b%10!=0){
			S.add(0, b);
			min = b%10;
		}
		
		else {
			S.add(1, b);
		}
			
		if (c%10<min && c%10!=0){
			S.add(0, c);
			min = c%10;
		}
		
		else {
			S.add(1, c);
		}
		
		if (d%10<min && d%10!=0){
			S.add(0, d);
			min = d%10;
		}
		
		else {
			S.add(1, d);
		}
		
		if (e%10<min && e%10!=0){
			S.add(0, e);
		}
		
		else {
			S.add(1, e);
		}
		
		int temp = S.get(0);
		S.remove(0);
		
		while (S.isEmpty()!=true){
			int pop = S.pop();
			int rem = pop%10;
			
			if (rem!=0){
				temp+=(pop-rem+10);
				
			}
			else temp+=pop;
			
		}
		System.out.println(temp);

	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int n; cin >> n;
    vii arr;
    for (int i = 0; i < n ; i++)
    {
        int a, b; cin >> a >> b;
        arr.push_back(make_pair(b, a));
    }
    sort(arr.begin(), arr.end());
    ll count = 0; bool sol = true;
    for (int i = 0; i < n; i++)
    {
        count += arr[i].second;
        if (arr[i].first < count)
            sol = false;
    }
    if (sol)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
}

Measured memory_bytes: 5344
N = input()
An = input().split()
number_of_devided = []
n = 0


def get_number_of_devided(val):
    tmp = int(val)
    count = 0
    while tmp % 2 == 0:
        tmp = tmp / 2
        count += 1
    return count


for val in An:
    number_of_devided.append(get_number_of_devided(val))
    n += 1

print(min(number_of_devided))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }

ll gcd(ll m, ll n){
  if(m<n) swap(m,n);
  if(n==0) return m;
  return gcd(n, m%n);
}

int main() {
  cout<<fixed<<setprecision(10);

  ll n,m;cin>>n>>m;
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }

  vint x(m);rep(i,m)cin>>x[i];
  vsort(x);
  vint diff(m-1);
  ll ans = 0;
  rep(i,m-1){
    diff[i] = x[i+1]-x[i];
    ans += diff[i];
  }
  vsortgr(diff);

  rep(i,n-1){
    ans -= diff[i];
  }

  cout << ans << endl;








}

















//


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;


int main() {
    vector<int> same_digits_vec = {111, 222, 333, 444, 555, 666, 777, 888, 999};
    int N;
    cin >> N;
    for (auto same_digits: same_digits_vec) {
        if (N <= same_digits) {
            cout << same_digits << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 0; i <= 1e4; i++) {
        int tar = b*i+c;
        if (tar % a == 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3616
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;

void main()
{
  while (true){
    ulong n = readln().chomp().to!ulong;
    if (n == 0) break;
    ulong pat = shinobu(n);
    pat /= 10;
    if (pat % 10 != 0){
      pat++;
    }

    writeln(pat / 365 + 1);
  }
}

ulong shinobu(ulong n)
{
  if (n == 1) return (1);
  if (n == 2) return (2);
  if (n == 3) return (4);

  return (shinobu(n - 1) + shinobu(n - 2) + shinobu(n - 3));
}

Measured memory_bytes: 2488
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>
#include <numeric>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

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

int main() {
  ll N;
  cin >> N;
  cout << (2 * N) / gcd(2, N) << endl;
  return 0;
}


Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

X, Y, Z, K = MAP()
A = sorted(LIST(), reverse = True)
B = sorted(LIST(), reverse = True)
C = sorted(LIST(), reverse = True)

ans = []
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			if (i+1)*(j+1)*(k+1) <= K:
				ans.append(A[i]+B[j]+C[k])
			else:
				break

for a in sorted(ans)[::-1][:K]:
	print(a)


Measured memory_bytes: 18184
//by OIerC
//Forca Barcelona!
#include<cstdio>
#include<vector>
using namespace std;

inline int read()
{
 	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
vector<int> G[N];
int SG[N];

void dfs(int u, int fa)
{
	SG[u] = 0;
	for (int v : G[u]) if (v != fa)
		dfs(v, u), SG[u] ^= (SG[v] + 1);
}

int main()
{
	int n = read();
	for (int i = 1; i < n; ++i)
	{
		int u = read();
		int v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	dfs(1, 0);
	
	puts(SG[1] ? "Alice" : "Bob");
	
	return 0;
}


Measured memory_bytes: 14720