akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int i,n,s[1024],p[1024],q[1024],r[1024],Q,R,P,C,m;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d%d%d",&s[i],&p[i],&q[i],&r[i]);
		}
		scanf("%d%d%d%d",&P,&Q,&R,&C);
		m=1;
		for(i=0;i<n;i++){
			if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&4*p[i]+9*q[i]+4*r[i]<=C){
				printf("%d\n",s[i]);
				m=0;
			}
		}
		if(m){
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1820
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long int lli;
typedef pair<int,int> mp;
typedef pair<int,mp> mmp;
#define fir first
#define sec second


struct unifo{
	int un;
	int uni[100005];
	void init(int n){
		rep(i,n)uni[i]=i;
		un=n;
	}
	int find(int p){
		if(uni[p]==p)return p;
		else return (uni[p]=find(uni[p]));
	}
	void mer(int p,int q){
		uni[find(p)]=find(q);
	}
	bool same(int p,int q){
		return find(p)==find(q);
	}
};

	
int kruskal(int n,vector<mmp>& es){
	unifo u;
	u.init(n);
	sort(es.begin(),es.end());
	int res=0;
	rep(i,es.size()){
		mmp pa=es[i];
		int a=pa.sec.fir,
			b=pa.sec.sec,
			c=pa.fir;
		if(!u.same(a,b)){
			res+=c;
			u.mer(a,b);
		}
	}
	return res;
}

	
int n,m;

//vector<mp> vs[105];


vector<mmp> es;


int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		//vs[a].push_back(mp(b,c));
		//vs[b].push_back(mp(a,c));
		es.push_back(mmp(c,mp(a,b)));
	}
	printf("%d\n",kruskal(n,es));
	return 0;
}

Measured memory_bytes: 2564
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;
const int INF = 1001001001;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){
    int n, x ,y;
    cin>> n >> x >> y;
    --x,--y;
    vector<int> ans(n);
    rep(sv,n){
        vector<int> dist(n,INF);
        queue<int> q;
        auto push = [&](int v,int d){
            if(dist[v] != INF)return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty()){
            int v = q.front();q.pop();
            int d = dist[v];
            if(v-1 >= 0)push(v-1,d+1);
            if(v+1 < n)push(v+1,d+1);
            if(v == x)push(y,d+1);
            if(v == y)push(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    rep(i,n) ans[i] /= 2;
    for(int i = 1;i <=n-1;++i){
        cout<<ans[i]<<endl;
    }
return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
vector<ll>graph[N];
ll ar[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, m, i, j, u, v, cnt = 0, ans = 0;
    cin >> n >> m;
    for(i = 1; i <= n; i++){
        cin >> ar[i];
    }
    for(i = 0; i < m; i++){
        cin >> u >> v;
        graph[u].eb(v);
        graph[v].eb(u);
    }
    for(i = 1; i <= n; i++){
        cnt = 0;
        for(auto adj: graph[i]){
            if(ar[i] > ar[adj]){
                cnt++;
            }
        }
        if(cnt == graph[i].size()){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14900
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int n;
int a[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	int r = *max_element(a, a + n);
	pii mi(INF, INF);
	
	REP(i, n) {
		if (r == a[i]) continue;
		chmin(mi, pii(abs(a[i] - (r / 2 + 1)), a[i]));
		if (!(r & 1)) chmin(mi, pii(abs(a[i] - (r / 2)), a[i]));
	}
	
	cout << r << " " << mi.se << endl;
	
	
	return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int n, m, d;

int main(){
  cin >> n >> m >> d;
  if(n<1){
    cout << 0 << endl;
  }
  ll c = n-d;
  cerr << "c:" << c << endl;
  double ans = (double)c*(m-1)*2/((double)n*n);
  if(d == 0){
    ans /= 2;
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;


struct SKE{int c1;int m1;int s1;int m2;int s2;int m3;int s3;int m4;int s4;int SUM;};
struct SKE NUM[1000001];
int main (){
int N;
SKE Te,M1,M2,M3,M;
while(1){
cin>>N;if(N==0)break;
for(int i=0;i<N;i++){
	cin>>NUM[i].c1>>NUM[i].m1>>NUM[i].s1>>NUM[i].m2>>NUM[i].s2>>NUM[i].m3>>NUM[i].s3>>NUM[i].m4>>NUM[i].s4;
	NUM[i].SUM=NUM[i].s1+NUM[i].s2+NUM[i].s3+NUM[i].s4+60*(NUM[i].m1+NUM[i].m2+NUM[i].m3+NUM[i].m4);
}

M1=NUM[0];M2=NUM[0];M=NUM[0];M3=NUM[0];
for(int i=1;i<N;i++){
	if(NUM[i].SUM<M1.SUM){M2=M1;M1=NUM[i];}
	else if(NUM[i].SUM<M2.SUM){M2=NUM[i];}
	if(NUM[i].SUM>M.SUM){M3=M;M=NUM[i];}
	else if(NUM[i].SUM>M3.SUM){M3=NUM[i];}

}
for(int i=0;i<N;i++){

}
cout<<M1.c1<<endl<<M2.c1<<endl<<M3.c1<<endl;
for(int i=0;i<N;i++)
{NUM[i].c1=0;NUM[i].m1=0;NUM[i].s1=0;NUM[i].m2=0;NUM[i].s2=0;NUM[i].m3=0;NUM[i].s3=0;NUM[i].m4=0;NUM[i].s4=0;}
}
return 0;
}

Measured memory_bytes: 1356
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n];
        for (int i = 1; i < n; i++) {
            b[i] = sc.nextInt();
        }
        b[0] = b[1];
        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            ans += Math.min(b[i], b[i + 1]);
        }
        ans += b[b.length - 1];
        System.out.println(ans);
    }
}

Measured memory_bytes: 35888
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int N,i,j;
  cin>>N;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(N==4*i+7*j) break;
      else if(4*i+7*j>N) break;
    }
    if(N==4*i+7*j){
        cout<<"Yes"<<endl;
        break;
      }
    if(i==N-1) cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h,w,x,y;

  while(1){
    scanf("%d %d",&h,&w);

    if(h+w == 0) break;

    for(y=0;y<h;++y){
      for(x=0;x<w;++x){
	if(y > 0 && y < h-1 && x > 0 && x < w-1){
	  printf(".");
	}else{
	  printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2044
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

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

		int n=s.nextInt();
		int[][] arr=new int[n][3];
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<3;j++) {
				arr[i][j]=s.nextInt();
			}
		}
		
		int[][] dp=new int[n][3];
		dp[0][0]=arr[0][0];
		dp[0][1]=arr[0][1];
		dp[0][2]=arr[0][2];
		
		for(int i=1;i<n;i++) {
			for(int j=0;j<3;j++) {
				if(j==0) {
					dp[i][j]=Math.max(dp[i-1][1], dp[i-1][2])+arr[i][j];
				}else if(j==1) {
					dp[i][j]=Math.max(dp[i-1][0], dp[i-1][2])+arr[i][j];
				}else {
					dp[i][j]=Math.max(dp[i-1][0], dp[i-1][1])+arr[i][j];
				}
			}
		}
		
		
		int h=Math.max(dp[n-1][0], dp[n-1][1]);
		System.out.println(Math.max(h, dp[n-1][2]));
				
	}
}

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

long long int  pow(long long int a,long long  int b,long long  int MOD)
{
    long long int x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}
long long int InverseEuler(long long int n,long long  int MOD)
{
    return pow(n,MOD-2,MOD);
}
long long int com1(long long int  n,long long  int r,long long  int MOD)
{
long long int i;
    vector<long long int> f(n + 1,1);
    for ( i=2; i<=n;i++)
        f[i]= (f[i-1]*i) % MOD;
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
long long int  Lucas(long long int n,long long int m,long long  int p)
{
    if (n==0 && m==0) return 1;
   long long  int ni = n % p;
   long long  int mi = m % p;
    if (mi>ni) return 0;
    return Lucas(n/p, m/p, p) * com1(ni, mi, p);
}
long long int com(long long int n,long long int r,long long int MOD)
{
    return Lucas(n, r, MOD);
}
 
int main()
{    
	long long int x,y;
  	cin>>x>>y;
  	long long int sum = x + y;
  	if(sum % 3 != 0){
      cout<<0;
      return 0;
    }
  	
  	long long int n = sum/3;
  	long long int r = y - n;
  	long long int p = 1000000007;
  	if(r<0 || n==0){
      cout<<0;
      return 0;
    }
  	cout<<com(n,r,p);
}

Measured memory_bytes: 5504
<?php
fscanf(STDIN, "%d %d", $a, $b);

if ($a <= 0 && $b >= 0) {
    echo "Zero\n";
}

if ($a > 0) {
    echo "Positive\n";
}

if ($b < 0) {
    // echo $b - $a . PHP_EOL;
    if (($b - $a) % 2 === 0)
    {
        echo "Negative\n";
    } else {
        echo "Positive\n";
    }
}


Measured memory_bytes: 4604
#include <iostream>


using namespace std;

int main() {

    int a,b,int_cast_avg;
    double avg;

    cin >> a >> b;

    avg = (a + b) / 2.0;
    int_cast_avg = (int)avg;

    if(int_cast_avg < avg) {
        int_cast_avg++;
    }

    cout << int_cast_avg << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static long ans;

	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] A = new Integer[N];

		int maxIdx = 0;
		int minIdx = 0;
		int min2Idx=0;
		long ans = 0;

		Queue<Integer> q = new PriorityQueue<Integer>(1, Comparator.reverseOrder());

		for(int i = 0;i<N ; i++) {
			q.add(sc.nextInt());
//			ans += A[i]*2;
//			if(A[i] > A[maxIdx]) {
//				maxIdx = i;
//			}
//			if(A[i] < A[minIdx]) {
//
//				min2Idx = minIdx;
//				minIdx = i;
//			}
		}
		ans = 0;

		for(int i = 1;i<N ; i++) {
			if(i==1) {
				ans+=q.poll();
			}else if(i%2 == 0) {
				ans+= q.peek();
			}else {
				ans+=q.poll();
			}
		}


		System.out.println(ans);
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
}


Measured memory_bytes: 65092
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int q;
    cin>>q;
    map<string, int> mp;
    rep(i, q) {
        int c;
        cin>>c;
        if (c == 0) {
            string k;
            cin>>k;
            int x;
            cin>>x;
            mp[k] = x;
        }
        else if (c == 1) {
            string k;
            cin>>k;
            cout<<mp[k]<<endl;
        }
        else if (c == 2) {
            string k;
            cin>>k;
            mp.erase(k);
        }
        else {
            string l, r;
            cin>>l>>r;
            auto it = mp.lower_bound(l);
            auto cl = mp.upper_bound(r);
            for (; it != cl; it = next(it, 1)) {
                if ((*it).second == 0) continue;
                cout<<(*it).first<<" "<<(*it).second<<endl;
            }
        }
    }
}


Measured memory_bytes: 25776
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int a, b;
  cin >> a >> b;
  int ans = (a*b);
  ans /= __gcd(a, b);
  cout << ans;
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


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

using namespace std;

struct P{
	int v;
	int n;
};

int func(P cd[7], int m, int n, int c, int p)
{
	if(c > n){
		return 0;
	}
	if(c == n){
		return 1;
	}
	int s=0;
	for(int i = p; i < m; i++){
		if(cd[i].n > 0){
			cd[i].n--;
			s += func(cd, m, n, c+cd[i].v, i);
			cd[i].n++;
		}
	}
	
	return s;
}

int main()
{
	int n, m, g;
	P cd[7];
	
	while(cin >> m && m){
		for(int i = 0; i < m; i++){
			cin >> cd[i].v >> cd[i].n;
		}
		cin >> g;
		for(int i = 0; i < g; i++){
			cin >> n;
			cout << func(cd, m, n, 0, 0) << endl;
		}
	}
	
	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(a >= b){
        b *= 2;
        k--;
    }
    while(b >= c){
        c *= 2;
        k--;
    }
    if(k >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int H,W,i,j;
  
    while(true){
          cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        else{
            for(j=0;j<W;j++){
                cout<<"#";
                }
                cout<<endl;
                
            for(i=0;i<H-2;i++){
                cout<<"#";
                for(j=0;j<W-2;j++){
                cout<<".";
                }
                cout<<"#"<<endl;
            }
            for(j=0;j<W;j++){
                cout<<"#";
                }
                cout<<endl;
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1152
n, total = map(int, input().split())
x, y, z = -1, -1, -1
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == total:
            x, y, z = i, j, k
print(x, y, z)

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

typedef pair<long, long> mypair;

int main()
{
  int n;
  cin >> n;
  vector<mypair> vec(n);
  for (int i = 0; i < n; i++)
  {
    long work, limit;
    cin >> work >> limit;
    vec.at(i) = make_pair(limit, work);
  }
  sort(vec.begin(), vec.end());
  long work_sum = 0;
  for (int i = 0; i < n; i++)
  {
    mypair p = vec.at(i);
    work_sum += p.second;
    if (work_sum > p.first)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main() {
  int x;cin>>x;
  int ans=1;
  for(int i=2;i<x;i++){
    int a=i*i;
    while(a<=x){
      ans=max(ans,a);
      a*=i;
    }
  }
  cout<<ans<<endl;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	cin.tie(0);
	string s;
	cin >> s;

	int nA = 0;
	ll ans = 0;
	int n = sz(s);
	for(int i = 0; i < n;){
		if(s[i] == 'A'){
			nA++;
			i++;
			continue;
		}
		if(i < n - 1 && s[i] == 'B' && s[i + 1] == 'C'){
			ans += nA;
			i += 2;
			continue;
		}
		i++;
		nA = 0;
	}
	cout << ans;
}

Measured memory_bytes: 3728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

inline bool cmp(const pair <int, int> &fst, const pair <int, int> &sec) {
  if (fst.first != sec.first) {
    return fst.first < sec.first;
  }
  return fst.second > sec.second;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector < pair <int, int> > vec;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    vec.push_back({x, y});
  }
  sort(vec.begin(), vec.end(), cmp);
  int l = vec[0].first, r = vec[0].second;
  int ans = 1;
  for (int i = 1; i < m; i++) {
    if (vec[i].first >= r) {
      ans++;
      l = vec[i].first;
      r = vec[i].second;
    } else {
      l = max(l, vec[i].first);
      r = min(r, vec[i].second);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #a = [list(map(int, input().split())) for i in range(1,n+1)]
    #res = 0

    n=int(input())
    a = [input() for i in range(n)]

    from collections import Counter
    S=Counter(a)
    b = sorted(S.items(), key=lambda x:(-x[1],x[0])) 
    m = b[0][1]
    for i in b:
        if i[1] == m:
            print(i[0])
        else:
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 119052
n = int(input())
ss = list(input())

rcount = 0
gcount = 0
bcount = 0

for s in ss:
  if s == "R":
    rcount += 1
  elif s == "G":
    gcount += 1
  else:
    bcount += 1

sumcount = rcount * gcount * bcount
# print(sumcount)

dist = 1
while dist <= (n - 1) / 2:
  i = 0
  while i + 2 * dist < n:
    if ss[i] != ss[i + dist] and ss[i + dist] != ss[i + 2 * dist] and ss[i + 2 * dist] != ss[i]:
      sumcount -= 1
      # print(ss[i], ss[i+dist], ss[i+dist*2])
    i += 1
  dist += 1

print(sumcount)
    

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans=0;
    ll e=a[0];
    if (e!=0) {cout << -1 << endl;return 0;}
    rep(i,n-1){
        if (a[i]+1<a[i+1]) {cout << -1 << endl;return 0;}
        if (a[i]>=a[i+1]){
            ans+=a[i];
        }
        if (i==n-2) ans+=a[i+1];
    }
    cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    int A[n], ans = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        ans += A[i];
    }

    if(ans % 10) cout << ans << endl;
    else{
        int b = 1e9;
        for(int i = 0; i < n; i++){
            if(A[i] % 10){
                b = min(b, A[i]);
            }
        }
        if(b == 1e9) cout << 0 << endl;
        else cout << ans - b << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; ++i) {
        if(i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <queue>
#include <map>
using namespace std;
const int M=1e9+7;
const int N=200100;
long long a[N],pos[N],n,ans=0;
int main(){
	cin>>n;
	memset(pos,0,sizeof pos);
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=n-1;i>=1;i--) pos[i]=(pos[i+1]+a[i+1])%M;
	for(int i=1;i<=n-1;i++) ans=((ans%M)+(a[i]*pos[i]%M))%M;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6720
#include <iostream>
#include <cstdio>
#include <vector>
#define N 200005
using namespace std;

int n, q, s[N], v[N];
vector<int> g[N];

void f(int p, int q) {
	if(v[p]) return;
	v[p] = true;
	s[p] += q;
	for(int i=0; i<g[p].size(); i++) {
		f(g[p][i], s[p]);
	}
}

int main() {
	int i, a, b;
	cin >> n >> q;
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(q--) {
		scanf("%d%d", &a, &b);
		s[a] += b;
	}
	f(1, 0);
	for(i=1; i<=n; i++) printf("%d ", s[i]);
	return 0;
}


Measured memory_bytes: 24320
#include<stdio.h>
#define N 2000000
#define MAX 100000
void Counting(int *, int *, int);
int a;

int main(){
    int i,A[N];

    scanf("%d",&a);
    for(i = 1;i <= a;i++){
        scanf("%d",&A[i]);
    }
    int B[a];
    Counting(A,B,MAX);

    for(i = 1;i <= a;i++){
        if(i == a)printf("%d\n",B[i]);
        else printf("%d ",B[i]);
    }
    return 0;
}
void Counting(int *A, int *B,int k)
{
    int C[k],i,j;
    for(i = 0;i < k;i++){
        C[i] = 0;
    }
    for(j = 1;j <= a;j++){
        C[A[j]]++;
    }
    for(i = 1;i <= k;i++){
        C[i] += C[i - 1];
    }
    for(j = a;j >= 1;j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}


Measured memory_bytes: 17728
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toInt).toList
  val b = StdIn.readLine().split(" ").map(_.toInt).toList
  val c = StdIn.readLine().split(" ").map(_.toInt).toList
  val additionalPoints = for {
    i <- 1 to N-1
    if (a(i) - a(i-1) == 1)
  } yield c(a(i-1)-1)
  println(b.sum + additionalPoints.sum)
}


Measured memory_bytes: 27204
#include <stdio.h>

int main() {
  int a,b,c,d;
  scanf("%d %d", &a, &b);
  c=b-a+1;
  d=b+a-1;
  for(int i=c; i <=d; i++) {
    printf("%d ", i);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
 int tot=0,i=0;
 char s[200000];
  scanf("%s",s);
  while(s[i]!=0){
   tot=tot+(s[i]-48);
    i++;
  }
  if(tot%9==0){
  printf("Yes");
  }else{
  printf("No");
  }
  
}

Measured memory_bytes: 1852
def main():
    N = int(input())
    A = map(int, input().split(" "))
    x4 = 0
    x2 = 0
    x1 = 0
    for a in A:
        if a % 4 == 0:
            x4 += 1
        elif a % 2 == 0:
            x2 += 1
        else:
            x1 += 1
    maxlen = x4 * 2 + x2
    if x4 >= 1 and x2 == 0:
        maxlen += 1
    if maxlen >= N:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 11100
n = int(input())
x = list(map(int, input()))

dp = [0] * n

for i in range(n):
    num = i
    while num:
        num2 = num
        cnt = 0
        while num2:
            if num2 & 1:
                cnt += 1
            num2 >>= 1

        num %= cnt
        dp[i] += 1

one_cnt = x.count(1)
mod1 = one_cnt - 1
mod2 = one_cnt + 1

sm1 = 0
sm2 = 0
for i, e in enumerate(x):
    if e == 0:
        continue

    if mod1 != 0:
        sm1 += pow(2, n - i - 1, mod1)
        sm1 %= mod1

    sm2 += pow(2, n - i - 1, mod2)
    sm2 %= mod2

for i, e in enumerate(x):
    if mod1 == 0 and e:
        print(0)
        continue

    if e:
        val = sm1 - pow(2, n - i - 1, mod1)
        val %= mod1

    else:
        val = sm2 + pow(2, n - i - 1, mod2)
        val %= mod2

    ans = dp[val] + 1
    print(ans)


Measured memory_bytes: 78084
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int swap;
        
        if(a>b){
            swap=a;
            a=b;
            b=swap;
        }
        if(b>c){
            swap=b;
            b=c;
            c=swap;
        }
        if(a>b){
            swap=a;
            a=b;
            b=swap;
        }
        System.out.println(a +" "+ b +" "+ c);
    }
}


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

int main() {
    
    int N;
    cin >> N;
    vector<int> a(N);
   
    for (int i=0; i<N; i++) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    int d=0;
    
   
    for (int i=0; i<N/2; i++) {
        d += a[2*i+1]-a[2*i];
    }
    
    if(N%2 == 1){
        d = a[N-1]-d;
    }
    
    cout <<endl << d <<endl;
    
}


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

using namespace std;

int main()
{
    long n,i,step=0;
    cin >> n;

    long a[n];
    cin >> a[0];
    for(i=1; i<n; i++){
        cin >> a[i];
        if(a[i] < a[i-1]){
            step += a[i-1]-a[i];
            a[i] += a[i-1]-a[i]; 
        }

    }
    
    cout << step << endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)

int main() {
    int n, x, sum = 0, cnt = 0;
    cin >> n >> x;
    int a[n];
    rep(i, n) { cin >> a[i]; }
    sort(a, a + n);
    rep(i, n) {
        x -= a[i];
        if (x >= 0) {
            cnt++;
        } else {
            break;
        }
    }
    if (x > 0)
        cnt--;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
    string o, e;

    cin >> o;
    cin >> e;

    int n = o.size() + e.size();
    int index = 0;

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            cout << o[index];
        }
        else {
            cout << e[index];
            index++;
        }
    }
    
    cout << endl;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
c=0
a=[]
for i in range(n-2):
    if p[i] <= p[i+1] and p[i+1] < p[i+2]:
        c += 1
    elif p[i] > p[i+1] and p[i+1] >= p[i+2]:
        c += 1
print(c)

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

typedef long long ll;

int main(void){
    ll k;
    cin>>k;
    int mi[101010],cur,cost,next;
    priority_queue<pair<int,int>> q;
    for(int i=0;i<k;i++)mi[i]=1<<30;
    for(int i=1;i<10;i++){
        mi[i%k]=min(mi[i%k],i);
        q.push({-mi[i%k],i%k});
    }
    while(q.size()){
        cur=q.top().second;
        cost=-q.top().first;
        //cout<<cur<<" "<<cost<<endl;
        q.pop();
        if(cost!=mi[cur]) continue;
        for(int i=0;i<10;i++){
            next=(cur*10+i)%k;
            if(mi[next]>cost+i){
                mi[next]=cost+i;
                //cout<<"@"<<next<<" "<<cost+i<<endl;
                q.push({-mi[next],next});
            }
        }
    }
    cout<<mi[0]<<endl;
    
    return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

struct edge { int to, cost; };

int N;
vector<edge> G[101010];
int a, b, c;
int Q, K;
int x, y;

int d[101010];

void dfs(int v, int p, int c)
{
    if (p == -1) {
        d[v] = 0;
    } else {
        d[v] = d[p] + c;
    }

    REP(i,G[v].size()) {
        edge ne = G[v][i];
        if (ne.to != p) dfs(ne.to, v, ne.cost);
    }
}

signed main()
{
    cin >> N;
    REP(i,N-1) {
        cin >> a >> b >> c;
        G[a].push_back((edge){b, c});
        G[b].push_back((edge){a, c});
    }

    cin >> Q >> K;
    dfs(K, -1, 0);
    REP(i,Q) {
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
}


Measured memory_bytes: 14336
n = int(input())
if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800<=n<=999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
elif 1800<=n<=1999:
    print(1)

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

int main(){
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) {
        int v;
        cin >> v;
        p.push_back(P(v,i+1));
    }
    sort(p.begin(),p.end(),greater<P>());
    multiset<int> s;
    s.insert(n+1); s.insert(n+1); s.insert(0); s.insert(0);
    ll ans = 0;
    rep(i,n){
        int l = p[i].second;
        s.insert(l);
        ll w, x, y, z;
        auto it = s.find(l);
        auto jt = s.find(l);
        x = *(--it);
        w = *(--it);
        y = *(++jt);
        z = *(++jt);
        ans += (ll)(n-i)*((x-w)*(y-l)+(l-x)*(z-y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	A, B, X := getInt(), getInt(), getInt()
	if A+B >= X && A <= X {
		out("YES")
		return
	}
	out("NO")
}


Measured memory_bytes: 1776
#include <stdio.h>

int main() {
  int A, B;
  
  scanf("%d %d", &A, &B);
  
  if(A == B) printf("Draw\n");
  else if(A == 1) printf("Alice\n");
  else if(B == 1) printf("Bob\n");
  else if(A > B) printf("Alice\n");
  else if(A < B) printf("Bob\n");
  
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    REP (i, n) cin >> x[i];
    REP (i, m) cin >> y[i];
    const int MOD = 1000000007;
    int sx = 0, sy = 0;
    REP (i, n) (sx += (2 * i - n + 1) * x[i] % MOD) %= MOD;
    REP (i, m) (sy += (2 * i - m + 1) * y[i] % MOD) %= MOD;
    cout << (sx * sy % MOD) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 4748
H, W = [int(_) for _ in input().split()]

if H == 1 or W == 1:
    ans = 1
else:
    ans = (H // 2) * (W // 2) * 2
    if H % 2 == 1:
        ans += W // 2
    if W % 2 == 1:
        ans += H // 2
    if H % 2 == 1 and W % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 2940
N, M = map(int, input().split())

if N == 1:
    lst = [str(i) for i in range(10)]

elif N == 2:
    lst = [str(i) for i in range(10, 100)]

else:
    lst = [str(i) for i in range(100, 1000)]

for j in range(M):
    s, c = map(int, input().split())
    lst = [i for i in lst if i[s-1] == str(c)]

if len(lst) == 0:
    print(-1)

else:
    print(lst[0])

Measured memory_bytes: 9016
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 300002
using namespace std;
struct shop{
	int l,r;
}a[N];
int n,m,i,j=1,d,c[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
int my_comp(const shop &x,const shop &y)
{
	return x.r-x.l<y.r-y.l;
}
int lowbit(int x)
{
	return x&(-x);
}
int ask(int x)
{
	int ans=0;
	for(int i=x;i>=1;i-=lowbit(i)) ans+=c[i];
	return ans;
}
void add(int x,int y)
{
	for(int i=x;i<=m+1;i+=lowbit(i)) c[i]+=y;
}
int main()
{
	n=read();m=read();
	for(i=1;i<=n;i++) a[i].l=read()+1,a[i].r=read()+1;
	sort(a+1,a+n+1,my_comp);
	for(d=1;d<=m;d++){
		while(j<=n&&a[j].r-a[j].l<d){
			add(a[j].l,1);
			add(a[j].r+1,-1);
			j++;
		}
		int ans=n-j+1;
		for(i=1;i<=m+1;i+=d) ans+=ask(i);
		printf("%d\n",ans);
	}
}

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

using namespace std;

const int NS = (int)1e5 + 4;
int N;
int arr[NS];
int d[NS][4];

int main(){
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%d", arr + i);
    d[1][1] = d[1][2] = 1;
    for(int i = 2; i <= N; ++i){
        for(int x = 1; x <= 2; ++x){
            for(int y = 1; y <= 2; ++y){
                int A = arr[i - 1] - x + 1, B = arr[i] - y + 1;
                if(d[i - 1][x] && A <= B) d[i][y] = 1;
            }
        }
    }
    printf("%s\n", d[N][1] + d[N][2] ? "Yes" : "No");
    return 0;
}


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

int gcd(long long a, long long b) {
  long long r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int main() {
  int N, tmp; cin >> N;
  long long ans=0, ans2=0, mingcd=1e9, minidx=0;
  vector<long long> V(N, 0);
  vector<long long> Vgcd(N, 0);
  for (int i=0; i<N; i++) cin >> V[i];
  sort(V.begin(), V.end());
  for (int i=0; i<N; i++) {
    Vgcd[i] = gcd(V[0], V[i]);
    if (Vgcd[i] <mingcd) {mingcd=Vgcd[i]; minidx=i;}
  }
  ans = V[0];
  for (int i=0; i<N; i++) {
    if(i==minidx) continue;
    ans = gcd(ans, V[i]);
  }
  ans2=V[1];
  for (int i=1; i<N; i++) {
    ans2 = gcd(ans2, V[i]);
  }
  cout << max(ans, ans2) << "\n";
}

Measured memory_bytes: 1792
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e5+7;
ll ME(ll x,ll n)
{
	ll res=1;
	
	while(n)
	{
		if(n&1)
		res=res*x;

		x=x*x;

		n/=2;

	}

	return res;

}

int main()
{
       
       int n;
       scf(n);

	   ll c=0;
       
       int a[n];
       
       rep(i,0,n)
       scf(a[i]);
       
        int l=0;
    
      rep(i,0,n)
    {
        l=max(l,a[i]);
        
        if(i)
         c+=(l-a[i]);        
            
        
    }
        lprin(c);
            
}


Measured memory_bytes: 4508
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;


    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
};


template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int a, b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}

int main()
{
    hello;
    
    ll t;
//    cin>>t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		cout<<1-n<<"\n";
	}
    
    return 0;  
} 

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
//#define ld long double
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mpp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define repr(x,n,j)for(ll x=n;x>j;x--)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;
typedef long double ld;
bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}




ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    a-=b;
    if(a<0)a+=mod;
    return a%mod;
}
struct CustomCompare
{
    bool operator()(ll a,ll b)
    {
        return a>b;
    }
};
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/


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

ll n; cin>>n;
ll cnt = 0,mx = 0;
vpi arr(n);
rep(i,0,n)cin>>arr[i].fi>>arr[i].se;

rep(i,0,n)
{
    if(arr[i].fi==arr[i].se)cnt++;
    else cnt = 0;
    mx = max(mx,cnt);
}
if(mx>=3)cout<<"Yes\n";
else cout<<"No\n";
return 0;
}
/*
4
1
1 2 1

*/


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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n),b(n);
  vector<pair<long,long>> c(n);
  for(long i=0;i<n;i++) {
    cin >> a[i] >> b[i];
    c[i]={a[i]+b[i],i};
  }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(long i=0;i<n;i++) {
    if(i%2==0) ans+=a[c[i].second];
    if(i%2==1) ans-=b[c[i].second];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
using namespace std;

int main() {
  string x, y;
  cin >> x >> y;
  if(x[0] == y[2] && x[1] == y[1] && x[2] == y[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
 
#include <map>
 
using namespace std;
typedef long long ll;
 
ll i,j,k;
ll a,b,c;
ll h,w,n;
 
int main(){
	cin>>h>>w>>n;
	map<pair<int,int>,int> cnt;
	for(i=0;i<n;i++){
		cin>>a>>b;
		for(j=-1;j<=1;j++){
			for(k=-1;k<=1;k++){
				if(a+j>=2 && a+j<=h-1 && b+k>=2 && b+k<=w-1){
					cnt[make_pair(a+j,b+k)]++;
				}
			}
		}
	}
	ll ans[10];
	fill(ans,ans+10,0);
	ans[0]=(h-2)*(w-2);
	for(auto& elem : cnt){
		ans[0]--;
		ans[elem.second]++;
	}
	for(i=0;i<=9;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(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++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0, sum = 0;
    rep(i, n) {
        if (a[i] == 0) {
            ans += sum / 2;
            sum = 0;
        }
        else {
            sum += a[i];
        }
    }
    if (sum > 0) ans += sum / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;


int main()
{

int n; cin>>n;
int a[n][3];

for(int i=0; i<n; i++)
cin>>a[i][0]>>a[i][1]>>a[i][2];

int dp[n][3];

memset(dp, 0, sizeof(dp));

dp[0][0]=a[0][0];
dp[0][1]=a[0][1];
dp[0][2]=a[0][2];

for(int i=1; i<n; i++)
{
	dp[i][0]= max(dp[i-1][1], dp[i-1][2]) + a[i][0];
		dp[i][1]= max(dp[i-1][0], dp[i-1][2]) + a[i][1];
			dp[i][2]= max(dp[i-1][1], dp[i-1][0]) + a[i][2];
}

cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

     return 0;
}

Measured memory_bytes: 5972
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()))
f = False
c = 0
for i in range(h):
    for j in range(w):
        if (a[i][j] == "#"):
            c += 1


def judge(x, y, l: set):
    global a, f
    l.add("{},{}".format(x, y))
    if (x != h - 1):
        if (a[x + 1][y] == "#") and not ("{},{}".format(x+1, y) in l):
            judge(x + 1, y, l.copy())
    if (y != w - 1):
        if (a[x][y + 1] == "#") and not ("{},{}".format(x, y+1) in l):
            judge(x, y + 1, l.copy())

    if (x == h - 1) and (y == w - 1):
        if (l.__len__() == c):
            f = True


judge(0, 0, set())

print("Possible" if f else "Impossible")


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int i;
	char str[1000];
	gets(str);
	for(i=0;i<1000;i++){
  if(str[i]=='a' &&str[i+1]=='p' &&str[i+2]=='p' &&str[i+3]=='l' &&str[i+4]=='e'){
	  str[i]='p';str[i+1]='e';str[i+2]='a';str[i+3]='c';str[i+4]='h';
	  continue;
  }
  if(str[i]=='p' &&str[i+1]=='e' &&str[i+2]=='a' &&str[i+3]=='c' &&str[i+4]=='h'){
	  str[i]='a';str[i+1]='p';str[i+2]='p';str[i+3]='l';str[i+4]='e';
  }
	}
	puts(str);
	return 0;
}

Measured memory_bytes: 920