akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 700;
  for (auto& e : s) {
    if (e == 'o')
      ans += 100;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	if n == 1 {
		fmt.Println(1)
	} else if n%2 == 0 {
		fmt.Println(0.5)
	} else {
		fmt.Println(((float64(n) + 1) / 2) / float64(n))
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
int main() { 
    fastIO;
     int t=1,n,k;
     //cin>>t;
     while(t--){
         cin>>n>>k;
       vector<int>a(n,0 );
       vector<int>dp(k+1,0);
        
        
        
       fr(i,1,n+1){ 
       cin>>a[i];}
       for(int i=k;i>=0;i--){
          fr(j,1,n+1){
             
            if(  (i+a[j])<=k && !dp[i+a[j]] )
            {  dp[i]=1;}}
          
        }
       if(dp[0])
         cout<<"First"<<endl;
       else
         cout<<"Second"<<endl;
         }
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll n,d;
ll Main() {
    cin >> n >> d;
    vl x(n);
    vl y(n);
    rep(i,n) {
        cin >> x[i];
        cin >> y[i];
    }

    ll cnt = 0;
    
    rep(i,n) {
        double dis = sqrt(x[i]*x[i]+ y[i]*y[i]);
//        cout << dis << " ";
        if(dis <= d) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main()
{
  string a;
  cin >> a;
  int n=a.length();
  int cntp=0, cntg=0, ans=0;
  for(int i=0;i<n;i++){
    if(cntp==cntg){
      if(a[i]=='g'){
	cntg+=1;
      }
      if(a[i]=='p'){
        cntg+=1;
	ans-=1;
      }
    }else{
      if(a[i]=='g'){
        cntp+=1;
	ans+=1;
      }
      if(a[i]=='p'){
        cntp+=1;
      }
    }
  }

  cout<< ans <<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<map>
#include<queue>
#include<iostream>
#include<cctype>
#include<cmath>
using namespace std;
#define int __int128
inline int gi(){short tmp=getchar();int flag=1;while(!isdigit(tmp)){if(tmp=='-'){flag=-1;tmp=getchar();break;}tmp=getchar();}int ans=0;while(isdigit(tmp)) {ans=(ans<<3)+(ans<<1)+tmp-'0';tmp=getchar();}return ans*flag;}
inline void write(int x){static int stk[100], top = 0;if (x == 0) { putchar('0'); putchar(' ');return; }if (x < 0) { x = -x; putchar('-'); }while (x) { stk[++top] = x % 10; x /= 10; }while (top) { putchar(stk[top--] + '0'); }putchar(' ');}
#define line() putchar('\n');
#define Mem(Arr,V) memset(Arr,V,sizeof Arr);
#define Mcpy(Arr,qwq) memcpy(Arr,qwq,sizeof qwq);
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max4(max3(a,b,c),d);
#define in(a) a=gi()
#define in2(a,b) in(a),in(b)
#define in3(a,b,c) in2(a,b),in(c)
#define in4(a,b,c,d) in3(a,b,c),in(d)
#define write2(a,b) write(a),write(b)
#define write3(a,b,c) write2(a,b),write(c)
#define write4(a,b,c,d) write3(a,b,c),write(d)
inline void smin(int &x,int y){x=min(x,y);}
inline void smax(int &x,int y){x=max(x,y);}
const int inf = 8000000;
const int Mod = 1e9+7;
inline int Pow(int b,int p,int k){int ans=1;while(p){if(p&1){ans=ans*b%k;}b=b*b%k;p>>=1;}return ans;}
inline int Inv(int a){return (Pow(a,Mod-2,Mod));}
const int N = 2000000;
int Fac[N];
inline void Prepare()
{
	Fac[0]=1;
	for(int i=1;i<=1000000;++i)
		Fac[i]=i*Fac[i-1]%Mod;	
}
inline int C(int n,int m)
{

	return Fac[n]*Inv(Fac[n-m]*Fac[m])%Mod;
}
signed main()
{
	int n,k;
	in2(n,k);
	Prepare();
	if(n<=k)
	{
		write(C(n+n-1,n-1));
	}
	else 
	{
		int all=C(n+n-1,n-1);
		for(int i=1;i<n-k;++i)
		{
			all-=C(n,i)*C(n-1,i-1)%Mod;
			all=(all%Mod+Mod)%Mod;	
		}
		write(all);
	}
	return 0;
}

Measured memory_bytes: 16640
package main

import "fmt"

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var (
	n         int
	visited   map[int]struct{}
	connected [][]bool
)

func dfs(now int) {
	if _, in := visited[now]; in || now == n {
		return
	}
	visited[now] = struct{}{}

	for next := range make([]struct{}, n) {
		if connected[min(now, next)][max(now, next)] {
			dfs(next)
		}
	}

}

func main() {
	n = nextInt()
	m := nextInt()
	connected = make([][]bool, n)
	for i := range connected {
		connected[i] = make([]bool, n)
	}
	for range make([]struct{}, m) {
		a := nextInt() - 1
		b := nextInt() - 1
		connected[min(a, b)][max(a, b)] = true
	}
	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if connected[i][j] {
				connected[i][j] = false
				visited = map[int]struct{}{}
				dfs(0)
				if len(visited) < n {
					ans++
				}
				connected[i][j] = true
			}
		}
	}
	fmt.Println(ans)
}


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

int main()
{
    ull A,B,C,D;
    cin >> A >> B >> C >> D;
    
    ull Cnum = B / C - A / C;
    if(A % C == 0)Cnum++;

    ull Dnum = B / D - A / D;
    if(A % D == 0)Dnum++;
    
    ull r = D % C;
    ull Ctmp = C;
    ull Dtmp = D;
    while(r > 0)
    {
        Dtmp = Ctmp;
        Ctmp = r;
        r = Dtmp % Ctmp;
    }

    ull CD = D / Ctmp * C;
    ull CDnum = B / CD - A / CD;
    if(A % CD == 0)CDnum++;

    cout << B - A + 1 - (Cnum + Dnum - CDnum) << endl;
    return 0;
}

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

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

	string A, B;
	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		int nl, ml;
		nl = A.size();
		ml = B.size();
		string a, b;
		if (nl >= ml) {
			a = A;
			b = B;
		}
		else {
			a = B;
			b = A;
		}
		//cout << "a:" << a << ' ' << "b:" << b << endl;

		int f = 0, of = 0;
		int as = a.size(),
			bs = b.size();
		int AL = as;
		as--;
		bs--;
		while (1) {
			int n = (int)a.at(as) - '0',
				m = (int)b.at(bs) - '0';
			as--;
			bs--;
			//cout << n << ' ' << m << endl;

			int r = n + m;
			if (f) {
				r++;
				f = 0;
			}
			a.at(as + 1) = (char)r%10 + 48;

			if (r > 9) {
				f = 1;

				if (as < 0 && bs < 0) {
					of = 1;
					AL++;
					break;
				}
				else if (as >= 0 && bs < 0) {
					for (int j = as; j >= 0; j--) {
						int n2 = (int)a.at(j) - '0';
						if (f) {
							n2++;
							f = 0;
						}
						a.at(j) = (char)n2 % 10 + 48;
						
						if (n2 > 9) {
							f = 1;
							if (!j) {
								of = 1;
								AL++;
								break;
							}
						}
					}
				}
			}

			if (bs < 0) break;
		}

		if (AL > 80) {
			cout << "overflow" << endl;
		}
		else {
			if (of) cout << 1;
			cout << a << endl;
		}
	}
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    double t, x;
    cin >> t >> x;
    double ans;
    ans = t / x;
    printf("%lf\n", ans);
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

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

	int a, b, k;
	cin >> a >> b >> k;

	set<int> se;
	for (int i = a, cnt = 0; i < b; i++, cnt++) {
		if (cnt == k) {
			break;
		}

		se.emplace(i);
	}

	for (int i = b, cnt = 0; i >= a; i--, cnt++) {
		if (cnt == k) {
			break;
		}

		se.emplace(i);
	}

	for (auto v : se) {
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(2e5);

int N;
vv<int> tree;
vector<int> subt;
vector<ll> dp, ans;

void dfs_pre(int v, int p) {
    subt[v] = 1;
    dp[v] = 1;

    if (p != -1 && tree[v].size() == 1) {
        return;
    }

    for (int u : tree[v]) {
        if (u == p) continue;
        dfs_pre(u, v);
        subt[v] += subt[u];
    }
    int csum = 0;
    for (int u : tree[v]) {
        if (u == p) continue;
        dp[v] = dp[v] * dp[u] % MOD * C(subt[v] - 1 - csum, subt[u]) % MOD;
        csum += subt[u];
    }
}

void dfs(int v, int p, int k) {
    if (p == -1) {
        ans[v] = dp[v];
        for (int u : tree[v]) {
            dfs(u, v, ans[v] * mpow(C(N - 1, subt[u]) * dp[u] % MOD, MOD - 2) % MOD);
        }
    }
    else {
        ans[v] = dp[v] * C(N - 1, N - subt[v]) % MOD * k % MOD;
        for (int u : tree[v]) {
            if (u == p) continue;
            dfs(u, v, ans[v] * mpow(C(N - 1, subt[u]) * dp[u] % MOD, MOD - 2) % MOD);
        }
    }
}

int main() {
    cin >> N;
    tree.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    subt.resize(N);
    dp.resize(N);
    ans.resize(N);
    dfs_pre(0, -1);
    dfs(0, -1, -1);
    for (ll x : ans) write(x);
}

Measured memory_bytes: 20980
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int A; cin >> A;
    cout << "Christmas";

    int ch = 25;
    ch -= A;
    FOR(i, 0, ch){
        cout <<  " Eve";
    }

    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum += x[i];
    }

    int ans1 = sum / n;
    int ans2 = sum / n + 1;

    int sum_sq1 = 0;
    int sum_sq2 = 0;
    for (int i = 0; i < n; i++) {
        sum_sq1 += (x[i] - ans1) * (x[i] - ans1);
        sum_sq2 += (x[i] - ans2) * (x[i] - ans2);
    }

    cout << min(sum_sq1, sum_sq2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream> 
using namespace std;
int main()
{
	unsigned long N;
	int k,t=1;
	cin>>N>>k;
	while(N/k)
	{
		t++;
		N/=k;
		
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
A=int(input())
listB=list(map(int,input().split()))
ans=deque()
for i in range(1,A+1):
    if (A-i+1)%2==1:
        ans.appendleft(listB[i-1])
    else:
        ans.append(listB[i-1])
ans = list(map(str,ans))
print(" ".join(ans))

Measured memory_bytes: 32964
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
		int b = 0, ans = 0;

		for(int i=0; i<t; i++){
			int a = sc.nextInt();
			if(a>k/2) b = a;
		}

		if(b!=0) ans = (b - k/2)*2 - 1;
		if(k%2==1 && b==(k+1)/2) ans = 0;

		System.out.println(ans);
	}
}

Measured memory_bytes: 9684
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b,s=0,t=0;
	cin >> a >> b;
	for (int i = 0; i < b;i++) {
		s += a * pow(10, i);
	}
	for (int i = 0; i < a; i++) {
		t += b * pow(10, i);
	}
	if (a<b) {
		cout << s << endl;
	}
	else {
		cout << t << endl;
	}
}

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

dp=[100000000000]*N

dp[0]=0
i=1
def chmin(a,b):
    if a>b:
        dp[i]=b

while i < N :
    chmin(dp[i],abs(H[i]-H[i-1])+dp[i-1])
    if i>1:
        chmin(dp[i],abs(H[i]-H[i-2])+dp[i-2])
    i+=1

print(dp[N-1])        


Measured memory_bytes: 13976
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>
#define ll long long int
#define l long int
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
    int a,b,i,j,ara[10000];
    long long int s=0,m,n;
    cin>>a>>b;
    for(i=0;i<b;i++)
    {
        cin>>ara[i];
        s=s+ara[i];
    }
    if(s<=a)
    {
        m=a-s;
        cout<<m<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3672
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

v = 0
for d in range(D):
  av = s[d] - sum( c*(d-last) ) + c*(d-last) 
  m = max(av)
  for t in range(26):
    if av[t] == m:
      last[t] = d
      v += av[t]
      print(t+1)
      break
#


Measured memory_bytes: 27156
from collections import deque
from collections import Counter
N, M, K = map(int, input().split())
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
C = [0]*K
D = [0]*K
for i in range(K):
    C[i], D[i] = map(int,input().split())

friend = {i: set([]) for i in range(1, N+1)}
brock = {i: set([]) for i in range(1, N+1)}
for i in range(M):
    friend[A[i]].add(B[i])
    friend[B[i]].add(A[i])
for i in range(K):
    brock[C[i]].add(D[i])
    brock[D[i]].add(C[i])

labels = [0] * (N+1)


def mark(n, label):
    if labels[n] != 0:
        return -1
    else:
        q = deque()
        q.append(n)
        labels[n] = label
        while q != deque():
            node = q.pop()
            labels[node] = label
            for i in friend[node]:
                if labels[i] == 0:
                    q.append(i)
        return label


label = 1
for n in range(1, N + 1):
    if mark(n, label) != -1:
        label += 1

group_size = Counter(labels)

res = [0] * N
for n in range(1, N + 1):
    tmp = 0
    for b in brock[n]:
        if labels[n] == labels[b]:
            tmp += 1
    res[n - 1] = group_size[labels[n]] - 1 - len(friend[n]) - tmp

print(*res)

Measured memory_bytes: 123732
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<iostream>

using namespace std;

int read(){
	char c=getchar();int x=0,f=1;
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	return x*f;
}
int n,m;
char a[60][60];
int mv[2][8]={
	{1,1,-1,-1,0,0,1,-1},
	{-1,1,1,-1,1,-1,0,0}
};
int main(){
	n=read();
	m=read();
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'){
				printf("#");
				continue;
			}
			int cnt=0;
			for(int k=0;k<8;k++){
				int nx=i+mv[0][k];
				int ny=j+mv[1][k];
				if(nx<1||ny<1||nx>n||ny>m);
				if(a[nx][ny]=='#')cnt++;
			}
			printf("%d",cnt);
		}
		printf("\n");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int H,W;
    cin >> H >> W;
    vector<string> V(H + 2);
    rep(i,H + 2) {
        if (i == 0 || i == H + 1) {
            string s = ".";
            rep(j,W + 1) {
                s += ".";
            }
            V[i] == s;
        }
        else {
            string t = ".";
            string u;
            cin >> u;
            string v = t + u + t;
            V[i] = v;
        }
    }
    rep2(j,1,H + 1) {
        rep2(k,1,W + 1) {
            if (V[j][k] == '.') {
                int count = 0;
                if (V[j][k + 1] == '#') {count++;}
                if (V[j][k - 1] == '#') {count++;}
                if (V[j + 1][k] == '#') {count++;}
                if (V[j - 1][k] == '#') {count++;}
                if (V[j + 1][k + 1] == '#') {count++;}
                if (V[j - 1][k + 1] == '#') {count++;}
                if (V[j + 1][k - 1] == '#') {count++;}
                if (V[j - 1][k - 1] == '#') {count++;}
                cout << count;
            }
            else {cout << '#';}
        }
        cout << endl;
    }
}



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

int main() {
  int N, A;
  cin >> N;
  cin >> A;
  int amari = N % 500;
  if (amari > A) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
typedef unsigned long long ll;
using namespace std;
int main()
{
	ll H, sum = 0, p = 1; cin >> H;
  	while(p <= H) {
    	sum += p;
      	p *= 2;
    }
  	cout << sum << endl;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.l();
  var u = [0,2,5,5,4,5,6,3,7,6];
  var v = [];
  a.sort((a,b)=>b-a);
  for(var i = 0; i < m; i++){
    v[i] = u[a[i]];
  }
  var ans = [""];
  for(i = 1; i <= n; i++){
    for(var j = 0; j < m; j++){
      var t = i - v[j];
      if(t >= 0 && ans[t] !== undefined){
        if(ans[i] === undefined)ans[i] = "";
        var l = ans[i].length;
        if(l <= ans[t].length){
          ans[i] = ans[t] + a[j];
        }
      }
    }
  }
  ans = ans[n].split("");
  ans.sort((a,b)=>b-a);
  return ans.join("");
}

Measured memory_bytes: 9420
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let n: i32 = buf.trim().parse().unwrap();

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let iter = buf.trim().split_whitespace();
    let difficulty: Vec<i32> = iter.map(|iter| iter.parse::<i32>().unwrap()).collect();

    println!("{}", solve(n, difficulty));
}

fn solve(n: i32, mut difficulty: Vec<i32>) -> i32{
    difficulty.sort();
    let mid = (n / 2 - 1) as usize;
    difficulty[mid + 1] - difficulty[mid]
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+')cnt++;
    else if(S.at(i)=='-')cnt--;
  }
  cout<<cnt<<endl;
}

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

#define P pair<int, int>
const int MAX_U = 1e5;

int main() {
    int n;
    cin >> n;
    vector<P> num_e(MAX_U + 5), num_o(MAX_U + 5);
    for (int i = 0, u; i < n; i++) {
        cin >> u;
        if (i & 1) {
            num_o[u].first++;
            num_o[u].second = u;
        } else {
            num_e[u].first++;
            num_e[u].second = u;
        }
    }
    sort(num_o.begin(), num_o.end(), greater<P>());
    sort(num_e.begin(), num_e.end(), greater<P>());
    ll ans = 0;
    if (num_o[0].second == num_e[0].second) {
        ans = min(n - (num_o[0].first + num_e[1].first), n - (num_o[1].first + num_e[0].first));
    } else ans = n - (num_o[0].first + num_e[0].first);
    cout << ans << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string s;
    cin >> s;
    int n = (int)s.size();

    int i = 0;
    int ans = 0;
    int cnt = 0;
    while(i < n){
        char tmp = s[i];
        while(i < n && s[i] == tmp){
            i++;
        }
        cnt++;
    }
    cout << --cnt << endl;

    return 0;
}


Measured memory_bytes: 1144
x,k,d = map(int,input().split())
n = (-x+k*d)//(2*d)
cur = float('inf')
if n < 0:
    print(abs(x-k*d))
else:
    if n == 0:
        L = [0,1]
    else:
        if n >= k:
            L = [k-1,k]
        else:
            L = [n-1,n,n+1]
    for i in range(len(L)):
        cur = min(cur, abs(x+L[i]*d-(k-L[i])*d))
    print(cur)


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

int gcd(int m, int n) {
  if (n == 0)
    return m;
  return gcd(n, m % n);
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  int n = gcd(A, B);

  int cnt = 0;
  for (int i = n; i > 0; i--) {
    if (A % i == 0 && B % i == 0)
      cnt++;
    if (cnt == K) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int r,d,x;
  cin>>r>>d>>x;
  rep(i,10){
    int nx=r*x-d;
    cout<<nx<<endl;
    x=nx;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[105],sum;
bool px(int x,int y)
{
	return x>y;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1,px);
    for(int i=1;i<=k;i++)
    {
    	sum+=a[i];
	} 
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<pair<string,int>,int> t[110];
int main(){
  int N;
  cin>>N;
  
  for(int i=0;i<N;i++){
    int score;
    string name;
    cin>>name>>score;
    t[i]=make_pair(make_pair(name,score*(-1)),i+1);
  }
  //sort(t.begin(),t.end());
  std::sort(t,t+N);
  for(int i=0;i<N;i++){
    cout<<t[i].second<<endl;
  }
}
  

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define LL long long int

using namespace std;

int main(){
    int n,k;
    cin>> n>> k;
    vector<int> h(n);
    for(int&x: h)
        cin>> x;
    int dp[n+1];
    dp[1] = 0;
    //dp[2] = abs(h[1] - h[0]);
    for(int i = 1;i <n;i++){
        dp[i + 1] = INT_MAX;
        for(int j = 1;j <= k && (i - j) >= 0;j++)
            dp[i + 1] = min(dp[i + 1],dp[i - j + 1] + abs(h[i] - h[i - j]));
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
package main

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

type shop struct {
	id    int
	name  string
	score int
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	s.Scan()
	k, _ := strconv.Atoi(s.Text())

	var pro, ans float64
	ans = 0
	for i := 1; i <= n; i++ {
		if i < k {
			t := math.Ceil(math.Log2(float64(k) / float64(i)))
			pro = (1 / float64(n)) * (1 / math.Pow(2, float64(t)))
			ans += pro
		} else {
			pro = (1 / float64(n))
			ans += pro
		}
	}
	fmt.Printf("%.9g", ans)
}


Measured memory_bytes: 640
#include <stdio.h>
#define min(x, y) ((x)>(y) ? (y) : (x))

int main(){
  long n, a, b;  scanf("%ld %ld %ld", &n, &a, &b);
  long ans;
  if((b-a) % 2 == 0)
    ans = (b-a) / 2;
  else if(a-1 < n-b)
    ans = min(b-1, a+(b-a-1)/2);
  else
    ans = min(n-a, n-b+1+(n-(a+n-b+1))/2);

  printf("%ld\n", ans);
  return 0;
}
    


Measured memory_bytes: 128
N = int(input())
xs = list(map(int, input().split()))
xs2 = sorted(xs)
M1 = xs2[len(xs)//2]
M2 = xs2[len(xs)//2 -1]
for x in xs:
    if x >= M1:
        print(M2)
    else:
        print(M1)

Measured memory_bytes: 25620
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 1000000

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

        if(n==0)
            break;
        
        vector<int> a(n);
        for(int i=0;i<n;i++)
            cin >> a[i];
        
        sort(a.begin(), a.end());

        int d = INF;
        for(int i=1;i<n;i++)
            d = min(d, a[i]-a[i-1]);
        
        cout << d << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];

            var answer = A;
            for (var i = 0; i < K; i++)
            {
                var tmp = new int[N + 1];
                for (var j = 0; j < answer.Length; j++)
                {
                    tmp[Math.Max(0, j - answer[j])]++;
                    tmp[Math.Min(N, j + answer[j] + 1)]--;
                }
                for (var j = 0; j < answer.Length; j++)
                {
                    tmp[j + 1] += tmp[j];
                }

                var isValid = true;
                for (var j = 0; j < answer.Length; j++)
                {
                    answer[j] = tmp[j];
                    if (answer[j] != N) isValid = false;
                }
                if (isValid) break;
            }

            Console.WriteLine(string.Join(" ", answer));
        }
    }
}


Measured memory_bytes: 61120
import math
def get_prime(n):
    if n <= 1:
        return []
    prime = [2]
    if n > 2:
        limit = int(math.sqrt(n))
        odd = [i for i in range(3, n + 1, 2)]
        while limit >= odd[0]:
            prime.append(odd[0])
            odd = [j for j in odd if j % odd[0] != 0]
        prime += odd
    return prime

from collections import defaultdict
def prime_factorization(n):
    if n <= 1:
        return {}
    else:
        # print(int(math.sqrt(n)))
        prime = get_prime(int(math.sqrt(n)))
        dct = defaultdict(int)
        for p in prime:
            while n % p == 0:
                dct[p] += 1
                n //= p
        if n != 1:
            dct[n] += 1
        dct = dict(dct)
        return dct

n = int(input())
pf = prime_factorization(n)

Z = []
for k, v in pf.items():
    for i in range(1, v + 1):
        Z.append(k ** i)
Z.sort()
count = 0
for z in Z:
    if n % z == 0:
        count += 1
        n //= z
    if n == 1:
        break

print(count)

Measured memory_bytes: 31716
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    hl = list(map(int, input().split()))
    counts = [0] * n

    for i in range(1,n):
        if hl[i-1] >= hl[i]:
            counts[i] = counts[i-1] + 1
    # print(counts)
    print(max(counts))


if __name__ == '__main__':
    main()


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

int main() {
	long long N, a[5], ans, mini=1e15;
	cin >> N;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < 5; i++) {
		mini = min(mini, a[i]);
	}

	long long late;
	if (N%mini == 0) {
		late = N / mini;
	}
	else {
		late = N / mini + 1;
	}

	ans = late + 4;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                      
#include <cstdio>                                                        
using namespace std;                                                     
                                                                         
int main() {                                                             
  int n;                                                                 
  cin >> n;                                                              
  for (int i=1; i<=n; i++) {                                             
    if (i%3==0) {                                                        
      cout << " " << i << flush;                                         
    } else {                                                             
      int x = i;                                                         
      while (x>0) {                                                      
        if (x%10==3) {                                                   
          cout << " " << i << flush;                                     
          break;                                                         
        }                                                                
        x /= 10;                                                         
      }                                                                  
    }                                                                    
  }                                                                      
  printf("\n");                                                          
  return 0;                                                              
}                                                                        
                                                                         
                                                                         
                                                                         
                                   

Measured memory_bytes: 3044
use proconio::input;

fn main() {
    input!(n: u64, e: [(u64, u64); n - 1]);

    let dec: u64 = e
        .iter()
        .map(|&(u, v)| {
            let (u, v) = if u < v { (u, v) } else { (v, u) };
            u * (n + 1 - v)
        })
        .sum();
    let ans = n * (n + 1) * (n + 2) / 6 - dec;

    println!("{}", ans);
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes";
	}  else {
		cout << "No";
	}
    return 0;
}


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

int main(){
  int n; ll k; cin>>n>>k;
  vector<ll> c(n),f(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    cin>>f[i];
  }
  sort(c.begin(),c.end());
  sort(f.rbegin(),f.rend());
  ll l=-1,r=1000000000000;
  while(r>1+l){
    ll sum=0,mid=(l+r)/2;
    for(int i=0;i<n;i++){
      if(0<c[i]*f[i]-mid) sum+=(c[i]*f[i]+f[i]-mid-1)/f[i];
    }
    if(sum<=k){
      r=mid;
    }else{
      l=mid;
    }
  }
  cout<<r<<endl;
}

Measured memory_bytes: 3328
using System;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.ReadLine().ToCharArray();

            for (int i = 0;i < input.Length; i++)
            {
                if (char.IsUpper(input[i]))
                {
                    input[i] = char.ToLower(input[i]);
                }
                else
                {
                    input[i] = char.ToUpper(input[i]);
                }
            }

            Console.WriteLine(input);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9148
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n; cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		
		
		Scanner sc =new Scanner(System.in);
		int d=sc.nextInt();
		int n=sc.nextInt();
		if(n==100)n++;
		System.out.println((int)Math.pow(100, d)*n);
	
	}
	
}





Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int s; cin >> s;
  set<int> S;
  int idx = 1;
  while (true){
    if (S.count(s)) break;
    else S.insert(s);

    if (s%2) (s *= 3) += 1;
    else s /= 2;
    
    idx++;
  }

  cout << idx << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int s;
	scanf("%d",&s);
	int mmyy=0,yymm=0;
	
	if(1 <= s%100 && s%100 <= 12)yymm++;
	if(1 <= (s/100)%100 && (s/100)%100 <= 12)mmyy++;
	
	if(mmyy == 0 && yymm ==0){
		printf("NA");
	}else if(mmyy == 1 && yymm ==0){
		printf("MMYY");
	}else if(mmyy == 0 && yymm ==1){
		printf("YYMM");
	}else{
		printf("AMBIGUOUS");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();

        if (a.equals("a") || a.equals("e") || a.equals("i") || a.equals("o") || a.equals("u")){
            System.out.println("vowel");
        }else{
            System.out.println("consonant");
        }
    }
}


Measured memory_bytes: 35728
def main():
    import sys
    input = sys.stdin.readline
    X, Y = map(int, input().split())
    a = 2 * X
    for i in range(2*X, 4*X+1, 2):
        if i == Y:
            print("Yes")
            break
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) cerr << #A << " = "; for (int i=1; i<=n; ++i) cerr << A[i] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int i=0; i<n; ++i) cerr << A[i] << ' '; cerr << '\n';

const int maxn = 1002;
const int maxm = 200002;
const int inf = 1e9;

int n, m, cnt[maxn], num[maxn], low[maxn], nTime;
int scc[maxn], nSCC, curBranch[maxn];
stack<int> st;
bool ok[maxn][maxn];
vector<int> g[maxn];
pair<int, int> e[maxm];

int readInt() {
	char c;
	for (c=getchar(); c<'0' || c>'9'; c=getchar());
	int res = c - '0';
	for (c=getchar(); '0'<=c && c<='9'; c=getchar())
		res = res * 10 + c - '0';
	return res;
}

void tarjan(int u) {
	st.push(u);
	num[u] = ++nTime;
	low[u] = inf;
	for (int i=0; i<g[u].size(); ++i) {
		int v = g[u][i];
		if (scc[v]!=0)
			continue;
		if (num[v])
			low[u] = min(low[u], num[v]);
		else {
			tarjan(v);
			low[u] = min(low[u], low[v]);
		}
	}
	if (low[u]<num[u])
		return;
	++nSCC;
	while (true) {
		int x = st.top(); st.pop();
		scc[x] = nSCC;
		if (x==u)
			break;
	}
}

void visit(int u, int branch, int root) {
	if (u!=branch)
		ok[root][u] = true;
	++cnt[u];
	for (int i=0; i<g[u].size(); ++i) {
		int v = g[u][i];
		if (v!=root && cnt[v]<2 && curBranch[v]!=branch) {
			curBranch[v] = branch;
			visit(v, branch, root);
		}
	}
}

void init(int x) {
	memset(cnt, 0, sizeof(cnt));
	memset(curBranch, 0, sizeof(curBranch));
	for (int i=0; i<g[x].size(); ++i) {
		int u = g[x][i];
		curBranch[u] = u;
		//debug(u);
		//debug(ok[3][4]);
		visit(u, u, x);
	}
}

int main() {
	//freopen("data.inp", "r", stdin);
	//freopen("data.out", "w", stdout);
	n = readInt(); m = readInt();
	for (int i=1; i<=m; ++i) {
		e[i].first = readInt();
		e[i].second = readInt();
		g[e[i].first].push_back(e[i].second);
	}
	for (int i=1; i<=n; ++i) {
		if (scc[i]==0) {
			tarjan(i);
		}
	}
	init(3);
	//debug(ok[3][4]);
	for (int i=1; i<=n; ++i) {
		init(i);
	}
	//debug(ok[3][4]);
	for (int i=1; i<=m; ++i) {
		int u = e[i].first, v = e[i].second;
		if (scc[u]==scc[v]) {
			if (ok[u][v])
				puts("same");
			else 
				puts("diff");
		}
		else {
			if (ok[u][v])
				puts("diff");
			else 
				puts("same");
		}
	}
}

Measured memory_bytes: 5376
n = gets.chomp
rates = gets.chomp.split.map(&:to_i)

colors = Array.new(9) { Array.new }
rates.each do |rate|
    x = rate / 400
    case x
        when 0..7
            colors[x] << rate
        else
            colors[8] << rate
    end
end

count = 0
8.times do |i|
    next if colors[i].empty?
    count += 1
end

puts "#{[count, 1].max} #{count + colors[8].size}"


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> ar(n), br(n);
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  } 
  for(int i = 0; i < n; ++i) {
    cin >> br[i];
  } 
  int x = 0, y = 0;
  vector<int> it(n);
  int pos = 0;
  iota(it.begin(), it.end(), 1);
  do {
    pos++;
    if(it == ar) x = pos;
    if(it == br) y = pos;
  } while(next_permutation(it.begin(), it.end()));
  cout << abs(x - y) << '\n';
  return 0;
}


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


void solve () {
    string s, t;
    cin >> s >> t;
    int n = (int) s.size();
    vector<int> b(26), a(26);
    for (int i = 0; i < n; i++) {
        b[t[i] - 'a']++;
        a[s[i] - 'a']++;
        if(a[s[i] - 'a'] != b[t[i] - 'a']) {
            cout << "No";
            return;
        }
    }
    cout << "Yes";

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


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string a;
  cin >> a;
  
  //to_stringはC++14 (GCC 5.4.1)で使うように
  a.replace(1, a.size()-2, to_string(a.size()-2));
  cout << a << endl;
}

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

int main() {
  int A, B, C, D, X, Y;
  cin >> A >> B >> C >> D;

  X = A + B;
  Y = C + D;
  if (X > Y) {
    cout << "Left" << endl;
  }
  else if (X == Y) {
    cout << "Balanced" << endl;
  }
  else cout << "Right" << endl;
}


Measured memory_bytes: 3636
/****************************************

	LostMartian

****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define LOCAL #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
long long a [100010];
int main()
{
	clock_t z = clock();
	FAST
	//LOCAL
	ll a;
    double b;
    cin >> a >> b;
    ll c = (ll)(b * 100.0 + 1e-9);
    cout << (a * c) / 100 << endl;


	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 3832
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define int long long
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
	IOS;
	cin>>n>>k;
	int res=n%k;
	cout<<min(res,k-res)<<ln;
}


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


void solve(long long K, long long A, long long B){
  if((A+1) < B && K >= A) {
    cout << (A + (((((K+1)-A)/2) * (B - A)) + (((K+1)-A)%2))) << endl;
  }
  else {
    cout << (K + 1) << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
  scanf("%lld",&K);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
K = int(input())
G = [[] for i in range(K)]

for n in range(K):
    G[n].append([(n + 1) % K, 1])
    G[n].append([(10 * n) % K, 0])


def dijkstra(x):
    d = [float('inf')] * K
    d[x] = 0
    visited = {x}

    # d, u
    hq = [(0, x)]

    while hq:
        u = heapq.heappop(hq)[1]
        visited.add(u)

        for node, cost in G[u]:
            if (node not in visited) and d[node] > d[u] + cost:
                d[node] = d[u] + cost
                heapq.heappush(hq, (d[u]+cost, node))
    return d


print(dijkstra(1)[0] + 1)


Measured memory_bytes: 100016
//import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)
			throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int n  = scan.nextInt();
		for(int i=0;i<n;i++){

			//scan.nextLine();
			BigDecimal x1,y1,x2,y2,x3,y3,x4,y4;
			x1= scan.nextBigDecimal();
			y1= scan.nextBigDecimal();
			x2= scan.nextBigDecimal();
			y2= scan.nextBigDecimal();
			x3=scan.nextBigDecimal();
			y3= scan.nextBigDecimal();
			x4= scan.nextBigDecimal();
			y4= scan.nextBigDecimal();
		
			try{
			if((((y2.subtract(y1)).multiply(x4.subtract(x3))).compareTo((y4.subtract(y3)).multiply(x2.subtract(x1))))==0){ System.out.println("YES");}
			else { System.out.println("NO");}
		}
			catch(ArithmeticException e){

	            System.out.println("No");

	        }
			
			}
	}
	
}

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

using namespace std;
typedef pair<int,int> pii;

int n;
int arr[100100];
vector<int> vec;
void print(int t) {
    puts(t==1?"First":"Second");
    exit(0);
}

int getv(int x) {
    int i, f = 0, p = -arr[1];
    for (i=1;i<=n;i++) {
        if (i==n||arr[i]!=arr[i+1]) {
            if (p<=x&&x<=i-arr[i+1]) {
                f |= abs((i-arr[i]-x)%2);
            }
            p = i-arr[i+1];
        }
    }
    return f;
}

int main() {
    int i;

    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d",&arr[i]);
    sort(arr+1,arr+n+1,greater<int>());
    print(getv(0)&&(getv(-2)||getv(2)));

    return 0;
}


Measured memory_bytes: 640