akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            double a = cin.NextInt();
            double b = cin.NextInt();
            double c = Math.Ceiling((a + b) / 2);

            Console.WriteLine(c);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



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

int kazoe(int N){
    int count=0;
    int origin=0;
    int repli=0;

    for(int i=0;i<32;i++){
        int mask=1<<i;

        if(N&mask){
            count=i;
            origin++;
        }
    }
    if(count<origin){
        return origin;
    }else{
        return count;
    }
}


int main(){
    int N;

    cin>>N;

    cout<<kazoe(N)<<endl;


}


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

using namespace std;

int main(){
    int P,Q,R;
    cin>>P>>Q>>R;
    int tmp,ans=100000;
    tmp = P +R;
    ans = min(ans,tmp);
    tmp = R+Q;
    ans = min(ans,tmp);
    tmp = Q+P;
    ans = min(ans,tmp);

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

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

int p[100],t[100];
int dp[100][55010];
int N;

int main(){
	while( cin >> N && N ){
		rep(i,N) cin >> p[i] >> t[i];
		rep(i,41)rep(j,55010) dp[i][j] = 1e9;
		dp[0][0] = 0;
		rep(i,N){
			rep(k,50010){
				int s = 0;
				int w = 0;
				int pr = 0;
				int maxi = k;
				rep(j,3){
					if( i+j >= N ) break;
					s = (j+1)*abs(pr-p[i+j]); 
					w += abs(pr-p[i+j]);
					if( maxi + s > t[i+j] ) break;
					maxi = t[i+j];
					int next = t[i+j]+(j+2)*p[i+j];
					dp[i+j+1][next] = min(dp[i+j+1][next],dp[i][k]+w+p[i+j]);
					pr = p[i+j];
				}
			}
		}
		int fail = 0;
		rep(i,N+1){
			int ok = 0;
			rep(j,55010)
				if( dp[i][j] != 1e9 ) ok = 1;
			if(!ok){ cout << "NG " << i << endl; fail = 1; break; }
		}
		if( fail ) continue;
		cout << "OK " << *min_element(dp[N],dp[N]+55010) << endl;
	}
}

Measured memory_bytes: 11400
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int X[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> X[i];
    }
    sort(X, X + 3);
    cout << X[0] + 10 * X[2] + X[1] << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    d:usize,
    }
    println!("{}",if a+b>c+d {"Left" }else if a+b==c+d{"Balanced"}else{"Right"})
}

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

int main() {
	int m,f,r,k,i = 0;
	char a[1000];
	while(m != -1 || f != -1 || r != -1){
		cin >> m >> f >> r;
		if (m+f < 30 || m == -1 || f == -1)
			a[k] = 'F';
		else if (m+f < 50 && r <50 )
			a[k] = 'D';
		else if (m+f < 65)
			a[k] = 'C';
		else if (m+f < 80)
			a[k] = 'B';
		else
			a[k] = 'A';
		k++;
	}
	for(i=0;i<k-1;i++){
		cout << a[i] <<endl;
	}
	return 0;
}

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

int GetDigitsCount(long long N) {
	int digitsCount = 0;
	while (N != 0) {
		digitsCount++;
		N /= 10;
	}
	return digitsCount;
}

int main()
{

	long long N;
	long long B;
	int F;
	int answer = 2147483647;

	cin >> N;


	for (long long A = 1LL; A*A <= N ; A++) {

		if ( (N % A) == 0 ) {
			
			B = N / A;
			F = max(GetDigitsCount(A), GetDigitsCount(B));
			answer = min(answer, F);
			
		}
	}
		
	cout << answer <<  endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> last(N - 1);
	vector<set<int>> edges(N);
	priority_queue<int, vector<int>, greater<int>> c;
	vector<int> res(N, 0);
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		last[i] = { a,b };
		edges[a].insert(b);
		edges[b].insert(a);
	}
	REP(i, N) {
		int tmp;
		cin >> tmp;
		c.push(tmp);
	}

	queue<int> q;
	REP(i, N)if (edges[i].size() == 1)q.push(i);
	while (!q.empty()) {
		int now = q.front(); q.pop();
		res[now] = c.top(); c.pop();
		for (int next : edges[now]) {
			edges[next].erase(now);
			if (edges[next].size() == 1)q.push(next);
		}
	}

	ll ans = 0;
	for (auto p : last) {
		ans += min(res[p.first], res[p.second]);
	}
	cout << ans << endl;
	for (auto point : res)cout << point << " ";
	cout << endl;
	return 0;
}


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

string s,t;

int main(){
    cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n = I()
a = LI()
l = lcm(a)
ans = 0
l %= mod
for i in a:
    ans += l*pow(i,mod-2,mod)
    ans %= mod
print(ans)


Measured memory_bytes: 67456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#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(void) {
	int N, M;
	cin >> N >> M;
	vector<int> H(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> H.at(i);
	}
	vector<int> vec(N + 1);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if (H.at(a) > H.at(b)) {
			vec.at(b) = 1;
		} else if(H.at(a) < H.at(b)) {
			vec.at(a) = 1;
		} else {
			vec.at(a) = 1;
			vec.at(b) = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (vec.at(i) == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define int long long
signed main(){
//int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin >> n >> a >> b;
    int x[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    vector<int> d(n-1);
    for(int i = 1; i < n; i++) {
        d[i-1]=x[i]-x[i-1];
    }
//    for(int i = 0; i < n-1; i++) {
//        cout << d[i] << " ";
//    }
//    cout << "\n";
    sort(d.begin(),d.end());

    int cnt=0;
    int idx=0;
    while(a*d[idx]<b) {
        cnt+=a*d[idx];
        idx++;
        if(idx==n-1) break;
    }
    cnt+=b*(n-1-idx);
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 4780
n = int(raw_input())
blue = {}
red = {}

for a in range(n):
  q = raw_input()
  if q not in blue:
    blue[q] = 1
    red[q] = 0
  else:
    blue[q] += 1

m = int(raw_input())
for a in range(m):
  q = raw_input()
  if q not in red:
    red[q] = 1
    if q not in blue:
      blue[q] = 0
  else:
    red[q] += 1

ans = 0

for a in blue:
  if ans < (blue[a] - red[a]):
    ans = blue[a] - red[a]
print ans

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, k;
    string s;
    cin >> n >> k >> s;

    int minus = 0;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] != s[i]) minus++;
    }

    cout << n - 1 - max(0, minus - k * 2);
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n,0);
  for (int i; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans=0;
  for (int i; i<n; i++){
    if (i%2==0){
      ans+=a[i];
    }
    else{
      ans-=a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,i,j,k,x[100005],y[100005],ans;
bool tag[405][405],ntok[405];
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
		scanf("%d%d",x+i,y+i);
	for(i=1;i<=n;++i)
		{
			for(k=1;k<=n;++k)
				tag[i][k]=false;
			tag[i][i]=true;
			for(k=m;k>=1;--k)
			{
				if(tag[i][x[k]]&&tag[i][y[k]])
					break;
				if(tag[i][x[k]]||tag[i][y[k]])
					tag[i][x[k]]=tag[i][y[k]]=true;
			}
			if(k>=1)
				ntok[i]=true;
		}
	for(i=1;i<n;++i)
		for(j=i+1;j<=n;++j)
			if(!ntok[i]&&!ntok[j])
			{
				for(k=1;k<=n;++k)
					if(tag[i][k]&&tag[j][k])
						break;
				if(k>n)
					++ans;
			}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int main(){
	int a, s, m, h, S;
	scanf("%d", &S);
	h = S / 3600;
	a = S % 3600;
	m = a / 60;
	s = a % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll X, Y;
	cin >> X >> Y;
	ll cnt = 1;
	while (true) {
		if (Y >= X * 2) {
			X *= 2;
			cnt++;
		}
		else {
			break;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
k=int(input())
x,y=map(int,input().split())
if x<0:fx=-1
else:fx=1
if y<0:fy=-1
else:fy=1
ax,ay=abs(x),abs(y)
if ax<ay:
  x,y=y,x
  ax,ay=ay,ax
  fx,fy=fy,fx
  flag=1
else:flag=0
r=ax+ay
if k%2==0 and r%2==1:print(-1);exit()
if r==k:
  print(1)
  if flag:x,y=y,x
  print(x,y)
  exit()
if r%2==1 and r<k:
  print(3)
  anss=[]
  anss.append(((ax+(k-ay))//2,(k-(ax+(k-ay))//2)))
  anss.append((ax+(k-ay),0))
  anss.append((ax,ay))
  for i,j in anss:
    ii,jj=i*fx,j*fy
    if flag:ii,jj=jj,ii
    print(ii,jj)
  exit()
if r%2==0 and r<k:
  rm=(2*k-ax-ay)//2
else:
  rn=(k-(r%k))%k
  if rn%2==1:rn+=k
  rm=rn//2
ans=(r+rm*2)//k
anss=[]*ans
print(ans)
first=[0,-rm]
second=[ax,-rm]
third=[ax,ay]
xx=yy=0
while yy>first[1]:
  if yy-k<=first[1]:
    xx+=k-(yy-first[1])
    yy=first[1]
  else:
    yy-=k
  anss.append((xx*fx,yy*fy))
while xx<second[0]:
  if xx+k>=second[0]:
    yy+=k-(second[0]-xx)
    xx=second[0]
  else:
    xx+=k
  anss.append((xx*fx,yy*fy))
while yy!=third[1]:
  yy+=k
  anss.append((xx*fx,yy*fy))
for i,j in anss:
  ii,jj=i,j
  if flag:ii,jj=jj,ii
  print(ii,jj)


Measured memory_bytes: 60924
#include<iostream>
#include<cstdio>

using namespace std;

const int N = 1e5 + 5;
int A, B, M, a[N], b[N], m[N],c,x,y,mina,minb,ans;

int main() {
	scanf("%d%d%d", &A, &B, &M);
	mina = minb = 1e6;
	for (register int i = 0; i < A; ++i) {
		scanf("%d", &a[i]);
		if (a[i] < mina)
			mina = a[i];
	}
	for (register int i = 0; i < B; ++i) {
		scanf("%d", &b[i]);
		if (b[i] < minb)
			minb = b[i];
	}
	ans = mina + minb;
	for (register int i = 1; i <= M; ++i) {
		scanf("%d%d%d", &x, &y, &c);
		m[i] = a[x - 1] + b[y - 1] - c;
	}
	for (register int i = 1; i <= M; ++i) {
		if (ans > m[i])
			ans = m[i];
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string.h>

using namespace std;

int main(){
    char s[210];//sは偶数文字数
    scanf("%s",s);
    int n=strlen(s);
    for(int i=n-2;i;i-=2){
        if(strncmp(s, s+i/2,i/2)==0){
            cout<<i<<endl;
            return 0;
            //条件を満たす1文字以上の文字列が存在
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			while(a==a){
				int b = sc.nextInt();
				int c = a.length();
				for(int d=0;d<b;++d){
					int e = sc.nextInt();
					String f = a.substring(0,e);
					String g = a.substring(e,c);
					a = g+f;
				}
				System.out.println(a);
				a = sc.next();
				if(a.equals("-")){
					break;
				}
			}
	}

}

Measured memory_bytes: 26492
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]

c=[0]
for i in range(n):
  if c[i]+a[i]<=k:
    c.append(c[i]+a[i])
  else:
    break

d=[0]
for i in range(m):
  if d[i]+b[i]<=k:
    d.append(d[i]+b[i])
  else:
    break

e=0
f=len(d)-1
for i in range(len(c)):
  for j in range(f,-1,-1):
    if c[i]+d[j]<=k:
      if i+j>e:
        e=i+j
      f=j
      break
print(e)

Measured memory_bytes: 40640
N,M,X,Y=map(int,input().split(' '))
x_list=list(map(int,input().split(' ')))
y_list=list(map(int,input().split(' ')))
x_list.append(X)
y_list.append(Y)
x_max=max(x_list)
y_min=min(y_list)

if(X < Y and x_max < y_min):
    print("No War")
else:
    print("War")
    

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

int main(){
    int x;
    rep(i,5){
        cin >> x;
        if(x==0){
            cout << i+1;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(tuple(map(int, input().split())))

def sumd(y, x):
    global s
    return sum(min(abs(i - y), abs(j - x)) * s[i][j] for i in range(h) for j in range(w))

print(min(sumd(i, j) for i in range(h) for j in range(w)))


Measured memory_bytes: 5612
a,b=map(int,input().split())
c=0
for i in range(1,a+1):
    for j in range(2,b//10+1):
        if i%j==0:
            if 2<=i//j<10:
                if int(str(j)+str(i//j))<=b:
                    c+=1
print(c)

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

using namespace std;
#define int long long

signed main(){

   int N;
   cin>> N;
   int a[N];
   for(int i=0; i<N; i++) cin>> a[i];

   sort(a, a+N);
   int b=0, c=0, d=0;
   for(int i=0; i<N; i++){
      if(i==0){
         b=a[i];
         c++;
      }else{
         if(a[i]<=2*b){
            c++;
         }else{
            c=1;
         }
         b+=a[i];
      }
   }

   cout<< c<< endl;

   return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
#define int ll
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
double f(int x,int y){return sqrt(x*x+y*y);}
signed main(){
    int n;
    while(cin>>n,n){
        map<int, pii>mp;
        rep(i,n){
            int hoge; pii foo; cin>>hoge>>foo.first>>foo.second;
            mp[--hoge]=foo;
        }
        vector<vector<pii>>edge(n,vector<pii>());
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            for(auto comp=mp.begin();comp!=mp.end();comp++){
                if(itr==comp)continue;
                double dis=f(abs(itr->second.first-comp->second.first),abs(itr->second.second-comp->second.second));
                if( dis<=50){
                    //cout<<itr->first<<" "<<comp->first<<endl;
                    edge[itr->first].push_back(pii(comp->first,dis));
                }
            }
        }
        int k; cin>>k;
        rep(_,k){
            int s,g; cin>>s>>g;
            --s,--g;
            priority_queue<pii,vector<pii>,greater<pii>>que;
            vector<int>prev(n,INF);
            vector<int>d(n,INF);
            d[s]=0;
            que.push(pii(0,s));
            while(!que.empty()){
                pii now=que.top(); que.pop();
                if(now.second==g)break;
                if(d[now.second]<now.first)continue;
                rep(i,edge[now.second].size()){
                    pii next=edge[now.second][i];
                    if(d[next.first]<d[now.second]+next.second)continue;
                    que.push(pii(d[now.second]+next.second,next.first));
                    d[next.first]=now.first+next.second;
                    prev[next.first]=now.second;
                }
            }
            if(edge[s].size()==0 ||edge[g].size()==0||d[g]==INF)cout<<"NA"<<endl;
            else {
                vi hoge;
                for(int v=g;; v=prev[v]){
                    hoge.push_back(v);
                    if(v==s)break;
                }
                reverse(all(hoge));
                rep(i,hoge.size())if(i)cout<<" "<<hoge[i]+1; else cout<<hoge[i]+1;
                cout<<endl;
            }
        }
    }
}

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

using namespace std;

const int maxN = 2e5+10;
int N, T, A[maxN];

int main()
{
    cin >> N >> T;
    for (int i=1; i <= N; i++) cin >> A[i];
    long long ans = T;
    for (int i=2; i <= N; i++)
    {
        ans -= max(0,T-(A[i]-A[i-1]));
        ans += T;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  map<string, ll> t;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    
    t[s]++;
  }

  ll m;
  cin >> m;
  for (int i = 0; i < m; i++){
    string s;
    cin >> s;
    
    t[s]--;
  }

  ll ans = 0;
  for (auto p : t){
    ans = max(ans, p.second);
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 3588
import collections

n=int(input())
a=list(map(int,input().split()))

b=[]
for i in range(n):
  c=a[i]
  d=a[i]-1
  e=a[i]+1
  b.append(c)
  b.append(d)
  b.append(e)
  
f=collections.Counter(b)

g=f.most_common()
print(g[0][1])

Measured memory_bytes: 35424
#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() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  ll minValue = INT_MAX;
  for (int i = 1; i <= (100); ++i) {
    ll tmp = 0;
    rep(j, n) {
      tmp += pow(i - x[j], 2);
    }
    minValue = min(minValue, tmp);
  }

  cout << minValue << endl;

  return 0;
}


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

L, R = 0, 10 ** 5 + 1
for _ in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r+1)

if R > L:
    result = R - L
else:
    result = 0
print(result)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll mul(ll a, ll b) {
  return (a * b) % MOD;
}

ll add(ll a, ll b) {
  a += b;
  a %= MOD;
  return a;
}

ll power(ll a, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1)
      ret = mul(ret, a);
    b /= 2;
    a = mul(a, a);
  }
  return ret;
}

ll fact[N], invFact[N];

ll C(int n, int r) {
  return mul(fact[n], mul(invFact[n-r], invFact[r]));
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  fact[0] = 1, fact[1] = 1, invFact[0] = 1, invFact[1] = 1;
  for (int i = 2; i < N; ++i) {
    fact[i] = mul(fact[i-1], i);
    invFact[i] = power(fact[i] ,MOD - 2);
  }
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    ll ans = 0;
    if(n - k + 1 >= i && k - 1 >= i - 1) {
      ans = C(n - k + 1, i);
      ans = mul(ans, C(k - 1, i - 1));
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 15872
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    tree = [[] for _ in range(n)]
    for idx, a in enumerate(A):
        tree[idx].append(a - 1)

    def dfs(pre, dist):
        depth[pre] = dist
        for to in tree[pre]:
            if depth[to] != f_inf:
                cycle.append([depth[to], depth[pre] + 1])
                return
            else:
                dfs(to, dist + 1)

    cycle = []
    depth = [f_inf for _ in range(n)]
    dfs(0, 0)

    cycle_start = cycle[0][0]
    cycle_end = cycle[0][1]
    if k <= cycle_start:
        print(depth.index(k) + 1)
    else:
        remainder = (k - cycle_start) % (cycle_end - cycle_start)
        res = cycle_start + remainder
        print(depth.index(res) + 1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 278064
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy
y = 100
x = N()
cnt = 0
while(1):
    cnt += 1
    y = (y*101)//100
    #print(y)
    if y >= x:
        print(cnt)
        break



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

int main() {
  char c;
  cin >> c;
  int a = c - 'a';
  if (0 <= a && a <= 25)
    cout << "a" << endl;
  else
    cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 3632
import fractions

A,B,C,D = map(int, input().split())


c_and_d=C*D
#CとDの最小公倍数を求める
lcm = int(C*D//fractions.gcd(C,D))


count_C =0
count_D =0
count_C_and_D =0

count_C = int(B//C)-int((A-1)//C)
count_D = int(B//D)-int((A-1)//D)
count_C_and_D = int(B//lcm)-int((A-1)//lcm)

print(int((B-A+1) -(count_C + count_D - count_C_and_D)))

Measured memory_bytes: 5044
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI = 3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM =
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin >> x;
    double xx = x;
    double yy = 100;
    ll ans = 0;
    while (yy < xx)
    {
        ans++;
        ll wow = yy;
        yy += (wow / 100);
    }
    cout << ans;
    return 0;
}


//252908XL

/*
comments:-

*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
int A[312345], cnt[312345];
ll ans[312345], sum[312345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	REP(i, N) cnt[A[i]]++;
	vector<ll> v;
	FOR(i, 1, N + 1) if (cnt[i] > 0) v.push_back(cnt[i]);
	sort(ALL(v));
	REP(i, v.size()) sum[i + 1] = sum[i] + v[i];
	
	FOR(K, 1, N + 1) {
		ll l = 0, r = longINF;
		
		while (r - l > 1) {
			ll m = (l + r) / 2;
			
			int p = lower_bound(ALL(v), m) - v.begin();
			ll cnt = v.size() - p;
			ll other = sum[p];
			if (cnt + other / m >= K) l = m;
			else r = m;
		}
		printf("%lld\n", l);
	}
	return 0;
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int t = 0, c = 0;
    rep(i, N) { cin >> A[i]; }
    rep(i, N) { t += A[i]; }
    double b = t / (4.0 * M);
    rep(i, N) if(A[i] >= b) c++;
    cout << (c >= M ? "Yes" : "No") << endl;
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i ++){
        int count = 0;
        if (i % 2 == 0){
            continue;
        }
        for (int j = 1; j <=i; j++){
            if (i % j == 0){
                count++;
            }
        }
        if (count == 8){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  let S = INPUT.split('\n')[0]
  let ans = 0
  let cnt = 0
  for (let i = 0; i < S.length; i++) {
    if (S[i] == 'W') {
      ans += cnt
    } else {
      cnt++
    }
  }
  console.log(ans)
}

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


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int N;
char S[100003];

vector<int> s;
vector<int> ans;
bool contra = true;

void search( int k ){

    if( !contra ) return;

    if( k <= 1 ){
        ans[k] = 0;
        search( k+1 );
        ans[k] = 1;
        search( k+1 );
    }else if( k == N ){
        // 00 x 0
        // 10 x 1
        // 01 x 1
        // 11 x 0
        // 00 o 1
        if( ans[N-2] xor ans[N-1] xor ans[0] xor s[N-1] )
        if( ans[N-1] xor ans[0] xor ans[1] xor s[0] ){
            contra = false;
            Rep(i,N){
                printf ("%c", ans[i] ? 'S' : 'W' );
            }
            printf ("\n");
        }
    }else{
        ans[k] = !ans[k-2] xor ans[k-1] xor s[k-1];
        search( k+1 );
    }
}

int main() {


    Scd(N);
    Scs(S);

    ans.assign(N,0);
    s.assign(N,0);

    Rep(i,N){
        s[i] = S[i] == 'x';
    }

    search(0);

    if( contra ) printf ("%d\n", -1);


    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

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

  return 0;
}


Measured memory_bytes: 256
from itertools import combinations
n = int(input())
w = [0] * 5
march = 'MARCH'
for i in range(n):
  s = input()[0]
  if s in march:
    w[march.index(s)] += 1
print(sum(map(lambda a:a[0]*a[1]*a[2], combinations(w, 3))))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 998244353;
const ll INF = 1LL << 60;

ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

struct BIT {
	vector<ll> bit;
	int size;

	BIT(int n) :size(n) {
		bit.resize(size + 1);
		fill(bit.begin(), bit.end(), 0);
	}

	ll sum(int i) {
		i++;
		ll s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, ll x) {
		i++;
		while (i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

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

	vector<P> ps;
	vector<int> vx, vy;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		ps.emplace_back(x, y);
		vx.push_back(x);
		vy.push_back(y);
	}
	sort(ps.begin(), ps.end());
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	for (int i = 0; i < N; i++) {
		ps[i].first = lower_bound(vx.begin(), vx.end(), ps[i].first) - vx.begin();
		ps[i].second = lower_bound(vy.begin(), vy.end(), ps[i].second) - vy.begin();
	}
	BIT bit(N);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll sum = (mod_pow(2, ps[i].first) + MOD - 1) % MOD;
		(sum += (mod_pow(2, N - ps[i].first - 1) + MOD - 1) % MOD) %= MOD;
		(sum += (mod_pow(2, ps[i].second) + MOD - 1) % MOD) %= MOD;
		(sum += (mod_pow(2, N - ps[i].second - 1) + MOD - 1) % MOD) %= MOD;
		int a = bit.sum(ps[i].second);
		int b = ps[i].second - a;
		int c = ps[i].first - a;
		int d = N - 1 - a - b - c;
		(sum += MOD - (mod_pow(2, a) + MOD - 1) % MOD) %= MOD;
		(sum += MOD - (mod_pow(2, b) + MOD - 1) % MOD) %= MOD;
		(sum += MOD - (mod_pow(2, c) + MOD - 1) % MOD) %= MOD;
		(sum += MOD - (mod_pow(2, d) + MOD - 1) % MOD) %= MOD;
		ll x = (mod_pow(2, N) + MOD - 1) % MOD;
		(x += MOD - sum) %= MOD;
		(ans += x) %= MOD;
		bit.add(ps[i].second, 1);
	}
	cout << ans << endl;
}

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


int main(){    
    ll n,w;
    cin >> n >> w;
    vector<ll> wgh (w+1);
    wgh[0] = 0;
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ll wg,v;
        cin >> wg >> v;
        for(int j = w - wg; j >= 0;j--){
            wgh[j+wg] = max(wgh[j+wg],wgh[j] + v); 
            ans = max(ans,wgh[j+wg]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import math

listC1=list(map(int,input().split()))
listC2=list(map(int,input().split()))
output = 0


dist = math.sqrt((listC1[0]-listC2[0])**2+(listC1[1]-listC2[1])**2)
if dist > (listC1[2]+listC2[2]):
	output = 4
elif dist == (listC1[2]+listC2[2]):
	output = 3
elif abs(listC1[2]-listC2[2]) < dist < (listC1[2]+listC2[2]):
	output = 2
elif dist == abs(listC1[2]-listC2[2]):
	output = 1
elif dist < abs(listC1[2]-listC2[2]):
	output = 0


print(output)


Measured memory_bytes: 5664
// TLEになる
#include <bits/stdc++.h>
using namespace std;

struct edge{ 
    long long to, a, b; 
    edge(int _to, int _a, long long _b): to(_to), a(_a), b(_b) {} 
};

typedef pair<long long,long long> P;

int main() {
    long long N, M, S;
    cin >> N >> M >> S;
    vector<vector<edge>> G(N);
    vector<long long> C(N), D(N);
    long long SumA = 0;
    for(int i = 0; i < M; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(edge(v, a, b));
        G[v].push_back(edge(u, a, b));
        SumA += a;
    }
    for(int i = 0; i < N; ++i) {
        cin >> C[i] >> D[i];
    }

    vector<vector<long long>> State(N, vector<long long>(SumA + 1, -1LL));
    priority_queue<P, vector<P>, greater<P> > que;
    vector<long long> fast_ans(N, -1LL);

    // que.second = K -> i = K/(Amax*(N-1) + 1), j = K%(Amax*(N-1) + 1)
    int Row_size = SumA + 1;
    S = min((long long)S, SumA); // 銀貨をAmax*(N-1)枚になるまで捨てる
    que.push(P(0, Row_size*0 + S));
    while(!que.empty()){
        P q = que.top(); que.pop();
        long long City = q.second/Row_size; 
        long long Money = q.second - City*Row_size;
        if(State[City][Money] != -1LL) continue;
        State[City][Money] = q.first;
        if(fast_ans[City] == -1) fast_ans[City] = q.first;
        // 移動するときの遷移
        for(auto e : G[City]) {
            if(Money - e.a >= 0LL && State[e.to][Money - e.a] == -1) {
                que.push(P(q.first + e.b, e.to*Row_size + Money - e.a));
            }
        }
        // 換金するときの遷移
        que.push(P(q.first + D[City], City*Row_size + min(SumA, Money + C[City])));
    }
    for(int i = 1; i < N; ++i) {
        cout << fast_ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    IN(ll, n);
    map<ll,ll> a;
    ll sum = 0;
    REP(i, n){
        IN(int, k);
        sum += k;
        a[k]++;
    }
    IN(ll, q);
    REP(i, q){
        ll b,c;
        cin >> b >> c;
        sum += (c-b)*a[b];
        a[c] += a[b];
        a[b] = 0;
        COUT(sum);
    }
    
}


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

int main(){
    vector<int> a(5), d(5);
    rep(i, 5){
        cin >> a.at(i);
    }
    
    int res = 0;
    rep(i, 5){
        if(a.at(i) % 10 != 0){
            d.at(i) = a.at(i)%10;
            a.at(i) = a.at(i)/10 *10 + 10;
        } else {
            d.at(i) = 10;
        }
        res += a.at(i);
    }
    sort(d.begin(), d.end());
    res -= (10-d.at(0));
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ALL(v) v.begin(), v.end()
ll mod = 1e9 + 7;
ll mul(ll a, ll b)
{
	return (a*b) % mod;
}
ll power(ll a, ll b)
{
	ll  re = 1;
	while(b)
	{
		while(!(b&1))a=mul(a,a),b>>=1;;
		re = mul(re,a);
		b--;
	}
	return re;
}
vector<ll> vec(1000010);
ll ncr(ll a, ll b)
{
	return (mul(vec[a], power(mul(vec[a-b], vec[b]), mod -2 )) );
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	

	int n;
	cin >> n;
	vector<pair<int,int> >a(n);
	int o = 0;

	for(auto &p : a)cin >> p.first, p.second = o, o++;
	sort(a.begin(), a.end());
	
	for(int x =0; x<n; x++)
	{
		if(a[n-1].second == x)
			cout << a[n-2].first << "\n";
		else
			cout << a[n-1].first << "\n";
	}
}

Measured memory_bytes: 11008
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
    int ia,ib,ix;
    double a,b,x;

    double c, theta, beta, gamma, phi, ans;

    cin >> ia >> ib >>ix;
    a= (double) ia;
    b= (double) ib;
    x= (double) ix;

    if( a/b > 2*x/(a*b*b) ){
        theta = atan( 2*x/(a*b*b) );

        //cout << "theta_pre a/b" << theta << " " << a/b << endl;     
    }else{
        theta = atan( a*a*a / ( 2* (a*a*b-x) ) );

        //cout << "c beta gamma phi theta " << c << " " << beta << " " << gamma <<" " << phi << " " << theta <<endl;
    }

    theta= theta/M_PI*180;
    ans=90-theta;

    cout << setprecision(9) << ans << endl;

    return 0;
}

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

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

typedef pair<int,int> PII;
typedef long long ll;

int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;

	cout<<H*W-h*W-w*H+w*h<<endl;	
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, M, K;
ll ans;

class FermatCombination {
private:

	long long MOD;

public:
	long long factrial[201010]; //階乗を保持
	long long inverse[201010];  //逆元を保持
	FermatCombination(ll size, long long mod);
	long long combine(ll n, ll k);
	long long fast_pow(long long x, ll n);
};

FermatCombination::FermatCombination(ll size, long long mod) {

	MOD = mod;

	factrial[0] = 1;
	inverse[0] = 1;

	for (ll i = 1; i <= size; i++) {
		factrial[i] = (factrial[i - 1] * i) % MOD;  // 階乗を求める
		inverse[i] = fast_pow(factrial[i], (int)MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
	}
}

long long FermatCombination::combine(ll n, ll k) {
	return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

long long FermatCombination::fast_pow(long long x, ll n) { // x^n 計算量O(logn)
	long long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD; // 一周する度にx, x^2, x^4, x^8となる
		n >>= 1;         // 桁をずらす n = n >> 1
	}
	return ans;
}

int main() {
	cin>>N>>M>>K;
	FermatCombination fc(N*M, mod);
	ll nmCk = fc.combine(N*M-2, K-2);
	ll sum = M*M %mod;
	sum *= nmCk % mod;
	sum %= mod;
	ll tmp=0;
	REP(i,1,N){
		tmp+=i;
		tmp%=mod;
		ans += (sum*tmp) %mod;
		ans %= mod;
	}
	sum = N*N % mod;
	sum *= nmCk % mod;
	sum %= mod;
	tmp = 0;
	REP(i,1,M){
		tmp+=i;
		tmp%=mod;
		ans += (sum*tmp) %mod;
		ans %= mod;
	}
	p(ans % mod);
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/24  Problem: ABC 123 C / Link: http://abc123.contest.atcoder.jp/tasks/abc123_c  ----- */


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

	LL N; cin >> N;
	vector<LL> a(5);
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	LL mn = *min_element(ALL(a));
	LL ans = 4 + (N + mn - 1) / mn;


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{

	int a, b;
	cin >> a >> b;
	if (a == 1)
	{
		a = 14;
	}
	if (b == 1)
	{
		b = 14;
	}
	if (a > b)
	{
		cout << "Alice" << endl;
	}
	else if (a < b)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Draw" << endl;
	}
		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
 int a,b,c;
 cin>>a>>b>>c;
 int t=abs(a-b);
 if(t>c){
    cout<<"0"<<endl;
 }
 else cout<<abs(c-t)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int m, k;
    cin >> m >> k;
    if(k >= (1 << m))cout << -1 << endl;
    else if(k == 1 && m == 1)cout << -1 << endl;
    else if(k > 0){
        rep(i, (1 << m))if(i != k)cout << i << ' ';
        cout << k << ' ';
        rep(i, (1 << m))if((1 << m) - 1 - i != k)cout << (1 << m) - 1 - i << ' ';
        cout << k << endl;
    }else{
        rep(i, (1 << m))cout << i << ' ';
        rep(i, (1 << m))cout << (1 << m) - 1 - i << ' ';
        cout << endl;
    }
    
}

Measured memory_bytes: 1792