akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int main()
{
	int x=read(),y=read(),z=read();
	printf("%d\n",(z-1)/max(x,y)+1); 
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++)
			a[i] = sc.nextInt();
		
		int idx = -1;
		for(int i=0; i<N-1; i++) {
			if(a[i]+a[i+1]>=L) {
				idx = i;
				break;
			}
		}
		
		if(idx>=0) {
			pw.println("Possible ");
			for(int i=0; i<idx; i++)
				pw.println(i+1);
			for(int i=N-2; i>=idx; i--)
				pw.println(i+1);
		} else {
			pw.println("Impossible ");
		}
		
		pw.close();
		sc.close();
	}
}


Measured memory_bytes: 24908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*
識別番号の配列num[m]
市の数を数える配列check[n]
配列<年数、<県、市の番号>>をソート
check[p]を調べ、取り出した数をnumに格納。１を足してcheckに代入
*/

int digitnumber(int a){
    int tmp=1;
    while(a/10!=0) {
        tmp++;
        a = a/10;
    }
    return tmp;
}

string number(int a, int b){
    string s="";
    string t="";
    rep(i, 6-digitnumber(a)){
        s = "0" + s;
    }
    s = s + to_string(a);
    rep(i, 6-digitnumber(b)){
        t = "0" + t;
    }
    t = t + to_string(b);
    return s + t;
}

void solve(){
    int n,m;
    cin >> n >> m;
    string num[m+10];
    rep(i,m){
        num[i] = "";
    }
    int check[n+10];
    rep(i,n){
        check[i]=0;
    }
    vector<pair<int, pair<int,int>>> v;
    rep(i,m){
        int p,y;
        cin >> p >> y;
        v.emplace_back(make_pair(y, make_pair(p,i)));
    }

    sort(v.begin(), v.end());
    rep(i,m){
        int pnum = (v[i].second).first;
        int tmp = check[pnum-1];
        int nu = (v[i].second).second;
        num[nu] = number(pnum, tmp+1);
        check[pnum-1]++;
    }

    rep(i,m){
        cout << num[i] << endl;
    }

}

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


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e3+10;
const int MAX_CHECK = (1<<12) + 10;
int N, M;
int A[MAX], B[MAX], dp[MAX][MAX_CHECK];
vi C[MAX];

int solve() {
    int check = 0;
    REP (m, M)  {
        FORE (c, C[m]) check |= (1<<c);
    }
    if (check+1 != (1<<N)) return -1;

    dp[0][0] = 1;
    REP (m, M) {
      REP (i, 1<<N) dp[m+1][i] = 1e9;
        int c = 0;
        FORE (x, C[m]) {
            c += (1<<x);
        }

        REP (i, 1<<N) if (dp[m][i] != 0) {
            dp[m+1][i] = min(dp[m+1][i], dp[m][i]);
            dp[m+1][i|c] = min(dp[m+1][i|c], dp[m][i] + A[m]);
        }
    }
    return dp[M][(1<<N)-1]-1;
}

int main() {
    cin >> N >> M;
    REP (m, M) {
        cin >> A[m] >> B[m];
        REP (b, B[m]) {
            int c; cin >> c;
            C[m].push_back(c-1);
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define test(a) printf("(%3d)", a)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int MAXN = 5e4 + 10;

int n, m, a[MAXN];
int pos;

int bs (int val) {
    int st = 1, en = n, md;
    while (st + 1 < en) {
        md = (st+en)>>1;
        if (a[md] > val) en = md-1;
        else st = md;
    }
    if (a[en] <= val) return en;
    if (a[st] <= val) return st;
    else return 0;
}

int main (void) {
    while (~scanf("%d%d", &n, &m) & (n || m)) {
        for (int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
        }
        sort(a+1,a+n+1);
        int ans = 0;
        for (int i = 1; i < n+1; i++) {
            pos = bs(m-a[i]);
            if (pos && pos != i) ans = max(ans, a[pos]+a[i]);
        }
        if (ans == 0) printf("NONE\n");
        else printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int maxint=200001;
int p[maxint],a[maxint],c[maxint];
struct node{
	int pro;
	int zhi;
	int ma;
};
node b[maxint];
bool cmp(node x,node y){
	return x.pro<y.pro || x.pro==y.pro && x.zhi<y.zhi; 
}
int main(){
	cin >> n >> m;
	for (int i=1;i<=m;i++){
		cin >> p[i] >> a[i];
		b[i].ma=i;
		b[i].zhi=a[i];
		b[i].pro=p[i];
	}
	sort(b+1,b+1+m,cmp);
	int tmp=1;
	c[b[1].ma]=1;
	for (int i=2;i<=m;i++){
		tmp++;
		if (b[i].pro!=b[i-1].pro) tmp=1;
		c[b[i].ma]=tmp;
	}
	for (int i=1;i<=m;i++){
		printf("%06d%06d\n",p[i],c[i]);
	}
	return 0;
}

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

using namespace std;

double const PI = acos(-1);

int r;

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> r;

	cout << setprecision(10) << 2 * PI * r << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll a, b, x, ans = 0;
  cin >> a >> b >> x;

  ans = b / x;
  if (a >= 1) ans -= (a - 1) / x;
  if (a == 0) ans++;

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


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

int main(){
  int n;
  cin >> n;
  double a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  double ave = (a[0]+a[1])/2;
  for(int i=0;i<n-2;i++)
    ave = (ave + a[2+i])/2;
  cout << fixed << setprecision(6) << ave << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int card[4][14] ={0};

int main(void)
{
    int n, m, i, j;
    char s;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf(" %c %d", &s, &m);
         switch (s) {
         case 'S': card[0][m] = 1; break;
         case 'H': card[1][m] = 1; break;
         case 'C': card[2][m] = 1; break;
         case 'D': card[3][m] = 1; break;
         }
    }
    for (i = 0; i < 4; i++) {
        for (j = 1;  j < 14; j++) {
            if (card[i][j] == 0) {
                switch (i) {
                case 0: printf("S "); break;
                case 1: printf("H "); break;
                case 2: printf("C "); break;
                case 3: printf("D "); break;
                }
                printf("%d\n", j);
             }
         }
    }
}







Measured memory_bytes: 2032
#include<stdio.h>

int main(){
  int i;
  int j;
  int k;
  int key;
  int n;
  
  scanf("%d",&n);
  
  int  A[n];
  
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  for(k=0; k<n-1; k++)
      printf("%d ",A[k]);
    printf("%d\n",A[k]);
  
  for(i = 1; i<n; i++){
    key = A[i];
    j = i-1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    for(k=0; k<n-1; k++)
      printf("%d ",A[k]);
    printf("%d\n",A[k]);
  }
      
  return 0;
}



Measured memory_bytes: 2084
#!/usr/bin/env python

def InsertSort(N,A):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        print(*A)


if __name__ == "__main__":
    N=int(input())
    arr=list(map(int,input().split()))
    print(*arr)
    InsertSort(N,arr)

Measured memory_bytes: 6752
n=int(input())
path=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    path[a-1].append([b-1,c%2])
    path[b-1].append([a-1,c%2])
ans=[-1]*n
ans[0]=0
q=[0]
while q:
    nq=[]
    for k in q:
        for i,j in path[k]:
            if ans[i]==-1:
                ans[i]=(ans[k]+j)%2
                nq.append(i)
    q=nq[:]
for i in ans:print(str(i))

Measured memory_bytes: 41928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vector<vector<pl>> g(n);
    rep(i,n-1){
        ll a,b,c;cin >> a >>b >>c;
        a--;b--;
        g[a].pb(mp(b,c));
        g[b].pb(mp(a,c));
    }
    queue<ll> que;
    que.push(0);
    vl dist(n,-1);
    dist[0]=0;
    while(!que.empty()){
        ll v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(dist[nv.fi]!=-1)continue;
            dist[nv.fi]=dist[v]+nv.se;
            que.push(nv.fi);
        }
    }
    rep(i,n){
        if(dist[i]%2==0)cout << 0 <<endl;
        else cout << 1 <<endl;
    }
}


Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
const int N = 30000;
using namespace std;
bool a[N];
vector<int> prime;
void erast(){
	fill(a,a + N,true);
	a[0] = a[1] = false;
	for(int i = 2; i*i <= N;++i){
		if(a[i] == false)continue;
		for(int j = i*i; j<=N;j += i){
			a[j] = false;
		}
	}
	REP(i,N){
		if(a[i] == false)continue;
		prime.push_back(i);
	}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	erast();
	int m,a,b;
	while(cin>>m>>a>>b,m){
		int maxpq = 0,maxp = 0,maxq = 0;
		REP(i,prime.size()){
			for(int j = i;j < prime.size();j++){
				int p = prime[i],q = prime[j];
				if(p <= q && p * q <= m && a*q <= b*p && maxpq <= p*q){
					maxpq = p*q;
					maxp = p;
					maxq = q;
				}
			}
		}
		cout << maxp << ' ' << maxq << endl;
	}
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    if (N % 10 == 3) {
        cout << "bon" << endl;
    }
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int W, p;
vector<int> q[4];
int f(int x, long long y){
    int r = 0, t = 0;
    for(int i=0;i<=q[x].size();i++){
        long long z = y + i * (p + x);
        if(z > W)break;
        if(x < 3)t = f(x+1, z);
        else t = 0;
        if(i > 0)t += q[x][i-1];
        r = max(r, t);
    }
    return r;
}
int main() {
    int n, w, v;
    cin >> n >> W;
    for(int i=0;i<n;i++){
        cin >> w >> v;
        if(i == 0)p = w;
        q[w-p].push_back(v);
    }
    for(int i=0;i<4;i++){
        sort(q[i].begin(), q[i].end(), greater<int>());
        for(int j=1;j<q[i].size();j++){
            q[i][j] += q[i][j-1];
        }
    }
    
    cout << f(0, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>

using namespace std;

typedef long long ll;

typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;

int occs[(int)1e6 + 5], tree[500005], n, ans[500005];

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
{    
    int q, s, e;
    vector<node> v;
    scanf("%d %d", &n, &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    //scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
    
    sort(v.begin(), v.end());
    
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
    
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
    
    return 0;
}



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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#define long long ll
using namespace std;
int GCD(int a, int b);
int main(){
    int n; cin >> n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans=a[0];
    for(int i=1; i<n; i++){
        ans = GCD(ans,a[i]);
    }
    cout << ans << endl;
}
int GCD(int a,int b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return GCD(b,a%b);
}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
   int i, j, temp;
   int sort[3];

   scanf("%d %d %d", &sort[0], &sort[1], &sort[2]);
   for (i = 0; i < 2; i++) {
      for (j = i + 1; j < 3; j++) {
         if (sort[j]< sort[i]) {
            temp = sort[i];
            sort[i] = sort[j];
            sort[j] = temp;
         }
      }
   }
   printf("%d %d %d\n", sort[0], sort[1], sort[2]);

}

Measured memory_bytes: 1848
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int answer;
  if(N%2 == 0){
    for(int i=0;i<N;i += 2){
      answer += vec.at(i)-vec.at(i+1);
    }
  }
  else{
    for(int i=0;i<N-1;i += 2){
      answer += vec.at(i)-vec.at(i+1);
    }
    answer += vec.at(N-1);
  }
  
  cout << answer << endl;
}    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t="CODEFESTIVAL2016";
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i])cnt++;
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;

namespace abl_a
{
  class Program
  {
    static void Main(string[] args)
    {
      var K = CIn.ReadInt();

      var ans = "";
      for (int i = 0; i < K; i++)
      {
        ans += "ACL";
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(all(L), greater<int>());
  int res = 0;
  rep(i, K) res += L[i];
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, k, lt, rt=1e18, md, ans, a[200005], b[200005];

ll f(ll p) {
	ll i, s=0;
	for(i=0; i<n; i++) {
		s += max(0LL, (a[i] * b[i] - p + b[i] - 1) / b[i]);
		if(s > k) return 0;
	}
	return 1;
}

int main() {
	ll i;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	for(i=0; i<n; i++) scanf("%lld", &b[i]);
	sort(a, a+n, greater<ll>());
	sort(b, b+n);
	while(lt <= rt) {
		md = lt + rt >> 1;
		if(f(md)) ans = md, rt = md - 1;
		else lt = md + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const ll INF = 1LL<<60;

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    vector<ll> ans;
    rep(i,q){
        ll x;
        cin >> x;
        int pos1 = lower_bound(all(s), x) - s.begin();
        int pos2 = lower_bound(all(t), x) - t.begin();
        vector<ll> s1, t1;
        if (pos1 != 0) s1.push_back(s[pos1-1]);
        if (pos1 != a) s1.push_back(s[pos1]);
        if (pos2 != 0) t1.push_back(t[pos2-1]);
        if (pos2 != b) t1.push_back(t[pos2]);

        ll dis = INF;
        rep(i, s1.size()) rep(j, t1.size()){
            dis = min(dis, abs(x-s1[i]) + abs(s1[i] - t1[j]));
            dis = min(dis, abs(x-t1[j]) + abs(s1[i] - t1[j]));
        }
        ans.push_back(dis);
    }
    rep(i,q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5860
import numpy as np
import itertools

n, d = list(map(int, input().split()))
arr = np.array([list(map(int, input().split())) for _ in range(n)])

cnt = 0
for a, b in itertools.combinations(arr, 2):
    a = np.array(a)
    b = np.array(b)
    diff = a - b
    diff = diff ** 2
    distance = diff.sum() ** 0.5
    if distance == int(distance):
        cnt += 1
print(cnt)

Measured memory_bytes: 12428
# n = input()
a,b,k = map(int,raw_input().split())
 
if a>k :
    print a-k,b
elif a<k:
     
    k = k-a
     
    if k > b :
        print 0,0
    else:
        print 0,b-k
else:
    print 0,b

Measured memory_bytes: 2568
use proconio::{input, fastout};
use std::collections::HashMap;

fn prime_factors(n: usize) -> HashMap<usize, usize> {
    let mut map = HashMap::new();
    let mut n = n;

    for i in 2..=(n as f64).sqrt() as usize {
        while n % i == 0 {
            *map.entry(i).or_insert(0) += 1;
            n /= i;
        }
    }

    if n > 1 {
        map.insert(n, 1);
    }

    map
}


#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let factors = prime_factors(n);
    let mut count = 0;

    for &val in factors.values() {
        let mut e = val;
        for i in 1..=val {
            if e >= i {
                e -= i;
                count += 1;
            } else {
                break;
            }
        }
    }

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


Measured memory_bytes: 2184
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vector<int> ng(10);
  rep(i,t){
    int x;
    cin>>x; ng[x]=1;
  }
  reps(j,n,1000000){
    int f=0;
    for(int i=j;i;i/=10) if(ng[i%10]) f=1;
    if(!f){
      cout<<j<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5])cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
int a[N];
int main(){
	int n,k,i;ll s=0ll;
	scanf("%d%d",&n,&k);
	rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	rep(i,1,n)s+=a[i];
	rep(i,1,k)s-=a[i];
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

bool compare_by_b_ascending(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
} 

static const ll mod  = 1e9 + 7;
static const ll inf  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;
static const int NIL = -1;

void pvector(vector<int> A){
    //cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}
int N;
static const int MAX = 10000;
int color[MAX];
int cnt[MAX] = {0};
vector<int> v[MAX];
vector<int> c;

int next(int u){
    for(int i = cnt[u]; i < v[u].size(); i++){
        if(color[v[u][i]] == White){
            cnt[u] = i + 1;
            return v[u][i];
        }
    }
    return NIL;
}

vector<int> ans(MAX);

void dfs(int root, int point){
    stack<int> S;
    S.push(root);
    int u = root;
    //int v = next(u, V);
    while(!S.empty()){
        u = S.top();
        //cout << u << endl;
        color[u] = Gray;
        int V = next(u);
        //cout << V << endl;
        if(V != NIL){
            if(color[V] == White){
                S.push(V);
            }
        }else{
            color[u] = Black;
            S.pop();
            ans[u] = c[point];
            point++;
            //cout << point << endl;
        }
    }
}

void dfs_init(){
    REP(i,N) color[i] = White;
    REP(i,N){
        if(color[i] == White) dfs(i,0);
    }
}

int main(){
    cin >> N;
    REP(i, N-1){
        int a, b;
        cin >>  a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    REP(i,N){
        int t;
        cin >> t;
        c.push_back(t);
    }
    sort(ALL(c));
    dfs_init();

    ll mscore = 0;
    REP(i,N-1){
        mscore += c[i]; 
    }
    p(mscore);
    REP(i,N){
        if( i != N-1) cout << ans[i] << ' ';
        else cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include <stdio.h>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

int main(void)
{
	int A, B;
	cin >> A >> B;
	int ans = (A - 1) * (B - 1);
	cout << ans;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

string x, y, z;
int a, b;

void solve(){
	cin >> x >> y >> a >> b >> z;

	if (x == z)
		a--;
	else
		b--;

	cout << a << " " << b;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = vec![0; n];
    for _ in 0..n - 1 {
        let a: usize = itr.next().unwrap().parse().unwrap();
        ans[a - 1] += 1;
    }
    let mut out = Vec::new();
    for i in 0..n {
        writeln!(out, "{}", ans[i]).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
 
int main(){
  double R; cin >> R;
  cout << 2.0*R*M_PI <<endl;
  return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>
#include <iomanip>

using namespace std;

long long maxof(long long* N, int p){
    long long big = N[0];
    for(int i = 0; i < p; i++){
        if(big < N[i]){
            big = N[i];
        }
    }
    return big;
}

long long pow2(int a, int b){
    long long ans = 1;
    for(int i = 0; i <b; i++){
        ans *= a;
    }
    return ans;
}

int main(){
    int n = 0;
    cin >> n;
    string s;
    cin >> s;
    int l[10] = {-1};
    int r[10] = {-1};
    for(int i = 0; i < 10; i++){
       l[i] = -1;
       r[i] = -1; 
    }
    for(int i = 0; i < n; i++){
        int cur = s[i] - '0';
        r[cur] = i;
    }
    for(int i = n-1; i >= 0; i--){
        int cur = s[i] - '0';
        l[cur] = i;
    }
    /*
    for(int i = 0; i < 10; i++){
        cout << i << "   " <<  l[i] << " " << r[i] << endl; 
    }
    */
    int ans = 0;
    for(int o = 0; o < 10; o++){
        for(int t = 0; t < 10; t++){
            for(int c = 0; c < 10; c++){
                int le = l[o];
                int ri = r[c];
                if(le == -1 || ri == -1) continue;
                for(int i = le + 1; i < ri; i++){
                    if(s[i]- '0' == t){
                        ans+= 1;
                        //cout << o << t <<c << endl;
                        break;
                    }
                }
            }
        }
    }
    
    cout << ans;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t[] = new int[5];

        t[0] = scan.nextInt();
        t[1] = scan.nextInt();
        t[2] = scan.nextInt();
        t[3] = scan.nextInt();
        t[4] = scan.nextInt();
        int g;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;

                }
            }
        }

        System.out.println(t[0] + " " + t[1] + " " + t[2] + " " + t[3] + " " + t[4]);

    }
}



Measured memory_bytes: 26208
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
inline int in() { char ch = getchar();int x = 0, f = 1;while (ch<'0' || ch>'9') { if (ch == '-')f = -1;ch = getchar(); }while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0';ch = getchar(); }return x * f; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 1e6+5;
bool vis[N+1];
ll p[N+1], cnt;
void x_x()
{
	f(i, 2, N)
	{
		if (!vis[i])p[++cnt] = i;
		for (int j = 1;p[j] <= N / i;j++)
		{
			vis[p[j] * i] = true;
			if (i%p[j] == 0)break;
		}
	}
}
vector<int> G[N+1];
int a[N+1];
int main()
{
	//freopen("in.txt", "r", stdin);
	x_x();
	int n;n = in();
	f(i, 1, n)a[i] = in();
	map<int, int> mp;
	int fg = 1;
	f(i, 1, n)
	{
		for (int j = 1;p[j] * p[j] <= a[i];j++)
		{
			if (a[i] % p[j] == 0)
			{
				int cot = 0;
				while (a[i] % p[j] == 0)
				{
					a[i] /= p[j];
					cot++;
				}
				mp[p[j]]++;
				if (G[p[j]].empty())G[p[j]].emplace_back(a[i]);
				else fg = 0;
			}
		}
		if (a[i] > 1)
		{
			mp[a[i]]++;
			if (G[a[i]].empty())G[a[i]].emplace_back(a[i]);
			else fg = 0;
		}
	}
	if (fg)puts("pairwise coprime");//两两可以
	else
	{
		int mx = 0;
		for (auto i : mp)
		{
			if (i.second == n)
			{
				mx = 1;break;
			}
		}
		if (mx==1)puts("not coprime");
		else puts("setwise coprime");
	}
	return 0;
}

Measured memory_bytes: 38632
n = int(input())
a = list(map(int,input().split()))
b = []
status = 0

for i in range(n):
    if a[i] % 2 == 0:
        b.append(a[i])

for j in range(len(b)):
    if b[j] % 3 == 0 or b[j] % 5 == 0:
        pass
    else:
        status = 1

if status == 1:
    print("DENIED")
else:
    print("APPROVED")


Measured memory_bytes: 3060
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =3e5+6;
void solve(){
	ll n,m,x;
	cin>>n>>m>>x;
	ll arr[n][m];
	ll cost[n];
	ll ans=inf;
	for ( ll i=0;i<n;i++){
		cin>>cost[i];
		for ( ll j=0;j<m;j++)
			cin>>arr[i][j];
	}
	for ( ll i=0;i<powm( 2,n);i++){
		ll j=0;
		ll brr[m];
		memset( brr,0,sizeof ( brr));
		ll k=i;
		ll c=0;
		while ( k){
			if ( k&1){
				c+=cost[j];
				for ( ll l=0;l<m;l++)
					brr[l]+=arr[j][l];
			}
			k>>=1;
			j++;
		}
		bool bo=true;
		for ( ll l=0;l<m;l++)
			if ( brr[l]<x)
				bo=false;
		if ( bo)
			ans=min(ans, c);
	}
	if ( ans==inf)
		cout<<-1<<'\n';
	else
		cout<<ans<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
//	#ifndef ONLINE_JUDGE
//		cin.tie(NULL);
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

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

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

	A := make([]int, N+1)
	B := make([]int, N)
	for i := 0; i < N+1; i++ {
		fmt.Scan(&A[i])
	}

	c := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&B[i])

		m := min(A[i], B[i])
		A[i] -= m
		B[i] -= m
		c += m

		m = min(A[i+1], B[i])
		A[i+1] -= m
		c += m
	}
	fmt.Println(c)
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define INF 2000000009

int main(){
  int n,s;
  int t[200009];
  cin>>n>>s;
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  t[n]=INF;
  int ans=0;
  for(int i=0;i<n;i++){
    if(t[i+1]-t[i]<s){
      ans+=t[i+1]-t[i];
    }
    else{
      ans+=s;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
from math import factorial
mod = 10**9+7

if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    print(factorial(N)*factorial(M)%mod)
else:
    print(2*factorial(N)*factorial(M)%mod)




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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    if (n == 2) {
        if (v[0] == v[1]) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    } else {

        unordered_map<int, int> m1, m2;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0)
                m1[v[i]]++;
            else
                m2[v[i]]++;
        }

        int cnt1 = 0, cnt2 = 0;
        int e1 = -1, e2 = -1;

        for (auto itr = m1.begin(); itr != m1.end(); itr++) {
            if (itr->second > cnt1) {
                cnt1 = itr->second;
                e1 = itr->first;
            }
        }
        for (auto itr = m2.begin(); itr != m2.end(); itr++) {
            if (itr->second > cnt2) {
                cnt2 = itr->second;
                e2 = itr->first;
            }
        }

        if (e1 != e2) {
            cout << n - cnt1 - cnt2 << endl;
        } else {
            m1.erase(e1);
            m2.erase(e2);

            int c1 = 0, c2 = 0;

            for (auto itr = m1.begin(); itr != m1.end(); itr++) {
                if (itr->second > c1) {
                    c1 = itr->second;
                }
            }
            for (auto itr = m2.begin(); itr != m2.end(); itr++) {
                if (itr->second > c2) {
                    c2 = itr->second;
                }
            }

            cout << (n - c1 - cnt2 < n - cnt1 - c2 ? n - c1 - cnt2 : n - cnt1 - c2) << endl;
        }
    }
}

Measured memory_bytes: 4760
#include <stdio.h>
#include <algorithm>

int N, M, A[112];

int main(void) {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }
	
	for (int k = 1; k <= M; ++k) {
		for (int i = 0; i < N - 1; ++i) {
			if (A[i] % k > A[i + 1] % k) {
				std::swap(A[i], A[i + 1]);
			}
		}
	}
	
	for (int i = 0; i < N; ++i) { printf("%d\n", A[i]); }
	return 0;
}

Measured memory_bytes: 2696
n, k, q = map(int, input().split())
a = [0] + list(int(input()) for _ in range(q))
p = [k - q] * (n + 1)

for i in range(1, q + 1):
    p[a[i]] += 1
    
for j in range(1, n + 1):
    if p[j] > 0:
        print('Yes')
    else:
        print('No')   

Measured memory_bytes: 15400
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  combination c(n);

  mint ans(0);
  mint mm(m);
  rep(i,k+1) {
    ans += c(n-1,i) * mm * (mm-1).pow(n-i-1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6312
#include <algorithm>
#include <cstdio>
typedef long long ll; 
int a[200005], b[200005], idx[200005]; 
inline bool comp(int x, int y)
{
	return a[x] < a[y]; 
}
int main()
{
	// freopen("ARC073-E.in", "r", stdin); 
	int n, mx = 0, mn = 1e9, mn_opp, mx_opp; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", a + i, b + i); 
		idx[i] = i; 
		if (a[i] > b[i])
			std::swap(a[i], b[i]); 
		if (a[i] < mn)
		{
			mn = a[i]; 
			mn_opp = b[i]; 
		}
		if (b[i] > mx)
		{
			mx = b[i]; 
			mx_opp = a[i]; 
		}
	}
	int cur_mx = mx_opp, cur_mn = mn_opp; 
	for (int i = 0; i < n; i++)
	{
		cur_mx = std::max(cur_mx, a[i]); 
		cur_mn = std::min(cur_mn, b[i]); 
	}
	ll ans = (ll)(mx - cur_mn) * (cur_mx - mn); 
	std::sort(idx, idx + n, comp); 
	int cur = 1e9;
	for (int i = 0; i < n; i++)
	{
		ans = std::min(ans, (ll)(mx - mn) * (cur_mx - std::min(a[idx[i]], cur))); 
		cur = std::min(cur, b[idx[i]]); 
		cur_mx = std::max(cur_mx, b[idx[i]]); 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }


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

  ll q=lcm(a,b);
  cout<<q<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint d(k);
    rep(i, k) cin >> d[i];

    int ans = n;
    bool c = true;
    while (c) {
        c = false;
        string s = to_string(ans);
        rep(i, s.length()) {
            rep(j, k) {
                if (s[i] == d[j]+'0') c = true;
            }
        }
        if (c) ans++;
    }

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

Measured memory_bytes: 256