akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <stack> 
#include <algorithm>
using namespace std;
const int num = 25, NIL = -1;
struct Node {
	int l, r, p, si;
};
Node T[num];
int Dp[num], Dg[num], H[num];
inline void getDepth(int u, int p) {
	Dp[u] = p;
	if (T[u].l != NIL) 
		getDepth(T[u].l, p + 1);
	if (T[u].r != NIL)
		getDepth(T[u].r, p + 1);
	
}
inline void getDegree(int u) {
	Dg[u] = 0;
	if (T[u].l != NIL) Dg[u]++;
	if (T[u].r != NIL) Dg[u]++;
}
inline int getHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].l != NIL) h1 = getHeight(T[u].l);
	if (T[u].r != NIL) h2 = getHeight(T[u].r);
	H[u] = max(h1, h2);
	return H[u];
}
int main() {
	int n, rootnum, h = 0, u;
	cin >> n;
	for (int i = 0; i < n; i++)
		T[i].l = T[i].r = T[i].p = T[i].si = H[i] =  NIL;
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> T[u].l >> T[u].r;
	}
	for (int i = 0; i < n; i++) {

		T[T[i].l].si = T[i].r;
		T[T[i].r].si = T[i].l;
		T[T[i].l].p = i;
		T[T[i].r].p = i;
	}
	for (int i = 0; i < n; i++)
		if (T[i].p == NIL) rootnum = i;
	getDepth(rootnum, 0);
	for (int i = 0; i < n; i++)
		getDegree(i);
	for (int i = 0; i < n; i++) {
		if (T[i].l == NIL && T[i].r == NIL)H[i] = h;
	}
	for (int j = 0; j < 13; j++) {
		for (int i = 0; i < n; i++) {
			if (H[i] != 0 && H[T[i].l] != NIL && H[T[i].r] != NIL)
				H[i] = 1 + max(H[T[i].l], H[T[i].r]);
		}
		if (H[rootnum] != NIL) break;
	}
	//getHeight(rootnum);
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].p << ", sibling = " << T[i].si << ", degree = " << Dg[i] << ", depth = " << Dp[i] << ", height = " << H[i] << ", ";
		if (T[i].p == NIL) cout << "root" << endl;
		else if (T[i].l == NIL && T[i].r == NIL) cout << "leaf" << endl;
		else cout << "internal node" << endl;
	}

}

Measured memory_bytes: 3088
#include<stdio.h>

int main(void)
{
        double moun = 0.0;
        double max = 0.0;
        double min = 0.0;

        scanf("%lf",&moun);
        min = moun;
        max = moun;

        while(scanf("%lf",&moun) != EOF)
        {
                if(max < moun)
                {
                        max = moun;
                }
                if(min > moun)
                {
                        min = moun;
                }
        }

        printf("%.1f\n",max - min);

        return 0;
}

Measured memory_bytes: 652
#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() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll d = c-a-b;
    if (d > 0 && d*d > 4*a*b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }




    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int  y = sc.nextInt();
        boolean ans = false;
        for (int i = 0; i <= x; i++) {
            int a = i * 2;
            int b = (x-i) * 4;
            if(a + b == y){
                ans = true;
                break;
            }
        }
        System.out.println(ans ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 35736
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void shortestPath(const vector<vector<int> >& graph, int start, vector<int>& dist)
{
    int n = graph.size();
    dist.assign(n, INT_MAX);
    dist[start] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(int i=0; i<n; ++i){
            if(graph[v][i] >= 0 && dist[v] + graph[v][i] < dist[i]){
                dist[i] = dist[v] + graph[v][i];
                q.push(make_pair(dist[i], i));
            }
        }
    }

    replace(dist.begin(), dist.end(), INT_MAX, -1);
}

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int> > graph(n, vector<int>(n, -1));
    vector<vector<bool> > check(n, vector<bool>(n, false));
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        -- a;
        -- b;
        graph[a][b] = graph[b][a] = c;
        check[a][b] = check[b][a] = true;
    }

    for(int i=0; i<n; ++i){
        vector<int> dist;
        shortestPath(graph, i, dist);

        for(int a=0; a<n; ++a){
            for(int b=0; b<n; ++b){
                if(abs(dist[a] - dist[b]) == graph[a][b])
                    check[a][b] = false;
            }
        }
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<i; ++j){
            if(check[i][j])
                ++ ans;
        }
    }
    cout << ans << endl;

    return 0;
}

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
arr = factorization(n)
ans = 0
if arr==[[1,1]]:
    print(0)
else:
    suretsu = [1,3,6,10,15,21,28,36,45]
    import bisect
    for i in arr:
        ans += bisect.bisect_right(suretsu,i[1])
    print(ans)

Measured memory_bytes: 9496
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner num = new Scanner(System.in);
        int a = num.nextInt();
        int b = num.nextInt();
        int c = num.nextInt();
        if (a < b && b < c) 
            System.out.println("Yes");
         else 
            System.out.println("No");
    }
}

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

int main()
{
  int n, max_val = 0, res = 0;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    int p;
    cin >> p;
    res += p;
    max_val = max(max_val, p);
  }
  
  res -= max_val / 2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
	 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, ans, dp[N];

main () {
	cin >> n;
	for (int x = 1; x <= 100; ++x)
		for (int y = 1; y <= 100; ++y)
			for (int z = 1; z <= 100; ++z)
				if (x*x + y*y + z*z + x*y + x*z + y*z <= n)
					++dp[x*x + y*y + z*z + x*y + x*z + y*z];

	for (int i = 1; i <= n; ++i)
		cout << dp[i] << endl;
}
	
        	
//check for the constants

                                                                                   	

                     	             

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
//
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mx 100010
#define pi acos(-1)
#define endl '\n'
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
//
int main()
{
    ll n, x;
    string s, s1, s2;

    cin >> n;
    cin >> s;

    if (n % 2 == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        x = n / 2;
        s1 = s.substr(0, x);
        s2 = s.substr(x, n);

        if (s1 == s2)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
long long n,s[100005],s1[100005],maxn=2e3+50,ans;
map<long long,long long> dem,used;
int main() {
	scanf("%lld",&n);
	for(long long i=0;i<n;i++){
		scanf("%lld",&s[i]);
		long long x=s[i];
		s[i]=s1[i]=1;
		for(long long j=2;j<=maxn;j++){
			if(x%j==0){
				long long cnt=0;
				while(x%j==0){
					x/=j;
					cnt++;
				}
				if(cnt%3==1){
					s[i]*=j;
					s1[i]*=j*j;
				}else if(cnt%3==2){
					s[i]*=j*j;
					s1[i]*=j;
				}
			}
		}
		if(x!=1){
			long long y=ceil(sqrt(x));
			s[i]*=x;
			if(y*y==x) s1[i]*=y;
			else s1[i]*=x*x;
		}
		dem[s[i]]++;
	}
	for(long long i=0;i<n;i++){
		if(!used[s[i]]){
			used[s[i]]=used[s1[i]]=1;
			if(s[i]==1) ans++;
			else ans+=max(dem[s[i]],dem[s1[i]]);
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long num,a;
    vector<long long> list;
    cin >> num;
    for (long long i=0; i<num; i++) {cin >> a; list.push_back(a);}
    sort(list.begin(),list.end());
    cout << list[num-1]-list[0];}

Measured memory_bytes: 3636
import java.util.*;

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

        String res = "Yes";
        int len = S.length();
        if(!isPalindrome(S)){
            res = "No";
        }
        if(!isPalindrome(S.substring(0,(len-1)/2))){
            res = "No";
        }
        if(!isPalindrome(S.substring((len+3)/2-1))){
            res = "No";
        }
        System.out.println(res);
    }
    public static boolean isPalindrome(String s){
        boolean res = true;
        for(int i=0; i<s.length()/2; i++){
            if(s.charAt(i) != s.charAt(s.length()-i-1)){
                res = false;
            }
        }
        return res;
    }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, m, a[101], b[101];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	for(int i = 0; i < m; i++){
		int dp[101][101];
		for(int j = 0; j < 101; j++) fill(dp[j],dp[j]+101,INF);
		for(int j = 0; j < 101; j++) dp[j][j] = 0;
		for(int j = 0; j < m; j++){
			if(i == j) continue;
			dp[a[j]][b[j]] = 1;
			dp[b[j]][a[j]] = 1;
		}
		for(int ii = 1; ii <= n; ii++){
			for(int jj = 1; jj <= n; jj++){
				for(int kk = 1; kk <=n; kk++){
					chmin(dp[jj][kk], dp[jj][ii]+dp[ii][kk]);
				}
			}
		}
		bool ok = 0;
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(dp[j][k] == INF){
					ok = 1;
				}
			}
		}
		if(ok) ans++;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int main(){
   string x;
   cin >> x;
   if (x.at(0) != x.at(1) && x.at(1) != x.at(2) && x.at(2) != x.at(0)){
         cout << "Yes" << endl;
   }
   else {
      cout << "No" << endl;
   }
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

int main(){
  ll ans=0;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll bg=lcm(c,d);
  ans=b-a+1-((b/c+b/d-b/bg)-((a-1)/c+(a-1)/d-(a-1)/bg));
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main () {
	int n, m;
	cin >> n >> m;
	vector<int> adj[n];
	int ai, bi;
	for (int i=0; i<m; i++) {
		cin >> ai >> bi;
		ai--; bi--;
		adj[ai].push_back(bi);
		adj[bi].push_back(ai);
	}
	int par[n];
	for (int i=0; i<n; i++) {
		par[i] = -1;
	}
	queue<int> q;
	q.push(0);
	while (q.size() > 0) {
		int cur = q.front();
		q.pop();
		for (auto i: adj[cur]) {
			if (par[i] == -1) {
				par[i] = cur;
				q.push(i);
			}
		}
	}
	for (int i=1; i<n; i++) {
		if (par[i] == -1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i=1; i<n; i++) {
		cout << par[i]+1 << endl;
	}
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      int sum = a[i] + a[j];
      auto it = lower_bound(a.begin(), a.end(), sum);
      ans += max(int(it - a.begin()) - 1 - j, 0);
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
function main()
  
  N = parse(Int,readline())
  H = map(x -> parse(Int,x), split(readline()))
  
  check = true
  count = 0
  
  for i in 1:N
    for j in 0:i-1
      
      if H[1+j] > H[i]
        check = false
      end
      
    end

    if check == true
      count += 1
    else
      check = true
    end
    
  end
  
  println(count)
  
end

main()

Measured memory_bytes: 110344
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;


void solve()
{
	int A, B, T;
	cin >> A >> B >> T;
	cout << T / A * B << endl;
}

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

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int n, x, t[4] ;
long double dp[305][305][305] ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n ;
    for(int i=1 ; i<=n ; i++) cin>> x, t[x]++ ;
    for(int k=0 ; k<=300 ; k++)
      for(int j=0 ; j+k<=300 ; j++)
        for(int i=0 ; i+j+k<=300 ; i++)
          if(i || j || k)
            {
              if(i) dp[i][j][k]+=(1.0*i/(i+j+k))*dp[i-1][j][k] ;
              if(j) dp[i][j][k]+=(1.0*j/(i+j+k))*dp[i+1][j-1][k] ;
              if(k) dp[i][j][k]+=(1.0*k/(i+j+k))*dp[i][j+1][k-1] ;
              dp[i][j][k]+=(1.0*n/(i+j+k)) ;
            }
    cout<< fixed << setprecision(15) << dp[t[1]][t[2]][t[3]] ;
  }


Measured memory_bytes: 436608
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    rl()
    A = rl()
    right = A.count('E')
    if A[0] == 'E':
        right -= 1
    r = right
    left = 0
    for i in xrange(1, len(A)):
        if A[i] == 'E':
            right -= 1
        if A[i-1] == 'W':
            left += 1
        r = min(r, left + right)
    print r


if __name__ == '__main__':
    main()


Measured memory_bytes: 3304
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll DP1[10005][100], DP2[10005][100];

int main(){
  string S; cin >> S;
  int D; cin >> D;

  DP1[0][0] = 0;
  DP2[0][0] = 1;

  for (int i = 1; i <= S.length(); i++){
    int now = S[i - 1] - '0';

    for (int j = 0; j < D; j++){
      for (int k = 0; k < 10; k++){
        DP1[i][(j + k) % D] += DP1[i - 1][j];
      }
    }

    for (int j = 0; j < D; j++){
      for (int k = 0; k < now; k++){
        DP1[i][(j + k) % D] += DP2[i - 1][j];
      }
    }
    
    for (int j = 0; j < D; j++){
      DP2[i][(j + now) % D] += DP2[i - 1][j];
    }

    for (int j = 0; j < D; j++){
      DP1[i][j] %= nmax;
      DP2[i][j] %= nmax;
    }
  }

  ll ans = DP1[S.length()][0] + DP2[S.length()][0] + nmax - 1;
  cout << ans % nmax << endl;

  return 0;
}


Measured memory_bytes: 15872
N = int(input())
L_list = list(map(int,input().split()))


counter = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = L_list[i]
            b = L_list[j]
            c = L_list[k]
            if a==b or b==c or c==a or a+b<=c or b+c<=a or c+a<=b:
                continue
            counter += 1


print(counter)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A; // 1<=N円<=10000 0<=A枚<=1000
 
  if (N <= A) {
    cout << "Yes" << endl;
  }
  else if (N%500 <= A) {
	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    //
    vector<int> d(N+1);
    d[0]=0;
    for(int i=1;i<=N;i++){
        cin >> d[i] ;
    }
    sort(d.begin(),d.end());
    //
    int cnt;
    //
    int K_max = d[(N/2)+1];
    int K_min = d[(N/2)] + 1;
    //
    if(d[N/2]==d[(N/2)+1]){
        cnt = 0;
    }
    else{
        cnt = K_max - K_min + 1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
char s[100010];
int n,p;
bool vis[100010];
void dfs(int x,int l,int r)
{
	if(l>r) return;
	while((!vis[p])&&p!=0) p--;
	int y=l+p-1;vis[p]=false;
	for(int i=y+1;i<=r;i++) printf("%d %d\n",x,i);
	if(p!=0)
	{
		printf("%d %d\n",x,l);
		dfs(l,l+1,y);
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) vis[i]=(s[i]=='1');
	if((!vis[1])||vis[n]) return puts("-1"),0;
	for(int i=1;i<=n;i++) if(vis[i]&&(!vis[n-i])) return puts("-1"),0;
	p=n/2;
	dfs(1,2,n);
}

Measured memory_bytes: 1408
#include <stdio.h>

	int main(void) {
	int a=0,b=0,c=0,d=0,e=0,k=0;
	int i=0;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
 
	i=e-a;
	if(i<=k)
	{
	printf("Yay!\n");
	}
	else
	{
	printf(":(\n");
	return 0;
}
	
	}

Measured memory_bytes: 128
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

class unionfind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.size = [1 for i in range(n)]
    def find(self,a):
        if a == self.parent[a]: return a
        else: self.parent[a] = find(self,self.parent[a]); return self.parent[a]
    def unite(self,a,b):
        pa,pb = self.find(self,a), self.find(self,b)
        if pa == pb: return
        else: self.parent[pb] = pa; self.size[pa] += self.size[pb]
    def same(self,a,b): return find(self,a) == find(self,b)

n = iinput()
ans = 0
for i in range(1,n+1):
    m = n//i
    ans += i * m*(m+1)//2
print(ans)


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

const int N = 200000;
int n, q;
string s;
char t[N+1], d[N+1];

int simulation(int pos) {
  for (int i = 1; i <= q; i++) {
    if (pos == 0) return -1;
    else if (pos == n+1) return 1;
    
    if (t[i] == s[pos]) {
      if (d[i] == 'L') pos--;
      else pos++;
    }
  }

  if (pos == 0) return -1;
  else if (pos == n+1) return 1;

  return 0;
}

int main() {
  int i, left, right, mid, pos, left_end, right_end, result;

  // input
  cin >> n >> q;
  cin >> s;
  s = ' ' + s + ' ';  // s[0], s[n]: dummy
  for (i = 1; i <= q; i++) cin >> t[i] >> d[i];

  // decide left_end
  left = 0;
  right = n+1;
  left_end = 0;

  while (left+1 < right) {
    mid = (left + right) / 2;
    pos = mid;

    result = simulation(pos);
    if (result == -1) {
      if (mid > left_end) left_end = mid;
      left = mid;
    } else {
      right = mid;
    }
  }
  
  // decide right_end
  left = 0;
  right = n+1;
  right_end = n+1;

  while (left+1 < right) {
    mid = (left + right) / 2;
    pos = mid;

    result = simulation(pos);

    if (result == 1) {
      if (mid < right_end) right_end = mid;
      right = mid;
    } else {
      left = mid;
    }
  }
  cout << right_end - left_end - 1 << endl;
  
  return 0;
}


Measured memory_bytes: 984
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0]==s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
s=""
dx=tx-sx
dy=ty-sy
s+="U"*dy+"R"*dx+"D"*dy+"L"*dx
s+="L"+"U"*(dy+1)+"R"*(dx+1)+"D"
s+="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(s)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        long K = sc.nextLong();
        
        if(K%2==0) System.out.println(A-B);
        else System.out.println(B-A);
    }
}

Measured memory_bytes: 22740
n = int(input())
L = list(map(int, input().split()))
counter = 0

for i in range(len(L)):
  for j in range(i+1, len(L)):
    for k in range(j+1, len(L)):
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]:
          counter += 1
print(counter)

Measured memory_bytes: 9208
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N-i+1):
        if((Y-10000*i-5000*j)>=0 and (Y - 10000*i-5000*j)/1000 == N-i-j):
            print(i, j, (Y-10000*i-5000*j)//1000)
            quit()
else:
    print("-1",  "-1" , "-1")

Measured memory_bytes: 3060
#include <stdio.h>
#define NUM_DATA 3
void SimSelSort(int num[ ], int n) ;
void ShowData(int num[ ], int n);

void SimSelSort(int num[ ], int n)
{
    int i, j, k, min, temp;

    for (i = 0; i < n - 1; i++) {
        min = num[i];                 /* i 番目の要素を暫定的に最小値とし */
        k = i;                        /* 添字を保存 */
        for (j = i + 1; j < n; j++) {
            if (num[j] < min) {       /* より小さい値が現れたら */
                min = num[j];         /* 最小値の入れ替え */
                k = j;                /* 添字を保存 */
            }
        }                             /* このループを抜けるとk に最小値の添字が入っている */
        temp = num[i];                /* i 番目の要素と最小値の交換 */
        num[i] = num[k];
        num[k] = temp;
        //ShowData(num, NUM_DATA);
    }
}
  /* n 個のデータを表示 */
void ShowData(int num[ ], int n)
{
    /*
    while (n--)
        printf("%d  ", *num++);
    printf("\n");*/
    printf("%d\n", num[0]+num[1]);
    
}

int main(void){
    //int a=0, b=0, c=0,a1,b1,c1;
    //int a[3], a1[3],maxnum=0,minnum=0,i,max=0,min=10001,min2=10001;
    int num[3];
    scanf("%d %d %d", &num[0],&num[1],&num[2]);
    
        /* ソート対象のデータ */
    //int num[ ] = {8, 7, 6, 5, 4, 3, 2, 1};	

    SimSelSort(num, NUM_DATA);
    ShowData(num, NUM_DATA);
    //printf("\n");
    
    
    
    
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        m: usize, k: usize
    }

    if (m, k) == (1, 0) {
        println!("0 0 1 1");
    } else if (m, k) == (1, 1) {
        println!("-1");
    } else if k < 2usize.pow(m as u32) {
        let mut v = (0..2usize.pow(m as u32)).filter(|&i| i != k) .collect::<Vec<_>>();
        let mut v2 = v.clone();
        v2.reverse();
        v.push(k);
        v.extend(v2);
        v.push(k);
        for i in 0..v.len() {
            if i != v.len()-1 {print!("{} ", v[i]);}
            else {println!("{}", v[i]);}
        }
    } else {
        println!("-1");
    }
}

Measured memory_bytes: 8952
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
const int INF = 1e9;
const ll LINF = 1e18;
const long MOD=1e9+7;


template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    int n;cin >> n;
    map<string,int> s;
    s["AC"]=0;
    s["WA"]=0;
    s["TLE"]=0;
    s["RE"]=0;
    for(int i=0;i<n;i++){
        string t;
        cin >> t;
        s[t]+=1;
    }

    cout << "AC x " << s["AC"] << endl;
    cout << "WA x " << s["WA"] << endl;
    cout << "TLE x " << s["TLE"] << endl;
    cout << "RE x " << s["RE"] << endl;

    return 0;
}

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

int main()
{
    int N, M;
    cin>>N>>M;
    string S;
    cin>>S;

    vector<int> T(N+1, -1);
    T[N] = 0;
    int p = N;
    while (p>0)
    {
        int np = max(0, p-M);
        while (np>p || S[np]=='1')
            np++;
        if (np==p)
        {
            cout<<-1<<endl;
            return 0;
        }
        T[np] = T[p]+1;
        p = np;
    }

    int x = T[0];
    for (int i=1; i<=N; i++)
        if (S[i]=='0')
            if (T[i]==-1)
                T[i] = x;
            else
                x = T[i];

    p = 0;
    while (p<N)
    {
        int np = p+1;
        while (T[np]!=T[p]-1)
            np++;
        cout<<(p==0?"":" ")<<np-p;
        p = np;
    }
    cout<<endl;    
}


Measured memory_bytes: 1088
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, M;
ll dp[5001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    dp[0] = 1;
    for (ll i = 0; i < N-1; i++) {
        ll x = min(i+1, N-i);
        for (ll j = x; j <= N; j++) dp[j] = (dp[j] + dp[j-x]) % M;
    }
    ll ans = 0;
    for (ll i = 0; i <= N; i++) ans = (ans + (N-i)*dp[i]) % M;
    cout << ans << endl;
}

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

using  namespace std;

int main(){
	int a[100];
	int b[100];
	int n, m;
	
	
	while (cin >> n >> m){
		int diff = 0;
		if (n == 0 && m == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a[i];
			diff += a[i];
		}
		for (int i = 0; i < m; i++){
			cin >> b[i];
			diff -= b[i];
		}

		sort(a, a + n);
		sort(b, b + m);

		int x1 = -1, x2 = -1;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (diff == (a[i] - b[j]) * 2 && x1 == -1){
					x1 = a[i]; x2 = b[j];
				}
			}
		}
		if (x1 == -1){
			cout << -1 << endl;
		}
		else {
			cout << x1 << " " << x2 << endl;
		}

	}


}

Measured memory_bytes: 1180
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    for (a, b) in a.iter().zip(a[k..].iter()) {
        if a < b {
            println!("Yes");
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 5716
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;
  
  int n; cin>>n;
  vec<int> v(n); 
  forn(i) cin>>v[i];
  
  int cont = 0;
  int max = v[0];
  forn(i){
    if(v[i] >= max){
      cont++;
      max = v[i];
    }
  }
  
  cout<<cont<<endl;

  return 0;
}

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

using namespace std;

struct st {
    string s;
    int p;
    int idx;

    bool operator<(const st& other) {
        if (other.s != s) {
            return s < other.s;
        } else if (p != other.p) {
            return p > other.p;
        }
        return p > other.p;
    }
};

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<st> varr;
    for (int i = 0; i < N; i++) {
        string s;
        int p;

        cin >> s >> p;
        st tmp_s;
        tmp_s.idx = i + 1;
        tmp_s.s = s;
        tmp_s.p = p;
        varr.push_back(tmp_s);
    }

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

    for (auto& var: varr) {
        cout << var.idx << endl;
    }
    return 0;
}


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    X = readint()
    print(10 - X // 200)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(double q,x;(q=s.nextInt())>=0;System.out.printf("%.6f\n",x))for(x=q/2.;!(Math.abs(x*x*x-q)<0.00001*q);)x-=(x*x*x-q)/(3*x*x);}}

Measured memory_bytes: 11000
//
// Created by Hideaki Imamura on 2020-04-04.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll K;

int main() {
    cin >> K;

    queue<ll> q;
    for (int i = 1; i <= 9; ++i) q.push(i);
    ll x;
    for (int i = 0; i < K; ++i) {
        x = q.front(); q.pop();
        if (x % 10 != 0) q.push(10 * x + x % 10 - 1);
        q.push(10 * x + x % 10);
        if (x % 10 != 9) q.push(10 * x + x % 10 + 1);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(N-1) :
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)

ans = [0]*N

def dfs(u, p) :
    for v in to[u] :
        if v == p :
            continue
        ans[v] += ans[u]
        dfs(v, u)

for i in range(M) :
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

dfs(0, -1)

print(*ans)


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='-'){
        cout<<a-b<<endl;
    }
    else{
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[50],b[50];
ll f(ll n,ll x)
{
    return n>0?x<=a[n-1]+1?f(n-1,x-1):b[n-1]+1+f(n-1,x-2-a[n-1]):x<=0?0:1;
}

int main()
{
    ll n,x;
    scanf("%lld%lld",&n,&x);
    a[0]=1;
    b[0]=1;
    for(int i=1;i<n;i++)
    {
        a[i]=a[i-1]*2+3;
        b[i]=b[i-1]*2+1;
    }
    printf("%lld\n",f(n,x));
}


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

zero = 0
minus = 0
ans = 0

for i in range(N) :
    if A[i] == 0 :
        zero = 1
    elif A[i] < 0 :
        minus += 1
        A[i] *= -1

if zero or (minus % 2 == 0) :
    ans = sum(A)
else :
    ans = sum(A) - min(A) * 2

print(ans)
    

Measured memory_bytes: 14412
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N = 1e5+1;
int n,fa[N];
struct nd{ll x,y;ll id;}a[N];
struct nd2{ll w;ll x,y;}e[N*2];
bool cmp(nd a,nd b){return a.x<b.x;}
bool cmp2(nd a,nd b){return a.y<b.y;}
ll gf(ll x){return fa[x]==x?x:fa[x]=gf(fa[x]);}
bool operator <(nd2 a,nd2 b)
{
	return a.w>b.w;
}
priority_queue<nd2>q[2];
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)fa[i]=i;
	for(int i=1;i<=n;++i)cin>>a[i].x>>a[i].y;
	for(int i=1;i<=n;++i)a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n-1;++i)
	{
		nd2 in;
		in.w=abs(a[i].x-a[i+1].x);
		in.x=a[i].id,in.y=a[i+1].id;
		q[0].push(in);
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n-1;++i)
	{
		nd2 in;
		in.w=abs(a[i].y-a[i+1].y);
		in.x=a[i].id,in.y=a[i+1].id;
		q[1].push(in);
	}
	ll ans=0;
	for(int i=1;i<=n-1;++i)
	{
		nd2 t=q[0].top();while(gf(t.x)==gf(t.y)&&!q[0].empty())q[0].pop(),t=q[0].top();
		nd2 t1=q[1].top();while(gf(t1.x)==gf(t1.y)&&!q[1].empty())q[1].pop(),t1=q[1].top();
		if(t.w<=t1.w)
		{
			ans+=t.w;
			fa[gf(t.x)]=gf(t.y);
		}
		else
		{
			ans+=t1.w;
			fa[gf(t1.x)]=gf(t1.y);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 12016
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[200010],b[200010],idx[200010];
int c(const void*p,const void*q){
	if(b[*(ll*)p]<b[*(ll*)q])return -1;
	return 1;
}

int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		scanf("%lld%lld",a+i,b+i);
		idx[i]=i;
	}
	qsort(idx,n,sizeof(ll),c);
	ll crr=0;
	rep(i,0,n){
		crr+=a[idx[i]];
		if(crr>b[idx[i]]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 6396
// atcoder/abc160/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  str s;
  while (cin >> s) {
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
  }

  return 0;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

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

int main(){
	int n; sd(n);
	printf("%d\n", (n - 2) * 180);	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-10;

// 外積、符号付面積の２倍　|a||b|sinθ
double cross(Point a, Point b){
	// return a.real() * b.imag() - a.imag() * b.real();
	return (conj(a) * b).imag();
}
// 直線の交点
Point cross_point(Line a, Line b){
    double d1 = cross(b.second - b.first, b.first - a.first);
    double d2 = cross(b.second - b.first, a.second - a.first);
    return a.first + (a.second - a.first) * d1 / d2;
}

int main(){
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        double x, y;
        Point p[4];
        for(int j = 0; j < 4; j++){
            cin >> x >> y;
            p[j] = {x, y};
        }
        Line s1 = {p[0], p[1]};
        Line s2 = {p[2], p[3]};
        Point res = cross_point(s1, s2);
        printf("%.10f %.10f \n", res.real(), res.imag());
    }
}


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

int N, L[300];
int ans;

int main()
{
	cin >> N;
	for(int i = 1; i <= 2 * N; i++) cin >> L[i];
	
	sort(L+1, L+2*N+1);
	
	for(int i = 1; i <= N; i++) ans += L[2*i-1];
	
	cout << ans << endl;
	
	return 0;
}

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

const int N=200010;
int a[N];
map<int,int> mp;

int main()
{
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        mp[i-a[i]]++;
    }
    long long ans=0;
    for (int i=1;i<=n;i++) {
        mp[i-a[i]]--;
        ans+=mp[i+a[i]];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 21556
#include <stdio.h>
int main()
{

  int a,b,c;
  scanf("%d%d%d", &a, &b, &c);
  if(a <= b && b <= c ) printf("%d %d %d\n",a,b,c);
  else if(a <= c && c <= b) printf("%d %d %d\n",a,c,b);
  else if(b <= a && a <= c) printf("%d %d %d\n",b,a,c);
  else if(b <= c && c <= a) printf("%d %d %d\n",b,c,a);
  else if(c <= a && a <= b) printf("%d %d %d\n",c,a,b);
  else if(c <= b && b <= a) printf("%d %d %d\n",c,b,a);

  return 0;

}

Measured memory_bytes: 596
#include<stdio.h>

int main(){

	int a,b,d,r;
	double f;
	
	scanf("%d %d\n",&a,&b);
	
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;

	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 1068
import itertools

N, M = map(int, input().split())
nodes = [set(map(lambda x: int(x)-1, input().split())) for i in range(M)]
ans = 0
for path in itertools.permutations(range(N)):
    flag = True
    for i in range(N-1):
        if not ({path[i], path[i+1]} in nodes and path[0] == 0):
            flag = False
    if flag:
        ans += 1
print(ans)
                        
    


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int,input().split(" ")))
C = list(map(int,input().split(" ")))

def wei(N,A,B,C):
    r = 0
    c = 0
    C.insert(0,0)
    for i in A:
        r+=B[i-1]
        if i - c == 1:
            c = 1
            r+=C[i-1]
        c = i
    return r

print(wei(N,A,B,C))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e6+20;

char str[maxn];
int n;

int a[maxn];
int num[3],p[3],id[3];

inline void init()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	int tn=1;
	REP(i,2,n)if(str[i]==str[tn]);
	else str[++tn]=str[i];
	n=tn;             
	REP(i,1,n)a[i]=str[i]-'A',num[a[i]]++;
	REP(i,0,2)p[i]=i; sort(p,p+3,[](int a,int b){ return num[a]<num[b];});
	REP(i,0,2)id[p[i]]=i;
	REP(i,1,n)a[i]=id[a[i]]; sort(num,num+3);
}

vector<int>inc;

int vis[maxn];

inline void check()
{
	int tn=0;
	REP(i,1,n)if(!vis[i])
	{
		if(tn && a[i]==a[tn])num[a[i]]--;
		else a[++tn]=a[i];
	}
	REP(i,tn+1,n)a[i]=0;
	n=tn;
	memset(vis,0,sizeof(int)*(tn+1));
}

inline void doing()
{
	int mn=0,existb=0,lst=0;
	REP(i,1,n+1)
	{
		if(a[i]==0)
		{
			if(existb)mn--;
			else {
				if(i==n+1 || !lst);
				else mn++,inc.push_back(i);
			}
			existb=0; lst=i;
		}
		else if(a[i]==1)existb=1;
	}
	chkmax(mn,0);
	while(mn--)vis[inc.back()]=1,inc.pop_back(),num[0]--;
	check();
	
	existb=0; lst=0;
	
	REP(i,1,n+1)
	{
		if(a[i]==0)
		{
			if(existb)
			{
				if(a[lst+1]==2 && num[2]>num[1])num[2]--,vis[lst+1]=1;
				if(a[i-1]==2 && num[2]>num[1])num[2]--,vis[i-1]=1;
			}else if((i==n+1 || !lst) && a[i-1]==2 && num[2]>num[1])vis[i-1]=1,num[2]--;
			existb=0; lst=i;
		}else existb|=a[i]==1;
	}
	assert(num[2]==num[1]);
	check();
	int is0=0;
	REP(i,1,n-1)
	{
		if( num[2]>num[0] &&  (a[i]^a[i+1])==3 && (is0==0 || i+2>n || a[i+2]))
		{
			num[1]--;num[2]--; vis[i]=vis[i+1]=1;i++;
		}else is0=a[i]==0;
	}
	check();
	REP(i,1,n)printf("%c",p[a[i]]+'A');
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 10488