akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

int n;
string s;
typedef pair<int,int> P;
map<int,map<int,double> > height;
set<string> st;

int main(int argc,char const* argv[])
{
  while(cin >>n && n)
    {
      int loc[45];
      int tim[45];
      loc[0]=0;
      tim[0]=0;
      int dp[45][4];
      for(int i=0;i<45;i++)
	{
	  for(int j=0;j<4;j++)
	    {
	      dp[i][j]=inf;
	    }
	}
      dp[0][0]=0;
      int out=0;
      int ans=inf;
      for(int i=1;i<=n;i++)
	{
	  cin >> loc[i] >> tim[i];
	}
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<4;j++)
	    {
	      if(dp[i][j]==inf) continue;
	      int dist=abs(loc[i+1]-loc[i]);
	      bool cancatch=false;
	      if(j<3 && dist*(j+1)<=(tim[i+1]-tim[i]))
		{
		  dp[i+1][j+1]=min(dp[i][j]+dist,dp[i+1][j+1]);
		  cancatch=true;
		}
	      if((loc[i+1]+loc[i]*(j+1))<=(tim[i+1]-tim[i]))
		{
		  dp[i+1][1]=min(dp[i][j]+loc[i+1]+loc[i],dp[i+1][1]);
		  cancatch=true;
		}
	      if(!cancatch)
		{
		  out=max(out,i+1);
		}
	    }
	}	
      for(int i=0;i<=3;i++)
	{
	  ans=min(ans,dp[n][i]+loc[n]);
	}   
      if(ans==inf)
	{
	  cout << "NG" << ' ' << out << endl;
	}
      else
	{
	  cout << "OK" << ' ' << ans << endl;    
	} 
        
    }
  return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    string st[102];
    cin>>n>>l;
    for(int i=1;i<=n;i++)
        cin>>st[i];
    sort(st+1,st+n+1);
    for(int i=1;i<=n;i++)
    {
        cout<<st[i];
    }   
    cout<<endl;
    return 0;
}

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

int main(){

    int n;

    cin >> n;

    for(int i = 0; i <= n/4; ++i){
        int nn = n-i*4;
        if(nn%7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {


	int a[100001]={};
	int b[100001]={};

	int n;
	cin>>n;
	int v;
	rep(i,n){
		cin>>v;
		if(i%2==0){
			a[v]++;
		}else{
			b[v]++;
		}
	}
	int x1=0,x2=0, y1=0,y2=0;
	int s1=0,t1=0;


	rep(j,100001){
		if(x1<=a[j]){
			x2=x1;
			x1=a[j];
			s1=j;
		}else if(a[j]>x2){
			x2=a[j];
		}
		if(y1<=b[j]){
			y2=y1;
			y1=b[j];
			t1=j;
		}else if(b[j]>y2){
			y2=b[j];
		}
	}


	if(s1!=t1){
		cout<<n-(x1+y1)<<endl;
	}else{
		if(x1+y2<y1+x2){
			cout<<n-(y1+x2)<<endl;
		}else{
			cout<<n-(x1+y2)<<endl;
		}
	}


	return 0;
}


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

int main(){
  int r,b,g;
  cin >>r>>g>>b;
  if((r*100+g*10+b)%4==0){
    cout <<"YES"<<endl;
  }
  else{
    cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
fn main() {
    input!{
        a: i32,
        b: i32,
    }
    println!("{}", max(a + b, max(a - b, a * b)));
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

  std::cin >> A >> B;

  int res = A * B;
  std::cout << res << std::endl;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

int main(void) {
	int n;
	scanf("%d", &n);
	std::vector<int> X;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		X.push_back(x);
	}
	std::sort(X.begin(), X.end());
	int dup = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (X[i] == X[i + 1]) {
			++dup;
		}
	}
	if (dup % 2 == 1) {
		dup++;
	}
	printf("%d", n - dup);
	return 0;
}


Measured memory_bytes: 892
def tanaka(arr)
    if arr[0]!=arr[1] && arr[0]!=arr[2] && arr[2]!=arr[1] 
    return false
    else return true
end
end

str=gets.chomp.split("")
ll=str.length
i=0
(ll-2).times{
    arr2=[str[i],str[i+1],str[i+2]]
    
    if  tanaka(arr2) && ll>=3
       
       puts "#{i+1} #{i+3}"
       break
    end
    
    
    
   i+=1 
}

if i==ll-2 && ll>=3
    puts "-1 -1"
end


if ll==2 && str[0]==str[1]
    puts "1 2"
    
    
elsif ll==2
     puts "-1 -1"
 end

Measured memory_bytes: 9468
N=int(input())
A=list(map(int,input().split()))

A_set=set(A)
A_lst=list(A_set)

# すべてが0のとき
if sum(A_set)==0 and len(A_set)==1:
    print('Yes')
    exit()

# x…2N/3,0…N/3
if len(A_set)==2 and A_lst.count(0)==1 and len(A)%3==0:
    cnt=0
    for i in range(N):
        if A[i]==0:
            cnt+=1
    if cnt==N//3:
        print('Yes')
    else:
        print('No')
    exit()

# x^y^z==0
if len(A_set)==3 and A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    cnt_x,cnt_y,cnt_z=0,0,0
    x,y,z=A_lst[0],A_lst[1],A_lst[2]
    for i in range(N):
        if A[i]==x:
            cnt_x+=1
            continue
        if A[i]==y:
            cnt_y+=1
            continue
        if A[i]==z:
            cnt_z+=1
    if cnt_x==cnt_y==cnt_z:
        print('Yes')
    else:
        print('No')
    exit()

# それ以外
print('No')

Measured memory_bytes: 14980
#include <bits/stdc++.h>
using namespace std;
int n,o,c;
int tretO,tretC;
string s;
int main()
{
    scanf("%d",&n);
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]==')'){
            if(tretO==0){
                o++;
            }
            else
                tretO--;
        }
        else{
            tretO++;
        }
    }
    c=tretO;            // needs to be closed
    for(int i=0;i<o;i++)
        printf("(");
    cout<<s;
    for(int i=0;i<c;i++)
        printf(")");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		int c = a + b;
		int count = 1;
		while (c >= 10)
		{
			c /= 10;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {
    int S,h,m,s;
    public void suzuki(){

        Scanner sc = new Scanner(System.in);

        S = sc.nextInt();
        h = S / 3600;
        m = (S - (h * 3600)) / 60;
        s = S - (h * 3600) - (m * 60);
        System.out.println(h + ":" + m + ":" + s);
    }

    public static void main(String[] args){

        new Main().suzuki();
    }

}

Measured memory_bytes: 17164
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;

    int C[VMAX+1];
    int n, i, j;
    scanf("%d", &n);

    A = (unsigned short *)malloc(sizeof(short) * n + 1);
    B = (unsigned short *)malloc(sizeof(short) * n + 1);

    for (i=0; i<=VMAX; i++) C[i]=0;

    for (i=0; i<n; i++) {
        scanf("%hu", &A[i+1]);
        C[A[i+1]]++;
    }

    for (i=1; i<=VMAX; i++) C[i]=C[i]+C[i-1];

    for (j=1; j<=n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for (i=1; i<=n; i++) {
        if (i>1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 10556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s,ans = "AC";
    bool c = false;
    cin >> s;
    if (s[0] != 'A') {
        ans = "WA";
    }
    nfor(i, 1, s.size()){
        if(isupper(s[i])){
            if(i > 1 && i < s.size() - 1 && s[i] == 'C'){
                if (!c) {
                    c = true;
                }else{
                    ans = "WA";
                }
            }else{
                ans = "WA";
            }
            
        }
    }
    
    if(!c){
        ans = "WA";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x = map(int, input().split())
    theta = None
    if 2*x <= a*a*b:
        theta = math.atan((a*b*b)/(2*x))
    else:
        theta = math.atan(2*(a*a*b-x)/(a**3))
    print(math.degrees(theta))

if __name__ == "__main__":
    main()


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

using ll = long long;

const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    if (A[0] + A[1] + A[2] >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
/*#include<stdio.h>
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string, int> mp;
int main() {
    int n, i, maxn = 0;
    string s, ans = "";
    scanf("%d", &n);
    for(i = 1; i <= n; ++i) {
        cin>>s;
        ++mp[s];
    }
    for(auto& v:s) maxn = max(maxn, v.second);
    for(auto& v:s) {
        if(v.second == maxn) cout << v.first << endl;
    }
    return 0;
}*/
#include <bits/stdc++.h> 
using namespace std; 
#define mp make_pair 
using ll=long long; 
using pii=pair<int, int>;
#define int ll 
map<string, int> mpp; 
signed main() { 
    int n; 
    cin >> n; 
    for(int i = 0; i <= n; ++i) { 
        string s; 
        cin >> s; 
        mpp[s]++; 
    } 
    int bes = 0; 
    for(auto& v:mpp) bes = max(bes, v.second); 
    for(auto& v:mpp) { if(v.second == bes) cout << v.first << endl; } 
    return 0;
}

Measured memory_bytes: 25216
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4072
N = int(input())
A = sorted(list(map(int, input().split())))


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


while len(A) > 1:
    A.append(gcd(A.pop(), A.pop()))

print(A[0])


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

long double is_it(long double a,long double b)
{
    return sqrt(a*a+b*b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long double n,d,ans=0;
    cin>>n>>d;
    for(int i=0; i<n; i++)
    {
        long double a,b;
        cin>>a>>b;
        if(is_it(a,b)<=d)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3872
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    print(sum(A) - N)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9296
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=200010;
struct P{ int x,y; }p[N];
bool cmp(const P &a,const P &b){ return a.x<b.x; }
int n,x,y,u[N];
ll ans;

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",&p[i].x,&p[i+n].x),p[i].y=i,p[i+n].y=-i;
	sort(p+1,p+n+n+1,cmp);
	rep(i,1,n) ans+=p[i].x,x|=u[abs(p[i].y)]++,y|=(1ll*p[i].y*p[i-1].y<0);
	printf("%lld\n",(x||!y) ? ans : (p[n].y==-p[n+1].y ? ans+min(p[n+2].x-p[n].x,p[n+1].x-p[n-1].x) : ans-p[n].x+p[n+1].x));
	return 0;
}

Measured memory_bytes: 2176
// GRL_3_C: Connected Components - Strongly Connected Components
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

// Strongly Connected Components
struct SCC
{
  vector< vector<int> > graph, rgraph, tree;
  vector<Pi> edges;
  vector<int> order, cmp;
  vector<bool> used;
  SCC(int sz):graph(sz), rgraph(sz), cmp(sz, -1), used(sz, false){}
  SCC(vector< vector<int> > g):graph(g), rgraph(g.size()), cmp(g.size(), -1), used(g.size(), false){}
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    edges.emplace_back(u, v);
  }
  void dfs(int u)
  {
    if(used[u]) return;
    used[u] = true;
    for(int v : graph[u]) {
      dfs(v);
    }
    order.push_back(u);
  }
  void rdfs(int u, int& cnt)
  {
    cmp[u] = cnt;
    for(int v : rgraph[u]) {
      if(cmp[v] == -1) rdfs(v, cnt);
    }
  }
  int compose()
  {
    int cnt = 0;
    for(int u = 0; u < (int)graph.size(); u++) {
      for(int v : graph[u]) {
	rgraph[v].push_back(u);
      }
    }
    for(int u = 0; u < (int)graph.size(); u++) dfs(u);
    reverse(order.begin(), order.end());
    for(int i = 0; i < (int)order.size(); i++) {
      if(cmp[order[i]] == -1) rdfs(order[i], cnt), cnt++;
    }
    tree.resize(cnt);
    for(Pi e : edges) {
      int x = cmp[e.first], y = cmp[e.second];
      if(x == y) continue;
      tree[x].push_back(y);
    }
    return cnt;
  }
};


int main()
{
  int V, E; cin >> V >> E;
  SCC graph(V);
  while(E--) {
    int s, t;
    cin >> s >> t;
    graph.add_edge(s, t);
  }
  graph.compose();
  int Q; cin >> Q;
  while(Q--) {
    int u, v;
    cin >> u >> v;
    if(graph.cmp[u] == graph.cmp[v]) puts("1");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
const int MAX_nodes=1e5;
vector<int> adj[MAX_nodes+1];
vector<bool> visited(MAX_nodes+1, 0);
vector<int> cnt(MAX_nodes+1, 0);
void dfs(int u){
	visited[u]=true;
	for(auto v: adj[u]){
		if(!visited[v]) dfs(v);
		cnt[u]=max(cnt[u], cnt[v]+1);
	}
}
int main(){
	int n, m;
	cin >> n >> m;
	while(m--){
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	int res=1;
	for(int i=1; i<=n; i++){
		if(!visited[i]) dfs(i);
		res=max(res, cnt[i]);
	}
	cout << res;
}

Measured memory_bytes: 8192
#include <stdio.h>

int main(void)
{
  int N, M;
  char A[50][50];
  char B[50][50];
  int i, j;
  int s, t;
  int f = 0;
  int tmp = 1;

  scanf("%d %d", &N, &M);
  for(i = 0; i < N; i++) {
    scanf("%s", &A[i]);
  }
  for(i = 0; i < M; i++) {
    scanf("%s", &B[i]);
  }

  for(i = 0; i < N-M+1; i++) {
    for(j = 0; j < N-M+1; j++) {
      if(A[i][j] == B[0][0]) {
	for(s = 0; s < M; s++) {
	  for(t = 0; t < M; t++) {
	    if(A[i+s][j+t] != B[s][t]) {
	      tmp = 0;
	      break;
	    }
	  }
	  if(tmp == 0) {
	    tmp = 1;
	    break;
	  }
	}
	if(s == M && t == M) {
	  f = 1;
	  break;
	}
      }
      if(f == 1) {
	break;
      }
    }
    if(f == 1) {
      break;
    }
  }

  if(f == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
n=int(input())
a=[None]*n
b=list(map(int,input().split()))
a[0]=b[0]
a[-1]=b[-1]
for i in range(1,n-1):
    if b[i]>=b[i-1]:
        a[i]=b[i-1]
    else:
        a[i]=b[i]
print(sum(a))

Measured memory_bytes: 38384
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;
int n, x=0, a[20];
void dfs(int pos, int sum)
{
    if(pos == n)
    {
        if((sum&1) == 0) ++x;
        return;
    }
    dfs(pos+1, sum*(a[pos]-1));
    dfs(pos+1, sum*(a[pos]));
    dfs(pos+1, sum*(a[pos]+1));
}
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; ++i) scanf("%d",&a[i]);
    dfs(0, 1);
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 256
N=int(input())
#N個以下
ans=0
if N<=104:
  ans=0
elif N==105:
  ans=1
else:#106から調べる
  ans=1
  for i in range(106,N+1):#その中のそれぞれの数値
    if i%2==0:
      continue
    cnt=0
    for j in range(1,i+1):
      if i%j==0:#素数の数を数える
        cnt+=1
        if cnt>8:
          break
    if cnt==8:
      ans+=1
print(ans)  

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int dp[1 << 16];
int table[16][17];

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0){ break; }
		for(int i = 0; i < (1 << N); ++i){ dp[i] = 0x3fffffff; }
		for(int i = 0; i < N; ++i){
			for(int j = 0; j <= N; ++j){ cin >> table[i][j]; }
		}
		queue<int> q;
		dp[0] = 0;
		q.push(0);
		while(!q.empty()){
			int x = q.front();
			q.pop();
			for(int i = 0; i < N; ++i){
				if(x & (1 << i)){ continue; }
				int minCost = table[i][0];
				for(int j = 0; j < N; ++j){
					if(x & (1 << j)){ minCost = min(minCost, table[i][j + 1]); }
				}
				int next = x | (1 << i), cost = dp[x] + minCost;
				if(cost < dp[next]){
					dp[next] = cost;
					q.push(next);
				}
			}
		}
		cout << dp[(1 << N) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,R,B;
  long long  loop;
  cin >> N >> B >> R;
  if(B == 0){
  	cout << 0 <<  endl;
  }else if( N >= (B + R)){
  	loop = N / (B + R);
    if( (N - (loop*(B + R))) >= B){
    	cout << (B * loop) + B << endl;
    }else{
    	cout << (B * loop) + ( N - (loop*(B + R)) ) << endl;
    }
  }else if(N < B){
  	cout << N << endl;
  }else if(N < (B + R)){
  	cout << B << endl;
  }
}

Measured memory_bytes: 256
function main(input: string) {
  const w: string = input.split("\n")[0];
  const count = w.split("").reduce((count, char) => {
    if (count[char] == null) {
      count[char] = 1;
    } else {
      count[char] += 1;
    }
    return count;
  }, {});
  if (Object.keys(count).some((char: string) => count[char] % 2 === 1)) {
    console.log("No");
  } else {
    console.log("Yes");
  }
}

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


Measured memory_bytes: 7372
package main

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

func calc(x int) int {
	sum := 1
	for {
		if sum >= x {
			return sum
		}
		sum <<= 1
	}
}

func calc1(x int) int {
	sum := 1
	for {
		if sum > x {
			return sum >> 1
		}
		sum <<= 1
	}
}

func main() {
	a, b := readInt(), readInt()

	c := calc(a)
	for c-a >= 64 {
		c -= calc1(c - a)
	}

	d := calc1(b)
	for b-d >= 64 {
		d += calc1(b - d)
	}
	// fmt.Println("c, d = ", c, d)
	// fmt.Println("c, d = ", c-a, b-d)

	if b-a < 64 {
		c = a
		d = a
	}

	ans := 0
	for i := a; i < c; i++ {
		ans ^= i
	}
	for i := d; i <= b; i++ {
		ans ^= i
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s,sl="",sr=""; cin>>s;
    int q,cnt; cin>>q;
    rep(i,q){
        int t; cin>>t;
        if(t==1){
            cnt++;
        }
        else{
            int f; cin>>f;
            char c; cin>>c;
            if((f+cnt)%2) sl=sl+c;
            else sr=sr+c;
        }
    }
    reverse(al(sl));
    if(cnt%2){
        reverse(al(s));
        reverse(al(sl));
        reverse(al(sr));
        cout<<sr<<s<<sl<<endl;
    }
    else cout<<sl<<s<<sr<<endl;
}


Measured memory_bytes: 1456
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define Int long long
#define rep(i, n) for (Int i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

int main() {
  int a;
  string s;
  cin >> a >> s;

  if (3200 <= a) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int k;
  int val = 10, count = 0;
  cin >> k;
  if (k==1) {
    printf("1\n");
    return 0;
  }
  if (!(k%7)) k /= 7;
  if (!(k%5)||!(k%2)) {
    printf("-1\n");
    return 0;
  }
  k*=9;
  for (int i = 0; i<=k; i++) {
    val%=k;
    if (val==1) {
      count = i;
      break;
    }
    val*=10;
  }
  cout << count+1 << endl;
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a+b<c)?"No":"Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
  string N;
  cin >> N;
string N_nomal =  N;
  reverse(all(N));

  if(N == N_nomal){
cout << "Yes" << endl;
  }else{
cout << "No" << endl;
  }

    return 0;
}


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

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

int main()
{
  int W, H;
  cin >> W >> H;
  vector<long long int> p(W), q(H);
  rep(i, W)
    {
      cin >> p[i];
    }
  rep(i, H)
    {
      cin >> q[i];
    }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  long long int cnt_w = 0, cnt_h = 0;
  long long int cost = 0;
  while(1)
    {
      if(cnt_w == W && cnt_h == H)
	{
	  break;
	}
      if(cnt_w == W)
	{
	  cost += q[cnt_h] * (W + 1 - cnt_w);
	  cnt_h++;
	  continue;
	}
      if(cnt_h == H)
	{
	  cost += p[cnt_w] * (H + 1 - cnt_h);
	  cnt_w++;
	  continue;
	}
      if(p[cnt_w] <= q[cnt_h])
	{
	  cost += p[cnt_w] * (H + 1 - cnt_h);
	  cnt_w++;
	  continue;
	}
      if(q[cnt_h] <= p[cnt_w])
	{
	  cost += q[cnt_h] * (W + 1 - cnt_w);
	  cnt_h++;
	  continue;
	}
      
    }
  cout << cost << endl;
  
  return 0;
}


Measured memory_bytes: 1792
s = input()
k = int(input())

vals = []
cur = s[0]
strk = 1

for i in range(1, len(s)):
    if s[i] == cur:
        strk += 1
    else:
        vals.append([cur, strk])
        cur = s[i]
        strk = 1
vals.append([cur, strk])

if len(vals) == 1:
    print((vals[0][1] * k) // 2)
else:
    if vals[0][0] == vals[-1][0]:
        start = vals[0][1] // 2
        join = (vals[0][1] + vals[-1][1]) // 2
        end = vals[-1][1] // 2

        middle = 0
        for i in range(1, len(vals)-1):
            middle += vals[i][1] // 2

        print(start + k*middle + (k-1)*join + end)
    else:
        cnt = 0
        for val in vals:
            cnt += (val[1]) // 2

        print(cnt*k)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, long long C, long long D, std::string S)
{
    for (int i = A - 1; i < C - 1; i++)
    {
        if (S[i] == '#' && S[i + 1] == '#')
        {
            cout << NO << endl;
            return;
        }
    }

    for (int i = B - 1; i < D - 1; i++)
    {
        if (S[i] == '#' && S[i + 1] == '#')
        {
            cout << NO << endl;
            return;
        }
    }
    if (C < B)
    {
        cout << YES << endl;
        return;
    }
    else
    {
        if (C < D)
        {
            cout << YES << endl;
            return;
        }
        else
        {
            for (int i = B - 1; i <= D - 1; i++)
            {
                if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
                {
                    cout << YES << endl;
                    return;
                }
            }
            cout << NO << endl;
        }
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long D;
    scanf("%lld", &D);
    std::string S;
    std::cin >> S;
    solve(N, A, B, C, D, S);
    return 0;
}


Measured memory_bytes: 772
#include <iostream>

using ll = long long;

ll solve(const ll &a, const ll &b, const ll &c) {
    if (a%2 == 0 || b%2 == 0 || c%2 == 0) return 0;
    return std::min( a*b, std::min(b*c, c*a) );
}

int main() {
    ll a, b, c;
    std::cin >> a >> b >> c;
    std::cout << solve(a, b, c) << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

const int MN = 550;
bool g[MN][MN];
int dp1[MN][MN], dp2[MN][MN];
bool solve() {
    int h, w;
    cin >> h >> w;
    if (!h) return false;
    for (int y = 0; y < h; y++) {
        string s; cin >> s;
        for (int x = 0; x < w; x++) {
            g[y][x] = s[x] == '*';
        }
    }
    memset(dp1, 0, sizeof(dp1));
    int ans = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            dp2[x][x+1] = dp1[x][x+1];
            if (g[y][x]) dp2[x][x+1] = y+1;
        }
        for (int d = 2; d <= w; d++) {
            for (int l = 0; l <= w-d; l++) {
                int r = l+d;
                dp2[l][r] = max(dp2[l+1][r], dp2[l][r-1]);
            }
        }
        for (int l = 0; l < w; l++) {
            for (int r = l+1; r <= w; r++) {
                dp1[l][r] = dp2[l][r];
                ans = max(ans, (r-l)*(y+1-dp1[l][r]));
            }
        }
    }
    printf("%d\n", ans);
    return true;
}

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

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (long i = (s); i < (long)(n); i++)
 
int main() {
    long n;
    cin>>n;
 
    vector<long>a(n+1);
    rep(i,0,n+1){
        cin>>a[i];
    }
 
    vector<long>b(n);
    rep(i,0,n){
        cin>>b[i];
    }
 
    long sum=0;
 
    rep(i,0,n){
        long x=min(a[i],b[i]);
        sum+=x;
        a[i]-=x;
        b[i]-=x;
        x=min(a[i+1],b[i]);
        sum+=x;
        a[i+1]-=x;
    }
 
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e12
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    vector<pair<ll,ll>> ar(n);
    vector<ll> dp(h+1,inf);
    dp[0]=0;
    for(ll x=0;x<n;x++){
        cin>>ar[x].first>>ar[x].second;
        for(ll y=0;y<=h;y++){
            dp[min(h,y+ar[x].first)]=min(dp[min(h,y+ar[x].first)],dp[y]+ar[x].second);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final long A = sc.nextLong();
		final long B = sc.nextLong();
		final long C = sc.nextLong();
		
		if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
			System.out.println(0);
		}else{
			System.out.println(Math.min(A * B, Math.min(B * C, C * A)));
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8020
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mp make_pair
#define pb push_back
#define ii pair<int, int>

int a[100001];

int main()
{
    int n;
    cin>>n;
    vector<ii> a;
    for(int i =0;i < n;i ++){
        int x;
        cin>>x;
        if(x == i + 1){
            if(a.empty())a.pb(mp(x, 1));else {
                ii w = a.back();
                //a.erase(a.back());
                //vector<ii>::const_iterator it = a.back();
                //a.erase(a.size() - 1);
                //a.erase()
                if(w.first == x - 1){
                    //a.pb(mp(x, a.second + 1));
                    a.back().first = x;
                    a.back().second++;
                }else{
                    //a.pb(w);
                    a.pb(mp(x, 1));
                }
            }
        }
    }
    int cnt = 0;
    for(auto i: a){
        if(i.second == 1)cnt ++;else cnt += (i.second/2) + i.second%2;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

int R_paired[101];

void solve()
{
    int N;
    cin >> N;
    vector<pii> R(N);
    vector<pii> B(N);

    REP0(i, N)
    {
        cin >> R[i].first >> R[i].second;
    }

    REP0(i, N)
    {
        cin >> B[i].first >> B[i].second;
    }

    sort(R.begin(), R.end());
    sort(B.begin(), B.end());

    int ans = 0;

    for (auto b : B)
    {
        int max_r_y = -1;
        int argmax_r_y = -1;

        for (int i = 0; R[i].first < b.first and i < N; i++)
        {
            if (R_paired[i])
                continue;

            if (max_r_y <= R[i].second and R[i].second < b.second)
            {
                max_r_y = max(R[i].second, max_r_y);
                argmax_r_y = i;
            }
        }

        if (argmax_r_y != -1)
        {
            R_paired[argmax_r_y] = 1;
            ans++;
        }
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
a = int(input())

if a <= 6:
    print(1)
else:
    if 7 <= a <= 11:
        print(2)
    else:
        t = a // 11
        a -= t * 11
        if 1 <= a <= 6:
            s = 1
        elif 7 <= a:
            s = 2
        else:
            s = 0
        print(t*2 + s) 

Measured memory_bytes: 38384
A, B, C, X, Y = map(int, input().split())
m_value = float('inf')
for ab in range(max(X, Y) + 1):
    ab2 = 2 * ab
    a = X - ab
    b = Y - ab
    tmp = C * ab2
    if a > 0:
        tmp += a * A
    if b > 0:
        tmp += b * B
    m_value = min(m_value, tmp)
print(m_value)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < n; ++i)



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

    char x;
    cin >> x;

    if (x >= 'a' && x <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	vc a(n+1);
	for(i=1;i<=n;i++)cin>>a[i];
	ll cnt=0;
	for(i=2;i<=n;i++)
	{
	    if(a[i-1]>a[i])
	    {
	        cnt+=a[i-1]-a[i];
	        a[i]=a[i-1];
	    }
	}cout<<cnt;
	return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>


int main(void) {

	// 1_8-C Counting Characters
	// ?????????????????±??????????????????????????¢???????????????????????°???
	// ??°??????????????°??????
	
	char str[1200];
	char chr[26];
	int i,j,len;

	for(j=0; j<26; j++){
		chr[j] = 0;
	}

	// 1?????????????????????
	str[0] = getchar();
	i = 0;
	// 
	while(str[i]!=EOF){
		for(j=0; j<26; j++){
			if( (('a'+j)==str[i]) || (('A'+j)==str[i])){
				chr[j]++;
			}
		}
		i++;
		str[i] = getchar();
	}
	len = i;
	for(i=0; i<26; i++){
		printf("%c : %d\n",'a'+i,chr[i]);
	}

	return 0;
}

Measured memory_bytes: 524
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()
    A.sort()

    C = [0]
    for a in A:
        C.append(C[-1] + a)

    t = 0
    for i, (a, c) in enumerate(zip(A[1:], C[1:-1])):
        # 1~kまでのサイズの和の2倍がk+1番目の生き物のサイズ未満なら1~kは最後まで生き残れない
        if a > 2 * c:
            t = i + 1

    return n - t


print(main())


Measured memory_bytes: 14684
#include<cstdio>
#define N 200010
#define F for(register int j(1);j<=now;j++)
int n,m,k,now,cnt,pre[N],a[N],b[N],opt[N],head[N],nxt[N<<1],dis[N<<1];
bool used[N];
int find(int x)
{
	return !pre[x]?x:pre[x]=find(pre[x]);
}
inline void add(int x,int y)
{
	dis[++cnt]=y,nxt[cnt]=head[x],head[x]=cnt;
	return;
}
void dfs(int x)
{
	used[x]=1,a[++now]=x;
	for(register int i(head[x]);i;i=nxt[i])
		if(!used[dis[i]])
			dfs(dis[i]);
	return;
}
signed main()
{
	scanf("%d%d%d",&n,&m,&k);int x,y;
	while(m--)
		scanf("%d%d",&x,&y),(x=find(x))-(y=find(y))?pre[x]=y:8;
	while(k--)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(register int i(1);i<=n;i++)
		if(!used[i])
		{
			dfs(i);
			F
				b[find(a[j])]++;
			F
				opt[a[j]]=b[find(a[j])];
			F
				b[find(a[j])]--;
			now=0;
		}
	for(register int i(1);i<=n;i++)
		printf("%d%c",opt[i],i-n?32:10);
	return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  int ans = 1;
  string s;

  cin >> N >> s;

  if(N%2 != 0) ans = 0;
  REP(i, N/2){
    if(s[i] != s[i+N/2]) ans = 0;
  }

  if(ans) Yes;
  else No;

  return 0;
}

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

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

  int ans = 0;
  int m = n + 1;
  for (int i = 0; i < n; i++) {
    m = min(p[i], m);
    if (m == p[i]) ans++;
  }

  cout << ans;
  
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > L;





int main()
{

	cin >> N;

	L.resize(N*2);

	REP(i,N*2){
		cin >> L[i];
	}


	sort(L.begin(),L.end());

	int ans=0;
	REP(i,N){
		ans+=L[i*2];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin,(x).end()
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define fastCin ios::sync_with_stdio(false)
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const db pi=acos(-1);
const int mod=1e9+7;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll quickpow(ll x,ll k) //x^k
{
	ll ans=1;
	while (k)
	{
		if (k&1) ans=ans*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ans;
}
int main()
{
	fastCin;
	int n;
	for (int i=1;i<=5;i++)
	{
		int k;
		cin>>k;
		if (k==0) cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 3596