akhauriyash/Code-Regression huggingface dataset:
s=int(input())
n=10**6
hist=[0]*(n+1)

a=s
ans=0
for i in range(n):
    if hist[a]==0:
        hist[a]+=1
    else:
        ans=i+1
        break
    if a%2==1:
        a=3*a+1
    else:
        a=a//2
print(ans)



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
int A[88][88], B[88][88];
bool dp[88][88][160 * 80 * 2 + 100];
signed main() {
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) { cin >> A[i][j]; }
    }
    rep(i, H) {
        rep(j, W) { cin >> B[i][j]; }
    }
    dp[0][0][160 * 80 + 5] = true;
    rep(i, H) {
        rep(j, W) {
            rep(k, 160 * 80 * 2 + 100) {
                if (!dp[i][j][k]) { continue; }
                dp[i + 1][j][k + A[i][j] - B[i][j]] = true;
                dp[i][j + 1][k + A[i][j] - B[i][j]] = true;
                dp[i + 1][j][k - A[i][j] + B[i][j]] = true;
                dp[i][j + 1][k - A[i][j] + B[i][j]] = true;
            }
        }
    }
    int ans = LLONG_MAX;
    rep(i, 160 * 80 * 2 + 100) {
        if (dp[H - 1][W][i]) { chmin(ans, abs(i - (160 * 80 + 5))); }
    }
    cout << ans << endl;
}


Measured memory_bytes: 179328
[n,m]=list(map(int,input().split()))
alist=[]
blist=[]
counter=0
for i in range(n):
    alist.append(list(input()))
for i in range(m):
    blist.append(list(input()))
clist=[]
if n!=m:
    for i in range(n-m):
        for j in range(n-m):
            for k in range(m):
                kari=[]
                for l in range(m):
                    kari.append(alist[i+k][j+l])
                clist.append(kari)
            
            if blist==clist:
                counter=1
                break
            clist=[]

else:
    if alist==blist:
        counter=1

if counter==1:
    print("Yes")
else:
    print("No")

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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;




int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;

    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int a[];
		int max;

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}

			a = new int[n + m];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < m; i++) {
				a[n + i] = sc.nextInt();
			}
			Arrays.sort(a);
			max = a[0];
			for (int i = 1; i < n + m; i++) {
				max = Math.max(max, a[i] - a[i - 1]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 63852
from collections import deque
from typing import List


def main():
    n = int(input())
    v = input().split(" ")
    print(*pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    ret = []
    for i in range(len(x)):
        ret.append(x.pop())

    for i in range(len(y)):
        ret.append(y.popleft())

    return ret


if __name__ == "__main__":
    main()


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

int main()
{
    int N, K;
    string S;

    cin >> N >> S >> K;

    for (int i = 0; i < N; i++) {
        if (S[K-1] != S[i]) {
            S[i] = '*';
        }
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main () {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S[K-1] == 'A') S[K-1] = 'a';
  else if (S[K-1] == 'B') S[K-1] = 'b';
  else if (S[K-1] == 'C') S[K-1] = 'c';

  cout << S;
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> m;
    vector<ll>arr(n);
    ll sum = 0;
    for(int i=0;i<n;i++){

    	cin >> arr[i];
    	sum += arr[i];
    }
    double d = sum /(4.0 * m);
    sort(arr.rbegin(),arr.rend());
    ll p = 0;
    for(int i=0;i<n;i++){
    	if(arr[i] >= d)
    		p++;
    }
    if(p>=m)
    	cout << "Yes";
    else
    	cout << "No";

    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      string w;
      cin >> w;
      a[i] = w.size();
    }
    for (int i = 0; i < n; ++i) {
      int s = 0;
      set<int> se;
      for (int j = i; j < n; ++j) {
        se.insert(s += a[j]);
      }
      if (se.count(5) and se.count(12) and se.count(17) and se.count(24) and se.count(31)) {
        cout << i + 1 << '\n';
        break;
      }
    }
  }
}



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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
#define FOR(x,to) for(x=0;x<(to);x++)
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________

const int N = 100 * 1002;
int par[N], sz[N], n, m;

void init()
{
    for(int i = 1; i <= n; i++)
    {
        par[i] = i;
        sz[i] = 1;
    }
}

int Find(int v)
{
    if(par[v] == v)
        return v;
    return par[v] = Find(par[v]);
}

void Join(int u, int v)
{
    u = Find(u);
    v = Find(v);

    if(u == v)
        return;

    if(sz[u] < sz[v])
        swap(u, v);

    par[v] = u;
    sz[u] += sz[v];
    sz[v] = 0;
}

int32_t main()
{ 
  __
  
  int x, y, z, ans = 0;

  cin >> n >> m;

  init();

  for(int i = 1; i <= m; i++)
  {
    cin >> x >> y >> z;
    Join(x, y);
  }

  for(int i = 1; i <= n; i++)
    if(Find(i) == i)
        ans++;

  cout << ans;
 
 return 0;
}

Measured memory_bytes: 1792
# coding: utf-8

import sys
from collections import deque

n, q = map(int, input().split())
total_time = 0
tasks = deque(map(lambda x: x.split(), sys.stdin.readlines()))

try:
    while True:
        t = tasks.popleft()
        if int(t[1]) - q <= 0:
            total_time += int(t[1])
            print(t[0], total_time)
        else:
            t[1] = str(int(t[1]) - q)
            total_time += q
            tasks.append(t)
except Exception:
    pass

Measured memory_bytes: 23072
/*
She came from the past
She was never meant to last
Her destiny was fatal
From the start
A messenger from hell
She cast a deadly spell
On all of those who dare
To cross her heart
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
History foretold of a circle
Cast in gold
An evil seed of power
Sealed within
But fate has lent a hand
Destroyed the golden band
And freed her soul
To wash the land with sin
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
She cast a deadly spell
She put a spell on you
She's got evil in her heart
Turn your heart into stone
Turn your heart into stone
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int pr[N],dp[222][222];
int cnt[222];
int n;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	pr[1]=1;
	for (int i=2;i<=1000;i++){
		if (pr[i]==0){
			for (int j=i*2;j<=1000;j+=i)
				pr[j]=1;
		}
	}

	cin>>n;
	for (int i=2;i<=n;i++){
		if (pr[i])
			continue;
		int val=n;
		while (val){
			cnt[i]+=val/i;
			val/=i;
		}
	}

	dp[1][1]=1;
	for (int i=1;i<=n;i++){
		for (int have=0;have<=75;have++){
			for (int take=1;take<=cnt[i]+1;take++){
				if (have*take>75)
					continue;
				dp[i+1][have*take]+=dp[i][have];
			}
		}
	}

	cout<<dp[n][75]<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    string res = "NA";
    if (s.length() == 4) {
        int f = 0;
        int a = stoi(s.substr(0, 2));
        int b = stoi(s.substr(2));
        for (int i = 0; i < 2; ++i) {
            if (a > 0 && a <= 12 && b >= 0 && b <= 99) {
                f |= 1 << i;
            }
            swap(a, b);
        }

        if (f == 1) {
            res = "MMYY";
        } else if (f == 2) {
            res = "YYMM";
        } else if (f == 3) {
            res = "AMBIGUOUS";
        }

    }
    
    cout << res << "\n";

    return 0;
}

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

long long N;

int main(){
	cin>>N;
	long long curr=7,pos=1;
	if(N%2==0||N%5==0){
		cout<<-1<<'\n'; return 0;
	}
	while(true){
		if(curr%N==0){
			cout<<pos<<'\n';
			break;
		}else{
			curr=curr%N;
			curr=curr*10+7;
			pos++;
		}
	}
}

Measured memory_bytes: 3632
#include<iostream>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main() {

	//input
	string S;
	cin >> S;

	//compute
	if (S == "Sunny")S = "Cloudy";
	else if (S == "Cloudy")S = "Rainy";
	else if (S == "Rainy")S = "Sunny";

		//output
	cout << S;


		return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		string s = Console.ReadLine();
		char c = s[0];
		int d = (int)c;
		d++;
		char e = (char)d;
		string ans = e.ToString();
		Console.WriteLine(ans);
		
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){

    int x,y;

    scanf("%d %d",&x,&y);
    // printf("%d %d\n",x,y);

    int flag=0;
    int tmp=0;
    int a=0;

    if(2*x==y || 4*x==y){
        flag=1;
    }else if (2*x<y){
        tmp=(y-2*x)%2;
        a=x-(y-2*x)/2;
        if (tmp==0 && a>0){
            flag=1;
        }
    }

    if (flag==1)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++)cin >> P[i];

	int cnt = 0;
	int mi = 50505050;
	for (int i = 0; i < N; i++) {
		cnt += (P[i] <= mi);
		mi = min(mi, P[i]);
	}
	puts(cnt);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;


int main(){
    int n,m,k;
    cin >> n >> m >> k;
    //i番とのブロック関係の数
    vector<int> bl[100005];
    // i番との友達
    vector<int> fr[100005];
    // group関係
    vector<int> gr(n,-1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        fr[a].push_back(b);
        fr[b].push_back(a);
    }
    int g=0;
    rep(i,n){
        // グループ化済み
        if(gr[i]!=-1){
            // cout << "gr[i]!=-1 => " << i << endl;
            continue;
        }
        stack<int> s;
        // O(n^2)かからんか？
        // stackの初期化
        // cout << endl;
        // rep(j,fr[i].size()){
        //     s.push(fr[i][j]);
        //     // cout << i << " friend:" << fr[i][j] << endl;
        // }
        // cout << endl;
        // cout <<"i "<< i <<  "i's number of friend" << fr[i].size()<<endl;

        // i番目の人にgroup番号gを振る
        gr[i]=g;
        s.push(i);
        while(!s.empty()){
            int f = s.top();s.pop();
            rep(j,fr[f].size()){
                int v = fr[f][j];
                if(gr[v]==-1){
                    s.push(v);
                    gr[v]=g;
                }
                // s.push(fr[i][j]);
                // if(gr[f]!=-1)continue;
            }
        }
        ++g;
    }
    // rep(i,n)cout<<gr[i]<<endl;
    // グループ番号を整理
    vector<ll> gr_count(g,0);
    rep(i,n){
        ++gr_count[gr[i]];
    }
    // ブロック関係について調べる.
    rep(i,k){
        int c,d;
        cin >> c >> d;
        --c;--d;
        bl[c].push_back(d);
        bl[d].push_back(c);
    }
    // 出力
    rep(i,n){
        ll ans=0;
        ans = gr_count[gr[i]] -1 - fr[i].size();
        // block関係を引く
        rep(j,bl[i].size()){
            if(gr[bl[i][j]]==gr[i])--ans;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12152
import os
import sys

import numpy as np


def solve(inp):
    def bit_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def bit_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    n = int(inp[0])
    lim = (n * (n - 1) // 2 + 1) // 2
    aaa = inp[1::3]
    bbb = inp[2::3]
    ccc = inp[3::3]

    inclines_x = [(aaa[i] / bbb[i], i) for i in range(n)]
    inclines_y = [(bbb[i] / aaa[i], i) for i in range(n)]
    inclines_x.sort()
    inclines_y.sort()
    incline_rank_x = np.zeros(n, dtype=np.int64)
    incline_rank_y = np.zeros(n, dtype=np.int64)
    for k in range(n):
        incline_rank_x[inclines_x[k][1]] = n - k
        incline_rank_y[inclines_y[k][1]] = n - k

    def check_x(m):
        yyy = [((ccc[i] - aaa[i] * m) / bbb[i], i) for i in range(n)]
        yyy.sort()

        bit = np.zeros(n + 1, dtype=np.int64)
        intersection_left = 0
        for j in range(n):
            i = yyy[j][1]
            k = incline_rank_x[i]
            intersection_left += bit_sum(bit, k)
            bit_add(bit, n + 1, k, 1)

        return intersection_left >= lim

    def check_y(m):
        xxx = [((ccc[i] - bbb[i] * m) / aaa[i], i) for i in range(n)]
        xxx.sort()

        bit = np.zeros(n + 1, dtype=np.int64)
        intersection_left = 0
        for j in range(n):
            i = xxx[j][1]
            k = incline_rank_y[i]
            intersection_left += bit_sum(bit, k)
            bit_add(bit, n + 1, k, 1)

        return intersection_left >= lim

    l = -2.0 * 10 ** 8
    r = 2.0 * 10 ** 8
    while r - l > 1e-9 and abs((r - l) / l if l != 0 else r) > 1e-9:
        m = (l + r) / 2
        if check_x(m):
            r = m
        else:
            l = m
    x = l

    l = -2.0 * 10 ** 8
    r = 2.0 * 10 ** 8
    while r - l > 1e-9 and abs((r - l) / l if l != 0 else r) > 1e-9:
        m = (l + r) / 2
        if check_y(m):
            r = m
        else:
            l = m
    y = l

    return x, y


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(f8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(f8[:],)', cache=True)(solve)

inp = np.fromstring(sys.stdin.buffer.read(), dtype=np.float64, sep=' ')
x, y = solve(inp)
print(x, y)


Measured memory_bytes: 29716
package main

// Solution for https://atcoder.jp/contests/abc179/tasks/abc179_b

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	var z, zmax int
	for i := 0; i < n; i++ {
		var d1, d2 int
		con.Scan(&d1, &d2)
		if d1 == d2 {
			z++
			if z > zmax {
				zmax = z
			}
		} else {
			z = 0
		}
	}
	if zmax >= 3 {
		con.Println("Yes")
	} else {
		con.Println("No")
	}
	return nil
}


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

void solve(int N, std::vector<int> X) {
  // int P = round(sqrt(accumulate(X.cbegin(), X.cend(), 0LL, [&](int acc, int x) {return acc + pow(x, 2);} ) / N));
  // cout << (accumulate(X.cbegin(), X.cend(), 0LL, [&](int acc, int x) {return acc + pow(x - P, 2);} )) << endl;
  int P = round(accumulate(X.cbegin(), X.cend(), 0) * 1.0 / N);
  cout << (accumulate(X.cbegin(), X.cend(), 0L, [&](int acc, int x) {return acc + pow(x - P, 2);} )) << endl;
}

// 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)
int main() {
  int N;
  cin >> N;
  std::vector<int> X(N);
  for (int i = 0 ; i < N ; i++) {
    cin >> X[i];
  }
  solve(N, std::move(X));
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
             String A = nstr(sc);
             String B = nstr(sc);

            BigDecimal bA = new BigDecimal(A);
            BigDecimal bB = new BigDecimal(B);

            if (bA.compareTo(bB) == 1) {
                out.println("GREATER");
            }else if (bA.compareTo(bB) == 0){
                out.println("EQUAL");
            }else {
                out.println("LESS");
            }


        }
    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 25300
import collections

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

c = collections.Counter(a).most_common()

cnt = 0
cntdiff = 0
for i, j in c:
    cntdiff += 1
    if cntdiff > k:
        cnt += j
print(cnt)


Measured memory_bytes: 39344
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi d(n);
    int s=0;
    rep(i,n)cin>>d[i],s+=d[i];
    int ans=0;
    rep(i,n)ans+=d[i]*(s-d[i]);
    ans/=2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main()
{
    int n,cnt=0;;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;;i++)
    {
        bool pd=true;
        for(int j=1;j<=n;j++) 
        {
            if(a[j]%2!=0)
            {
                pd=false;
                break;
            } 
        }
        if(pd==false)break;
        if(pd)
        {
            cnt++;
            for(int j=1;j<=n;j++)
                a[j]/=2;
        } 
    } 
    cout<<cnt; 
    return 0;
}

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

#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i<=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s,t;
  cin >> s >>t;
  int a;
  a=0;
//cout << t.size() <<"ZZZ"<<s.size()<<endl;
  if(t.size()==s.size()+1){
    a=0;
    //cout <<"selected up";
  }else{
    a=1;
    //cout <<"selected down";
  }

for(int i = 0; i < s.size(); i++){
  if(s.at(i)!=t.at(i)){
    a=1;
   // cout << i <<endl;
  }
}
if(a==1){
 cout<<"No";
}else{
  cout <<"Yes";
}

}


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

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var nab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            var k = n / (a + b);
            var km = n % (a + b);
            var ans = (a) * k;
            if (km > a)
            {
                ans += a;
            }
            else
            {
                ans += km;
            }

            Console.WriteLine(ans);

            
            
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <list>
#include <algorithm>

using namespace std;

// Returns 1 if the i-th bit of x is set, 0 otherwise.
#define BIT_SET(x, i) (((x) & (1<<(i))) != 0)
// Sets the i-th bit of x to 1
#define SET_BIT(x, i) ((x) | (1<<(i)))
// Sets the i-th bit of x to 0
#define UNSET_BIT(x, i) ((x) & ~(1<<(i)))

vector<int> parent;
vector<int> size;
unordered_map<int, vector<int>> spoken;
int N, M, Kj, Ljk;

int rep(int item) {
    if (parent[item] == -1)
        return item;
    return parent[item] = rep(parent[item]);
}

int setSize(int item) {
    return size[rep(item)];
}

void union2(int a, int b) {
    int ra = rep(a); int rb = rep(b);
    if (ra == rb)
        return;
    if (size[ra] < size[rb]) {
        size[rb] += size[ra];
        parent[ra] = rb;
    }
    else {
        size[ra] += size[rb];
        parent[rb] = ra;
    }
}

void solve() {
    cin >> N >> M;
    for (int j = 0; j < N; j++) {
        cin >> Kj;
        for (int k = 0; k < Kj; k++) {
            cin >> Ljk;
            spoken[Ljk].push_back(j);
        }
    }
    parent.resize(N, -1);
    size.resize(N, 1);
    for (auto l: spoken)
        for (int k = 1; k < l.second.size(); k++)
            union2(l.second[0], l.second[k]);
    cout << (setSize(1) == N ? "YES" : "NO") << endl;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //std::istream& in(std::cin);
    //std::ostream& out(std::cout);
    solve();
    return 0;
}


Measured memory_bytes: 6668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

	int mod = 1000000007;

	void solve(){

		ini(n);
		ini(n1);
		out(modpow(n,n1,mod));
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 3216
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll x;
    cin >> x;
    cout << 1 - x << endl;
    return 0;
}


Measured memory_bytes: 3224
// Together
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define total 100010

int main() {
    int N;
    cin >> N;
    vector<int> a(total);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    int count;
    int max_count = 0;
    for (int X = 1; X < total-1; X++) {
        max_count = max(max_count, a[X-1]+a[X]+a[X+1]);
    }
    cout << max_count << endl;
}


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

da =[-1] * n
da[n-1] = k - a[n-1] + a[0]
for i in range(n-1):
    da[i] = a[i+1] - a[i]
print(k-max(da))

Measured memory_bytes: 32360
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<limits.h>
#include<string.h>
using namespace std;
int main(){
    //cout<<"a"<<endl;
    int a[200000],n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            break;
        }else if(i==n-2){
            cout<<"YES"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
import heapq


def select(ls0, ls1, k):
    ls = []
    for a in ls0:
        for b in ls1:
            heapq.heappush(ls, -(a + b))
    return [-heapq.heappop(ls) for _ in range(min(k, len(ls0) * len(ls1)))]


x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
ps = select(ls[0], ls[1], k)
res = select(ps, ls[2], k)
print(*res, sep='\n')

Measured memory_bytes: 137708
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf =2e5+9,mod = 1e9+7;

int sz[inf],par[inf],n;

int root(int x){
    return (par[x] == x?x:par[x] = root(par[x]));
}

void join(int x,int y){
    x = root(x);
    y =root(y);
    if(x == y)
    return;
    if(sz[x] > sz[y] )
        swap(x,y);
    par[x] = y;
    sz[y] += sz[x];
}

int main(){
    int m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        par[i] = i,sz[i] = 1;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        join(a,b);
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
        ans = max(ans,sz[ root(i) ]);
    cout<<ans<<endl;
}


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

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    vector<int>a(n),b(n),c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        auto itr1 = lower_bound(a.begin(),a.end(),b[i]);
        auto itr2 = upper_bound(c.begin(),c.end(),b[i]);
        itr1--;
        ll l1 = distance(a.begin(),itr1);
        ll l2 = distance(itr2,c.end());
        ans += (l1+1)*l2;
    }
    cout << ans << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int ans[110000][2];
signed main() {
    cin >> N >> M;
    rep(i, M) { ans[i][0] = i + 1; }
    rep(i, M) {
        { ans[M - i - 1][1] = M + i + 1; }
        if (N % 2 != 1) {
            if (ans[M - i - 1][1] - ans[M - i - 1][0] >= N / 2) { ans[M - i - 1][1]++; }
        }
    }
    rep(i, M) { cout << ans[i][0] << " " << ans[i][1] << endl; }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 200000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

int dp[25][1005] ;

int a[1005] ;

int main()
{
    preprocess() ;

    int n , k ;

    scanf("%d %d",&n,&k) ;

    for(int i=1 ; i<=k ; i++) scanf("%d",&a[i]) ;

    dp[0][0] = 1 ;

    for(int i=1 ; i<=k ; i++)
    {
        dp[i][0] = (1LL*C(n,a[i])*dp[i-1][0])%mod ;
        for(int j=1 ; j<=n ; j++)
        {
            for(int l=0 ; l<=min(a[i],j) ; l++)
            {
                int ret = (1LL*C(j,l)*C(n-l,a[i]-l))%mod ;
                ret = (1LL*ret*dp[i-1][j-l])%mod ;

                dp[i][j] = ( dp[i][j] + ret )%mod ;
            }
        }
    }

    printf("%d\n" , dp[k][n] ) ;

    return 0 ;
}


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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


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


const double EPS = 1e-8;
const long long mod = 1e9 + 7;

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

const int N = 1e6 + 5;
const long long INF = 1e18;



int n , a, b;
vector<pair<int,int> > vec;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a >> b;
        vec.push_back(make_pair(b,a));
    }
    sort(vec.begin(),vec.end());
    int acc[N] = {};
    for(int i = 0; i < n; ++i){
            acc[i] = vec[i].second;
            if(i)
                    acc[i] += acc[i - 1];
    }
    bool can = 1;
    for(int i = 0; i < n; ++i){
        can &= (acc[i] <= vec[i].first);
    }
    cout << (can ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 5872
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで

vector<vector<int>> G;

void dfs(int v, vector<bool> &seen, int &res) // 0、チェック済み配列、まずは0
{
    bool end = true; // 終了フラグ
    for (int i = 0; i < seen.size(); i++) //チェック済み配列の長さ分最大N繰り返す
        if (!seen[i] && i != v) //もしチェック済みじゃなくて、かつ、iがvじゃなければ
            end = false; //終了しない
    if (end) //チェック済みなら
    {
        ++res; //終了する場合はカウンタを加算して返す
        return;
    }

    seen[v] = true; // v を訪問済にする
    for (auto next_v : G[v]) // v から行ける各頂点 next_v について
    {
        if (seen[next_v]) // next_v が探索済だったらスルー
            continue;
        dfs(next_v, seen, res); // 再帰的に探索
    }
    seen[v] = false; //v番目をfalseにする
}

int main()
{
    int N, M; //N頂点、M辺
    cin >> N >> M;
    G.assign(N, vector<int>()); //N個のint型の配列を入れる
    // 各辺と頂点の関係性の表の作成。下記のように各頂点と線でつながってる頂点の表ができる。
    // G[0] {1, 3}
    // G[1] {0, 3}
    // G[2] {0, 1}
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        --a, --b; //配列の0スタートに合わせてる
        G[a].push_back(b);
        G[b].push_back(a); //無向グラフのため
    }
    vector<bool> seen(N, false); //チェック済みの頂点を格納してる配列 初期値はN個のfalse
    int res = 0;
    dfs(0, seen, res); // 頂点 0 をスタートとした探索
    cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	static FastScanner sc = new FastScanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		ArrayList<Integer> s = new ArrayList<>();
		for (int i=0; i<n; i++) {
			s.add(sc.nextInt());
		}
		int m = sc.nextInt();
		int num = 0;
		for (int i=0; i<m; i++) {
			if (s.contains(sc.nextInt())) {num++;}
		}
		out.println(num);
	}
}



class FastScanner implements Closeable {
	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	public FastScanner(InputStream in) {this.in = in;}
	private boolean hasNextByte() {
		if (ptr < buflen) {return true;}
		else{
			ptr = 0;
			try {buflen = in.read(buffer);}
			catch (IOException e) {e.printStackTrace();}
			if (buflen <= 0) {return false;}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {throw new NumberFormatException();}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){return minus ? -n : n;}
			else{throw new NumberFormatException();}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
	public void close() {
		try {in.close();}
		catch (IOException e) {}
	}
}


Measured memory_bytes: 26800
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	ll n,k;
	cin>>n>>k;
	if (n >= k) {
        n %= k;
    }
    n = min(n, k - n);
    cout << n << endl;

	

}

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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 1 ; i <= a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


void solve()
{
	int x[5] , pos = -1;
	f(i, 5)
	{
		cin >> x[i];

		if (x[i] == 0)
			pos = i + 1;
	}

	cout << pos << "\n";
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	int t = 1;
	//cin >> t;


	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n, k, x, y;
  std::cin >> n >> k >> x >> y;
  if (n < k) printf("%d\n", x * n);
  else printf("%d\n", k * x + (n - k) * y);
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256