akhauriyash/Code-Regression huggingface dataset:
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int par[100010],rnk[100010],dif[100010];

void init(int n){
	rep(i,n){
		par[i] = i; rnk[i] = 0; dif[i] = 0;
	}
}

pi find(int x){
	if(par[x] == x) return mp(x, 0);
	else{
		pi res = find(par[x]);
		par[x] = res.fir;
		dif[x] += res.sec;
		return mp(par[x], dif[x]);
	}
}

void unite(int x,int y,int d){
	pi res0 = find(x), res1 = find(y);
	x = res0.fir, y = res1.fir;
	if(x == y) return;
	if(rnk[x] < rnk[y]){
		par[x] = y;
		dif[x] = d - res0.sec + res1.sec;
	}
	else{
		par[y] = x;
		dif[y] = -d + res0.sec - res1.sec;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

pi query(int x,int y){
	pi res0 = find(x), res1 = find(y);
	x = res0.fir, y = res1.fir;
	if(x != y) return mp(0, 0);
	else return mp(1, res0.sec - res1.sec);
}

int N,M;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N>>M && N){
		init(N);
		rep(i,M){
			char c;
			cin>>c;
			if(c=='!'){
				int a,b,w;
				cin>>a>>b>>w,a--,b--;
				unite(a,b,w);
			}else{
				int a,b;
				cin>>a>>b,a--,b--;
				pi p = query(a,b);
				if(p.fir == 0)cout<<"UNKNOWN"<<endl;
				else cout<<p.sec<<endl;
			}
		}
	}
}

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

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int main(void)
{
	int ans=0;
	string s;
	cin>>s;
	rep(i,4) ans+=(s[i]=='+')?1:-1;
	cout<<ans<<endl;
}

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

long long int s[100005],t[100005];
int lower_s(int start,int end,long long int x){
    while(end-start>1){
        if(s[(start+end)/2]<x)start=(start+end)/2;
        else end=(start+end)/2;
    }
    return end;
}
int lower_t(int start,int end,long long int x){
    while(end-start>1){
        if(t[(start+end)/2]<x)start=(start+end)/2;
        else end=(start+end)/2;
    }
    return end;
}

int main(){
    int a,b,q;
    cin >> a >> b >> q;
    long long int x;
    long long int ans=1e15;
    int tmp1,tmp2;
    for(int i=0;i<a;i++)cin >> s[i];
    for(int j=0;j<b;j++)cin >> t[j];
    for(int i=0;i<q;i++){
        ans=1e15;
        cin >> x;
        tmp1=lower_s(0,a-1,x);
        tmp2=lower_t(0,b-1,x);
        for(int i=max(tmp1-1,0);i<=tmp1;i++){
            for(int j=max(tmp2-1,0);j<=tmp2;j++){
                ans=min(ans,abs(s[i]-x)+abs(s[i]-t[j]));
                ans=min(ans,abs(t[j]-x)+abs(s[i]-t[j]));
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	if (s.size() <= n) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, n) << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3588
function f()
    N = map(x -> parse(Int, x), split(chomp(readline()), " "))[1]
    t = map(x -> parse(Int, x), split(chomp(readline()), " "))
    M = map(x -> parse(Int, x), split(chomp(readline()), " "))[1]

    P = []
    X = []
    for i in 1:M
        input = map(x -> parse(Int, x), split(chomp(readline()), " "))
        append!(P, input[1])
        append!(X, input[2])
    end

    ret = []
    for i in 1:M
        tmp = copy(t)
        tmp[P[i]] = X[i]
        println(sum(tmp))
    end
end
f()

Measured memory_bytes: 170016
x,k,d = map(int,input().split())
ans = 0

if x < 0:
    if k <= abs((x//d))-1:
        ans = abs(x+(k*d))
    else:
        a = abs((x//d))-1
        x = x+(a*d)
        k -= a
        if k%2 == 0:
            ans = abs(x)
        else:
            ans = abs(x+d)
elif x > 0:
    if k <= (x//d):
        ans = abs(x-(k*d))
    else:
        a = x//d
        x = x-(a*d)
        k -= a
        if k%2 == 0:
            ans = abs(x)
        else:
            ans = abs(x-d)
else:
    if d % 2 == 0:
        ans = 0
    else:
        ans = d

print(ans)


Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<vector<char>> C(2 * H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> C.at(2 * i).at(j);
			C.at(2 * i + 1).at(j) = C.at(2 * i).at(j);
		}
	}

	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			cout << C.at(i).at(j);
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Node
{
	int key;
	Node prev, next;

	Node()
	{
		key = -1;
		prev = next = null;
	}
}

class DoublyLinkedList
{
	Node nil;
	int N;

	DoublyLinkedList()
	{
		nil = new Node();
		nil.next = nil;
		nil.prev = nil;
		N = 0;
	}

	//先頭に挿入
	void insertNode(Node t, int val)
	{
		Node x = new Node();
		x.key = val;
		x.next = t.next;
		t.next.prev = x;
		x.prev = t;
		t.next = x;
		N++;
	}

	void insertFirst(int val)
	{
		insertNode(nil, val);
	}

	void insertLast(int val)
	{
		insertNode(nil.prev, val);
	}

	void deleteNode(Node t)
	{
		if (t == nil)
		{
			return;
		}
		t.prev.next = t.next;
		t.next.prev = t.prev;
		N--;
	}

	void deleteFirst()
	{
		deleteNode(nil.next);
	}

	void deleteLast()
	{
		deleteNode(nil.prev);
	}

	Node searchKey(int key)
	{
		Node cur = nil.next;
		while (cur != nil && cur.key != key)
		{
			cur = cur.next;
		}
		return cur;
	}

	void deleteKey(int key)
	{
		deleteNode(searchKey(key));
	}

	void print()
	{
		for (Node cur = nil.next; cur != nil; cur = cur.next)
		{
			if (cur != nil.next)
			{
				System.out.print(" ");
			}
			System.out.print(cur.key);
		}
		System.out.println();
	}
}

class Hoge
{
	int fuga;
	static int honya = 100;

	Hoge(int x)
	{
		fuga = x;
	}
}

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		DoublyLinkedList L = new DoublyLinkedList();
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; ++i)
		{
			String line = br.readLine();
			if (line.charAt(6) == ' ')
			{
				//****** x
				String[] com = line.split(" ");
				if (com[0].charAt(0) == 'i')
				{
					L.insertFirst(Integer.parseInt(com[1]));
				} else if (com[0].charAt(0) == 'd')
				{
					L.deleteKey(Integer.parseInt(com[1]));
				}
			} else
			{
				if (line.charAt(6) == 'F')
				{
					L.deleteFirst();
				} else if (line.charAt(6) == 'L')
				{
					L.deleteLast();
				}
			}
		}
		L.print();
	}
}



Measured memory_bytes: 192464
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll ans = 1;
    rep(0, i, N)
    {
        ans *= (i + 1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
const int MaxN=2e5;
const int MaxA=1e6;
int N, num[MaxN];
bool IsDiv[MaxA+1]={};

int main(){
	scanf("%d\n",&N);
	for(int i=0;i<N;i++)
		scanf("%d",&num[i]);
	
	int cnt=0;
	sort(num,num+N);
	
	for(int i=0;i<N-1;i++)
		if(IsDiv[ num[i] ]==0){
			if(num[i]!=num[i+1])
				cnt++;
			for(int j=num[i];j<=num[N-1];j+=num[i])
				IsDiv[j]=1;
		}
	printf("%d\n",cnt+(IsDiv[ num[N-1] ]==0));
}

Measured memory_bytes: 5316
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n, m, k = nm()
a = nl()
b = nl()
sum_a = [0]
sum_b = [0]
for i in range(n):
    sum_a.append(sum_a[i] + a[i])
for i in range(m):
    sum_b.append(sum_b[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if sum_a[i] > k:
        break
    while sum_b[j] > k - sum_a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47848
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,m;cin>>n>>m;
	ll res=min(2LL*n,m);
	ll ct=res/2;
	m=m-res;
	m/=4;
	cout<<ct+m;

	
}

Measured memory_bytes: 256
/*Lower_Rating*/
/*Ex*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<set>
using namespace std;

#define LL long long
#define DB double
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 100
#define eps 1e-10
#define INF 2147483647
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(LL a,int b){return a*b%MOD;}

int n;
int a[MAXN+5],p[MAXN+5],ans;
int dp[(MAXN>>1)+5][MAXN+5][MAXN+5];

int main(){
    //freopen("hardest.in","r",stdin);
    //freopen("hardest.out","w",stdout);
    n=read();
    for(int i=1;i<=2*n-1;i++)a[i]=read();
    sort(a+1,a+2*n);
    dp[n][1][0]=1;
    for(int i=n-1;i>=1;i--){
        int al=(a[i]!=a[i+1]),ar=(a[2*n-i]!=a[2*n-i-1]);
        for(int l=0;l<=2*n-1;l++)
            for(int r=0;l+r<=2*n-1;r++)
            if(dp[i+1][l][r]){
                for(int dl=1;dl<=l+al;dl++){
                    int pl=l+al-dl+1,pr=r+ar+(dl>1);
                    dp[i][pl][pr]=add(dp[i][pl][pr],dp[i+1][l][r]);
                }
                for(int dr=1;dr<=r+ar;dr++){
                    int pl=l+al+1,pr=r+ar-dr;
                    dp[i][pl][pr]=add(dp[i][pl][pr],dp[i+1][l][r]);
                }
            }
    }
    for(int l=0;l<=2*n-1;l++)
        for(int r=0;l+r<=2*n-1;r++)
        ans=add(ans,dp[1][l][r]);
    printf("%d",ans);
}


Measured memory_bytes: 1408
import java.util.Scanner

fun main(args:Array<String>){
    val sc=Scanner(System.`in`)

    var n=sc.nextInt()
    var x=sc.nextLong()
    var a=IntArray(n)
    var total=0L

    for (i in 0 until n){
        a[i]=sc.nextInt()
        total+=a[i]
    }

    when{
        x==total-> println(n)
        x>total-> println(n-1)
        x<total->{
            a.sort()
            var sum=0
            for (k in 0 until n){
                sum+=a[k]
                if (sum>x){
                    println(k)
                    break
                }
            }
        }
    }
}

Measured memory_bytes: 35784
import sys

sys.setrecursionlimit(10 ** 7)


def fact(x):
    if x == 0:
        return 1
    else:
        return x * fact(x - 1) % mod


mod = 10 ** 9 + 7

n = int(input())
s = input()
t = list(map(lambda x: 1 if x == 'B' else 0, s))
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(range(n * 2))))
# print(t)

zeros = 0
ans = 1
ones = 0
for tt in t:
    if tt == 0:
        zeros += 1
    else:
        if zeros == 0:
            print(0)
            exit()
        ans *= zeros
        ans %= mod
        zeros -= 1
        ones += 1

if zeros > 0:
    ans = 0

ans *= fact(ones)
ans %= mod
print(ans)


Measured memory_bytes: 85504
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a,b;
  int ans = INT_MIN;
  cin >> a >> b;

  ans = max(ans,a+b);
  ans = max(ans,a-b);
  ans = max(ans,a*b);

  cout << ans << endl;
}

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

int main() {
  char a,b;
  cin>>a>>b;
  if((a=='D' && b=='D') || (a=='H' && b=='H')) cout<<'H'<<endl;
  else cout<<'D'<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,K;cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;i++)cin>>A[i];
  for(int j=K;j<N;j++){
    if(A[j-K]<A[j])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string S, T;
    cin >> S >> T;

    vi sS(SZ(S)), sT(SZ(T));
    sS[0] = S[0] - 'A' + 1;
    REPF(i, 1, SZ(S)) sS[i] += sS[i - 1] + (S[i] - 'A' + 1);
    sT[0] = T[0] - 'A' + 1;
    REPF(i, 1, SZ(T)) sT[i] += sT[i - 1] + (T[i] - 'A' + 1);

    int q;
    cin >> q;
    REP(i, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        
        int x = sS[b] - (a > 0 ? sS[a - 1] : 0);
        int y = sT[d] - (c > 0 ? sT[c - 1] : 0);
        if (x % 3 == y % 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return (0^_^0);
}



Measured memory_bytes: 2512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

V<V<int>> to(1e5+5);
map<P, ll> d;
V<ll> dk(1e5+5, -1);

void dfs (int now, int p, ll cost) {//nowの親はp
    dk[now] = cost;
    for (int nxt : to[now]) {
        if (nxt == p) continue;
        dfs(nxt, now, cost + d[{now, nxt}]);
    }
}

int main () {
    int n; cin >> n;
    rep(i, n-1) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        to[a].emplace_back(b); to[b].emplace_back(a);
        d[{a, b}] = d[{b, a}] = c;
    }
    int q, k; cin >> q >> k; k--;
    dfs(k, -1, 0);
    rep(i, q) {
        int x, y; cin >> x >> y; x--; y--;
        printf("%ld\n", dk[x] + dk[y]);
    }

    return 0;
}

Measured memory_bytes: 31372
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;

int main()
{
	//ios::sync_with_stdio(false);
	ll a = 0, b = 0, c = 0, k = 0;
	cin >> a >> b >> c >> k;
	ll res = 0;
	if(k <= a){
		res += k;
		k = 0;
	}
	else{
		res += a;
		k -= a;
	}
	k -= b;
	if(k > 0)
		res -= k;
	cout << res << endl;
    return 0;
}















Measured memory_bytes: 3636
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long s = sc.nextLong();
		
		long[] a = new long[20];
		long[] b = new long[20];
		for(int i=1;;i++){
			long all = (long)Math.pow(10, i);
			b[i] = all/3 + all/5;
			long sum = 0;
			long sum2 = 0;
			for(int j=i;j>0;j--){
				sum += (b[j]-b[j-1])*j;
				sum2 += (b[j]-b[j-1]);
			}
			a[i] = b[i]*4 + sum;

			if(a[i]>s){
				sum2 -= (b[i]-b[i-1]);
				sum -= (b[i]-b[i-1])*i;
				long left = (long)Math.pow(10, i-1);
				long right = (long)Math.pow(10, i)-1;
				long mid = -1;
				long id = -1;
				while(true){
					mid = (left+right)/2;
					
					long fb = mid/3 + mid/5;
					long dif = mid-sum2-fb+mid/15;
					id = fb*4 + sum + dif*i;
					
					if(id<s){
						left = mid+1;
					}else{
						right = mid-1;
					}

					if(left>right) break;
				}
				String str = "";
				for(long j=mid;j<=mid+20;j++){
					if(j%3==0) str += "Fizz";
					if(j%5==0) str += "Buzz";
					if(j%3!=0 && j%5!=0) str += j;
				}
				
				long mus = i;
				if(mid%15==0) mus = 8;
				else if(mid%3==0 || mid%5==0) mus = 4;
				long iid = mus-(id-s+1);
				str = str.substring((int)iid, (int)(iid+20));
				System.out.println(str);
				break;
			}
		}
	}	
}

Measured memory_bytes: 17388
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)
t=1
# t=int(input())
for _ in range(t):
    h,w = map(int, input().split())

    if h%3==0 or w%3==0:
        print(0)
        exit()

    res = min(h,w)
    for hi in range(1,h):
        b1 = hi*w
        b2 = (h-hi)*(w//2)
        b3 = (h-hi)*(w//2+w%2)
        res = min(res, max(b1,b2,b3)-min(b1,b2,b3))
    for wi in range(1,w):
        b1 = wi*h
        b2 = (w-wi)*(h//2)
        b3 = (w-wi)*(h//2+h%2)
        res = min(res, max(b1,b2,b3) - min(b1,b2,b3))

    print(res)


Measured memory_bytes: 10640
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define ll long long int
#define MOD (int) (1e9+7)
#define in_arr(ar) for(int i=0;i<sizeof(ar)/sizeof(ar[0]);i++)cin>>ar[i];
#define val(x) cout<<"Value of "<<(#x)<<" is "<<x<<endl;

ll ans=0;
void factorize(long long n)
{
    int count = 0;

    // check for all the possible numbers that can
    // divide it
    for (long long i = 2; i <= sqrt(n); i += 1) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        int sum=0;
        int j=1;
        while(sum+j<=count)
        {
            sum+=j;
            j++;
        }
        if(count)ans+=(j-1);
    }

    // if n at the end is a prime number.
    if (n > 2)
        ans+=1;
}

int main()
{
    ll n;
    cin>>n;
    factorize(n);
    cout<<ans<<endl;


}


Measured memory_bytes: 3700
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
h = [int(input()) for _ in range(n)]

h = sorted(h)
ans = 10 ** 9 + 1
for i in range(len(h) - (k-1)):
    ans = min(ans, h[i+k-1] - h[i])
print(ans)



Measured memory_bytes: 8324
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a,b,c,ans;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b) swap(a,b);
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	printf("%d\n",c-a);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    int x,a,b;
    cin >> x >> a >> b;

    if(a - b >= 0) cout << "delicious" << endl;
    else if(b - a < x + 1) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}

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

int main(void){
    int i;
    char X;
    int Count[26];

    for(i=0;i<26;i++){
        Count[i]=0;
    }

    while(scanf("%c",&X)!=EOF){
        if(X<97) Count[X-'A']++;
        else Count[X-'a']++;
    }

    for(i=0;i<26;i++){
        printf("%c : %d\n",i+97,Count[i]);
    }

    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll>a(n);
	ll sum = 0;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	vector<pair<ll, ll>>b(m);
	REP(i, m) {
		cin >> b[i].second >> b[i].first;
	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	int s = 0;
	REP(i, m) {
		if (a[s] >= b[i].first) {
			break;
		}
		REP(j, b[i].second) {
			if (a[s] < b[i].first) {
				sum += b[i].first - a[s];
				a[s] = b[i].first;
				s++;
				if (s == n) {
					break;
				}
			}
		}
		if (s == n) {
			break;
		}
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> ps;
  for (int i = 0; i < n; i++) {
    int r, c;
    cin >> r >> c;
    r--;
    c--;
    ps.push_back(make_pair(r, c));
  }
  sort(ps.begin(), ps.end(), [](auto& p1, auto& p2) {
    if (p1.first != p2.first) return p1.first < p2.first;
    return p1.second < p2.second;
  });
  ps.push_back(make_pair(h - 1, w - 1));

  vector<FiniteField> factorials(h + w + 1);
  factorials[0] = 1;
  for (int i = 1; i <= h + w; i++) {
    factorials[i] = factorials[i - 1] * i;
  }

  auto base_count = [&](int dr, int dc) -> FiniteField {
    if (dr < 0) return 0;
    if (dc < 0) return 0;
    return factorials[dr + dc] / factorials[dr] / factorials[dc];
  };

  n = ps.size();
  vector<FiniteField> dp(n);
  for (int i = 0; i < n; i++) {
    int r, c;
    tie(r, c) = ps[i];
    FiniteField value = base_count(r, c);
    for (int j = 0; j < i; j++) {
      value -= dp[j] * base_count(r - ps[j].first, c - ps[j].second);
    }
    dp[i] = value;
  }
  cout << dp[n - 1].Value() << endl;
}


Measured memory_bytes: 2048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var A = inputNum[0];
			var B = inputNum[1];
			var M = inputNum[2];

			var AList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var BList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			// 割引券なしの最小値
			var min = AList.Min() + BList.Min();

			for(int i = 0; i < M;i++)
			{
				var waribiki = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

				var afterWari = AList[waribiki[0] - 1] + BList[waribiki[1] - 1] - waribiki[2];

				if(min > afterWari)
				{
					min = afterWari;
				}
			}

			Console.WriteLine(min);
		}
	}
}

Measured memory_bytes: 35676
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s;
    cin >> s;
    int a_res = 0;
    int b_res = 0;
    REP(i, s.size()) {
        // a: 1010...
        // b: 0101...
        if (s[i] == '1') {
            a_res += i % 2;
            b_res += (i + 1) % 2;
        } else {
            a_res += (i + 1) % 2;
            b_res += i % 2;
        }
    }
    cout << min(b_res, a_res) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
using namespace std;

int main() {
  int A, B, C, X;
  scanf("%d\n", &A);
  scanf("%d\n", &B);
  scanf("%d\n", &C);
  scanf("%d\n", &X);
  int ans = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        int sumV = 500* i + 100* j + 50* k;
        if (sumV == X) {
          ++ans;
        }
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
N = int(input())
P = []
for _ in range(N):
    t,x,y = map(int, input().split())
    P.append((t,x,y))

ans = True
pre = (0,0,0)
for t,x,y in P:
    dt, dx, dy = t-pre[0], abs(x-pre[1]), abs(y-pre[2])
    if dt < dx+dy or (dt-(dx+dy))&1:
        ans = False
        break
    pre = (t,x,y)

print('Yes' if ans else 'No')

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

int main(){
  long long n,m;
  cin >> n >> m;
  long long yoko=0,tate=0;
  long long now,next;
  long long shou = 1000000007;
  cin >> next;
  for(int i=1;i<=n-1;i++){
    now = next;
    cin >> next;
    yoko+=(((next-now)*(n-i)%shou)*i%shou);
    yoko%=shou;
  }
  cin >> next;
  for(int i=1;i<=m-1;i++){
    now = next;
    cin >> next;
    tate+=(((next-now)*(m-i)%shou)*i%shou);
    tate%=shou;
  }

  cout << (tate*yoko%shou) << endl;

  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

/*
0-index
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
struct segtree{
	int n;
	vector<T> dat;
	T ZERO;
	function<T(T,T)> f;
	
	segtree(int n_,T zero, function<T(T,T)> f_)
	:ZERO(zero), f(f_){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	
	void update(int k, T a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = f(dat[k*2+1],dat[k*2+2]);
	  }
	}

	void set(int k, T a) {
		k += n - 1;dat[k] = a;
	}

	void build(){
		for(int i = n - 2;i >= 0;i--){
			dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
		}
	}

	T get(int k){return dat[k+n-1];}

	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = f(L,dat[A++]);
            if((B & 1) == 0)R = f(dat[--B],R);
            A = A >> 1;
            B = B >> 1;
		}
		return f(L,R);
	}
};

ll mp[222222];
segtree<ll> evenSeg(222222, INF, [](ll a, ll b){return min(a, b);});
segtree<ll> oddSeg(222222, INF, [](ll a, ll b){return min(a, b);});

pair<P, P> getPair(int l, int r){
	ll fi,se;
	if(l % 2) {
		fi = oddSeg.que(l, r+1);
		se = evenSeg.que(mp[fi], r+1);
	}
	else {
		fi = evenSeg.que(l, r+1);
		se = oddSeg.que(mp[fi], r+1);
	}
	return MP(MP(fi, se), MP(l, r));
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	
	int n;cin >> n;
	
	REP(i, n){
		ll a;cin >> a;a--;
		mp[a] = i;
		if(i % 2)oddSeg.update(i, a);
		else evenSeg.update(i, a);
	}
	
	priority_queue<pair<P, P>, vector<pair<P, P>>, greater<pair<P, P>>> pq;
	vector<P> ans;
	pq.push(getPair(0, n-1));
	
	while(!pq.empty()){
		auto now = pq.top();pq.pop();
		ans.PB(now.FI);
		ll nl = mp[now.FI.FI];
		ll nr = mp[now.FI.SE];
		ll l = now.SE.FI;
		ll r = now.SE.SE;
		if(abs(nl - l) > 1)pq.push(getPair(l, nl-1));
		if(abs(nr - nl) > 1)pq.push(getPair(nl+1, nr-1));
		if(abs(r - nr) > 1)pq.push(getPair(nr+1, r));
	}
	
	REP(i, ans.size()){
		cout << ans[i].FI+1 << " " << ans[i].SE+1;
		if(i != ans.size() - 1)cout << " ";
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 15192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int s,ue,sita;
  	cin >>s;
  	sita=s%100;  
  	ue=(s-sita)/100;
  
  	//cout<<ue<<"a"<<sita<<endl;
  
  	if (1<=ue&&ue<=12) {
      if (1<=sita&&sita<=12) {       
        cout<<"AMBIGUOUS"<<endl;
    	}       
      else{       
        cout<<"MMYY"<<endl;
    	}    
    }
  	else{
       if (1<=sita&&sita<=12) {       
        cout<<"YYMM"<<endl;
    	}       
      else{       
        cout<<"NA"<<endl;
    	}    
    }
}

Measured memory_bytes: 256
//AC

#include<stdio.h>
#include<string.h>
int main()
{
	char a[10]={};
	int c,i,cnt=0,leap=0;
	while(gets(a)){
		c=strlen(a);
		for(i=0;i<c;i++){
			if(a[i]==' '){
				continue; 
			}else if(a[i]=='5'){
				cnt++;
			}else if(a[i]=='7'){
				leap++;
			}
		}if(cnt==2&&leap==1){
			printf("YES\n");
		}else{
			printf("NO\n");
		}cnt=0;leap=0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
using namespace std;

int main (void) {
  int n;
  cin >> n;
  vector<int> x(n);
  REP(i, n) {
    cin >> x[i];
  }
  vector<int> x2(x);
  sort(ALL(x2));
  int m1 = x2[n / 2 - 1], m2 = x2[n / 2];

  if (m1 == m2) {
    REP(i, n)
      cout << m1 << endl;
  } else {
    REP(i, n) {
      // cerr << "x[" << i << "] = " << x[i] << endl;
      if (x[i] <= m1) {
        cout << m2 << endl;
      } else {
        cout << m1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3840
import sys
  
dic = {}

stdin = sys.stdin
n = int(stdin.readline())

for _ in range(n):
    command, c = stdin.readline().split()
    if command == 'insert':
        dic[c] = 1
    elif command == 'find':
        if c in dic:
            sys.stdout.write('yes\n')
        else:
            sys.stdout.write('no\n')

sys.stdout.flush()


Measured memory_bytes: 33240
import java.io.*;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				String v = br.readLine();
				int a[] = new int[8];
				int max[] = new int[8];
				int min[] = new int[8];
				for (int j=0;j<8;j++) {
					a[j] = Character.getNumericValue(v.charAt(j));
				}
				Arrays.sort(a);
				for (int j=0;j<8;j++) {
					min[j] = a[j];
					max[j] = a[7-j];
				}
				int dif[] = new int[8];
				sub(max,min,dif);

				int c = 0;
				while (dif[c]==0) {
					c++;
					if (c==7) break;
				}
				for (int j=c;j<8;j++) {
					System.out.print(dif[j]);
				}
				System.out.println("");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void sub(int a[],int b[],int c[]) {
		for (int i=7;i>=0;i--) {
			c[i] = a[i]-b[i];
			if (c[i]<0) {
				a[i-1] -= 1;
				c[i] += 10;
			}
		}
	}
}

Measured memory_bytes: 16864
<?php
list($k,$a,$b) = explode(" ",trim(fgets(STDIN)));
if($b-$a<=2||$k<=$a){
  echo $k+1;
}else{
  $n=floor(($k+1-$a)/2);
  $r=($k+1-$a)%2;
  echo (int)$n*($b-$a)+$r+$a;
}

Measured memory_bytes: 4856
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    vector<int> t;
    vector<int> x;
    vector<int> y;
    int tmp_t;
    int tmp_x;
    int tmp_y;
    bool ans=true;

    cin >> n;

    t.push_back(0);
    x.push_back(0);
    y.push_back(0);
    for(int i=0; i<n; i++){
        cin >> tmp_t >> tmp_x >> tmp_y;
        t.push_back(tmp_t);
        x.push_back(tmp_x);
        y.push_back(tmp_y);
    }

    for(int i=0; i<n; i++){
        int dist=(int)abs(x[i+1]-x[i])+(int)abs(y[i+1]-y[i]);
        int tdiff=t[i+1]-t[i];
        if(dist>tdiff){
            ans=false;
        }else if((tdiff-dist)%2!=0){
            ans=false;
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main(void){
  int A, B, C, X, Y, Z;
  cin >> A >> B >> C >> X >> Y;
  if(A + B > 2 * C){
    Z = min(X, Y);
    X -= Z;
    Y -= Z;
    Z *= 2;
  }
  cout << X * min(A, 2 * C) + Y * min(B, 2 * C) + Z * C << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var (
		n, k, sum int
	)
	n, k = nextInt(), nextInt()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}
	sort.Ints(p)
	for j := 0; j < k; j++ {
		sum += p[j]
	}
	fmt.Print(sum)
}

func init() {
	const max = 1024
	var buf = make([]byte, max)
	sc.Buffer(buf, max)
	sc.Split(bufio.ScanWords)
	return
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N,X[4];
    ll ans=0;
    string S;
    bool F;
int main(){
    cin>>A>>B;
    X[A]=X[A]+1,X[B]=X[B]+1;
  	for(int i=1;i<=3;i++){
      if(X[i]==0)cout<<i<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, h, w;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> h >> w >> n;
    int best = h + w;
    for (int cnt1 = 0; cnt1 <= h; cnt1++) {
        for (int cnt2 = 0; cnt2 <= w; cnt2++) {
            int tot = cnt1 * w + cnt2 * h - cnt1 * cnt2;
            if (tot >= n) best = min(best, cnt1 + cnt2);
        }
    }
    cout << best;
    return 0;
}

Measured memory_bytes: 256
// AOJ 3001: GPA JANKEN
// 2017.11.29 bal4u@uu

#include <stdio.h>

int a[100002];
int p[100002];
int tr[4002];

char buf[10], *bp;
int getint() { int n = 0; while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf); return n; }
int getdbl() {
	int n = 0; while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	if (*bp == '.') { bp++; while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);	} return n;
}

int main()
{
	int n, i, j;

    fgets(bp=buf, 10, stdin), n = getint();
	for (i = 0; i < n; i++) {
		fgets(bp=buf, 10, stdin);
		a[i] = getdbl();
	}

    for (i = 0; i < n; i++) {
		if (tr[a[i]]) { p[i] = tr[a[i]]; continue; } 
        for (j = 0; j < n; j++) {
            if      (a[i]  > a[j]) p[i] += 3;
            else if (a[i] == a[j]) p[i]++;
        }
        tr[a[i]] = p[i];
    }
	for (i = 0; i < n; i++) printf("%d\n", p[i]-1);
    return 0;
}

Measured memory_bytes: 2488
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, k;
bool vis[110];

int main() {
    n = read(); k = read();
    for(int i = 1; i <= k; ++i) {
        int d = read(); int a;
        for(int j = 1; j <= d; ++j) a = read(), vis[a] = 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) if(!vis[i]) ++ans;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, c, t;
  cin >> a >> b >> c;

  if(a > b) {
    t = a;
    a = b;
    b = t;
  }
  if(b > c) {
    t = b;
    b = c;
    c = t;
  }
  if (a > b) {
    t = a;
    a = b;
    b = t;
  }
  cout << a << " " << b << " " << c << endl;

  return 0;
}


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

int main() {
    double a, b, x; cin >> a >> b >> x;
    double h = x / a / a;
    cout.precision(10);
    if(h > b / 2.0) {
        // tanX = 2*(b - h)/a
        cout << atan(2*(b - h) / a) * 180 / PI << "\n";
    } else {
        cout << atan(b*b / 2 / a / h) * 180 / PI << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

typedef long long LL;

inline void Cmax(LL &a, LL b) {
    if (a < b) a = b;
    return;
}

const int N = 100010;
const LL NINF = 0x8000000000000000;

int n;
LL a[N * 3], lsum[N * 3], rsum[N * 3];

priority_queue<int> pq;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n * 3; ++i)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= n; ++i) {
        pq.push(-a[i]);
        lsum[n] += a[i];
    }
    for (int i = n + 1; i <= n * 2; ++i) {
        lsum[i] = lsum[i - 1];
        int cur = -pq.top();
        if (cur < a[i]) {
            lsum[i] += a[i] - cur;
            pq.pop();
            pq.push(-a[i]);
        }
    }
    for (int i = n * 2 + 1; i <= n * 3; ++i) {
        pq.push(a[i]);
        rsum[n * 2 + 1] += a[i];
    }
    for (int i = n * 2; i >= n + 1; --i) {
        rsum[i] = rsum[i + 1];
        int cur = pq.top();
        if (cur > a[i]) {
            rsum[i] += a[i] - cur;
            pq.pop();
            pq.push(a[i]);
        }
    }
    LL Max = NINF;
    for (int i = n; i <= n * 2; ++i)
        Cmax(Max, lsum[i] - rsum[i + 1]);
    printf("%lld\n", Max);
    return 0;
}

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

using namespace std;
#define ll  long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn= 2e5+7;
const ll mod= 1e9+9 ;
const ll base=1e6+1000;

ll st[4*maxn][3];
ll la[4*maxn][3];
void dosth(ll id,ll left,ll right,ll type)
{
    if (left!=right)
    {
        st[id*2][type]=min(la[id][type],st[id*2][type]);
        la[id*2][type]=min(la[id][type],la[id*2][type]);
        st[id*2+1][type]=min(la[id][type],st[id*2+1][type]);
        la[id*2+1][type]=min(la[id][type],la[id*2+1][type]);
        la[id][type]=1e15;
    }

}
void update(ll id,ll left,ll right , ll x,ll y ,ll diff,ll type)
{
    dosth(id,left,right,type);
    if (x>right||y<left) return ;
    if (x<=left&&y>=right)
    {
        st[id][type]=min(st[id][type],diff);
        la[id][type]=min(la[id][type],diff);
          dosth(id,left,right,type);
          return;
    }
    ll mid=(left+right) /2;
    update(id*2, left, mid,x, y, diff, type);
    update(id*2+1, mid+1 , right,x, y, diff, type);
    st[id][type]=min(st[id*2][type],st[id*2+1][type]);
}
ll get(ll id,ll left,ll right,ll x, ll y,ll type)
{
 dosth(id,left,right,type);
    if (x>right||y<left) return 1e15;
    if (x<=left&&y>=right)
    {

          return st[id][type];
    }
    ll mid=(left+right) /2;
    return min(get(id*2, left, mid,x, y, type),get(id*2+1, mid+1 , right,x, y, type));

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//freopen("test.txt","r", stdin);

    if (fopen("walk.in","r"))
    {
        freopen("walk.in","r", stdin);
        freopen("walk.out", "w",stdout);
    }
    ll n;
     cin>>n ;
     for (int i=1;i<=4*n;i++)
     {
         st[i][1]=1e15;
         la[i][1]=1e15;
         la[i][0]=1e15;
         st[i][0]=1e15;
     }
     update(1,1,n,1,n,n,0);
      update(1,1,n,1,n,n,1);
      ll q;
      cin>> q;
      ll ans=(n-2)*(n-2);
      //cout <<ans<<endl;
      while (q--)
      {
           ll t;
           cin>> t;
           if (t==1)
           {
             ll x;
              cin>>x;
              ll h= get(1,1,n,x,n,0);
              //cout <<h<<endl;
              ans=ans-(h-2);
              update(1,1,n,1,h,x,1);


           }
           else
           {
             ll x;
              cin>>x;
              ll h= get(1,1,n,x,n,1);
              ans=ans-(h-2);
              update(1,1,n,1,h,x,0);
           }
      }
      cout <<ans;


}


Measured memory_bytes: 41144
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

// int get_abs(int x);

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), num_patterns(n + 1, -1);
    // int diff_min = n;
    for(int i = 0; i < m; ++i){
        cin >> a[i];
        num_patterns[a[i]] = 0;
        // if(i > 0){
        //     diff_min = /*(a[i] == a[i - 1])? diff_min :*/ min(diff_min, a[i] - a[i - 1]);
        // }
    }

    // cout << "diff_min = " << diff_min << endl;
    // if(diff_min == 1){
    //     cout << "0" << endl;
    //     return 0;
    // }
    
    for(int i = 0; i < n + 1; ++i){
        if(num_patterns[i] == 0){
            continue;
        }

        if(i <= 1){
            num_patterns[i] = 1;
        }else{
            num_patterns[i] = (num_patterns[i - 1] % MOD_CONST + num_patterns[i - 2] % MOD_CONST) % MOD_CONST;
        }
    }

    // cout << "num_patterns : [";
    // for(int i = 0; i < n + 1; ++i){
    //     cout << " " << num_patterns[i];
    // }
    // cout << " ]\n";
    int ans = num_patterns[n];
    cout << ans << endl;
    return 0;
}

// int get_abs(int x){
//     return (x > 0)? x : -x;
// }

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> xl, xr;
  rep(i, N){
    ll x;
    cin >> x;
    if(x >= 0) xr.push_back(x);
    else xl.push_back(-x);
  }
  sort(xl.begin(), xl.end());

  ll ans = 1e13;
  rep(n_left, K+1){
    if(n_left > (ll)xl.size() || K - n_left > (ll)xr.size()) continue;
    ll tl = xl.size() > 0 ? xl[n_left-1] : 0;
    ll tr = xr.size() > 0 ? xr[K-n_left-1] : 0;
    ll t = tl + tr + min(tr, tl);
    ans = min(t, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1656
#include<stdio.h>

int A[100000];

int partition(int A[],int p,int r){
  int x,i,j,tmp,tmp2;

  x = A[r];
  i = p-1;
  for(j=p ; j<r ; j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp2=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp2;
  return i+1;

}



int main(){
  int i,j,count,q;

  scanf("%d",&count);

  for(i=0 ; i<count ; i++){
    scanf("%d",&A[i]);
  }

  q = partition(A,0,count-1);
  for(i=0 ; i<count-1 ; i++){
    if(i==q){
      printf("[%d] ",A[q]);
      continue;
    }
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  return 0;

}

Measured memory_bytes: 988
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
typedef long long LL;
LL n,p,ans=1;
int main(){
	scanf("%lld%lld",&n,&p);
	if(n==1) return 0*printf("%lld\n",p);
	for(LL i=2;i*i<=p;i++){
		if(p%i==0){
			int cnt=0;
			while(p%i==0) p/=i,cnt++;
			for(int j=1;j<=cnt/n;j++) ans*=i;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128