akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t Int;
using namespace std;
 
int main(){
    int H, W, K;
    vector<vector<char>> S(310, vector<char>(300));
    vector<vector<int>> ans(310, vector<int>(300, 0));
    vector<bool> exist(310, false);

    cin >> H >> W >> K;

    int id = 1;
    rep(i,H) rep(j,W){
        cin >> S[i][j];
        if(S[i][j] == '#'){
            ans[i][j] = id; id++;
            exist[i] = true;
        }
    }

    id = 0;
    rep(i, H){
        if(exist[i]){
            rep(j, W){
                if(j == 0 && ans[i][j] == 0) ans[i][j] = ++id;
                else if(ans[i][j] == 0) ans[i][j] = ans[i][j-1];
                
                id = ans[i][j];
            }
        }
    }

    rep(i, H){
        if(!exist[i] && i != 0){
            rep(j, W) ans[i][j] = ans[i-1][j];
            if(ans[i][0] != 0) exist[i] = true;
        }
    }

    
    for(int i = H-1; i>=0; i--){
        if(!exist[i] && i != H-1){
            rep(j, W) ans[i][j] = ans[i+1][j];
        }
    }
    
    rep(i, H){
        rep(j, W) cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int dp[405][405];

int main(void)
{
  int n, ma, mb, a[40], b[40], c[40];
  cin >> n >> ma >> mb;
  REP(i, n) {
    cin >> a[i] >> b[i] >> c[i];
  }

  REP(i, 401) REP(j, 401) dp[i][j] = INF;

  REP(i, n) {
    for(int j=400; j>=0; j--) {
      for(int k=400; k>=0; k--) {
        if(dp[j][k] != INF && j+a[i] <= 400 && k+b[i] <= 400) {
          //cout << j+a[i] << " " << k+b[i] << endl;
          dp[j+a[i]][k+b[i]] = min(dp[j+a[i]][k+b[i]], dp[j][k] + c[i]);
        }
      }
    }
    dp[a[i]][b[i]] = min(dp[a[i]][b[i]], c[i]);
  }

  int ret = INF, ii = ma, jj = mb;
  while(ii <= 400 && jj <= 400) {
    if(dp[ii][jj] != INF) ret = min(dp[ii][jj], ret);
    ii += ma;
    jj += mb;
  }

  /*REP(i, 10) {
    REP(j, 10) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/

  if(ret == INF) cout << -1 << endl;
  else cout << ret << endl;

  return 0;
}


Measured memory_bytes: 896
#include <iostream>

int N, K;
int hate[10];

bool okay() {
  int cur = N;
  while (cur) {
    if (hate[cur % 10])
      return false;
    cur /= 10;
  }
  return true;
}

int main() {
  std::cin>>N>>K;
  for (int i = 0; i < K; ++i) {
    int x;  std::cin>>x;
    hate[x] = 1;
  }

  while (!okay())
    ++N;

  std::cout<<N<<"\n";

  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N-1: 
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        if start == N-2:
            break
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)

Measured memory_bytes: 92840
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
#define MAX (100000)
#define NIL (-1)

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();S.pop();
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id=1;
    for(int i=0;i<n;i++)color[i]=NIL;
    for(int i=0;i<n;i++){
        if(color[i]==NIL)dfs(i,id++);
    }
}

int main(void){
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8984
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(e5 + 10);
  F(i, 0, n) {
    l x; cin >> x;
    if (x > 0) v[x - 1]++;
    v[x]++;
    v[x + 1]++;
  }
  l answer = 0;
  for (auto i : v) answer = max(answer, i);
  cout << answer << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main() {
  int n, s[100000], q, t[50000], i, left, right, mid, count = 0;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &s[i]);
 
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &t[i]);
 
  for(i = 0; i < q; i++){
    left = 0;
    right = n;
 
    while(left < right){
      mid = (left + right)/2;
 
      if(s[mid] == t[i]){
    count++;
    break;
      }
 
      else if(s[mid] < t[i])
    left = mid + 1;
      else
    right = mid;
    }
 
  }
 
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1184
n = gets.to_i
a = []
n.times do
  x,len = gets.split.map(&:to_i)
  a << [x-len,x+len]
end
a.sort_by!{|a|a[1]}
ans = 0
pre = [-10**12,-10**12]
while !a.empty?
  now = a.shift
  if pre[1] <= now[0]
    ans += 1
    pre = now
  end
end
puts ans


Measured memory_bytes: 12688
def binomial(n, k):
    if n < k:
        return 0

    n2, k2 = 1, 1
    for i in range(1, min(k, n - k) + 1):
        n2 *= n
        k2 *= i
        n -= 1
    return n2 // k2


mod = 10**9 + 7
N, K = map(int, input().split())
for i in range(1, K + 1):
    a = binomial(N - K + 1, i) * binomial(K - 1, i - 1)
    print(a % mod)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int N = S.size();
  int M = (N-1)/2;
  int L = (N+3)/2;
  int count1 = 0;
  int count2 = 0;
  int count3 = 0;
  int kaibun = 0;
  for(int i=0; i<N; i++){
    if(S.at(i)==S.at(N-1-i)){
      count1++;
    }
    if(count1==N){
      kaibun++;
    }
    }
  
   for(int i=0; i<M; i++){
    if(S.at(i)==S.at(M-1-i)){
      count2++;
    }
    if(count2==M){
      kaibun++;
    }
    }
   for(int i=L-1; i<N; i++){
    if(S.at(i)==S.at(N+L-i-2)){
      count3++;
    }
    if(count3==N-L+1){
      kaibun++;
    }
    }
	
  if(kaibun==3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
vector<T> Divisor(T n) {
	vector<T> ret;
	
	for(T i = 1; i * i <= n; ++i) {
		if( n % i == 0 ) { 
			ret.push_back(i);	
			if( i * i != n ) ret.push_back(n / i);
		}
	}
	
	sort(ret.begin(), ret.end());
	
	return ret;
}

template<typename T>
bool prime_factor(T n) {
	for(T i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) return false;
	}
	
	return true;
}

template<typename T>
vector<T> common_divisor(vector<T> &a, vector<T> &b) {
	
	vector<T> ret;
	
	for(int i = 0; i < a.size(); ++i) {
		auto result = find(b.begin(), b.end(), a[i]);
		
		if( result != b.end() ) ret.push_back(a[i]);
	}
	
	return ret;
}

int main(void) {
	ll a, b;
	cin >> a >> b;
	
	vector<ll> div, div2, div3;
	
	div = Divisor(a);
	div2 = Divisor(b);
	div3 = common_divisor(div, div2);
	
	int ans = 0;
	for(auto x : div3) {
		if( prime_factor(x) ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Node{
public:
  long long w;
  long long v;
};

class UnionFind{
public:
  vector<long long> parent;
  UnionFind(long long N){
    parent.resize(N + 1);
    for (int i = 0; i < N;i++){

    }
  }
};

int main()
{
  long long X, Y, Z;
  cin >> X >> Y >> Z;
  X-=(2*Z);
  long long ans=0;
  while (X >= Y)
  {
    ans++;
    X -= Y;
    X -= Z;
  }
  cout << ans << endl;
}


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

int main() {
  int n, sum, r;
  string c;
  cin >> n >> c;
  sum = 0;

  // ここにプログラムを追記
  rep (i, n) {
    if (c[i] == 'R') {
      sum++;
    }
  }
  r = sum;
  rep (i, sum) {
    if (c[i] == 'R') {
      r--;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define Nmax 55
ll dp[Nmax][Nmax][Nmax*Nmax];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N,K; cin>>N>>K;
    for(int i=0;i<Nmax;i++)for(int j=0;j<Nmax;j++)for(int k=0;k<Nmax*Nmax;k++){
	dp[i][j][k]=0;
    }
    dp[0][0][0]=1;
    for(ll n=0;n<N;n++)for(ll x=0;x<=N;x++)for(ll k=0;k<=K;k++){
	mad(dp[n+1][x+1][k+2*x],dp[n][x][k]);
	mad(dp[n+1][x+0][k+2*x],dp[n][x][k]*(2*x+1));
	if(x)mad(dp[n+1][x-1][k+2*x],dp[n][x][k]*x*x);
    }
    cout<<dp[N][0][K]<<endl;
}




Measured memory_bytes: 71808
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input;

        input = Console.ReadLine().Split(' ');

		// モンスターの数
		int monsters = int.Parse(input[0]);
		// 必殺技の数
		int h_max = int.Parse(input[1]);

		// モンスターのHP
	    input = Console.ReadLine().Split(' ');
        List<int> lstHP = new List<int>();
		foreach (string v in input)
		{
			lstHP.Add(int.Parse(v));
		}
        // モンスターのHPが高い方から並べて
		lstHP.Sort();
		lstHP.Reverse();

		int max = monsters;
        if(monsters >= h_max) {
			max = h_max;
        }
		Int64 sum = 0;
		int i;
		for (i = 0; i < max; i++)
		{
			lstHP[i] = 0;
			//sum++;
		}
        // 必殺技が使えなかったモンスター達
        for(; i < monsters ;i++ ) {
			sum += lstHP[i];
        }
		Console.WriteLine(sum);
	}
}


Measured memory_bytes: 37760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	string s;
	cin >> a >> b;
	cin >> s;
	for(int i=0;i<a;i++){
		if(s[i]=='-'){
			cout << "No" << endl;
			return 0;
		}
	}
	if(s[a]!='-'){
		cout << "No" << endl;
		return 0;
	}
	for(int i=a+1;i<a+b;i++){
		if(s[i]=='-'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String str =sc.next();
        
        if(a>=3200){
            System.out.println(str);
        }else{
            System.out.println("red");
        }
    }
}


Measured memory_bytes: 35384
#include<iostream>
using namespace std;
#include<string>
#include<cctype>
int main(){
    string target,x;
    cin>>target;
    for(int i=0;i<target.size();i++){
        target[i]=tolower(target[i]);
    }
    cin>>x;
    int cnt=0;
    while(x != "END_OF_TEXT"){
        for(int i=0;i<x.size();i++){
        x[i]=tolower(x[i]);
        }
        if(x==target){
            cnt++;
        }
        cin>>x;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3208
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
ans = []
for i in range(H):
    ans_s = []
    for j in range(W):
        if S[i][j] == "#":
            ans_s.append("#")
        else:
            bom = 0
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if 0 <= i - x and i - x <= H - 1 and 0 <= j - y and j - y <= W - 1:
                        if not (x == 0 and y == 0):
                            if S[i - x][j - y] == "#":
                                bom += 1
            ans_s.append(str(bom))
    ans.append(ans_s)

for s in ans:
    print("".join(s))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>a>>b>>c>>n;
    while (b<=a)
    {
        b*=2;n--;
    }
    while (c<=b)
    {
        c*=2;n--;
    }
    if(n>=0)cout<<"Yes";
    else cout<<"No";
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3652
n=int(input())
d={}
for i in range(4):
    for j in range(3):
        d[(i+1,j+1)]=[0,0,0,0,0,0,0,0,0,0]
for i in range(n):
    b, f, r, v = map(int,input().split())
    d[(b,f)][r-1]+=v
for i in range(4):
    for j in range(3):
        print(" "+" ".join(map(str,d[i+1,j+1])))
    if i <3:
        print("####################")


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    int ns[101];
    for(int i = 0; i < 101; i++){
        ns[i] = 1;
    }

    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        ns[x - 1] = 0;
    }

    int ans = 10000;
    for(int i = 0; i < 101; i++){
        if(abs(n - ans) > abs(n - (i + 1))){
            if(ns[i]) ans = i + 1;
        }
    }

    if(abs(n - ans) >= abs(n)){
         ans = 0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

ll N, X;
vector<ll> S;

const ll MOD = 1e9+7;
ll mod(ll x) {
    return x % MOD;
}

void input() {
    cin >> N >> X;
    S.resize(N);
    for (auto &s : S)
        cin >> s;
}

ll solve() {
    sort(S.rbegin(), S.rend());
    vector<ll> dp(X+1);
    dp[X] = 1;
    for (ll i = 0; i < N; i++) {
        for (ll x = 0; x <= X; x++) {
            if (dp[x] == 0)
                continue;
            ll dpx = dp[x], xn = x % S[i];
            dp[x] = mod(dpx * (N-i-1));
            dp[xn] = mod(dp[xn] + dpx);
        }
    }
    ll ans = 0;
    for (ll x = 0; x <= X; x++) {
        ans = mod(ans + x * dp[x]);
    }
    return ans;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



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

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double INF = 1e9;

bool compX(const Point a, const Point b) {
    return (a.X!=b.X ? a.X<b.X : a.Y<b.Y);
}

bool compY(const Point a, const Point b) {
    return a.Y<b.Y;
}

double closestPair(Point *a,int n) {
    if(n<=1) return INF;
    int m = n/2;
    double x = a[m].X;
    double d = min(closestPair(a,m),closestPair(a+m,n-m));
    inplace_merge(a,a+m,a+n,compY);
    
    VP b;
    rep(i,n){
        if(abs(a[i].X - x)>=d)continue;
        for(int j=b.size()-1;j>=0;j--){
            Point ba = a[i]-b[j];
            if(ba.Y>=d)break;
            d = min(d,abs(ba));
        }
        b.push_back(a[i]);
    }
    return d;
}
int main(void){
    int n;
    cin>>n;
    Point ps[n];
    rep(i,n){
        double x,y;
        cin>>x>>y;
        ps[i] = Point(x,y);
    }
    sort(ps,ps+n,compX);
    printf("%.9f\n",closestPair(ps,n));
    return 0;
}

Measured memory_bytes: 7884
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include<vector>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;

int main()
{
    ll mod = 1000000007;
    ll h,w;
    cin>>h>>w;
    char m[h+1][w+1];
    for(ll i=0;i<=h;i++){
        for(ll j=0;j<=w;j++){
            m[i][j]='0';
        }

    }
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            cin>>m[i][j];
        }
    }
   /* for(ll i=0;i<=h;i++){
     cout<<"\n";
        for(ll j=0;j<=w;j++){
            cout<<m[i][j]<<" ";
        }

    }*/
    ll dp[h+1][w+1];
    for(ll i=0;i<=h;i++){
        for(ll j=0;j<=w;j++){
            dp[i][j]=0;
        }

    }
    dp[1][1]=1;dp[0][1]=1;
    /*for(ll i=0;i<=h;i++){
     cout<<"\n";
        for(ll j=0;j<=w;j++){
            cout<<dp[i][j]<<" ";
        }

    }*/
    //cout<<"\n\n";
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            if(m[i][j]=='#'){
                dp[i][j]=0;

            }
            else{
                dp[i][j]=dp[i-1][j]%mod;
                dp[i][j]=(dp[i][j]+ (dp[i][j-1]%mod))%mod;
            }
        }
    }
    /*for(ll i=0;i<=h;i++){
     cout<<"\n";
        for(ll j=0;j<=w;j++){
            cout<<dp[i][j]<<" ";
        }

    }*/
    cout<<dp[h][w];
}




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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NY = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var N = NY[0];
            var Y = NY[1];

            var count = 0;

            if (Y>10000*N)
            {
                Console.WriteLine("-1 -1 -1");
            }
            else
            {
                for(int i =0; i <= N; i++)
                {
                    for (int j =0; j<= N-i; j++)
                    {
                        int k = N - i - j;
                        if(i*10000 + j * 5000+ k* 1000 == Y)
                        {
                            Console.WriteLine(i+" "+j+" "+k);
                            return;
                        }
                    }
                }

                Console.WriteLine("-1 -1 -1");
                return;
            }

        }
    }

}


Measured memory_bytes: 13268
lis = []
for _ in range(5):
  lis.append(int(input()))
mod = []
for i in lis:
  mod.append(i%10)
if mod == [0,0,0,0,0]:
  print(sum(lis))
else:
  k = min(mod) if min(mod) != 0 else sorted(set(mod))[1]
  ans = 0
  for i in range(5):
    if i == mod.index(k):
      ans += lis[i]
    else:
      ans += ((lis[i]+9)//10)*10
  print(ans)

    

Measured memory_bytes: 38256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

struct Trie {
  Trie *children[2];
  Trie() {
    fill(children, children+2, nullptr);
  }
  void add(const string &s) {
    Trie *cur = this;
    for (char ch : s) {
      int d = ch - '0';
      if (!cur->children[d]) {
        cur->children[d] = new Trie();
      }
      cur = cur->children[d];
    }
  }
};

long long dfs(Trie *r, int lv, long long L) {
  if (lv == L) {
    return 0;
  }
  if (!r->children[0] && !r->children[1]) {
    return 0;
  }
  long long Xor = 0;
  for (int d = 0; d < 2; d++) {
    if (r->children[d]) {
      Xor ^= dfs(r->children[d], lv + 1, L);
    } else {
      long long h = L - lv;
      int p = 0;
      while (h > 0 && h % 2 == 0) {
        p++;
        h /= 2;
      }
      Xor ^= (1LL << p);
    }
  }
  return Xor;
}

const int N = int(1e5);
char s[N+1];

int main(void) {
  int n; long long L;
  scanf("%i %lld", &n, &L);
  
  Trie *tree = new Trie();
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    tree->add(string(s));
  }
  
  puts(dfs(tree, 0, L) ? "Alice" : "Bob");
  
  return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    rep(i,10) rep(j,10){
        if(i*j == n) {
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3676
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    multiset <int> a, b;
    n = (1 << n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a.insert(-x);
    }
    int val = *a.begin();
    a.erase(a.find(val));
    b.insert(-val);
    int k = 1;
    for (int i = 1; i < n * 2; i ++)
    {
        if (a.empty())
            break;
        vector <int> flex;
        for (auto it : b)
        {
            auto f = a.upper_bound(-it);
            if (f == a.end())
            {
                cout << "No";
                return 0;
            }
            flex.pb(*f);
            a.erase(a.find(*f));
        }
        for (auto it : flex)
            b.insert(-it);
        k *= 2;
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 13304
#include <cassert>// c
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>
using namespace std;

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

#define ALL(c) c.begin(),c.end()
template<class T> bool IN(T l,T v,T r){return l<=v && v <r;}
template<class T> void UNIQUE(T v){v.erase(unique(ALL(v)),v.end());}
//debug
#define DUMP(x) cerr << #x <<" = " << (x)
#define LINE() cerr<< " (L" << __LINE__ << ")"

// values
template<typename T> inline T INF(){assert(false);};
template<> inline int INF<int>(){return 1<<28;};
template<> inline ll INF<ll>(){return 1LL<<58;};
template<> inline double INF<double>(){return 1e16;};
template<> inline long double INF<long double>(){return 1e16;};

template<class T> inline T EPS(){assert(false);};
template<> inline int EPS<int>(){return 1;};
template<> inline ll EPS<ll>(){return 1LL;};
template<> inline double EPS<double>(){return 1e-8;};
template<> inline long double EPS<long double>(){return 1e-8;};

// min{2^r | n < 2^r}
template<typename T> T upper_pow2(T n){ T res=1;while(res<n)res<<=1;return res;}
// max{d | 2^d  <= n}
template<typename T> T msb(T n){ int d=63;while((1LL<<d)>n)d--;return d;}

template<typename T,typename U> T pmod(T v,U M){return (v%M+M)%M;}

class Main{
	public:
	void run(){
		int N;cin >> N;
		vector<int> rs(N),cs(N);
		
		for(int i=0;i<N;i++)cin >> rs[i] >> cs[i];

		vector<vector<ll>> dp(N,vector<ll>(N+1,INF<ll>()));
		for(int l=0;l<N;l++) dp[l][l+1] = 0;

		for(int d=2;d<=N;d++)for(int l=0;l+d<=N;l++){
			int r = l+d;
			for(int m=l+1;m<r;m++){
				dp[l][r] = min(dp[l][r],dp[l][m] + rs[l] * rs[m] * cs[r-1] + dp[m][r]);
			}
		}
		cout << dp[0][N] <<endl;
	}
};

int main(){
	cout <<fixed<<setprecision(20);
	cin.tie(0);
	ios::sync_with_stdio(false);
	Main().run();
	return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,a,b;
ll x[100100];
ll ans;

int main(){
	cin>>n>>a>>b;
	REP(i,n)
		cin>>x[i];
	
	for(int i=0;i<n-1;i++){
		ll t=x[i+1]-x[i];
		if(t*a>b){
			ans+=b;
		}else{
			ans+=t*a;
		}
	}
	cout<<ans<<endl;
	return 0;
}
	

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

char s[110];
int main()
{
    int n; scanf("%d",&n);
    scanf("%s",s+1);
    int len=strlen(s+1);
    if(len>n){
        for(int i=1;i<=n;++i) printf("%c",s[i]);
        puts("...");
    }
    else printf("%s\n",s+1);
    
}

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

def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]
def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]
p=list(int(i)-1 for i  in input().split())
pp=p
ans=0
#007映画　4/10
s=[list(int(i)-1 for i  in input().split()) for _ in range(m)]
for x, y in s:
    unite(a,x,y)
for i in range(n):
    if find(a,i)==find(a,pp[i]):
        ans+=1

print(ans)

Measured memory_bytes: 104368
#include <iostream>

using namespace std;

int main()
{
	char C;
	cin >> C;

	switch (C)
	{
	case 'a':
	case 'i':
	case 'u':
	case 'e':
	case 'o':
		cout << "vowel" << endl;
		break;
	default:
		cout << "consonant" << endl;
		break;
	}
}


Measured memory_bytes: 256
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>
#include<math.h>


using namespace std;
#define rep(i, n) for ( int i = 0; i < ( int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < ( int)(n); i++)

int main() {


	int n=1,t=0;
	string s;
	cin >> s;
	rep2(i,1, 3) {
		if (s[i] == 'R'&&s[i-1]=='R') {
			
			n++;
		}
		
	}
	rep(i, 3) {
		if (s[i] == 'S')t++;
	}
	if (t == 3) n = 0;
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
int main(){
	int vector[3];
	int conteo,k,valor,i;
	for(conteo=0;conteo<3;conteo++){
		vector[conteo]=-1;
	}
	for(conteo=0;conteo<10;conteo++){
		scanf("%d",&valor);
		if(valor>vector[2]){
			vector[2]=valor;
			
			if(vector[2]>vector[1]){
				int aux=vector[2];
					vector[2]=vector[1];
					vector[1]=aux;
				if(vector[1]>vector[0]){
					int aux=vector[1];
						vector[1]=vector[0];
						vector[0]=aux;	
				}
			}
		}
	}
	for(conteo=0;conteo<3;conteo++){
		printf("%d\n",vector[conteo]);
	}	
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#define min(a,b) ((a)<(b)?(a):(b))
int main()
{
	long long Q,H,S,D,N;
	scanf("%lld %lld %lld %lld\n%lld",&Q,&H,&S,&D,&N);
	long long cost=min(min(min(8*Q,4*H),2*S),D);
	if(cost==D){
		if(N%2==0){
			printf("%lld\n",N/2*D);
		}else{
			printf("%lld\n",N/2*D+min(min(4*Q,2*H),S));
		}
	}else{
		cost/=2;
		printf("%lld\n",N*cost);
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 10000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buff[20],len; len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buff[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buff[--len]+'0');
}
inline void writeln(ll x)
{
	write(x); putchar('\n');
}
inline void writesp(ll x)
{
	write(x); putchar(' ');
}
char s[110],goal[7]={'k','e','y','e','n','c','e'};
int n;
int main()
{
	scanf("%s",s); n=strlen(s);
	for(int i=0;i<7;i++){
		int flag=1;
		for(int k=0;k<=i;k++)
			if(s[k]!=goal[k]){
				flag=0; break;
			}
		for(int k=6;k>i;k--)
			if(s[n-7+k]!=goal[k]){
				flag=0; break;
			}
		if(flag){
			puts("YES"); return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <utility>

using namespace std;

int main()
{
	int n, m;
	vector<pair<int, int> > place;
	int vote[100], v[100];

	while(1){
		for(int i = 0; i < 100; i++)    v[i] = 0;

		place.clear();

		cin >> n >> m;

		if(n == 0 && m == 0)    break;

		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++)
				cin >> vote[j];
			for(int j = 0; j < m; j++){
				if(vote[j])    v[j]--;
				else        v[j]++;
			}
		}

		for(int i = 0; i < m; i++)
			place.push_back(make_pair(v[i], i+1));


		sort(place.begin(), place.end());

		for(int i = 0; i < m; i++){
				cout << place[i].second;
				if(i != m - 1)    cout << " ";
		}
		cout << "\n";
	}

	return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

const int INF = 1e5;

int n,x;
int pre[305];

int main() {
	cin >> x >> n;
	int num;
	for(int i=0;i<n;i++) {
		cin >> num;
		pre[105 + num] = 1;
	}

	int ans;
	int diff = INF;

	for(int i=-105;i<=105;i++) {
		int t = i + 105;
		if(pre[t] != 1) {
			if(abs(x-i) < diff) {
				diff = abs(x-i);
				ans = i;
			}
			else if(abs(x-i) == diff) {
				if(i < ans) {
					ans = i;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

const int N = 200005;
const int mod = 998244353;

void add(int& x,int y,int p = mod) {
	x += y; if (x >= p) x -= p;
}

void sub(int& x,int y,int p = mod) {
	x -= y; if (x < 0) x += p;
}

int mul(int x,int y) {
	return 1LL * x * y % mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mul(ret, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ret;
}

int n, m;
map<pair<int,int>,int> mp;
int dp[N][2];

int on(int mask,int b) {
	return (mask >> b) & 1;
}

bool invalid(int u,int v,int w) {
	if (mp.count({u, v})) {
		return mp[{u, v}] != w;
	} else if (u < 1 || v < 1) {
		return w == 1;
	} else {
		return false;
	}
}

int main() {
	scanf("%d %d", &n, &m);
	int free = 0;
	for (int i = 1; i <= n; ++i) {
		add(free, max(i - 3, 0), mod - 1);
	}
	for (int i = 1; i <= m; ++i) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		if (abs(u - v) >= 3) {
			if (invalid(u, v, w)) {
				puts("0"); return 0;
			} else if (mp.count({u, v})) {
				continue;
			} else {
				mp[{u, v}] = mp[{v, u}] = w;
				sub(free, 1);
			}
		} else {
			mp[{u, v}] = w;
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int b = 0; b < 2; ++b) {
			if (dp[i - 1][b] == 0) continue;
			for (int mask = 0; mask < 8; ++mask) {
				int a = on(mask, 0);
				int c = on(mask, 1);
				int f = on(mask, 2);
				if (invalid(i - 2, i, a)) continue;
				if (invalid(i - 1, i, c)) continue;
				if (invalid(i, i, f)) continue;
				int e = (b ^ c ^ f);
				int d = (a ^ c ^ e ^ f);
				if (i > 1 && invalid(i, i - 1, e)) continue;
				if (i > 2 && invalid(i, i - 2, d)) continue;
				add(dp[i][f], dp[i - 1][b]);
			}
		}
	}
	printf("%d\n", mul(dp[n][0] + dp[n][1], pw(2, free)));
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,x,y;
	cin>>n>>x>>y;
	int a[n];
	map<int,int> vec;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int dist;
			if(i<=x && j>=y) dist = x-i + j-y + 1;
			else if(i>=x && j>=y) dist = min(i-x+1,y-i) + j-y;
			else if(i<=x && j<=y) dist = x-i + min(j-x,y-j+1);
			else if(i>=x && j<=y) dist = min(j-i,i-x+y-j+1);
			else dist = y-x;
			vec[dist]++;
		}
	}
	for(int i=1;i<n;i++) cout<<vec[i]<<endl;
	return 0;
}



Measured memory_bytes: 384
N = int(input())

table = [[0]*3 for i in range(N)]

for i in range(N):
    a = list(map(int,input().split()))
    for j in range(3):
        table[i][j] = a[j]


dp = [[0]*3 for i in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + table[i][k])

ans = 0            
for j in range(3):
    ans = max(ans,dp[N][j])
    
print(ans)

Measured memory_bytes: 100464
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int X; cin>>X;
  int ans;
  if(X==2)
    ans=2;
  else{
    if(X%2==0)
      X++;
    for(int i=X;i<MOD;i+=2){
      bool flag=1;
      for(int j=3;j<i;j+=2){
        if(i%j==0){
          flag=0;
          break;
        }
      }
      if(flag){
        ans=i;
        break;
      }
    }
    }
  cout<<ans<<endl;
  }

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

using namespace std;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;

    int max_water = 0;
    int max_sugar = 0;
    double max_ratio = 0.0;
    for (int a = 0; a * A <= F; a++) {
        for (int b = 0; a * A + b * B <= F; b++) {
            int current_water = a * A + b * B;
            for (int c = 0; c * C <= F; c++) {
                for (int d = 0; c * C + d * D <= F; d++) {
                    int current_sugar = c * C + d * D;
                    int current = current_water + current_sugar;
                    if (current == 0) {
                        continue;
                    } else if (current > F || current_sugar > current_water * E / 100) {
                        break;
                    }

                    double current_ratio = (double) current_sugar / (double) current;
                    if (max_water == 0 || current_ratio > max_ratio) {
                        max_water = current_water;
                        max_sugar = current_sugar;
                        max_ratio = current_ratio;
                    }
                }
            }
        }
    }

    printf("%d %d\n", max_water + max_sugar, max_sugar);
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	vector<bool> prime(200201,true);
	prime[0]=prime[1]=false;
	for(int i=2;i*i<=200200;i++)
		if(prime[i])
			for(int j=i*i;j<=200200;j+=i)
				prime[j]=false;
	for(int i=n;;i++)
		if(prime[i]){cout<<i;return 0;}
	
		

}


Measured memory_bytes: 256
#define MOD 1000000007

#include <iostream>

long long Modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long Modinv(long long a, long long mod)
{
	return Modpow(a, mod - 2, mod);
}

int main()
{
	int x = 0;
	int y = 0;

	std::cin >> x >> y;
	if ((x + y) % 3 != 0)
	{
		std::cout << 0 << std::endl;
		return 0;
	}

	long long n = (2 * y - x) / 3;
	long long m = (2 * x - y) / 3;

	if (n < 0 || m < 0)
	{
		std::cout << 0 << std::endl;
		return 0;
	}

	long long over = 1;
	long long under = 1;

	for (long long i = 0; i < n; ++i)
	{
		over = over * (n + m - i) % MOD;
		under = under * (i + 1) % MOD;
	}
	std::cout << over * Modinv(under, MOD) % MOD << std::endl;
}




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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  vector<int> v(n);
  for (int i = 0; i < n - 1; i++) {
    int d = i % 2 ? -1 : 1;
    v[i] += d;
    v[i + 1] += -d;
  }
  sort(begin(v), end(v));
  ll s = 0, t = 0;
  for (int i = 0; i < n; i++) {
    s += v[i] * a[i];
    t += -v[n - i - 1] * a[i];
  }
  cout << max(s, t) << endl;
}


Measured memory_bytes: 1408
s=input()
while True:
    if len(s) == 0:
        print("YES")
        break
    elif s[-5:] == "dream" or s[-5:] == "erase":
        s=s[:-5]
    elif s[-6:] == "eraser":
        s=s[:-6]
    elif s[-7:] == "dreamer":
        s=s[:-7]
    else:
        print("NO")
        break

Measured memory_bytes: 78576
import sys
input = sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
sort_a=sorted(a, reverse=True)
max=sort_a[0]
semimax=sort_a[1]
for i in range(n):
  if a[i] != max:
    print(max)
  else:
    print(semimax)

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

int N, X, T;

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  cin >> N >> X >> T;
  cout << my_ceil(N, X) * T << endl;
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std; 

int main() {
  // BE EXTRA CAREFUL WHEN TRANSLATING SCIENTIFIC NOTATION INTO NUMBERS
  // IDEALLY, PASTE IT AS A CONSTANT
  // 1E5 IS NOT TEN THOUSAND IT IS A HUnDRED THOUSAND
  // THIS IS NOT THE FIRST TIME MAKING THIS MISTAKE
  int Q; cin >> Q;
  int l[100000];
  int r[100000];
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
  }

  int res[100001] = {0}; // 0 indicates non-2017-like, 1 indicates 2017-like prime

  // O(R sqrt(R))
  for (int i = 3; i < 100000; i += 2) {
    bool is_prime = true;

    int j = 2;
    while(j * j <= i) {
      if (i % j == 0) {
        is_prime = false;
        break;
      }
      j++;
    }

    if (!is_prime) continue;

    bool is_2017_like = true;

    int k = 2;
    while(k * k <= (i + 1) / 2) {
      if ((i + 1) / 2 % k == 0) {
        is_2017_like = false;
        break;
      }
      k++;
    }

    if (!is_2017_like) continue;

    res[i] = 1;
  }

  // cumsum
  for (int i = 0; i < 100000; i++) {
    res[i + 1] += res[i];
  }

  for (int i = 0; i < Q; i++) {
    cout << res[r[i]] - res[l[i] - 1] << endl;
  }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(1e4+1,0);
	for(int x=1;x<100;++x){
		for(int y=1;y<100;++y){
			for(int z=1;z<100;++z){
				int sum=x*x+y*y+z*z+x*y+y*z+z*x;
				if(sum>n)break;
				++v.at(sum);
			}
		}
	}
	for(int i=1;i<=n;++i){
		cout<<v.at(i)<<"\n"s;
	}
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  
  else if (A+B < C+D) {
    cout << "Right" << endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
}

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

int main()
{
    long long int H,W,sum,H1,H2,W1,W2;
    scanf("%lld%lld",&H,&W);
    if(H==1||W==1)
    {
        sum=1;
    }
    else
    {
        if(H%2==0)
        {
            H=H/2;
            sum=H*W;

        }
        else if(W%2==0)
        {
            W=W/2;
            sum=H*W;
        }
        else
        {
            H2=H/2;
            H1=H2+1;
            W2=W/2;
            W1=W2+1;
            sum=H1*W1+H2*W2;
        }
    }

    printf("%lld",sum);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

ll k;

#define N 100000
#define K 5

ll val[N*(18-K)];
pll ev[N*(18-K)];
bool snuke[N*(18-K)];
int s(ll x){
  int r = 0;
  while(x){
    r += x%10;
    x/=10;
  }
  return r;
}

int main(){
  cin>>k;
  FOR(x,1,N){
    val[x] = x;
    ev[x] = pll(x, s(x));
  }
  int h = N;
  FOR(kk,K+1,17){
    // k-keta
    ll base = 1;
    REP(_,kk-K)base*=10ll;
    FOR(i,N/10,N){
      ll v = (ll)i*base + base - 1;
      val[h] = v;
      ev[h] = pll(v, s(v));
      h++;
    }
  }
  pll mn = pll(1ll<<57, 1);
  FORR(x,1,h){
    pll p = ev[x];
    if(p.first*mn.second <= mn.first*p.second){
      mn = p;
      snuke[x] = true;
    }
  }
  REP(x,h)if(snuke[x]){
    printf("%lld\n",val[x]);
    k--;
    if(k==0){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 28544