akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//









Int a[100010];


int main(){
        int n;
        cin >> n;
        int cnt1=0;
        rep(i,n)
        {
                cin >> a[i];
                if(a[i]%2!=0) cnt1++;
        }
        if(cnt1%2==0) puts("YES");
        else puts("NO");
        return 0;
}














Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{

    int a,b,dai,syou;
    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    if(a>b){
        printf("a > b\n");
    }
    if(a==b){
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string.h>
using namespace std;

int mod = 100000;
int dp[101][101][4];

int main() {
	int w, h;
	
	// 0: 右向きで曲がれない、 1: 上向きで曲がれない、 2: 右向きで曲がれる 3: 上向きで曲がれる
	while(cin >> w >> h && (w || h)){
		memset(dp, 0, sizeof(dp));
		for(int i = 1; i < 100; ++i){
			if(i < w)
				dp[0][i][2] = 1;
			if(i < h)
				dp[i][0][3] = 1;
			
		}
		for(int i = 1; i < h; ++i){
			for(int j = 1; j < w; ++j){
				dp[i][j][2] += (dp[i][j - 1][2] + dp[i][j - 1][0]) % mod;
				dp[i][j][3] += (dp[i - 1][j][3] + dp[i - 1][j][1]) % mod;
				dp[i][j][0] += dp[i][j - 1][3] % mod;
				dp[i][j][1] += dp[i - 1][j][2] % mod;
			}
		}
		int ans = 0;
		for(int i = 0; i < 4; ++i)
			ans += dp[h - 1][w - 1][i] % mod;
			
		cout << ans % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
// C - Same Integers
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B,C; cin>>A>>B>>C;
	bool isodd = (A+B+C)&1;
	// cout<<isodd<<"\n";//
	vi S{A,B,C};
	int ans = 0;
	rpz(i, 3){
		if((S[i]&1) != isodd){
			S[i]++;
			ans = 1;
		}
	}
	sort(all(S));
	// for(auto s:S) cout<<s<<" ";puts("\n---");//
	ans += (S[2]-S[0])/2;
	ans += (S[2]-S[1])/2;
	cout<< ans <<endl;
}


Measured memory_bytes: 256
A,B,H,M = `dd`.split.map &:to_f
PhaseA = (H + M / 60) / 12 * Math::PI * 2
PhaseB = M / 60 * Math::PI * 2
AX = A * Math.cos(PhaseA)
AY = A * Math.sin(PhaseA)
BX = B * Math.cos(PhaseB)
BY = B * Math.sin(PhaseB)
puts Math.sqrt((AX-BX) ** 2 + (AY-BY)**2)

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

int main() {
  int N,K,ans=0,temp=0;
  cin >> N >> K;
  while(N>temp){
    temp += pow(K,ans)*(K-1);
    ans++; 
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4100
#include<iostream>
using namespace std;
#define ll long long
ll n;
signed main(){
	scanf("%lld",&n);
	ll cnt=0;
	if(n==1||n==0){
		printf("%d",0); return 0;
	}
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll res=0;
			while(n%i==0){res++; n/=i;
			}
			ll cntt=1;
			while(res-cntt>=0){res-=cntt;cntt++; 
			}
			cnt+=cntt-1;
		}
	}
	if(n>1)cnt++;
	printf("%lld",cnt);
	}

Measured memory_bytes: 3836
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - String Transformation
string S, T;
string ans = "Yes";
int s[26], t[26];

int main(){
    cin >> S >> T;

    rep(i, 0, 26){
        s[i] = t[i] = -1;
    }
    rep(i, 0, S.size()){
        int s_tmp = S[i] - 'a';
        int t_tmp = T[i] - 'a';
        if(s[s_tmp] != -1 || t[t_tmp] != -1){
            if(s[s_tmp] != t_tmp || t[t_tmp] != s_tmp){
                cout << "No" << endl;
                return 0;
            }
        }else{
            s[s_tmp] = t_tmp;
            t[t_tmp] = s_tmp;
        }
    }


    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum<=n)
		cout<<n-sum;
	else
		cout<<"-1";

	return 0;
}

Measured memory_bytes: 3668
N,M = map(int,input().split())
d=[0]*M
res = []
for i in range(M):
    P,Y = map(int,input().split())
    res.append((P,Y,i))
c=0
res.sort()
t = str(res[0][0])
for i in res:
    x = str(i[0])
    if x == t:
        c+=1
    else:
        c=1
        t = x
    d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)

for i in d:
    print(i)


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

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	if ( m % n == 0 )
	{
		cout << m / n << endl;
	} else 
	{
		for( n = m / n; n > 0 ; n-- ){
			if (m % n == 0)
			{
				cout << n << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

// data types
#define ll long long int
#define ld long double

//funtion macros


// stl
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define ilp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))

#define mod 1000000007

// utility functions
ll max(ll a, ll b)
{
    if(a>b)return a;
    return b;
}

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

ll power(ll x, ll y, ll m=mod)
{
	if(y<0)
    {
		x = power(x,m-2);
		y = -y;
	}
	ll ans=1;
	x = x % m;
	while(y)
    {
		if(y&1) ans = (ans*x)%m;
		y=y/2;
		x=(x*x)%m;
	}
	return ans;
}

bool poss(ll c, ll arr[],ll pos,ll v, ll m, ll n, ll p)
{
    if(pos>(arr[n-c]+m))
    {
        return 0;
    }
    else if(pos==arr[n-c])
    {
        return 1;
    }
    else
    {
        ll cnt = 0;
        cnt = (p-1)*m;
        lp(i,0,n-p+1)
        {
            cnt += min((arr[n-c]+m-arr[i]),m);
        }
        if(cnt>=v*m)
        {
            return 1;
        }
        else
        {
            return 0;
        }
        
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m,v,p,i;
    cin >> n >> m >> v >> p;
    ll arr[n];
    lp(i,0,n)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    ll pos = arr[n-p];
    ll min = p, max = n,avg,res=p;
    while(min<=max)
    {
        avg = min + (max-min)/2;
        if(poss(avg,arr,pos,v,m,n,p))
        {
            res = avg;
            min = avg+1;
        }
        else
        {
            max = avg-1;
        }        
    }
    cout << res << "\n";
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{  int n,m,i,a[100],s=0,c=0;
   double k;
   scanf("%d%d",&n,&m);
   for(i=0;i<n;i++)
   {  scanf("%d",&a[i]);
      s=s+a[i];
   }
   k=s/4.;
   k=k/m;
   for(i=0;i<n;i++)
   if(a[i]>=k)
   c++;
   if(c>=m) printf("Yes");
   else printf("No");
} 

Measured memory_bytes: 128
#ABC124C/Coloring_Colorfully_別解
def main():
    s = [int(x) for x in input()]
    odd = s[::2]
    even = s[1::2]
    cnt = 0

    if odd[0]:
        cnt = odd.count(0) + even.count(1)    
    else:
        cnt = odd.count(1) + even.count(0)
    print(cnt)
main()

Measured memory_bytes: 44764
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
#define  MAX 100
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
int field[12][12];
char s[12];

void dfs(int x,int y){
	field[y][x] = 0;

	for(int i = 0;i < 4;i++){

		int nx = x + dx[i];
		int ny = y + dy[i];

		if(nx < 0 || ny < 0 || nx >= 12 || ny >= 12){

			continue;

		}else if(field[ny][nx] == 1){
			dfs(nx,ny);
		} 
	}
	
	
}

void setfield(char S[],int y){
	rep(i,12){
		if(S[i] == '1'){
			field[y][i] = 1;
		}else{
			field[y][i] = 0;
		}
	}
}

int countisland(){
	int count = 0;
	rep(y,12){
		rep(x,12){
			if(field[y][x] == 1){
				count++;
				dfs(x,y);
			}
		}
	}
	return count;
}

int main(){

	while(true){
		if(scanf("%s",s) == EOF) break;
		setfield(s,0);
		FOR(i,1,12){
			scanf("%s",s);
			setfield(s,i);
		}
		cout << countisland() << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

struct mint {
    ll x;
    mint(ll x=0):x(x%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    sort(all(s));

    vpair rl;
    rl.emplace_back(s[0], 2);
    srep(i, 1, n) {
        if (s[i] == rl.back().fi) rl.back().se++;
        else rl.emplace_back(s[i], 2);
    }

    mint ans = 1;
    for (auto x : rl) {
        ans *= x.se;
    }

    cout << ans.x-1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, k;
    cin >> n >> k;
    int t = n, ans = 1;
    while (t / k) {
        t /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())-1
d=12
az=26
a=[]
b=[]
b0=0
for ii in range(d):
  a0=az**(ii+1)
  a.append(a0)
  b0+=a0
  b.append(b0)
for ii in range(d):
  if n<b[ii]:
    break
i0=b[ii]-a[ii]
n=n-i0

def func(ii,n):
  r=[]
  for jj in range(ii+1):
    azjj=az**(ii-jj)
    c=n//azjj
    r.append(chr(ord("a")+c))
    n=n%azjj
  return r
             
print("".join(func(ii,n)))

Measured memory_bytes: 9220
import heapq
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))

hq = []
for a in A:
  heapq.heappush(hq, a * -1)

for i in range(M):
  n = math.ceil(heapq.heappop(hq) / 2)
  heapq.heappush(hq, n)

b = []
for hqi in hq:
  b.append(hqi * -1)
  
print(sum(b))

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

int main() {
    int h,w,i,j;
    cin >> h >> w;

    char pic[h+2][w+2];
    for(i=0;i<h+2;i++){
        for(j=0;j<w+2;j++){
            pic[i][j] = '#';
        }
    }

   for(i=1;i<h+1;i++){
        for(j=1;j<w+1;j++){
            cin >> pic[i][j];
        }
    }

    for(i=0;i<h+2;i++){
        for(j=0;j<w+2;j++){
            cout << pic[i][j];
        }
        cout << endl;
    }

}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = {}
    for i in range(N):
        x = i - A[i]
        if m.get(x) == None:
            m[x] = [1, 0]
        else:
            m[x][0] += 1
    for i in range(N):
        y = i + A[i]
        if m.get(y) != None:
            m[y][1] += m[y][0]
    ans = 0
    for key in m:
        ans += m[key][1]
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 110668
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [, nums] = content
    .trim()
    .split('\n')
    .map(line => line.split(' ').map(n => +n));
  insertionSort(nums);
});

const insertionSort = nums => {
  console.log(nums.join(' '));
  for (let i = 1; i < nums.length; i++) {
    const v = nums[i];
    j = i - 1;
    while (j >= 0 && nums[j] > v) {
      nums[j + 1] = nums[j];
      j--;
    }
    nums[j + 1] = v;
    console.log(nums.join(' '));
  }
};


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










const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L() {}
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]) <= 0 &&
		ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]) <= 0;
}

P projection(const L &l, const P &p) {
	double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
	return l[0] + t*(l[0] - l[1]);
}

bool intersectSP(const L &s, const P &p) {
	return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS; // triangle inequality
}

double distanceSP(const L &s, const P &p) {
	const P r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const L &s, const L &t) {
	if (intersectSS(s, t)) return 0;
	return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
		min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

typedef vector<P> G;

#define curr(PP, i) PP[i]
#define next(PP, i) PP[(i+1)%PP.size()]
enum { OUT, ON, IN };
int contains(const G& g, const P& p) {
	bool in = false;
	for (int i = 0; i < g.size(); ++i) {
		P a = curr(g, i) - p, b = next(g, i) - p;
		if (imag(a) > imag(b)) swap(a, b);
		if (imag(a) <= 0 && 0 < imag(b))
			if (cross(a, b) < 0) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
	}
	return in ? IN : OUT;
}







int N;
L line;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double x, y, xx, yy, h;
	while (cin >> N)
	{
		if (N == 0) return 0;

		cin >> x >> y; P s(x, y);
		cin >> x >> y; P t(x, y);
		line = L(s, t);

		double ans = 1000;

		rep(i, 0, N)
		{
			cin >> x >> y >> xx >> yy >> h;

			G poly;
			poly.push_back(P(x, yy));
			poly.push_back(P(x, y));
			poly.push_back(P(xx, y));
			poly.push_back(P(xx, yy));

			if (contains(poly, line[0]) == IN && contains(poly, line[1]) == IN)
			{
				ans = 0;
				continue;
			}
			
			double d = 1000;
			d = min(d, distanceSS(line, L(P(x, y), P(x, yy))));
			d = min(d, distanceSS(line, L(P(x, yy), P(xx, yy))));
			d = min(d, distanceSS(line, L(P(xx, yy), P(xx, y))));
			d = min(d, distanceSS(line, L(P(xx, y), P(x, y))));

			if (d < EPS)
			{
				ans = 0;
			}
			else if (d <= h + EPS)
			{
				ans = min(ans, d);
			}
			else
			{
				double r = (h * h + d * d) / (2.0 * h);
				ans = min(ans, r);
			}
		}

		printf("%.10f\n", ans);
	}
}

Measured memory_bytes: 3204
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(int argc, char const *argv[])
{
	int n;
	VI x,y,t;
	cin>>n;
	REP(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		t.PB(a);
		x.PB(b);
		y.PB(c);
	}
	int curx, cury;
	curx=0;cury=0;
	REP(i,n){
		int diff = abs(curx - x[i]) + abs(cury + y[i]);
		// debug(diff);
		// debug(t[i]);
		if(diff < t[i] && (diff-t[i])%2==0){

		}
		else if(diff - t[i] != 0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1644
fun main(args: Array<String>) {
    var (m, f, r) = readLine()!!.split(" ").map { it.toInt() }
    while (m != -1 || f != -1 || r != -1) {
        if (m != -1 && f != -1) {
            when {
                m + f in 80..100 -> println("A")
                m + f in 65..79 -> println("B")
                m + f in 50..64 -> println("C")
                m + f in 30..49 -> {
                    if (r >= 50) {
                        println("C")
                    } else {
                        println("D")
                    }
                }
                m + f in 0..29 -> println("F")
            }
        } else {
            println("F")
        }
        val (m2, f2, r2) = readLine()!!.split(" ").map { it.toInt() }
        m = m2
        f = f2
        r = r2
    }
}


Measured memory_bytes: 31996
//
//  abc153_Fennec_Monster.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265


int main(int argc, const char* argv[]) {

  ll h, k;
  std::cin >> h >> k;
  std::priority_queue<ll> q;
  ll sum = 0;

  for (int i = 0; i < h; i++) {
    ll a;
    std::cin >> a;
    sum += a;
    q.push(a);

  }
  for (int i = 0; i < k; i++) {
    if (!q.empty()) {
      ll top = q.top();
      q.pop();
      sum -= top;
    }
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 2420
#define rep(i,n) for(ll i=0;i<(n);++i)

#include<iostream>
#include<fstream>
#include<iomanip>

#include<vector>
#include<array>
#include<string>
#include<bitset>
#include<queue>
#include<list>

#include<utility>

#include<algorithm>
#include<cmath>
using ll = long long;
using namespace std;

ll n;

void input(){
    cin>>n;
}
void src(){
    input();
    cout<< (n-1)*n/2;
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

int a[50];



int cal(int *a){
  return (a[1]-a[0])/2 + a[2] - a[1];
}


int main(){
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3);
  int ans = 0;
  if((a[1]-a[0]) % 2 != 0){
    ans++;
    a[1]++;
    a[2]++;
  }
  ans += cal(a);
  cout << ans << endl;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define INF 1 << 30
#define MAX 1000000000
#define SIZE 1000000000
int main() {
	int n, a, b, c, d, f, t;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	char str[200000];
	scanf("%s", str);
	a--, b--, c--, d--;
	if (a < b) {
		swap(a, b);
		swap(c, d);
	}//a > bにする
	//printf("%d-%d %d-%d\n", a, c, b, d);
	if (c > d) {
		f = 1;
		rep(i, b, c) {
			if (str[i] == '#' && str[i] == str[i + 1]) {
				f = 0;
				break;
			}
		}
		puts(f ? "Yes" : "No");
	}
	else {// c < d
		f = 0;
		rep(i, a - 1, c) {
			if (str[i] == '.' && str[i + 1] == '.'&& str[i + 2] == '.') {
				f++;
			}
		}
		rep(i, b, d) {
			if (str[i] == '#' && str[i] == str[i + 1]) {
				f = 0;
				break;
			}
		}
		puts(f ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 384
fun main() {
    // 文字列
//    var n = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
    var (n,x,t) = readLine()!!.split(" ").map(String::toInt)
//    val xys = List(n) {
////        readLine()!!.split(" ").map(String::toLong)
//        readLine()!!.toDouble()
//    }

    var it=0
    var ix=0
    var flag=true
    while (n>ix){
        ix=ix+x
        it=it+t

    }

    print(it)

}

Measured memory_bytes: 36460
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n+1];
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
        
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 2 == 1 && array[i] % 2 == 1) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 36256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int n;
int a[101];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    ll ans=0;
    ll color=a[0], len=1;
    REP(i, 1, n){
        if(a[i]==color){
            len++;
        }
        else{
            ans+=(len/2);
            color=a[i];
            len=1;
        }
    }
    ans+=(len/2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, M, ans;
  ans = 0;
  cin >> N >> M;
  vector<int> H(N), A(M), B(M), X(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
    X.at(i) = 1;
  }
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  for (int i = 0; i < M; i++) {
    if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)) {
      X.at(A.at(i) - 1) = 0;
    }
    else if (H.at(A.at(i) - 1) == H.at(B.at(i) - 1)) {
      X.at(A.at(i) - 1) = 0;
      X.at(B.at(i) - 1) = 0;
    }
    else {
      X.at(B.at(i) - 1) = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    ans += X.at(i);
  }
  cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N;
  
  vector<int> p(N);
  for (int i = 0; i < N; i++ ) {
    cin >> p.at(i);
  }
  
  K = 0;
  
  for (int i = 0; i < N; i++ ) {
    if ( p.at(i) != i+1 ) {
      K = K + 1;
    }
  }
  
  if ( K <=2 ) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

int main() {

	int N,M;
	cin >> N >> M;

	vector<bool> brdg(N - 1);
	fill(brdg.begin(), brdg.end(), true);

	vector<pair<int,int>> ab(M);
	rep(i, M) {
		cin >> ab[i].first >> ab[i].second;
		ab[i].first--;
		ab[i].second--;
	}

	sort(ab.begin(),ab.end(),
		[](const pair<int, int> x, const pair<int, int> y) {return x.second < y.second; });

	rep(i, M) {
		int start = ab[i].first;
		int goal = ab[i].second;

		bool flag = true;
		for (int j = start; j < goal; j++) {
			if (brdg[j] == false) {
				flag = false;
				break;
			}
		}

		if (flag == false) {
			continue;
		} else{
			brdg[goal - 1] = false;
		}
	}

	int ans = 0;
	rep(i, N - 1) {
		if (brdg[i] == false) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//写経　おぶ　すぬけ
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i = 0 ; i <  (n) ; ++i) 
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {} //このコロンってなんですか
	int find(int x){
		if (d[x] < 0) return x; //x:根
		return d[x] = find(d[x]);//x:子 -> xの親の根を返す
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//根同士をくっつける。
		if ( x ==  y) return false ; 
		/*連結成分が一致してるんだったらfalse返す。
			minimum spanning tree (クラスカル法と言うのをやるときに、くっつけたかどうかを取れると嬉しい.
			chmin/chmaxみたいなノリかな
		 */
		if ( d[x] > d[y]) swap(x,y);//xの方が大きいようにする（ただしサイズは負デモっているので不等号が逆）
		d[x] += d[y] ; //xにyをくっつける.
		d[y] = x;
		return true; 
	}
	bool same(int x, int y) { return find(x) == find(y) ; }
	int size(int x) { return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005] ;
int main(){
	int n, m;
	cin >>  n>> m;

	UnionFind uf(n);
	rep(i,m){
		int a, b;
		cin >>  a>> b;
		uf.unite(a,b);
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}




Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[100007];
ll arr[100007];
int recur(ll i,ll n,ll k){
ll mini=INT_MAX;
 if(dp[i]!=-1){
   return dp[i]; }
 else if(i>=n)
    dp[i]=INT_MAX;
 else if(i==n-1)
    dp[i]=0;
 else{
    for(ll j=1;j<=k;j++){
        mini=min(mini,recur(i+j,n,k)+abs(arr[i+j]-arr[i]));
    }
    dp[i]= mini;
 }
 return dp[i];
}
int main(){
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<recur(0,n,k)<<endl;
    return 0;
}

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

int main(){
	int n,k[10000];
	while(scanf("%d",&n),n){
		int ok=0,res=0;
		for(int i=0;i<n;i++){
			scanf("%d",&k[i]);
			if(k[i]>0) res++;
			if(k[i]>1) ok=1;
		}
		if(ok) printf("%d\n",res+1);
		else printf("NA\n");
	}
}

Measured memory_bytes: 1232
n = int(input())
d = dict()
for i in range(n):
    w, t = map(int, input().split())
    if t in d:
        d[t] = d[t] + w
    else:
        d[t] = w
d = sorted(d.items(), key=lambda x:x[0])
now = 0
ans = True
for x in d:
    t, w = x
    now = now + w
    if now > t:
        ans = False
        break
print('Yes' if ans else 'No')

Measured memory_bytes: 43868
#include <bits/stdc++.h>
 
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vpii a (n);
  vi ordem;
  FOR (i, 0, n) {
    cin >> a[i].first >> a[i].second;
    ordem.eb(i);
  }
  double sum = 0;
  int tot = 0;
  do {
    tot++;
    FOR (i, 1, n) {
      int last = ordem[i - 1];
      int cur = ordem[i];
      double dist = hypot (a[cur].first - a[last].first, a[cur].second - a[last].second);
      sum += dist;
    }
  } while (next_permutation(ordem.begin(), ordem.end()));
  cout << fixed << setprecision(10) << sum / tot << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MaxN 100000+100
typedef long long LL;
LL flower[MaxN][2];
LL end=2999999999999999999;
int main()
{
	int N,K;
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++)
		scanf("%lld %lld",&flower[i][0],&flower[i][1]);
	LL star=0;
	while(star<=end)
	{
		LL zj=(star+end)/2;
		LL sum=0;
		for(int i=0;i<N;i++)
		{
			if(zj>=flower[i][0])
				sum+=(1+(zj-flower[i][0])/flower[i][1]);
		}
		if(sum>=K)
			end=zj-1;
		else
			star=zj+1;
	}
	printf("%lld\n",star);
	return 0;
 } 

Measured memory_bytes: 1664
import java.io.*;
import java.util.*;
import java.awt.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplitHW[] = br.readLine().split(" ");
            int H = Integer.parseInt(strSplitHW[0]);
            int W = Integer.parseInt(strSplitHW[1]);
            String strSplitC[] = br.readLine().split(" ");
            int sh = Integer.parseInt(strSplitC[0])-1;
            int sw = Integer.parseInt(strSplitC[1])-1;
            String strSplitD[] = br.readLine().split(" ");
            int dh = Integer.parseInt(strSplitD[0])-1;
            int dw = Integer.parseInt(strSplitD[1])-1;
            
            int yWalk[] = {-1, 0, 1, 0};
            int xWalk[] = {0, 1, 0, -1};
            
            
            char ch[][] = new char[H][W];
            int d[][] = new int[H][W];
            for(int i=0; i<H; i++){
                char strChar[] = br.readLine().toCharArray();
                for(int j=0; j<W; j++){
                    ch[i][j] = strChar[j];
                    d[i][j] = Integer.MAX_VALUE;
                }
            }
            
            
            d[sh][sw] = 0;
            Point p = new Point(sh, sw);
            Deque<Point> dq = new ArrayDeque<Point>();
            dq.offerFirst(p);
            while(dq.size() != 0){
                Point dqP = dq.pollFirst();
                int y = dqP.x;
                int x = dqP.y;
                int kariD = d[y][x];
                for(int i=0; i<4; i++){
                    int chY = y+yWalk[i];
                    int chX = x+xWalk[i];
                    if(chY >= 0 && chY < H && chX >= 0 && chX < W && ch[chY][chX] == '.' && d[chY][chX] > kariD){
                        d[chY][chX] = kariD;
                        dq.offerFirst(new Point(chY, chX));
                    }
                }
                for(int i=-2; i<=2; i++){
                    for(int j=-2; j<=2; j++){
                        int chY = y+i;
                        int chX = x+j;
                        if(chY >= 0 && chY < H && chX >= 0 && chX < W && ch[chY][chX] == '.' && d[chY][chX] > kariD+1){
                            d[chY][chX] = kariD+1;
                            dq.offerLast(new Point(chY, chX));
                        }
                    }
                }
                
                //System.out.println(dq);
            }
    
    
            /*for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    System.out.print(d[i][j] + " ");
                }
                System.out.println();
            }*/
            
            
            if(d[dh][dw] == Integer.MAX_VALUE){
                System.out.println("-1");
            }else{
                System.out.println(d[dh][dw]);
            }
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;
int width,height;
string field[10];

int main(){
    int i,j,k,l;
    int x,y;
    
    cin >> height >> width;cin.ignore();
    
    for (i=0;i<height;i++){
        cin >> field[i];
    }
    
    int count = 0;
    for (y=0;y<height;y++){
        for (x=0;x<width;x++){
            count += field[y][x]=='#';
        }
    }
    if (count!=width+height-1){
        cout << "Impossible" << endl;
        return 0;
    }
    
    queue<vector<int>> q;
    q.push(vector<int>{0,0});
    while (!q.empty()){
        vector<int> &e =q.front();
        x = e[0];
        y = e[1];
        q.pop();
        
        if (x == width-1 && y == height-1){
            cout << "Possible" << endl;
            return 0;
        }
        if (x < width-1 && field[y][x]=='#'){
            q.push(vector<int>{x+1,y});
        }
        if (y < height-1 && field[y][x]=='#'){
            q.push(vector<int>{x,y+1});
        }
    }
    cout << "Impossible" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,h;cin>>n>>h;
  vector<P>v;
  rep(i,0,n){
    ll a,b;cin>>a>>b;
    v.push_back(P(a,0));
    v.push_back(P(b,1));
  }
  sort(v.begin(),v.end(),greater<P>());
  ll sum=0;ll k=0;
  rep(i,0,v.size()){
    if(v[i].second==0){
      k=i;
      break;
    }
  }
  ll ans=0;
  rep(i,0,k){
    h-=v[i].first;
    ans++;
    if(h<=0){
      out(ans);
      return 0;
    }
  }
  while(h>0){
    ans++;
    h-=v[k].first;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll t = n/(a+b);
    cout << t*a+min(n%(a+b), a) << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main(){
    int N;
    long long K;
    std::cin >> N >> K;
    std::vector< int > A(N);
    std::vector< int > F(N);
    long long total = 0;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        total += A[i];
    }
    for(int i=0; i<N; i++){
        std::cin >> F[i];
    }
    if(K >= total){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    std::sort(A.begin(), A.end());
    std::sort(F.begin(), F.end(), std::greater<int>() );
    
    long long min = 0;
    long long max = 1e12;
    while(min != max - 1){
        long long mid = (min + max) / 2;
        long long cnt = 0;
        for(int i=0; i<N; i++){
            long long tmp = A[i] - mid / F[i];
            if(tmp > 0){
                cnt += tmp;
            }
        }
        if(K >= cnt){
            max = mid;
        }else{
            min = mid;
        }
    }
    
    std::cout << max << std::endl;
    
    return 0;
}



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

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

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

	int N; cin >> N;

	int MIN = INT_MAX;
	int MAX = -1;

	for (int i = 0;i < N;i++){
		int a; cin >> a;
		MIN = min(MIN, a);
		MAX = max(MAX, a);
	}

	cout << MAX - MIN << endl;

	return 0;

}


Measured memory_bytes: 256
#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() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  cout << fixed << setprecision(12);

  double angle = (60 * H - 11 * M) / 360 * M_PI;
  double c_2 = A * A + B * B - 2 * A * B * cos(angle);
  double c = sqrt(c_2);
  cout << c << endl;
}


Measured memory_bytes: 4180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define grade(a) cout << a << endl
using namespace std;

int main(){
    int r, c;
    int i, j;
    cin >> r >> c;
    int Table[r+1][c+1];
    rep(i,r+1){
        rep(j,c+1)Table[i][j]=0;
    }
    rep(i,r){
        rep(j,c) cin >> Table[i][j];
    }
    rep(i,r){
        rep(j,c){
            Table[i][c] += Table[i][j];
        }
    }
    rep(i,c+1){
        rep(j,r){
            Table[r][i] += Table[j][i];
        }
    }
    rep(i,r+1){
        rep(j,c)cout << Table[i][j] << " ";
        cout << Table[i][c];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a:usize,
        b:usize,
        c:usize
    }
    let mut a: HashSet<usize> = vec![a, b, c].into_iter().collect();
    println!("{}", a.len())
}


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

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.resize(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
	
	ll n,m;
	cin >> n >> m;
	UnionFind uf(n);
	
	
	rep(i,m){
		int x,y,z;
		cin >> x >> y >> z;
		--x; --y;
		uf.merge(x,y);
	}
	
	set<ll> roots;
	rep(i,n) roots.insert(uf.root(i));
	cout << roots.size() << endl; 
	return 0;
}


Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(10**5) #再帰回数を増やさないとREになる


N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
for _ in range(K):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)


friendnetwork = []
sgn = [0 for _ in range(N)] #groupnumを書いていく
groupnum = 0

def makenetwork(n, groupnum):
  for item in friend[n]:
    if sgn[item] > 0:
      continue
    else:
      sgn[item] = groupnum
      makenetwork(item, groupnum)

for k in range(N):
  if sgn[k] == 0:
    groupnum += 1
    sgn[k] = groupnum
    makenetwork(k, groupnum)


friends = [[] for _ in range(groupnum)]
for k in range(N):
  friends[sgn[k]-1].append(k)

ans = ''
for k in range(N):
  num = len(friends[sgn[k]-1])-1  - len(friend[k])
  for item in block[k]:
    if sgn[item] == sgn[k]:
      num -= 1
  ans += str(num) + ' '

ans.rstrip()
print(ans)

Measured memory_bytes: 64708
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int N;
    cin >> N;
    
    vector<long int> A(N);
    map<long int,long int> X;

    
    for (long int i=0; i<N; i++) {
        cin >> A.at(i);
        if (X.count(A.at(i)) == 0) {
            X.insert(make_pair(A.at(i),1));
        } else {
            X.at(A.at(i)) += 1;
        }
    }
    
    long int count = 0;
    for (const auto x : X) {
        long int value = x.second;
        if ( value >= 2) {
            count += value * (value -1) / 2;
        }
    }
    
    
    for (long int i=0; i<N; i++) {
        long int target = A.at(i);
        long int value = X[target];
        long int ans = count;
        if ( value >= 2) {
            ans -= value * (value - 1) / 2;
            ans += (value-1) * (value - 2) /2;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 11008
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

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

struct ST
{
	vector<int> data;
	vector<int> lazy;
	int size;

	ST(int n)
	{
		size = 1;
		while (size < n)size *= 2;
		data = vector<int>(2 * size - 1, 0);
		lazy = vector<int>(2 * size - 1, 0);
	}

	void apply(int k)
	{
		data[k] += lazy[k];
		if (k < (size - 1))
		{
			if (lazy[k] >= 0)
			{
				lazy[2 * k + 1] += lazy[k];
				lazy[2 * k + 2] += lazy[k];
			}
		}
		lazy[k] = 0;
	}

	void add(int s, int t, int x, int k, int l, int r)
	{
		if (r == -1)
		{
			r = size;
		}
		apply(k);
		if (t <= l || r <= s)
		{
			return;
		}
		if (s <= l&&r <= t)
		{
			lazy[k] += x;
			apply(k);
			return;
		}
		else
		{
			apply(k);
			add(s, t, x, 2 * k + 1, l, (l + r) / 2);
			add(s, t, x, 2 * k + 2, (l + r) / 2, r);
			data[k] = max(data[2 * k + 1], data[2 * k + 2]);
		}
	}

	int get(int s, int t, int k, int l, int r)
	{
		apply(k);
		return data[k];
	}

	void draw()
	{
		printf("\n");
		for (int i = 0; i != (2 * size - 1); i++)
		{
			printf("[%d]:%d ", i, data[i]);
		}
		printf("\n");
	}
};

int main() 
{
	int N, T;
	scanf("%d %d", &N, &T);

	ST st(T);

	for (int i = 0; i < N; i++)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		st.add(l, r, 1, 0, 0, -1);
		//st.draw();
	}
	cout << st.get(0, T, 0, 0, -1) << endl;
	return 0;
}


Measured memory_bytes: 4912