akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, Q, A, B;
int X[202020];

struct segtree
{
	static const int DEPTH = 18;
	static const int N = 1 << DEPTH;
	i64 val[2 * N];
	i64 ofs;

	void init()
	{
		for (int i = 0; i < 2 * N; ++i) val[i] = (1LL << 60LL);
		ofs = 0;
	}
	void update(int p, i64 v)
	{
		p += N;
		val[p] = v - ofs;
		p >>= 1;
		while (p) {
			val[p] = min(val[p * 2], val[p * 2 + 1]);
			p >>= 1;
		}
	}
	void add_all(i64 val)
	{
		ofs += val;
	}
	i64 query(int L, int R)
	{
		i64 ret = 1LL << 60LL;
		L += N; R += N;
		while (L < R) {
			if (L & 1) ret = min(ret, val[L++]);
			if (R & 1) ret = min(ret, val[--R]);
			L >>= 1; R >>= 1;
		}
		return ret + ofs;
	}
};

segtree lf, rg;

void upd(int p, i64 v)
{
	lf.update(p, v - p);
	rg.update(p, v + p);
}
i64 query(int p)
{
	i64 ret = lf.query(0, p + 1) + p;
	ret = min(ret, rg.query(p, segtree::N) - p);
	return ret;
}

int main()
{
	scanf("%d%d%d%d", &N, &Q, &A, &B);

	lf.init();
	rg.init();
	
	int last_pos = A;
	upd(B, 0LL);

	for (int i = 0; i < Q; ++i) {
		scanf("%d", X + i);

		i64 a = query(X[i]);
		lf.add_all(abs(X[i] - last_pos));
		rg.add_all(abs(X[i] - last_pos));
		upd(last_pos, a);
		last_pos = X[i];
	}

	i64 ret = 1LL << 60LL;
	for (int i = 1; i <= N; ++i) {
		ret = min(ret, lf.query(i, i + 1) + i);
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 9216
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f1 f2 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1]))
  member this.Scan3 f1 f2 f3 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2]))
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M = util.Scan2 int int
let xs = util.ScanMatrix M int
let left = xs |> List.map (Array.item 0) |> List.max
let right = xs |> List.map (Array.item 1) |> List.min

match right - left with
| x when x < 0 -> 0
| x -> x + 1
|> printfn "%d"


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

using namespace std;

int main(void){
    int N;
    double sum = 0;
    double div = 0;
    cin >> N;
    vector<pair<double, double>> p(N);
    for(int i = 0; i < N; i++) cin >> p[i].first >> p[i].second;
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    do{
        for(int i = 0; i < N - 1; i++){
            double dx = p[v[i + 1]].first - p[v[i]].first;
            double dy = p[v[i + 1]].second - p[v[i]].second;
            sum += sqrt(dx * dx + dy * dy);
        }
        div += 1.0;
    }while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / div << endl;
    return 0;
}


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

public class Main {
	static int[] f = new int[101];
	static int n;
	private static void solve(){
		//Implement solution here.
		int x = ni();
		int y = ni();
		System.out.println(x + y / 2);

	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 21076
# Aizu Problem 0009: Prime Number
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(50500)

for line in sys.stdin:
    n = int(line)
    if n in primes:
        idx = primes.index(n)
        print(primes[idx-1], primes[idx+1])
    else:
        idx = bisect.bisect_right(primes, n)
        print(primes[idx-1], primes[idx])
    

Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int num[26];

int main()
{
  ll a,b,c,k,ans;
  cin>>a>>b>>c>>k;
  if (k % 2 == 0)
    ans = a - b;
  else if (k % 2 == 1)
    ans = b - a;
  
  cout<<ans<<endl;
  return 0;
}


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

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

  vector<int> vec(n);

  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  vec.at(0) /= 2;
  int sum=0;
  for (int i = 0; i < n; i++)
  {
    sum += vec.at(i);
  }
  cout << sum << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v first
#define p second.first
#define f second.second
#define MAX_N 200000
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lnt;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), _f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) _f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += _f*(c-'0');
}
int n, m; lnt ans;
piii seq[MAX_N+5];
bool mrk[MAX_N+5][2];
bool chkA() {
	for (int i = 1; i <= n; i++)
		if (!mrk[i][0]) return false;
	return true;
}
bool chkB() {
	for (int i = 1; i <= n; i++)
		if (!mrk[i][1]) return false;
	return true;
}
bool chkAB() {
	for (int i = 1; i <= n; i++)
		if (mrk[i][0] && mrk[i][1])
			return true;
	return false;
}
int main() {
	read(n);
	for (int i = 1, A, B; i <= n; i++)
		read(A), seq[++m] = piii(A, pii(i, 0)), 
		read(B), seq[++m] = piii(B, pii(i, 1));
	sort(seq+1, seq+m+1);
	for (int i = 1; i <= n; i++) ans += seq[i].v;
	for (int i = 1; i <= n; i++)
		mrk[seq[i].p][seq[i].f] = true;
	if (chkA() || chkB() || chkAB())
		return printf("%lld\n", ans), 0;
	int mi = INF;
	for (int i = 1; i <= n; i++)
		if (seq[i].p ^ seq[n+1].p)
			mi = min(mi, seq[n+1].v-seq[i].v);
		else
			mi = min(mi, seq[n+2].v-seq[i].v);
	return printf("%lld\n", ans+mi), 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, M;
    cin >> N >> M;
    int ans = ((N - 1) * N) / 2;
    ans += ((M - 1) * M) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_f
#include <bits/stdc++.h>
using namespace std;
string X, Y;
void lcs(int m, int n) {
  int L[m + 1][n + 1];
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      if (i == 0 || j == 0)
        L[i][j] = 0;
      else if (X[i - 1] == Y[j - 1])
        L[i][j] = L[i - 1][j - 1] + 1;
      else
        L[i][j] = max(L[i - 1][j], L[i][j - 1]);
    }
  }
  int index = L[m][n];
  char lcs[index + 1];
  lcs[index] = '\0';
  int i = m, j = n;
  while (i > 0 && j > 0) {
    if (X[i - 1] == Y[j - 1]) {
      lcs[index - 1] = X[i - 1];
      i--;
      j--;
      index--;
    } else if (L[i - 1][j] > L[i][j - 1])
      i--;
    else
      j--;
  }
  cout << lcs;
}
int main() {
  cin >> X >> Y;
  int m = X.size();
  int n = Y.size();
  lcs(m, n);
}


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


int main(){
    //input
    int N, T, A, result;
    int H[1000];
    cin >> N >> T >> A;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    //serch
    float best;
    for(int i = 0; i < N; i++){
        float temp = T - H[i] * 0.006;
        float dif = fabsf(A - temp);
        if(i == 0){
            best = dif;
            result = 1;
        }
        if(dif < best){
            best = dif;
            result = i + 1;
        }
    }

    //output
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
double gc(double x,double y){
  if(x<0) x=-x;
  if(y<0) y=-y;
  if(x==0) return y;
  if(y==0) return x;
  while(x!=y){
    // cout <<x<<"tttt "<<y<<endl;
    if(x>y)
      x=x-y;
    if(y>x)
      y=y-x;

  }
  return x;
}
int test(int a,int b,int c){
  int t=b*b-4*a*c;
  for(int i=0; i*i<=t; i++)
    if(i*i==t) 
      return 0;
  
  return 1;
}
int main(){
  double a,b,c,p,q,r,s,qq,ww,ee,rr;
  int hanbetu;
  
  while(1){
    cin >>a>>b>>c;
    // cin >>qq>>ww>>ee>>rr;
    //a=qq*ee;b=qq*rr+ww*ee;c=ww*rr;
    if(a==0&&b==0&&c==0) break;
    hanbetu=b*b-4*a*c;
    //    if(hanbetu<0||sqrt(hanbetu)!=(double)((int)sqrt(hanbetu)) ) {
    if(hanbetu<0||test(a,b,c) ) {     
      cout<<"Impossible"<<endl;
     
      continue;
    }
    q=b-sqrt(hanbetu);
    s=b+sqrt(hanbetu);
    //cout<<q<<' '<<s<<endl;
    p=gc(2*a,q);    r=gc(2*a,s);
    q=q/p; s=s/r;
    p=2*a/p; r=2*a/r;
    if(p>r||(p==r&&q>=s))
      cout <<p<<' '<<q<<' '<<r<<' '<<s<<endl;
    else cout<<r<<' '<<s<<' ' <<p<<' '<<q<<endl;
  }
  return 0;
}

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

using LL = long long;

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

    char x, y;

    cin >> x >> y;

    if (x == y)
    {
        cout << "=" << endl;
    }
    else if (x > y)
    {
        cout << ">" << endl;
    }
    else
    {
        cout << "<" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from bisect import*
A,B=abs,bisect
a,b,q,*l=map(int,open(0).read().split())
f=2**60
s,t=[-f]+l[:a]+[f],[-f]+l[a:a+b]+[f]
for x in l[a+b:]:
  m=f
  i,j=B(s,x),B(t,x)
  for v in s[i-1:i+1]:
    for w in t[j-1:j+1]:
      m=min(m,A(x-v)+A(v-w),A(x-w)+A(w-v))
  print(m)

Measured memory_bytes: 127460
#include <stdio.h>

long a,b,r;

int main(void)
{
   scanf("%ld %ld",&a,&b);
     
   if(a >= b){
     do{
       r=a%b;
       a=b;
       b=r;
     }while(r != 0);
    printf("%ld\n",a);
    exit(0);
   }
     
    else if(a < b){
     do{
       r=b%a;
       b=a;
       a=r;
     }while(r != 0);
    printf("%ld\n",b);
    exit(0); 
    }
   
  
   


   
}




Measured memory_bytes: 2052
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> nums;

    ll N_tmp=N;
    for (int i=2; i<=sqrt(N); i++){
        if (N_tmp<i) break;
        if (N_tmp%i!=0) continue;
        
        ll cnt=0;
        while(N_tmp%i==0){
            cnt++;
            N_tmp/=i;
        }
        nums.push_back(cnt);
    }
    if (N_tmp!=1) nums.push_back(1);

    ll ans=0;
    for (ll n: nums){
        ll cnt=1;
        while (n>=cnt){
            n-=cnt;
            cnt++;
        }
        ans+=cnt-1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  ll cl, cr;
  cin >> cl >> cr;
  rep(i, 1, N) {
    ll l, r;
    cin >> l >> r;
    if(cl <= l && cr <= r) {
      cl = l, cr = r;
    } else {
      ll nl = cl / l, nr = cr / r;
      nl += (cl % l != 0) , nr += (cr % r != 0);
      ll m = max(nl, nr);
      cl = l * m, cr = r * m;
    }
  }
  cout << cl + cr << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // Treeなので連結成分は、頂点数 - 辺の数
  int N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i < N+1; i++) {
    ans += i * (N-i+1);
  }
  vector<int> graph[N+1]; // 1-indexed
  rep(i, N-1) {
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    ans -= a * (N-b+1);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  cout << ans << '\n';
  return 0;
}

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

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

    long double rad = M_PI * 2 * (
                (long double)h/12.0 + ((long double)m/60.0)/12.0 -
                (long double)m/60.0);
    
    long double rsq = (long double)(a*a + b*b) - (long double)(2*a*b) * cos(rad);

    cout << setprecision(20) <<sqrt(rsq) << endl;

    return 0;
}

Measured memory_bytes: 4104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll sumn = 1, summ = 1;
	for (int i = 1; i <= n; i++) {
		sumn = sumn * i;
		sumn %= INF;
	}
	for (int i = 1; i <= m; i++) {
		summ = summ * i;
		summ %= INF;
	}
	if (n == m) cout << ((sumn*summ) % INF) * 2 % INF << endl;
	else cout << (sumn*summ) % INF << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int ac = 0, wa = 0, tle = 0, re = 0;
        int n = Integer.parseInt(sc.nextLine());
        for(int i = 0;i<n;i++){
            String temp = sc.nextLine();
            if(temp.equals("AC")) ac++;
            if(temp.equals("WA")) wa++;
            if(temp.equals("TLE")) tle++;
            if(temp.equals("RE")) re++;
        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }
}

Measured memory_bytes: 60140
# coding: utf-8
import math

(n,d) = [int(i) for i in input().rstrip().split(" ")]

point_list = [[int(i) for i in input().rstrip().split(" ")] for j in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1,n):
       temp = sum([pow(point_list[i][k] - point_list[j][k],2) for k in range(d)])
       sq = int(math.sqrt(temp))
       if sq * sq == temp:
           ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
//unionfind
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int a,b,c,k,i;
  i=0;
  cin >> c>>b>>a>>k;
  while(i<k){
    if(b<=c)b*=2;
    else if(a<=b)a*=2;
    else a*=2;
    i++;
  }
  if(a>b&&b>c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3624
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

string s, t;
vector<vector<int>> g;
int main(){
  cin >> s >> t;
  g.resize(26);
  REP(i, s.size()){
    g[s[i]-'a'].push_back(i+1);
  }
  int loop = 0, idx = -1;
  REP(i, t.size()){
    if(g[t[i]-'a'].size() == 0){
      cout << -1 << endl;
      return 0;
    }
    auto ite = upper_bound(g[t[i]-'a'].begin(), g[t[i]-'a'].end(), idx);
    if(ite == g[t[i]-'a'].end()){
      loop++;
      idx = g[t[i]-'a'][0];
    }
    else{
      idx = *ite;
    }
  }
  cout << loop * s.size() + idx << endl;
  return 0;
}


Measured memory_bytes: 1216
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var line = Console.ReadLine().Split(' ');
                var a = int.Parse(line[0]);
                var op = line[1];
                var b = int.Parse(line[2]);

                if (op == "?")
                {
                    return;
                }

                switch (op)
                {
                    case "+":
                        Console.WriteLine(a + b);
                        break;
                    case "-":
                        Console.WriteLine(a - b);
                        break;
                    case "*":
                        Console.WriteLine(a * b);
                        break;
                    case "/":
                        Console.WriteLine(a / b);
                        break;
                }
            }
        }
    }
}


Measured memory_bytes: 15960
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int contests = sc.nextInt();
        int rating = sc.nextInt();
        if (contests >= 10) {
            System.out.println(rating);
        } else {
            System.out.println(rating + 100 * (10 - contests));
        }
    }
}


Measured memory_bytes: 21972
//32
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>

#define S(X) ((X)*(X))

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    double x[100],y[100],z[100],r[100];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>z[i]>>r[i];
    }
    double d[100][100];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	d[i][j]=max(0.,sqrt(S(x[i]-x[j])+S(y[i]-y[j])+S(z[i]-z[j]))-r[i]-r[j]);
      }
    }
    bool u[100]={};
    double s=0;
    double e[100];
    fill(e,e+100,1<<30);
    e[0]=0;
    for(int i=0;i<n;i++){
      int x;
      double m=1<<30;
      for(int j=0;j<n;j++){
	if(!u[j]&&m>e[j]){
	  m=e[j];
	  x=j;
	}
      }
      u[x]=true;
      s+=e[x];
      for(int j=0;j<n;j++){
	if(!u[j]&&e[j]>d[x][j]){
	  e[j]=d[x][j];
	}
      }
    }
    cout<<fixed<<setprecision(3)<<s<<endl;
  }
  return 0;
}

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

struct PrimeFact {
    vector<ll> spf;
    PrimeFact(ll N) { init(N); }
    void init(ll N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (ll i = 0; i <= N; i++)
            spf[i] = i;
        for (ll i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (ll j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    // map<ll, ll> get(ll n) { // nの素因数分解を求める
    //     map<ll, ll> m;
    //     while (n != 1) {
    //         m[spf[n]]++;
    //         n /= spf[n];
    //     }
    //     return m;
    // }

    ll get(int n) {
        map<int, int> mp;
        while (n != 1) {
            mp[spf[n]]++;
            n /= spf[n];
        }

        int ans = 1;
        for (auto p : mp) {
            ans *= p.second + 1;
        }

        return ans;
    }
};

int main() {
    int n;
    cin >> n;
    PrimeFact pri(n);

    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += pri.get(i) * i;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,A, B;
 1<=N<=20;
   1<=A<=100;
  1<=B<=2000;
cin>>N>>A>>B;
    
  if(N*A<B){
   cout<<N*A<<endl; 
  }
  else {
   cout<<B<<endl; 
  }
  }


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

#define N 13
#define M 13

using namespace std;

int a[N][M];
int c[N];
bool use[N];
int n, m, x;
int c_min;


void check(int c_sum)
{
    int x_sum[M];
    for(int i = 0; i < m; i++) {
        x_sum[i] = 0;
    }

    for(int i = 0; i < n; i++) {
        if(use[i]) {
            for(int j = 0; j < m; j++) {
                x_sum[j] += a[i][j];
            }
        }
    }

    for(int i = 0; i < m; i++){
        if(x_sum[i] < x) {
            return;
        }
    }

    c_min = min(c_min, c_sum);
}


void dfs(int p, int c_sum)
{
    if(c_sum >= c_min) {
        return;
    }
    if(p == n) {
        if(c_sum > 0) {
            check(c_sum);
        }
        return;
    }

    dfs(p+1, c_sum);
    use[p] = true;
    dfs(p+1, c_sum + c[p]);
    use[p] = false;
}

int main()
{
    cin >> n >> m >> x;
    c_min = 1;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
        c_min += c[i];
        use[i] = false;
    }

    int c_max = c_min;
    dfs(0, 0);

    if(c_max == c_min) {
        c_min = -1;
    }
    cout << c_min << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			if(s.substring(i, i+1).equals("0")) {
				ans.append("0");
			}
			else if(s.substring(i, i+1).equals("1")) {
				ans.append("1");
			}
			else if(s.substring(i, i+1).equals("B")) {
				if(ans.length()>0) {
					ans.delete(ans.length()-1,ans.length());
				}
			}
		}
		System.out.println(ans);
	    scanner.close();
		}
}


Measured memory_bytes: 35436
#include <bits/stdc++.h>
using namespace std;
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;

int main() {
    cin >> n;
    vector<int> X(n, 0);
    for(int i = 0; i < n; ++i) cin >> X.at(i);
    vector<int> sX;
    sX = X;
    sort(sX.begin(), sX.end());

    int chfst = (n-1)/2; int chsnd = chfst+1;
    // 消すのが前半のやつならchsnd, 後半ならchfst

    for(int i = 0; i < n; ++i) {
        int now = lower_bound(sX.begin(), sX.end(), X.at(i)) - sX.begin();
        if(now <= chfst) cout << sX.at(chsnd) << endl;
        else cout << sX.at(chfst) << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

int main() {
	
	int a[5];
	fx(5){
		a[x]=0;
	}
	fx(6){
		int b;
		cin>>b;
		a[b]++;
	}
	bool can=true;
	for(int y=1;y<=4;y++){
		if(a[y]>=3){
			can=false;
			break;
		}
	}
	
	if(can){
		ce("YES")
	}else{
		ce("NO")
	}
	
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;



const ll m = 1e9+7;
ll a[200007];
ll pre[200007];
int main() {
  ll n; cin>>n;
  for(ll i=1;i<=n;i++)
  {
      cin>>a[i];
      pre[i] = (pre[i-1]%m + a[i]%m)%m;
  }
  ll ans=0;
  for(ll i=1;i<=n;i++)
  {
      ll t = (pre[n]%m - pre[i]%m + m)%m;
      t = (t%m * a[i]%m)%m;
      ans = (ans%m + t%m)%m;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 6748
package main

import ("fmt")

func main(){
	var a, b int

	fmt.Scan(&a, &b)

	if a < b{
		for i := 0 ; i < b ; i++{
			fmt.Print(a)
		}
	}else {
		for i := 0 ; i < a ; i++{
			fmt.Print(b)
		}
	}
	fmt.Println()

}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	int A[200005];

	cin >> N;
	rep(i,N) cin >> A[i];

	map<int,int> cnt;
	rrep(i,N){
		int a = A[i] - i;
		ans += cnt[-i*2 - a];
		cnt[a]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 21460
#include<iostream>
using namespace std;
int main(){
	int i,H,j,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(j=0;j<H;j++){
			for(i=0;i<W;i++){
				cout<<'#';
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int absolute(int);
int main() {
  int N,L,ans;
  cin >> N >> L;
  if(-N<L && L<1)ans = 1-L;
  else if(0<L)ans = 1;
  else ans = N;
  cout << (2*L+N-1)*N/2-L-ans+1 << endl;
}

Measured memory_bytes: 256
import math

MOD = 10**9 + 7

# nCk
def comb(n, r):
    r = min(r, n-r)
    if r == 0: return 1
    if r == 1: return n

    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
  
# nCk mod
def comb_mod(n, r, mod):
  r = min(r, n-r)
  
  g1 = [1, 1] # 元
  g2 = [1, 1] # 逆元
  inverse = [0, 1] # 逆元計算用
  
  for i in range(2, n+1):
    g1.append( (g1[-1] * i) % mod )
    inverse.append( (-inverse[mod % i] * (mod // i)) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

  return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()

# (+1,+2):n, (+2,+1):m
m = (X*2 - Y) // 3
n = X - m*2

if m < 0 or n < 0:
  print(0)
  quit()

ans = comb_mod(n+m, n, MOD)

print(ans)

Measured memory_bytes: 82296
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = llabs(a*b*(c/2) - a*b*(c - c/2));
	chmin(ans, llabs(a*(b/2)*c - a*(b - b/2)*c));
	chmin(ans, llabs((a/2)*b*c - (a - a/2)*b*c));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<set>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
long long n,m,q,i,j,k,num[2005],vis[2005],ans=1ll<<60,fa[2005],mx=1ll<<55;
vector<long long> seq,seq2,all,pos[2005];
multiset<long long> s[2005],s1;
int find(int x)
{
	if (fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y)
{
	x=find(x);
	y=find(y);
	if (x==y) return;
	if (s[x].size()>s[y].size()) swap(x,y);
	fa[x]=y;
	llx(s[x],it) s[y].insert(*it);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>m>>q;
	if (q==1)
	{
		cout<<0;
		return 0;
	}
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
		all.push_back(num[i]);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	for (i=1;i<=n;i++)
	{
		fa[i]=i;
		s[i].insert(num[i]);
		num[i]=upper_bound(all.begin(),all.end(),num[i])-all.begin();
		pos[num[i]].push_back(i);
	}
	for (i=all.size()+1;i>=1;i--)
	{
		llx(pos[i],it)
		{
			vis[*it]=1;
			if (vis[(*it)-1]) merge(*it,(*it)-1);
			if (vis[(*it)+1]) merge(*it,(*it)+1);
			j=find(*it);
			while (s[j].size()>=m)
			{
				long long x=*s[j].begin();
				s[j].erase(s[j].begin());
				s1.insert(x);
			}
			while (s1.size()>=q)
			{
				long long x=*s1.rbegin();
				s1.erase(--s1.end());
				mx=min(mx,x);
			}
			if (s1.size()==q-1) ans=min(ans,mx-*s1.begin()); 
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*
import kotlin.collections.ArrayDeque

fun main(args: Array<String>){

    var (H, W) = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    var S = Array(H){CharArray(W)}
    var dx = arrayOf(1,0,-1,0)
    var dy = arrayOf(0,1,0,-1)

    for(i in S.indices){
        S[i] = readLine()!!.toCharArray()
    }

    for(i in 0 until H){
        for(j in 0 until W){
            var visited = Array(H){Array(W){false}}
            var queue = java.util.ArrayDeque<Data>()

            if(S[i][j] == '.') queue.add(Data(i,j,0))

            while(!queue.isEmpty()){
                var data = queue.poll()
                if(!visited[data.x][data.y]){
                    visited[data.x][data.y] = true
                    ans = Math.max(ans,data.distance)

                    for(k in dx.indices){
                        var x = data.x + dx[k]
                        var y = data.y + dy[k]

                        if(x > -1 && x < H && y > -1 && y< W && !visited[x][y] && S[x][y] == '.'){
                            queue.add(Data(x,y,data.distance+1))
                        }
                    }
                }

            }


        }

    }


    println(ans)

}

class Data(var x:Int,var y:Int,var distance:Int)

Measured memory_bytes: 47636
#include <iostream>
#include <map>

int main(void) {
  std::string str;  
  std::map<std::string, std::string> map_weather;
  map_weather["Sunny"] = "Cloudy";
  map_weather["Cloudy"] = "Rainy";
  map_weather["Rainy"] = "Sunny";

  std::cin >> str;
  std::cout << map_weather[str] << std::endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main()
{
  int n;cin>>n;
  set<string> s;
  string a;
  
  for(int i=0;i<n;++i)
  {
    cin>>a;
    s.insert(a);
  }
  
  cout<<s.size();
  
}

Measured memory_bytes: 19148
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
priority_queue<ll,vector<ll>,greater<ll> > Q;
map<ll,bool> mp;
set<ll> s;
ll k; 
ll tp;
ll lst;
ll nw;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
int main()
{
	read(k);
	for(ll i=1;i<=9;i++)
	{ 
		Q.push(i);
		mp[i]=true;
	} 
	int sj=k<<1;
	for(int i=1;i<=sj;++i)
	{
		tp=Q.top();
		Q.pop();
		s.insert(tp);
		if(tp<0) 
		{
			puts("err");
			return 0;
		}
		lst=tp%10;
//		cout<<tp<<" ";
		if(lst+1<10) 
		{
			nw=tp*10+(lst+1);
			if(!mp[nw]) 
			{
				Q.push(nw);
				mp[nw]=true;
			}
		}
		if(lst-1>=0) 
		{
			nw=tp*10+(lst-1);
			if(!mp[nw]) 
			{
				Q.push(nw);
				mp[nw]=true;
			}
		}
		nw=tp*10+lst;
		if(!mp[nw]) 
		{
			Q.push(nw);
			mp[nw]=true;
		}
	}
	set<ll>::iterator it=s.begin();
	int p=1;
	for(;p<k;++p,++it) ;
	cout<<*it;
//	if(s.count(3234566667)) puts("Y");
	puts("");
	return 0;
}




Measured memory_bytes: 49772
# coding: utf-8
import math

def main():
    N = int(input())

    total = 0

    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
             k = i - 1
             m = N // i
             if k > 1 and N % k != 0 and k > m:
                 total += k
             k2 = (N // i - 1)
             m2 = i
             if k2 != k and k2 > 1 and N % k2 != 0 and k2 > m2:
                 total += k2
    print(total)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0]+x[1], reverse=True)
ans = 0
for i in range(n):
    if i%2:
        ans -= ab[i][1]
    else:
        ans += ab[i][0]
print(ans)

Measured memory_bytes: 32224
import math

def permutations_count(n, r):
    return math.factorial(n) // ( math.factorial(n - r) * math.factorial(r) )
n , m = map(int,input().split())

x ,y = 0,0
if n > 1 :
    x = permutations_count(n,2)

if m > 1:
    y = permutations_count(m,2)

print(x+y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int alice=0,bob=0;
    sort(a.begin(),a.end());
    for(int i=1;i<=n;i++){
        if(i%2!=0){
            alice+=a[n-i];
        }else{
            bob+=a[n-i];
        }
    }
    cout <<alice-bob<< endl;

    return 0;
}

Measured memory_bytes: 3596
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

vector<int> getPath(vector<vector<int> > graph, int s, int t) {
	vector<int> parent(graph.size(), -1);
	queue<int> qu;
	qu.push(s);
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (next != s && parent[next] < 0) {
				parent[next] = now;
				qu.push(next);
			}
		}
	}
	vector<int> ans;
	int now = t;
	while (now != -1) {
		ans.push_back(now);
		now = parent[now];
	}
	reverse(ans.begin(), ans.end());
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > graph(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	vector<int> path = getPath(graph, 0, n - 1);
	int l = path.size();
	queue<int> fqu, squ;
	vector<bool> isChecked(n, false);
	int fnum = 0;
	int snum = 0;
	for (int i = 0; i < l / 2 + (l % 2); i++) {
		fqu.push(path[i]);
		fnum++;
		isChecked[path[i]] = true;
	}
	for (int i = l / 2 + (l % 2); i < l; i++) {
		squ.push(path[i]);
		snum++;
		isChecked[path[i]] = true;
	}
	while (!fqu.empty()) {
		int now = fqu.front();
		fqu.pop();
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (!isChecked[next]) {
				isChecked[next] = true;
				fnum++;
				fqu.push(next);
			}
		}
	}
	while (!squ.empty()) {
		int now = squ.front();
		squ.pop();
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (!isChecked[next]) {
				isChecked[next] = true;
				snum++;
				squ.push(next);
			}
		}
	}
	if (fnum > snum)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;
}

Measured memory_bytes: 12160
#include <iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int A = 0, B = 0;
  for(int i = 0; i < b; i++) {
    A = A*10 + a;
  }
  for(int i = 0; i < a; i++) {
    B = B*10 + b;
  }
  if(a < b){
    cout << A << endl;
  } else{
    cout << B << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
#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>;

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;}

const long long INF = 1LL << 60;

ll GCD(ll a,ll b){
	if(b == 0) return a;	
	return GCD(b,a%b);
}
int main(void){
	int n;cin >> n;
	int k=1,count = 0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(k == a){
			count++;
			k++;
		}
	}
	if(k==1)cout << -1 << endl;
	else cout << n-count << endl;
	return 0;
}



Measured memory_bytes: 256
card = [[],[],[]]

row1=input().split()
row2=input().split()
row3=input().split()

for i in range(3):
  card[0].append(row1[i])
for i in range(3):
  card[1].append(row2[i])
for i in range(3):
  card[2].append(row3[i])
  
n = int(input())
b=[]
bingo = [[],[],[]]
for i in range(3):
  for j in range(3):
    bingo[i].append(None)
for k in range(n):
  t = input()
  b.append(t)
  for i in range(3):
    for j in range(3):
      if t == card[i][j]:
        bingo[i][j] = True
  
flag = "No"
if bingo[0][0] and bingo[1][0] and bingo[2][0]:
  flag = "Yes"
if bingo[0][1] and bingo[1][1] and bingo[2][1]:
  flag = "Yes"
if bingo[0][2] and bingo[1][2] and bingo[2][2]:
  flag = "Yes"
  
if bingo[0][0] and bingo[0][1] and bingo[0][2]:
  flag = "Yes"
if bingo[1][0] and bingo[1][1] and bingo[1][2]:
  flag = "Yes"
if bingo[2][0] and bingo[2][1] and bingo[2][2]:
  flag = "Yes"

if bingo[0][0] and bingo[1][1] and bingo[2][2]:
  flag = "Yes"
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
  flag = "Yes"
  
print(flag)
  

  
  
  


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int c[N],s[4],n,m,a,b,flag,E;
vi e[N],r[N];
ll ans;

void dfs(int u,int col){
	if(c[u]){
		flag|=(c[u]!=col);
		return;
	}
	s[c[u]=col]++;
	for(auto v:e[u]) dfs(v,col%3+1),E++;
	for(auto v:r[u]) dfs(v,(col+1)%3+1),E++;
}

int main(){
	read(n),read(m);
	rep(i,1,m){
		read(a),read(b);
		e[a].pb(b),r[b].pb(a);
	}
	rep(i,1,n){
		if(c[i]) continue;
		s[1]=s[2]=s[3]=E=flag=0;
		dfs(i,1);
		if(flag){
			ll t=s[1]+s[2]+s[3];
			ans+=t*t;
		}
		else if(s[1]&&s[2]&&s[3]){
			ans+=(ll)s[1]*s[2]+(ll)s[2]*s[3]+(ll)s[3]*s[1];
		}
		else ans+=E/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> S;
  N = S.length();

  int minus{};

  for (int i{1}; i < N; ++i) {
    if (S[i-1] == S[i]) {
      ++minus;
      i += 2;
    }
  }

  cout << N - minus << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
B = list(map(int, input().split()))
A = [B[0]] + [0] * (N - 1)

for i in range(1, N):
    if i == (N - 1):
        break
    else:
        A[i] = min(B[i-1], B[i])

A[-1] = B[-1]
print(sum(A))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    int m,nmin,nmax;
    cin>>m>>nmin>>nmax;
    while(m){
        int score[m]={},line=-INF,ans=0;
        for(int i=0;i<m;i++){
            cin>>score[i];
        }
        for(int i=nmin-1;i<nmax;i++){
            if(line<=score[i]-score[i+1]){
                line=score[i]-score[i+1];
                ans=i+1;
            }
        }
        cout<<ans<<endl;
        cin>>m>>nmin>>nmax;
    }
    return 0;
}



Measured memory_bytes: 3072
n, t = map(int, input().split())
times = [int(x) for x in input().split()]

result = 0
for i in range(n - 1):
  if times[i] + t > times[i + 1]:
    tmp = times[i+1] + t - (times[i] + t)
    result += tmp
  else:
    result += t

print(result + t)

Measured memory_bytes: 30780
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN 200005
#define INF 100000000
// #define int long long

using namespace std;

int N, Q;
int a[2][MAXN << 2];

int init(int sid, int l, int r, int id, int v) {
	if (l == r) {
		return a[sid][id] = v;
	}
	int m = (l + r) >> 1;
	return a[sid][id] = min(init(sid, l, m, id << 1, v), init(sid, m + 1, r, id << 1 | 1, v));
}

int query(int sid, int l, int r, int L, int R, int id) {
	// cerr << l << ' ' << r << ' ' << L << ' ' << R << endl;
	if (r < L || R < l) {
		return INF;
	}
	if (l == r) {
		return a[sid][id];
	}
	int m = (l + r) >> 1;
	return min({a[sid][id], query(sid, l, m, L, R, id << 1), query(sid, m + 1, r, L, R, id << 1 | 1)});
}

void update(int sid, int l, int r, int L, int R, int id, int v) {
	// cerr << l << ' ' << r << ' ' << L << ' ' << R << endl;
	if (r < L || R < l) {
		return;
	}
	if (L <= l && r <= R) {
		a[sid][id] = min(a[sid][id], v);
		return;
	}
	int m = (l + r) >> 1;
	update(sid, l, m, L, R, id << 1, v);
	update(sid, m + 1, r, L, R, id << 1 | 1, v);
	//a[sid][id] = min(a[sid][id << 1], a[sid][id << 1 | 1]);
}

signed main()
{
	IO;
	cin >> N >> Q;

	init(0, 1, N, 1, N);
	init(1, 1, N, 1, N);

	long long remain = ((long long)N - 2) * ((long long)N - 2);
	while (Q--) {
		int type, x;
		cin >> type >> x;

		if (type == 1) {
			int mn = query(0, 1, N, x, x, 1);
			remain -= mn - 2;
			update(1, 1, N, 1, mn, 1, x);
		} else {
			int mn = query(1, 1, N, x, x, 1);
			remain -= mn - 2;
			update(0, 1, N, 1, mn, 1, x);
		}
	}

	cout << remain << endl;
	return 0;
}



Measured memory_bytes: 7760