akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> per(n),che(m);

    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        per[i] = make_pair(a,b);
    }
    for(int i = 0; i < m; i++){
        int c,d;
        cin >> c >> d;
        che[i] = make_pair(c,d);
    }


    for(int i = 0; i < n; i++){
        int num,mn = mod;
        for(int j = 0; j < m; j++){
            int d = abs(per[i].first-che[j].first)+abs(per[i].second-che[j].second);
            if(d < mn){
                mn = d;
                num = j;
            }
        }
        cout << num+1 << endl;
    }


    return 0;
}

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

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<int> c(100001, 0);
		for(int i=0;i<N;i++){
			int A; cin >> A;
			c[A]++;
		}
		int kind = 0;
		int del = 0;
		for(int i=0;i<c.size();++i){
			if(c[i] == 0) continue;
			++kind;
			del += c[i] - 1;
		}
		if(del%2 == 1) --kind;
		cout << kind << endl;
	}
}



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

const int N = 2005;
int n, k, cnt, ans, dep[N];
vector <int> g[N];

void dfs (int x, int p) {
	dep[x] = dep[p] + 1;
	if (dep[x] > k / 2) ++cnt;
	for (int i = 0, y; i < g[x].size(); ++i) {
		y = g[x][i];
		if (y == p) continue;
		dfs(y, x);
	}
}
int main () {
	cin >> n >> k;
	for (int i = 1, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	ans = 1e9;
	if (~ k & 1) {
		for (int i = 1; i <= n; ++i) {
			cnt = 0;
			dep[0] = -1, dfs(i, 0);
			ans = min(ans, cnt);
		}
	} else {
		for (int i = 1; i <= n; ++i) {
			for (auto x : g[i]) {
				cnt = 0;
				dep[x] = -1, dfs(i, x);
				dep[i] = -1, dfs(x, i);
				ans = min(ans, cnt);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll nCr(ll n,ll r){
	if(n<0||r<0||n<r)return 0;
	if(n==0)return 1;
	return nCr(n-1,r-1)+nCr(n-1,r);
}
int main(){
	int n,m;
	cin>>n>>m;
	int co[2]={0,0};
	rep(i,n){
		int a;cin>>a;
		co[a%2]++;
	}
	ll out=0;
	rep(i,co[1]+1)if(i%2==m)out+=nCr(co[1],i);
	rep(i,co[0])out*=2;
	cout<<out<<endl;
}









Measured memory_bytes: 256
import Data.List
import Data.Char

div' :: Int -> Int -> Int
div' a b
  | a`mod`b == 0 = a`div`b
  | otherwise    = a`div`b+1
  
mod' :: Int -> Int -> Int
mod' a b
  | a`mod`b==0 = 0
  | otherwise  = a`mod`b-b

f :: Int -> Maybe (Char, Int)
f i
  | i == 0    = Nothing
  | i == 1    = Just ('1',0)
  | otherwise = Just (chr (ord '0'+(i`mod'`(-2))), i`div'`(-2))

main :: IO ()
main = do
  n <- readLn :: IO Int
  let cs = unfoldr f n

  putStrLn $ if null cs
    then "0"
    else foldl' (\ans c -> c : ans)  "" cs

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int k[112345];
  for(int i=0;i<n;i++){
    cin>>k[i];
  }
  sort(k,k+n);
  int ans=n;
  for(int i=0;i<n;i++){
    if(k[i]==k[i+1]){
      ans-=2;
      i+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) Yes();
  else No();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#define INF 1e9
using namespace std;

int main() {
    ll s; cin >> s;
    ll minnum = INF;
    while(s>100){
        minnum = min(minnum,abs(753-s%1000));
        s /= 10;
    }
    cout << minnum << endl;
    return 0;
}

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

int main() {
  int K;
  cin >> K;
  string s;
  cin >> s;
  
  int sl = s.size();
  int m = min(K, sl);
  for(int i = 0; i < m; i++){
    cout << s.at(i);
  }
  if(s.size() > K){
    cout << "..." << endl;
  }
  

}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	origin := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
		origin[i] = nums[i]
	}

	nums = sort(nums)
	// fmt.Println(nums)
	// fmt.Println(origin)
	count := 0
	for i := 0; i < n; i++ {
		if origin[i] != nums[i] {
			count = count + 1
		}
		if count > 2 {
			break
		}
	}
	if count == 2 || count == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func sort(values []int) (ret []int) {
	if len(values) < 2 {
		return values
	}

	pivot := values[0]

	left := []int{}
	right := []int{}
	for _, v := range values[1:] {
		if v > pivot {
			right = append(right, v)
		} else {
			left = append(left, v)
		}
	}

	left = sort(left)
	right = sort(right)

	ret = append(left, pivot)
	ret = append(ret, right...)

	return
}


Measured memory_bytes: 512
import Foundation
 
let inputLine: String = readLine()!
 
let a: Int64 = Int64(inputLine)!

 
var i = 1;
 
var ans = 0;
 
while i <= a {
  
 if i % 3 == 0 || i % 5 == 0 {
    i += 1
  	continue
  } 
	ans += i
    i += 1
}
 
print(ans)


Measured memory_bytes: 12992
class ManyFormulas:
	def getSum(self,string):
		length = len(string)
		ans = 0
		t = 0
		while t<1<<(length-1):
			num = int(string[0]) - int("0")
			for i in range(length-1):
				if t & (1<<i):
					ans += num
					num = 0
				num = num * 10 + int(string[i+1]) - int("0")
			ans += num
			t += 1
		print ans

if __name__ == "__main__":
	string = raw_input()
	m = ManyFormulas()
	m.getSum(string)

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int ta[100][100];
int main(){
	int n;
	while(
	cin>>n,n){
	int ni=(n+1)/2+1;
	int nj=(n+1)/2;
	
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)ta[i][j]=-1;
	ta[ni][nj]=1;
	int now=2;
	for(int i=1;i<n*n;i++){
			ni++;nj++;
				while(true){
				if(nj>n)nj=1;
				if(nj<1)nj=n;
				if(ni>n)ni=1;
					if(ta[ni][nj]!=-1){
						ni++,nj--;
					}
					if(ni>=1&&ni<=n&&nj>=1&&nj<=n&&ta[ni][nj]==-1)break;
				}

			ta[ni][nj]=now;
			now++;
	}
	
	for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){printf("%4d",ta[i][j]);}
	cout<<endl;
	}
	
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair





int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){swap(a,b);}
    if(a<c){swap(a,c);}
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        a*=2;
    }
    cout<<a+b+c<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y;
int vis[100001];
vector<int> v[100001];
int dfs(int i){
	int& ret=vis[i];
	if(ret!=0) return ret;
	for(int k:v[i])
		ret=max(ret,1+dfs(k));
	return ret;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){ 
		scanf("%d%d",&x,&y);
		v[--x].push_back(--y);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dfs(i));
	}
	cout<<ans;

}


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

int main(){
  string a;
  cin>>a;
  if(a.at(0)==a.at(1)&&a.at(1)==a.at(2)){
    cout<<"Yes"<<endl;
  } else if (a.at(1)==a.at(2)&&a.at(3)==a.at(2)){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <string>
#include <stack>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <time.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;
typedef long long ll;


int main() {
	int n, k, ans = 0;
  cin>>n>>k;
  while(n--)
  {
    int h;
    cin>>h;
    if(h >= k)
      ans++;
  }
  cout<<ans;
	
	return 0;
}



Measured memory_bytes: 256
sx , sy , tx , ty = map(int,input().split())
a = []

for _ in range(tx - sx):
    a.append("R")
for _ in range(ty - sy):
    a.append("U")
for _ in range(tx - sx):
    a.append("L")
for _ in range(ty - sy):
    a.append("D")
    
a.append("D")

for _ in range(tx - sx + 1):
    a.append("R")
for _ in range(ty - sy + 1):
    a.append("U")
    
a.append("L")
a.append("U")

for _ in range(tx - sx + 1):
    a.append("L")
for _ in range(ty - sy + 1):
    a.append("D")
    
a.append("R")

print("".join(a))

Measured memory_bytes: 40176
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    bool flag = false;
    if(b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b <=k && d-c<=k && e-c<=k && e-d<=k){
        flag = true;
    }
    if(flag) cout<< "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	
	int a,b;
	std::cin >>a>>b;
	
	if(a<b)std::cout <<"a < b"<<"\n";
	else if (a>b) std::cout << "a > b" << "\n" ;
	else std::cout << "a == b" << "\n";
	
	return 0;
	
	
}

Measured memory_bytes: 1124
K = int(input())
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[K-1])


Measured memory_bytes: 2940
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


n = int(input())
if n<30:
    print("No")
else:
    print("Yes")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int MAX = 1000000;
constexpr int inf = 1<<30;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> m;
    for(auto & b : a) cin>>b,m[b]++;
    int q;
    cin>>q;
    vector<pair<int,int>> qe(q);
    for(auto & t : qe){
        cin>>t.first >> t.second;
    }
    ll sum = 0;
    sum = accumulate(a.begin(),a.end(),0ll);
    for(int i=0;i<q;++i){
        int num = m[qe[i].first];
        sum -= 1ll*num * qe[i].first;
        sum += 1ll*num * qe[i].second;
        m[qe[i].first] -= num;
        m[qe[i].second] += num;
        cout << sum << endl;
    }
    return 0;
}

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

const ll MAX = 5000;

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

    for (ll i=-200; i<=200; i++) {
        for (ll j=-200; j<=200; j++) {
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if (a - b == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 3612
#include <iostream> // cout, endl, cin
#include <cmath>    //sin, cos, tan
#include <vector>   // vector
#include <iomanip>  //setprecsion
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;
const double PI = acos(-1.0);

int main(void)
{
  while(1)
  {
    int a, b;
    char op;
    cin >> a >> op >> b;
    switch(op)
    {
      case '+': cout << a + b << endl; break;
      case '-': cout << a - b << endl; break;
      case '*': cout << a * b << endl; break;
      case '/': cout << a / b << endl; break;
      default : return 0;
    }
  }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
double pi=3.141592653; 
vector<vector<int>>g;
int main(){
  int n,m;
  cin>>n>>m;
  g.assign(n+1,vector<int>());
  for(int i=0;i<m;i++){
      int u,v;
      cin>>u>>v;
      g[u].push_back(v);
      g[v].push_back(u);    
  }
    int dis[n+1];
    for(int i=1;i<=n;i++)   
        dis[i]=INT_MAX;

    dis[1]=0;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int n=q.front();
        q.pop();
        for(int u:g[n]){
            if(dis[u]==INT_MAX){
                dis[u]=n;
                q.push(u);
                }
        }
    }
    for(int i=2;i<=n;i++)
        if(dis[i]==INT_MAX){
            cout<<"No";return 0;}

    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<dis[i]<<endl;
    }

return 0;
}

Measured memory_bytes: 10280
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
((input: string): void => {
    const hoge = input.trim().slice(1).split(/\n/).map(
        (i) => { return i.split(" ") }
    );
    let piyo: number = 0;
    for(let i of hoge) {
        piyo += (i[1] == 'JPY') ? Number(i[0]) : Number(i[0]) * 380000;
    }
    console.log(piyo);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    vector<int> v(3);
    int p;
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    
    sort(v.begin(), v.end());
    
    cout << v[0] << " " << v[1] << " " << v[2] << endl;
}


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

using namespace std;

int main(){

	int x[4+1], y[4+1];
	cin >> x[1] >> y[1] >> x[2] >> y[2];

	x[3] = x[2] - y[2] + y[1];
	y[3] = y[2] + x[2] - x[1];
	x[4] = x[1] - y[2] + y[1];
	y[4] = y[1] + x[2] - x[1];

	printf("%d %d %d %d\n", x[3], y[3], x[4], y[4]);

	return 0;
}


Measured memory_bytes: 256
const main = (input) => {
  var K = input.trim().split("\n")[0].split(" ")[3];
  var x = input.trim().split("\n")[0].split(" ")[0];
  var y = input.trim().split("\n")[0].split(" ")[1];
  var z = input.trim().split("\n")[0].split(" ")[2];

  var a = input.trim().split("\n")[1].split(" ").sort((a,b)=>b-a).map(v=>v-0);
  var b = input.trim().split("\n")[2].split(" ").sort((a,b)=>b-a).map(v=>v-0);
  var c = input.trim().split("\n")[3].split(" ").sort((a,b)=>b-a).map(v=>v-0);
  var anss = [];
  var min = 0;
  for(var i=0;i<x;i++){
    for(var j=0;j<y;j++){
      for(var k=0;k<z;k++){
        if((i+1)*(j+1)*(k+1)<=K){
          var sum = a[i]+b[j]+c[k];
          anss.push(sum);
        }else break;
      }
    }
  }
  anss = anss.sort((a,b)=>b-a);
  for(var i=0;i<K;i++)
    console.log(anss[i]);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 29600
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


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

    for (int m = 100 * n; m < 100 * (n + 1); ++m)
    {
        int x = m / 108;
        if (x * 108 == m)
        {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;


    return 0;
}


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

using namespace std;
using ll = long long ;
struct Node {
    int i;
    ll d;
    Node() {}
    Node(int _i, ll _d) : i(_i), d(_d) {}
    bool operator<(const Node& _r) const {
        return d > _r.d;
    }
};

void solve() {
    int n; cin >> n;
    vector<int> p(n,-1), sz(n,1);
    set<Node> s;
    for (int i = 0; i < n; i++) {
        ll d; cin >> d;
        s.insert({i,d});
    }
    vector<vector<int>> g(n);
    vector<pair<int, int>> e;
    while ((int)s.size()>1) {
        auto it = s.begin();
        auto v = *it; s.erase(it);
        ll target = v.d + 2*sz[v.i] - n; 
        auto jt = s.lower_bound({-1, target});
        if (jt == s.end() || jt->d != target) {
            cout << -1; return;
        }
        p[v.i] = jt->i;
        sz[jt->i] += sz[v.i];
        g[jt->i].emplace_back(v.i);
        e.emplace_back(jt->i, v.i);
    }
    int root = -1;
    for (int i = 0; i < n; i++) {
        if (p[i] == -1) root = i;
    }
    function<ll(int)> dfs = [&](int u){
        ll sum = sz[u]-1;
        for (int v: g[u])
            sum += dfs(v);
        return sum;
    };
    auto it = s.begin();
    if (sz[root] != n || it->d != dfs(root)) {
        cout << -1; return;
    }
    for (auto& p: e) {
        cout << p.first+1 << ' ' << p.second+1 << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 14840
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	int num;
	int num_4,num_2;
	num_4=num_2=0; 
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num;
		if(num%4==0){
			num_4++;
		}
		if(num%4!=0&&num%2==0){
			num_2++;
		}
	}
	int y=num_4+num_2/2;
	if(y>=n/2){
		cout<<"Yes"<<endl;
	} else{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  int n,t;
  cin >> n >> t;
  vint a(n);
  cin >> a;
  int minv = a[0], maxprof = 0;
  unordered_map<int, int> ma;
  ma[a[0]] = 0;
  FOR(i, 1, n) {
    maxprof = max(maxprof, a[i] - minv);
    minv = min(minv, a[i]);
    ma[a[i]] = i;
  }
  int ans = 0;
  for (auto elem : ma){
    int nowval = maxprof + elem.first;
    if (ma.find(nowval) != ma.end()) {
      if (elem.second < ma[nowval]) ++ans;
    }
  }
  cout << ans << endl;
}

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

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

    vector <vector<int>> G(n + 1);
    vector <pair<int, int>> ans;

    if(n % 2 == 1){
         for(int i = 1; i < n; i ++){
            G.at(n).push_back(i);
            G.at(i).push_back(n);
            ans.push_back(make_pair(i, n));
        }
        n -= 1;
    }

    for(int now = 1; now <= n; now ++){
        for(int to = 1; to < n + 1; to ++){
            if(to + now == n + 1 || to == now) continue;
            if(find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue;
            ans.push_back(make_pair(now, to));
            G.at(now).push_back(to);
            G.at(to).push_back(now);
        }
    }

    cout << ans.size() << endl;
    for(auto P: ans){
        cout << P.first << " " << P.second << endl;
    }
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int int64_t
#define fi first
#define se second
signed main(){
  int n,a[100],q;
  int sum;
  map<int,int> m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      if(i&(1<<j)) sum+=a[j];
    }
    m[sum]=1;
    sum=0;
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>n;
    if(m[n]==1) cout<<"yes\n";
    else cout<<"no\n";
  }
}



Measured memory_bytes: 3148
n = int(input())
raw = []
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  raw.append([a,b])
  peer[a].append(b)
  peer[b].append(a)
rank = [10**6 for _ in range(n)]
clr = [10**6 for _ in range(n)]
clr2 = [10**6 for _ in range(n)]
seen = [0 for _ in range(n)]
rank[0] = 0
clr[0] = 0
clr2[0] = 0
seen[0] = 1
now = [0]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        clr[y] = clr2[x] + 1
        clr2[y] = clr[y]
        clr2[x] += 1
        rank[y] = rank[x] + 1
        now.append(y)
maxi = 0
for i in range(n):
  maxi = max(maxi,len(peer[i]))
print(maxi)
for i in range(n-1):
  a,b = raw[i]
  if rank[a] < rank[b]:
    c = b
  else:
    c = a
  print(clr[c] % maxi + 1)
#print(clr)

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

int main() {
    string n;
    cin >> n;
    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 2e18
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,x,a[maxn],pre[maxn];

int main()
{
	n=read(); x=read(); rep(i,1,n) a[i]=read(),pre[i]=pre[i-1]+a[i];
	ll ans=inf;
	for(ll k=1;k<=n;k++)
	{
		ll nw=3,tmp=0;
		for(ll i=n;i>=1;i-=k)
		{
			tmp+=max(nw,5ll)*(pre[i]-pre[max(0ll,i-k)]); nw+=2;
			if(tmp>ans) break;
		}
		ans=min(ans,tmp+(k+n)*x);
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int n, q;
    string s;
    cin >> n >> s >> q;
    SegmentTree<bitset<26>> seg(n, [](bitset<26> b1, bitset<26> b2){return b1 | b2;}, 0);
    for(int i = 0; i < n; ++i){
        bitset<26> bs = 0;
        bs.set(s[i] - 'a');
        seg.set(i, bs);
    }
    seg.build();
    for(int i = 0; i < q; ++i){
        int type;
        cin >> type;
        if(type == 1){
            int p;
            char ch;
            cin >> p >> ch;
            --p;
            bitset<26> bs = 0;
            bs.set(ch - 'a');
            seg.update(p, bs);
        }
        else{
            int l, r;
            cin >> l >> r;
            --l;
            bitset<26> bs = seg.query(l, r);
            cout << bs.count() << '\n';
        }
    }
}

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

template<uint_fast64_t Modulus> class modint{
    using u64=uint_fast64_t;
    public:
    u64 a;
    constexpr modint(const u64 x=0) noexcept:a(x%Modulus){}
    constexpr u64 &value() noexcept{return a;}
    constexpr const u64 &value() const noexcept{return a;}
    constexpr modint &operator+=(const modint &rhs) noexcept{
        a+=rhs.a;
        if (a>=Modulus) a-=Modulus;
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const noexcept{
        return modint(*this)+=rhs;
    }
    constexpr modint &operator++() noexcept{
        return ++a,*this;
    }
    constexpr modint operator++(int) noexcept{
        modint t=*this; return ++a,t;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{
        if (a<rhs.a) a+=Modulus;
        a-=rhs.a;
        return *this;
    }
    constexpr modint operator-(const modint &rhs) const noexcept{
        return modint(*this)-=rhs;
    }
    constexpr modint &operator--() noexcept{
        return --a,*this;
    }
    constexpr modint operator--(int) noexcept{
        modint t=*this; return --a,t;
    }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        a=a*rhs.a%Modulus;
        return *this;
    }
    constexpr modint operator*(const modint &rhs) const noexcept{
        return modint(*this)*=rhs;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{
        u64 exp=Modulus-2;
        while(exp){
            if (exp&1) *this*=rhs;
            rhs*=rhs; exp>>=1;
        }
    }
    constexpr modint operator/(const modint &rhs) const noexcept{
        return modint(*this)/=rhs;
    }
    constexpr modint operator-() const noexcept{
        return modint(Modulus-a);
    }
    constexpr bool operator==(const modint &rhs) const noexcept{
        return a==rhs.a;
    }
    constexpr bool operator!=(const modint &rhs) const noexcept{
        return a!=rhs.a;
    }
    constexpr bool operator!() const noexcept{return !a;}
    friend ostream &operator<<(ostream &s,const modint &rhs) noexcept {
        return s << rhs.a;
    }
    friend istream &operator>>(istream &s,modint &rhs) noexcept {
        u64 a; rhs=modint{(s >> a,a)}; return s;
    }
};

using mint=modint<MOD>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    mint ans=0,n=N;
    rep(i,60){
        mint cnt=0;
        rep(j,N) if (1LL<<i&A[j]) ++cnt;
        ans+=cnt*(n-cnt)*(1LL<<i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
	int x,y,swap;
	while(1){
	    scanf("%d %d",&x,&y);
		if(x+y == 0){break;}
		if(x>y){printf("%d %d\n",y,x);
		}else{printf("%d %d\n",x,y);}
	}
	return 0;
}

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

const int SIZE=200010;
vector<int> G[SIZE];
bool visited[SIZE];
int num[SIZE],ans[SIZE];

void dfs(int v,int sum)
{
    visited[v]=true;
    
    sum+=num[v];
    ans[v]=sum;
    for(int u:G[v]){
        if(visited[u]) continue;
        dfs(u,sum);
    }
}

int main()
{
    int N,Q; cin>>N>>Q;
    for(int i=0;i<N-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    while(Q--){
        int p,x; cin>>p>>x;
        p--;
        num[p]+=x;
    }
    dfs(0,0);

    for(int i=0;i<N;i++) cout<<ans[i]<<' ';
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 ll dp[100001][4];
int main() { 
    fastIO;
     int t=1,n;
     //cin>>t;
     while(t--){
         cin>>n;
       int a[100001],b[100001],c[100001];
       fr(i,0,n){
       cin>>a[i]>>b[i]>>c[i];
       }
       int* map1[4];
       map1[0]=a;
       map1[1]=b;
       map1[2]=c;
       
       memset(dp,0,sizeof(dp));
       ll ans[100001];
       fr(i,0,n){
       ans[i]=INT_MIN;
       }
       // main part iterative dp with two states
       //base case
       ans[0]=max({a[0],b[0],c[0]});
       dp[0][0]=a[0];
        dp[0][1]=b[0];
        dp[0][2]=c[0];
       fr(i,0,n-1)
       {fr(k,0,3)
       {fr(j,0,3)
       {if(j!=k)
       {dp[i+1][j]=max(dp[i+1][j],dp[i][k]+map1[j][i+1]);
        ans[i+1]=max(dp[i+1][j],ans[i+1]);}}
       }
       }
       
       print(ans[n-1]);
        
        
        
        
        
        
         
     }
	 
	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>

int main()
{
    int x, y, z;

    while(1){
        scanf("%d %d", &x, &y);
        if((x==0) && (y==0)){
            break;
        }
        if(x>y){
            z=x;
            x=y;
            y=z;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  std::cout << min(n%k, abs(n%k-k)) << '\n';
}


Measured memory_bytes: 3600
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		var b = new int[n];
		var m = n / 2;
		for (var i = m; i < n; i++)
			b[i] = a[i];
		for (var i = m - 1; i >= 0; i--)
			b[i] = (a[i] + Enumerable.Range(2, n / (i + 1) - 1).Sum(j => b[j * (i + 1) - 1])) % 2;

		var c = b.Select((x, i) => new { x, i }).Where(_ => _.x == 1).Select(_ => _.i + 1).ToArray();
		Console.WriteLine(c.Length);
		Console.WriteLine(string.Join(" ", c));
	}
}


Measured memory_bytes: 34628
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	
	cout << (n + 1) / 2 - 1 << endl;
	
	return 0;
}


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

int main() {
    int t;
    cin >> t;
    int h = t / 3600;
    int m = (t - h * 3600) / 60;
    int s = t - h * 3600 - 60 * m;
    cout << h << ":" << m << ":" << s << endl;
}



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

struct Node {
    long key;
    Node *parent, *left, *right;
};

struct Node *root, *NIL;

void preParse(struct Node *id) {
    if (id == NIL) {
        return;
    }
    cout << " " << id->key;
    preParse(id->left);
    preParse(id->right);
}

void inParse(struct Node *id) {
    if (id == NIL) {
        return;
    }
    inParse(id->left);
    cout << " " << id->key;
    inParse(id->right);
}

void insert(long k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    }
    else {
        if (z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

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

    char com[10];

    for (long i = 0; i < m; i++) {
        cin >> com;
        if (com[0] == 'p') {
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
        else if (com[0] == 'i'){
            long key;
            cin >> key;
            insert(key);
        }
    }

    return 0;
}



Measured memory_bytes: 26432
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
    int n, d, x, i, j;
    cin>>n>>d>>x;
    int a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    int choko = x+n;
    for(i=0; i<n; i++){
        int j=1;
        while(a[i]*j<=d-1){
            choko++;
            j++;
        }
    }
    cout<<choko<<endl;

    return 0;
}

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

struct P{
	int team;
	int win;
	int rank;
	static bool more(const P& left,const P& right){ return left.win > right.win; }
};

int main()
{
	int n,t1,t2,p1,p2;
	P data [512];
	cin >> n;
	for(int i=0;i<n;i++){
		data[i].team = i+1;
		data[i].win = 0;
	}
	for(int i=0;i<n*(n-1)/2;i++){
		cin >> t1 >> t2 >> p1 >> p2;
		if(p1 > p2) data[t1-1].win += 3;
		else if(p1 < p2) data[t2-1].win += 3;
		else if(p1 == p2){
			data[t1-1].win++;
			data[t2-1].win++;
		}
	}
    sort(data,data + n,P::more);
	data[0].rank = 1;
	for(int i=1;i<n;i++){
		if(data[i-1].win == data[i].win) data[i].rank= data[i-1].rank;
		else data[i].rank = i+1;
	}
	for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			if(data[i].team == j+1){
				cout << data[i].rank << endl;
				break;
			}
		}
	}
}

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

using namespace std;

int A, B, C;
long long ans = (1e9) * 1LL * (2e9);

int main(){
	scanf("%d %d %d",&A,&B,&C);
	if((A % 2 == 0) || (B % 2 == 0) || (C % 2 == 0)){
		ans = 0;
	} 
	ans = min(ans, A * 1LL * B);
	ans = min(ans, A * 1LL * C);
	ans = min(ans, C * 1LL * B);
	printf("%lld\n",ans);



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n;
    cin>>n;
    ll ans=LINF;
    for(ll i=1; i<=sqrt(n)+2; i++) {
        if(n%i!=0) continue;
        ans=min(ans,i+(n/i));
    }
    cout<<ans-2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 1
#define GRAY 0
#define BLACK -1

void dfs( void );//this is recursive function
void visit( int );

int adj[100+1][100+1];//this is a adjacency list. 1-origin.
int d[100+1], f[100+1];//d is discovery time, and f is finished time.
int color[100+1], time = 0, n;

int main(){
    int i, j;

    //input a adjacency list
    scanf("%d", &n);
    for(i = 1; i<=n; i++){
	scanf("%d%d",&i, &adj[i][0]);//first element of ith array store the number of adjcency vertex
	for(j = 1; j<=adj[i][0]; j++){
	    scanf("%d", &adj[i][j]);
	}
    }
    //impliment the algorithm DFS
    dfs();
    //print
    for(i = 1; i<=n; i++)
	printf("%d %d %d\n", i, d[i], f[i]);
    
    return 0;
}

void dfs( void ){
    int i, j;

    //initialization
    for(i = 0; i<=n; i++)
	    color[i] = WHITE;
    for(i = 1; i<=n; i++)
	if(color[i] == WHITE) visit(i);
    return ;
}

void visit( int u ){
    int i, j, k;

    color[u] = GRAY;
    d[u] = ++time; //discovery time
    //find undiscovered adjcency vertices 
    for(i = u,j = 1; j <= adj[i][0]; j++){
	if(color[ adj[i][j] ] == WHITE) 
	    visit( adj[i][j] );
    }
    color[u] = BLACK; //finished time
    f[u] = ++time;

    return ;
}



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

namespace ConsoleApp15
{
    class Class368
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var p = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();

            var uni = new Union_Find(N);
            for (int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();
                uni.Unite(r[0], r[1]);
            }
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (uni.IsSameGroup(p[i], i))
                    count++;
            }
            Console.WriteLine(count);
        }
    }

    public class Union_Find
    {
        private int[] data;
        public Union_Find()
        {
            int size = 200000;
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public Union_Find(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }
        public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
        public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
        public int getMem(int x) => -data[Root(x)];
    }
}


Measured memory_bytes: 27744
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
from collections import defaultdict, deque
import sys
# input = sys.stdin.readline
# sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# INF = float("inf")
import numpy as np


def main():
    n = int(input())
    dict = defaultdict(int)
    for _ in range(n):
        s = input()
        if s[0] in ['M', 'A', 'R', 'C', 'H']:
            dict[s[0]] += 1
    ans = 0
    if len(dict) < 3:
        print(ans)
    else:
        l = [v for v in dict.values() if v != 0]
        for a, b, c in combinations(l, 3):
            ans += a * b * c
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 12100
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();

		long distPossible = (long)s*t;
		if(d <= distPossible) System.out.println("Yes");
		else System.out.println("No");
	
	}
}

Measured memory_bytes: 35620
#include<iostream>
using namespace std;
int main(void){
  int h,w,i,j;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2!=0&&j%2!=0)){
	  cout<<"#";
	}else{
	  cout<<".";
	}
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,c;
priority_queue<long long,vector<long long>,greater<long long> > r;
priority_queue<long long,vector<long long>,greater<long long> > g;
priority_queue<long long> s;
int main()
{
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++)
	{
		int z;
		scanf("%d",&z);
		r.push(z);
	}
	for(int i=1;i<=b;i++)
	{
		int z;
		scanf("%d",&z);
		g.push(z);
	}
	for(int i=1;i<=c;i++)
	{
		int z;
		scanf("%d",&z);
		s.push(z);
	}
	while(r.size()>x)r.pop();
	while(g.size()>y)g.pop();
	for(int i=1;i<=c;i++)
	{
		if(r.top()>g.top()&&s.top()>g.top())g.pop(),g.push(s.top());
		else if(s.top()>r.top())r.pop(),r.push(s.top());
		s.pop();
	}
	long long sum=0;
	for(int i=1;i<=x;i++)
	{
		//cout<<r.top()<<" ";
		sum+=r.top();
		r.pop();
	}
	//cout<<endl;
	for(int i=1;i<=y;i++)
	{
		//cout<<g.top()<<" ";
		sum+=g.top();
		g.pop();
	}
	cout<<sum;
}

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

int main(){
  int a,b,sum;
  cin >> a >> b;
  sum=0;
  if(a>b){
    sum+=a;
    a--;
  }else{
    sum+=b;
    b--;
  }
  if(a>b){
    sum+=a;
  }else{
    sum+=b;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600