akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N, K; cin >> N >> K;

    if (N >= K / 2) {
        if (K % 2 != 0) {
            ll a = N / K;
            cout << a*a*a << endl;
        }
        else {
            ll a = N / K;
            ll b = max((N - K / 2) / K + 1, (ll)0);
            cout << a*a*a + b*b*b << endl;
        }
    }
    else {
        cout << 0 << endl;
    }

}

Measured memory_bytes: 3160
h, w, a, b = map(int, input().split())
ans = [[0]*w for _ in range(h)]

for i in range(h-b):
    for j in range(a):
        ans[i][j] = 1

for i in range(h-b, h):
    for j in range(a, w):
        ans[i][j] = 1

for row in ans:
    print(*row, sep='')


Measured memory_bytes: 13300
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        r: usize,
        g: usize,
        b: usize,
        n: usize,
    }
    let mut ans = 0;
    for i in 0..(n / r) + 1 {
        for j in 0..(n / g) + 1 {
            if n >= i * r + j * g {
                let temp = n - i * r - j * g;
                if temp % b == 0 {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2120
#include<stdio.h>
int main(void) {
	int a, b, c, d,min,max;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (a >= c) min = a;
	else min = c;
	if (b <= d) max = b;
	else max = d;
	if (max > min) printf("%d", max - min);
	else printf("0");

	return 0;
}

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

//素数判定(素数ならtrue)
bool Prime(int prime)
{
	//偶数除く
	if (prime == 2) {
		return true;
	}
	else if (prime % 2 == 0 || prime < 2) {
		return false;
	}

	float Asqrt = sqrtf(prime);

	for (int i = 3; i <= Asqrt; i += 2) {
		if (prime%i == 0) {
			return false;
		}
	}

	return true;
}

int main()
{
	int n;

	cin >> n;
	
	cout << n << ":";

	for (int prime = 2;; prime++) {

		if (Prime(n)) {
			cout << " " << n << endl;
			break;
		}

		while (true)
		{
			//素数 かつ 素因数の場合
			if (Prime(prime) && n%prime == 0) {
				n /= prime;
				cout << " " << prime;
				
				if (n == 1) {
					cout << endl;
					exit(0);
				}

				//分解可能なら続ける
				continue;
			}

			//分解不可でbreak;
			break;
		}

	}

	return 0;
}


Measured memory_bytes: 3096
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  cout << (M*1900+(N-M)*100)*pow(2,M) << endl;
  return 0;
}


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

using namespace std;

void execute()
{
	int N, K;
	int tmp;
	cin >> N >> K;
	vector<int> data(N + 1, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> tmp;
		data[tmp]++;
	}
	sort(data.begin(), data.end(), greater<int>());

	for (int i = 0; i < K; i++)
	{
		N -= data[i];
	}

	cout << N << endl;

	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;


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


    ll result = 0;
    
    // mod 0 pattern
    ll pattern = N / K;
    result += pattern + pattern * (pattern - 1) * (pattern - 2) + pattern * (pattern - 1) * 3;

    // mod N/2 pattern
    if(K % 2 == 0){
        pattern = (N - (K / 2)) / K;
        if(K / 2 <= N){
            pattern++;
        }
        result += pattern + pattern * (pattern - 1) * (pattern - 2) + pattern * (pattern - 1) * 3;
    }

    cout << result;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 300010;
const int maxM = 100010;
 
 
int n,m,d; 
int main()
{
	scanf("%d %d %d",&n,&m,&d);
	int fnd;
	if(d == 0)
	{
		fnd = n;
	}
	else
	{
		fnd = 2*(n-d);
	}
	long double ans = (long double)(fnd)/(long double)(n);
	long double tmp = (long double)(m-1)/(long double)(n);
	double cnt = ans * tmp;
	printf("%.10f\n",cnt);
	return 0;
}  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
	long long int n,a,b,na = 1,nb = 1;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a >> b;
		if((na - 1) / a > (nb - 1) / b){
			na = ((na - 1) / a + 1) * a;
			nb = ((na - 1) / a + 1) * b;
		}
		else{
			na = ((nb - 1) / b + 1) * a;
			nb = ((nb - 1) / b + 1) * b;
		}
	}
	cout << na + nb << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  ll N, D;
  cin >> N >> D;
  vector<ll> X(N), Y(N);
  REP(i, N) cin >> X[i] >> Y[i];
  ll dist = 0;
  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    dist = X[i] * X[i] + Y[i] * Y[i];
    if (dist <= D * D) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6420
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };


int main() {

	int n;
	while (cin >> n) {

		vector <int>a;

		for (int i = 1; i <= 9; i++) {
			a.push_back(i);
		}

		for (int i = 1; i <= 9; i++) {
			a.push_back(10 * i + i);
		}

		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				a.push_back(100 * i + 10 * j + i);
			}
		}

		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				a.push_back(1000 * i + 100 * j + 10 * j + i);
			}
		}

		int ans = INF;

		for (int i = 0; i < a.size(); i++) {
			if (abs(n - a[i]) < abs(n - ans)) {
				ans = a[i];
			}
		}

		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3164
#include <stdio.h>

int max(int x, int y){
  if(x<=y)
  return y;
  else
  return x;
}

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  int add, sub, mul;
  add=a+b;
  sub=a-b;
  mul=a*b;
  
  printf("%d\n", max(add, max(sub, mul)));
  
  return 0;
}

Measured memory_bytes: 128
n = gets.chomp.to_i

n.times do
  balls = gets.chomp.split.map(&:to_i)
  a = [0, 0]

  while balls.any?
    ball = balls[0]
    if a.max < ball
      index = a.index(a.max)
      a[index] = ball
    elsif a.min < ball
      index = a.index(a.min)
      a[index] = ball
    else
      break
    end
    balls.shift
  end

  puts (balls.empty?) ? :YES : :NO
end

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    ll h, w;
    ll ans = 0;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h % 2 == 0) {
        ans = h / 2 * w;
    }
    else {
        ans = (h - 1) / 2 * w;
        ans += w / 2;
        if (w % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;cin.get( );
    //n++;
    string ss;
    for(int j=0;j<n;j++)
    {
        getline(cin,ss);
        int len =ss.size();
        for(int i=6;i<len;i++)
        {
            //cout << ss[i];
            if(ss.substr(i-6,7)=="Hoshino")
            {
                ss[i]='a';
            }
            //if(ss[i]=='\0')break;
        }

        /*for(int i=0;i<len;i++){
            if(ss[i]=='\0')break;
            cout <<ss[i];
        }*/
        cout <<ss << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())
H = [int(i) for i in input().split()] + [10**10]

ans = 0
tmp = 0
for i in range(N):
	if H[i+1] <= H[i]:
		tmp += 1
		#print("H[i]",H[i])
	else:
		ans = max(ans,tmp)
		tmp = 0
		#print("ans",ans)

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> C(N);  
  for (int i=0;i<N;i++){
  cin >> A.at(i);
  C.at(i)=A.at(i);
  }
  sort (C.begin(),C.end());
  
  for (int i=0;i<N;i++){
  if (A.at(i)!=C.at(N-1)){
  cout << C.at(N-1) << endl;    
  }
  else {
  cout << C.at(N-2) << endl;
  } 
  }
}

Measured memory_bytes: 3200
import numpy as np
import itertools
import math
N = int(input())

x = [0]*N
y = [0]*N

for i in range(N):
    x[i], y[i] = [int(i) for i in input().split()]

dist = np.zeros([N, N])
for i in range(N):
    for j in range(N):
        dist[i,j] = np.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)

perm = list(itertools.permutations(range(N)))
num = math.factorial(N)
sum = 0
for i in perm:
    for j in range(len(i)-1):
        sum += dist[i[j], i[j+1]]
print(sum/num)

Measured memory_bytes: 16996
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    vector<bool> seen(26);
    for (char c : s) {
        seen[c - 'a'] = true;
    }
    
    for (int i = 0; i < 26; i++) {
        if (!seen[i]) {
            cout << char('a' + i) << '\n';
            return 0;
        }
    }
    cout << "None" << '\n';
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          #define pb push_back
          #define ll long long
          #define ld long double

          int main()
          {
               tani_nachi_ke  

               int n;
               cin >> n;
               int mn = n;
               int ans = 0;
               for(int i = 1; i <= n; i++)
               {
                    int x;
                    cin >> x;
                    mn = min(mn,x);
                    if(x <= mn)
                         ans++;
               }
               cout << ans << endl;
               





         
               return 0;
          }

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

using namespace std;

int main(){
    int N;cin>>N;
    vector<int>D(N);

    for(int i =0 ; i < N; i++){
        cin>>D[i];
    }
    sort(D.begin(),D.end());
    cout<<D[N/2] - D[N/2-1]<<endl;
}

Measured memory_bytes: 768
#include <string>
#include <queue>
#include <iostream>
using namespace std;
int main() 
{
	string cmd;
	priority_queue<int> Q;
	while(cin>>cmd&&cmd!="end")
	{
		if(cmd=="insert")
		{
			int temp;
			cin>>temp;
			Q.push(temp);
		}
		else if(cmd=="extract")
		{
			cout<<Q.top()<<endl;
			Q.pop();
		}
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, K, d, a;
    std::vector<bool> D(10, false);
    std::cin >> N >> K;

    floop(K)
    {
        std::cin >> d;
        D[d] = true;
    }

    for(int i = N; i < N*10; ++i)
    {
        a = i;
        while(a > 0)
        {
            d = a % 10;
            if(D[d])
                break;
            a /= 10;
        }

        if(a == 0)
        {
            N = i;
            break;
        }
    }

    print(N);
    return 0;
}

Measured memory_bytes: 3600
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void main() {
    const s = readln;
    char prev = '\0';
    bool nikui = false;
    foreach(c; s) {
        if (c == prev) {nikui = true; break;}
        prev = c;
    }
    writeln(nikui ? "Bad" : "Good");
}


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

using namespace std;

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

    int N = 50;
    vector<long long> a(N, K/N+N-1);
    for (int i=0; i<K%N; i++)
        for (int j=0; j<N; j++)
            if (i==j)
                a[j] += N;
            else
                a[j]--;

    cout<<N<<endl;
    const char *s = "";
    for (long long t: a)
        cout<<s<<t,
        s = " ";
    cout<<endl;
}


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

using namespace std;

int main(){
    int k, n;
    cin>>k>>n;
    vector<int>v(n), v1(n);
    for(int i=0;i<n;++i)cin>>v[i];
    for(int i=0;i<n-1;++i)v1[i]=v[i+1]-v[i];
    v1[n-1]=v[0]+k-v[n-1];
    sort(v1.begin(),v1.end());
    cout<<k-v1[n-1];

    return 0;

}


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

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;
}

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

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          cout << "#";
        }
        else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3072
'use strict'

function main(input) {
  const inputList = input.split(' ');
  const a = Number(inputList[0])
  const b = Number(inputList[1])
  const c = Number(inputList[2])
  const d = Number(inputList[3])

  const left = Math.max(a, c)
  const right = Math.min(b, d)

  if (left > right) {
    console.log(0)
  } else {
    console.log(right-left)
  }
}

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

Measured memory_bytes: 7372
/*
				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "
*/


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define f for
#define ll long long
#define ull unsigned long long
#define endl "\n"
using namespace std;
#define BI  acos(-1)
#define all(a) a.begin(), a.end()
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
void madesetprobblem()
{
	//$ $
	//less than or equal => $ 1 \leq 100 $
	//  $(1 \le A,B \le 10^5 )$
	// a[i] => $a_i$
	// a[i][j] => $a_{i,j}$
	// double qoutes ''yext''
	/*
		image
		\begine{center}
		\includegraphics{image.jpg}
		\end{center}
	*/
	/*
		list
		\begin{itemize}
			\item first one
			\item second one
		\end{itemize}
	*/
}

int n;
vector<int>a(100005), b(100005), c(100005);
int dp[100005][4];
int ans(int cc = 0,int x=0)
{
	int a1 = INT_MIN;
	if (cc == n)return 0;
	if (dp[cc][x] != -1)
		return dp[cc][x];
	if (x != 1)
	{
		a1= max(a[cc] + ans(cc + 1, 1),a1);
	}
	if (x != 2)
	{
		a1 = max(b[cc] + ans(cc + 1, 2),a1);
	}
	if (x != 3)
	{
		a1 = max(c[cc] + ans(cc + 1, 3),a1);
	}
	//cout << cc << " " << a1 << " " << x << endl;
	return dp[cc][x] = a1;

}
int main()
{  
	// توكلت علي الله 
//Open();
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	f(int i = 0; i < 100005; i++)
	{
		dp[i][0] = -1, dp[i][1] = -1, dp[i][2] = -1, dp[i][3] = -1;
	}
	f(int i = 0; i < n; i++)
	{
		cin >> a[i]>>b[i]>>c[i];
	}
	cout << ans();
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> to(n,0),from(n,0);
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        if(x==1)to[y-1]=1;
        if(y==n)from[x-1]=1;
    }
    
    rep(i,0,n){
        if(to[i] && from[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string A, B;
  cin >> A >> B;
  if(A.length()>B.length()) {
    puts("GREATER");
  } else if(A.length()<B.length()) {
    puts("LESS");
  } else {
    FOR(i,0,A.length()) {
      if(A[i] - '0' > B[i] - '0') {
        puts("GREATER");
        return 0;
      }
      else if(B[i] - '0' > A[i] - '0') {
        puts("LESS");
        return 0;
      }
    }
    puts("EQUAL");
  }
  return 0;
}

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

using llint = long long int;
using T_iicls = tuple<int, int, char, llint, string>;

int main() {
	vector<T_iicls> vec;
	int t1, t2; char t3; llint t4; string t5;
	int tn; cin >> tn; vec.resize(tn);
	for (int i = 0; i < tn; i++) {
		cin >> t1 >> t2 >> t3 >> t4 >> t5;
		vec[i] = make_tuple(t1, t2, t3, t4, t5);
	}
	sort(vec.begin(), vec.end(),
		[](T_iicls const &lhs, T_iicls const &rhs) {
			if (get<0>(lhs) != get<0>(rhs)) return get<0>(lhs) < get<0>(rhs);
			if (get<1>(lhs) != get<1>(rhs)) return get<1>(lhs) < get<1>(rhs);
			if (get<2>(lhs) != get<2>(rhs)) return get<2>(lhs) < get<2>(rhs);
			if (get<3>(lhs) != get<3>(rhs)) return get<3>(lhs) < get<3>(rhs);
			return get<4>(lhs) < get<4>(rhs);
		}
	);
	for (T_iicls data : vec) {
		cout << get<0>(data) << " " << get<1>(data) << " " 
			<< get<2>(data) << " " << get<3>(data) << " " << get<4>(data) << endl;
	}
	return 0;
}


Measured memory_bytes: 12204
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;
ll f[N];
ll ksm(ll a,ll b)
{
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
void fac(int n)
{
    f[0]=1;
    f[1]=1;
    for(int i=2;i<=n;i++) f[i]=f[i-1]*i%mod;
}
ll C(ll a,ll b)
{
    return f[a]*ksm(f[b],mod-2)%mod*ksm(f[a-b],mod-2)%mod;
}
int main()
{
    fac(2100);
    ll n,k;cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        if(i>n-k+1) cout<<0<<endl;
        else
        {
            cout<<C(n-k+1,i)*C(k-1,i-1)%mod<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3580
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    int ll=0,r=n;
    while(r>ll+1){
        int m = (ll+r)/2;
        map<long long, int> ma;
        long long l=0;
        bool b = true;
        if(m==1){
            for(int i=0;i<n-1;++i){
                if(a[i+1]<=a[i])b=false;
            }
        }
        else{
            for(int i=0;i<n;++i){
                int aa = a[i];
                if(aa<=l){
                    vector<long long> tmp(0);
                    // auto itr = ma.upper_bound(l);
                    for(auto itr=ma.end();itr!=ma.begin();){
                        itr--;
                        if((itr->first)>aa)tmp.push_back(itr->first);
                        else break;
                    }
                    for(auto i:tmp)ma.erase(i);
                    while(aa>1&&ma.find(aa)!=ma.end()&&ma[aa]>=m-1){
                        ma.erase(aa);
                        aa--;
                    }
                    if(ma.find(aa)!=ma.end()&&ma[aa]>=m-1){
                        b=false;
                        break;
                    }
                    else{
                        if(ma.find(aa)!=ma.end())ma[aa]++;
                        else ma[aa]=1;
                    }
                }
                l = a[i];
            }
        }
        if(b)r=m;
        else ll=m;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 1792
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

struct UnionFind {
	UnionFind(size_t size) : v(size, -1) {}
	vector<int> v;

    int root(int x) {
        return (v[x] < 0 ? x : v[x] = root(v[x]));
    }

    bool is_root(int x) {
        return x == root(x);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (v[x] > v[y]) swap(x, y);
            v[x] += v[y];
            v[y] = x;
        }
    }

    int size(int x) {
        return -v[root(x)];
	}
};

LL n, m;
int a[101010], b[101010];
LL ans[101010];
int main(){
    cin >> n >> m;
    UnionFind uf(n);
    REP(i, m){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    for(int i = m - 1;i >= 0;i--){
        if(i == m - 1){
            ans[i] = n * (n - 1)/2;
        }
        if(uf.same(a[i], b[i])){
            ans[i - 1] = ans[i];
        }
        else if(i != 0){
            LL c = uf.size(a[i]);
            LL d = uf.size(b[i]);
            ans[i - 1] = ans[i] - c * d;
            uf.unite(a[i], b[i]);
        }
    }
    REP(i, m){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int n,k;
	cin>>n>>k;
	vector<int> cnt(n+1);
	for(int i=0;i<k;++i) {
		int c;
		cin>>c;
		for(int j=0;j<c;++j) {
			int x;
			cin>>x;
			cnt[x]++;
		}
	}
	
	int ans=-1;
	for(auto i:cnt) ans+=i==0;
	
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 3644
n=int(input())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append([b,a])
l=sorted(l)
l=l[::-1]
c=0
for i in l:
  c+=i[1]
b=True
for i in l:
  if c>i[0]:
    b=False
    break
  else:
    c-=i[1]
if b:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 37156
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std; vector <char>k;
int main(){
	string t; cin >> t; 
	for (int i=0;i<t.size();i++){
		if(t[i]=='?') k.push_back('D');
		else k.push_back(t[i]);
	}
	for (int i=0; i<t.size(); i++) cout << k[i];
}


Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); ++i )
using namespace std;

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

Measured memory_bytes: 1152
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long K = sc.nextLong();
    if (A >= K) {
      A = A - K;
    } else {
      if (B >= (K-A)){
        B = B - (K - A);
        A = 0;
      } else {
        B = 0;
        A = 0;
      }
    }
    System.out.println(A + " " + B);
  }
}

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

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

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;

struct node
{
    int c;
    vector<int> v;
};
node arr[maxn];

ll ans=0x3f3f3f3f3f;
vector<int> v;
int n,m,x;
int check()
{
    int c[13]={0};
    for(int i=0;i<v.size();i++)
    {
        for(int j=0;j<m;j++)
        {
            c[j]+=arr[v[i]].v[j];
        }
    }
    for(int i=0;i<m;i++)
    {
        if(c[i]<x) return 0;
    }
    return 1;
}
void dfs(int num)
{
    if(num>n+1) return ;
    if(v.size()>=1)
    {
        if(check()) 
        {
            ll sum=0;
            for(int i=0;i<v.size();i++) sum+=arr[v[i]].c;
            ans=min(sum,ans);
        }
    }
    v.push_back(num);
    dfs(num+1);
    v.pop_back();
    dfs(num+1);
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i].c;
        for(int j=1;j<=m;j++)
        {
            int x;cin>>x;
            arr[i].v.push_back(x);
        }
    }
    dfs(1);
    if(ans==0x3f3f3f3f3f) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
 } 

Measured memory_bytes: 6784
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010;
int x[N],n,L,nxt[N][20];
signed main(){
	n=gi();
	for(int i=1;i<=n;i++)x[i]=gi();
	L=gi();
	for(int i=1;i<=n;i++){
		int l=i+1,r=n,ans=i;
		while(l<=r){
			int mid=(l+r)>>1;
			if(x[mid]-x[i]<=L){ans=mid;l=mid+1;}
			else r=mid-1;
		}
		nxt[i][0]=ans;
	}
	for(int j=1;j<=18;j++)
		for(int i=1;i<=n;i++)
			nxt[i][j]=nxt[nxt[i][j-1]][j-1];
	int q=gi();
	while(q--){
		int a=gi(),b=gi();if(a>b)swap(a,b);
		int ans=0;
		for(int i=18;~i;i--)
			if(nxt[a][i]<b){a=nxt[a][i];ans+=1ll<<i;}
		printf("%lld\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 17280
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


ll dp[5005], dp2[5005 * 5005];
int main() {

	ll N;
	ll g1, s1, b1, g2, s2, b2;
	cin >> N;
	cin >> g1 >> s1 >> b1 >> g2 >> s2 >> b2;



	for(int i = 1; i < N+1; i++){

		dp[i] = dp[i - 1];
		if(i >= g1)
			dp[i] = max(dp[i], g2 - g1 + dp[i - g1]);
		if (i >= b1)
			dp[i] = max(dp[i], b2 - b1 + dp[i - b1]);
		if (i >= s1)
			dp[i] = max(dp[i], s2 - s1 + dp[i - s1]);

		
	}


	for (int i = 1; i < N + dp[N] + 1; i++) {
		dp2[i] = dp2[i - 1];

		if (i >= g2)
			dp2[i] = max(dp2[i], g1 - g2 + dp2[i - g2]);
		if (i >= b2)
			dp2[i] = max(dp2[i], b1 - b2 + dp2[i - b2]);
		if (i >= s2)
			dp2[i] = max(dp2[i], s1 - s2 + dp2[i - s2]);


	}
	
	cout << N + dp[N] + dp2[N + dp[N]] << endl;

	return 0;
}

Measured memory_bytes: 195584
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    fscanf(STDIN, "%d%d", $x, $y);
    $X[] = $x-1;
    $Y[] = $y-1;
    $orderX[$i] = $i;
    $orderY[$i] = $i;
}
array_multisort($X, $orderX);
array_multisort($Y, $orderY);

$k = new Kruskal($n);
for($i = 0; $i < $n - 1; $i++){
    $k->connect($orderX[$i] + 1, $orderX[$i+1] + 1, abs($X[$i] - $X[$i+1]));
    $k->connect($orderY[$i] + 1, $orderY[$i+1] + 1, abs($Y[$i] - $Y[$i+1]));
}
echo $k->build();

class Kruskal{
    public $I, $J, $L;
    public $uft;
    function __construct($n){
        $this->uft = new UFT($n);
    }
    function connect($i, $j, $l){
        $this->I[] = $i;
        $this->J[] = $j;
        $this->L[] = $l;
    }
    function build(){
        $total = 0;
        array_multisort($this->L, $this->I, $this->J);
        foreach($this->L as $k => $l){
            if($this->uft->getRoot($this->I[$k]) != $this->uft->getRoot($this->J[$k])){
                $this->uft->unite($this->I[$k], $this->J[$k]);
                $total+=$l;
            }
        }
        return $total;
    }
}

class UFT{
    public $parent;
    public $size;
    public $rank;
    public function __construct($size){
        for($i = 1; $i <= $size; $i++){
            $this->size[$i] = 1;
            $this->rank[$i] = 1;
            $this->parent[$i] = 0;
        }
    }
    public function dump(){
        o("--------------");
        o($this->parent);
        o($this->size);
        o($this->rank);
    }
    public function getRoot($i){
        if($this->parent[$i] == 0){
            return $i;
        }else{
            return $this->getRoot($this->parent[$i]);
        }
    }
    public function unite($i, $j){
        $rootI = $this->getRoot($j);
        $rootJ = $this->getRoot($i);
        if($rootJ == $rootI)return false;//元から同じグループ
        if($this->rank[$rootI] > $this->rank[$rootJ])list($rootI, $rootJ) = [$rootJ, $rootI];//Rank(J)>Rank(I)に揃えておく
        $this->parent[$rootI] = $rootJ;
        if($this->rank[$rootI] == $this->rank[$rootJ]){
            $this->rank[$rootJ]++;
        }
        $this->size[$rootJ]+=$this->size[$rootI];
        $this->size[$rootI] = '*';//不要な情報となるので潰す/デバッグ出力向けに*を入れている
        $this->rank[$rootI] = '*';//同上
    }
    public function size($i){return $this->size[$this->getRoot($i)];}
    public function isUnion($i, $j){return $this->getRoot($i) == $this->getRoot($j);}
}

Measured memory_bytes: 90836
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

const int MAX = 100009;

vi adj[MAX];
int cnt[MAX], parent[MAX];

void dfs(int here) {
	vi visit;
	for (auto there : adj[here]) {
		if (cnt[there] == 1) {
			parent[there] = here;
			visit.pb(there);
		}
		cnt[there]--;
	}
	for (auto there : visit) {
		dfs(there);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(n); ini(m);
	forn(i, 0, n-1+m) {
		ini(a); ini(b);
		cnt[b]++;
		adj[a].pb(b);
	}
	//forn(i, 1, n+1) outn(cnt[i]);
	int r;
	forn(i, 1, n+1) if (!cnt[i]) r = i;
	parent[r] = 0;
	dfs(r);
	forn(i, 1, n+1) outn(parent[i]);
	
	return 0;
}


Measured memory_bytes: 19584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <queue>
#include <map> 
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

vector<vector< int > >  g;


int main(){
   int n,x,y;
   cin >> n >> x >> y;
   g.resize(n);
   g[x-1].push_back(y-1);
   g[y-1].push_back(x-1);
   rep(i,n-1){
      g[i+1].push_back(i);
      g[i].push_back(i+1);
   }
   map<int,int> m;
   for (int i = 0;i < n;i++){
      queue<int> q;
      vector<int> dist(n,-1);
      dist[i] = 0;
      q.push(i);
      while(!q.empty()){
         int now = q.front();q.pop();
         for(auto nx:g[now]){
            if (dist[nx] == -1){
               dist[nx] = dist[now] + 1;
               q.push(nx);
            }
         }
      }
      for (int i = 0;i < n;i++){
         m[dist[i]]++;
      }
   }
   for (int i = 1; i < n;i++){
      cout << m[i]/2 << endl;
   }  

   return 0;
}



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

using namespace std;

int adjMat[212][212];
int p[212];
int n;

bool dfs(int x, int v) {
	p[x] = v;
	int vv = (!(v-1)) + 1;
	for (int y = 0; y < n; y++) {
		if (!adjMat[x][y]) continue;
		if (y == x) continue;
		if (p[y] == 0) {
			if (!dfs(y, vv)) return false;
		} else if (p[y] != vv) {
			return false;
		}
	}
	return true;
}

int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			char c;
			cin >> c;
			adjMat[i][j] = (c == '1');
		}
	}
	p[0] = 1;
	if (!dfs(0, 1)) {
		cout << "-1\n";
		return 0;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (k == i || i == j || k == j) continue;
				if (!adjMat[i][k] || !adjMat[k][j]) continue;
				if (!adjMat[i][j] || adjMat[i][j] > adjMat[i][k] + adjMat[k][j])
					adjMat[i][j] = adjMat[i][k] + adjMat[k][j];
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) 
			ans = max(ans, adjMat[i][j]);
	cout << ans + 1 << '\n';
	return 0;
}


Measured memory_bytes: 384
n,m,s=map(int,input().split())
s=min(s,2500)
edge=[[] for i in range(n*50*51)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        edge[u-1+j*n].append((v-1+(j-a)*n,b))
        edge[v-1+j*n].append((u-1+(j-a)*n,b))
for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i+j*n].append((i+(j+c)*n,d))
    for j in range(2500):
        edge[i+(j+1)*n].append((i+j*n,0))
s=s*n
from heapq import heappush,heappop,heapify
d = [float('inf') for i in range(n*50*51)]
pq = []
d[s]=0
heappush(pq,(0,s))
while pq:
    dist,u = heappop(pq)
    for v,cost in edge[u]:
        if d[v]<=dist+cost:
            continue
        d[v]=dist+cost
        heappush(pq,(d[v],v))
for i in range(1,n):
    print(d[i])

Measured memory_bytes: 131416
#include <iostream>

using ll = long long;

int main()
{
    ll N, A, B;
    std::cin >> N >> A >> B;

    ll kumi = N / (A + B);
    ll amari = N - (A + B) * kumi;
    if (amari > A) amari = A;
    ll ans = kumi * A + amari;

    std::cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for (int i = 0; i < n; ++i)if(i==k-1) s[i]=s[i]+32;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
string1 , string2 = map(str,input().split())
res = ''
j = 0
k = 0
for i in range((2*N)):
	if(i%2==0):
		res+=string1[j]
		j+=1
	else:
		res+=string2[k]
		k+=1
print(res)

Measured memory_bytes: 38256
n=int(input())
l=list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      if a != b and b != c and a != c:
        ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)


Measured memory_bytes: 74152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
map<ll,ll> m;
ll larg(ll x){
	ll p = 1;
	while(x>=p){
		p*=2;
	}
	return p;
}
int main(){
	int n,ans=0;
	vector<ll> a;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		m[x]++;
		a.pb(x);
	}
	sort(a.begin(),a.end());
	for(int i=a.size()-1;i>=0;i--){
		ll tg = larg(a[i])-a[i];
		if(tg == a[i]){
			ans += m[ a[i] ]/2;
			m[a[i]] %= 2;
		}
		else{
			ll t = min(m[tg],m[a[i]]);
			ans += t;
			m[tg] -= t;
			m[a[i]] -= t;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
ll lookup[101][501];

ll power(ll a,ll b)
{
    ll res=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res * a)%mod;
        }
        b/=2;
        a = (a*a)%mod;
    }
    return res;
}

int main()
{
    fast;
    ll n;
    cin>>n;
    ll k=n;
    if(n==2) {cout<<"1";return 0;}
    if(n==3) {cout<<"2";return 0;}
    if(n==4) {cout<<"3";return 0;}
    if(n==5) {cout<<"3";return 0;}
    ll ans=2;
    for(ll i=2;i*i<=n;i++)
    {
        k=n;
        if(k%i == 0)
        {
            while(k%i==0)
            {
                k/=i;
            }
            if(k%i == 1) {ans++;}
            if(i*i!=n)
            {
                ll h=i;
                ll j=n/i;
                while(h%j==0)
                {
                    h/=j;
                }
                if(h%j == 1) {ans++;}
            }
        }
    }
    for(ll i=2;i*i<=(n-1);i++)
    {
        if((n-1)%i==0)
        { ans++;
           if(i*i != (n-1)) ans++; 
       }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#define pb push_back
using namespace std;
const int maxn=1e6+10;
int n,h[maxn],m,ans;
bool ok[maxn];
int main()
{
	scanf("%d%d",&n,&m); memset(ok,1,sizeof ok);
	for (int i=1;i<=n;i++) scanf("%d",&h[i]);
	for (int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		if (h[x]<=h[y]) ok[x]=0;
		if (h[y]<=h[x]) ok[y]=0;
	}
	for (int i=1;i<=n;i++) ans+=ok[i];
	printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;

char a[105][105];

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n, m; cin >> n >> m;
	rep(i, n) rep(j, m) cin >> a[i][j];
	vi v;
	rep(i, m) rep(j, n) if(a[j][i] != '.'){
		v.add(i);
		break;
	}
	rep(i, n) rep(j, m) if(a[i][j] != '.') {
		for(auto x : v) cout << a[i][x];
		print("");
		break;
	}
	return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

string s;
size_t cur;

P expression();

int rnum(){
	int res = 0;
	while(cur < s.size() && isdigit(s[cur])){
		res = res * 10 + s[cur++] - '0';
		if(res > 10000){
			while(cur < s.size()) cur++;
			return INF;
		}
	}
	return res;
}

P number(){
	if(s[cur] == 'i'){
		cur++;
		return P(0, 1);
	}else{
		P p(0, 0);
		p.first = rnum();
		if(p.first == INF) return P(INF, INF);
		return p;
	}
}

P term(){
	P a;
	P b;
	if(s[cur] == '('){
		cur++;
		a = expression();
		if(cur >= s.size()) return a;
		assert(s[cur] == ')');
		cur++;
	}else{
		a = number();
	}
	if(abs(a.first) > 10000 || abs(a.second) > 10000){
		while(cur < s.size()) cur++;
		return P(INF, INF);
	}
	while(cur < s.size() && (s[cur] == '*')){
		cur++;
		assert(cur < s.size());
		if(s[cur] == '('){
			cur++;
			assert(cur < s.size());
			b = expression();
			if(cur >= s.size()) return b;
			assert(s[cur] == ')');
			cur++;
		}else{
			b = number();
		}
		if(abs(b.first) > 10000 || abs(b.second) > 10000){
			while(cur < s.size()) cur++;
			return P(INF, INF);
		}
		int a1 = a.first;
		int a2 = a.second;
		a.first = a1 * b.first - a2 * b.second;
		a.second = a1 * b.second + a2 * b.first;
		if(abs(a.first) > 10000 || abs(b.second) > 10000){
			while(cur < s.size()) cur++;
			return P(INF, INF);
		}
	}
	return a;
}

P expression(){
	P a = term();
	if(abs(a.first) > 10000 || abs(a.second) > 10000){
		while(cur < s.size()) cur++;
		return P(INF,INF);
	}
	P b;
	while(cur < s.size() && (s[cur] == '+' || s[cur] == '-')){
		char op = s[cur++];
		assert(cur < s.size());
		b = term();
		if(abs(b.first) > 10000 || abs(b.second) > 10000){
			while(cur < s.size()) cur++;
			return P(INF, INF);
		}
		if(op == '+'){
			a.first += b.first;
			a.second += b.second;
		}else{
			a.first -= b.first;
			a.second -= b.second;
		}
		if(abs(a.first) > 10000 || abs(a.second) > 10000){
			while(cur < s.size()) cur++;
			return P(INF,INF);
		}
	}
	return a;
}



int main(){
	while(cin >> s){
		if(s.empty()) break;
		cur = 0;
		P p = expression();
		if(abs(p.first) > 10000 || abs(p.second) > 10000){
			cout << "overflow" << endl;
		}else{
			if(p.first != 0){
				cout << p.first;
				if(p.second != 0){
					if(p.second > 0) cout << "+";
					cout << p.second << "i";
				}
			}else{
				if(p.second == 0){
					cout << 0;
				}else{
					cout << p.second << "i";
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
  #N_C_kのN
  for i in range(2, n+10):
    fac.append(fac[-1]*i%Mod)
    inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
    finv.append(finv[-1] * inv[-1] % Mod)


def COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod


COMinit()

ans = 0

for i in range(min(n, k)+1):
  ans += (COM(n, i) * COM(n-1, n-i-1))
  ans %= Mod

print(ans)

Measured memory_bytes: 115960