akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 22740
# ABC 087 C

N = int(input())
A = [[int(n) for n in input().split()] for _ in range(2)]

max_ = A[0][0]
q = [(0, 0, max_)]
while q:
    i, j, x = q.pop()
    if i < 1:
        q.append((i+1, j, x + A[i+1][j]))
    if j < N-1:
        q.append((i, j+1, x + A[i][j+1]))
    if i == 1 and j == N-1:
        max_ = max(max_, x)
print(max_)

Measured memory_bytes: 3064
n = int(input())
l = [list(_ for _ in input().split()) for i in range(n)]
l = [[l[i][0] ,int(l[i][1]),i+1] for i in range(n)]
l = sorted(l,key = lambda x:(x[0],-x[1]))
[print(l[i][2]) for i in range(n)]


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>


const int MAXN = 200007;


int dp[MAXN];


int main() {
    int n, fAKe_ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        int num;
        scanf("%d", &num);
        dp[num] = dp[num - 1] + 1;
        fAKe_ans = std::max(dp[num], fAKe_ans);
    }
    std::cout << n - fAKe_ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

ll N;
string S;

int main(){
	cin >> N >> S;
	string lr = "L";
	if(S[0]=='W' || S[2*N-1]=='W') {
		cout << 0 << endl;
		return 0;
	}
	for(int i=1;i<2*N;i++)
	{
		if(S[i-1] == S[i]) {
			if(lr[i-1] == 'L') lr += 'R';
			else lr += 'L';
		} else {
			if(lr[i-1] == 'L') lr += 'L';
			else lr += 'R';
		}
	}
	bool flag = true;
	int ltmp = 0, rtmp = 0;
	for(int i=0;i<lr.size();i++) {
		if(lr[i]=='L') ltmp++;
		else rtmp++;
	}
	if(ltmp != rtmp) {
		cout << 0 << endl;
		return 0;
	}
	//cout << lr << endl;
	ll ans = 1;
	ll l = 0;
	for(int i=0;i<2*N;i++) {
		if(lr[i]=='L') {
			l++;
		} else {
			ans *= l;
			ans %= MOD;
			l--;
		}
	}
	for(int i=N;i>=1;i--) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    priority_queue<int> b;
    rep(i,n) {
        int bi;
        cin >> a.at(i) >> bi;
        b.push(bi);
    }
    
    int amax = *max_element(a.begin(), a.end());
    int ans = 0;
    while (0 < h) {
        if (b.size() && amax < b.top()) {
            h -= b.top();
            b.pop();
            ans++;
        }
        else {
            ans += h/amax;
            if (0 < (h % amax)) ans++;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4248
A = [0 for _ in xrange(10**5+10)]
N, K = map(int, raw_input().split())
for i in xrange(N):
    a, b = map(int, raw_input().split())
    A[a] += b

k = 0
for i in xrange(10**5+10):
    k += A[i]
    if k >= K:
        print i
        break


Measured memory_bytes: 4840
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a), greater<int>());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld n,i,j,p,k,m,l,x,y;
    cin>>n;
    if((n%10==9)||((n/10)==9))
        cout<<"Yes";
    else
        cout<<"No";






}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

ll L, R;

int main()
{
    cin >> L >> R;
    if (R - L >= 2018)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans = inf;
    for (ll i = L; i < R; i++)
    {
        for (ll j = i + 1; j <= R; j++)
        {
            ll fact = i * j;
            ll m = fact % 2019;
            ans = min(ans, m);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);


//入力変数
int H,W;
H = sc.nextInt();
W = sc.nextInt();
String[] Temp = new String[H];
for(int i=0;i<H;i++){
    Temp[i]=sc.next();
}
String[][] S = new String[H][W];
for(int i = 0;i<H;i++){
    for(int j=0;j<W;j++){
        S[i][j]=Temp[i].substring(j,j+1);
    }
}

//入力値変換
int numberofwhite=0;
int numberofblack=0;
for(int i = 0;i<H;i++){
    for(int j=0;j<W;j++){
        if(S[i][j].equals(".")){
            numberofwhite++;
        }else{
            numberofblack++;
        }
    }
}

int[][] count = new int[H][W];
for(int i = 0;i<H;i++){
    for(int j=0;j<W;j++){
        count[i][j]=-1;
    }
}
count[0][0]=0;


//出力変数
int ans=0;

//計算
for(int k=1;count[H-1][W-1]==-1&&k<H*W;k++){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(count[i][j] == k-1){
                if(0<=i-1){
                    if(count[i-1][j]==-1&&S[i-1][j].equals(".")){
                    count[i-1][j]=k;
                    }
                }
                if(i+1<H){
                    if(count[i+1][j]==-1&&S[i+1][j].equals(".")){
                    count[i+1][j]=k;
                    }
                }
                if(0<=j-1){
                    if(count[i][j-1]==-1&&S[i][j-1].equals(".")){
                    count[i][j-1]=k;
                    }
                }
                if(j+1<W){
                    if(count[i][j+1]==-1&&S[i][j+1].equals(".")){
                    count[i][j+1]=k;
                    }
                }
            }
        }
    }
}
if(count[H-1][W-1]==-1){
    ans=-1;
}else{
    ans=H*W-count[H-1][W-1]-1-numberofblack; 
}

//出力
System.out.println(ans);

}}

Measured memory_bytes: 21972
import sys


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    n, m, d = map(int, input().split())
    if d == 0:
        print(n * (m - 1) / (n ** 2))
    else:
        print((n - d) * 2 * (m - 1) / (n ** 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
# input
a, b, c, d = map(int, input().split())

if abs(a - b) > abs(a - c):
    if abs(a - c) <= d:
        print('Yes')
    else:
        print('No')
else:
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};

bool isdig(char c){
  return '0' <= c && c <= '9';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  cout<<SUBS(s,0,s.size()-8)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll k,x;
    cin>>k>>x;
    rep(i,2*k-1){
        cout<<x-k+i+1<<" ";
    }cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int count = 0;
	while(true){
	    count=0;
	    int n=sc.nextInt();
	    int x=sc.nextInt();
	    if(n==0 && x==0) break;
	    for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
		    for(int k=j+1;k<=n;k++){
			if(i+j+k==x) count++;
		    }
		}
	    }
	    System.out.println(count);
	}
    }
}

Measured memory_bytes: 19588
#include <cstdio>

int main(){
    int N,M,X,Y;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    int x[N];
    for(int i = 0; i < N; i++){
        scanf("%d",&x[i]);
    }
    int y[M];
    for(int i = 0; i < M; i++){
        scanf("%d",&y[i]);
    }

    if(Y - X < 1){
        printf("War\n");
        return 0;
    }else{
        int max_x = x[0];
        for(int i = 0; i < N; i++){
            if(x[i] > max_x){
                max_x = x[i];
            }
        }
        int min_y = y[0];
        for(int i = 0; i < M; i++){
            if(y[i] < min_y){
                min_y = y[i];
            }
        }

        if(max_x < Y && X < min_y && max_x < min_y){
            printf("No War\n");
            return 0;
        }else{
            printf("War\n");
            return 0;
        }
    }
    
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 && b==2)cout<<3;
	
	if(a==1 && b==3)cout<<2;
	
	if(a==3 && b==2)cout<<1;
	if(a==2 && b==1)cout<<3;
	
	if(a==3 && b==1)cout<<2;
	
	if(a==2 && b==3)cout<<1;
	 
	return 0;
}
/*3 4
4 1 2 3
4 1 3 2
4 2 1 3
*/

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	s := inputLine()
	el := strings.Split(s, " ")
	var res string = ""

	for _, v := range el {
		res += strings.ToUpper(v[0:1])
	}
	fmt.Println(res)
}


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n; cin >> n;
    int ans = 1;
    while(ans * 2 <= n){
        ans *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while 1:
    H,W = map(int,input().split())
    if H==0:break
    for i in range(H):
        print([["#."*int(W/2),"#."*int(W//2)+"#"][W%2==1],[".#"*int(W/2),".#"*int(W//2)+"."][W%2==1]][i%2==1])
    print()


Measured memory_bytes: 5620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> h(N);
  ll min_v = INF;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    min_v = min(min_v, h[i]);
  }
  for (int i = 0; i < N; i++) {
    h[i] -= min_v;
  }
  ll ans = min_v;
  for (int i = 0; i < N; i++) {
    if (h[i] == 0) continue;
    ll res = h[i];
    ans += res;
    ll r = i;
    while (r + 1 < N && h[r + 1] != 0) r++;
    ll l = i + 1;
    while (l <= r) {
      if (h[l] < res) {
        res = h[l];
        h[l] = 0;
      } else {
        h[l] -= res;
      }
      l++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  string m;
  cin >> n >> m;
  sort(all(m));
  if(m[(n+2-1)/2-1]=='B') pri("No");
  else pri("Yes");
  return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main() {
  int n; cin >> n;
  ll cnt = 0;
  FOR(i, 1, n+1){
    if((int)to_string(i).size() %2==1) cnt++;
  }
  cout << cnt << endl;
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<bool> has_snack(N,false);
    REP(_, K) {
        int d;
        cin >> d;
        REP(_, d) {
            int A;
            cin >> A;
            --A;
            has_snack[A] = true;
        }
    }
    int result = N - accumulate(all(has_snack), 0);
    cout << result << endl;

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){
        OP("No");
    }else{
        OP("Yes");
    }
}


Measured memory_bytes: 256
S = str(input())

if S == 'SUN':
	print(7)
	
if S == 'SAT':
	print(1)
	
if S == 'MON':
	print(6)
	
if S == 'TUE':
	print(5)

if S == 'WED':
	print(4)
	
if S == 'THU':
	print(3)
	
if S == 'FRI':
	print(2)
	


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

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

  int n, m;
  cin >> n >> m;

  long ans = 1;
  for (long a = 1; a * a <= m; ++a) {
    if (m % a != 0) continue;
   
    long b = m / a; 
    if ((long)a * n <= m) ans = max(ans, a); 
    if ((long)b * n <= m) ans = max(ans, b); 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int ai[10000];
int main()
{
    int n;
    cin>>n;
    long long sum = 0;
    for(int i=1;i<=n;i++){
        cin>>ai[i];
        sum +=ai[i];
    }
    cout<<sum-n<<endl;
    return 0;
}
/*
4
128 4 340
*/


Measured memory_bytes: 256
n = int(input())
s = int(input())
if(n<s):
    print(-1)
    exit()
elif(n==s):
    print(n+1)
    exit()

lim = 10**6
for i in range(2,lim+1):
    tmp = 0
    x = n
    while(x > 0):
        tmp += x%i
        x //= i
    if(tmp==s):
        print(i)
        exit()

#2桁
ns = n-s
inf = 10**12
ans = inf
for i in range(1,ns+1):
    if(i**2 > ns):
        break

    if(ns%i==0):
        b = ns//i + 1
        y = n-(b*i)
        if(i+y==s)&(0<=y<b):
            ans = min(ans,b)

if(ans==inf):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 73292
n = int(input())
A = tuple(map(int, input().split()))
A = sorted(A, reverse=True)
from collections import deque
q = deque([])
ans = A[0]

for a in A[1:n-1]:
    q.append(a)
    q.append(a)
    ans += q.popleft()
print(ans)


Measured memory_bytes: 31492
# 連結
import sys
from collections import Counter, defaultdict
input = sys.stdin.readline
N, K, L = map(int, input().split())


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n+1) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


A = UnionFind(N)
B = UnionFind(N)


ans = [0 for i in range(N+1)]
for _ in range(K):
    p, q = map(int, input().split())
    A.union(p, q)
for _ in range(L):
    p, q = map(int, input().split())
    B.union(p, q)

members = defaultdict(list)
for i in range(1, N+1):
    K = A.find(i)
    members[A.find(i)].append(i)

roots = A.roots()

for parent in roots:
    if parent == 0:
        continue

    group = members[parent]
    # ここでN**2のループをしている危険性があるので予め連想配列で処理する
    B_parent = [B.find(child) for child in group]
    C = dict(Counter(B_parent))
    for child in group:
        ans[child] = C[B.find(child)]
print(*ans[1:])

Measured memory_bytes: 120136
#include <iostream>
#include <stdlib.h>
using namespace std;

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
	int n;
	int si[114];
	int sum = 0;
	bool f = 0;

	cin >> n;

	for(int i = 0; i < n;++i){
		cin >> si[i];
		sum += si[i];
	}

	 qsort(si, n, sizeof(int), compare_int);

	 for(int i = 0;i < n;++i){
	 	if(sum % 10 != 0){
	 		cout << sum <<endl;
	 		f = 1;
	 		break;
	 	}

	 	if((sum - si[i]) % 10 == 0)
	 		continue;
	 	else{
	 		cout << sum - si[i] <<endl;
	 		f = 1;
	 		break; 
	 	}	 	

	}
	if(f == 0)
		cout << "0" <<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

	int n, i;
	int p;
	double sum;
	int ave;

	while (scanf("%d", &n) != EOF)
	{
		if (n != 0)
		{
			sum = 0;
			for (i = 0; i < n; i++)
			{
				scanf("%d", &p);
				sum += p;
			}

			ave = sum / n;

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

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  string s = is();
  string t = is();
  ll len = s.size();
  
  ll ans = 0;
  rep(i, len){
    if (s[i]!=t[i]) ans++;
  }

  cout << ans << endl;


  
}

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

def normal_form(x):
    if x == 1:
        return ['a']
    temp = normal_form(x-1)
    res = []
    for s in temp:
        for k in range(ord(max(s))-97+2):
            res.append(s+chr(k+97))
    return res

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


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    string s;
    cin >> n >> s;
    vector<set<ll>> vs(26);
    for(i = 0;i < n;++i){
        char tmp = s.at(i);
        vs.at(tmp - 'a').insert(i);
    }
    vector<char> ss(n);
    for(i = 0;i < n;++i){
        ss.at(i) = s.at(i);
    }
    ll q;
    cin >> q;
    for(i = 0;i < q;++i){
        ll com;
        cin >> com;
        if(com == 1){
            ll ind;
            char c;
            cin >> ind >> c;
            --ind;
            char tmp = ss.at(ind);
            ss.at(ind) = c;
            vs.at(tmp - 'a').erase(ind);
            vs.at(c - 'a').insert(ind);
        }else{
            ll l,r;
            cin >> l >> r;
            ll ans = 0;
            rep(j,26){
                auto it1 = vs.at(j).lower_bound(l-1);
                auto it2 = vs.at(j).lower_bound(r);
                if(it1 != it2) ++ans;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

int n, a[100010], b[100010], ans = 0;
long long need = 0;
priority_queue<int> q;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++)
    {
        if (a[i] < b[i])
        {
            ans++;
            need += b[i] - a[i];
        }
        else if (a[i] > b[i])
            q.push(a[i] - b[i]);
    }
    while (need > 0 && !q.empty())
    {
        ans++;
        need -= q.top();
        q.pop();
    }
    if (need > 0) puts("-1");
    else printf("%d\n", ans);
}

Measured memory_bytes: 1408
/*
luogu AT5759
*/
#include <bits/stdc++.h>
using namespace std;

int n;
int s[2],c[200005],num[200005],x1=1,x2=2,x3=3;
int ee,h[200005],nex[200005<<1],to[200005<<1];

void addedge(int x,int y)
{
	nex[++ee] = h[x];
	to[ee] = y;
	h[x] = ee;
}

void dfs(int x,int pre)
{
	c[x] = c[pre]^1;
	s[c[x]]++;
	for(int i=h[x];i;i=nex[i])
		if(to[i]!=pre)
			dfs(to[i],x);
}

int main()
{
	cin>>n;
	for(int i=1,x,y;i<n&&cin>>x>>y;i++)
		addedge(x,y), addedge(y,x);
	dfs(1,0);
	if(s[0]>n/3 && s[1]>n/3)
	{
		for(int i=1;i<=n;i++)
			if(c[i]==1)
			{
				if(x1<=n)
					num[i] = x1, x1 += 3;
				else
					num[i] = x3, x3 += 3;
			}
			else
			{
				if(x2<=n)
					num[i] = x2, x2 += 3;
				else
					num[i] = x3, x3 += 3;
			}
	}
	else if(s[0]<=n/3)
	{
		for(int i=1;i<=n;i++)
			if(c[i]==1)
			{
				if(x1<=n)
					num[i] = x1, x1 += 3;
				else if(x2<=n)
					num[i] = x2, x2 += 3;
				else if(x3<=n)
					num[i] = x3, x3 += 3;
			}
			else
				num[i] = x3, x3 += 3;
	}
	else if(s[1]<=n/3)
	{
		for(int i=1;i<=n;i++)
			if(c[i]==0)
			{
				if(x1<=n)
					num[i] = x1, x1 += 3;
				else if(x2<=n)
					num[i] = x2, x2 += 3;
				else if(x3<=n)
					num[i] = x3, x3 += 3;
			}
			else
				num[i] = x3, x3 += 3;
	}
	for(int i=1;i<=n;cout<<num[i++]<<' ');cout<<endl;
	
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long pow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = pow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return pow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (int i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (int i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    long long m;
    cin >> m;
    long long d = 0, s = 0;
    for (int i = 0; i < m; i++)
    {
        long long x, y;
        cin >> x >> y;
        d += y;
        s += x * y;
    }
    cout << (d - 1) + (s - 1) / 9 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll odd = 0;
  for(int i = 0;i < n;i++){
    ll in;
    cin >> in;
    if(in % 2 == 1)odd++;
  }
  if(odd % 2 == 1)cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NOTF -1
#define FREE 1
 
int A[N][N];
int x,row[N],col[N],dpos[2*N-1],dneg[2*N-1];
 
void printboard(){
  int i,j;
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]){
    if(row[i]!=j) return;
      }
    }
  }
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if (row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void putQueen(int i){
  int j;
  if(i==N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOTF || dpos[i+j]==NOTF || dneg[i-j+N-1] == NOTF) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOTF;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}
 
int main(){
   
  int i,j,t,w;
   
  scanf("%d",&x);
 
  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=FREE;
 
  for(i=0;i<N;i++) col[i]=row[i]=FREE;
   
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]==false;
    }
  }
 
  for(i=0;i<x;i++){
    scanf("%d%d",&t,&w);
      A[t][w]=true;
  }
  putQueen(0);
   
  return 0;

}



Measured memory_bytes: 2108
#include<iostream>
#include<cmath>
#include<map>

using namespace std;

map<string ,int >mp;

int main(){
    string a[105];
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    cin>>m;
    string str;
    for(int i=0;i<m;i++){
        cin>>str;
        mp[str]--;
    }
    int mx=0;
    for(int i=0;i<n;i++){
        mx=max(mx,mp[a[i]]);
    }
    cout<<mx;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>

using ll = long long;

using namespace std;
int main()
{/*三日目*/
	string s;cin >> s;
	int n = s.length();
	bool kaibun=true;
	for (int i = 0;i < n / 2;i++) {
		if (s[i] != s[n - i-1]) {
			kaibun = false;
			break;
		}
	}
	if (kaibun) {
		for (int i = 0;i<(n - 1) / 4;i++) {
			if (s[i] != s[((n - 1) / 2)-1 - i]) {
				kaibun = false;
				break;
			}if (s[((n + 3) / 2) + i-1] != s[n - i-1]) {
				kaibun = false;
				break;

			}
		}
	}if (kaibun)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	int n, k;
	cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    combination c(n+5);
    mint ans = 0;
    rep(ri,2) {
        rep(i,n) {
            mint now = c(i,k-1);
            if (ri == 1) now = -now;
            ans += now * a[i];
        }
        reverse(all(a));
    }
	cout << ans.x << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >>m;
    if (n<=5) {
        cout << 0 << endl;
    }
    else if(6<=n&&n<=12) {
        cout << m/2 << endl;
    }
    else {
        cout << m << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    string sx = ">" + s;
    sx += "<";
    int sxlen = sx.length();
    int slen = sxlen-2;

    vector<long long> ans(sxlen-1, 0);
    vector<int> zp;
    for(int i = 0; i < sxlen-1; ++i) {
        if(sx.at(i) == '>' && sx.at(i+1) == '<') {
            zp.push_back(i);
        }
    }

    int zplen = zp.size();

    for(int i = 0; i < zplen; ++i) {
        // cout << zp.at(i) << endl;
        long long left = 1;
        for(int j = zp.at(i); ; --j) {
            // cout << "j " << j << endl;
            if(sx.at(j) == '>' && j != 0) {
                ans.at(j-1) = max(ans.at(j-1), left);
                left++;
            }else {
                break;
            }
        }

        long long right = 1;
        for(int j = zp.at(i)+1; ; ++j) {
            // cout << "j " << j << endl;
            if(sx.at(j) == '<' && j != sxlen-1) {
                ans.at(j) = max(ans.at(j), right);
                right++;
            }else {
                break;
            }
        }
    }

    long long sum = 0;

    for(int i = 0; i < sxlen-1; ++i) {
        sum += ans.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 5892
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, _, W := sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	dp := make([][2]int, N+1)
	for i := N - 1; i >= 1; i-- {
		for j := 0; j < 2; j++ {
			if j == 0 {
				dp[i][j] = INF
			} else {
				dp[i][j] = 0
			}
			for k := i + 1; k <= N; k++ {
				if k == N {
					if j == 0 {
						dp[i][j] = min(dp[i][j], abs(A[i-1]-A[N-1]))
					} else {
						dp[i][j] = max(dp[i][j], abs(A[i-1]-A[N-1]))
					}
					continue
				}
				if j == 0 {
					dp[i][j] = min(dp[i][j], dp[k][1])
				} else {
					dp[i][j] = max(dp[i][j], dp[k][0])
				}
			}
		}
	}
	mx := abs(A[N-1] - W)
	for i := 1; i < N; i++ {
		mx = max(mx, dp[i][0])
	}

	fmt.Fprintln(wtr, mx)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n;
vector<LP> jobs;

void solve(){
    cin >> n;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        jobs.push_back(LP(b,a));
    }
    sort(jobs.begin(),jobs.end());
    ll t=0;
    rep(i,n){
        ll b=jobs[i].first,a=jobs[i].second;
        //cout << a << " " << b << endl;
        if (t+a>b) {
            cout << "No" << endl;
            return;
        }
        t+=a;
    }
    cout << "Yes" << endl;


}

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

Measured memory_bytes: 6512
import std.stdio, std.string, std.conv;

void main()
{
    while(true)
    {
        int n=readln.chomp.to!int;
        if(!n)break;

        int num;
        for(int i=1; i<n; ++i)
        {
            int sum;
            for(int j=i; j<n; ++j)
            {
                sum+=j;
                if(sum == n) ++num;
                else if(sum > n) break;
            }
        }
        num.writeln;
    }
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const int mod = 1e9 + 7;
void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}
void sub_self (int & a, int b) {
	a -= b;
	if (a < 0) a += mod;
}

int main() {
	int n, k; scanf ("%d%d", &n, &k);
	vector < int > a (n);
	for (int & x : a) scanf ("%d", &x);
	vector < int > dp (k + 1);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		vector < int > dp_new (k + 1);
		vector < int > P (k + 2);
		for (int j = 1; j <= k + 1; j++) {
			P[j] = P[j - 1];
			add_self (P[j], dp[j - 1]);
		}
		for (int total = 0; total <= k; total++) {
			int R = min (a[i], total);
			// j = total - take => take = total - j
			// j = total -> total - j <= R => j >= total - R
			// total++ => j--;
			dp_new[total] = P[total + 1];
			sub_self (dp_new[total], P[total - R]);
			//for (int j = total - R; j <= total; j++) {
				//add_self (dp_new[total], dp[j]);
			//}
		}
		dp = dp_new;
	}
	cout << dp[k] << endl;
	return 0;
}



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

    int main(){
        char sa;
    cin>>sa;
    if(sa>='A'&&sa<='Z')
    {
        cout<<"A"<<endl;
    }
    else if(sa>='a'&&sa<='z')
    {
        cout<<"a"<<endl;
    }
    }


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
using namespace std;


int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int res = 2000000000;
    for(int i = 0; i < N - K + 1; i++)
    {
        res = min(res,h[i+K - 1] - h[i]);
    }
   cout << res << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
      var StrIn = Console.ReadLine();
      var strLength = StrIn.Length;
      int LengthA = -1;
      int LengthZ = -1;
      for(int i = 0; i < strLength; i++)
      {
        if (StrIn[i] == 'A')
        {
          LengthA = i + 1;
          break;
        }
      }
      for (int i = strLength-1; 0 <= i; i--)
      {
        if (StrIn[i] == 'Z')
        {
          LengthZ = strLength-( i + 1);
          break;
        }
      }

      var ans = strLength - (LengthA + LengthZ)+1;
      Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11616
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

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

    ll N ;
    cin >> N ;
    vector<ll> A;

    rep(i, N){
      ll inp;
      cin >> inp;
      A.pb(inp);
    }

    ll ans = 0;
    rep(i, A.size())rep(j, A.size()){
      ans = max(ans, abs(A[i]-A[j]));
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>  
using namespace std;  
int fa[100500];  
int dis[100500];  
int find(int x) {  
    if(fa[x]==x) return x;  
    int f1=fa[x];  
    int f2=find(fa[x]);  
    fa[x]=f2;  
    dis[x]=dis[x]+dis[f1];  
    return f2;  
}
 
int find_dis(int x) {  
    if(fa[x]==x) return 0;  
    return find_dis(fa[x])+dis[x];
}
   
int main() {  
    int n,m,a,b,d;  
    cin>>n>>m;  
    for(int i=0;i<=n;i++) {  
        fa[i]=i;  
        dis[i]=0;  
    }  
    while(m>0) {
        m--;
        cin>>a>>b>>d;  
        int f1=find(a);  
        int f2=find(b);  
        if(f1==f2) {  
            if(dis[a]+d!=dis[b]) {  
                cout<<"No";  
                return 0;
            }  
        } 
        else{  
            fa[f2]=f1; 
            dis[f2]=find_dis(a)-find_dis(b)+d;  
        }  
    }  
    cout<<"Yes";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
/*
	ll N, M, K, A, B, C;
	cin >> N >> M;

	string S, T;


	ll plus = N + M;
	ll absNM = abs(N - M);
	
	ll pro = N * M;
	ll divNM = N / M;
	ll divMN = M / N;
	ll modNM = N % M;
	ll modMN = M % N;


	ll ans = 0;
*/

	char C;
	cin >> C;


	cout << (char)((int)C + 1);




}




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

int n, p[25], x;

int main() {
    cin >> n;
    for(int i=0; i<n; i++) cin >> p[i];

    for(int i=1; i<n-1; i++){
        if((p[i] > p[i+1] && p[i] < p[i-1]) || (p[i] < p[i+1] && p[i] > p[i-1])){
            x++;
        }
    }

    cout << x;
}

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

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s;
            string[] word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a + b < a + c && a + b < b + c)
                s = a + b;

            else if (a + c < a + b && a + c < b + c)
                s = a + c;

            else
                s = b + c;

            Console.WriteLine(s);

            //Console.Readkey();

        }
    }
}

Measured memory_bytes: 27520