akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
int n;
bool flag = false;
cin >> n;

for(int i=0; i<10;i++){
    for (int j=0; j<10;j++){
        if(n == i *j){
            flag = true;
            }
        }
    }
if(flag) printf("Yes");
else printf("No");

return 0;
}

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

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

int main(){
    int n;
    while(cin >> n && n > 0){
        if(n == 1){
            cout << 0 << endl;
            continue;
        }
        if(n == 2) {
            int p1, t1, p2, t2;
            cin >> p1 >> t1 >> p2 >> t2;
            cout << abs(p1 - p2) << endl;
            continue;
        }
        vector<int> p1;
        vector<int> p2;
        p2.reserve(n * n);
        vector<P> pv;
        REP(i, n) {
            int p, t;
            cin >> p >> t;
            if(t == 1){
                p1.push_back(p);
            }else{
                pv.push_back(P(p, t));
            }
        }

        sort(pv.begin(), pv.end());
        REP(i, pv.size() - 1) pv[i].second --;
        REP(i, pv.size() - 1) pv[i + 1].second --;
        REP(i, pv.size()){
            REP(_, pv[i].second){
                p2.push_back(pv[i].first);
            }
        }

        int n1 = p1.size();
        int n2 = p2.size();

        if(n1 > n2) {
            cout << -1 << endl;
            continue;
        }

        sort(p1.begin(), p1.end());
        sort(p2.begin(), p2.end());

        long long ans = *max_element(p2.begin(), p2.end()) - *min_element(p2.begin(), p2.end());
        // cout << ans << endl;
        // cout << "p1 : "; REP(i, p1.size()) cout << p1[i] << " "; cout << endl;
        // cout << "p2 : "; REP(i, p2.size()) cout << p2[i] << " "; cout << endl;

        vector<long long> dp(2 * n1, 0);
        int last_base2 = -1;
        for(int i1 = 0; i1 < n1; i1++){
            vector<long long> next(2 * n1, LLONG_MAX);
            int base2 = lower_bound(p2.begin(), p2.end(), p1[i1]) - p2.begin();
            for(int di = 0; di < 2 * n1; di++){
                int i2 = di - n1 + base2;
                if(i2 >= 0 && i2 < n2){
                    if(i1 == 0) {
                        next[di] = abs(p1[i1] - p2[i2]);
                        continue;
                    }

                    int lastdi = di + (base2 - last_base2) - 1;
                    if(lastdi < 0) continue;

                    long long last = (lastdi < 2 * n1 ? dp[lastdi] : dp.back());
                    if(last == LLONG_MAX) continue;

                    next[di] = last + abs(p1[i1] - p2[i2]);
                    // printf("i1 = %d i2 = %d di = %d base = %d lastdi = %d last = %lld next[%d] <- %lld + %lld = %lld\n", i1, i2, di, base2, lastdi, last, di, last, abs(p1[i1] - p2[i2]), next[di]);
                }
            }
            for(int j = 1; j < 2 * n1; j++){
                next[j] = min(next[j], next[j - 1]);
            }
            last_base2 = base2;
            dp.swap(next);
        }

        cout << ans + (n1 != 0 ? dp.back() : 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 67936
class MP:
    def __init__(self,p):
        # Preprocess: Longest border
        self.pattern = p
        n = len(p)
        A = [-1]*(n+1)
        j = -1
        for i in range(n):
            while j >= 0 and p[j] != p[i]:
                j = A[j]
            j += 1
            A[i+1] = j
        self.border = A

    def findall(self, t):
        p = self.pattern
        A = self.border
        res = list()
        j = 0
        for i in range(len(t)):
            while j >= 0 and p[j] != t[i]:
                j = A[j]
            j += 1
            if j == len(p):
                res.append(i-j+1)
                j = A[j]
        return res

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

axor=[0]*n
bxor=[0]*n

for i in range(n-1):
    axor[i] = a[i] ^ a[i+1]
    bxor[i] = b[i] ^ b[i+1]

axor[-1] = a[0] ^ a[-1]
bxor[-1] = b[0] ^ b[-1]

m = MP(bxor)
kls = m.findall(axor + axor[:-1])

for k in kls:
    x = b[0] ^ a[k]
    print(k,x)

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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
    int N;
    IN(N);
    vector<double> A(N);
    double sum = 0;
    REP(i, N) {
        IN(A[i]);
        A[i] = 1 / A[i];
        sum += A[i];
    }
    OUT(1 / sum);
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    long long n,m;
    cin>>n>>m;
    if(n*2==m)
    cout<<n;
    if(n*2>m)
    cout<<m/2;
    if(n*2<m)
    cout<<n+(m-(n*2))/4;

    return 0;
}    
    
     
    
     

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

double calc_dist(ll x1, ll y1, ll x2, ll y2){
    const double dx = x1 - x2;
    const double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}

int main(){
    ll xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    ll n;
    cin >> n;

    vector<pair<ll, ll>> xy(n + 2);
    vector<ll> r(n + 2);

    xy.at(0) = {xs, ys};
    xy.at(1) = {xt, yt};
    r.at(0) = 0;
    r.at(1) = 0;

    REP(i, n){
        ll xi, yi, ri;
        cin >> xi >> yi >> ri;
        xy.at(i + 2) = {xi, yi};
        r.at(i + 2) = ri;
    }

    vector<double> dist(n + 2, numeric_limits<double>::max());
    dist.at(0) = 0;
    reverse_priority_queue<pair<double, ll>> que;
    que.emplace(0, 0);
    while(!que.empty()){
        const auto p = que.top(); que.pop();
        const ll i = p.second;
        if(p.first > dist.at(i)){ continue; }
        for(ll j = 1; j < n + 2; ++j){
            if(i == j){ continue; }
            double d = max(0.0, calc_dist(
                xy.at(i).first, xy.at(i).second, xy.at(j).first, xy.at(j).second
            ) - r.at(i) - r.at(j));
            if(dist.at(j) > dist.at(i) + d){
                dist.at(j) = dist.at(i) + d;
                que.emplace(dist.at(j), j);
            }
        }
    }
    printf("%.10f\n", dist.at(1));
    return 0;
}


Measured memory_bytes: 7556
import java.util.*;
public class Main {
    public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();
    
    
    for(int i =0;i<n;i++){
        int a = sc.nextInt();
        if(map.containsKey(a)){
            map.put(a, map.get(a)+1);
			} else {
				map.put(a, 1);
			}
        }
        int max = map.lastKey();
        boolean[]  b = new boolean[max+1];
        for(int i =0;i<max+1;i++){
            b[i] = true;
        }
        
        for(int key :map.keySet()){
         if(b[key] == false){
             continue;
         }
             for(int i =2;i*key<=max;i++){
                 b[i*key] = false;
             
         }
        }
        
        int ans = 0;
        for(int key : map.keySet()){
            if (map.get(key) == 1 && b[key] == true){
				ans++;
			}
        }
        System.out.println(ans);
    }
    }


Measured memory_bytes: 71448
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

vecll done,a,at,LL,L,R,RR;
int n;

int main(){
    n=in();
    a.resize(n+2);
    at.resize(n+2);
    L.resize(n+2);
    LL.resize(n+2);
    R.resize(n+2);
    RR.resize(n+2);
    a[0]=0;
    a[n+1]=n+1;
    at[0]=0;
    at[n+1]=n+1;
    rep2(i,1,n){
        a[i]=in();
        at[a[i]]=i;
    }
    done={0,n+1};
    L[n+1]=0;
    R[n+1]=n+1;
    rep3(x,n,1){
        auto itr = upper_bound(ALL(done),at[x]);
        L[x]= *(itr-1);
        R[x]= *itr;
        LL[x]=itr!=done.begin()+1?*(itr-2):0;
        RR[x]=itr!=done.end()-1?*(itr+1):n+1;
        done.insert(itr,at[x]);
    }
    ll ans=0;
    for(ll i=1;i<n;i++)ans += i*((RR[i]-R[i]) * (at[i]-L[i]) + (L[i]-LL[i]) * (R[i]-at[i]));
    cout<<ans<<endl;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    
    vector<long long> p(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }

    vector<long long> p_sum(n-k+1,0);
    for (int i = 0; i < k; i++){
        p_sum[0]=p_sum[0]+p[i];
    }
    for (int i = 1; i < n-k+1; i++){
        p_sum[i]=p_sum[i-1]-p[i-1]+p[i-1+k];
    }

    long long maxp_sum=0;
    for (int i = 0; i < n-k+1; i++){
        maxp_sum=max(maxp_sum,p_sum[i]);
    }
    double ans=0.5*(double)k+(double)maxp_sum/2.0;

    cout << fixed << setprecision(13) << ans << endl;
}


Measured memory_bytes: 6260
N,M=map(int,input().split())
C = [0]*(N+1)
D = []
for i in range(M):
  P,Y=map(int,input().split())
  D.append([i,P,Y])
D.sort(key=lambda x:x[2])
for i in range(M):
  P = D[i][1]
  R = C[P] + 1
  C[P] = R
  st = '{0:06d}'.format(P)
  st = st + '{0:06d}'.format(R)
  D[i] = [D[i][0],st]
D.sort(key=lambda x:x[0])
for i in range(M):
  print(D[i][1])

Measured memory_bytes: 31436
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)
unsigned GetDigit(unsigned num){
    if(num == 0)return 1;
    return log10(num)+1;
}

int main(){
    int N,K;cin >> N >> K;
    vector<int> D(K);
    rep(i,K)cin >> D[i];
    int ans = N;
    bool ok = true;
    for(int i = N;i < 100000;i++){
        int keta = GetDigit(i);
        ok = true;
        for(int j = 1;j <= keta;j++){
            int tmp = 0;
            tmp = i % (int)pow(10,j);
            tmp = tmp / (int)pow(10,j-1);      //  tmpにj桁目の数字を格納  
            rep(k,K){
                if(tmp == D[k])ok = false;
            }
        }
        if(ok){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}



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

int main(){
	// sengen
	int n,d;
	// nyuryoku
	cin >> n >> d;
	int x[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin >> x[i][j];
		}
	}
	// keisan
	int ans = 0;
	for(int i=0;i<n-1;i++){
		int wa = 0;
		for(int j=i+1;j<n;j++){
			wa = 0;
			for(int k=0;k<d;k++){
				wa += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			if(floor(sqrt(wa)) == sqrt(wa)){
				ans++;
			}
		}
		
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 3572
import itertools

N = int(input())
P = tuple(input().split())
Q = tuple(input().split())
P_num = -1
Q_num = -1

onetoN = ""
for i in range(1, N+1):
    onetoN += str(i)

permu_list = list(itertools.permutations(onetoN))

for i in range(len(permu_list)):
    if P == permu_list[i]:
        P_num = i+1
    if Q == permu_list[i]:
        Q_num = i+1

print(abs(Q_num-P_num))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)
 
 
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (b <= a) {
        cout << "delicious" << endl;
    } else if (b <= a + x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}

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

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

struct P {
  char dir;
  int pos, t;
  P() { t = 0; }
  P(char d, int p, int t) : dir(d), pos(p), t(t) {}
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, l;
  while (cin >> n >> l, n) {
    vector<P> now(n), next = now;
    for (int i = 0; i < n; i++) {
      cin >> now[i].dir >> now[i].pos;
    }

    while (true) {
      bool update = false;
      for (int i = 0; i < n; i++) {
        int pos = now[i].pos;
        if (pos == 0 || pos == l) {
          next[i] = now[i];
        } else {
          if (now[i].dir == 'R') {
            next[i] = P('R', pos + 1, now[i].t + 1);
            for (int j = 0; j < n; j++) {
              if (pos + 2 < l && now[j].dir == 'L' && now[j].pos == pos + 2) next[i] = P('L', pos + 1, now[i].t + 1);
            }
          } else {
            next[i] = P('L', pos - 1, now[i].t + 1);
            for (int j = 0; j < n; j++) {
              if (pos - 2 > 0 && now[j].dir == 'R' && now[j].pos == pos - 2) next[i] = P('R', pos - 1, now[i].t + 1);
            }
          }
          update = true;
        }
      }
      swap(now, next);
      if (!update) break;
    }

    int ansl = -1, ansr = -1;
    for (int i = 0; i < n; i++) {
      if (now[i].dir == 'L' && (ansl < 0 || now[i].t > now[ansl].t)) ansl = i;
      if (now[i].dir == 'R' && (ansr < 0 || now[i].t > now[ansr].t)) ansr = i;
    }
    
    int tl = ansl < 0 ? 0 : now[ansl].t, tr = ansr < 0 ? 0 : now[ansr].t;
    if (tl >= tr) cout << tl << " " << ansl + 1 << endl;
    else cout << tr << " " << ansr + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3120
from collections import defaultdict
from itertools import groupby

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    
    def cmb(n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)

        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
    
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
    
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
    
        return result

    B = sorted(A)
    d = defaultdict(int)
    gr = groupby(B)
    
    s = 0
    for key, group in gr:
        c = len(list(group))
        d[key] = c
        s += cmb(c, 2)
    
    for a in A:
        ans = s - cmb(d[a], 2) + cmb(d[a]-1, 2)
        print(ans)
    
solve()

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int n, ans=0;
    cin >> n;
    REP(i, 1, n+1){
        int divN=0;
        if(i%2==0) continue;
        REP(j, 1, i+1){
            if(i%j==0) divN++; 
        }
        if(divN==8) ans++;
    }
    P(ans);
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int x,y; cin >>x >>y;
  bool ok = false;
  for (int i=0; i<=x; i++){
    int j = x - i;
    if (i * 2 + j * 4 == y) ok = true;
  }
  cout <<(ok ? "Yes" : "No") <<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int Nmax=200010;
 
int main() {
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int price=0;
	
	if(A > B) price += B;
	else price += A;
	
	if(C > D) price += D;
	else price += C;
	
	cout << price << endl;
	
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];

    ll ans=0,m=a[0];

    repa(i,1,n){
        if(a[i]<m)ans+=m-a[i];
        else m=a[i];
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 4044
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
      c=0;
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      if (a+b == 0) break;
		}catch(Exception e){
      break;
    }

    for(i = 1;i <= a-2;i++){
      for(j = 1;j <= a-1;j++){
        for(k = 1;k <= a;k++){
          if(i < j && j < k && i+j+k == b){ 
            c++;
          }

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


Measured memory_bytes: 25372
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

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

  int a, b; cin >> a >> b;
  cout << max(0, a - b - b) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
    cin>>x;
    int a=0,b=0;
    while(x>=500){
    	x -=500;
        a ++;
    }
    while(x>=5){
        x -= 5;
        b++;
    }
    long long ans;
    ans =1000*a+5*b;
    cout<<ans<<endl;
    }
    

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

bool isnum(string s) { return '0' <= s[0] && s[0] <= '9'; }
int toi(string s) { return s[0]-'0'; }
int calc(string op, int a, int b) { return (op == "+") ? a + b : a * b; }

int parse(vector<string> vs) {
    if (isnum(vs[0])) return toi(vs[0]);

    for (int i=1; i<(int)vs.size(); ++i) {
        vs[i] = vs[i].substr(1);
    }
    int res = (vs[0] == "+" ? 0 : 1);
    int k = 1;
    while (k < (int)vs.size()) {
        if (isnum(vs[k])) {
            res = calc(vs[0], res, toi(vs[k++]));
         } else {
            vector<string> t(1, vs[k++]);
            while (k < (int)vs.size() && vs[k][0] == '.') {
                t.push_back(vs[k++]);
            }
            res = calc(vs[0], res, parse(t));
        }
    }
    return res;
}

int main() {
    int n;
    while (cin >> n) {
        if (!n) break;
        vector<string> vs(n);
        for (int i=0; i<n; ++i) {
            cin >> vs[i];
        }
        cout << parse(vs) << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int wk = Math.max(a+b, a-b);

		// 出力
		System.out.println(Math.max(wk, a*b));
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int n;
  cin >> n;
  n%=10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
  else cout << "bon" << endl;
}

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

vector<int> dig {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void add_print(const string &s, int id) {
    if(id == -1) {
        putchar('0' + dig[dig[0] == 0]);
        return;
    }
    auto it = upper_bound(dig.begin(), dig.end(), s[id] - '0');
    if(it == dig.end()) {
        add_print(s, id - 1);
        putchar('0' + dig.front());
    } else {
        printf("%s%d", s.substr(0, id).c_str(), *it);
    }
}

int main() {
    ios::sync_with_stdio(false);
    string n;
    int K;
    cin >> n >> K;
    for(int i = 1; i <= K; i++) {
        int val;
        cin >> val;
        dig.erase(lower_bound(dig.begin(), dig.end(), val));
    }
    for(size_t i = 0; i < n.length(); i++) {
        auto it = lower_bound(dig.begin(), dig.end(), n[i] - '0');
        if(it == dig.end() || *it != n[i] - '0') {
            add_print(n, i);
            for(size_t j = 0; j < n.length() - i - 1; j++) putchar('0' + dig.front());
            return 0;
        }
    }
    cout << n << "\n";
    return 0;
}


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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

ll N;
vector<ll> A;

void dump(map<ll,ll> &mp){
    vector<ll> v(20);
    for (const auto &m: mp){
        v[m.first] = m.second;
    }

    rep(i,0,20){
        cout<<v[i];
    }
    cout<<endl;
}


bool countup(map<ll,ll> &mp, ll K, ll pos){
    ll end=pos;
    auto it = mp.find(0); //dummy
    while (it=mp.find(pos), it!=mp.end() && it->second == K-1){
        pos--;
    }
    if (pos>=0){
        mp[pos]++;

        // rep(i,pos+1,end+1){
        //     mp.erase(i);
        // }
        mp.erase(mp.lower_bound(pos+1), mp.end());

        return mp[pos]<K;
    }else{
        return false;
    }
}

bool check(ll K){
    map<ll,ll> mp; // pos -> value
    // dump(mp);
    rep(i,1,N){
        if (A[i]>A[i-1]){
            // noop
            ;
        } else if (A[i]==A[i-1]) {
            // count up

            // 0    1  2  3    4    5
            // K-1, 0, 3, K-1, K-1, K-1
            if (!countup(mp, K, A[i]-1))
                return false;
        } else {
            // A[i]<A[i-1]
            // get prefix + count up
            
            // rep(pos, A[i], A[i-1]){
            //     mp.erase(pos);
            // }
            mp.erase(mp.lower_bound(A[i]), mp.end());

            if (!countup(mp, K, A[i]-1))
                return false;
        }
        // dump(mp);
    }

    return true;
}

signed main() {
    // map<ll,ll> mp;
    // mp.insert(PLL(0,2));
    // mp.insert(PLL(1,1));
    // mp.insert(PLL(2,0));
    // mp.insert(PLL(3,9));
    // mp.insert(PLL(4,9));
    // mp.insert(PLL(5,9));
    // dump(mp);
    // countup(mp, 10, 5);
    // dump(mp);
   
    cin>>N;
    rep(i,0,N){
        ll x;
        cin>>x;
        A.push_back(x);
    }

    // ll c1 = check(1); cout<<"check(1)="<<c1<<endl;
    // ll c2 = check(2); cout<<"check(2)="<<c2<<endl;
    // ll c3 = check(3); cout<<"check(3)="<<c3<<endl;

    ll L=0,R=1e11;
    while(L+1<R){
        ll m = (L+R)/2;
        if (check(m))
            R=m;
        else
            L=m;
    }
    cout<<R<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int h, w;
	string s;
	vs a;
	cin >> h >> w;
	rep(i, h) {
		cin >> s;
		a.pb(s);
	}
	rep(i, w + 2) cout << '#';
	cout << endl;
	rep(i, h) cout << '#' << a[i] << '#' << endl;
	rep(i, w + 2) cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
var main = function(input) {

var array =input.split('\n')
  var ar=array[0].split(' ').map(x=>parseInt(x));
  var N=ar[0];
  var M=ar[1];
  var X=ar[2];
  var Y=ar[3];
var xn=array[1].split(' ').map(x=>parseInt(x));
  xn=xn.sort((a, b) => a - b);
var ym=array[2].split(' ').map(x=>parseInt(x));
  ym=ym.sort((a, b) => a - b);
for(var z=X+1;z<=Y;z++){
  if(xn[N-1] < z && z <= ym[0]){
    console.log('No War');
    return 0;
  }
}
  
  console.log('War');
    return 0; 
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

string S;
int N;
long long ans = 0;

void check_A(int ind);

int main() {

    cin >> S;
    string target = "BC";     // 検索文字列
    string replacement = "D"; // 置換文字列
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = S.find(target, pos)) != std::string::npos) {
        S.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }

    N = S.size();

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A') cnt++;
        else if (S[i] == 'D') {
            ans += cnt;
        }
        else cnt = 0;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define M 100008
using namespace std;
int f[M],sum[M],st[M],ne[M];
int zm(int x)
{
	return f[x]==x?x:f[x]=zm(f[x]);
}
void jiebai (int x,int y)
{
	int f1=zm(f[x]),f2=zm(f[y]);
	if(f1!=f2)f[f1]=f2;
	return;
}
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=m;++i)
	{
		int a,b;
		cin>>a>>b;
		st[a]++;
		st[b]++;
		jiebai(a,b);
	}
	for(int i=1;i<=n;++i)
	{
		f[i]=zm(i);
	}
	for(int i=1;i<=n;++i)
	{
		sum[f[i]]++;
	}
	for(int i=1;i<=k;++i)
	{
		int a,b;
		cin>>a>>b;
		if(f[a]==f[b])
		{
			ne[a]++;
			ne[b]++;
		}
	}
	for(int i=1;i<=n;++i)
	{
		int ans=sum[f[i]]-st[i]-ne[i]-1;
		cout<<ans<<" ";
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, long long Q, std::vector<long long> A){
	long long numofCorrect[N]={};
	int i;
	for(i=0;i<Q;i++){
		numofCorrect[A[i]-1]++;
	}
	for(i=0;i<N;i++){
		if(K>Q-numofCorrect[i]){
			cout  << YES << endl;
		}else{
			cout  << NO << endl;
		}
	}

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll H[200010];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> H[i];
	sort(H, H+N, greater<>());
	ll ans=0;
	for(int i=K; i<N; ++i) ans += H[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#abc151c
import sys
n,m=map(int,raw_input().split())
fac=[0]*(n+1)
fwa=[0]*(n+1)
ac=0
wa=0
l=[]
for i in range(m):
 p,s=map(str,raw_input().split())
 p=int(p)
 if fac[p]==0:
  if s=='AC':
   fac[p]=1
   ac+=1
   wa+=fwa[p]
  else:
   fwa[p]+=1
print ac,wa


Measured memory_bytes: 7300
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
long long int mod = 1000000007;
int main()
{
  int a;
  cin>>a;
  unordered_map<string, int> mp;
  while(a--)
  {
    string s;
    cin>>s;
    mp[s]=1;
  }

  cout<<mp.size()<<"\n";
  return 0;
}


Measured memory_bytes: 17724
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>tree[100005];
int color[100005];
bool visited[100005];
vector<int>path;
bool dfs(int curr){
	visited[curr] = true;
	if(curr==n){
		path.push_back(n);
		return true;
	}
	bool ret = 0;
	for(int i=0; i<tree[curr].size(); i++){
		int nxt = tree[curr][i];
		if(!visited[nxt]){
			ret|=dfs(nxt);
		}
	}
	if(ret) path.push_back(curr);
	return ret;
}
void black(int curr){
	visited[curr] = true;
	color[curr] = 1;
	for(int i=0; i<tree[curr].size(); i++){
		int nxt = tree[curr][i];
		if(!visited[nxt] && color[nxt]!=2) black(nxt);
	}
}
void white(int curr){
	visited[curr] = true;
	color[curr] = 2;
	for(int i=0; i<tree[curr].size(); i++){
		int nxt = tree[curr][i];
		if(!visited[nxt] && color[nxt]!=1) white(nxt);
	}
}

int main(){
    cin>>n;
    for(int i=1; i<n; i++){
    	int a,b;
    	cin>>a>>b;
    	tree[a].push_back(b);
    	tree[b].push_back(a);
	}
	dfs(1);
	memset(visited,0,sizeof(visited));
	if(path.size()%2){
		for(int i=0; i<path.size()/2; i++){
			color[path[i]] = 2;
		}
		for(int i=path.size()/2; i<path.size(); i++){
			color[path[i]] = 1;
		}
	}
	else{
		for(int i=0; i<path.size()/2; i++){
			color[path[i]] = 2;
		}
		for(int i=path.size()/2; i<path.size(); i++){
			color[path[i]] = 1;
		}
	}
	black(1);
	white(n);
	int b = 0;
	for(int i=1; i<=n; i++){
		if(color[i]==1) b++;
	}
	int w = n-b;
	if(b>w) cout<<"Fennec";
	else cout<<"Snuke";
}

Measured memory_bytes: 15980
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];
    vector<vector<int>> cnt(h, vector<int>(w));
    // 縦方向
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if (grid[i][j] == '#') continue;
            if (done[i]) continue;
            int offset = 0;
            while (i+offset<h) { 
                if (grid[i+offset][j] == '#') break;
                ++offset;
            }
            rep(k, offset) {
                cnt[i+k][j] += offset;
                done[i+k] = 1;
            }
        }
    }
    // 横
    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if (grid[i][j] == '#') continue;
            if (done[j]) continue;
            int offset = 0;
            while (j+offset<w) { 
                if (grid[i][j+offset] == '#') break;
                ++offset;
            }
            rep(k, offset) {
                cnt[i][j+k] += offset;
                done[j+k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) chmax(ans, cnt[i][j]-1);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;

  cin >> n;

  n %= 100;
  n %= 10;

  if (n == 3){
    cout << "bon" << endl;
  } else if (n == 0 || n == 1 || n == 6 || n== 8){
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

int main()
{
    boost;
    int n,h[N],i,ans[N];
    
    cin>>n;
    for(i=0;i<n;i++) cin>>h[i];
    
    ans[0]=0;ans[1]=abs(h[1]-h[0]); 
    
    for(i=2;i<n;i++)
    {
        ans[i] = min( ans[i-1] + abs(h[i-1]-h[i]), ans[i-2] + abs(h[i-2]-h[i]) ) ; 
    }
    
    cout<<ans[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
s = str(input())

import itertools
ans = 0
rep = len(s) - 1
operators = ('', '+')

for opers in itertools.product(operators, repeat=rep):
  #print(opers)
  formula = s[0]
  for oper, num in zip(opers, s[1:]):
    formula += oper + num
  #print(formula)
  ans += sum(map(int, formula.split('+')))

print(ans)

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

int main()
{
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; ++i) scanf("%d", &A[i]);

    sort(A, A + N, greater<int>());
    //for(int i = 0; i < N; ++i) cout << A[i] << " ";
    //cout << endl;
    vector<pair<int, int>> Q;
    for(int i = 0; i < N; ++i) {
        if(i == 0) {
            Q.push_back(make_pair(A[i], 1));
            continue;
        }

        int cur = Q.size()-1;
        int prev = Q[cur].first;
        if(A[i] != prev) {
            Q.push_back(make_pair(A[i], 1));
        }
        else {
            ++Q[cur].second;
        }

    }
    vector<int> P;
    vector<int> R;
    for(int i = 0; i < Q.size(); ++i) {
        if(Q[i].second >= 4) R.push_back(Q[i].first);
        if(Q[i].second >= 2) P.push_back(Q[i].first);
    }

    ll res = 0;
    if(R.size() >= 1) res = max(res, (ll)R[0] * (ll)R[0]);
    if(P.size() >= 2) res = max(res, (ll)P[0] * (ll)P[1]);
    printf("%lld\n", res);
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; i + j <= s.size(); j++) {
      bool f = true;
      string t = s.substr(i, j);
      for (auto &c : t) {
        f &= (c == 'A') || (c == 'C') || (c == 'G') || (c == 'T');
      }
      if (f) {
        ans = max(ans, j);
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[28];
	int i,j;
	for(i=0;i<28;i++){
		scanf("%d",&a[i]);
	}
	for (i=1;i<=30;i++)
	{
		for (j=0;j<28;j++)
		{
			if (i==a[j])
			{
				break;
			}
		}
		if (j==28)
		{
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 596
line = STDIN.gets.strip

alphabets = Array.new(26, 0)
line.each_char do |char|
  alphabets[char.ord - 'a'.ord] = 1
end

answer = alphabets.find_index do |n|
  n == 0
end

if answer
  puts ('a'.ord + answer).chr
else
  puts 'None'
end

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n; cin >> n;
    for (int ni = 0; ni < n; ni++) {
        int p; cin >> p;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == p) a[i][j] = 0;
            }
        }
    }
    bool ok = false;
    for (int i = 0; i < 3; i++) {
        bool tmp1 = true, tmp2 = true;
        for (int j = 0; j < 3; j++) {
            tmp1 &= (a[i][j] == 0);
            tmp2 &= (a[j][i] == 0);
        }
        ok |= tmp1 | tmp2;
    }
    bool tmp1 = true, tmp2 = true;
    for (int i = 0; i < 3; i++) {
        tmp1 &= (a[i][i] == 0);
        tmp2 &= (a[i][2-i] == 0);
    }
    if (ok | tmp1 | tmp2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  vector<int> v(N);
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  vector<int> c(N);
  for(int i=0;i<N;++i){
    cin>>c[i];
  }
  
  int ans=0;
  for(int i=0;i<N;++i){
    int diff=v[i]-c[i];
    if(diff>0)
      ans+=diff;
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, UV, S, T):
    G = defaultdict(list)
    for u, v in UV:
        G[u-1].append(v-1)
    
    S -= 1
    T -= 1
    # print(G)
    d = [defaultdict(lambda: sys.maxsize) for _ in range(N)]
    q = deque([(S, 0, 0)])
    while q:
        u, md, cd = q.popleft()
        if md not in d[u]:
            d[u][md] = min(d[u][md], cd)
            nd = (md+1) % 3
            for v in G[u]:
                q.append((v, nd, cd+1))

    if 0 in d[T]:
        return math.ceil(d[T][0] / 3)
    return -1


def main():
    N, M = read_int_n()
    UV = [read_int_n() for _ in range(M)]
    S, T = read_int_n()
    print(slv(N, M, UV, S, T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 104456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		int ans = Math.min(a, b)  + Math.min(c, d);
		System.out.println(ans);


	}
}

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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;
    ll t,n;
    cin >> t>>n;
    ll dist=n*n;
    ll x,y;
    int cnt=0;
    while(t--)
    {
        cin>>x>>y;
        ll tmp=(x*x)+(y*y);
        
        if(dist>=tmp)
            cnt++;
    }

    cout<<cnt;
}

Measured memory_bytes: 3656
"use strict";

function main(arg) {
    //    console.log(arg.trim().split("\n"));
    let ary = arg.trim().split(" ").map(n => Number(n));
    let THp = ary.shift();
    let TAt = ary.shift();
    let AHp = ary.shift();
    let AAt = ary.shift();
    // Takahashi Atack 回数
    let TX = Math.ceil(AHp/TAt);
    let AX = Math.ceil(THp/AAt);

    console.log((TX<=AX) ? 'Yes' : 'No');

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 29628
INF = 10000000

def bf(es, dist, c, s, d):
    dist[s][0] = 0

    isUpdated = True
    while isUpdated:
        isUpdated = False
        for e in es:
            a, b, f = e
            for i in range(c+1):
                if dist[a][i] != INF and dist[a][i] + f < dist[b][i]:
                    dist[b][i] = dist[a][i] + f
                    isUpdated = True
                if dist[a][i] != INF and (i+1) <= c and dist[a][i] + f / 2 < dist[b][i+1]:
                    dist[b][i+1] = dist[a][i] + int(f / 2)
                    isUpdated = True
    
    return min(dist[d])

if __name__ == '__main__':
    while True:
        c, n, m, s, d = map(int, input().split())
        if c == 0:
            break

        s -= 1
        d -= 1
        es = []
        dist = [[INF for _ in range(c+1)] for __ in range(n)] # dist[i][j]: ???i?????§????????????j????????£??????????????????
        for _ in range(m):
            a, b, f = map(int, input().split())
            a -= 1
            b -= 1
            es.append([a, b, f])
            es.append([b, a, f])

        print(bf(es, dist, c, s, d))

Measured memory_bytes: 7784
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define BIT_MAX 201010

int bit[BIT_MAX], n, N;
int offset = 100001;

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}

int main() {

  cin >> N;
  n = BIT_MAX - 1;

  vi a(N);
  REP(i, N) cin >> a[i];

  int l = 0;
  int h = 1e9 + 1;

  while (h - l > 1) {

    memset(bit, 0, sizeof(bit));

    int m = (l + h) / 2;
    vi b(N);
    REP(i, N) b[i] = (m <= a[i] ? 1 : -1);
    FOR(i, 1, N) b[i] += b[i - 1];

    ll ans = 0;
    add(offset, 1);

    REP(i, N) {
      b[i] += offset;
      ans += sum(b[i]);
      add(b[i], 1);
    }
    // cout << m << " " << ans << endl;

    if (ans < (1LL * N * (N + 1) / 2 + 1) / 2)
      h = m;
    else
      l = m;
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 1796
from bisect import bisect_left


def dfs(n, X):
    p = bisect_left(layer[n], X)
    if n == 0:
        return 1
    if p == 0:
        return 0
    elif p == 1:
        return dfs(n - 1, X - 1)
    elif p == 2:
        return patty[n - 1] + 1
    elif p == 3:
        return patty[n - 1] + 1 + dfs(n - 1, X - layer[n][2])
    else:
        return 2 * patty[n - 1] + 1


N, X = map(int, input().split())

layer = [0] * (N + 1)
layer[0] = [1]
for i in range(N):
    t = layer[i][-1]
    layer[i + 1] = [1, 1 + t, 1 + t + 1, 1 + t + 1 + t, 1 + t + 1 + t + 1]


patty = [0] * (N + 1)
patty[0] = 1
for i in range(N):
    t = patty[i]
    patty[i + 1] = 1 + 2 * t


print(dfs(N, X))


Measured memory_bytes: 3064