akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)

const int MN = 1000000;

P tree[MN];//tree[頂点番号]={子左,子右};
P value[MN];//value[頂点番号]={xの値,yの値};
int ind=1,root=1;

int n;
auto fx = [](P &a,P &b){return (a.first<b.first);};//x小さい順
auto fy = [](P &a,P &b){return (a.second<b.second);};//y小さい順

void make_tree(int p,vector<P> data,int depth,bool leftc){
	sort(data.begin(), data.end(),(depth%2?fy:fx));//0x 1y
	int mid = data.size();mid/=2;
	if(leftc){
		tree[p].first = ind;
		value[ind] = data[mid];
	}else{
		tree[p].second = ind;
		value[ind] = data[mid];
	}
	int pp = ind;
	ind++;
	vector<P> datal,datar;
	FOR(i,0,mid)datal.push_back(data[i]);
	FOR(i,mid+1,data.size())datar.push_back(data[i]);
	data.clear();
	if(datal.size())make_tree(pp,datal,depth+1,true);
	if(datar.size())make_tree(pp,datar,depth+1,false);
}

vector<P> ans;
int sx,tx,sy,ty;
void calc(int ind,int dep){
	int x = value[ind].first;
	int y = value[ind].second;
	if(sx<=x&&x<=tx && sy<=y&&y<=ty){
		ans.push_back({x,y});
		if(~tree[ind].first)calc(tree[ind].first,dep+1);
		if(~tree[ind].second)calc(tree[ind].second,dep+1);
		return;
	}
	if(dep&1){//y
		if(~tree[ind].first){
			if(value[ind].second>=sy)calc(tree[ind].first,dep+1);
		}
		if(~tree[ind].second){
			if(value[ind].second<=ty)calc(tree[ind].second,dep+1);
		}
	}else{//x
		if(~tree[ind].first){//-1じゃない
			if(value[ind].first>=sx)calc(tree[ind].first,dep+1);
		}
		if(~tree[ind].second){
			if(value[ind].first<=tx)calc(tree[ind].second,dep+1);
		}
	}
}


int main(){

	FOR(i,0,MN)tree[i]=value[i]={-1,-1};
	cin >> n;
	vector<P> xy(n);
	FOR(i,0,n)cin>>xy[i].first>>xy[i].second;
	map<P,int> ma;
	FOR(i,0,n)ma[xy[i]] = i;
	make_tree(0,xy,0,true);
	/*FOR(i,0,7){
		cout << "i:" << i << " " << tree[i].first << " " << tree[i].second << " : " << value[i].first << " " << value[i].second << endl;
	}*/
	int q;
	cin >> q;
	FOR(i,0,q){
		ans.clear();
		cin >> sx >> tx >> sy >> ty;
		if(n)calc(1,0);
		vector<int> ansi;
		for(P x:ans)ansi.push_back(ma[x]);
		sort(ansi.begin(), ansi.end());
		for(int i:ansi) cout << i << '\n';
		cout << '\n';
	}
}


Measured memory_bytes: 68024
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int p[50],q[50];
    for(int i=0; i<N; i++){
        cin >> p[i];
        q[i]=p[i];
    }
    sort(q,q+N);
    int num=0;
    for(int i=0; i<N; i++){
        num += p[i]!=q[i];
    }
    if(num<=2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    a,b = input().split()
    l.append((a,int(b),i+1))

l.sort(key = lambda x: x[0])

l1 = []
count = 0
left = 0
while n > count:
    
    l1 = []
    a = l[count][0]

    while l[count][0] == a:
        l1.append((l[count][1],l[count][2]))
        count += 1
        if count == n:
            break
    
    l1.sort(key = lambda x: x[0], reverse=True)
    
    for b,c in l1:
        print(c)


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI v(n, -1);
	
	
	bool ok=true;
	rep(i, m){
		int s, c;
		cin >>s >>c;
		s--;
		if(v[s] != -1 && v[s] != c ) ok=false;
		if(s==0 && c==0 && n>1) ok=false;
		v[s] = c;
		
	}
	
	rep(i, n){
		if(v[i]==-1) v[i] = i? 0: 1;
	}
	if(!ok) cout<<"-1\n";
	else if(n==1 && m==0){ cout<<"0\n";}
	else { rep(i, n) cout <<v[i]; cout<<"\n";}
	return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
        cout<<r+100*(10-n)<<endl;
    }
    
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)
 

def swap_time(array0, array1):
    n = len(array0)
    memo = {}
    for i in range(n)[::-1]:
        if array0[i] not in memo:
            memo[array0[i]] = []
        memo[array0[i]].append(i)
    res = []
    for val in array1:
        ind = memo[val].pop()
        res.append(ind)
    
    bit = BIT(n)
    ans = 0
    for i in range(n):
        bit.add(res[i], 1)
        ans += bit.get_sum(res[i] + 1, n)
    return ans
  
  

ALPH = "abcdefghijklmnopqrstuvwxyz"
s = input()

cnt_memo = {}
for char in s:
    if char not in cnt_memo:
        cnt_memo[char] = 1
    else:
        cnt_memo[char] += 1

odd = ""
for char in cnt_memo:
    if cnt_memo[char] % 2 == 1:
        if odd:
            print(-1)
            exit()
        else:
            odd = char
            cnt_memo[char] -= 1
            cnt_memo[char] //= 2
    else:
        cnt_memo[char] //= 2

left = []
mid = []
if odd:
    mid = [odd]
right = []
for char in s:
    if odd == char and cnt_memo[char] == 0:
        odd = ""
    elif cnt_memo[char] != 0:
        left.append(char)
        cnt_memo[char] -= 1
    else:
        right.append(char)

ans = 0
ans += swap_time(left + mid + right, list(s))
ans += swap_time(left, right[::-1])
print(ans)

Measured memory_bytes: 83660
#include<iostream>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int c(0);
  for(int i(1);i<=N;i++){
    if(i%2==1){
      int a(0);
      for(int j(1);j<=i;j++){
        if(i%j==0)a++;
      }
      if(a==8)c++;
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		String str = s.nextLine();
		String[] sp = str.split(" ");
		int[] year = { 1, 9, 4, 7 };

		boolean check1947 = true;
		for (int j = 0; j < year.length; j++) {
			boolean checkNo = false;
			for (int i = 0; i < sp.length; i++) {
				if (Integer.parseInt(sp[i]) == year[j])
					checkNo = true;
			}
			check1947 = check1947 && checkNo;
		}
		if (check1947)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 22996
n = int(input())
a, b = [list(map(int, input().split())) for _ in range(2)]

tmp, cnt = 0, 0
for i in range(n):
    tmp = min(a[i] - tmp, b[i])
    cnt += tmp
    tmp = min(a[i + 1], b[i] - tmp)
    cnt += tmp
print(cnt)

Measured memory_bytes: 24184
#include <bits/stdc++.h>
using namespace std;
int main(){
    int pos1, pos2;
    string s;
    cin>>s;
    pos1 = 0; pos2 = s.size() - 1;
    while(pos2 > pos1){
        if(s[pos1] == 'x') pos1++;
        else if(s[pos2] == 'x') pos2--;
        else{
            if(s[pos1] != s[pos2]){
                cout<<-1<<endl;return 0;
            }
            pos1++;pos2--;
        }
    }
    int ans = 0;
    pos1 = 0; pos2 = s.size() - 1;
    while(pos2 > pos1){
        if(s[pos1] == s[pos2]){pos1++;pos2--;continue;} 
        if(s[pos1] == 'x'){
            ans++;
            pos1++;
        }
        else{
            ans++;
            pos2--;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

struct node{
  int key;
  struct node *p;
  struct node *right;
  struct node *left;
};
typedef struct node * Node;

Node root, NIL;
int max;

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

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

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

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

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

void in(Node n){
  if (n == NIL) return;
  in(n -> left);
  printf(" %d", n -> key);
  in(n -> right);
}
void out(Node n){
  if ( n == NIL ) return;
  printf(" %d",n -> key);
  out(n -> left);
  out(n -> right);
}

int main(){
  int l,i,s;
  char M[20];
  scanf("%d",&l);
  max = 0;
  for(i=0 ; i<l ; i++){
    scanf("%s",M);
    if(M[0] == 'f'){
      scanf("%d",&s);
      Node t = treeSearch(root, s);
      if(t != NIL){printf("yes\n");
    }
      else{
        printf("no\n");
      }
    }
    else if(M[0] == 'i'){
      scanf("%d",&s);
      insert(s);
    } else if(M[0] == 'p'){
      in(root);
      printf("\n");
      out(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20516
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
 
main(){
  int n,q;
  cin>>n;
  vector<int>v(n);
  r(i,n)cin>>v[i];
  cin>>q;
  while(q--){
    int a,l,r,s=0;
    cin>>l>>r>>a;
    for(;l<r;l++)s+=v[l]==a;
      cout<<s<<endl;
  }
}


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

int main() {
    int P, Q , R , A ;
    cin >> P >> Q >> R ; // 1 ≤ P,Q,R ≤ 100
    A = P + Q + R - max({P,Q,R});
    cout << A; 
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  if (s.at(0) == '1') count++;
  if (s.at(1) == '1') count++;
  if (s.at(2) == '1') count++;
  
  cout << count << endl;

}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
const int maxn = 1e6+10;

int m,n;
int main()
{
	long long x,y,j,ans=0;
	cin>>x>>y;
	j=x;
	while(j<=y)
	{
		j*=2;
		ans++;
	}
	cout<<ans;
}

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

typedef struct{
	int x;
	int y;
}point;

int main(){
	while(1){
		int h, w;
		char f[101][101];
		
		scanf(" %d %d", &h, &w);
		if(h==0) break;
		for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
		scanf(" %c", &f[i][j]);
		
		int ans=0;
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				if(f[i][j]=='-') continue;
				else{
					//printf(" %d %d\n", i, j);
					++ans;
					
					//bfs
					int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
					char fruit=f[i][j];
					point s;
					s.x=j; s.y=i;
					f[i][j]='-'; //訪問済み
					
					queue<point> que;
					que.push(s);
					while( !que.empty() ){
						point v=que.front();
						que.pop();
						for(int k=0; k<4; ++k){
							int nx=v.x+dx[k], ny=v.y+dy[k];
							if(nx>=0 && nx<w && ny>=0 && ny<h && f[ny][nx]==fruit){
								f[ny][nx]='-';	
								point tmp;
								tmp.x=nx; tmp.y=ny;
								que.push(tmp);
							}		
						}
						
					}
				}		
				
				/*
				for(int ii=0; ii<h; ++ii){
					for(int jj=0; jj<w; ++jj){
						printf("%c", f[ii][jj]);
					}
					printf("\n");
				}
				*/
			}
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <map>
#include <string>

int main() {
  int N, i;
  std::cin >> N;
  
  std::map<std::string, int> mp;
  std::string word;
  for (i = 0; i < N; i++) {
    std::cin >> word;
    if (mp.count(word)) {
      mp[word] += 1;
    } else {
      mp.insert(std::make_pair(word, 1));
    }
  }
  
  int max = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (max < itr->second) {
      max = itr->second;
    }
  }
  
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second == max) {
      std::cout << itr->first << std::endl;
    }
  }
}

Measured memory_bytes: 17664
def resolve():
    import collections
    N = int(input())
    A = list(map(int, input().split()))
    d = collections.OrderedDict([
        (400, 0),
        (800, 0),
        (1200, 0),
        (1600, 0),
        (2000, 0),
        (2400, 0),
        (2800, 0),
        (3200, 0)
    ])
    other = 0
    for a in A:
        for th in d:
            if a < th:
                d[th] += 1
                break
        else:
            other += 1
    mincolor = 0 if other != N else 1
    for th in d:
        if d[th] > 0:
            mincolor += 1
    maxcolor = mincolor+other if other != N else other
    print("{} {}".format(mincolor, maxcolor))
    

if '__main__' == __name__:
    resolve()

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

void dfs(int,long long,long long);
long long ctoll(char);

long long ans;

string s;

int main(){

    cin>>s;
    dfs(0,0,0);
    cout<<ans<<endl;



    return 0;
}

void dfs(int i,long long sum,long long next){

    long long num=ctoll(s[i])+next;

    if(i==s.size()-1){
        ans+=sum+num;
        return;
    }

    dfs(i+1,sum+num,0);
    dfs(i+1,sum,num*10);

    return;

}

long long ctoll(char c){
    return c-'0';
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int K,T;

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

	cin >> K >> T;
	vector<int> A(T);
	FOR(i,0,T){
		cin >> A [i];
	}

	int mx = *max_element(ALL(A));
	int other = K - mx;

	int ans = max(0,mx - other - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int cnt[100005] = {0};
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    sum += a[i];
    cnt[a[i]]++;
  }
  int q;
  cin >> q;
  while (q--)
  {
    int b, c;
    cin >> b >> c;
    int f = cnt[b];
    sum += (c - b) * f;
    cnt[b] = 0;
    cnt[c] += f;
    cout << sum << endl;
  }

}

Measured memory_bytes: 5176
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	char s[101]; cin >> s;
	ll cnt = 0, i = 0;;
	while (s[i++]) {
		cnt++;
	}
	cout << s[0] << cnt - 2 << s[cnt - 1] << endl;
}

Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())
ans=[]
x3=x2-y2+y1
y3=y2+x2-x1
ans.append(x2-y2+y1)
ans.append(y2+x2-x1)
ans.append(x3-y3+y2)
ans.append(y3+x3-x2)
print(*ans)


Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF ((int)(1e9))
#define LINF ((ll)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%I64d ",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
struct InputReader{
    static const int bs = 1000000;
    char buf[bs];
    int p;
    InputReader():p(bs) {}
    void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
    int operator() (){
        int ans = 0;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans;
    }
    void nextlet( int &x ){
    	char ch = c();
    	while( ch < 'a'  ||  ch > 'z' ) ch = c();
    	if( ch == 'c' ) x = 1;
    	if( ch == 'd' ) x = 2;
    	if( ch == 'q' ) x = 3;
	}
	ll readll(){
		ll ans = 0LL;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read2( int &x, int &y ){
	x = in(); y = in();
}
il void read3( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
/*********************************************************************/
/*********************************************************************/
#define MAXN 200100

int n , m;
int d;
map<int,int> have;
int main(){
	//fin("B.in");
	read(n);
	for( int i = 1 ; i <= n ; i++ ){
		read(d);
		have[d]++;
	}
	read(m);
	for( int i = 1 ; i <= m ; i++ ){
		read(d);
		have[d] = have[d]-1;
		if( have[d] < 0 ){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


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

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

const double PI = acos(-1);

int main(){
  
  cout << fixed << setprecision(20);
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double hh = 30.0*h+m/2.0,mm = m*6;
  double k = abs(hh-mm);
  cout << sqrt(a*a+b*b-2*a*b*cos(k*PI/180)) << endl;
  
  
  
  
  return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
using vec2div = vector<vector<long long>>;
using vec = vector<long long>;

int main(){
	long double a,b;
	cin >> a >> b;
	//cout << a << ' ' <<  b << endl;
  	long long seki = a*b;
	cout << seki << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

using Graph = vvll;
/* LCA(G, root): 木 G に対する根を root として Lowest Common Ancestor を求める構造体
    query(u,v): u と v の LCA を求める。計算量 O(logn)
    前処理: O(nlogn)時間, O(nlogn)空間
*/
struct LCA {
    vector<vector<int>> parent;  // parent[k][u]:= u の 2^k 先の親
    vector<int> dist;            // root からの距離
    LCA(const Graph &G, int root = 0) { init(G, root); }
    // 初期化
    void init(const Graph &G, int root = 0) {
        int V = G.size();
        int K = 1;
        while ((1 << K) < V) K++;
        parent.assign(K, vector<int>(V, -1));
        dist.assign(V, -1);
        dfs(G, root, -1, 0);
        for (int k = 0; k + 1 < K; k++) {
            for (int v = 0; v < V; v++) {
                if (parent[k][v] < 0) {
                    parent[k + 1][v] = -1;
                } else {
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }
    // 根からの距離と1つ先の頂点を求める
    void dfs(const Graph &G, int v, int p, int d) {
        parent[0][v] = p;
        dist[v] = d;
        for (auto e : G[v]) {
            if (e != p) dfs(G, e, v, d + 1);
        }
    }
    int query(int u, int v) {
        if (dist[u] < dist[v]) swap(u, v);  // u の方が深いとする
        int K = parent.size();
        // LCA までの距離を同じにする
        for (int k = 0; k < K; k++) {
            if ((dist[u] - dist[v]) >> k & 1) {
                u = parent[k][u];
            }
        }
        // 二分探索で LCA を求める
        if (u == v) return u;
        for (int k = K - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};


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

    ll n; cin >> n;
    Graph g(n);
    rep(i, n) {
        ll k; cin >> k;
        if(k > 0) {
            rep(j, k) {
                ll c; cin >> c;
                g[i].push_back(c);
                g[c].push_back(i);
            }
        }
    }

    LCA lca(g);
    lca.init(g);

    ll q; cin >> q;
    rep(i, q) {
        ll u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
}



Measured memory_bytes: 19360
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::Ordering;

#[derive(Eq)]
struct Data {
    name: String,
    score: u32,
    id: u32
}

impl Ord for Data {
    fn cmp(&self, other: &Self) -> Ordering {
        let result_name = self.name.cmp(&other.name);
        if result_name != Ordering::Equal {
            return result_name;
        }
        let result_score = other.score.cmp(&self.score);
        if result_score != Ordering::Equal {
            return result_score;
        }
        self.id.cmp(&other.id)
    }
}

impl PartialOrd for Data {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl PartialEq for Data {
    fn eq(&self, other: &Self) -> bool {
        self.name == other.name &&
            self.score == other.score &&
            self.id == other.id
    }
}

fn main() {
    let n = read();
    let mut v: Vec<Data> = (0..n)
        .map(|i| {
            Data {
               name: read::<String>(),
               score: read::<u32>(),
               id: i + 1
           }
       }).collect();
    v.sort();
    for a in v {
        println!("{}", a.id);
    }
}


Measured memory_bytes: 4352
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

    
def main():
    n,m = na()
    mod = 1000000007
    ans = 0
    pm = 1
    nCk = 1
    tmp = 1
    for i in range(m-n+1,m+1):
        tmp *= i*i
        tmp %= mod
    for k in range(n+1):
        ans += pm*nCk*tmp
        ans %= mod
        pm *= -1
        nCk *= (n-k)*pow(k+1,mod-2,mod)
        nCk %= mod
        tmp *= pow(m-k,mod-2,mod)  
        tmp %= mod
    print(ans)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 67668
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long k;
	cin >> k;
	priority_queue<pair<long double,long long>, vector<pair<long double,long long>>, greater<pair<long double,long long>>> hoge;
	for (int i = 0; i < 15; ++i) {
		for (int q = 1; q <= 1000; ++q) {
			string s = to_string(q);
			for (int j = 0; j < i; ++j) {
				s += "9";
			}
			long long geko = stoll(s);
			long double valuing = stold(s);
			long double bunsi = 0;
			for (int q = 0; q < s.length(); ++q) {
				bunsi += s[q] - '0';
			}
			hoge.push(make_pair(valuing / bunsi,geko));
		}
	}
	long long cnt = 0;
	while (hoge.empty() == false) {
		long long pepe = hoge.top().second;
		hoge.pop();
		if (cnt < pepe) {
			cnt = pepe;
			cout << cnt << endl;
			k--;
			if (k == 0) {
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
        using namespace std;
        long long m=1000000007;
     
        #define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define MAX(a,b) ((a)>(b)?(a):(b))
        #define MIN(a,b) ((a)<(b)?(a):(b))
        #define pb  push_back
        #define p2  second
        #define p1  first
        typedef long long ll;
        typedef long double ld; 
        long long M=1e9+7;			
        #define deb_(x)       cerr<< #x <<" : "<< x << endl;
        #define deb(A,N)    cerr <<" :[";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
        #define deb2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}																				
        #define rep(n) for(int i=0;i<n;i++)																		
        #define range(a,b) for(int i=a;i<=b;i++)																	
        #define loop(i,n) for(int i=0;i<n;i++)
    	void code();
     
        int main()
        {   
        	boost;
           ll t=1;
           // cin>>t;
           while(t--){
           	code();
           }
         
           return 0;
        }
     
       
        void code(){
        	ll n;
        	cin>>n;
        	ll A[n];
        	rep(n)cin>>A[i];
        	ll dp[n];
        	dp[0]=0;
        	dp[1]=abs(A[1]-A[0]);
        	range(2,n-1){
        		dp[i]=MIN(dp[i-1]+abs(A[i-1]-A[i]), dp[i-2]+abs(A[i-2]-A[i]));

        	}
        	// deb(dp,n);
        	cout<<dp[n-1]<<endl;

       	
        }

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

// xorの掃き出し法をするためのクラス
// matに基底たちが入る
// Tはbitsetは無理(minしないといけないから)
template <typename T>
class BitLinearSpace {
    vector<T> bases; // この中身をsortしちゃうと壊れる

public:
    BitLinearSpace() = default;
    BitLinearSpace(vector<T> &matrix) {
        for (auto &mi:matrix) {
            add_val(mi, false);
        }
    }

    // valが張れるように基底を追加する
    // 追加した場合true, しなかった場合false
    // O(N) (ソートするとNlogN)
    // 追加後にソートするかを選ぶ
    bool add_val(T val) {
        if ((val = elementary_opperation(val))) {
            bases.push_back(val);
            return true;
        } else {
            return false;
        }
    }

    // 今のベクトル空間にvalが含まれるか(=basesの要素のxorでvalが作れるかをチェック)
    // O(n)
    bool includes(T val) {
        return elementary_opperation(val) == 0;
    }

    // 行列にvalを追加するていで行基本変形をvalに施す
    // 実際には追加しない
    // O(n)
    T elementary_opperation(T val) {
        for (auto &b:bases) {
            val = min(val, val ^ b);
        }
        return val;
    }

    T &operator[](int i) { return bases[(size_t)i]; }
    const T &operator[](int i) const { return bases[(size_t)i]; }

    auto begin() { return bases.begin(); }
    auto end() { return bases.end(); }
    auto begin() const { return bases.begin(); }
    auto end() const { return bases.end(); }

    int size() { return (int)bases.size(); }
};

int main() {
    int n;
    cin >> n;
    BitLinearSpace<ll> bls;
    ll sum = 0;
    for (int i=0; i<n; i++) {
        ll ai; cin >> ai;
        sum ^= ai;
        bls.add_val(ai);
    }
    vector<ll> bases(bls.begin(), bls.end());
    ll blue = 0, red = sum;
    for (int i=59; i>=0; i--) {
        if ((blue & (1ll << i)) == (red & (1ll << i))) {
            ll used = -1;
            for (auto &bi:bases) {
                if (bi & (1ll << i)) {
                    if (used < 0) {
                        if ((blue & (1ll << i)) == 0)
                            blue ^= bi;
                        used = bi;
                    }
                    bi ^= used;
                }
            }
        }
        red = blue ^ sum;
    }
    cout << blue + red << '\n';
    return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
c=[]
for i in range(n):
    x,y,a=map(int,input().split())
    c.append([x,y,a])
s=w*h
ans=0
for j in range(s):
    x=j%w
    y=j//w
    t=0
    for i in range(n):
        if c[i][2]==1:
            if x<c[i][0]:
                t+=1
                break
        if c[i][2]==2:
            if x>=c[i][0]:
                t+=1
                break
        if c[i][2]==3:
            if y<c[i][1]:
                t+=1
                break
        if c[i][2]==4:
            if y>=c[i][1]:
                t+=1
                break
    if t==0:
        ans+=1
print(ans)

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

const int N = 1e5+10;
int ar[3] = {N,N,N},dp[3] = {0,N,N},n;

int main(){
	cin>>n>>ar[0];

	int j,i;
	for(j = 1;j < n;j++){
		i = j%3;
		cin>>ar[i];
		dp[i] = min(abs(ar[i]-ar[((i-2)+3)%3])+dp[((i-2)+3)%3],abs(ar[i]-ar[((i-1)+3)%3])+dp[((i-1)+3)%3]);
	}
	
	cout<<dp[i]<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
bool vis[N];
string ss="ABC";
int main()
{
    string s;cin>>s;
    if(s[1]=='B') s[1]='R';
    else s[1]='B';
    cout<<s<<endl;
}


Measured memory_bytes: 3568
#include "iostream"
 
using namespace std;
 
int main() {
 
 
  int fw=0;
  int df=0;

  int S=0;
  
  cin >> S;
  
  fw=S/100;
  df=S-fw*100;
  
  if(fw>0 && fw<=12 && df>0 && df<=12){
    
    cout << "AMBIGUOUS";
    
  }else if(df>0 && df<=12){
    
    cout << "YYMM";
    
  }else if(fw>0 && fw<=12){
    
    cout << "MMYY";
    
  }else {
    
    cout << "NA";
    
  }

	return 0;
}

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

int main(){
    int n,ans;
    cin>>n;

    for(int i=n;i<2*n+1;i++){  
        int t=0;
        for(int j=2;j<n;j++){
            if(i%j==0){t++;}
                }
            if(t==0){
                ans=i;
                break;
            }
        }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;
const int MAX_V = 1000;
const int MAX_N = 500;
// ¸_
int V;
// OtÌ×ÚXg\»
vector <int> G[MAX_V];


int R[MAX_N], B[MAX_N];
// }b`OÌyA
int match[MAX_V];

// DFSÅ·ÅÉ²×½©ÌtO
bool used[MAX_V];

// uÆvðÔÓðOtÉÇÁ·é
void add_edge (int u, int v )
{
	G[u].push_back(v);
	G[v].push_back(u);
}

// ÁpXðDFSÅT·
bool dfs (int v )
{

	used[v] = true;

	for (int i = 0; i < G[v].size(); ++i ){
		int u = G[v][i], w = match[u];
		if (w < 0 || !used[w] && dfs(w) ){
			match[v] = u;
			match[u] = v;
			return true;
		} // end if
	} // end for
	
	return false;
}

// ñOtÌÅå}b`Oðßé
int bipartite_matching (void)
{
	int res = 0;
	memset (match, -1, sizeof(match ) );
	for (int v = 0; v < V; ++v ){
		if (match[v] < 0 ){
			memset (used, 0, sizeof(used) );
			if (dfs(v) ) {
				++res;
			} // end if
		} // end if
	} // end for

	return res;
}

int gcd (int a, int b )
{
	if (a > b ){
		swap (a, b );
	} // end if
	while (b % a != 0 ){
		b = b % a;
		if (a > b ){
			swap (a, b );
		} // end if
	} // end while

	return a;
}

void solve (int m, int n )
{
	V = m + n;
	for (int i = 0; i < m; ++i ){
		for (int j = 0; j < n; ++j ){
				if (gcd(B[i], R[j] ) != 1 ){
					add_edge (i, m + j );
				} // end if
		} // end for
	} // end for

	cout << bipartite_matching() << endl;	
}

void init (void )
{
	memset (B, 0, sizeof(B) );
	memset (R, 0, sizeof(R) );
	for (int i = 0; i < MAX_V; ++i ){
		G[i].clear();
	} // end for		
}	

int main()
{
//	cut here before submit 
//	freopen ("testcase.card1163", "r", stdin );
	int m, n;

	while (cin >> m >> n && m && n){
		init();
		for (int i = 0; i < m; ++i){
			cin >> B[i];
		} // end for
		for (int j = 0; j < n; ++j ){
			cin >> R[j];
		} // end for
	
		solve (m,n );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_weight,int arg_value){
		weight = arg_weight;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return arg.weight*value > arg.value*weight;
	}
	int weight,value;
};

int main(){

	int N;
	double W,ans = 0;

	scanf("%d %lf",&N,&W);

	vector<Info> V;

	int weight,value;
	for(int loop = 0; loop < N; loop++){

		scanf("%d %d",&weight,&value);

		if(weight >= 0 && value <= 0)continue;

		if(weight >= 0 && value >= 0){

			V.push_back(Info(weight,value));

		}else if(weight <= 0 && value >= 0){

			ans += value;
			W -= weight;

		}else if(weight < 0 && value < 0){

			ans += value;
			W -= weight;
			V.push_back(Info(-weight,-value));
		}
	}
	sort(V.begin(),V.end());

	double tmp_x;

	for(int i = 0; i < V.size(); i++){

		tmp_x = min(1.0,W/V[i].weight);
		ans += tmp_x*V[i].value;
		W -= tmp_x*V[i].weight;
		if(W < EPS)break;
	}

	printf("%.10lf\n",ans);

	return 0;
}



Measured memory_bytes: 3312
#include<stdio.h>
#include<string.h>
int main(){

	char s[200]={},p[100]={},task[101]={};//??£?????¨;
	scanf("%s",s);
	scanf("%s",p);
	strcpy(task,s);	//??????????????????
	strcat(s,task); //??°??¶????????¨????????????????????????

	if(strstr(s,p)!=0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1764
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF 1000000000
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

struct edge {int from, to, cost; };

int digitSum(long long x){
    int res = 0;
    string s = to_string(x);
    for(int i = 0; i < s.length(); i++){
        res += s[i]-'0';
    }
    return res;
}

int digitSum2(long long x){
    string s = to_string(x);
    int res = (s[0]-'0')+9*(s.length()-1);
    if((x+1)%10 == 0){
        return res;
    }else{
        return res-1;
    }
}

void solve(){
    ll n;
    cin >> n;
    if(n >= 10){
        cout << digitSum2(n) << endl;
    }else{
        cout << n << endl;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;cin>>n;
	vi vec(n);
	rep(i,0,n) cin>>vec[i];
	map<int,vector<int>> mp;
	for(int i=0;i<n;i++) mp[vec[i]].pb(i);
	vi ans;
	if(!mp.count(1)) cout<<"-1";
	else{
		int pre=mp[1].front();
		ans.pb(pre);int i=2;
		while(true){
			if(!mp.count(i)) break;
			auto it=lower_bound(all(mp[i]),pre);
			if(it==mp[i].end()) break;
			ans.pb(*it);
			pre=*it;
			i++;
		}
		cout<<n-ans.size();
	}
	
	
	
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 24056
def insertionSort(A,n,g,cnt):
	for i in range(g,n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v
	return A,cnt

def shellSort(A,n):
	cnt = 0
	G = [1]
	while G[-1]*3+1 <= n:
		G.append(G[-1]*3 + 1)
	G = G[::-1]
	m = len(G)
	for g in G:
		A,cnt = insertionSort(A,n,g,cnt)
	return A,m,G,cnt

if __name__ == '__main__':
	
	n = int(input())
	A = []
	[A.append(int(input())) for i in range(n)]
	
	'''
	data = [int(d) for d in data.split('\n')]
	n = data.pop(0)
	A = data[:]
	'''
	
	A,m,G,cnt = shellSort(A,n)
	print(m)
	print(' '.join([str(i) for i in G]))
	print(cnt)
	[print(a) for a in A]

Measured memory_bytes: 55232
#include <bits/stdc++.h>
using namespace std;
int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<w*h/2<<" ";
  if(x==w/2 && y==h/2){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
}
  

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = 0; i <= 1000 / k; ++i) {
        if (a <= i * k and i * k <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}
 
 
int main(){
  ll h1,h2,m1,m2,k,ans=0;
  cin>>h1>>m1>>h2>>m2>>k;
  if(m2<m1){
   	ans+=(m2-m1)+60; 
    h2--;
  }
  else
    	ans+=m2-m1;
  ans+=(h2-h1)*60;
  ll val=ans-k;
  cout<<val;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int dp[45][1005][1005];

int main(void)
{
    int n, ma, mb;
    cin >> n >> ma >> mb;

    v_int a(n), b(n), c(n);

    irep(i, n) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }
    
    irep(i, 45) {
        irep(ca, 1005) {
            irep(cb, 1005) {
                dp[i][ca][cb] = INF;
            }
        }
    }
    
    dp[0][0][0] = 0;

    irep(i, n) {
        irep(ca, 1005) {
            irep(cb, 1005) {
                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
                if(ca < a[i] || cb < b[i]) { continue; }
                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca - a[i]][cb - b[i]] + c[i]);
            }
        }
    }
#if 0
    irep(i, n) {
        irep(ca, 40) {
            irep(cb, 40) {
                printf("i,%d,ca,%d,cb,%d,%d\n", i, ca, cb,dp[i][ca][cb]);
            }
        }
    }
#endif
    int ans = INF;
    irep2(ca, 1, 1000) {
        irep2(cb, 1, 1000) {
            if(ca*mb == cb*ma) { 
                ans = min(ans, dp[n][ca][cb]);
            }
        }
    }
    if(ans != INF) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}
/** atcoder **/


Measured memory_bytes: 177792
// B - Counting of Trees
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
#define MOD 998244353

int main(){
	int N; cin>>N;
	vl D(N);
	map<ll,ll> M;
	rpz(i, N){
		ll d; cin>>d;
		if((i==0 && d!=0) || (i>0 && d<=0)){
			cout<< 0 <<endl;
			return 0;
		}
		M[d]++;
	}
	ll ans = 1;
	rp(d, 1, M.size())
		rpz(i, M[d]) ans  = ans * M[d-1] % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 7296
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define PB push_back

ll dp[21][100];
int n;
int num[100];

main(){
  cin>>n;
  rep(i,n)cin>>num[i];
  
  dp[num[0]][0]=1;
  
  for(int i=1;i<n-1;i++){
    rep(j,21){
      int nn=j-num[i];
      if(nn>=0)dp[j][i]+=dp[nn][i-1];
      nn=j+num[i];
      if(nn<21)dp[j][i]+=dp[nn][i-1];
    }
  }
  cout<<dp[num[n-1]][n-2]<<endl;
}

Measured memory_bytes: 0
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

# cumulated value
c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = c_p[K - 1]

for i in range(K, N):
    e = c_p[i] - c_p[i - K]
    max_e = max(max_e, e)

print((max_e + K) / 2)


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

int main(){

  int i=1;
  long N, num=0;
  cin >> N;

  while(N/i){
    num += (N%(i*10))/i;
    i *= 10;
  }

  if(N%num){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
//32
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(;;){
    int occ[14]={};
    for(int i=0;i<5;i++){
      int h;
      cin>>h;
      cin.ignore();
      if(!cin)return 0;
      occ[h]++;
    }
    int me=*max_element(occ,occ+14);
    int c2=count(occ,occ+14,2);
    int *lr=find(occ,occ+14,1);
    if(me==4){
      cout<<"four card"<<endl;
    }else if(me==3 && c2){
      cout<<"full house"<<endl;
    }else if(count(lr,lr+5,1)==5 || count(occ+10,occ+14,1)==4&&occ[1]){
      cout<<"straight"<<endl;
    }else if(me==3){
      cout<<"three card"<<endl;
    }else if(c2==2){
      cout<<"two pair"<<endl;
    }else if(c2==1){
      cout<<"one pair"<<endl;
    }else{
      cout<<"null"<<endl;
    }
  }
  return 0;
}

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

int main()
{
    int N,L;
    string S[110];
    cin >> N >> L;
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S,S+N);
    for(int i = 0; i < N; i++) cout << S[i];
    cout << endl;
}

Measured memory_bytes: 256
# 2020/01/20
# https://atcoder.jp/contests/abc081/tasks/arc086_a
# counterによってC = [(A_l, c_l),..]を求めてソート、小さい順にK-len(C)を取り出す

from collections import Counter

def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    counter = Counter(A)
    L = len(counter)
    ret = 0
    if L > K:
        l = counter.most_common()
        # print(L,l,l[K:])
        ret += sum(map(lambda x:x[1],l[K:]))
    
    print(ret)
    
solve()

Measured memory_bytes: 39320