akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
D = []#D[i] = [i_i,p_i,y_i]

for i in range(M):
  p, y = map(int, input().split())
  D.append([i,p,y])
  
D = sorted(D, key=lambda x:(x[1],x[2]))

S =[None for i in range(M)]

p_ = D[0][1]
n = 0

for i in range(len(D)):
  if p_ != D[i][1]:
    p_ = D[i][1]
    n = 1
  else:
    n+=1
  S[D[i][0]] =str(D[i][1]).zfill(6)+str(n).zfill(6)


print(*S, sep = '\n')

Measured memory_bytes: 34848
import math

def main():
    a, b, k = [int(x) for x in input().split()]

    p = []
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            p.append(i)

    print(p[len(p) - k])



if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int n;
    cin >>n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int maxabs=0;
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            if(abs(a[i]-a[j])>maxabs){
                maxabs = abs(a[i]-a[j]);
            }
        }
    }
    cout << maxabs << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 500000

int n;

/*int parent(int i){
    return i/2;
}*/
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}

void maxHeapify(int A[], int i){
    int largest;
    int l,r;
    int tmp;
    l = left(i);
    r = right(i);
    
    if(l<=n && A[l] > A[i])largest=l;
    else largest=i;
    
    if(r<=n && A[r]>A[largest])largest=r;
    
    if(largest != i){
        tmp=A[i];
        A[i]=A[largest];
        A[largest]=tmp;
        maxHeapify(A,largest);
    }
    
}

void buildMaxHeap(int A[]){
    int i;
    for(i=n/2;i>=1;i--){
        maxHeapify(A, i);
    }
}


int main(void){
    int i;

    int heap[M];
    scanf("%d",&n);
    for(i=1;i<n+1;i++){
        scanf("%d",&heap[i]);
    }
    
    buildMaxHeap(heap);

    
    for(i=1;i<n+1;i++){
        printf(" %d",heap[i]);
    }
    printf("\n");
    return 0;
}

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

namespace CSharpSample01
{

    
    class Program
    {

        //操作Aと操作Bのうち、より小さい解を選ぶ
        static int Solve(int N, int K)
        {
            int rec = 1;

            for(int i = 0; i < N; i++)
            {
                if (rec * 2 < rec + K) rec *= 2;  //操作A
                else rec += K;  //操作B
            }

            return rec;
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());

            Console.WriteLine(Solve(N, K));
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	int t;
	string s;
	cin>>s;
	if(s[(int)s.size()-1]=='s'){
		s+="es";
	}
	else{
		s+='s';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3628
package main

import (
  "bufio"
  "container/list"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,10000)}
  n,k := input.NextInts()
  a := input.NextIntArray()
  idx := map[int]int{}
  g := make([][]int64,60)
  for i:=0;i<60;i++ { g[i] = make([]int64,n) }
  for i:=0;i<n;i++ {
    if _,ok := idx[a[i]];!ok { idx[a[i]] = n+i }
  }
  for i:=n-1;i>-1;i-- {
    g[0][i] = int64(idx[a[i]]-i+1)
    idx[a[i]] = i
  }
  for i:=1;i<60;i++ {
    for j:=0;j<n;j++ {
      if g[i-1][(g[i-1][j]+int64(j))%int64(n)]+g[i-1][j] < 0 { continue }
      g[i][j] = g[i-1][(g[i-1][j]+int64(j))%int64(n)]+g[i-1][j]
    }
  }
  x := int64(0)
  r := int64(n)*k-1
  for x+g[0][x%int64(n)] <= r {
    for i:=59;i>-1;i-- {
      if g[i][x%int64(n)] > 0 && x+g[i][x%int64(n)] <= r {
        x += g[i][x%int64(n)]
      }
    }
  }
  queue := list.New()
  set := make(map[int]struct{})
  for ;x<=r;x++ {
    if _,ok := set[a[x%int64(n)]];ok {
      for {
        y,_ := queue.Remove(queue.Back()).(int)
        delete(set,y)
        if y == a[x%int64(n)] { break }
      }
      continue
    }
    queue.PushBack(a[x%int64(n)])
    set[a[x%int64(n)]] = struct{}{}
  }
  for queue.Len() > 0 {
    v,_ := queue.Remove(queue.Front()).(int)
    fmt.Print(v)
    if queue.Len() == 0 { break }
    fmt.Print(" ")
  }
  fmt.Println()
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int64) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.ParseInt(s[1],10,64)
  return x,y
}
func(i *Input) NextIntArray() []int {
  s := strings.Fields(i.NextLine())
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 129664
#include <bits/stdc++.h>
#define INF 1234567891
#define MAXS 100007

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INP freopen("input.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
  int n, m;
  cin >> n >> m;
  cout << (n*3 + m) /2;
}

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

int main(){
    int64_t K;
    cin >> K;
    
    queue<int64_t> que;
    
    for ( int64_t i = 1; i <= 9; ++i){
        que.push(i);
    }
    
    bool flg = true;
    int64_t count = 1;
    int64_t num = 0;
    while ( flg ){
        num = que.front();
        que.pop();
        count += 1;
        
        int64_t a = num % 10;
        
        if ( a == 0 ){
            for ( int64_t b = 0; b <= 1; ++b){
                int64_t c = num * 10 + a + b;
                que.push(c);
            }
        } else if ( a == 9 ){
            for ( int64_t b = -1; b <= 0; ++b){
                int64_t c = num * 10 + a + b;
                que.push(c);
            }
        } else {
            for ( int64_t b = -1; b <= 1; ++b){
                int64_t c = num * 10 + a + b;
                que.push(c);
            }
        }
        
        //cout << count << num << endl;
        
        if ( count > K ){
            flg = false;
        }
        
    }
    
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> a(N),b(N),c(M),d(M);
    rep(i,N){
        cin>>a[i]>>b[i];
    }
    rep(i,M){
        cin>>c[i]>>d[i];
    }
    long long tmp;
    vector<int> ans(N);
    rep(i,N){
        tmp=INF;//tmpを初期化
        rep(j,M){
            //i番目の人のチェックポイントを見つける
            //前のチェックポイントから探して今見ているのがそれより近いなら
            //ansを更新してtmpを更新
            if(tmp>abs(c[j]-a[i])+abs(d[j]-b[i])){
                ans[i]=j+1;//1-indにする
                tmp=abs(c[j]-a[i])+abs(d[j]-b[i]);
            }
        }
    }
    rep(i,N){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  ll l = n % k;
  l = min(l, abs(l - k));
  cout << l;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  int i,n,v,j,m;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  for(i=0;i<n;i++){
    
    printf("%d",A[i]);
    
    if(i<n-1)printf(" ");
    
  }
  
  printf("\n");
  
  for(i=1;i<n;i++){
    
    v=A[i];
    
    j=i-1;

    while(j>=0 && A[j]>v){
      
      A[j+1] = A[j];
      
      j--;
      
      A[j+1] =v;
      
    }
    
    for(m=0;m<n;m++){
      
      printf("%d",A[m]);
      
      if(m<n-1)printf(" ");
      
    }
    
    printf("\n");
    
  }
      
  return 0;  
}



Measured memory_bytes: 2124
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int dp[][] = new int[20010][256];
		while(true){
			int n = in.nextInt(), m = in.nextInt();
			if(n==0 && m==0) return ;
			int cs[] = new int[m], xs[] = new int[n];
			for(int i=0; i<m; i++){
				cs[i] = in.nextInt();
			}
			for(int i=0; i<n; i++){
				xs[i] = in.nextInt();
			}
			for(int i=0; i<n+1; i++)
				for(int j=0; j<256; j++)
					dp[i][j] = 1<<30;
			dp[0][128] = 0;
			for(int i=0; i<n; i++){
				for(int j=0; j<256; j++){
					for(int k=0; k<m; k++){
						int next = round(j+cs[k]);
						dp[i+1][next] = Math.min(dp[i+1][next], dp[i][j] + sq(xs[i]-next));
					}
				}
			}
			int ans = 1<<30;
			for(int i=0; i<256; i++)
				ans = Math.min(ans, dp[n][i]);
			System.out.println(ans);
		}
	}
	
	private static int round(int x){
		return x>255?255:x<0?0:x;
	}
	
	private static int sq(int x){
		return x*x;
	}
}

Measured memory_bytes: 34000
A,B,K = list(map(int,input().split()))

if 0 < A:
    if A <= K:
        K -= A
        A = 0
    else:
        A -= K
        K = 0
        
if 0 < B and 0 < K:
    if B <= K:
        K -= B
        B = 0
    else:
        B -= K
        K = 0        

print(A,end=" ")
print(B)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>

using namespace std;
using ll = long long;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> v(n, 0);
	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		v[a-1]++;
		v[b-1]++;
	}

	bool flag = true;
	for (int i = 0; i < n; ++i)
	{
		flag = flag && (v[i] % 2 == 0);
	}

	if (flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 640
local n = io.read("*n")
local s = {}
local ans = 0
for _ = 1,n do
    local a = io.read("*n")
    if s[a] == nil then
        s[a] = true
        ans = ans + 1
    end
end
if ans % 2 == 0 then
    ans = ans - 1
end
print(ans)


Measured memory_bytes: 2424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){
  ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
  int n,m;
  cin >> n >> m;
  vector<bool> ok(n+1,true);
  int a;
  rep(i,m){
    cin >> a;
    ok[a] = false;
  }
  vll dp(n+1);
  dp[0] = 1;
  for(int now=0;now<n;now++){
    for(int next=now+1;next<=min(n,now+2);next++){
      if(ok[next]){
        dp[next] += dp[now];
        dp[next] %= 1000000007;
      }
    }
  }
  cout << dp[n] << endl;
//////////////////////////////////////////////////////
return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if (h==0 && w==0) break;
        for (int i=0;i<h;i++){
            for (int j=0;j<w;j++){
                  if ((i+j)%2==0){
                      printf("#");
                  } else {
                       printf(".");
                  }
            }
            printf("\n");
         }
         printf("\n");
    }
    return 0;
}   


Measured memory_bytes: 2048
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
typedef long long ll;

set<string> t;
string s;

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
	{
		cin>>s;
		t.insert(s);
	}
	printf("%d\n",(int)t.size());
	return 0;
}

Measured memory_bytes: 19372
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int n; string s;
vector<int> a;

void make(){
	for(int i = 1; i <n-1; ++i){
		int l=i-1, r=i+1;
		if(a[i]==0){
		  if(s[i]=='o'){a[r]=a[l];}
		  else{a[r]=(a[l]+1)%2;}
		}
		else{
			if(s[i]!='o'){a[r]=a[l];}
		    else{a[r]=(a[l]+1)%2;}
        }
    }
}

bool check(int l, int c, int r){
	if(a[c]==0){
		if(s[c]=='o' && a[l]!=a[r])return false;
		if(s[c]!='o' && a[l]==a[r])return false;
    }
    else{
    	if(s[c]!='o' && a[l]!=a[r])return false;
        if(s[c]=='o' && a[l]==a[r])return false;
    }
    return true;
}

int main(){
	cin >> n >> s;
    a.resize(n);
	for(int t = 0; t < 4; ++t){
		if(t==0){a[0]=0;a[1]=0;}
		if(t==1){a[0]=1;a[1]=0;}
		if(t==2){a[0]=0;a[1]=1;}
		if(t==3){a[0]=1;a[1]=1;}
		make();
		if(check(n-2, n-1,0) && check(n-1, 0, 1)){
			for(int i = 0; i < n; ++i){
				if(a[i]==0)cout << 'S';
				else cout << 'W';
            }
            cout << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
}


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

int main() {
    int N;
    cin >> N;
    int flag = 0;

    for(int i = 1; i < 50001; i++){
        int X = i * 1.08;
        if(N == X){
            cout << i << endl;
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << ":(" << endl;
    }
}

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

int main(){
  string s;
  cin>>s;
  int a=0;
  int c=0;
  for(int i=0;i<1000000;i++){
if(s.at(i)=='A'){
a=i;
  break;
}
  }
   for(int i=s.size()-1;i<1000000;i--){
if(s.at(i)=='Z'){
c=i;
  break;
}
  }
   cout<<c-a+1<<endl;
}
   

Measured memory_bytes: 640
import java.util.*;


/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        long N = scanner.nextLong();

        int i = 1;
        long sum = 0;
        while(N > sum){
            sum += i;
            i++;
        }
        System.out.println(i - 1);


    } // mainMethod


} // MainClass


Measured memory_bytes: 22736
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  vector<int> S;
  loop(i,0,3) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  sort(S.begin(), S.end());
  cout << S[0]+S[1] << endl;
}


Measured memory_bytes: 3532
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long 
ll n,c,a[100010],b[100010],ans1[100010],ans2[100010],ans3[100010],ans4[100010],anss1,anss2,anss3,anss4;
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
	}
	ll sum=0;
	anss1=anss2=anss3=anss4=0;
	for(int i=1;i<=n;i++)
	{
		sum+=b[i];
		ll tt=sum-a[i];
		ans1[i]=max(ans1[i-1],tt);
		ll tmp=sum-2*a[i];
		ans2[i]=max(tmp,ans2[i-1]);
		anss1=max(ans1[i],anss1);
	//	anss2=max(ans2[i],anss2);
	//	cout<<ans1[i]<<" "<<ans2[i]<<endl;
	}
	sum=0;
	for(int i=n;i>=1;i--){
		sum+=b[i];
		ll tt=sum-c+a[i];
		ans3[i]=max(ans3[i-1],tt);
		ll tmp=sum-2*c+2*a[i];
		ans4[i]=max(tmp,ans4[i-1]);
		anss3=max(ans3[i],anss3);
	//	anss4=max(ans4[i],anss4);
	//	cout<<ans3[i]<<" "<<ans4[i]<<endl;
	}
	for(int i=1;i<=n;i++)
	{
		anss2=max(anss2,ans1[i]+ans4[i+1]);
	}
	for(int i=1;i<=n;i++)
	{
		anss4=max(anss4,ans2[i]+ans3[i+1]);
	}
	ll ans=0;
	ans=max(anss1,anss2);
	ans=max(ans,max(anss3,anss4));
	cout<<ans;
	return 0;
}

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

struct Card{ char suit, value;};

void bubble(struct Card A[], int N){
  Card tmp;

  for( int i = 0; i < N-1; i++){
    for( int j = N-1; j >= i; j--) {
      if (A[j].value < A[j-1].value) {
        tmp = A[j-1]; A[j-1] = A[j]; A[j] = tmp;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  int minj;
  Card tmp;

  for ( int i = 0; i < N-1; i++) {
    minj = i;
    for ( int j = i; j < N; j++) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    tmp = A[i]; A[i] = A[minj]; A[minj] = tmp;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}      

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}


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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n, k;
ll a[mnx];
ll suff[mnx];
ll pref[mnx];
ll b[mnx];

int main() {

cin >> n >> k;

for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
    pref[i + 1] = pref[i] + max(a[i], 0LL);
}

ll res = -1;

for(int i = 0; i <= n - k; i++){
    res = max(res, pref[n] - (pref[i + k] - pref[i]) + max(0LL, b[i + k] - b[i]));
}

cout << res << '\n';

return 0;

}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(1e6) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e16;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

ld r;
int main ()
{
    cin >> r;
    ld cur = pi * 1ll * r * r;
    ld cur2 = pi * 1ll * 1 * 1;
    int ans = int(cur / cur2);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void chkmax(T &x, T y) {x = x > y ? x : y;}
template <typename T> void chkmin(T &x, T y) {x = x < y ? x : y;}
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); x *= f;
}
const int N = 50;
int a[N][N]; ll f[N][N][N];
ll dp(int l, int r, int mid) {
	if (~f[l][r][mid]) return f[l][r][mid];
	if (l == r) return 1;
	if (l == mid || r == mid) return 0;
	ll ret = 0;
	for (int j = l; j < mid; j++)
		for (int k = mid + 1; k <= r; k++) {
			if (!a[j][k]) continue;
			for (int p = j; p < mid; p++)
				for (int q = mid + 1; q <= k; q++)
					ret += dp(l, p, j) * dp(q, r, k) * dp(p + 1, q - 1, mid);
			}
	return f[l][r][mid] = ret;
}
int main() {
	int n; read(n);
	for (int i = 1; i <= 2 * n; i++)
		for (int j = 1; j <= 2 * n; j++) {
			char c = getchar();
			while (!isdigit(c)) c = getchar();
			a[i][j] = c - '0';
		}
	memset(f, -1, sizeof(f)); ll ans = 0;
	for (int i = 2; i <= 2 * n; i++)
		if (a[1][i]) ans += dp(2, 2 * n, i);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <string>
#include <iostream>
//#include <algorithm>
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}
std::string ConvIntToStr(int checkNum)
{
	return std::to_string(checkNum);
}

int main(void)
{
	int a, b, c;

	cin >> a >> b;

	if ((a * b) % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, A):
    d = dict()
    for a in A:
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
    total = 0
    for a, n in d.items():
        total += (n * (n-1)) // 2
    for a in A:
        n = d[a]
        print(total - (n-1))


if __name__ == "__main__":

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

    solv(N, A)


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int64_t> dp(N), ans(N);
    auto dfs = [&](auto &&dfs, int cur, int pre) -> int64_t {
        dp[cur] = 1;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            dp[cur] *= (dfs(dfs, to, cur) + 1);
            dp[cur] %= M;
        }
        return dp[cur];
    };
    auto efs = [&](auto &&efs, int cur, int pre, int64_t ret) -> void {
        vector<int> V;
        for(auto &e : G[cur]) {
            if(e != pre) V.push_back(e);
        }
        int n = V.size();
        vector<int64_t> L(n), R(n);
        for(int i = 0; i < n; ++i) {
            L[i] = dp[V[i]] + 1;
            if(i) L[i] *= L[i - 1];
            L[i] %= M;
        }
        for(int i = n - 1; i >= 0; --i) {
            R[i] = dp[V[i]] + 1;
            if(i != n - 1) R[i] *= R[i + 1];
            R[i] %= M;
        }
        for(int i = 0; i < n; ++i) {
            int64_t l = i ? L[i - 1] : 1;
            int64_t r = i + 1 < n ? R[i + 1] : 1;
            ans[V[i]] = ((l * r) % M) * ret + 1;
            ans[V[i]] %= M;
            efs(efs, V[i], cur, ans[V[i]]);
        }
    };
    ans[0] = 1;
    dfs(dfs, 0, 0);
    efs(efs, 0, 0, 1);
    for(int i = 0; i < N; ++i) {
        dp[i] *= ans[i];
        cout << dp[i] % M << '\n';
    }
    return 0;
}


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

int main(void) {
    int N, count = 0 , ret = 0;
    string S;
    cin >>N >> S;
    for (int i = 0; i < S.size(); i++) {
        char c = S.at(i);
        count = (c == 'I') ? count + 1 : count - 1;
        ret = max(count, ret);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3572
import java.io.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	
    	if (A+B+C == 17 && A*B + B*C + C*A == 95 && A*B*C == 175){
    		System.out.println("YES");
    	} else {
    			System.out.println("NO");
    		}
    	}
    	
    }

   

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

using namespace std;




int main(){
  
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif
 
 long long n,k;
 cin>>n>>k;
 vector< long long  > arr(n);
 std::vector< long long> v;
 for(int i =0;i<(int)n;i++){
  cin>>arr[i];
 }

for(int i = k;i<n;i++){
  if(arr[i]> arr[i-k]){
    cout<<"Yes\n";
  }
  else
    cout<<"No\n";
}





}






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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int M, n, N;
    vector<int> P;
    bool input() {
        cin >> M >> n >> N;
        if (M == 0 && n == 0 && N == 0) return false;
        P.clear(); P.resize(M); cin >> P;
        return true;
    }

    void solve() {
        int ans = -1;
        int g = 0;
        for (int i = n; i <= N; i++) {
            int c = P[i - 1] - P[i];
            if (c >= g) {
                ans = i;
                g = c;
            }
        }
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    int max = 0;
    int max_psi = 1;
    for(int i = 0; i <=N; i++){
        if(max < (int)log2(i)){
            max = (int)log2(i);
            max_psi = i;
        }
    }
    
    cout << max_psi << endl;
}


Measured memory_bytes: 3332
n = int(input())
a = list(map(int, input().split()))

even_list = filter(lambda x: x % 2 == 0, a)

is_approved = True

for i in even_list:
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        is_approved = False
        break

print('APPROVED' if is_approved else 'DENIED')


Measured memory_bytes: 2940
#include <iostream>

int main()
{
  int b;
  std::cin >> b;
  int i = 1;
  int c = 0;
  c += b % 10;
  c += (b / 10) % 10;
  c += (b / 100) % 10;
  
  std::cout << c << std::endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const ll MOD = 1000000007;
const ll INF = 100000;

int n, m, cnt;

int prime[100010];
bool is_prime[1000010];
int c[100010];
void func(int n){

    int p = 0;
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= n; i++){
        if (is_prime[i]){
            if (is_prime[(i + 1) / 2]) c[i]++;
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }

    for (int i = 1; i <= n; i++) c[i] += c[i - 1];
}

int main(void){
    int Q;
    cin >> Q;
    cnt = 0;
    for (int i = 0; i < n; i++) c[i] = 0;
    func(100000);
    for (int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << c[r] - c[l - 1] << endl;
    }

}

Measured memory_bytes: 1152
var
    n,i,x,y: Integer;
    a: array[0..108] of Integer;
    
procedure qsort(l,r:Longint;data:PInteger);
//array index start at 0
var
    i,j,mid: Integer;
begin
    if l>=r then
    begin
        exit;
    end;
    i:=l;
    j:=r;
    mid:=data[(l+r) div 2];
    repeat
        while data[i]<mid do
        begin
            inc(i);
        end;
        while data[j]>mid do
        begin
            dec(j);
        end;
        if i<=j then
        begin
            data[0]:=data[i];
            data[i]:=data[j];
            data[j]:=data[0];
            inc(i);
            dec(j);
        end;
    until i>j;
    qsort(l,j,data);
    qsort(i,r,data);
end;
begin
    readln(n);
    for i := 0 to n-1 do
    begin
        read(a[i+8]);
    end;
    qsort(8,n+7,@a);
    x:=0;
    y:=0;
    i:=n+7;
    while i>=8 do
    begin
        inc(x,a[i]);
        dec(i,2);
    end;
    i:=n+6;
    while i>=8 do
    begin
        inc(y,a[i]);
        dec(i,2);
    end;
    writeln(x-y);
end.

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

namespace AtCorder
{
	public class Program
	{	
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int h = cin.Int();
			int w = cin.Int();
			string[] s = new string[h];
			for (int i = 0; i < h; i++) {
				s[i] = cin.Next();
			}

			int[,] yoko = new int[h, w];
			int[,] tate = new int[h, w];
			for (int y = 0; y < h; y++) {
				int count = 0;
				int start = 0;
				for (int x = 0; x < w; x++) {
					if (s[y][x] == '#') {
						yoko[y, x] = 0;
						if (count != 0) {
							for (int i = start; i < x; i++) {
								yoko[y, i] = count;
							}
						}
						count = 0;
					} else {
						if (count == 0) {
							start = x;
						}
						count++;
						if (x == w - 1) {
							for (int i = start; i <= x; i++) {
								yoko[y, i] = count;
							}
						}
					}
				}
			}

			for (int x = 0; x < w; x++) {
				int count = 0;
				int start = 0;
				for (int y = 0; y < h; y++) {
					if (s[y][x] == '#') {
						tate[y, x] = 0;
						if (count != 0) {
							for (int i = start; i < y; i++) {
								tate[i, x] = count;
							}
						}
						count = 0;
					} else {
						if (count == 0) {
							start = y;
						}
						count++;
						if (y == h - 1) {
							for (int i = start; i <= y; i++) {
								tate[i, x] = count;
							}
						}
					}
				}
			}

			int max = 0;
			for (int y = 0; y < h; y++) {
				for (int x = 0; x < w; x++) {
					if (s[y][x] != '#') {
						max = Math.Max(max, yoko[y, x] + tate[y, x] - 1);
					}
				}
			}

			Console.WriteLine(max);
		}
		
		
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 61976
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c, k = map(int, readline().split())
    t = [int(readline()) for _ in range(n)]
    t.sort()

    ans = 0
    oldest = t[0]
    cnt = 1
    for x in t[1:]:
        if oldest + k < x or cnt == c:
            ans += 1
            cnt = 0
            oldest = x
        cnt += 1

    if cnt > 0:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)


#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)


#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


ll binary(ll bina)
{
    long long ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    string a;
    return ans;

}

int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> v;
    Rep(i,1,max(A,B) + 1)
    {
        if((A % i == 0 && B % i == 0))
        {
            v.push_back(i);
        }
    }
    REVERSE(v);
    cout << v[K - 1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 200000

int i, n, max1, max2;
int a[MAX];

int main(void)
{
  scanf("%d", &n);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    if (a[i] >= max1)
    {
      max2 = max1; max1 = a[i];
    }
    else
    if (a[i] >= max2) max2 = a[i];
  }

  for (i = 0; i < n; i++)
    if (a[i] != max1) printf("%d ",max1);
    else printf("%d ", max2);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2304
using System;

public class AtCoder
{
    public static void Main()
    {
        long n;
        n = int.Parse(Console.ReadLine().Trim());
        int ans = 0;
        int[] j = new int[3];
        for (int i = 1; i <= 10; i++)
        {
            ans += test.F357(n, i, 0, 0, 0, j);
        }
        Console.WriteLine(ans);
    }


}

public class test
{
    public static int F357(long n, int m, int c, long d, int a, int[] j)
    {
        if (c == m)
        {
            if (j[0] * j[1] * j[2] == 0) return a;
            if (d <= n)
            {
                a++;
                //Console.WriteLine(j[0]+" "+j[1]+" "+j[2]);
            }
            return a;
        }
        long p = (long)Math.Pow(10, c);
        c++;
        d += p * 3;
        j[0]++;
        a=F357(n, m, c, d, a, j);
        d += p * 2;
        j[0]--; j[1]++;
        a=F357(n, m, c, d, a, j);
        d += p * 2;
        j[1]--; j[2]++;
        a=F357(n, m, c, d, a, j);
        j[2]--;
        return a;
    }
}




Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100000
#define Q 50000

int main(){

  int i, n, q, cnt = 0;
  int mid, right, left;
  int s[N], t[Q];
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &s[i]);
 
  scanf("%d", &q);
  for(i = 0; i < n; i++) scanf("%d", &t[i]);
  
  for(i = 0; i < q; i++){
    right = n;
    left = 0;
 
    while(left <= right){
      mid = (right + left) / 2;
      if(s[mid] == t[i]) {
	cnt++;
	break;
      }
      else if(s[mid] < t[i]) left = mid + 1;
      else if(s[mid] > t[i]) right = mid - 1;
    }
  }

  printf("%d\n", cnt);
 
  return 0;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector <vector <int>> g(n+1);
	vector <int> pred(n+1);
	for (int i=1; i<=m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	queue <int> bfs;
	bfs.push(1);
	while (!bfs.empty()) {
		int v = bfs.front();
		bfs.pop();
		for (const int& i:g[v]) {
			if (pred[i]) continue;
			pred[i] = v;
			bfs.push(i);
		}
	}
	for (int i=2; i<=n; i++) {
		if (!pred[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i=2; i<=n; i++) {
		cout << pred[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 10188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        int disA = 0;
        int disB = 0;
        
        if(x - a >= 0){
            disA = x - a;
        }else{
            disA = a - x;
        }
        
        if(x - b >= 0){
            disB = x - b;
        }else{
            disB = b - x;
        }
        
        if(disA < disB){
            System.out.println("A");
        }else{
            System.out.println("B");
        }
    }
}

Measured memory_bytes: 21844
import bisect
import math
N = int(input())
A = list(map(int, input().split()))
T = [2 ** i for i in range(31)]
A.sort()
already = set()


def to_dic(A):
    d = {}
    for a in A:
        d[a] = d.setdefault(a, 0) + 1

    return d

def is_in(t, num):
    i = D.setdefault(t, 0)
    if i == 0:
        return 0
    s = min(i, num)
    D[t] -= s
    return s


res = 0
D = to_dic(A)
A2 = list(D.keys())
A2.sort()

for n in range(len(A2) - 1, -1, -1):
    a = A2[n]

    if a in T:
        res += D[a] // 2
        D[a] = 0

        if D[a] % 2 == 0:
            continue

    num = D[a]
    t = 1 << (int(math.log2(a)) + 1)

    while t > a:
        s = is_in(t - a, num)
        res += s
        num -= s
        if num == 0:
            break

        t >>= 1

print(res)


Measured memory_bytes: 56056
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, A: "List[int]"):
    if N == len(set(A)):
        print("YES")
    else:
        print("NO")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    string S,T;
    cin >> S >> T;
    ll N = S.size();
    vector<ll> v(26,-1),u(26,-1);
    rep(i,N){
        //if(S[i] == T[i])continue;
        if(v[S[i]-'a'] == -1 && u[T[i]-'a'] == -1){
            v[S[i]-'a'] = T[i] - 'a';
            u[T[i]-'a'] = S[i] - 'a';
            continue;
        }
        if(v[S[i]-'a'] == T[i] - 'a' && u[T[i]-'a'] == S[i] - 'a'){
            continue;
        }
        /*
        if(v[S[i]-'a'] == -1){
            v[S[i]-'a'] = T[i] - 'a';
            continue;
        }
        if(u[T[i]-'a'] == -1){
            u[T[i]-'a'] = S[i] - 'a';
            continue;
        }
        /*if(v[S[i]-'a'] == -1 || u[T[i]-'a'] == -1){
            v[S[i]-'a'] = T[i] - 'a';
            u[T[i]-'a'] = S[i] - 'a';
            continue;
        }else{*/            
        cout << "No" << endl;
        return 0;
        //}
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    cnt = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3828
#include<stdio.h>
#define PI  3.14159265358979323846
int main(void){
    double ans_a,ans_c,r;
    scanf("%lf",&r);
    ans_a=r*r*PI;
    ans_c=2*r*PI;
    printf("%.6f %.6f\n",ans_a,ans_c);
    return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}


void solve() {
  int n;
  cin >> n;
  vector<pii> a(n), b(n);
  rep(i, n) cin >> a[i].F >> a[i].S;
  rep(i, n) cin >> b[i].F >> b[i].S;

  sort(all(b));
  vector<int> used(n);
  rep(i, n) {
    int y = -1, x = -1, id = -1;
    rep(j, n) {
      if (used[j]) continue;
      if (a[j].F < b[i].F && a[j].S < b[i].S && chmax(y, a[j].S)) {
        id = j;
      }
    }
    if (id != -1) {
      used[id] = 1;
    }
  }
  cout << accumulate(all(used), 0) << endl;
}

/*
youtube editorial
赤が左下ほど貴重

青を左から見る
赤が左にあることは前提となる
下ほど貴重になる
*/


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	string s;
	cin>>s;
	ll a=0,b=0;
	rep(i,0,s.size()){
		if(i%2==0){
			if(s[i]=='0')a++;
			else b++;
		}
		else{
			if(s[i]=='1')a++;
			else b++;
		}
	}
	cout<<min(a,b)<<endl;
	
}

Measured memory_bytes: 512
#include<stdio.h>

#define N 101

int main(){
int i,j,n;
int u,k,v;
int G[N][N];

scanf("%d",&n);

for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        G[i][j]=0;
    }
}

for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
        scanf("%d",&v);
        G[u-1][v-1]=1;
    }
}

for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
        printf("%d ",G[i][j]);
    }
    printf("%d\n",G[i][j]);
}

return 0;

}

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

F = [True] * N
for i in range(M):
    Ai, Bi = map(lambda s: int(s) - 1, input().split())
    if H[Ai] > H[Bi]:
        F[Bi] = False
    elif H[Ai] < H[Bi]:
        F[Ai] = False
    else:
        F[Ai] = F[Bi] = False

print(F.count(True))


Measured memory_bytes: 20144
"use strict";

function Main(input) {
    var line=input.replace("\n","").split(" ").map(Number);
    var ans=Math.floor(line[0]/line[1])+" "+(line[0]%line[1])+" "+(line[0]/line[1]).toFixed(9)+"\n";
    console.log(ans);
}
    
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

ll gcd(ll a,ll b)
{

    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{

    //  #ifndef oj
    // freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
    //#endif
    // system("cls");
    //getchar();
   ll n,sum=0,temp;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=n;j++)
       {
           for(int k=1;k<=n;k++)
           {
               temp=gcd(i,j);
               sum+=gcd(temp,k);
           }
       }
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3596
def solve(n, k, aaa):
    buf = []
    prev_last = -1

    for t in range(k + 1):
        ma, mi = min((a, i + 1) for i, a in enumerate(aaa) if i + 1 != prev_last)
        others = set(range(1, n + 1)) - {prev_last, mi}
        buf.extend(others)
        buf.append(mi)
        # print(buf)

        for i in range(n):
            if i + 1 != prev_last:
                aaa[i] -= 1
                if aaa[i] < 0:
                    print(-1)
                    return

        prev_last = mi

    print(len(buf))
    print(*buf)


n, k = map(int, input().split())
aaa = list(map(int, input().split()))
solve(n, k, aaa)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, k;
vector<II> res;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    int g = (n - 2) * (n - 1) / 2;
    if (k > g) {
        cout << -1;
        return 0;
    }
    if (k > n) {
        FOR(i,2,n) res.emplace_back(II(1, i));
        FOR(i,1,n-2) 
            if (i * (i + 1) / 2 >= k) {
                int h = n - 2 - i;
                FOR(j,2,h+1)
                    FOR(k,j+1,n) res.emplace_back(II(j, k));
                int remain = i * (i + 1) / 2 - k;
                FOR(j,h+2,h+2+remain-1) res.emplace_back(II(j, j+1));
                break;
            }
        cout << SZ(res) << "\n";
        FOR(i,0,SZ(res)-1) cout << res[i].FI << ' ' << res[i].SE << "\n";
        return 0;
    }
    if (n == 2) {
        cout << "1\n";
        cout << "1 2";
        return 0;
    }
    FOR(i,1,n) {
        if (i == 1) {
            FOR(j,i+2,n-1) {
                res.emplace_back(II(i, j));
            }
        }
        else {
            FOR(j,i+2,n) {
                res.emplace_back(II(i, j));
            }
        }
        
    }

    if (k < n) {
        FOR(i,1,n-k) {
            if (i == n) {
                res.emplace_back(II(i, 1));
            }
            else res.emplace_back(II(i, i+1));
        }
    }
    cout << SZ(res) << "\n";
    FOR(i,0,SZ(res)-1) cout << res[i].FI << ' ' << res[i].SE << "\n";
    return 0;
}

Measured memory_bytes: 384