akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    int allneg = 1;
    for (auto &&i : v) {
        scanf("%li", &i);
        if(i > 0) allneg = 0;
    }
    if(allneg){
        int cur = 0;
        for (int i = 0; i < n; ++i) {
            if(v[i] > v[cur]) cur = i;
        }
        cout << v[cur] << "\n";
        cout << n-1 << "\n";
        for (int i = 0; i < cur; ++i) {
            cout << 1 << "\n";
        }
        for (int i = 0; i < n-1-cur; ++i) {
            cout << n-cur-i << "\n";
        }
        return 0;
    }
    ll sum1 = 0, sum2 = 0, summ;
    vector<int> v1, v2, v3;
    for (int i = 0; i < n; ++i) {
        if(v[i] >= 0) (i%2 ? sum1 : sum2) += v[i], (i%2 ? v1 : v2).emplace_back(i+1);
    }
    if(sum1 >= sum2 && !v1.empty()) summ = sum1, v3 = v1;
    else summ = sum2, v3 = v2;
    cout << summ << "\n";
    vector<int> ans;
    for (int j = n; j > v3.back(); --j) {
        ans.emplace_back(j);
    }
    for (int i = static_cast<int>(v3.size())-1; i > 0; --i) {
        int k = v3[i]-v3[i-1]-1;
        for (int j = 0; j < (k+1)/2; ++j) {
            ans.emplace_back(v3[i-1]+(k+1)/2-j);
        }
    }
    for (int i = 1; i < v3[0]; ++i) {
        ans.emplace_back(1);
    }
    cout << ans.size() << "\n";
    for (auto &&l : ans) cout << l << "\n";
    return 0;
}


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

#define f first
#define s second
#define eb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) (s.begin (), s.end ())

using namespace std;

typedef long long ll;

const int N = (int) 3e3 + 5;
const int mod = (int) 1e9 + 7;

inline void add (int &a, int b) {
        a += b;
        if (a >= mod) {
                a -= mod;
        }
}

int n, m, dp[N][N][2], ans;

inline void solve () {
        scanf ("%d%d", &m, &n);
        for (int i = 0; i <= m; i++) {
                dp[0][i][0] = 1;
        }
        for (int i = 0; i < n; i++) {
                for (int a = 0; a <= m; a++) {
                        int b = m - a;
                        if (a) {
                                add (dp[i + 1][a][1], dp[i][a][1]);
                                add (dp[i + 1][a - 1][1], dp[i][a][1]);
                                if (a == 1) {
                                        add (dp[i + 1][a][1], dp[i][a][0]);
                                        add (dp[i + 1][a - 1][1], dp[i][a][0]);
                                } else {
                                        add (dp[i + 1][a][0], dp[i][a][0]);
                                        add (dp[i + 1][a - 1][0], dp[i][a][0]);
                                }
                        }
                        if (b) {
                                add (dp[i + 1][a][1], dp[i][a][1]);
                                add (dp[i + 1][a + 1][1], dp[i][a][1]);
                                if (a == 0) {
                                        add (dp[i + 1][a][1], dp[i][a][0]);
                                        add (dp[i + 1][a + 1][1], dp[i][a][0]);
                                } else {
                                        add (dp[i + 1][a][0], dp[i][a][0]);
                                        add (dp[i + 1][a + 1][0], dp[i][a][0]);
                                }
                        }
                }
        }
        for (int i = 0; i <= m; i++) {
                add (ans, dp[n][i][1]);
        }
        printf ("%d\n", ans);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 70656
#include"bits/stdc++.h"
using namespace std;
#define     uniq(x)         sort(x.begin(),x.end());x.erase(unique(x.begin(),x.end()),x.end())

const int N = 1e5+5;
typedef long long int ll;

int main()
{
    int n,x,y;
    cin>>n>>x>>y;

    map<int,int>mm;

    for(int i=1; i<n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if(i<=x and j>x)
            {
                int xx=abs(i-j);

                int ss = abs(i-x);
                int dd = abs(j-y);

                int yy = ss+dd+1;

                mm[min(xx,yy)]++;
            }
            else if(i>=x and i<=y)
            {

                int xx= abs(i-j);

                int ss = abs(i-x);
                int dd = abs(j-y);

                int yy = ss+dd+1;

                mm[min(xx,yy)]++;

            }

            else
            {
                mm[abs(i-j)]++;
            }
        }
    }
    for(int i=1; i<n; i++)
    {
        cout<<mm[i]<<endl;
    }

}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int i, n;
    double x, r = 380000.0, sum = 0;
    char s[4];
    scanf("%d", &n);

    while(n--){
        scanf("%lf%s", &x, s);
        if(s[0] == 'J'){
            sum += x;
        }else{
            sum += x * r;
        }
    }

    printf("%lf\n", sum);
    return 0;
}

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

long long n,k,now=1,cnt,a[210000],pre[210000];

int main(){
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  while(k--){
    now=a[now];
    if(pre[now])k%=cnt-pre[now];
    pre[now]=cnt++;
  }
  cout<<now<<endl;
}


Measured memory_bytes: 6752
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main  {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int z=10000;
		int j=10000;
		int k=0;
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();

		for(int i=0;n>i;i++) {
			list.add(l+i);
		}
		//System.out.println(list);

		for(int i=0;n>i;i++) {
			if(Math.abs(list.get(i))<z) {
				z=Math.abs(list.get(i));
				j=i;
				//System.out.println(Math.abs(list.get(i)));
				//System.out.println(j);
			}
			//System.out.println(i);
		}
		list.remove(j);
		for(int i=0;list.size()>i;i++) {
			k=k+list.get(i);
		}
		System.out.println(k);
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
const double PI = 3.14159265358979323846;

int main() {
	int N, M;

	cin >> N >> M;

	int total = 0;

	for (int i = 0; i < M; i++) {
		int temp;
		cin >> temp;
		total += temp;
	}

	if (N < total) {
		cout << -1 << endl;
	}
	else {
		cout << N - total << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

int main(void){
    // Your code here!
    char S[1001];
    int w,n;
    scanf("%s",S);
    scanf("%d",&w);
    n = strlen(S);
    
    for(int i = 0; i < n; i = i + w)
    {
        printf("%c",S[i]);
    }
    printf("\n");
    
    return 0;
}

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

// FACTORIAL OF N MOD M

int main(){
  long long MOD=1000000007;
  long long P=1;
  int N;cin>>N;
  for(long long i=1;i<N+1;i++){
    P=(P*i)%MOD;
  }
  cout<<P%MOD<<endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for(int (i) = (n)-1; (i) >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define FI first
#define SE second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

int n;
vector<vector<int>> g;
vector<int> d, f;
vector<bool> vis;

void dfs(int v, int &t) {
  if(vis[v]) return;
  vis[v] = true;
  d[v] = t++;
  for(int u : g[v]) {
    dfs(u, t);
  }
  f[v] = t++;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n;
  g.resize(n);
  vis.resize(n, false);
  rep(i,n) {
    int u, k;
    cin >> u >> k;
    --u;
    rep(j,k) {
      int v;
      cin >> v;
      --v;
      g[u].push_back(v);
    }
  }
  d.resize(n); f.resize(n);
  int t = 1;
  rep(i,n) dfs(i, t);
  rep(i,n) {
    cout << i+1 << " " << d[i] << " " << f[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3152
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
vector<vector<ll>> dp;
vector<ll> w, v;
ll N, W;

ll res(ll i, ll j)
{
    if (i >= N)
    {
        return 0;
    }

    if (dp.at(i).at(j) != -1)
    {
        return dp.at(i).at(j);
    }
    ll ret;
    if (w.at(i) > j)
    {
        ret = res(i + 1, j);
    }
    else
    {
        ret = max(res(i + 1, j), res(i + 1, j - w.at(i)) + v.at(i));
    }

    return dp.at(i).at(j) = ret;
}

void solve()
{
    cin >> N >> W;
    dp = vector<vector<ll>>(N, vector<ll>(1000000, -1));
    w = vector<ll>(N);
    v = vector<ll>(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> w.at(i) >> v.at(i);
    }

    cout << res(0, W) << endl;

    return;
}

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


Measured memory_bytes: 789632
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	ans := 0
	for i := 1; i <= n; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		ans += i
	}
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

public class Main{

	
	public static void main(String[] args){
	
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int ans = 0;

		for(int i = 0;i < N;i++){
			int h = stdIn.nextInt();
			if(h >= K){
				ans++;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 48932
n = gets.chomp.to_i

point = Array.new(n).map{|x| x=0}

for i in 0..n*(n-1)/2-1
  a,b,c,d = gets.chomp.split.map(&:to_i)
  if c==d
    point[a-1] += 1
    point[b-1] += 1
  elsif c>d
    point[a-1] += 3
  else
    point[b-1] += 3
  end
end

p_sort = point.sort.reverse

point.map{|x|
  puts p_sort.index{|y| x==y}+1
}


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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

//const long long MAXN =1001000;
long long n,m;

int main(){
    read(n);read(m);

    long long ans=1e9;


    {
        long long tmp=n%3;
        long long A=n/3;
        long long B=(n/3+tmp/2);
        long long C=(n-A-B);
        A=A*m; B=B*m;   C=C*m;
        ans=min( ans , max ( max(A,B) ,C) - min( min( A, B ) ,C ) );
    }

    for (long long i=1;i<n;i++)
        {
            long long A=i*m;
            long long B=(n-i)*(m/2);
            long long C=(n-i)*m-B;
            ans=min( ans , max ( max(A,B) ,C) - min( min( A, B ) ,C ) );
        }
    swap(n,m);



    {
        long long tmp=n%3;
        long long A=n/3;
        long long B=(n/3+tmp/2);
        long long C=(n-A-B);
        A=A*m; B=B*m;   C=C*m;
        ans=min( ans , max ( max(A,B) ,C) - min( min( A, B ) ,C ) );
    }
    for (long long i=1;i<n;i++)
        {
            long long A=i*m;
            long long B=(n-i)*(m/2);
            long long C=(n-i)*m-B;
            ans=min( ans , max ( max(A,B) ,C) - min( min( A, B ) ,C ) );
        }


    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
ll mp[400][400];
ll mp2[400][400];

bool s() {
    int i, j, k;
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <= n; ++j) {
            if (j == i)
                continue;
            for (k = j + 1; k <= n; ++k) {
                if (k == i)
                    continue;
                ll t = mp[j][i] + mp[i][k];
                if (t < mp[j][k])
                    return 0;
                if (mp2[j][k] == 0)
                    mp2[j][k] = t;
                else
                    mp2[j][k] = min(mp2[j][k], t);
            }
        }
    }
    return 1;
}

int main() {
    int i, j;
    cin >> n;
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <=n; ++j) {
            cin >> mp[i][j];
        }
    }
    if (!s()) {
        cout << -1 << endl;
        return 0;
    }
    ll sum = 0;
    for (i = 1; i <= n; ++i) {
        for (j = i + 1; j <= n; ++j) {
            if (mp2[i][j] != mp[i][j]) {
                sum += mp[i][j];
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  vector<int> vec(12);
  vec = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (vec.at(a - 1) == vec.at(b - 1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n); inn(l);
    int max = (l - 1)*n + n*(n + 1)/2;
    if (l < 0) {
        out(max - (l - 1) - (std::min(-l, n - 1) + 1));
    } else {
        out(max - (l - 1) - 1);
    }
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
#define i_am_god return 0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

map<string,int>a;
int n,m,rez=-1e9;
string x;

int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        a[x]++;
    }
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        a[x]--;
    }
    auto it=a.begin();
    while(it!=a.end()){
        if(rez<a[it->first]) rez=a[it->first];
        it++;
    }
    cout<<max(rez,0);
    i_am_god;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    int cnt=0, tap=1;
    while(tap<b){
        tap+=a-1;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#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(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N, M, X;
    cin >> N >> M >> X;

    int left = 0;
    int right = 0;

    FOR(i, 0, M){
        int a;
        cin >> a;

        if(a < X){
            left++;
        }else{
            right++;
        }
    }

    if(left < right){
        p(left);
    }else{
        p(right);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define P 137  //check the limits, man
#define N 200005
const ll INF = 1e18;
bool cmp(ii A,ii B)
{
    if(A.F!=B.F)
        return A.F<B.F;
    return A.S>B.S;
}
int main()
{
    int n,i,l,r,a,b,ans;
    in(n);
    l=0,r=M;
    vii vp(n);
    rep(i,n)
    {
        in2(vp[i].F,vp[i].S);
        vp[i].S++;
        if(vp[i].F>l)
            l=vp[i].F;
        if(vp[i].S<r)
            r=vp[i].S;
    }
    vii ar(n);
    ans=0;
    rep(i,n)
    {
        a=max(vp[i].S-l,0);
        b=max(r-vp[i].F,0);
        ar[i]={a,b};
        ans=max(ans,vp[i].S-vp[i].F);
    }
    ans+=max(0,(r-l));
    sort(all(ar),cmp);
    b=ar[0].S;
    lp(i,1,n)
    {
        ans=max(ans,ar[i].F+b);
        b=min(b,ar[i].S);
    }
    out(ans);
}


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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
  int n=in(),v[n],c[n],ans=0;
  forin(v,n);
  forin(c,n);
  for (int i=0;i<n;i++){
    if (v[i]>c[i]) ans+=(v[i]-c[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
    vector<ll> a(n+1);
    bool ok=1;
    ll res=0;
    for(int i=0;i<n+1;i++){
        cin >> a[i];
    }
    if(n==0){
        if(a[0]==1){
            printf("1\n");
        }
        else{
            printf("-1\n");
        }
        return 0;
    }
    if(a[0]==1){
        if(n==0){
            printf("1\n");
        }
        else{
            printf("-1\n");
        }
        return 0;
    }
    vector<ll> mi(n+1),ma(n+1);
    for(int i=n;i>=0;i--){
        if(i==n){
            mi[i]=ma[i]=a[i];
        }
        else{
            ma[i]=ma[i+1]+a[i];
            mi[i]=a[i]+(mi[i+1]+1)/2;
        }
    }
    /*for(int i=0;i<=n;i++){
        cout << mi[i] << " " << ma[i] << endl;
    }*/
    res++;
    ll now=1;
    for(int i=1;i<=n;i++){
        if(mi[i]<=2*now){
            now=min(2*now,ma[i]);
            //cout << now << endl;
            res+=now;
            now-=a[i];
        }
        else{
            ok=0;
            break;
        }
    }
    if(ok){
        printf("%lld\n",res);
    }
    else{
        printf("-1\n");
    }
}

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

public class Main {

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

        String[] cycle = {"Sunny","Cloudy","Rainy"};
        int num = Arrays.asList(cycle).indexOf(s);

        System.out.println(cycle[num >= 2? 0: num+1]);
    }
}

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

using namespace std;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int m,n;
bool ice[90][90];

int step(int x,int y)
{
	if(!ice[y][x])	return 0;
	ice[y][x]=false;
	int maxstep=0;
	for(int i=0;i<4;i++){
		int xx=x+dx[i],yy=y+dy[i];
		if(0<=yy && y<m && 0<=xx && xx<n)	maxstep=max(maxstep,step(xx,yy)+1);
	}
	ice[y][x]=true;
	return maxstep;
}

int main()
{
	for(;cin>>m>>n,m;){
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			int a;	cin>>a;
			ice[i][j]=a;
		}
		int maxstep=0;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	maxstep=max(maxstep,step(j,i));
		cout<<maxstep<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] V = new long[N];
        for (int i=0; i<N; i++){
            V[i] = sc.nextInt();
        }
        sc.close();

        // l + r - d

        long ans = Long.MIN_VALUE;

        for(int l=0; l<=K; l++){
            for (int r=0; r<=K-l; r++){
                if (l+r > N) break;

                ArrayList<Long> s = new ArrayList<>();
                int d = K - l - r;
                long now =0;

                for (int i=0; i<=l-1; i++){
                    now += V[i];
                    s.add(V[i]);
                }
                for (int i=N-r; i<N; i++){
                    now += V[i];
                    s.add(V[i]);
                }

                Collections.sort(s);

                for (int i=0; i<d; i++){
                    if (i >= s.size()) break;
                    long tmp = s.get(i);
                    if (tmp > 0) break;
                    now -= tmp;
                }
                ans = Math.max(ans, now);
            }
        }
        System.out.println(ans);

    }
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    string s;cin>>s;
    s[3]++;
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 82;
const int tmp = 80 * 80 * 2;
int h,w,x;
int a[N][N];
bool dp[N][N][N * N * 4];
int main()
{
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            scanf("%d", a[i] + j);
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            scanf("%d", &x), a[i][j] -= x;
    dp[1][1][tmp + a[1][1]] = 1;
    dp[1][1][tmp - a[1][1]] = 1;
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            for (int k = 0; k <= tmp * 2; ++k)
                if (dp[i][j][k])
                {
                    dp[i][j + 1][k + a[i][j + 1]] = 1;
                    dp[i][j + 1][k - a[i][j + 1]] = 1;

                    dp[i + 1][j][k + a[i + 1][j]] = 1;
                    dp[i + 1][j][k - a[i + 1][j]] = 1;
                }
    int ans = 1e9;
    for (int k = 0; k <= tmp * 2; ++k)
        if (dp[h][w][k])
            ans = min(ans, abs(tmp - k));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 174848
#include <cstdio>
#include <algorithm>

const int MAXW = 100005;

long long f[MAXW];

int main() {
    int n, W;
    scanf("%d %d", &n, &W);

    for (int i = 0, w, v; i < n; i++) {
        scanf("%d %d", &w, &v);
        for (int j = W; j >= w; j--) f[j] = std::max(f[j], f[j - w] + v);
    }

    long long ans = 0;
    for (int i = 0; i <= W; i++) ans = std::max(ans, f[i]);
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 896
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

var graph [][]int
var counter []int

// 深さ優先探索
var seen []bool

func dfs(id, cnt int) {
	counter[id] += cnt
	seen[id] = true
	if len(graph[id]) > 0 {
		for _, v := range graph[id] {
			if seen[v] {
				continue
			}
			dfs(v, counter[id])
		}
	}
}

func main() {
	var N, Q int
	fmt.Scan(&N, &Q)
	graph = make([][]int, N)
	counter = make([]int, N)
	seen = make([]bool, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N-1; i++ { // 辺の数はN-1本
		a := nextInt(sc)
		b := nextInt(sc)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}
	for i := 0; i < Q; i++ {
		p := nextInt(sc)
		p--
		counter[p] += nextInt(sc)
	}

    dfs(0, 0)

    wtr := bufio.NewWriter(os.Stdout) // 出力高速化
	for i := range counter {
		fmt.Fprint(wtr, counter[i], " ")
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}


Measured memory_bytes: 50304
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp = sum(p[0:k])
ans = exp
for i in range(n-k):
  exp = exp-p[i]+p[i+k]
  #print(ans, exp)
  if ans<exp:
    ans = exp
    #print("ans", exp, ans)
print((ans+k)/2)



Measured memory_bytes: 25060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef vector<int> Vec;

inline double distance(double dl, double da, double db) {
  return dl * dl + da * da + db * db;
}

int main() {
  int n, m, r;
  bool reverse;
  double l[20], a[20], b[20];
  double max_sum = 0;
  queue<Vec> vq;
  queue<int> iq;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> l[i] >> a[i] >> b[i];
  }
  r = (m <= n / 2? m: n - m);
  reverse = (not (m <= n / 2));
  vq.push(Vec());
  iq.push(0);
  while (not vq.empty()) {
    Vec v = vq.front();
    int begin = iq.front();
    vq.pop();
    iq.pop();
    if (int(v.size()) == r) {
      double s = 0;
      if (reverse) {
        Vec rv;
        set<int> is;
        for (size_t i = 0; i < v.size(); ++i) {
          is.insert(v[i]);
        }
        for (int i = 0; i < n; ++i) {
          if (is.count(i) == 0) {
            rv.push_back(i);
          }
        }
        v = rv;
      }
      for (int i = 0; i < m; ++i) {
        for (int j = i + 1; j < m; ++j) {
          s += distance(l[v[i]] - l[v[j]], a[v[i]] - a[v[j]], b[v[i]] - b[v[j]]);
        }
      }
      max_sum = max(max_sum, s);
    } else if (begin < n) {
      vq.push(v);
      iq.push(begin + 1);
      v.push_back(begin);
      vq.push(v);
      iq.push(begin + 1);
    }
  }
  cout.precision(20);
  cout << fixed << max_sum << endl;
  return 0;
}

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

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

  int group = 1, score = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i+1]) {
      score++;
    } else {
      group++;
    }
  }

  for (int i = 0; i < k; i++) {
    if (group > 1) {
      group--;
      score += 2;
    } else {
      break;
    }
  }

  cout << min(score, n - 1) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	ll N;
	cin >> N;

	cout << (N-1)*N/2 << endl;

	return 0;
}


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

vector<vector<ll> > a(301,vector<ll>(301,0));
vector<vector<bool> > c(301,vector<bool>(301,true));
int n;
bool chk;

void wf(){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(a[i][j]>a[i][k]+a[k][j]){
                    chk=false;
                }
                if(a[i][j]==a[i][k]+a[k][j]&&k!=i&&j!=k){
                    c[i][j]=false;
                }
            }
        }
    }
}

int main(){

    cin >> n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin >> a[i][j];
        }
    }
    chk=true;
    wf();

    if(!chk){
        cout << -1 << endl;
        return 0;
    }

    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(c[i][j]){
                ans+=a[i][j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
  for(int u : to[v]) {
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int n, q;

  cin >> n >> q;

  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);


  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);

  rep(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 23808
//#pragma GCC optimize (2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ii =  pair<int,int>;
const int  dir[2][2] = {{-1,0},{0,1}};
const int mod = 1000000007;
const int INF = 0x3f3f3f;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solution();
int main() {
    int T = 1;
//    cin>>T;
    while (T--) {
        solution();
    }
    return 0;
}
void solution(){
    int cur = 0;
    int n;
    cin>>n;
    int temp;
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        cin>>temp;
        if (temp >= cur){
            cur = temp;
        }
        else{
            ans+=cur-temp;
//            cout<<cur-temp<<endl;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    x -= z*2;
    int ans = x/y;
    int num_z = ans - 1;

    for (size_t i = 0; i < x/y; i++)
    {
        if(x/(y*ans+num_z*z) >= 1) break;
        else {
            ans--;
            num_z = ans -1;
            }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Node{
  int now;
  int sub;
  long cost;
};

struct Edge{
  int from;
  int to;
  long cost;
};

bool operator<(const Node &a, const Node &b){
  if(a.cost != b.cost){
    return a.cost < b.cost;
  }else{
    return a.now < b.now;
  }
}
bool operator>(const Node &a, const Node &b){return (b < a);}
bool operator<=(const Node &a, const Node &b){return !(b < a);}
bool operator>=(const Node &a, const Node &b){return !(a < b);}

//vector<vector<Edge>> Graph(n);

vector<vector<long>> Dijkstra(vector<vector<Edge>> &Graph, int s){ //最小コスト
  priority_queue<Node, vector<Node>, greater<Node>> que;
  vector<vector<long>> dist(Graph.size(), vector<long>(3, 1e16));

  dist.at(s).at(0) = 0;
  que.push(Node{s, 0, 0});

  while(que.size()){
    Node node = que.top();
    que.pop();
    int v = node.now;
    int sv = node.sub;
    if(node.cost > dist.at(v).at(sv)) continue;
    for(Edge edge : Graph.at(v)){
      int nv = edge.to;
      long cost = edge.cost;
      int nsv = (sv + 1) % 3;
      if(dist.at(nv).at(nsv) > dist.at(v).at(sv) + cost){
        dist.at(nv).at(nsv) = dist.at(v).at(sv) + cost;
        que.push(Node{nv, nsv, dist.at(nv).at(nsv)});
      }
    }
  }
  return dist;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<Edge>> Graph(n);
  rep(i,m){
    int u,v;
    cin >> u >> v;
    u--;v--;
    Graph.at(u).push_back(Edge{u,v,1});
  }
  int s,t;
  cin >> s >> t;
  s--;t--;
  vector<vector<long>> dist = Dijkstra(Graph, s);
  if(dist.at(t).at(0) % 3 == 0) cout << dist.at(t).at(0) / 3 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 11136
"use strict";

const getGcd = (a, b) => {
  return a ? getGcd(b % a, a) : b;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    // 最大公約数を見つける
    let gcd = getGcd(A, B);
    
    let answer = 1;

    // 最大公約数の素因数の数+1が答えになる
    // ループを回すのは平方根までで良い
    for(let i=2; i*i<=gcd; i++) {
        if(gcd % i === 0) {
            answer++;
            while(gcd%i===0) gcd /= i;
        }
    }
    
    if(gcd !== 1) {
        answer++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9932
// Fractional Knapsack - 2
// Greedy Method
// given N number of items and a W weight bag .
// Each item consists a weight w (-10<=w<=10) and it's corresponding value v(-10<=v<=10) .
// Fill the bag with this item but not overflow and also maximize the profit .
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
struct ABC
{
    double w , v , u ;
};
bool cmp(ABC A,ABC B)
{
    return A.u > B.u ;
}
vector <ABC> list ;
int main()
{
    int N ;
    double W ;
    scanf("%d%lf",&N,&W);
    double profit = 0.0 ;
    for(int i=0;i<N;i++)
    {
        ABC obj ;
        scanf("%lf%lf",&obj.w,&obj.v);
        obj.u = obj.v / obj.w ;
        if(obj.w>=0&&obj.v<=0) continue ; // Not consider the item .
        if(obj.w<=0&&obj.v>=0)
        {
            W-=obj.w;
            profit+=obj.v;
            continue;
        } // Must take item .
        if(obj.w<=0&&obj.v<=0)
        {
            W-=obj.w;
            profit+=obj.v;
            obj.w*=-1.0;
            obj.v*=-1.0;
        }
        list.push_back(obj);
    }
    sort(list.begin(),list.end(),cmp);

    for(int i=0;i<list.size()&&W!=0.0;i++)
    {
        if(list[i].w<=W)
        {
            W-=list[i].w;
            profit+=list[i].v; // Take the item .
        }
        else
        {
            profit+=list[i].u*W; // take the item .
            W=0.0;
        }
    }
    printf("%.8lf\n",profit);
    return 0;
}
/*
5 10
4 20
5 24
3 25
1 10
2 5
*/
/*
Maximize value is : 64.600000
*/

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

typedef long long ll;
 
int main(){
  int n, y;
  cin >> n >> y;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n; j++){
      if(i+j>n) continue;
      if((4*i+9*j)==y/1000-n){
        cout << j << " " << i << " " << n-i-j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

using P = pair<int, int>;

constexpr int MAX_N = 2 * 1e5 + 9;

P p[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p+N, [](P l, P r) {
    if (l.second == r.second)
      return (l.second - l.first) < (r.second - r.first);
    return l.second < r.second;
  });

  int t{};
  for (int i{}; i < N; ++i) {
    t += p[i].first;
    if (t > p[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int price = 700;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'o') { price += 100; }
  }
  cout << price << endl;
}

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

using namespace std;

using ll = long long;

bool Solve() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];

    for (int i = 0; i + m <= n; ++i)
        for (int j = 0; j + m <= n; ++j) {
            bool flag = true;
            for (int y = 0; y < m; ++y)
                for (int x = 0; x < m; ++x)
                    if (a[i + y][j + x] != b[y][x]) flag = false;
            if (flag) return true;
        }

    return false;
}

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

    cout << (Solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	char s[101];
	scanf("%s",s);
	int l = strlen(s);
	int ans = 10000;
	for(char c='a';c<='z';c++){
		int cnt = 0;
		int t = 0;
		for(int i=0;i<=l;i++){
			if(i==l||s[i]==c){
				t = max(t,cnt);
				cnt = 0;
			}else{
				cnt++;
			}
		}
		ans = min(ans,t);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
def do(level,x):
    if x<=0: #1層も手を付けないとき
        return 0
    elif x>=whole[level]: #完食できるとき
        return patty[level]
    #それ以外、途中まで食べるときはlevel>=1の場合のみあり得る
    x-=1 #このとき1層目は必ずバンズ
    res=0 #食べたパティの総数を記録する
    if x>=whole[level-1]+1: #真ん中のパティまで到達できるとき
        x-=whole[level-1]+1
        res+=patty[level-1]+1
    return res+do(level-1,x)

n,x=map(int,input().split())
whole=[1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]
patty=[1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]
print(do(n,x))

Measured memory_bytes: 38336
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    using namespace std ;
    int main(){
        int a,b;
        cin>>a>>b;
        if((a+b)%2==0)cout<<(a+b)/2<<endl;
        else cout<<((a+b)/2)+1<<endl;
        return 0 ;
    }

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
up=0
down=0
cnt=0
for i in range(n-1):
    if up==1:
        if a[i]>a[i+1]:
            up=0
            cnt+=1
    elif down==1:
        if a[i]<a[i+1]:
            down=0
            cnt+=1
    else:
        if a[i]<a[i+1]:
            up=1
        elif a[i]>a[i+1]:
            down=1
else:
    cnt+=1
    print(cnt)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		if(a>c)swap(a,c);
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
		if(a*a+b*b==c*c)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3120
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  long n;
  cin >> n;
  
  long ans = 1;
  for(long i = 1 ; i <= n ; i++){
    ans = ans * i %1000000007; 
  }
  P(ans);
  ret 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int H, W;
    cin >> H >> W;

    vector<vector<int>> dp(H, vector<int>(W));
    dp[0][0] = 1;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char a;
            cin >> a;
            bool iswall = (a == '#');
            if (iswall)
                continue;
            if (i > 0)
                (dp[i][j] += dp[i - 1][j]) %= MOD;
            if (j > 0)
                (dp[i][j] += dp[i][j - 1]) %= MOD;
        }
    }

    cout << dp[H - 1][W - 1] << endl;
    return 0;
}


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

signed main() {
	string s;
	cin >> s;

	int a = stoi(s.substr(0, 2)), b = stoi(s.substr(2, 2));

	bool A = false, B = false;

	if (0 < a and a < 13) A = true;
	if (0 < b and b < 13) B = true;

	if (A and !B) cout << "MMYY" << endl;
	else if (!A and B) cout << "YYMM" << endl;
	else if (A and B) cout << "AMBIGUOUS" << endl;
	else cout << "NA" << endl;
}



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

int main() {
  int k,x;
  cin>>k>>x;
  if (500*k>=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256