akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll x;
    cin >> x;

    ll i = 0;
    ll a, b;
    bool found  = false;
    while(true)
    {
        for(ll j = 0; j <= i; j++)
        {
            a = i;
            b = j;
            ll a5 = pow(a, 5);
            ll b5 = pow(b, 5);
            if(a5 - b5 == x)
            {
                found = true;
                break;
            }

            a = i;
            b = -j;
            a5 = pow(a, 5);
            b5 = pow(b, 5);
            if(a5 - b5 == x)
            {
                found = true;
                break;
            }

            a = -i;
            b = j;
            a5 = pow(a, 5);
            b5 = pow(b, 5);
            if(a5 - b5 == x)
            {
                found = true;
                break;
            }

            a = -i;
            b = -j;
            a5 = pow(a, 5);
            b5 = pow(b, 5);
            if(a5 - b5 == x)
            {
                found = true;
                break;
            }
        }

        if(found)
        {
            break;
        }
        i++;
    }

    cout << a << " " << b;
}

/*
int main()
{
    ll x;
    cin >> x;

    ll xMax = pow(10, 9) * 10;
    map<ll, ll> pows;
    ll ab = 0;
    while(true)
    {
        ll powi5 = pow(ab, 5);
        if(powi5 > xMax)
        {
            break;
        }

        pows[ab] = powi5;
        pows[-ab] = -powi5;
        ab++;
    }

    ll a = 0, b = 0;
    bool found = false;
    for(ll i = 0; i < ab; i++)
    {
        for(ll j = 0; j < ab; j++)
        {
            if(pows[i] - pows[j] == x)
            {
                a = i;
                b = j;
                found = true;
                break;
            }
            else if(pows[i] - pows[-j] == x)
            {
                a = i;
                b = -j;
                found = true;
                break;
            }
            else if(pows[-i] - pows[j] == x)
            {
                a = -i;
                b = j;
                found = true;
                break;
            }
            else if(pows[-i] - pows[-j] == x)
            {
                a = -i;
                b = -j;
                found = true;
                break;
            }
        }

        if(found)
        {
            break;
        }
    }

    cout << a << " " << b;

    return 0;
}
*/

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

bool dfs(int u, vector<vector<pair<int, int>>>& adj, vector<int>& seen, vector<int>& pos)
{
  seen[u] = 1;
  for (pair<int, int> p : adj[u]) {
    int v = p.first, d = p.second;
    if (seen[v]) {
      if (pos[v] != (pos[u] + d)) { return false; }
      continue;
    }
    pos[v] = pos[u] + d;
    if (not dfs(v, adj, seen, pos)) { return false; }
  }
  return true;
}

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>());
  for (int i = 0; i < M; ++i) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    adj[l - 1].push_back(make_pair(r - 1, d));
    adj[r - 1].push_back(make_pair(l - 1, -d));
  }

  vector<int> seen(N, 0), pos(N, 0);
  bool ok = true;
  for (int u = 0; u < N; ++u) {
    if (seen[u]) { continue; }
    pos[u] = 0;
    if (not dfs(u, adj, seen, pos)) {
      ok = false;
      break;
    }
  }
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 13312
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
#include<string>
#include<cmath>
using namespace std;

int main(){
    string s;cin >> s;
    string t;cin >>t ;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(s[i] == t[i]){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;
ll vs[2020];
pair<ll,int> ps[2020];
ll memo[2020][2020];
bool visited[2020][2020];
ll solve(int tot, int left) {
  ll &res = memo[tot][left];
  if(!visited[tot][left]) {
    visited[tot][left] = true;
    if(tot == 0) {
      res = left == 0 ? 0 : -1;
    } else {
      res = 0;
      int target = tot-1;
      if(left > 0) {
        ll tmp = solve(tot-1, left-1);
        tmp += ps[target].first * (ps[target].second - (left-1));
        res = max(res, tmp);
      }
      int right = tot-left;
      if(right > 0) {
        ll tmp = solve(tot-1, left);
        tmp += ps[target].first * ((n-right) - ps[target].second);
        res = max(res, tmp);
      }
    }
  }
  return res;
}



int main(void) {
  scanf("%d", &n);
  
  REP(i, n) {
    scanf("%lld", &vs[i]);
    ps[i] = make_pair(vs[i], i);
  }
  sort(ps, ps + n);
  reverse(ps, ps + n);
  ll res = 0;
  REP(i, n+1) {
    res = max(res, solve(n, i));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 29980
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int count = 0;
		String W = scan.next();
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}
			String w = W.toLowerCase();
			String t = T.toLowerCase();
			if(t.equals(w)){
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int main(void) {
	int A, B, C;
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> A >> B >> C;
	if (A == 7) {
		if (B == 5 && C == 5) {
			cout << "YES\n";
		} else {
			cout << "NO\n";
		}
	} else if (B == 7) {

		if (A == 5 && C == 5) {
			cout << "YES\n";
		} else {
			cout << "NO\n";
		}

	} else if (C == 7){

		if (B == 5 && A == 5) {
			cout << "YES\n";
		} else {
			cout << "NO\n";
		}
	} else {
		cout << "NO\n";
	}

	return 0;
}


Measured memory_bytes: 256
/*
 * Author: Kewth

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Type "!!sh" in Vim.

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
   __  __                  __   __
  |  |/  |.-----.--.--.--.|  |_|  |--.
  |     < |  -__|  |  |  ||   _|     |
  |__|\__||_____|________||____|__|__|

 */

#include <cstdio>
#include <algorithm>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

static struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 200005;
int a[maxn], id[maxn], ans[maxn];
std::vector<int> G[maxn];
int stack[maxn], sp;
int vis[maxn], tot[maxn];

void dfs (int u, int i) {
	++ tot[i];
	vis[u] = i;
	for (int v : G[u])
		if (!vis[v])
			dfs(v, i);
}

int main () {
	int n = read;
	for (int i = 1; i <= n; i ++) {
		int x = read, y = read;
		id[x] = i;
		a[x] = y;
	}
	for (int i = 1; i <= n; i ++) {
		int neo = sp and a[stack[sp]] < a[i] ? stack[sp] : i;
		while (sp and a[stack[sp]] < a[i]) {
			int j = stack[sp --];
			G[i].push_back(j);
			G[j].push_back(i);
		}
		stack[++ sp] = neo;
	}
	int p = 0;
	for (int i = 1; i <= n; i ++) {
		if (!vis[i])
			dfs(i, ++ p);
		ans[id[i]] = tot[vis[i]];
	}
	for (int i = 1; i <= n; i ++)
		printf("%d\n", ans[i]);
}


Measured memory_bytes: 18180
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Edge
{
public:
    int a, b, cost;
    Edge(int a, int b, int cost){
        this->a = a;
        this->b = b;
        this->cost = cost;
    }
};

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

    int n = 1;
    vector<Edge> edges;
    for(int i=0; (2<<i)<=l; ++i){
        edges.push_back(Edge(i, i+1, 0));
        edges.push_back(Edge(i, i+1, 1<<i));
        ++ n;
    }
    int cnt = 1 << (n - 1);

    for(int i=n-1; i>=0; --i){
        int x = 1 << i;
        if(x <= l - cnt){
            edges.push_back(Edge(i, n-1, cnt));
            cnt += x;
        }
    }

    int m = edges.size();
    cout << n << ' ' << m << endl;
    for(int i=0; i<m; ++i){
        int a = edges[i].a + 1;
        int b = edges[i].b + 1;
        cout << a << ' ' << b << ' ' << edges[i].cost << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    pr((h == 0 || h == H - 1 || w == 0 || w == W - 1) ? "#"
                            : ".");
 
                }
                ln();
            }
            ln();
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 34784
#include <stdio.h>

int main(void){
	int n;
	int y, m, d;

	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int ans = 0;
		scanf("%d %d %d", &y, &m, &d);

		if(y % 3 != 0){
			if(m % 2 == 1){
				ans += 20 - d + 1;	
			}else{
				ans += 19 - d + 1;
			}
		}else{
			ans += 20 - d + 1;
		}

		for(int j=m+1; j<=10; j++){
			if(y % 3 != 0){
				if(j % 2 == 1){
					ans += 20;
				}else{
					ans += 19;
				}
			}else{
				ans += 20;
			}
		}
			
		for(int j=y+1; j<1000; j++){
			for(int k=1; k<=10; k++){
				if(j % 3 != 0){
					if(k % 2 == 1){
						ans += 20;
					}else{
						ans += 19;
					}
				}else{
					ans += 20;
				}
			}
		}

		printf("%d\n", ans);

	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n; 
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    rep(i,n) {
        if(p[i]!=i+1){
            cnt++;
        }
    }
    if(cnt>=3) cout << "NO" << endl;
    else cout << "YES" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  if(a==0) cout<<b/x+1<<endl;
  else cout<<b/x-(a-1)/x<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define N 3

int puzz[N][N];
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};

int huri(){

  int x,y ,i,j,sum=0;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(puzz[i][j] == 0)continue;

      x=(puzz[i][j]-1)%N-j;
      y=(puzz[i][j]-1)/N-i;
      x=abs(x);
      y=abs(y);
      
      sum+=x;
      sum+=y;
    }
  }
  return sum;
}

int DFS(int iof0,int jof0,int lim,int dpt){

  int i,j,h,x,y,tmp,ans=-1;

  h = huri();
  if(h == 0) return dpt;
  if(h+dpt > lim) return -1;

  for(i=0;i<4;i++){
    x = iof0 + dx[i];
    y = jof0 + dy[i];

    if(x >= N || x < 0) continue;
    if(y >= N || y < 0) continue;

    tmp = puzz[x][y];
    puzz[x][y] = puzz[iof0][jof0];
    puzz[iof0][jof0] = tmp;

    ans = DFS(x,y,lim,dpt+1);

    if(ans != -1) return ans;
    tmp = puzz[x][y];
    puzz[x][y] = puzz[iof0][jof0];
    puzz[iof0][jof0] = tmp;
  }
  return -1;
}

int main(){

  int i,j,iof0,jof0,ans;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&puzz[i][j]);
      if(puzz[i][j] == 0){
	iof0 = i;
	jof0 = j;
      }
    }
  }

  for(i=1;i<101;i++){
    ans = DFS(iof0,jof0,i,0);
    if(ans != -1) {
      printf("%d\n",ans);
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 2080
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
l=[0]*26
for d in range(D):
    x=[S[d][i]-sum([(d+1-l[j])*C[j] for j in range(26) if i!=j]) for i in range(26)]
    j=x.index(max(x))
    l[j]=d+1
    print(j+1)

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

const int dx2[] = {1,1,1,0,0,0,-1,-1,-1};
const int dy2[] = {1,0,-1,1,0,-1,1,0,-1};

void go(vector<vector<int> > &F,int h,int w){
    if(F[h][w]==0) return;
    F[h][w] = 0;
    for(int i=0;i<9;i++){
        go(F,h+dy2[i],w+dx2[i]);
    }
}
int main(){
    while(true){
        int w,h;
        cin >> w >> h;
        if(w==0) break;
        vector<vector<int> > F(h+2,vector<int>(w+2,0));
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> F[i][j];
            }
        }
        int c=0;
        for(int i=0;i<h+2;i++){
            for(int j=0;j<w+2;j++){
                if(F[i][j] == 1){
                    go(F,i,j);
                    c++;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 1340
// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University
 
#include <bits/stdc++.h>
using namespace std;
 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)
 
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
 
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number
 
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
 
typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);
 
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }
 
//inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
//ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
//ll add(ll a,ll b,ll M)  { return mod(( mod(a,M ) + mod(b,M )),M);     }
//ll sub(ll a, ll b,ll M) { return mod((mod(a,M ) + M - mod(b,M )),M);   }
//ll mult(ll a,ll b,ll M) { return  mod(( mod(a,M)*mod(b,M) ),M) ; }
//bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 
 
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
 
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; }
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
  
               /* -------------------------------Main Code------------------------------- */
 

int main(){
	FAST
	ll n;cin>>n;
	vi v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(all(v));
	ll ans = n*(n-1)*(n-2)/6 ;
	for(int i = 0;i<n;i++){
		for(int j = i+1;j<n;j++){
			int pos = lower_bound(all(v),v[i]+v[j]) - v.begin();
			ans -= (n-pos);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void) {
	long long int X,Y;
	long long int ans = 0;
	cin >> X >> Y;
	for (long long int i = X; i <= Y;  i*=2) {
		ans++;
	}

		cout << ans << endl;

	return 0;
}


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

int main(){
  int n;
  vector<int> v(100001, 0);
  cin >> n;
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    for (int j = -1; j <= 1; j++){
      if (k+j < 0) continue;
      v[k+j]++;
    }
  }
  int ma = 0;
  for (int i = 0; i <= 100000; i++){
    ma = max(ma, v[i]);
  }

  cout << ma << endl;

  return 0;
}


Measured memory_bytes: 640
/*
[abc150] C - Count Order
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 8;

int N;
vector<int> P, Q;

int ord(vector<int> t) {
    vector<int> a(N);
    for (int i = 1; i <= N; i++) {
        a[i - 1] = i;
    }
    int ret = 0;
    while (a != t) {
        next_permutation(ALL(a));
        ret++;
    }
    return ret;
}

ll solve() { return abs(ord(P) - ord(Q)); }

int main() {
    cin >> N;
    P.resize(N);
    Q.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	as <- readInts
	let
		lefts = scanl gcd 0 as
		rights = tail $ scanr gcd 0 as
	print $ maximum $ zipWith gcd lefts rights

Measured memory_bytes: 27900
#include <iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int i;
  int counter = 1;
  while (1){
    cin >> i;
    if (i == 0) {
      break;
    } else {
      cout << "Case " << counter << ": " << i << "\n";
    }
    counter ++;
  }
}



Measured memory_bytes: 3124
fun main(args: Array<String>)
{
    val (n, k) = readNInts()

    val mod = 1000000007L
    val c = Array<LongArray>(2001, { LongArray(2001) })
    for (i in 0..2000) {
        for (r in 0..i) {
            if (r == 0 || r == i) {
                c[i][r] = 1L
                continue
            }

            c[i][r] = c[i-1][r-1] + c[i-1][r] % mod
        }
    }

    for (i in 1..k) {
        val a = c[n-k+1][i] % mod
        val b = c[k-1][i-1] % mod

        val ans: Long = (a * b) % mod
        println(ans)
    }
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


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

int number_count[200005];
int count_count[200005];

int main() {
    int N, K, A, count = 0, min_del = 0;
    cin >> N >> K;

    for (int i = 0; i < 200005; i++) {
        number_count[i] = 0;
        count_count[i] = 0;
    }

    for (int i = 0; i < N; i++) {
        cin >> A;
        number_count[A]++;
    }

    for (int i = 0; i < 200005; i++) {
        if (number_count[i] != 0) count++;
    }

    for (int i = 1; i < 200005; i++) {
        count_count[number_count[i]]++;
    }

    int idx = 1;

    while (count > K) {
        if (count_count[idx] != 0) {
            min_del += idx;
            count_count[idx]--;
            count--;
        }
        else idx++;
    }

    cout << min_del << endl;

    return 0;
}

Measured memory_bytes: 1920
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy


a,b,c,d = L()
ta = -(-c // b)
ao = -(-a//d)
#print(ta,ao)
if ta <= ao :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61736
n,m = list(map(int, input().split()))

jouken = {}
ans = ''
for i in range(m):
    s, t = list(map(int, input().split()))
    if s in jouken.keys():
        if jouken[s] != t:
            ans = -1
            break
    else:
        jouken[s] = t
    
if ans != -1:
    for j in range(n):
        keta = j+1
        if keta in jouken.keys():
            if keta == 1 and jouken[keta] == 0 and n != 1:
                ans = -1
                break
            else:
                ans += str(jouken[keta])
        elif keta == 1 and n != 1:
            ans += '1'
        else:
            ans += '0'
            
print(int(ans))


Measured memory_bytes: 3064
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 25;
int a[N], c[N], n, m, xx, ans;
vi v[N];

void subsets(int x)
{
     int range = 1LL << x;

     for (int mask = 0; mask < range; mask++)
     {
          vi e;
          int cost = 0;
          for (int i = 0; i < x; i++)
          {
               if (mask & (1LL << i))
               {
                    e.pb(i);
                    cost += c[i];
               }
          }
          vi f(m, 0);
          for (auto x : e)
          {
               for (int i = 0; i < m; i++)
                    f[i] += v[x][i];
          }
          int ok = 1;
          for (int i = 0; i < m; i++)
               if (f[i] < xx)
                    ok = 0;

          if (ok)
               ans = min(ans, cost);

     }

}

void solve()
{
     cin >> n >> m >> xx;
     ans = 1e9;
     for (int i = 0; i < n; i++)
     {
          cin >> c[i];
          for (int j = 0; j < m; j++)
          {
               int x; cin >> x;
               v[i].pb(x);
          }
     }

     subsets(n);
     if (ans == 1e9)
          ans = -1;
     cout << ans;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


// ABC121C - Energy Drink Collector
// https://atcoder.jp/contests/abc121/tasks/abc121_c
void ABC121C() {
	ll N, M;
	cin >> N >> M;

	//vector<ll> A(N), B(N), VALUE(N);
	vector<pair<ll, ll>> AB(N); //金額と本数
	for (ll i = 0; i < N; i++)
	{
		cin >> AB[i].first >> AB[i].second;
	}

	//昇順にソートすれば、低い方から買えるだけ買えばOKになる
	sort(AB.begin(), AB.end());

	//本数と金額の累積和を求める
	vector<pair<ll, ll>> CS(N + 1);
	int index = 0;
	for (; index < N; index++)
	{
		CS[index + 1].first  = CS[index].first  + AB[index].first * AB[index].second; //金額
		CS[index + 1].second = CS[index].second + AB[index].second;              //本数
		
		//合計本数がM本以上になったらそれ以上見る必要はない
		if (CS[index +1].second >=M) {
			break;
		}
	}

	/*
	for (int i = 0; i <= N; i++)
	{
		cout << CS[i].first << ", " << CS[i].second << endl;
	}*/

	//M本を超えている場合は、M本になるまで金額と本数を減らす
	while (CS[index +1].second > M) {
		CS[index +1].first -= AB[index].first; //金額
		CS[index +1].second--; //本数
	}

	cout << CS[index + 1].first << endl;
}


int main() {
	ABC121C();

	return 0;
}

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

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

    //ある整数が素数か否かを1から順に決定する（素数でなければtrue)
    vector<bool> notP(1001, false);
    notP[1] = true;
    for(int i=1; i<101; i++) {
        if(!notP[i]) {
            for(int j=i*2; j<=1000; j+=i) notP[j] = true;
        }
    }

    //N!に含まれる素因数をそれぞれ数える
    //一般に、n!に含まれる素因数pの個数はΣ(n/p^k)
    vector<int> cnt(101, 0);
    for(int i=2; i<=N; i++) {
        if(notP[i]) continue;
        int x = N;
        while(x) {
            cnt[i] += x/i;
            x /= i;
        }
    }

    
    //dp[i][j] ->　iの階乗の約数のうち、ちょうどj個の約数を持つ整数の数
    vector<vector<int>> dp(200, vector<int>(200, 0));
    dp[1][1] = 1;
    for(int i=1; i<=N; i++) {
        for(int j=0; j<=75; j++) {
            for(int k=1; k<=cnt[i]+1; k++) {
                if(j*k > 75) continue;

                //約数がj個の整数にk個の素因数が掛かると、約数の数はj*(k+1)個になる。
                //ここでは、kは1からcnt[i]+1までなので、cnt[i]が0(iが素因数でない)場合、
                //dp[i+1][j]にdp[i][j]の結果がそのまま代入される。
                //テーブルを図に起こすと考えやすい。
                dp[i+1][j*k] += dp[i][j];
            }
        }
    }

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

Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();
		System.out.println(Math.min(a, b)+Math.min(c, d));
		
		
		
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define int long long
#define maxlen 100000
#define inf 200000007
using namespace std;

int bag,n,ans=1e18+7;
int a[maxlen+5],cost[maxlen+5],dp[maxlen+5];

signed main()
{
	cin>>bag>>n;
	for (int i=1;i<=n;i++)  cin>>a[i]>>cost[i];
	
	for (int i=1;i<=maxlen;i++)  dp[i]=inf;
	for (int i=1;i<=n;i++)
	{
		for (int j=a[i];j<=maxlen;j++)  dp[j]=min(dp[j],dp[j-a[i]]+cost[i]);
	}
	for (int i=bag;i<=maxlen;i++)  ans=min(ans,dp[i]);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int sx = scanner.nextInt(),sy = scanner.nextInt();
		int tx = scanner.nextInt(),ty = scanner.nextInt();
		int x = Math.abs(sx-tx);
		int y = Math.abs(sy-ty);
		String path = "";
		for(int i=0;i<x;i++){
			System.out.print("R");
		}
		for(int i=0;i<y;i++){
			System.out.print("U");
		}
		for(int i=0;i<x;i++){
			System.out.print("L");
		}
		for(int i=0;i<y+1;i++){
			System.out.print("D");
		}

		for(int i=0;i<x+1;i++){
			System.out.print("R");
		}
		for(int i=0;i<y+1;i++){
			System.out.print("U");
		}
		System.out.print("L");
		System.out.print("U");
		for(int i=0;i<x+1;i++){
			System.out.print("L");
		}
		for(int i=0;i<y+1;i++){
			System.out.print("D");
		}

		System.out.println("R");
	}

}


Measured memory_bytes: 27076
h, w = map(int, input().split())
n = 10
cost = []
for i in range(n):
    cost.append(list(map(int, input().split())))

for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

res = 0
for i in range(h):
    for j in map(int, input().split()):
        if j == -1:
            continue
        else:
            res += cost[j][1]
print(res)


Measured memory_bytes: 40428
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val n = s.size
  val v = "keyence"

  val res = for {
    i <- 0 to 7
    j = 7 - i
    if s.take(i) + s.takeRight(j) == v
  } yield true

  val ans = if(res.nonEmpty) "YES" else "NO"
  println(ans)
}

Measured memory_bytes: 25416
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
//
int cnt[100000];
vector<int> g[100000];
map<pair<int,int>,int> m;
int col[100000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		if(a>b){
			swap(a,b);
		}
		cnt[a]++;
		cnt[b]++;
		g[a].push_back(b);
		g[b].push_back(a);
		m[make_pair(a,b)]=i;
	}
	int mem;
	int ans=0;
	for(int i=0;i<n;i++){
		if(ans<cnt[i]){
			mem=i;
			ans=cnt[i];
		}
	}
	cout<<ans<<endl;
	queue<pair<int,int>> que;
	que.push(make_pair(mem,-1));
	bool used[100000]={};
	used[mem]=1;
	while(!que.empty()){
		int now=que.front().first;
		int co=que.front().second;
		int nco=0;
		if(nco==co){
			nco++;
		}
		que.pop();
		for(int i=0;i<g[now].size();i++){
			if(!used[g[now][i]]){
				used[g[now][i]]=1;
				col[m[make_pair(min(g[now][i],now),max(g[now][i],now))]]=nco;
				que.push(make_pair(g[now][i],nco));
				nco++;
				if(nco==co){
					nco++;
				}
			}
		}
	}
	for(int i=0;i<n-1;i++){
		cout<<col[i]+1<<endl;
	}
	return 0;
}

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

int main() {
  ll n; cin >> n;
  vector<ll> Cnt(100100,0);
  rep(i,n){
    ll c; cin >> c;
    Cnt[c]++;
  }
  
  ll sum = 0;
  rep(i,100100){
    sum += i*Cnt[i];
  }
  
  ll q; cin >> q;
  rep(i,q){
    int a,b; cin >> a >> b;
    Cnt[b] += Cnt[a];
    sum += (b-a)*Cnt[a];
    Cnt[a] = 0;
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 3932
H,W=map(int,input().split())

import sys
if H*W%3==0:
    print(0)
    sys.exit()

ans=min(H,W)  #平行に3つ切るとき

for i in range(1,H):
    a=i*W
    b=(H-i)*(W//2)
    c=(H-i)*(-(-W//2))
    m=min([a,b,c])
    M=max([a,b,c])
    ans=min(ans,M-m)

for i in range(1,W):
    a=i*H
    b=(W-i)*(H//2)
    c=(W-i)*(-(-H//2))
    m=min([a,b,c])
    M=max([a,b,c])
    ans=min(ans,M-m)

print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
H_list = list(map(int, input().rstrip().split()))
AB_list = [list(map(int, input().rstrip().split())) for i in range(M)]
#-----

road_dic = {}

for A,B in AB_list:
    road_dic.setdefault(A, [])
    road_dic[A].append(B)
    
    road_dic.setdefault(B, [])
    road_dic[B].append(A)


cnt = 0
for i in range(1, len(H_list)+1):
    if i not in road_dic:
        cnt += 1
    
    else:
        for j in road_dic[i]:
            if H_list[i-1] <= H_list[j-1]:
                break
        else:
            cnt += 1


print(cnt)


Measured memory_bytes: 43276
#include <iostream>
#include <vector>
#include <utility>

typedef std::vector<int> vi;
typedef std::vector<vi> vii;

int main()
{
  int H, W;
  std::cin >> H >> W;
  vii a(H, vi(W, 0));
  vii ans;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int tmp;
      std::cin >> tmp;
      a.at(i).at(j) += tmp;
      a.at(i).at(j) %= 2;
      if (i != H-1)
      {
        if (a.at(i).at(j) == 1)
        {
          a.at(i+1).at(j)++;
          vi tmp_v = {i+1, j+1, i+2, j+1};
          ans.push_back(tmp_v);
        }
      }
    }
  }
  for (int i = 0; i < W-1; i++)
  {
    if (i != W-1)
    {
      if (a.at(H-1).at(i) % 2)
      {
        a.at(H-1).at(i+1)++;
        vi tmp_vv = {H, i+1, H, i+2};
        ans.push_back(tmp_vv);
      }
    }
  }
  std::cout << ans.size() << std::endl;
  for (int i = 0; i < ans.size(); i++)
  {
    for (int j = 0; j < 4; j++)
    {
      std::cout << ans.at(i).at(j);
      if (j != 3) std::cout << " ";
      else std::cout << std::endl;
    }
  }
}


Measured memory_bytes: 10032
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) if (s[i] == t[i]) ans++;
  cout << ans << endl;
  return 0;
}


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

int main(){
  int a,b,c;
  int mx;
  int t;

  scanf("%d %d %d", &a, &b, &c);
  mx = max(max(a,b),c);
  t = a + b + c - mx;

  if(mx == t) printf("Yes\n");

  else printf("No\n");

  return 0;
}


Measured memory_bytes: 256
//2020.1.30
//s1270188 xxxmk2
//alds1_13a

#include<stdio.h>
#define N 8

//global
int masu[N][N], row[N], col[N], dpos[2*N-1], dneg[2*N-1];

//function
void pr_masu(void){
  int i, j;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(masu[i][j]==1 && row[i]!=j) return;
  }
}

for(i=0;i<N;i++){
  for(j=0;j<N;j++){
    if(row[i]==j) printf("Q");
    else printf(".");
  }
  printf("\n");
 }
}




void queens(int i){
  int j;
  
  if(i==N){
    pr_masu();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==1 || dpos[i+j]==1 || dneg[i-j+N-1]==1) continue;

    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=1;

    queens(i+1);

    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=-1;
  }
}


int main(){
  int i, j, k, num;

  //reset
  for(i=0;i<N;i++)
    for(j=0;j<N;j++) masu[i][j]=-1;
  for(i=0;i<N;i++) row[i]=col[i]=-1;
  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=-1;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d %d",&j,&k);
    masu[j][k]=1;
  }

  queens(0);
  
  return 0;
}



Measured memory_bytes: 2112
def main():
    N = int(input())
    S1 = input()
    S2 = input()
    mod = 10**9 + 7
    if S1[0] != S2[0]:
        r = 6
    else:
        r = 3
    for i in range(1, N):
        if S1[i-1] == S1[i]:
            continue
        if S1[i] == S2[i] and S1[i-1] != S2[i-1]:
            continue
        if S1[i] != S2[i] and S1[i-1] != S2[i-1]:
            r *= 3
            r %= mod
            continue
        r *= 2
        r %= mod
    return r
print(main()) 


Measured memory_bytes: 3064
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
T.sort()

ans=0
nexttime=0
people=0
for t in T:
  if t>nexttime:
    nexttime=t+K
    ans+=1
    people=0
  people+=1
  if people==C:
    nexttime=0
print(ans)

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int>moji(3);
  for(int i=0;i<3;i++){
  cin>>moji.at(i);
  }
sort(moji.begin(),moji.end());
  reverse(moji.begin(),moji.end());
  cout<<moji.at(0)*10+moji.at(1)+moji.at(2)<<endl;

}


Measured memory_bytes: 256
def solve():
    dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
    for i in range(N):
        for j in range(W + 1):
            if j < w[i]:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] +v[i])
    return dp[N][W]

N, W = map(int, input().split())
w = [0 for i in range(N)]
v = [0 for i in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())
print(solve())


Measured memory_bytes: 171912
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

volume = [1, 2, 4, 8]
value = {k:v for k, v in zip(volume, inpl())}
cosp = {k:v/k for k, v in value.items()}
N = int(input())
N = N*4
res = 0

for k, _ in sorted(cosp.items(), key=lambda x: x[1]):
    res += (N // k)*value[k]
    N = N % k
print(int(res))

Measured memory_bytes: 3064
n = gets.to_i

p_a = gets.chomp.split
p_s = String.new
n.times do |i|
    p_s += p_a[i]
end

q_a = gets.chomp.split
q_s = String.new
n.times do |i|
    q_s += q_a[i]
end

from_1_to_n = []
(1..n).each do |num|
    from_1_to_n << num
end
n_permu = from_1_to_n.permutation(n).to_a
n_permu.length.times do |i|
    n_permu[i] = n_permu[i].join
end
n_permu.sort!

a = n_permu.index(p_s)
b = n_permu.index(q_s)

puts (a - b).abs

Measured memory_bytes: 13912
#include <iostream>

using namespace std;

typedef long long ll;

ll b, w, fact[200005];
const ll mod = (ll)1e9 + 7;

ll power(ll x, ll y){
	ll ret = 1;
	while(y){
		if(y & 1){
			ret = (ret * x) % mod;
		}
		x = (x * x) % mod;
		y >>= 1;
	}
	return ret;
}

void initfact(int gran){
	fact[0] = 1;
	for(int i = 1 ; i <= gran ; ++i){
		fact[i] = (fact[i - 1] * i) % mod;
	}
}

ll inv(ll x){
	return power(x, mod - 2);
}

ll povrh(ll x, ll y){
	if(y > x)
		return 0;
	ll ret = (fact[x] * inv((fact[y] * fact[x - y]) % mod)) % mod;
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
initfact(200001);
cin >> b >> w;
ll inv2 = inv(2);
int n = b + w;
cout << inv2 << endl;
ll x = 0, y = 0;
for(int i = 1 ; i < n ; ++i){
	x = (x + (povrh(i - 1, b - 1) * inv(power(2, i))) % mod) % mod;
	y = (y + (povrh(i - 1, w - 1) * inv(power(2, i))) % mod) % mod;
	ll sol = ((1 - x) % mod + mod) % mod;
	sol = (sol + y) % mod;
	sol = (sol * inv2) % mod;
	cout << sol << endl;
}

return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  string s; cin >>s; int sum=0;
  for(int i=0; i<s.size(); i++) sum+=(int)(s[i]-'0');
  cout <<(sum%9?"No":"Yes");
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3780
n = int(input())

numOfColors = 0
edges = [[] for j in range(n+1)]
ngColor = [-1]*(n+1)
outsI = [[] for j in range(n+1)]
outs = [0]*(n-1)

for i in range(n-1):
  a, b = map(int, input().split())
  edges[a].append(b)
  outsI[a].append(i)

numOfColors = len(edges[1])
for i in range(2, len(edges)):
  numOfColors = max(len(edges[i])+1, numOfColors)

#print(edges)
#print(outsI)

for i in range(len(edges[1])):
  ngColor[edges[1][i]] = i+1
  outs[outsI[1][i]] = i+1
  
queue = []
queue.extend(edges[1])
while queue != []:
  v = queue.pop(0)
  c = 0
  for i in range(len(edges[v])):
    c += 1
    if c == ngColor[v]:
      c += 1
    ngColor[edges[v][i]] = c
    outs[outsI[v][i]] = c
  queue.extend(edges[v])
#print(ngColor)
print(numOfColors)
for out in outs:
  print(out)



Measured memory_bytes: 30896
#include <iostream>
#include <utility>
#include <vector>
#include <map>
#include <numeric>

/*snuke*/

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

using ll = long long;
using P = std::pair<int,int>;
 
constexpr int mod {1000000007};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
 
struct Sieve {
  int n;
  std::vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  std::vector<int> factorList(int x) {
    std::vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  std::vector<P> factor(int x) {
    std::vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    std::vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
 
int main(int argc, char** argv) {
  Sieve sieve(1000000);
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i,n) std::cin >> a[i];
 
  std::map<int,int> mp;
  rep(i,n) {
    auto f = sieve.factor(a[i]);
    for (auto p : f) {
      mp[p.first] = std::max(mp[p.first], p.second);
    }
  }
 
  mint lcm = 1;
  for (auto p : mp) {
    rep(i,p.second) {
      lcm *= p.first;
    }
  }
 
  mint ans;
  rep(i,n) {
    mint b = lcm/a[i];
    ans += b;
  }
  std::cout << ans.x << '\n';
  return 0;
}


Measured memory_bytes: 5364
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0], 10);
  var a = input[1].split(" ");
  var tmp = Math.abs(a[0]);
  var tmp2 = 0;
  var count = 0;
  
  for (var i = 0; i < n; i++) {
    if (a[i] < 0) {
      count++;
    } 
    tmp2 += Math.abs(a[i]);
    if (tmp > Math.abs(a[i])) {
      tmp = Math.abs(a[i]);
    }
  }
  if (count % 2 == 0) {
    console.log('%d',tmp2);
  } else {
    console.log('%d',tmp2 - 2 * tmp);
  }
  
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 19048
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
        int y2 = sc.nextInt();
    
		int xGap = x2 - x1;
        int yGap = y2 - y1;
        StringBuilder builder = new StringBuilder();
        builder.append(x2 - yGap);
        builder.append(" ");
        builder.append(y2 + xGap);
        builder.append(" ");
        builder.append(x1 - yGap);
        builder.append(" ");
        builder.append(y1 + xGap);
    
		// 出力
		System.out.println(builder.toString());
	}
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;
    map<ll, ll> ans;
    REP(x, 1, 110)
    REP(y, 1, 110)
    REP(z, 1, 110) ans[x * x + y * y + z * z + x * y + y * z + z * x]++;

    REP(i, 1, N + 1)
    cout << ans[i] << "\n";
}


Measured memory_bytes: 6560