akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 1e9 + 7;
class {
  public:
    i64 cnt[maxn], pwN[maxn], n, k;
    i64 pw(i64 a, i64 b) {
        i64 res = 1;
        while (b) {
            if (b & 1)
                res = res * a % MOD;
            a = a * a % MOD;
            b >>= 1;
        }
        return res;
    }
    void solve() {
        cin >> n >> k;
        for (int i = 1; i <= k; ++i)
            pwN[i] = pw(i, n);
        for (int i = 1; i <= k; ++i)
            cnt[i] = i;
        i64 ans = 0;
        for (int i = 1; i <= k; ++i) {
            (ans += pwN[k / i] * cnt[i] % MOD) %= MOD;
            i64 count = cnt[i];
            for (int j = i; j <= k; j += i)
                cnt[j] -= count;
        }
        cout << ans << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 5156
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int n; cin >> n;
    int sum = 0;
    vector<int> v(n);

    rep(i,n) {
        cin >> v[i]; 
        sum += v[i];
    }
    sort(v.begin(), v.end());
    if(v[n-1] < (sum - v[n-1])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#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(void)
{
  LL n, m;
  cin >> n >> m;
  vector<vector<LL>> a(n+1);
  vector<bool> b(n+1, false);
  vector<LL> s(1),t(1);
  cin >> s[0] >> t[0];
  b[s[0]]=true;
  b[t[0]]=true;
  REP(i,m-1) {
    LL l, r;
    cin >> l >> r;
    a[l].push_back(r);
    a[r].push_back(l);
  }
  for(;;) {
    LL l=s.back();
    for(LL x:a[l]) {
      if(b[x]) continue;
      b[x] = true;
      s.push_back(x);
      break;
    }
    if(l==s.back()) break;
  }
  for(;;) {
    LL r=t.back();
    for(LL x:a[r]) {
      if(b[x]) continue;
      b[x] = true;
      t.push_back(x);
      break;
    }
    if(r==t.back()) break;
  }
  reverse(s.begin(),s.end());
  for(auto x:t) s.push_back(x);

  cout << s.size() << endl;
  REP(i, s.size()) {
    if(i) cout << " ";
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
string s;
int nums[SIZE];
int main(){
	int H,W;
	cin >> H >> W;
	REP(i,H){
		cin >> s;
		REP(j,W){
			nums[s[j]]++;
		}
	}
	int one=H&1&W;
	int two=(W&1)*H/2+(H&1)*W/2;
	FOR(i,'a','z'+1){
		if(nums[i]%2==1){
			one--;
		}
		else if(nums[i]%4==2){
			two--;
		}
	}	
	if(one<0 or two<0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Frog 1
            int N = int.Parse(Console.ReadLine());
            var h = ReadLine();

            //トータルコストがゼロのケースと、メモに何の値も入っていないケースを区別する
            var dp = Enumerable.Repeat(-1, N).ToArray();
            dp[0] = 0;

            for(int i = 0; i < N; i++)
            {
                for(int j = 1; j <= 2; j++)
                {
                    if (i + j < N)
                    {
                        int cost = Math.Abs(h[i] - h[i + j]);

                        if (dp[i + j] == -1 | dp[i + j] > cost + dp[i])
                        {
                            dp[i + j] = cost + dp[i];
                        }
                    }                    
                }
            }

            Console.WriteLine(dp[N - 1]);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	vector<int32> a(N);
	REP(i, N) cin >> a[i];
	int32 cnt = 0;
	int32 bef = -1;
	int32 res = 0;
	REP(i, N){
		if(a[i] == bef){
			cnt++;
		}else{
			res += cnt/2;
			cnt = 1;
		}
		bef = a[i];
	}
	if(cnt > 0)
		res += cnt/2;
	cout << res << endl;
}


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

int main(void)
{
    int a, b;
    char op;
    int flag = 1;
    
    while(flag)
    {
        int ans;
        cin >> a >> op >> b;
        switch(op)
        {
            case '+':
                ans = a + b;
                break;
            case '-':
                ans = a - b;
                break;
            case '*':
                ans = a * b;
                break;
            case '/':
                ans = a / b;
                break;
            case '?':
                flag = 0;
                continue;
        }
        cout << ans << endl;
    }
    return 0; 
}


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

int main() {
  int A,B;
  cin >> A >> B;
  if(A >= 13){
    cout << B << endl;
  }else if( A <= 5){
    cout << '0' << endl;
  }else{
    cout << B/2 << endl;
  }


}


Measured memory_bytes: 256
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def f(n, C, D):
    x = n // C
    y = n // D
    z = n // lcm(C, D)
    return n - x - y + z


A, B, C, D = map(int, input().split())
ans = f(B, C, D) - f(A-1, C, D)
print(ans)

Measured memory_bytes: 5076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong(), m = sc.nextLong();
		Map<Long, Long> map = new TreeMap<>();
		for(long i = 0; i < n; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if(map.containsKey(a)) {
				map.put(a, map.get(a)+b);
			}else {
				map.put(a, b);
			}
		}
		long yen = 0;
		for(Long a : map.keySet()) {
			long x = map.get(a);
			if(x <= m) {
				yen += a*x;
			}else {
				yen += a*m;
			}
			m -= x;
			if(m <= 0) {
				break;
			}
		}
		System.out.println(yen);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 59328
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,k,ans=1e9;
int c[13],a[13][13];
int tot[13];
int pd()
{
	int x;
	for(int i=1;i<=m;i++)
	{
		x=0;
		for(int j=1;j<=n;j++)
		x+=a[j][i];
		if(x<k)
		return 0;
	}
	return 1;
}
int pd1()
{
	for(int i=1;i<=m;i++)
	if(tot[i]<k)
	return 0;
	return 1;
}
void dfs(int x,int y)
{
	if(y>=ans)
	return;
	if(x==n+1)
	{
		if(pd1())
		ans=y;
		return;
	}
	for(int i=1;i<=m;i++)
	tot[i]+=a[x][i];
	dfs(x+1,y+c[x]);
	for(int i=1;i<=m;i++)
	tot[i]-=a[x][i];
	dfs(x+1,y);
}
signed main()
{
	scanf("%lld%ld%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&c[i]);
		for(int j=1;j<=m;j++)
		scanf("%lld",&a[i][j]);
	}
	if(pd()==0)
	{
		printf("-1");
		return 0;
	}
	dfs(1,0);
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
struct edge{int to,cost;};
int dp[100][11];
vector<edge> G[100];
int main(){
      int c,n,m,s,d;
      while(cin>>c>>n>>m>>s>>d&&(c||n||m||s||d)){
            s--;d--;
            REP(i,100)REP(j,11)dp[i][j]=INF;
            REP(i,100)G[i].clear();
            REP(i,m){
                  int x,y,z;
                  cin>>x>>y>>z;x--;y--;
                  G[x].PB((edge){y,z});
                  G[y].PB((edge){x,z});
            }
            dp[s][0]=0;
            queue<int> Q;
            Q.push(s);
            while(!Q.empty()){
                  int v=Q.front();Q.pop();
                  //cout<<v<<" "<<G[v].size()<<endl;
                  REP(i,G[v].size()){
                        bool f=false;
                        edge e=G[v][i];
                        int to=e.to;
                        REP(i,c+1){
                              //cout<<dp[v][i]+e.cost<<endl;;
                              if(dp[to][i]>dp[v][i]+e.cost){
                                    dp[to][i]=dp[v][i]+e.cost;
                                    f=true;
                              }
                        }
                        REP(i,c){
                              if(dp[to][i+1]>dp[v][i]+e.cost/2){
                                    dp[to][i+1]=dp[v][i]+e.cost/2;
                                    f=true;
                              }
                        }
                        if(f)Q.push(to);
                  }
            }
            int ans=INF;
            REP(i,c+1)ans=min(ans,dp[d][i]);
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1240
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  # Xi+Xi+1=2Ai
  # Xi=S-(Xi+1+Xi+2...)
  # X1=S-2A2-2A4...

  n=I()
  l=LI()
  sm=sum(l)
  _a=0
  for i,x in enumerate(l):
    if i%2==1:
      _a+=x
  x1=sm-_a*2
  ans=[x1]
  for i in range(n-1):
    b=2*l[i]-x1
    x1=b
    ans.append(x1)
  return ' '.join([str(x) for x in ans])

# main()
print(main())


Measured memory_bytes: 21124
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main()
{
    int N;
    cin >> N;
    int odds = (int)(N + 1) / 2;
    double answer = (double)odds / N;
    cout << std::setprecision(10) << std::fixed << answer << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#AtCoDeerくんとペンキ
def ABC_46_A():
    A,B,C = map(int, input().split())
    iroha = [0 for i in range(3)]
    iroha = []
    iroha.append(A)
    iroha.append(B)
    iroha.append(C)

    if iroha.count(A)==3:
        print(1)
    elif iroha.count(A)==2 or iroha.count(B)==2:
        print(2)
    else:
        print(3)

if __name__ == '__main__':

    ABC_46_A()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{   int A,B;
    cin>>A;
    cin>>B;
    int sum,multi,subtract;
    sum=A+B;
    multi=A*B;
    subtract=A-B;
    if(sum>=multi && sum>=subtract){cout<<sum;}
    else if (multi>=sum && multi>=subtract ){cout<<multi;}
    else if(subtract>=multi && subtract>=sum){cout<<subtract;}
    return 0;}


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

void rec(int d,long long val, vector<long long>&all){
  all.push_back(val);
  if(d==10){return;}
  for(int j=-1; j<=1; j++){
    int add=(val%10)+j;
   if(add>=0 && add<=9) {rec(d+1,(val*10+add),all);}
  }
}
  
  
  
int main(){
int K;
  cin>>K;
    vector<long long>all;
    for(long long i=1; i<10; i++){rec(1,i,all);}
  sort(all.begin(),all.end());
  cout<<all[K-1]<<endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 ll H,W;

vector<string> vec;
vector<ll> A{1,0,-1,0};
vector<ll> B{0,1,0,-1};
vector<ll> C{-2,-1,0,1,2};
vector<ll> D{-2,-1,0,1,2};
int main() {

  cin>>H>>W;
  ll Ch,Cw;
  cin>>Ch>>Cw;
  Ch--;
  Cw--;
  ll Dh,Dw;
  cin>>Dh>>Dw;
  Dh--;
  Dw--;
  
  vec=vector<string> (H);
  for(ll i=0;i<H;i++) {
cin>>vec[i];
  }
  
  vector<vector<ll>> note(H,vector<ll>(W,-1));
  
  deque<tuple<ll,ll,ll>> S;
 
  S.push_back(make_tuple(Ch,Cw,0));
  
  while(!S.empty()) {
ll nh,nw,a;
    tie(nh,nw,a)=S.front();
    S.pop_front();
    
    if(note[nh][nw]!=-1) {
continue;
      
    }
  note[nh][nw]=a;
    
    
    
    for(ll i=0;i<4;i++) {
ll kh,kw;
      kh=nh+A[i];
      kw=nw+B[i];
      
      if(kh<0||kh>=H||kw<0||kw>=W) {
continue;
      }
      
      if(vec[kh][kw]=='#') {
continue;
      }
      if(note[kh][kw]!=-1) {
continue;
      }

      S.push_front(make_tuple(kh,kw,a));
    }
    
    for(ll i=0;i<5;i++) {
for(ll j=0;j<5;j++) {
if(abs(C[i])+abs(D[j])<=1) {
continue;
}
  ll kh,kw;
  kh=nh+C[i];
  kw=nw+D[j];
 
     if(kh<0||kh>=H||kw<0||kw>=W) {
continue;
      }
      
      if(vec[kh][kw]=='#') {
continue;
      }
      if(note[kh][kw]!=-1) {
continue;
      }
  
  S.push_back(make_tuple(kh,kw,a+1));
              
}
    }
    
  }
  
cout<<note[Dh][Dw]<<endl;
  
}

    
    
    
      
      
    
  
  
  
  
  

Measured memory_bytes: 14440
a,b,k=map(int,input().split())

if k*2>(b-a+1):
    for i in range(a,a+b-a+1):
        print(i)
    #print("SDFG")
else:
    for i in range(k):
        print(a+i)
    for i in range(k-1,-1,-1):
        print(b-i)



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];
int rev[202020];

template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	static V const def=303030;
	V comp(V l,V r){ return min(l,r);};
	
	SegTree_1(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=v;
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};

SegTree_1<int,1<<20> ev,od;

int T;
pair<int,int> P[202020];
vector<int> E[202020];
map<pair<int,int>,int> to;

int dfs(int L,int R) {
	if(R<=L) return -1;
	
	int tar;
	if(L%2==0) tar=ev.getval(L,R);
	else tar=od.getval(L,R);
	int x=rev[tar];
	
	if((x+1)%2==0) tar=ev.getval(x+1,R);
	else tar=od.getval(x+1,R);
	int y=rev[tar];
	
	int cur=T++;
	P[cur]={A[x],A[y]};
	to[P[cur]]=cur;
	
	int ch;
	ch=dfs(L,x);
	if(ch>=0) E[cur].push_back(ch);
	ch=dfs(x+1,y);
	if(ch>=0) E[cur].push_back(ch);
	ch=dfs(y+1,R);
	if(ch>=0) E[cur].push_back(ch);
	return cur;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		if(i%2==0) {
			ev.update(i,A[i]);
			od.update(i,1<<20);
		}
		else {
			od.update(i,A[i]);
			ev.update(i,1<<20);
		}
		rev[A[i]]=i;
	}
	
	dfs(0,N);
	
	set<pair<int,int>> cand;
	vector<int> Q;
	cand.insert(P[0]);
	while(cand.size()) {
		pair<int,int> p=*cand.begin();
		cand.erase(cand.begin());
		Q.push_back(p.first);
		Q.push_back(p.second);
		
		x = to[p];
		FORR(e,E[x]) cand.insert(P[e]);
	}
	
	assert(T==N/2);
	assert(Q.size()==N);
	
	FOR(i,N) _P("%d%c",Q[i],(i==N-1)?'\n':' ');
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 46836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	int a, b; cin >> a >> b;
	int m = min(a, b), n = max(a, b);
	rep(i, n) cout << m; cout << endl;
}

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

using namespace std;

int main(){
	int N, M, k;
	int stu[100];

	cin >> N >> M;

	for (int i = 0; i < N; i++){
		cin >> stu[i];
	}

	for (int i = 1; i <= M; i++){
		k = i;
		for (int j = 0; j < N - 1; j++){
			if ((stu[j] % k) > (stu[j + 1] % k)){
				swap(stu[j], stu[j + 1]);
			}
		}
	}

	for (int i = 0; i < N; i++){
		cout << stu[i] << endl;
	}
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

int main(){
  int n,m,X;
  cin >> n >> m >> X;
  ll c[n];
  ll a[n][m];
  rep(i,n){
    cin >> c[i];
    rep(j,m)cin >> a[i][j];
  }
  ll ans=longinf;
  for(int bit=0;bit<(1<<n);bit++){
    int temp=bit;
    int ok[m]={};
    bool ng=false;
    ll x=0;
    vector<int> v;
    v.clear();
    rep(i,n){
      v.push_back(temp%2);
      temp/=2;
    }
    rep(i,n){
      if(v[i]){
        x+=c[i];
      rep(j,m){
        ok[j]+=a[i][j];
      }
      }
    }
    rep(j,m){
      if(ok[j]<X){
        ng=true;
      }
    }
    if(!ng)ans=min(ans,x);
  }
  if(ans==longinf)ans=-1;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,a[100010];

int gcd(int a, int b){
    if (!b) return a;
    return gcd(b,a%b);
}

bool get_ans(){
    int cnte=0,i,gc=0;
    bool g=1; LL sum=0;
    for (i=1; i<=N; i++){
        if (a[i]%2==0) cnte++;
        sum+=a[i];
        if (a[i]==1) g=0;
    }

    if (!g) return (sum-N)%2;

    if (cnte%2) return 1;
    else if (N-cnte>1) return 0;
    else {
        for (i=1; i<=N; i++){
            if (a[i]%2) a[i]--;
            gc=gcd(a[i],gc);
        }
        for (i=1; i<=N; i++)
            a[i]/=gc;

        return !get_ans();
    }
}
int main(){
    cin >> N;

    int i;
    for (i=1; i<=N; i++)
        cin >> a[i];

    bool ans=get_ans();
    if (ans) cout << "First\n";
    else cout << "Second\n";

    return 0;
}


Measured memory_bytes: 640
// ------------------------------------
// Date:2018/ 3/ 9
// Problem:ABC 062 PictureFrame b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  char ch;
  int H, W;
  cin >> H >> W;

  REP(hi, H + 2) {
    REP(wi, W + 2) {
      if (hi == 0 or hi == H + 1 or wi == 0 or wi == W + 1) {
	cout << '#';
      } else {
	cin >> ch;
	cout << ch;
      }
    }
    cout << endl;
  }

  
  return 0;
}



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

ll solve() {
    ll N, M, x, y;
    cin >> N >> M;
    vector<vector<ll>> G(N);
    vector<int> c_in(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        c_in[y]++;
    }

    vector<int> h(N,-1);
    function<int(int,int)> dfs = [&](int v, int p) {
        if ( h[v] >= 0 ) return h[v];
        if ( G[v].size() == 0 ) return 0;
        int x = 0;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            x = max(x, dfs(u, v) + 1);
        }
        h[v] = x;
        return x;
    };

    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( h[i] >= 0 ) continue;
        ans = max(ans, (ll)dfs(i, -1));
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    int res = INF;
    while(N--) {
        int a;
        cin >> a;
        int cnt = 0;
        while(a % 2 == 0) {
            a >>= 1;
            ++cnt;
        }
        res = min(res, cnt);
    }
    cout << res << endl;

    return 0;
}



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

signed main(){
	int q;
	multimap<string,int>m;
	cin>>q;
	while(q--){
		int t,y;
		string x;
		cin>>t;
		if(t==0){
			cin>>x>>y;
			m.insert(make_pair(x,y));
		}
		if(t==1){
			string l;
			cin>>l;
			map<string,int>::iterator end,it;
			it=m.lower_bound(l);
			end=m.upper_bound(l);
			for(;it!=end;it++){
				cout<<(*it).second<<endl;
			}
		}
		if(t==2){
			cin>>x;
			m.erase(x);
		}
		if(t==3){
			string l,r;
			cin>>l>>r;
			map<string,int>::iterator end,it;
			it=m.lower_bound(l);
			end=m.upper_bound(r);
			for(;it!=end;it++){
				cout<<(*it).first<<' '<<(*it).second<<endl;
			}
		}
	}
}



Measured memory_bytes: 24852
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var ave;
  var sum = 0;
  var output = 0;
  for(var i = 0; i < list.length; i++){
    sum += list[i];
  }
  ave = Math.round(sum / N);
  for(var i = 0; i < list.length; i++){
    output += Math.pow((list[i] - ave),2);
  }
  myout(output);
}

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


Measured memory_bytes: 7500
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

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

//�G���g�X�e�l�X���
vector<int> estora(vector<int> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
vector<ll> fac(ll n, vector<ll> num) {
    ll kazu = n;
    for (int i = 2; i <= n; i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1)
        num[n]++;
    return num;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return num;
}
const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()


sab = [[i,i,0] for i in range(N)]

cnt = N
for i in range(N//2, N):
    sab[i][2] = cnt
    sab[i][0] += cnt
    cnt += 1

for i in range(N//2):
    sab[i][2] = cnt
    sab[i][0] += cnt
    cnt += 1

sab.sort()

C = N*2
ans = []
for s,a,b in sab:
    if s+K <= C:
        tmpl = [a+K,b+K,C+K]
        ans.append(' '.join(map(str,tmpl)))
    else:
        print(-1)
        sys.exit()
    C += 1

print('\n'.join(ans))


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

void trace(vector<int> &vi) {
    for (auto n : vi)
        cout << n << " ";
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> vi;
    for (int i = 0; i < n; i++) {
        int input;
        cin >> input;
        vi.push_back(input);
    }
    sort(vi.begin(), vi.end());

    int left = vi.size() / 2 - 1;
    int right = vi.size() / 2;
    cout << (vi.at(right) - vi.at(left)) << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

ll gcd(const ll &a, const ll &b) {
    if (b == 0) return a;

    return gcd(b, a % b);
}

ll lcm(const ll &a, const ll &b) {
    return a / gcd(a, b) * b;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    ll t;
    ll ans = 1;

    int i;

    for (i = 0; i < n; i++) {
        cin >> t;

        ans = lcm(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e5+100;

int a[N], b[N];

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin >> n;
	set<ii> st;
	for(int i=0 ; i<n ; i++)
		cin >> a[i];
	for(int i=0 ; i<n ; i++){
		cin >> b[i];
		st.insert(ii(b[i], i));
	}
	ll ans=0;
	while(!st.empty()){
		ii v = *st.rbegin();
		st.erase(v);
		int cur = v.second;
		int nxt = (v.second+1)%n;
		int prv = (v.second-1+n)%n;
		if(b[cur] == a[cur])
			continue;
		int s = b[prv] + b[nxt];
		if(b[cur] < a[cur] || b[cur] < s){
			cout << "-1\n";
			return 0;
		}
		if(a[cur] < s){
			ans += b[cur]/s;
			b[cur] %= s;
			st.insert(ii(b[cur], cur));
			continue;
		}
		if(b[cur] - a[cur] < 0 || (b[cur] - a[cur]) % s != 0){
			cout << "-1\n";
			return 0;
		}
		ans += (b[cur] - a[cur]) / s;
		b[cur] = a[cur];
	}
	cout << ans << "\n";
 	return 0;
}
















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

using namespace std;

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

  int n; 
  cin >> n;
  vector<int> cards(n);
  int sum = 0;
  for (auto &c : cards) cin >> c, sum += c;
  sort(cards.begin(), cards.end());

  int alice = 0; 
  for (int a = n-1; a >= 0; a -= 2) alice += cards[a];
  cout << 2*alice - sum << endl;

  return 0;
}



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

int main() {
    std::string r, g, b;
    std::cin >> r >> g >> b;

    int num = std::atoi((r+g+b).c_str());
    if(num % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 384
arr = (0..9).to_a
loop do
  n,s = gets.split.map(&:to_i)
  break if n == 0 && s == 0
  i = 0
  arr.combination(n) do|a|
    i += 1 if a.reduce{|x,y|x+y} == s
  end
  puts i.to_s
end

Measured memory_bytes: 6100
import java.util.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String str=s.next();
		if(str.contentEquals("Sunny")) {
			System.out.println("Cloudy");
		}
		else if(str.contentEquals("Cloudy")) {
			System.out.println("Rainy");
		}
		else {
			System.out.println("Sunny");
		}
	} 

}


Measured memory_bytes: 19156
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const std::pair<char,int> TABLE[4] = {
    mp('m', 1000), mp('c', 100), mp('x', 10), mp('i', 1)
};

int toInt(const std::string& s){
    int res = 0, pos;

    REP(i, 4){
        if(pos = s.find(TABLE[i].first), pos != std::string::npos){
            if(pos - 1 >= 0 && std::isdigit(s[pos-1])){
                res += (s[pos-1] - '0') * TABLE[i].second;
            }else{
                res += TABLE[i].second;
            }
        }
    }

    return res;
}

std::string toMCXI(int n){
    std::string res = "";

    REP(i, 4){
        if(n / TABLE[i].second > 0){
            if(n / TABLE[i].second > 1){
                res += (n / TABLE[i].second + '0');
            }
            res += TABLE[i].first;
            n %= TABLE[i].second;
        }
    }

    return res;
}

int main(){
    int N;
    std::cin >> N;

    REP(_, N){
        std::string S, T;
        std::cin >> S >> T;
        
        std::cout << toMCXI(toInt(S) + toInt(T)) << std::endl;
    }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
long long n,m,z;
char a[999][999];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		cin>>a[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]!='#')
			{
				z=0;
				if(a[i][j-1]=='#')z++;
				if(a[i][j+1]=='#')z++;
				if(a[i-1][j-1]=='#')z++;
				if(a[i+1][j-1]=='#')z++;
				if(a[i-1][j+1]=='#')z++;
				if(a[i-1][j]=='#')z++;
				if(a[i+1][j]=='#')z++;
				if(a[i+1][j+1]=='#')z++;
				a[i][j]=char(z+48);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
    s = [int(x) for x in input().split()]
    adj[s[0]].append(s[1])
    adj[s[1]].append(s[0])

cc = [-1 for _ in range(n)]
cnt = 0
for i in range(n):
    if cc[i] < 0:
        cc[i] = cnt
        stack = [i]
        while stack:
            v = stack.pop()
            for u in adj[v]:
                if cc[u] < 0:
                    cc[u] = cnt
                    stack.append(u)
        cnt += 1

q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    if cc[s] == cc[t]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 23392
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#9:04

n = int(input())

for i in range(n):
    a,b,c,d = list(map(int, input().split()))
    if(b>d or a<b):
        print("No")
        continue
    G = fractions.gcd(b,d)
    minim = a%G
    if(b-G<=c and minim<=c):
        print("Yes")
    else:
        print("No")























Measured memory_bytes: 65004
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cstdlib>
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vint;

int main() {
	string s;
	cin >> s;
	char mae{}, ato{};
	int countmae{}, countato{};
	for(int i = 0; i < s.size(); i++) {
		char a = s[i];
		char b = s[s.size() - i - 1];
		if(i == 0) {
			mae = a;
			ato = b;
		} else {
			if(mae == a) {
				countmae++;
				mae = (a == '0') ? '1' : '0';
			} else {
				mae = a;
			}
			if(ato == b) {
				countato++;
				ato = (b == '0') ? '1' : '0';
			} else {
				ato = b;
			}
		}
	}
	cout << min(countmae, countato) << endl;
	return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

N = int(input())
T = [list(map(int, input().split())) for i in range(N)]

T.sort(key=lambda x:x[1])
te = 0
for a,b in T:
  te += a
  if te > b:
    print("No")
    exit()
print("Yes")

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	int R, G, B, N; cin >> R >> G >> B >> N;
	
	int acc = 0;
	for (int r = 0; r * R <= N; r++)
		for (int b = 0; r * R + b * B <= N; b++)
			if ((N - r * R - b * B) % G == 0)
				acc++;
	cout << acc << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

vector<bool> IsPrime;

void sieve(int N) {

  IsPrime.resize(N+1, true);
  IsPrime[0] = IsPrime[1] = false;

  for(int i=2; i*i<=N; ++i) {
    if(IsPrime[i]) {
      for(int j=2; i*j<=N; ++j) {
        IsPrime[i*j] = false;
      }
    }
  }
}

int main() {

  int X;
  cin >> X;

  sieve(X*10);

  int i = X;
  while(true) {

    if(IsPrime[i]) {
      cout << i << endl;
      break;
    }

    ++i;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>;
using namespace std;
int main()
{
int a[3];
cin>> a[0]>> a[1]>> a[2];
for(int i=0;i<2;i++)
{
     for(int j=1;j<3;j++)
     {
         if(a[i]>a[j])
         {
            int temp=a[i]; a[i]=a[j]; a[j]=temp;
         }
     }
}
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
return 0;
}

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

int n,k,m,a,b,c,d;
string s;

int main() {
  cin >> a >> b >> c >> d;
  cout << (d==1 ? 1 : 0) << endl;
}

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

int main(){
   long long int H, W;
   std::cin >> H >> W;
   std::cerr << H*W << std::endl;
   if ((H == 1) || (W == 1)){
      std::cout << 1 << std::endl;
   } else if (H*W % 2 == 0)
      std::cout << H*W/2 << std::endl;
   else
      std::cout << H*W/2+1 << std::endl;
}



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int n = 0;
    cin >> n;
    set<string> s_str;
    REP(i, n)
    {
        string s = "";
        cin >> s;
        s_str.insert(s);
    }
    switch (s_str.size())
    {
    case 3:
        COUT("Three");
        break;
    case 4:
        COUT("Four");
        break;
    }

    return 0;
}

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

using namespace std;

int Abs(int x) {
    return x < 0 ? -x : x;
}

int main() {
    int n;
    scanf("%d", &n);
    int t1 = 0, a1 = 0, b1 = 0;
    for(int i = 1; i <= n; i++) {
        int t2, a2, b2;
        scanf("%d%d%d", &t2, &a2, &b2);
        int dis = Abs(a2 - a1) + Abs(b2 - b1);
        if(((dis + t2 - t1) & 1) || dis > t2 - t1) {
            puts("No");
            return 0;
        }
        t1 = t2;
        a1 = a2;
        b1 = b2;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128