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

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    lint A;
    cin >> A;

    string B;
    cin >> B;
    int BB = (B[0] - '0') * 100 + (B[2] - '0') * 10 + B[3] - '0';

    cout << (A * BB / 100) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 3652
#include <stdio.h>

char solve(char b) {
  if (b == 'A') {
    return 'T';
  } else if (b == 'T') {
    return 'A';
  } else if (b == 'C') {
    return 'G';
  } else {
    return 'C';
  }
}

int main() {
  char b;
  scanf("%c", &b);

  printf("%c", solve(b));

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
//string b="12345";
//a = int(b[4]-48);
using namespace std;
int main()
{
	double H, A;
	cin >> H >> A;

	cout << ceil(H / A) << endl;

}

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

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

    vector<int> d(N);
    for(int i=0;i<N;i++) {
        cin >> d.at(i);
    }

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

    int ans;
    ans = d.at(N/2) - d.at(N/2-1);

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};

typedef struct node *Node;


Node root;

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

}

void inorder(Node u){
  if( u != NIL ){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  printf(" %d",u->key);
    
  if( u->left != NIL ) preorder(u->left);
  
  if( u->right != NIL ) preorder(u->right);
    

}

Node treeSearch(Node u, int k){
  while( u != NIL )
    {
      if( u->key == k ) break;
      if( u->key < k )
	u = u->right;
      else
	u = u->left;
    
    }
  
  return u;
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s",com);
 
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int

let B = Array.zeroCreate<int64> (N + 1)

A
|> Array.groupBy (fun n -> n)
|> Array.map (fun (k, v) ->
    B.[k] <- (v
              |> Array.length
              |> int64))
|> ignore

let sum =
    B
    |> Array.map (fun x -> x * (x - 1L) / 2L)
    |> Array.sum

[| 0..(N - 1) |]
|> Array.map (fun i -> sum - (B.[A.[i]] - 1L))
|> Array.iter (printfn "%d")

Measured memory_bytes: 65888
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
static const ULLONG UL_HUGE_DIVIDER = 1000000007LLU;
static const LLONG LL_HUGE_DIVIDER = 1000000007LL;

//static void ABC111D_RobotArms();
static void ABC105C_Base_2Number();

#if 1
int main()
{
	//ABC111D_RobotArms();
	ABC105C_Base_2Number();

	fflush(stdout);
	return 0;
}
#endif


static void ABC105C_Base_2Number()
{
	int N;
	scanf(" %d", &N);

	int i = 0;
	LLONG powVal[33] = { 0 };	//	2^32 = 1073741824
	powVal[0] = 1;
	for(i = 1; i <= 32; i++) {
		powVal[i] = powVal[i - 1] * -2;
	}

	std::string ans = "";
	if (N == 0) ans = "0";

	for (int i = 0; i < 32; i++) {
		if (N == 0) {
			break;
		}
		else if (N % powVal[i + 1]) {
			ans.insert(ans.begin(), '1');
			N -= powVal[i];
		}
		else {
			ans.insert(ans.begin(), '0');
		}
	}
	
	printf("%s\n", ans.c_str());
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <algorithm>
using namespace std;
int M[15][10005];
int r, c, ans;
void Dfs(int now){
    if(now == r){
        int res = 0;
        for(int i = 0; i < c; i++){
            int on = 0;
            for(int j = 0; j < r; j++)
                if(M[j][i] == 1) on++;
            res += max(on, r - on);
        }
        ans = max(ans, res);
        return ;
    }
    Dfs(now + 1);
    for(int i = 0; i < c; i++)
        M[now][i] = 1 - M[now][i];
    Dfs(now + 1);
}
int main(){
    while(~scanf("%d%d",&r, &c)){
        if(!r && !c) break;
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &M[i][j]);
        ans = 0; Dfs(0);
        printf("%d\n",ans);
    }

    return 0;
}


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

int main()
{
    int r,b,g;

    cin >> r >> b >> g;

    int x = (r*10+b)*10+g;

    if(x%4==0)
    {
        cout << "YES\n";
        return 0;
    }
    cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;
ll vis[1000005];
void solve()
{
	ll n, mx=-1;
	cin>>n;
	map<ll, ll> m;
	
	vector<ll> v(n, 0);for(int i=0;i<n;i++)cin>>v[i], m[v[i]]++, vis[v[i]]=1, mx=max(mx, v[i]);
	
	for(int i=0;i<n;i++)
	{
		for(int j=2*v[i];j<=mx;j+=v[i])vis[j]=0;
	}
	ll ans=0;
	for(auto it: m)if(it.S==1 && vis[it.F]==1)ans++;
	cout<<ans;
	
	
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}


Measured memory_bytes: 24032
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=5005;
const int mod =1e9+7;
int n,p[Maxn];
int par[Maxn],cy[Maxn],sz[Maxn];
int pw[Maxn];
int findset(int x){
	return par[x]=(par[x]==x)?x:findset(par[x]);
} 
void Union(int x,int y){
	x=findset(x);y=findset(y);
	if (x==y){
		cy[x]=1;
		return;
	}
	par[x]=y;
	sz[y]+=sz[x];
	if (cy[x]) cy[y]=1;
}
void Add(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
int dp[Maxn],fact[Maxn];
int main(){
	scanf("%d",&n);
	pw[0]=1;
	for (int i=1;i<=n;i++){
		pw[i]=1ll*pw[i-1]*(n-1)%mod;
	}
	fact[0]=1;
	for (int i=1;i<Maxn;i++){
		fact[i]=1ll*fact[i-1]*i%mod;
	}
	int k=0;
	for (int i=1;i<=n;i++) scanf("%d",&p[i]),k+=(p[i]==-1);
	for (int i=1;i<=n;i++) par[i]=i,sz[i]=1;
	for (int i=1;i<=n;i++){
		if (p[i]!=-1){
			Union(i,p[i]);
		}
	}
	vector<int> T;
	int ans=0;
	for (int i=1;i<=n;i++){
		if (findset(i)==i){
			if (cy[i]) {
				Add(ans,pw[k]);
			}
			else{
				T.pb(sz[i]);
			}
		}
	}
//	cout<<ans<<endl;
	dp[0]=1;
	for (int i=0;i<T.size();i++){
		for (int j=k;j>=1;j--){
			Add(dp[j],1ll*dp[j-1]*T[i]%mod);
		}
	}
	for (int i=2;i<=k;i++){
		int pre=1ll*fact[i-1]*pw[k-i]%mod;
		Add(ans,1ll*pre*dp[i]%mod);
	}
	for (int i=0;i<T.size();i++){
		int v=T[i];
		Add(ans,1ll*(v-1)*pw[k-1]%mod);
	}
//	cout<<ans<<endl;
	int res=1ll*n*pw[k]%mod;
	ans=res-ans;
	if (ans<0) ans+=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n, k;
	cin>>n>>k;
	long long a[n];
	for(long long i=0;i<n;i++){
		cin>>a[i];
	}sort(a,a+n);
	long long cost=0;
	for(long long i=0;i<k;i++){
		cost+=a[i];
	}cout<<cost<<endl;
	return 0;
}

Measured memory_bytes: 3596
n, y = map(int, input().split())

flug = 0
for i in range(n+1):
    value = y - i * 10000
    if flug == 1:
        break
    for second_value in range(n - i + 1):
        answer_value = value - second_value*5000 - (n-second_value-i)*1000
        if answer_value == 0:
            print(i, second_value, n-second_value-i)
            flug = 1
            break
else:
    if flug != 1:
        print("-1 -1 -1")


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 5010;
int p[N][N], s[N][N], n, k, a[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n >> k;
	For(i, 1, n + 1) cin >> a[i];

	Foz(i, k) p[0][i] = 0;
	For(i, 1, n) {
		Foz(z, k) {
			p[i][z] = p[i - 1][z];
			if (z - a[i] >= 0) ckmax(p[i][z], a[i] + p[i - 1][z - a[i]]);
		}
	}

	Foz(i, k) p[n + 1][i] = 0;
	Dor(i, 2, n + 1) {
		Foz(z, k) {
			s[i][z] = s[i + 1][z];
			if (z - a[i] >= 0) ckmax(s[i][z], a[i] + s[i + 1][z - a[i]]);
		}
	}

	int ans = 0;
	For(i, 1, n + 1) {
		int res = 0;
		Foz(x, k) ckmax(res, p[i - 1][x] + s[i + 1][k - 1 - x]);
		ans += (res < k - a[i]);
	}
	cout << ans << '\n';
}



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

using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int>h(n),a(q);
    h[0] = 0;
    for(int i = 0; i < n - 1; i++){
        if(i != 0){
            h[i+1] = h[i];
        } 
        if(s[i] == 'A' && s[i+1] == 'C'){
            h[i+1]++;
        }
    }




    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        a[i] = h[r-1] - h[l-1]; 
    }

   for(int i = 0; i < q; i++) cout << a[i] << endl;    


}

Measured memory_bytes: 1792
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	double N, K;
	double ans = 0;
	cin >> N >> K;
	vector<int> a(N + 1, 0);	//さいころの目ごとに勝つまでに振る回数を格納
	for (double i = 1; i < N + 1; i = i + 1)	//1から順番に回数を求める
	{
		double k = K;

		if (i >= k)
		{
			a[i] = 0;
		}

		for (int j = 1; k > i; j++)	//jは降る回数
		{
			k = k / 2;
			if (i >= k) a[i] = j;
		}
	}

	double bunsi = 0;
	for (int i = 1; i < N + 1; i++)
	{
		double tmp = a[1] - a[i];
		bunsi += pow(2, tmp);
	}

	ans = bunsi / (N * pow(2, a[1]));

	//cout << ans;

	printf("%1.12f", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    static int[] a;
    static void sosu(int MAX){
        a = new int[MAX+1];
 
        a[2] = 1;
        for(int i=3;i<=MAX;i+=2){
            a[i] = 1;
        }
        int b = (int) Math.sqrt(MAX);
        for(int i=3;i<=b;i+=2){
            if(a[i] == 1){
                for(int j=i*i;j<=MAX;j+=i){
                    a[j] = -1;
                }
            }
        }
    }
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        while(true){
        	int count = 0;
            int N = stdIn.nextInt();
            int P = stdIn.nextInt();
            if(N==-1&&P==-1){
                return;
            }
            sosu(N+1000);
            int[] sosu = new int[50];
            int idx = N+1;
            int z = 0;
            for(int i=idx;z<sosu.length;i++){
                if(a[i] == 1){
                    sosu[z++] = i;
                }
            }
            z = 0;
            int[] wasosu = new int[1000];
            for(int i=0;i<sosu.length;i++){
                for(int j=i;j<sosu.length;j++){
                    wasosu[z++] = sosu[i] + sosu[j];
                    if(z==1000){
                    	count = 1;
                        break;
                    }
                }
                if(count == 1)break;
            }
            Arrays.sort(wasosu);
            System.out.println(wasosu[P-1]);
        }
    }
}

Measured memory_bytes: 99636
#-------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------

from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[j - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] =  j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else '0' * (length - len(y)) + y

def solve(N, A):
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if A[i] != A[j] and A[i] != A[k] and A[j] != A[k] and A[i] + A[j] > A[k] and A[i] + A[k] > A[j] and A[k] + A[j] > A[i]:
                    #print(A[i], A[j], A[k])
                    ans += 1
    return ans

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

print(solve(N, A))


Measured memory_bytes: 68020
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

double a, b, x;

bool cond(double mid){
    mid = 90.0 - mid;
    mid = mid * PI /180.0;
    double taka = tan(mid) * b;
    if(taka <= a){
        return taka * b / 2.0 >= x;
    }else{
        return taka * b /2.0 / (taka * taka) * (taka * taka - (taka - a) * (taka - a)) >= x;
    }
}

int main(){
    cin >> a >> b >> x;
    x /= a;
    double l = 0.0, r = 90.0;
    REP(ttt, 30){
        double mid = (l + r)/2;
        if(cond(mid))l = mid;
        else r = mid;
    }
    cout << fixed << setprecision(13) << l << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    int N;
    cin >> N;

    vector<int> h(N);
    rep (i, N) {
        cin >> h[i]; } // dp table
    vector<int> dp(100100, INF);

    // init dp table

    // init condition
    dp[0] = 0;

    // loop
    for (int i = 1; i < N; i++) {
        if (i == 1) {
            dp[i] = abs(h[i] - h[i-1]);
        } else { 
            dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1])); 
        } 
    } 

    cout << dp[N-1] << endl; 
    return 0; 
}

Measured memory_bytes: 1024
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt

fun main() {
    val (a, b, h, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val hRad = PI * (h + m / 60.0) / 6
    val mRad = PI * m / 30
    val hx = sin(hRad) * a
    val hy = cos(hRad) * a
    val mx = sin(mRad) * b
    val my = cos(mRad) * b
    println("%.15f".format(sqrt((hx - mx).let{it * it} + (hy - my).let{it * it})))
}

Measured memory_bytes: 37688
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    let n = parseInt(lines[0]) % 10;
    if (n === 2 || n === 4 || n === 5 || n === 7 || n === 9){
        console.log("hon");
    } else if (n === 0 || n === 1 || n === 6 || n === 8){
        console.log("pon");
    }
    else {
        console.log("bon");
    }
});

Measured memory_bytes: 30068
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N; i++)
			L[i] = sc.nextInt();
		Arrays.sort(L);
		int s = 0;
		for (int i = 0; i < N - 1; i++)
			s += L[i];
		if (L[N - 1] < s)
			System.out.println("Yes");
		else
			System.out.println("No");

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007

#A

#B

#C
n = II()
a = LI()
print(sum(a)-n)
#D
"""
s = list(S())
lis = []
sign = ["","+"]
k = 2**(len(s)-1)
d = 10-len(s)
for i in range(d):
    s.insert(0,"0")
i = 0
for a0 in range(2):
    for a1 in range(2):
        for a2 in range(2):
            for a3 in range(2):
                for a4 in range(2):
                    for a5 in range(2):
                        for a6 in range(2):
                            for a7 in range(2):
                                for a8 in range(2):
                                    if i >= k:break
                                    lis.append(s[0]+sign[a0]+s[1]+sign[a1]+s[2]+sign[a2]+s[3]+sign[a3]+s[4]+sign[a4]+s[5]+sign[a5]+s[6]+sign[a6]+s[7]+sign[a7]+s[8]+sign[a8]+s[9])
                                    i += 1
ans = 0
for i in lis:
    ans += eval(i[d:])
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 40816
void main() {
  problem();
}

void problem() {
  auto N = scan!ulong;

  ulong solve() {
    auto primes = primeFactoring(N);

    int[ulong] primeCounts;
    foreach(p; primes) {
      primeCounts[p]++;
    }

    ulong answer;
    foreach(p; primeCounts.keys) {
      const count = primeCounts[p];

      int sumCount;
      foreach(i; 1..count+1) {
        sumCount += i;
        if (sumCount > count) break;

        answer++;
      }
    }

    return answer;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

ulong[] primeFactoring(ulong target)
{
  ulong s = target.to!float.sqrt().floor.to!ulong;
  ulong num = target;
  ulong[] primes;
	for (ulong i = 2; i <= s; i++) {
    if (num % i != 0) continue;

		while (num%i == 0) {
      num /= i;
      primes ~= i;
    }
	}
  if (num > s) primes ~= num;
	return primes;
}

// -----------------------------------------------


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n],dp[n];
    for(int i=0;i<n;i++)cin>>h[i];
    dp[0] = 0;
    for(int i=1;i<n;i++){
        dp[i] = INT_MAX;
        for(int j=max(0,i-k);j<i;j++){
            dp[i] = min(dp[i],dp[j]+abs(h[i] - h[j]));
        }
    }   
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	int n;
	cin >> n;
	
	vector<string> s(n);
	map<string, int> mp;
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
		mp[s[i]]++;
	}
	
	int max = 0;
	for(auto& x : mp) {
		if( max < x.second ) max = x.second;
	}
	
	for(auto& x : mp) {
		if( max == x.second ) cout << x.first << endl;
	}
	
	return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
  vector<ll> dp(N);
  vector<ll> cnt(3);
  if(A[0]!=0){
    cout<<0<<endl;
    return;
  }
  dp[0]=3;
  ++cnt[0];
  FOR(i,1,N){
    ll j=0,tmp=0,k=0;
    for (; j < 3; j++)
    {
      if(A[i]==cnt[j]){
        tmp=j;
        ++k;
      }
    }
    if(k==0){
      dump(i);
      dump(cnt);
      cout<<0<<endl;
      return;
    }
    ++cnt[tmp];
    dp[i]=dp[i-1]*k%MOD;
  }
  cout<<dp[N-1]<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n=int(input())
	P=list(map(int,input().split()))
	
	a=P[0]
	
	ans=0
	
	for i in P:
		if i<=a:
			ans+=1
			a=i
	
	print(ans)
	
	
	
	
	


if __name__ == "__main__":
	main()


Measured memory_bytes: 69488
import java.util.*;
import java.text.DecimalFormat;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		Random rn = new Random();
		DecimalFormat df = new DecimalFormat("#,###.##");

		int N = sc.nextInt();
		int K = sc.nextInt();
		int counter = 0, hi = 0;

		for(int i = 1; i <= N; i++)
		{
			hi = sc.nextInt();
			if (hi >= K)
				counter++;
		}

		System.out.println(counter);
	}
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

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

	if (H==1||W==1) {
		ce(1)
			return 0;
	}

	if (H%2==0) {
		ce(H*W/2)
	}
	else {
		if (W%2==0) {
			ce((H/2)*W+W/2)
		}
		else {
			ce((H / 2) * W + W / 2+1)
		}
	}



    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        
        double x = Double.parseDouble(line1);
        
        long yokin = 100;
        int count = 0;
        while(yokin < x)
        {
            yokin = yokin + (long)(yokin * 0.01);
            count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


lint D;
lint decrease[26];
lint satis[365][26];
lint prv[26];

lint downscore(lint passed) {
	lint sum = 0;
	REP(i, 26) {
		sum += decrease[i] * (passed - prv[i]);
	}
	return -sum;
}

signed main() {
	cin >> D;
	REP(i, 26) {
		cin >> decrease[i];
	}
	REP(i, D) {
		REP(j, 26) {
			cin >> satis[i][j];
		}
	}

	REP(i, D) {
		lint maxv = -INF, max_idx = 0;
		REP(s, 26) {
			lint inst = 0;
			inst += satis[i][s];
			inst += downscore(i + 1);
			chmax(inst, 0ll);
			if (maxv < inst) {
				maxv = inst;
				max_idx = s;
			}
		}
		prv[max_idx] = i + 1;
		cout << max_idx + 1;
		if (i != D - 1) cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3700
n = int(input())
s = input()
R_ls = [0] * n
G_ls = [0] * n
B_ls = [0] * n
R_csum = [0] * n
G_csum = [0] * n
B_csum = [0] * n
for i in range(n):
    if s[i] == 'R':
        R_ls[i] = 1
        R_csum[i] = R_csum[i-1] + 1
        G_csum[i] = G_csum[i-1]
        B_csum[i] = B_csum[i-1]
    elif s[i] == 'G':
        G_ls[i] = 1
        G_csum[i] = G_csum[i-1] + 1
        R_csum[i] = R_csum[i-1]
        B_csum[i] = B_csum[i-1]
    else:
        B_ls[i] = 1
        B_csum[i] = B_csum[i-1] + 1
        R_csum[i] = R_csum[i-1]
        G_csum[i] = G_csum[i-1]
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if (s[i] == 'R' and s[j] == 'G') or (s[i] == 'G' and s[j] == 'R'):
            now = B_csum[-1] - B_csum[j]
            if j + (j-i) < n and s[2*j-i] == 'B':
                now -= 1
        elif (s[i] == 'R' and s[j] == 'B') or (s[i] == 'B' and s[j] == 'R'):
            now = G_csum[-1] - G_csum[j]
            if j + (j-i) < n and s[2*j-i] == 'G':
                now -= 1
        elif (s[i] == 'G' and s[j] == 'B') or (s[i] == 'B' and s[j] == 'G'):
            now = R_csum[-1] - R_csum[j]
            if j + (j-i) < n and s[2*j-i] == 'R':
                now -= 1
        else:
            now = 0
        ans += now
print(ans)




Measured memory_bytes: 74452
n = int(input())
a = list(map(int,input().split()))
m = sum(a)
if n > 0 and a[0] != 0:
    print(-1)
    exit()
if m > pow(2,n+1) - 1:
    print(-1)
    exit()
if n == 1:
    print(a[1]+1)
    exit()
l = 1
ans = 1
for i in range(n):
    x = a[i+1]
    if x > l*2:
        print(-1)
        exit()

    if m >= l*2:
        ans += l * 2
        l *= 2
    else:
        ans += m
        l = m
        #gr = False
    if x > 0:
        m -= x
        l -= x
        if m < 0:
            print(-1)
            exit()
print(ans)



Measured memory_bytes: 20140
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 100000

int n;
vector<int> e[MAX];
vector<bool> v(MAX, false);

void dfs(int s){
	v[s]=true;
	for(int i=0; i<e[s].size(); i++){
		if(!v[e[s][i]]) dfs(e[s][i]);
	}
	return;
}

int main(){
	int m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}

	int cnt=0;
	for(int i=0; i<n; i++){
		if(!v[i]){
			dfs(i);
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 8832
N, M = map(int, input().split())
#p = []
#S = []
AC = [0]*N
WA = [0]*N
for i in range(M):
  pp, SS = input().split()
  #p.append(int(pp))
  #S.append(SS)
  
  if SS == "AC" and AC[int(pp)-1] == 0:
    AC[int(pp)-1] += 1
  elif SS == "WA" and AC[int(pp)-1] == 0:
    WA[int(pp)-1] += 1
    
for i in range(N):
  if AC[i] == 0:
    WA[i] = 0
    
print(sum(AC), sum(WA))
#print(p, S)

Measured memory_bytes: 4596
#include<stdio.h>
int X, A, B, a, b;
char c;
int main(){
  scanf("%d%d%d", &X, &A, &B);
  a = X>A?X-A:A-X;
  b = X>B?X-B:B-X;
  c = a>b?'B':'A';
  printf("%c\n", c);
}


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

int main(){
  
  for(int i=0;i<4;i++){
    int a,b;
    cin>>a>>b;
    if(a==1){
      cout<<6000*b<<endl;
    }else if(a==2){
      cout<<4000*b<<endl;
    }else if(a==3){
      cout<<3000*b<<endl;
    }else{
      cout<<2000*b<<endl;
      }
    
  }
  return 0;
}
  

    
  
  
	



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll n, k;
	cin >> n >> k;
	cout << min(n % k, k - (n % k)) << endl;
}


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


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

int n;
cin>>n;
int h[n];int ans[n]={};
for(int i=0;i<n;i++)
{
    cin>>h[i];
}
ans[0]=0;
ans[1]=abs(h[1]-h[0]);
if(n==2)
    cout<<ans[1];
else
{
    for(int i=2;i<n;i++)
    {
        ans[i] = min(ans[i-1] + abs(h[i]-h[i-1]),ans[i-2]+ abs(h[i]-h[i-2]));
    }
    cout<<ans[n-1];
}
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int height[10],i;
int compar(const int *val1, const int *val2);
int main()
{
    for(i=0;i<10;i++)
    {
        scanf("%d",&height[i]);
    }
    qsort(height,10,sizeof(int),(int (*)(const void *, const void *))compar);
    printf("%d\n%d\n%d\n",height[9],height[8],height[7]);
    return 0;
}

int compar(const int *val1, const int *val2)
{
    if( *val1 < *val2 ) return -1;
    else if( *val1 == *val2 ) return 0;
    else return 1;
}

Measured memory_bytes: 604
c = {'I'=> 1, 'V'=> 5, 'X'=>10, 'L'=>50, 'C'=>100, 'D'=>500, 'M'=>1000}
c.default = 0
readlines.each do |l|
  puts l.chars.each_cons(2).inject(0){|sum,(i,j)|
    c[i] < c[j] ? sum-c[i] : sum+c[i]
  }
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    ll n;
    cin>>n;
    ll ans=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ind = s.IndexOf("YAKI");
            Console.WriteLine(ind == 0 ? "Yes" : "No");
        }
    }
}


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

int main() {
 int n;
  cin>>n;
  set<int> st;
  rep(i, n){int a;
            cin>>a;
            st.insert(a);}
  cout<<st.size()<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;

	if (A < B) co(0);
	else co(10);


	Would you please return 0;
}

Measured memory_bytes: 892
n, a, b = gets.chomp.split(" ").map(&:to_i)
h = []
n.times { h << gets.chomp.to_i }

h_max = (h.max.to_f / b).ceil


l = 1
r = h_max

def check(h, t, a, b)
    count = 0
    h.each do |v|
        v -= t * b
        count += (v.to_f / (a-b)).ceil if v > 0    
    end
    return count <= t
end

while(l < r)
    m = (l + r) / 2
#    print "#{l} #{r} #{m}\n"

    if check(h, m, a, b)
#        print "true\n"
        r = m
    else
#        print "false\n"
        l = m + 1
    end
end

puts l



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

int main() {
	int N, L;
	vector<int> a;
	cin >> N >> L;
	a.resize(N);
	for(int i = 0; i < N; i++) cin >> a[i];

	int idx = -1;
	for(int i = 0; i < N-1; i++)
		if(a[i] + a[i+1] >= L) {
			idx = i;
		}

	if(idx < 0) {
		cout << "Impossible" << endl;
		return 0;
	}

	cout << "Possible" << endl;
	for(int i = 0; i < idx; i++) {
		cout << i+1 << endl;
	}
	for(int i = N-2; i >= idx; i--) {
		cout << i+1 << endl;
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ma, mi, t;
	cin>>n;
	cin>>ma;
	mi = ma;
	for(int i=1;i<n;i++){
		cin>>t;
		ma = max(ma, t);
		mi = min(mi, t);
	}
	cout<<abs(ma-mi)<<endl;
	return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var A = input[1];
            var B = input[2];
            var ans = 0;

            for (int i = 1; i <= input[0]; i++)
            {
                var sum = 0;
                var rem = i;
                do
                {
                    sum += rem % 10;
                    rem = rem / 10;
                } while (rem > 0);
                if (sum >= A && sum <= B) ans += i;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d))
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final int r;
        final int c;
        final int[][] ints;
        try (Scanner scanner = new Scanner(System.in)) {
            r = scanner.nextInt();
            c = scanner.nextInt();
            ints = new int[r + 1][c + 1];
            for (int i = 0; i < r; i++) {
                for (int j = 0; j < c; j++) {
                    ints[i][j] = scanner.nextInt();
                    ints[i][c] += ints[i][j];
                    ints[r][j] += ints[i][j];
                    ints[r][c] += ints[i][j];
                }
            }
        }
        Arrays
                .stream(ints)
                .map(Main::toStringList)
                .map(it -> String.join(" ", it))
                .forEach(System.out::println);
    }

    private static List<String> toStringList(int[] intArray) {
        return Arrays.stream(intArray).mapToObj(String::valueOf).collect(Collectors.toList());
    }
}

Measured memory_bytes: 44900
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  set<int> s;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin>>a;
    s.insert(a);
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 256