akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>m>>n;
   
   
   cout<<(m*(m-1))/2 + (n*(n-1))/2<<endl;
   return 0;
}
    

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, x;
	cin >> n >> x;
	int a;
	int mx = 1000000;
	int cnt = 0;
	rep(i, n) {
		cin >> a;
		cnt += a;
		mx = min(mx, a);
	}
	cout << n + (x - cnt) / mx << endl;
	return 0;
}

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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) ((v).begin()), ((v).end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

#define faster_IO_stream ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define endl "\n"

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
*/

const double pi = 3.14159265358979323846;
const int module = 1e9 + 7;

int main() {
	faster_IO_stream

	string s;
	cin >> s;

	if(s[s.length() - 1] == 's') cout << s << "es" << "\n";
	else cout << s << "s" << "\n";

	return 0;
}


Measured memory_bytes: 3648
grid=[]
for i in range(19):
  grid.append([])
  for j in range(19):
    grid[-1].append(0)
n=int(input())
twos=[]
fives=[]
for i in range(n):
  t=input()
  predec=[]
  afdec=[]
  flag=0
  for j in range(len(t)):
    if t[j]=='.':
      flag=1
      continue
    if flag==0:
      predec.append(t[j])
    if flag==1:
      afdec.append(t[j])
  s=int(''.join(predec))*(10**9)
  if len(afdec)>0:
    s+=int(''.join(afdec))*(10**(9-len(afdec)))
  twos=0
  while s%2==0 and twos<18:
    twos+=1
    s=s//2
  fives=0
  while s%5==0 and fives<18:
    fives+=1
    s=s//5
  grid[twos][fives]+=1
ans=0
for i in range(19):
  for j in range(19):
    for k in range(18-i,19):
      for l in range(18-j,19):
        ans+=grid[i][j]*grid[k][l]
    if i>=9 and j>=9:
      ans-=grid[i][j]
print(ans//2)

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int k;
  cin>>k;
  long long int n;
  cin>>n;
  long long int sum=0;
  long long int h[200004];
  for(long long int j=0;j<n;j++){
    cin>>h[j];
    sum+=h[j];
  }
   if(sum>=k){
    cout<<"Yes";
   }else{
    cout<<"No";
   }

}


Measured memory_bytes: 1024
# coding: utf-8
from collections import Counter


def ncr(n, r, mod):
    ret = 1
    for i in range(1, r+1):
        ret = (ret * (n-i+1) * pow(i, mod-2, mod)) % mod
    return ret


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    mod = 10**9+7
    C = Counter()

    i = 2
    r = -int(-m**(1/2)//1)
    while 1 < m:
        while m % i == 0:
            C[i] += 1
            m //= i
        if r < i:
            C[m] = 1
            break
        i += 1

    ret = 1
    for v, c in C.items():
        ret *= ncr(n+c-1, min(n-1, c), mod)
        ret %= mod

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3316
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan= new Scanner(System.in);
        int t = scan.nextInt();
        double sum = 0;
        for (int i = 0; i < t; i++) {
            sum += (double) 1/scan.nextDouble();
        }

        System.out.println(1/sum);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> num(4);
    for (int i = 0; i < 4; i++) {
        num.at(i) = (int)s.at(i)-'0';
    }

    for (int i = 0; i < (1<<3); i++) {
        bitset<3> ope(i);
        int sum = num.at(0);
        for (int j = 2; j >= 0; j--) {
            if (ope[j] == 1) {
                sum += num.at(3-j);
            } else {
                sum -= num.at(3-j);
            }
        }
        if (sum == 7) {
            cout << num.at(0);
            for (int j = 1; j <= 3; j++) {
                if (ope[3-j] == 1) cout << '+';
                else cout << '-';
                cout << num.at(j);
            }
            cout << "=7" << endl;
            break;
        }
    }
}


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

int main(){
    string o, e, ans;
    cin >> o >> e;

    long long i = 0, j = 0;
    long long count = 0;
    while(i < o.size() || j < e.size()){
        if(count % 2 == 0){
            ans.push_back(o[i]);
            i++;
            count++;
        }
        else{
            ans.push_back(e[j]);
            j++;
            count++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int X, A;
    cin >> X >> A;

    int ans = 0;
    if(X >= A) ans = 10;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  
  if (N < 10) ans = N;
  else if (N < 100) ans = 9;
  else if (N < 1000) ans = 9 + (N - 99); 
  else if (N < 10000) ans = 9 + 900;
  else if (N < 100000) ans = 9 + 900 + (N - 9999); 
  else ans = 9 + 900 + 90000;
  
  cout << ans << endl;
  
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n, m, s[5], c[5];
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    for (int i = 0; i < 1000; ++i) {
        string num = to_string(i);
        if (num.size() != n)
            continue;
        bool f = true;
        for (int j = 0; j < m; ++j) {
            if (num[s[j]] != ('0' + c[j])) {
                f = false;
            }
        }
        if (f) {
            cout << num << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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


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

    string s;
    cin >> s;
    string r = "CODEFESTIVAL2016";
    int cnt = 0;
    for(int i=0; i<len(r); i++){
      if(s[i] != r[i]) cnt++;
    }
    cout << cnt << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

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

	vector<vector<pii>> graph(N, vector<pii>(0));

	rep(i, N-1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].pb(mp(b, i));
		graph[b].pb(mp(a, i));
	}

	queue<ll> que;

	vi color(N, 0);
	vi ecolor(N-1, 0);

	que.push(0);
	
	ll K = 0;

	while (que.empty() == false) {
		ll i = que.front();
		que.pop();

		ll col = 1;
		for (auto g : graph[i]) {
			if ( g.first == 0 || color[g.first] != 0)
				continue;

			if (col == color[i])
				col++;
			color[g.first] = col;
			ecolor[g.second] = col;
			if (col > K) {
				K = col;
			}
			col++;
			que.push(g.first);
		}
	}

	cout << K << endl;
	repa(i, 0, N-1) {
		cout << ecolor[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9600
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    s = set()
    for a in A:
        s.add(a)
    num = len(s)
    ret = num - (num + 1) % 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define M 1000000007
#define pb push_back
#define mp make_pair

#define f(i,n) for(int i=0;i<n;i++)
#define bf(i,n) for(int i=n-1;i>=0;i--)

#define all(v) v.begin(), v.end()
#define p0(a) cout<<a<<" "<<'\n'
#define p1(a) cout<<a<<'\n'
#define p2(a,b) cot<<a<<" "<<b<<'\n'
#define p3(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define p4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<d<<'\n'

#define bl '\n'


int main() {
	// your code goes here
	FIO;
	ll test = 1;
	//cin>>test;
	while(test--){
	    int x;
	    cin>>x;
	    if(x>=400 && x<=599) cout<<8<<endl;
	    else if(x>=600 && x<=799) cout<<7<<endl;
	    else if(x>=800 && x<=999) cout<<6<<endl;
	    else if(x>=1000 && x<=1199) cout<<5<<endl;
	    else if(x>=1200 && x<=1399) cout<<4<<endl;
	    else if(x>=1400 && x<=1599) cout<<3<<endl;
	    else if(x>=1600 && x<=1799) cout<<2<<endl;
	    else if(x>=1800 && x<=1999) cout<<1<<endl;
	}
	return 0;
}


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

int main() {
  int a[100002];
  int b;
  int i, j, N;
  int *p;

  for (i = 0; i < 100002; i++) {
    a[i] = 0;
  }

  scanf("%d", &N);
  p = (int*)malloc(sizeof(int) * N);

  for (int i = 0; i < N; i++) {
    scanf("%d", (p + i));
  }

  for (i = 0; i < N; i++) {
    b = *(p + i);
    a[b]++;
    a[b - 1]++;
    a[b + 1]++;
  }

  int max = 0;
  for (int i = 0; i < 100002; i++) {
    if (max < a[i]) {
      max = a[i];
    }
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  long long H, W, x, y; std::cin >> H >> W >> x >> y;

  bool flag = false;
  if ( x*2 == H && y*2 == W ) flag = true;

  std::cout << std::fixed << std::setprecision(12) << (double) (H*W)/2. << " ";
  if ( flag ) std::cout << 1 << std::endl;
  else std::cout << 0 << std::endl;
  return 0;
}

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

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

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll N;
  cin >> N;
  ll A[N];
  rep(i,0,N)cin >> A[i];

  bool all_even = true;
  ll ans = 0;
  while(all_even){
    rep(i,0,N){
      if (A[i] % 2 != 0){
        all_even = false;
      }
    }
    if (all_even){
      rep(i,0,N){
        A[i] /= 2;
      }
    }else{
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

ll dp[25000005];

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

    ll N;
    vector<vector<int>> X(2, vector<int>(3));
    cin >> N;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> X[i][j];
        }
    }
    for(int loop = 0; loop < 2; ++loop){
        iota(dp, dp + N + 1, 0LL);
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j <= N; ++j){
                if(j - X[0][i] >= 0)    chmax(dp[j], dp[j - X[0][i]] + X[1][i]);
            }
        }
        swap(X[0], X[1]);
        N = dp[N];
    }
    cout << N << endl;
}

Measured memory_bytes: 198820
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#include <regex>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin >> s;
	regex e ("(A?)KIH(A?)B(A?)R(A?)");
	if(regex_match(s, e)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=8000;
const long INF=1e9;
int main(){
	int W,H;cin>>W>>H;
	int A[W],B[H];int sum=0;
	rep(i,0,W){ cin>>A[i]; sum+=A[i]; }
	rep(i,0,H){ cin>>B[i]; sum-=B[i]; }
	if(sum!=0){ cout<<0<<endl; return 0; }
	sort(A,A+W,greater<int>());
	rep(i,0,W){
		sort(B,B+H,greater<int>());
        if(A[i]==0) break;
        if(A[i]>H){ cout<<0<<endl; return 0;}
        if(B[A[i]-1]==0){ cout<<0<<endl; return 0;}
		rep(j,0,A[i]) B[j]--;
	}cout<<1<<endl;
	return 0;
}


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

int solve(const std::string& s, const std::string& t)
{
  int result = 0;
  for (auto i = 0u; i < s.size(); ++i) {
    if (s[i] == t[i]) ++result;
  }
  return result;
}

int main()
{
  std::string s, t;
  std::cin >> s >> t;

  std::cout << solve(s, t) << std::endl;
}


Measured memory_bytes: 256
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void printM(vector<vector<int> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
    cout << endl;
    }
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n;
    vector<double> ansv;
    while(cin >> n){
        if(n == 0)break;
        vi s;
        s.resize(n);
        long sum = 0;
        F(i, 0, n){
            cin >> s[i];
        }
        F(i, 0, n){
            sum += s[i];
        }
        double m = (double)sum / n;
        double alpha2 = 0;
        F(i, 0, n){
            alpha2 += pow(s[i]-m, 2);
        }
        alpha2 /= n;
        double ans = sqrt(alpha2);
        ansv.pb(ans);
    }
    F(i, 0, ansv.size()){
        printf("%1.8lf\n",ansv[i]);
    }

#if TST==1
#endif
}



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

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

    int cnt[210000];
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    
    sort(cnt, cnt+N);

    int ans = 0;
    for(int i = 0; i < N - K; i++) {
        ans += cnt[i];
    }
    cout << ans << endl;
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //int N = int.Parse(Console.ReadLine());

            string[] tmp = Console.ReadLine().Split(' ');

            string a = tmp[0];
            string b = tmp[1];

            if(a == "H")
            {
                if(b == "H")
                {
                    Console.WriteLine("H");
                }
                else
                {
                    Console.WriteLine("D");
                }
            }
            else
            {
                if (b == "H") Console.WriteLine("D");
                else Console.WriteLine("H");
            }

            //int[] hogeArray = new int[N];
            //for(int i = 0;i<N;i++)
            //{
            //    hogeArray[i] = int.Parse(tmp[i]);
            //}
        }
    }
}


Measured memory_bytes: 11092
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};
ll dp1[5010];
ll dp2[30000000];
int main(void){
  ll N, M; cin >> N >> M;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  vector<ll> S(N+1, 0); rep(i, N+1) S[i] = (S[i-1] + A[i-1]) % M;
  sort(S.begin(), S.end()); S.push_back(M);
  ll cnt = 1;
  ll ans = 0;
  rep(i, N+1){
    if(S[i] == S[i+1]) cnt++;
    else{
      ans += cnt * (cnt-1) /2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int a,b,c,t;
    
    cin>>a>>b>>c; 
    
    if (a>b){t=a;a=b;b=t;}
    if (b>c){t=b;b=c;c=t;}
    if (a>b){t=a;a=b;b=t;}
    
        cout<<a<<" "<<b<<" "<<c<<endl;
    
        
    return 0;        
         
}

Measured memory_bytes: 1164
N=int(input()) 
import math
A=list(map(int, input().split())) 
k =  len(bin(max(A))[2:])
mod = 10**9+7

c = [0]*k

for i in A:
  bit = bin(i)[2:].zfill(k)
  for j in range(k):
    if bit[j] == '1':
      c[-1-j] +=1
      
ans = 0
for i in range(k):
  ans = (ans +(2**i)*(c[i]*(N-(c[i]))))%mod
  
print(ans)
  
  
  

Measured memory_bytes: 122808
N, L = map(int, input().split())
a = [int(x) for x in input().split()]

ans = False
for i in range(N-1):
    if a[i] + a[i+1] >= L:
        ans = True
        break
if ans:
    print('Possible')
    for j in range(i):
        print(j+1)
    for j in range(N-2, i-1, -1):
        print(j+1)
else:
    print('Impossible')

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int check(ll x) {
  int cnt = 0;
  while (x % 2 == 0) {
    x /= 2;
    cnt++;
    if (cnt == 2) break;
  }
  return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> a(3);
    rep (i, n) {
      int x;
      cin >> x;
     // cout << x << " " << check(x) << endl;
      a[check(x)]++;
    }
    if (a[1] >= 1) a[0]++;

    if (a[0] <= a[2] + 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int x=sc.nextInt(),t=sc.nextInt(),c=x-t;
    if(c>=0){
      System.out.println(c);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21844
#                         author:  kagemeka 
#                         created: 2019-11-07 13:42:36(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    a, b, c, d = (int(x) for x in sys.stdin.readline().split())

    ans = 'No'
    if abs(c - a) <= d:
        ans = 'Yes'
    else:
        if abs(a - b) <= d and abs(c - b) <= d:
            ans = 'Yes'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int x, y, z;
    int ans;
    
    scanf("%d%d%d", &x, &y, &z);
    
    ans=(x-z)/(y+z);
    
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 1724
#include<cstdio>
using namespace std;
int n,m,x;
int main(){
	scanf("%d%d",&n,&x);m=(n<<1)-1;
	if(x==1||x==m) puts("No");else{
		puts("Yes");
		if(n==2) printf("1\n2\n3\n");else
		if(x==2)
		for (int i=1,j=1;i<=m;i++){
			if(i==n-2) printf("%d\n",m-1);else
			if(i==n-1) puts("1");else
			if(i==n) printf("%d\n",x);else
			if(i==n+1) printf("%d\n",m);else
			printf("%d\n",(++j)==x?++j:j);
		}
		else
		for (int i=1,j=2;i<=m;i++){
			if(i==n-2) puts("2");else
			if(i==n-1) printf("%d\n",m);else
			if(i==n) printf("%d\n",x);else
			if(i==n+1) puts("1");else
			printf("%d\n",(++j)==x?++j:j);
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
#define allSum(a) accumulate(a.begin(),a.end(),0)
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n,x;
  cin>>n>>x;
  vint a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  int sum=0;
  rep(i,n){
    sum+=a[i];
    if(x<sum){
      cout<<i<<endl;
      return 0;
    }
  }
  if(sum==x)n++;
  cout<<n-1<<endl;

  return 0;
}



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

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

int main() {
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    vector<ll> pA(N + 1), pB(M + 1);
    rep(i, N) {
        cin >> A[i];
        pA[i + 1] = pA[i] + A[i];
    }
    rep(i, M) {
        cin >> B[i];
        pB[i + 1] = pB[i] + B[i];
    }
    int ans = -1;
    for (int i = 0; i <= N; ++i) {
        if(pA[i] <= K) {
            int j = upper_bound(pB.begin(), pB.end(), K - pA[i]) - pB.begin() - 1;
            ans = max(ans, i + j);           
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9560
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,n) for(ll i=0;i<n;i++)

using namespace std;

int main(int argc, char const* argv[])
{
    ll N,M;
    cin >> N;
    cin >> M;
    vector<ll> A(N);
    priority_queue<ll> que;
    vector<vector<ll>> vec;
    rep(i,N){
        ll tmp;
        cin >> tmp;
        que.push(tmp);
    }
    rep(i,M){
        ll tmp = que.top()/2;
        que.pop();
        que.push(tmp);
    }
    ll sum(0);
    rep(i,N){
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;
    return 0;
}


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

int main() {
  int N, M, c, maxL = 0, minR = 100000;
  cin >> N >> M;
  int L[M], R[M];
  for(int i; i < M; i++) cin >> L[i] >> R[i];
  for(int i; i < M; i++) {
    if(maxL < L[i]) maxL = L[i];
    if(minR > R[i]) minR = R[i];
  }
  c = minR - maxL + 1;
  
  if(c > 0) cout << c;
  else cout << 0;
  
  return 0;
}


Measured memory_bytes: 1024
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
######################################################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
H, W = LI()
c = [LI() for _ in range(10)]
A = [LI() for _ in range(H)]
d = [[float("inf") for i in range(10)] for i in range(10)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(10):
    for j in range(10):
        d[i][j] = c[i][j]
for i in range(10):
    d[i][i] = 0 #自身のところに行くコストは０
#print(warshall_floyd(10,d))
L = warshall_floyd(10,d)
cur = int(0)
for i in range(H):
    for j in range(W):
        l = A[i][j]
        if l>=0:
            cur += L[l][1]

ans = cur
print(ans)


Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0';
    return tmp*f;
}
inline ll power(ll a,ll b)
{
	ll tmp=1;
	for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;}
	return tmp;
}
using namespace std;
int main()
{
	ll a=read(),b=read(),c=read(),x=read(),y=read();
	if(2*c<a+b){
		if(x>y)printf("%lld\n",y*2*c+(x-y)*min(2*c,a));
		else printf("%lld\n",x*2*c+(y-x)*min(2*c,b));
	}
	else printf("%lld\n",a*x+b*y);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

using int64 = long long;
using uint64 = unsigned long long;

#define repeat(i, x) for (int64 i = 0; (i) < (x); (i)++)
#define rev_repeat(i, x) for (int64 i = (x) - 1; (i) >= 0; (i)--)
#define countup(i, n) for (int64 i = 0; (i) <= (n); (i)++)
#define countdown(i, n) for (int64 i = (n); (i) >= 0; (i)--)
#define range(i, a, b) for (int64 i = (a); (i) < (b); (i)++)
#define traverse(it, ctn) for (auto it = begin(ctn); (it) != end(ctn); (it)++)
#define rev_traverse(it, ctn) for (auto it = rbegin(ctn); (it) != rend(ctn); (it)++)

template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec)
{
    os << "[";
    repeat (i, vec.size())
    {
        os << (i == 0 ? "" : ", ") << vec[i];
    }
    os << "]";
    return os;
}

template<typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T>& s)
{
    os << "{";
    traverse (it, s)
    {
        if (it != s.begin()) os << ", ";
        os << *it;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
ostream& operator<<(ostream& os, map<K, V>& m) 
{
    os << "{";
    traverse (it, m)
    {
        if (it != m.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "}";
    return os;
}

//
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

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

    int64 N, K;
    cin >> N >> K;

    map<int64, int64> counter;
    range (a, 1, N + 1)
    {
        counter[a % K]++;
    }

    int64 ans = 0;
    range (a, 1, N + 1)
    {
        int64 amod = a % K,
              bmod = (K - amod + K) % K,
              cmod = (K - bmod + K) % K;
        
        // cerr << "amod: " << amod << " bmod: " << bmod << " cmod: " << cmod << endl;

        if ((amod + cmod) % K != 0) continue;

        // cerr << "a: " << a << " " << counter[bmod] * counter[cmod] << endl;

        ans += counter[bmod] * counter[cmod];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, x, y) for(int i = int(x); i < int(y); i++)
#define MAXD 40
#define sf scanf

int n; ll k;
ll cnt[MAXD + 10];

void process(ll x){
    FOR(i, 0, MAXD + 1){
        if(x & (1LL<<i)) cnt[i]++;
    }
}

ll DP[MAXD + 10][2];

ll solve(int pos, int smaller){
    if(pos<0) return 0;
    auto &ret = DP[pos][smaller];
    if(~ret) return ret; ret = 0;
    int cur = ((k>>pos)&1);
    int lim = smaller? 1 : cur;
    FOR(i, 0, lim+1){
        ll now = i ? n - cnt[pos] : cnt[pos];
        ret = max(ret, solve(pos-1, smaller | i < cur) + now * (1LL<<pos));
    }
    return ret;
}

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // VAMP
    memset(DP, -1, sizeof(DP));
    sf("%d %lld", &n, &k);
    FOR(i, 0, n){
        ll x; sf("%lld", &x);
        process(x);
    }
    printf("%lld\n", solve(40, 0));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        int a,b,c,temp;
        int i,j;
        int N;

        scanf("%d",&N);

        int k[N][3];

        i=0;

        while(scanf("%d %d %d",&a,&b,&c)!=EOF){
                if(a>b){
                temp=b;
                b=a;
                a=temp;
                }
                if(b>c){
                temp=c;
                c=b;
                b=temp;
                }

                k[i][0]=a;
                k[i][1]=b;
                k[i][2]=c;
                i++;
                if(N==i) break;

        }

        for(j=0;j<N;j++){
                if(k[j][2]*k[j][2]==k[j][1]*k[j][1]+k[j][0]*k[j][0]){
                printf("YES\n");
                }else{
                printf("NO\n");
                }
        }

        return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::set<std::string> st;
	for(int i = 0; i < n; i++) {
		std::string s; cin >> s;

		st.insert(s);
	}
	
	printf("%d\n", st.size());
	return 0;
}


Measured memory_bytes: 19292
#include <cstdio>
#include <cmath>
using namespace std;
int a, b, c, d;

int main() {
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if((abs(a - b) <= d && abs(b - c) <= d) || (abs(a - c) <= d)) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
from collections import defaultdict

MOD = 10 ** 9 + 7

N = int(input())
s = input()

d = defaultdict(int)
for ss in s:
    d[ss] += 1

ans = 1
for k, v in d.items():
    ans *= (v + 1)
    ans %= MOD
    # v通りの選び方 + 選ばない1通り
ans -= 1
print(ans)


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n;

int main(){
	cin >> n;
	while(!n==0){
		if((n+10)%10 == 9){
			cout << "Yes" << endl;
			return 0;
		}
		n=n/10;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n,t = map(int, input().split())
l = list(map(int ,input().split()))

nums = [0]*(n-1)
for i in range(n-1): nums[i] = l[i+1] - l[i]

ans = t
m = 0
for i in nums:
  ans += min(i,t)
print(ans)

Measured memory_bytes: 30844
/**************************************************
 * Atcoder problems
 * Contest No :086
 * Problem No :B
 * File Name  :program.cs
 * Create date:2020/06/06
 *
 * Copyright 2020 Shunichi Sato,All Rights Reserved.
**************************************************/
//memo terinal command
//compile:mcs program.cs
//excute :mono program.exe
using System;

class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		string input = Console.ReadLine();
		string taget = input.Replace(" ","");
		int a = int.Parse(taget);
		int b = 0;
		string s = "No";
		// 判定
		while( a >= (b * b))
		{
			if(a == (b * b))
			{
				s = "Yes";
				break;
			}
			b++;
		}
		//出力
		Console.WriteLine(s);
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string alpha[26] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
string nyuryoku;


int main(void){
    int i;

    cin >> nyuryoku;

    for(i=0; i<26; i++){
        if(alpha[i] == nyuryoku){
            cout << alpha[i+1] << endl;
        }

    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=(sum(a))/2
count=0
if n==2:
    ans=int(abs((b-a[0])*2))
else:
    for i in range(n):
        count+=a[i]
        if b<=count:
            if i==0:
                c=count
                d=count+a[i+1]
            else:
                c=count-a[i]
                d=count
            break
    e=min(abs(c-b),abs(d-b))
    ans=int(e*2)
print(ans)


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

int main() {
  int n;
  cin >> n;
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    ans += 1 / a;
  }
  ans = 1 / ans;
  cout << fixed << setprecision(5);
  cout << ans << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())

limit=(N*(N-1)//2)-(N-1)
Ans=[]
#N-1本引く
for index in range(2,N+1):
    Ans.append((1,index))

if K>limit:
    print('-1')
else:
    rest=limit-K
    From=2
    To=3

    while rest:
        Ans.append((From,To))
        To+=1
        if To==N+1:
            From+=1
            To=From+1
        rest-=1
    
    print(len(Ans))
    for i in range(len(Ans)):
        print('{0} {1}'.format(Ans[i][0],Ans[i][1]))
        



Measured memory_bytes: 3700
# ABC112B

n, T = map(int, input().split())
Min = -1
for i in range(n):
    c, t = map(int, input().split())
    if t <= T:
        if Min == -1:
            Min = c
        else:
            Min = min(Min, c)
if Min == -1:
    print('TLE')
else:
    print(Min)


Measured memory_bytes: 2940
/*
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string S;
  cin >> S;
  for(int i = 0; i < (1 << 4); i++) {
    string s;
    s += S[0];
    int sum = S[0] - '0';
    for(int j = 1; j < 4; j++) {
      if((i >> j) & 1) s += "+", sum += S[j] - '0';
      else s += "-", sum -= S[j] - '0';
      s += S[j];
    }
    if(sum == 7) {
      cout << s << "=7" << endl;
      return (0);
    }
  }
}
*/

#include <bits/stdc++.h>
using namespace std;
int main(){
 
string S;
cin>>S;


for(int tmp=0;tmp<(1<<4);tmp++){
  string s;
  s+=S.at(0);
  int sum=S.at(0)-'0';
  for(int i=1;i<4;i++){
    if((tmp>>i)&1){//trueの時+
     s+="+";
     sum +=S.at(i)-'0';
     
     }else{
       s+="-";
       sum-=S.at(i)-'0';
    }s+=S.at(i);
  }
  if(sum==7){cout<<s<<"=7"<<endl;
             return 0;
            }
  
}
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(M)]

ab_copy = [ab[i] for i in range(M)]
ans = 0
for i in range(M):
    ab_copy.pop(i)
    uf = UnionFind(N)
    for j in range(M-1):
        uf.union(ab_copy[j][0]-1,ab_copy[j][1]-1)
    if len(uf.roots())!=1:
        ans += 1
    ab_copy = [ab[i] for i in range(M)]
print(ans)

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

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

    int n;
  	cin>>n;
    vector<int>a(n),c(n),d(n),x(n);
    rep(i,n)cin>>a[i];

    c[0]=a[0];
    d[n-1]=a[n-1];

    forx(i,1,n){
        c[i]=__gcd(c[i-1],a[i]);
        d[n-1-i]=__gcd(d[n-i],a[n-i-1]);
    }
    forx(i,1,n-1){
        x[i]=__gcd(c[i-1],d[i+1]);
    }
    x[0]=d[1];
    x[n-1]=c[n-2];

  	sort(x.begin(),x.end());
    cout<<x[n-1]<<endl;

    
    return 0;
}



Measured memory_bytes: 1792