akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n)cin >> a[i];

    vector<int> val(n+1,-1);
    vector<int> s;
    int c = 1, l = 0;
    int v = 1;
    while(val[v] == -1){
        val[v] = s.size();
        s.push_back(v);
        v = a[v-1];
    }
    c = s.size() - val[v];
    l = val[v];

    if (k < l)cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }

    return 0;
}


Measured memory_bytes: 5904
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(; sc.hasNext();){
			char[] s=sc.next().toCharArray();
			int a1=0, a2=0;
			for(int i=0; i<s.length-2; i++){
				if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I'){
					a1++;
				}
				if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){
					a2++;
				}
			}
			println(a1+"");
			println(a2+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
#include <climits>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N;
  ll a[110000];
  cin>>N;
  for(int i=0;i<N;i++) cin>>a[i];

  for(int i=0;i<N;i++){
      if(a[i]%2==1){
          cout<<"first"<<endl;
          return 0;
      }
  }
  cout<<"second"<<endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True


if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+2)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)



Measured memory_bytes: 462068
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main(){
	string s;
	cin >> s;
	if ((int)s.find("a") != -1&& (int)s.find("b") != -1 && (int)s.find("c") != -1  ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	int arr[6] = {100, 101, 102, 103, 104, 105};

	int dp[1000005];
	MSET(dp,false);

	dp[0] = true;

	REP(i, 0, 5)
	{
		for(int j = 0; arr[i]+j <= 1000000; j++)
			dp[arr[i]+j] |= dp[j];
	}


	int n;
	while(~scanf("%d", &n))
	{
		if(dp[n])
		{
			printf("1\n");
		}
		else
			printf("0\n");
	}

		
	return 0;
}

Measured memory_bytes: 4096
class Prime():
    def __init__(self, n):
        self.p = []
        self.d = [0] * n

        for i in range(2, n):
            if self.d[i] == 0:
                self.p.append(i)
                for j in range(i, n, i):
                    if self.d[j] == 0:
                        self.d[j] = i

        self.ind = [-1] * n
        for i in range(len(self.p)):
            self.ind[self.p[i]] = i

    def prime_factorization_index(self, x):
        l = []
        while x != 1:
            if l == [] or l[-1] != self.ind[self.d[x]]:
                l.append(self.ind[self.d[x]])
            x //= self.d[x]
        return l

    def num_prime(self):
        return len(self.p)

def main():

    from math import gcd
 
    n = int(input())
    a = list(map(int, input().split()))
 
    g = a[0]
    for i in range(1, n):
        g = gcd(g, a[i])
        if g == 1:
            break
    else:
        print('not coprime')
        exit()

    p = Prime(10**6 + 1)

    tf = [False] * p.num_prime()

    for i in range(1, n):
        l = p.prime_factorization_index(a[i])
        for i in l:
            if tf[i]:
                print('setwise coprime')
                exit()
            else:
                tf[i] = True

    print('pairwise coprime')

main()

Measured memory_bytes: 126760
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;
long long int ans;

long long int GCD(long long int a, long long int b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int num;
	ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> num;
		ans = ans / GCD(ans, num)*num;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  long long n,i,c=0;
  cin>>n;
  long long m[n];
  vector<long long>v;
  for(i=0;i<n;i++)
  {
    cin>>m[i];
    v.push_back(m[i]);
  }
  sort(m,m+n);
  for(i=0;i<n;i++)
  {
    if(v[i]!=m[i])
    {
      c++;
    }
  }
  if(c==0||c==2)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
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...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){

  ini(N);inl(W);
  vector<vl> v(4);
  ll w;
  {
    in(w); inl(_);
    v[0].pb(_);
  }
  rep(i , N - 1){
    inl(ww , a); v[ww - w].pb(a);
  }
  trc(v);
  rep(i , 4) sort(all(v[i]) , greater<ll>());
  rep(i , 4){
    if(sz(v[i]) <= 1) continue;
    rep1(j , sz(v[i]) - 1){
      v[i][j] += v[i][j - 1];
    }
  }
  trc(v);
 
  ll ans = 0;
  rep(i , sz(v[0]) + 1) rep(j , sz(v[1]) + 1) rep(k , sz(v[2]) + 1) rep(l , sz(v[3]) + 1){
    ll ww = 1LL * i * w + 1LL * j * (w + 1) + 1LL * k * (w + 2) + 1LL * l * (w + 3);
    if(ww > W) continue;
    ll vv = 0;
    if(i) vv += v[0][i - 1];
    if(j) vv += v[1][j - 1];
    if(k) vv += v[2][k - 1];
    if(l) vv += v[3][l - 1];
    amax(ans , vv);
  
  }
  out(ans);
}

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

namespace ABC129
{
    class C
    {
        
        static void Main(string[] args)
        {
            const int m = 1000000007;
            int[] b = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
            int N = b[0], M = b[1];
            HashSet<int> alist = new HashSet<int>();
            for (int i = 0; i < M; i++)
            {
                int a = int.Parse(Console.ReadLine());
                alist.Add(a);
            }

            long[] way = new long[N+1];
            way[0] = 1;
            way[1] = 1;if (alist.Contains(1)) way[1] = 0;
            for(int i = 2; i <= N; i++)
            {
                if (alist.Contains(i)) way[i] = 0;
                else way[i] = way[i - 1] + way[i - 2];
                way[i] %= m;
            }
            Console.WriteLine(way[N]);
        }

    }
}


Measured memory_bytes: 18272
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int Q=1<<8;
struct graph{
    int las[Q],e[Q],nn[Q],inc;
    void ins(int x,int y)
    {
        e[++inc]=y;
        nn[inc]=las[x];
        las[x]=inc;
    }
}t1,t2,g;
int ap[Q][Q];
queue<int> q;
int lv[Q];
int Time=0;
int H;
void dfs(int x,int last,graph b,int ty)
{
    if(max(lv[x],lv[last])<Time)
        g.ins(ty?x:last,ty?last:x);
    for(int t=b.las[x];t;t=b.nn[t]){
        int y=b.e[t];
        if(y==last)continue;
        dfs(y,x,b,ty);
    }
}
int vis[Q],huan;
void dfs(int x)
{
    if(huan)return;
    lv[x]=Time;
    vis[x]=1;
    for(int t=g.las[x];t&&(!huan);t=g.nn[t]){
        int y=g.e[t];
        if(lv[y]!=Time)dfs(y);
        else if(vis[y]){
            huan=1;
            return;
        }
    }
    vis[x]=0;
}
int n;
int Huan()
{
    huan=0;
    for(int j=1;j<=n;j++)
        vis[j]=0;
    ++Time;
    for(int j=1;j<=n&&(!huan);j++)if(lv[j]!=Time)dfs(j);
    return huan;
}
int Gans(int i)
{
    int als=998244353;
    q.push(i);
    lv[i]=++Time;
    int opha=0;
    while(q.size()){
        ++opha;
        int x=q.front();
        q.pop();
        for(int t=t1.las[x];t;t=t1.nn[t]){
            int y=t1.e[t];
            if(lv[y]==Time)continue;
            if(ap[x][y])
                lv[y]=Time,q.push(y);
        }
    }
    g.inc=0;
    for(int j=1;j<=n;j++)
        g.las[j]=0;
    dfs(i,0,t1,0);
    dfs(i,0,t2,1);
    return Huan()?998244353:(n-opha);
}
int d[Q];
int X1[Q],X2[Q],Y1[Q],Y2[Q];
int L[Q];
#define INS(p,a,b) (p.ins(a,b),p.ins(b,a))
void solve()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        t1.las[i]=t2.las[i]=0,d[i]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ap[i][j]=0;
    t1.inc=t2.inc=0;
    for(int i=1,x,y;i<n;i++)
        scanf("%d%d",&x,&y),INS(t1,x,y),++d[x],++d[y],X1[i]=x,Y1[i]=y,L[x]=L[y]=i;
    for(int i=1,x,y;i<n;i++)
        scanf("%d%d",&x,&y),INS(t2,x,y),ap[x][y]=ap[y][x]=1,X2[i]=x,Y2[i]=y;
    int als=998244353;
    for(int i=1;i<=n;i++)als=min(als,Gans(i));
    if(als>n)
    for(int i=1;i<=n;i++){
        if(d[i]!=1)continue;
        int id=L[i];
        for(int k=1;k<=n;k++){
            if(k==i)continue;
            for(int j=1;j<=n;j++)
                t1.las[j]=0;
            t1.inc=0;
            for(int j=1;j<n;j++){
                if(j!=id)INS(t1,X1[j],Y1[j]);
                else INS(t1,k,i);
            }
            if(Gans(i)<=n)
            {als=n;break;}
        }
    }
    printf("%d\n",als>n?-1:als);
}
int main()
{
    int t;
    for(scanf("%d",&t);t;--t)
        solve();
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __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 debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
ll n,k, h[L], dp[L];
ll solve(int i)
{
	if(i==n-1)return 0;
	if(i>=n)return INT_MAX;
	if(dp[i] != -1)return dp[i];
	ll &ret = dp[i];
	ret = INT_MAX;
	FOR(j,1,k+1)
	ret = min(ret,solve(i+j) + abs(h[i]-h[i+j]));
	return ret;
}
void fff()
{
	cin >> n >> k;
	init(dp, -1);
	FOR(i,0,n)cin >> h[i];
	cout<<solve(0)<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 18428
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
    
void trace(vector<int>&v, int N) {
  for (int i = 0 ; i < N; i++){
    if (i > 0) { cout << " "; }
    cout << v[i] ;
  }
  cout << endl;
}
    
int main() {
  int n;
  vector<int> v;
  for (int i = 0; i < 3 ; i++) { 
    cin >> n;
    v.push_back(n);
  }
  sort(v.begin(), v.end());
  trace(v, 3);
  return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>
int main(){
    int n,m,l;
    long long a[100][100],b[100][100],c[100][100]={0};
    scanf("%d %d %d",&n,&m,&l);
    //get a's
    for (int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    //gets b's
    for (int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    //cal
    for (int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]=0;
            for (int k =0;k<m;k++){
                c[i][j]=c[i][j]+a[i][k]*b[k][j];
            }
        }
    }
    //ans
    for (int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==0){
                printf("%lld",c[i][j]);
            }else{
                printf(" %lld",c[i][j]);
            }
        }
        printf("\n");
    }

}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<iostream>
using namespace std;
int main()
{
	int i, n, a, b, c, d[10000],g,max;
	scanf("%d", &n);
	scanf("%d %d", &a, &b);
	scanf("%d", &c);
	for (i = 0; i < n; i++){
		scanf("%d", &d[i]);
	}
	sort(d, d + n, greater<int>());
	max = c / a;
	for (i = 1; i <= n; i++){
		g = 0;
		for (int i2 = 0; i2 < i; i2++){
			g += d[i2];
		}
		g = (g + c) / (a + i*b);
		if (max < g)
			max = g;

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

Measured memory_bytes: 1212
import java.util.Scanner;

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

		int N = scanner.nextInt();
		int D = scanner.nextInt();
		while(1 > N || N > 20 || 1 > D || D > 20) {
			N = scanner.nextInt();
			D = scanner.nextInt();
		}

		int count = 1; // 必要な人の数
		int spot = D + 1; // 人のいる場所14

		while(spot + D + 1 <= N) {
			spot = spot + (2*D + 1);
			count++;
		}
		System.out.println(count);
		scanner.close();
	}
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  rep(i,N) {
    cin >> x[i];
  }

  int total = 0;
  rep(i,N) {
    int m = min(2*x[i], 2*(K-x[i]));
    total += m;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
// ITP1_8_B Sum of Numbers
import java.io.*;

class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 16868
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {

    int n;
    cin >> n;
    vector<int> vc;
    while(n--) {
        int x;
        cin >> x;
        vc.push_back(x);
    }


    set<int> st(vc.begin(), vc.end());

    if (vc.size() == st.size()) {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 10356
ATGC = ["A", "T", "G", "C"]
s = input()
max_length = 0
tmp_length = 0
for car in s:
    if car in ATGC:
        tmp_length += 1
    else:
        max_length = max(max_length, tmp_length)
        tmp_length = 0

max_length = max(max_length, tmp_length)
print(max_length)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

bool comp(l_l a,l_l b){
    return a.second<b.second;
}

int main(){fastio
    ll n;cin>>n;
    l_l a[n];rep(i,0,n-1)cin>>a[i].first>>a[i].second;
    sort(a,a+n,comp);
    
    rep(q,1,500){
        ll time=0;
        rep(i,0,n-1){
            time+=a[i].first;
            if(time>a[i].second){
                cout<<"No"<<endl;return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=105;

ll int num[maxn];

ll int book1[maxn];
ll int book2[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
    ll int n;
	
	while(cin>>n)
	{
		
		for(ll int i=1;i<=n;i++)
		{
			cin>>num[i];
		
		}
		
		ll int now=1000;
		
		ll int cnt=0;
		
		for(ll int i=1;i<n;i++)
		{
			if(num[i] < num[i+1])
			{
				ll int to=now/num[i];
				now+=(num[i+1]-num[i])*to;
			}
		}
		
		cout<<now<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
    int A , B , X ;
    cin >> A >> B >> X ;
    if((X - A)>= 0 && (A + B -X)>= 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, k; cin >> n >> k;
  vi num(n, 0);
  for(int i = 0; i < k; i++){
    int d; cin >> d;
    for(int j = 0; j < d; j++){
      int a; cin >> a;
      a--;
      num[a]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(num[i] == 0) ans++;
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

template<typename flow_t = int, typename cost_t = int>
struct PrimalDual {
    const cost_t INF;
    struct edge {
        int to;
        flow_t cap;
        cost_t cost;
        int rev;
        bool isrev;
    };
    vector<vector<edge>> graph;
    vector<cost_t> potential, min_cost;
    vector<int> prevv, preve;

    PrimalDual(int v) : graph(v), INF(numeric_limits<cost_t>::max()) {}
    void add_edge(int from, int to, flow_t cap, cost_t cost) {
        graph[from].emplace_back((edge) {to, cap, cost, (int) graph[to].size(), false});
        graph[to].emplace_back((edge) {from, 0, -cost, (int) graph[from].size() - 1, true});
    }

    cost_t min_cost_flow(int s, int t, flow_t f) {
        int V = (int) graph.size();
        cost_t ret = 0;
        priority_queue<pair<cost_t, int>, vector<pair<cost_t, int>>, greater<pair<cost_t, int>>> que;
        potential.assign(V, 0);
        prevv.assign(V, -1);
        preve.assign(V, -1);

        while (f > 0) {
            min_cost.assign(V, INF);
            que.emplace(0, s);
            min_cost[s] = 0;
            while (!que.empty()) {
                pair<cost_t, int> p = que.top();
                que.pop();
                if (min_cost[p.second] < p.first) continue;
                for (int i = 0; i < graph[p.second].size(); i++) {
                    edge& e = graph[p.second][i];
                    cost_t next_cost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to];
                    if (e.cap > 0 && min_cost[e.to] > next_cost) {
                        min_cost[e.to] = next_cost;
                        prevv[e.to] = p.second, preve[e.to] = i;
                        que.emplace(min_cost[e.to], e.to);
                    }
                }
            }
            if (min_cost[t] == INF) return -1;
            for (int v = 0; v < V; v++) {
                potential[v] += min_cost[v];
            }
            flow_t addflow = f;
            for (int v = t; v != s; v = prevv[v]) {
                addflow = min(addflow, graph[prevv[v]][preve[v]].cap);
            }
            f -= addflow;
            ret += addflow * potential[t];
            for (int v = t; v != s; v = prevv[v]) {
                edge& e = graph[prevv[v]][preve[v]];
                e.cap -= addflow;
                graph[v][e.rev].cap += addflow;
            }
        }
        return ret;
    }
};

int main() {
    int V, E, F;
    scanf("%d %d %d", &V, &E, &F);
    PrimalDual<> g(V);
    for(int i = 0; i < E; i++) {
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        g.add_edge(a, b, c, d);
    }
    printf("%d\n", g.min_cost_flow(0, V - 1, F));
}


Measured memory_bytes: 3340
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>
#define INF 1000000000
int main() {
  int n, ans = INF;
  cin >> n;
  vector<int> x(n), y(n);
  vector<string> s(n);
  map<int, set<int> > udu, udd, lrl, lrr, uru, urr, ulu, ull, drd, drr, dld,
      dll;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> s[i];
    if (s[i] == "U") {
      udu[x[i]].insert(y[i]);
      uru[y[i] + x[i]].insert(x[i]);
      ulu[y[i] - x[i]].insert(x[i]);
    } else if (s[i] == "D") {
      udd[x[i]].insert(y[i]);
      drd[y[i] - x[i]].insert(y[i]);
      dld[y[i] + x[i]].insert(y[i]);
    } else if (s[i] == "R") {
      lrr[y[i]].insert(x[i]);
      urr[y[i] + x[i]].insert(y[i]);
      drr[y[i] - x[i]].insert(x[i]);
    } else {
      lrl[y[i]].insert(x[i]);
      ull[y[i] - x[i]].insert(y[i]);
      dll[y[i] + x[i]].insert(x[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == "U") {
      if (udd[x[i]].lower_bound(y[i]) != udd[x[i]].end()) {
        ans = min(ans, (*udd[x[i]].lower_bound(y[i]) - y[i]) * 5);
      }
      if (urr[y[i] + x[i]].lower_bound(y[i]) != urr[y[i] + x[i]].end()) {
        ans = min(ans, (*urr[y[i] + x[i]].lower_bound(y[i]) - y[i]) * 10);
      }
      if (ull[y[i] - x[i]].lower_bound(y[i]) != ull[y[i] - x[i]].end()) {
        ans = min(ans, (*ull[y[i] - x[i]].lower_bound(y[i]) - y[i]) * 10);
      }
    } else if (s[i] == "D") {
      if (dll[y[i] + x[i]].lower_bound(x[i]) != dll[y[i] + x[i]].end()) {
        ans = min(ans, (*dll[y[i] + x[i]].lower_bound(x[i]) - x[i]) * 10);
      }
    } else if (s[i] == "R") {
      if (lrl[y[i]].lower_bound(x[i]) != lrl[y[i]].end()) {
        ans = min(ans, (*lrl[y[i]].lower_bound(x[i]) - x[i]) * 5);
      }
      if (drd[y[i] - x[i]].lower_bound(y[i]) != drd[y[i] - x[i]].end()) {
        ans = min(ans, (*drd[y[i] - x[i]].lower_bound(y[i]) - y[i]) * 10);
      }
    }
  }
  if (ans == INF) {
    cout << "SAFE" << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 122200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	getline(cin,a);
	getline(cin,b);
	int la=a.length(),lb=b.length();
	int l=min(la,lb);
	for(int i=0;i<l;i++) cout<<a[i]<<b[i];
	if(la>lb)
	for(int i=l;i<la;i++) cout<<a[i];
	else for(int i=l;i<lb;i++) cout<<b[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int>> ans(h,vector<int> (w,0));
    rep(i,h) cin >> s[i];
    rep(i,h){
        int cnt = 0;
        int start = 0;
        rep(j,w){
            if(s[i][j] == '.'){
                cnt++;
            }else{
                rep(k,j - start) ans[i][k + start] = cnt;
                start = j+1;
                cnt = 0;
            }
        }
        if(cnt != 0){
            rep(k,w - start) ans[i][k + start] = cnt;
        }
    }
    int res = 0;
    rep(i,w){
        int cnt = 0;
        int start = 0;
        rep(j,h){
            if(s[j][i] == '.'){
                cnt++;
            }else{
                rep(k,j - start) chmax(res,ans[k + start][i] + cnt - 1);
                start = j+1;
                cnt = 0;
            }
        }
        if(cnt != 0){
            rep(k,h - start) chmax(res,ans[k+start][i] + cnt - 1);
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 26932
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int N;
	int K;
	int max = 0;

	cin >> N;

	for (int i = 1; i <= 100; i++)
	{
		for (int j = 2; j <= 100; j++)
		{
			K = (int)pow(i,j);
			if (K > N) {
				break;
			}
			if (K > max) {
				max = K;
			}
		}
	}

	cout << max << endl;

	return 0;
}

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

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






Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];  
  }    
  sort(a, a + n);
  vector<pair<ll, ll> > box;
  ll now = 0;
  ll num = 0;
  for (ll i = 0; i < n; i++) {
    if (i == 0) {
      now = a[i];
      num++;  
    }    
    else {
      if (now != a[i]) {
        box.push_back(make_pair(num, now));
        now = a[i];
        num = 1;  
      }
      else {
        num++;  
      }
    }
    if (i == n - 1) {
      box.push_back(make_pair(num, now));  
    }
  }
  sort(box.begin(), box.end());
  for (ll i = 0; i < box.size(); i++) {
    ll j = box.size() - 1 - i;
    if (box[j].first >= 2) {
      box[j].first = box[j].first % 2;
      if (box[j].first == 0) {
        box[j].first = 2;  
      }  
    }  
  }
  sort(box.begin(), box.end());
  ll two = 0;
  for (ll i = 0; i < box.size(); i++) {
    if (box[i].first == 2) {
      two++;  
    }
  }
  cout << box.size() - (two % 2) << endl;
}

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

int main(){

string str;
map<char,int>count;
while(cin>>str){
for(int i=0;i<(int)str.size();i++){
if(isupper(str[i])){str[i]=tolower(str[i]);}
}
for(int i=0;i<(int)str.size();i++){
count[str[i]]++;
}}

for(char ch='a';ch<='z';ch++){
cout<<ch<<" : "<<count[ch]<<endl;
}


return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  ll k;
  cin >> s;
  cin >> k;

  char ch = '1';
  rep(i, min(k, (ll)(s.size()))) if (s[i] != '1') {
    ch = s[i];
    break;
  }

  cout << ch << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int

using namespace std ;
int n,m;
map<string,int> mem;

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

    loop(i,n){
        cin>>s;
        map<string,int>::iterator it = mem.find(s);
        if(it == mem.end()){
            mem[s] = 1;
        }else{
            it->second++;
        }
    }

    cin>>m;
    loop(i,m){
        cin>>s;
        map<string,int>::iterator it = mem.find(s);
        if(it == mem.end()){
            mem[s] = -1;
        }else{
            it->second--;
        }
    }
    int ans = 0;

    for( map<string,int>::iterator it = mem.begin(); it != mem.end(); ++it ) {
        if(ans<it->second){
            ans=it->second;
        }
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=65;
const int mod=1e9+7;
typedef long long ll;
ll l,r;
ll dp[maxn][2][2][2];
ll cal(int ind,int bot,int top,int lead)
{
	if(ind<0) return 1;
	if(dp[ind][bot][top][lead]!=-1) return dp[ind][bot][top][lead];
	dp[ind][bot][top][lead]=0;
	int up=!(!(r&(1ll<<ind)));
	int down=!(!(l&(1ll<<ind)));
	//cout<<ind<<" "<<bot<<" "<<top<<" "<<lead<<" "<<up<<" "<<down<<endl;
	ll ans=0;
	for(int i=0;i<2;i++)//y
	{
		for(int j=0;j<2;j++)//x
		{
			//cout<<i<<" "<<j<<" "<<up<<" "<<down<<endl;
			if(i<j) continue;
			if((!lead)&&(i!=j)) continue;
			if(bot&&(j<down)) continue;
			if(top&&(i>up)) continue;
			ans+=cal(ind-1,bot&&(j==down),top&&(i==up),lead||(i>0));
			ans%=mod;
			//cout<<ans<<endl;
		}
	}
	dp[ind][bot][top][lead]=ans;
	//cout<<ind<<" "<<bot<<" "<<top<<" "<<lead<<" "<<dp[ind][bot][top][lead]<<endl;
	return ans;
}
int main()
{
	scanf("%lld %lld",&l,&r);memset(dp,-1,sizeof dp);
	ll ans=cal(63,1,1,0);
	cout<<ans<<endl;
 } 

Measured memory_bytes: 256
n = int(input())
count = 0
l = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
  ii = str(i)
  s = int(ii[0])
  t = int(ii[-1]) 
  l[s][t] += 1
for i in range(1,9):
  for j in range(i+1,10):
    count += l[i][j]*l[j][i]*2
for i in range(1,10):
  count += l[i][i]*l[i][i]
print(count)

Measured memory_bytes: 3064
#define max(a,b) ((a)>(b)?(a):(b))
int lcs[1002][1002];
 
int main(){
  char a[1002],b[1002];
  int i,j,_a,_b;scanf("%d",&i);
  while(~scanf("%s%s",a+1,b+1)){
    memset(lcs,0,sizeof(lcs));
    _a=strlen(a+1);_b=strlen(b+1);
    for(i=1;i<=_a;i++)
      for(j=1;j<=_b;j++)
        lcs[i][j]=max(max(lcs[i-1][j],lcs[i][j-1]),lcs[i-1][j-1]+(a[i]==b[j]));
    printf("%d\n",lcs[_a][_b]);
  }
  exit(0);
}


Measured memory_bytes: 5724
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ar = {"SUN","MON", "TUE", "WED", "THU", "FRI", "SAT"};
        String s = sc.next();
        for (int i = 0; i < ar.length; i++) {
            if (s.equals(ar[i])) {
                System.out.println(7 - i);
                return;
            }
        }
        
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

void solve(std::string S, std::string T){
    int ans = 0;
    REP(i, 3)
    {
        if (S[i]==T[i]){
            ++ans;
        }
    }
    cout << ans << endl;
}

int main(){
    std::string S;
				std::cin >> S;
				std::string T;
				std::cin >> T;
    solve(S, T);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

typedef pair<int, int>P;

long long dp[100][100];

long nCr(int n, int r)
{
  if (n == r) return dp[n][r] = 1;
  if (r == 0) return dp[n][r] = 1;
  if (r == 1) return dp[n][r] = n;
  if (dp[n][r]) return dp[n][r];
  return dp[n][r] = nCr(n - 1, r) + nCr(n - 1, r - 1);
}

int main() {
  int N, P;
  int A;
  int odd=0, even=0;
  long long ans=0;
  cin >> N >> P;

  for (int i = 0; i < N; i++) {
	cin >> A;
	if (A % 2)odd++;
	else even++;
  }

  long long oddcom=0;
  long long evencom=0;

  for (int i = 0; i <= even; i++) {
	evencom += nCr(even, i);
  }

  if (P) {
	for (int i = 0; i <= odd; i++) {
	  if (i % 2)oddcom += nCr(odd, i);
	}
  }
  else {
	for (int i = 0; i <= odd; i++) {
	  if (i % 2 == 0)oddcom += nCr(odd, i);
	}
  }
  cout << evencom*oddcom << endl;


}

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

using namespace std;

int main()
{
    int n;scanf("%d",&n);
    char ch[100007];
    scanf("%s",ch);
    int mod=1e9+7;
    long long ans=1;
    int ar[30];
    memset(ar,0,sizeof(ar));
    for(int i=0;i<n;i++){
        ar[ch[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        ans = ans * (ar[i] + 1) % mod;
    }
    ans = (ans - 1 + mod) % mod;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct Node{
	int x,y,num;
}Edge[100005];

bool cmp(Node a,Node b){
	if(a.x == b.x){
		return a.y < b.y;
	}
	return a.x < b.x;
}

bool cmp1(Node a,Node b){
	return a.num < b.num;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&Edge[i].x,&Edge[i].y);
		Edge[i].num = i;
	}
	sort(Edge,Edge+m,cmp);
	int num = 1;
	for(int i=0;i<m-1;i++){
		if(Edge[i].x == Edge[i+1].x){
			Edge[i].y = num++;
		}
		else{
			Edge[i].y = num;
			num = 1;
		}
	}
	if(Edge[m-1].x == Edge[m-1].x) Edge[m-1].y = num;
	else Edge[m-1].y = ++num;
	sort(Edge,Edge+m,cmp1);
	for(int i=0;i<m;i++){
		string str;
		str = to_string(Edge[i].x);
		int len = str.length();
		if(len < 6){
			for(int j=0;j<6-len;j++){
				cout<<"0";
			}
		}
		cout<<str;
		str = to_string(Edge[i].y);
		len = str.length();
		if(len < 6){
			for(int j=0;j<6-len;j++){
				cout<<"0";
			}
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());

		long inf = 100000000000;

		//Z,Wそれぞれの最大値と最小値
		/*
		但し、
		Z = x + y, W = x - y;
		*/
		long maxZ = -inf;
		long minZ = inf;
		long maxW = -inf;
		long minW = inf;

		for(int i=0; i<N; i++){
			string[] S = Console.ReadLine().Split(' ');
			long x = long.Parse(S[0]);
			long y = long.Parse(S[1]);

			long z = x + y;
			if(maxZ < z){
				maxZ = z;
			}
			if(minZ > z){
				minZ = z;
			}
			long w = x - y;
			if(maxW < w){
				maxW = w;
			}
			if(minW > w){
				minW = w;
			}
		}

		long ans = Math.Max(maxZ - minZ, maxW - minW);

		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 21800
N = int(input())
s = [[0,0,0]]
for i in range(N):
    s.append(list(map(int,list(input().split()))))
err = 0
for i in range(N):
    dt = s[i+1][0] - s[i][0]
    dist = abs(s[i+1][1] - s[i][1]) + abs(s[i+1][2] - s[i][2])
    if(dt < dist):
        err = 1
    if(dist % 2 != dt % 2):
        err = 1

if(err == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27380
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

vector<ll> sieve(ll n);

int main() {
	ll n;
	ll x;
	ll count;
	vector<ll> prime;
	vector<bool> is_prime(50000 + 1, true);

	is_prime[0] = is_prime[1] = false;

	REP(i, 50000 + 1) {
		if (is_prime[i]) {
			prime.push_back(i);

			for (ll j = 2 * i; j <= 50000; j += i) {
				is_prime[j] = false;
			}
		}
	}

	while (true) {
		count = 0;

		cin >> n;

		if (n == 0) {
			break;
		}

		if (n % 2 == 0) {
			x = n / 2;
		}
		else {
			x = (n - 1) / 2;
		}

		REP(i, x + 1) {
			if (is_prime[i] == true && is_prime[n - i] == true) {
				count++;
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    int mi = INF;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a < mi) ans++;
        chmin(mi, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
const ll mod=1e18;
ll num[100010];
int main()
{
	int n;
	cin>>n;
	ll res=1;
	for(int i=0;i<n;i++)
	{
       	scanf("%lld",&num[i]);
       	if(num[i]==0)
       	{
       	     puts("0");
			 return 0;	
		}
    }
    for(int i=0;i<n;i++)
    {
    	if(num[i]>mod/res)
    	{
    		res=-1;
    		break;
		}
		res*=num[i];
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	VV<int> a(3, V<int>(3, 0));
	RBF(ai, a) {
		RBF(aij, ai) {
			cin >> aij;
		}
	}
	int n;
	cin >> n;
	V<int> b(n);
	RBF(bi, b) {
		cin >> bi;
	}

	RBF(bi, b) {
		RBF(ai, a) {
			RBF(aij, ai) {
				if (aij == bi) {
					aij = 0;
				}
			}
		}
	}

	V<int> sum(8, 0);
	REP(i, 3) {
		sum[0] += a[0][i];
		sum[1] += a[1][i];
		sum[2] += a[2][i];
		sum[3] += a[i][0];
		sum[4] += a[i][1];
		sum[5] += a[i][2];
		sum[6] += a[i][i];
		sum[7] += a[i][2-i];
	}

	RBF(s, sum) {
		if (s == 0) {
			col("Yes");
			return 0;
		}
	}

	col("No");
	return 0;
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

vll h(string s){
	ll p1 = 1000000000 + 7, p2 = 1000000000 + 9, q = 31;

	ll n = s.size();
	vll res(n);

	res[0].ff = (s[0]-'a' + 1)%p1;
	res[0].ss = (s[0]-'a' + 1)%p1;
	for(int i = 1; i < n; ++i){
		res[i].ff = ((s[i]-'a' + 1)%p1 + (res[i-1].ff * q)%p1 )%p1;
		res[i].ss = ((s[i]-'a' + 1)%p2 + (res[i-1].ss * q)%p2 )%p2;
	}


	return res;
}

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

	ll n, res = 0;
	cin >> n;

	vl l(n);
	for(auto&p : l){
		cin >> p;
	}

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

	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			auto a = lower_bound(l.begin() + j, l.end(), l[i] + l[j]);
			
			res += a - l.begin() - j - 1;
		}
	}

	cout << res << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k=0,ans=0;
	cin>>a>>b>>c;
	while(k<c){
		k+=a;
		ans++;
		if(ans%7==0){
			k+=b;
			//cout<<'a'<<endl;
		}
		//cout<<ans<<' '<<k<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
  
int main(void){
int N=0;
scanf("%d",&N);
int A[N], B[N];
for (int i=0;i<N;i++){
  A[i]=0;
  B[i]=0;
}
for (int i=1;i<N;i++){
  scanf("%d",&A[i]);
  if (A[i]>0)
  B[A[i]-1] = B[A[i]-1] + 1;
}
for (int i=0;i<N;i++){
  printf("%d\n",B[i]);
}
return 0;
}



Measured memory_bytes: 3292
#include<stdio.h>

int main(){
  int a, b;

  scanf("%d %d", &a, &b);

  if (a<b) {
    printf("a < b\n");
  } else if (a>b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N, K;
  long long sum = 0;
  cin >> N >> K;
  
  vector<int> vec(N);
  
  rep(i, N) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  rep(i, N - K) {
    sum += vec.at(i);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 1024