akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

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

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

struct RMQ {
  long dat[kMax5][20];
  long dat2[kMax5][20];

  RMQ() {}
  void init(const vector<long> & a) {
    auto n = a.size();
    rep(i, 0, n - 2) {
      dat[i][1] = max(a[i], a[i + 1]);
      dat2[i][1] = min(a[i], a[i + 1]);
      // cout << i << " " << 1 << " " << dat[i][1] << " " << dat2[i][1] << endl;
    }
    for (auto j = 2; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = max(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto min_dat = min(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto max_dat2 = max(dat2[i][j - 1], dat2[i + (1 << (j - 1))][j - 1]);
        dat2[i][j] = max(min_dat, max_dat2);
        // cout << i << " " << j << " " << dat[i][j] << " " << dat2[i][j] << endl;
      }
    }
  }

  long query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    auto dat_l = dat[l][k];
    auto dat_r = dat[r - (1 << k) + 1][k];
    auto dat2_l = dat2[l][k];
    auto dat2_r = dat2[r - (1 << k) + 1][k];
    // auto min_dat = min(dat[l][k], dat[r - (1 << k) + 1][k]);
    // auto max_dat2 = max(dat2[l][k], dat2[r - (1 << k) + 1][k]);
    if (dat_l == dat_r && dat2_l == dat2_r) {
      return dat2_l;
    } else if (dat_l == dat_r) {
      return max(dat2_l, dat2_r);
    } else if (dat2_l == dat2_r){
      return min(dat_l, dat_r);
    } else if (dat_l == dat2_r){
      return dat_l;
    } else if (dat2_l == dat_r){
      return dat2_l;
    } else {
      return max(min(dat_l, dat_r), max(dat2_l, dat_r));
    }
  }
};

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

  ll ans = 0;
  string s;
  int n, m;
  cin >> n >> m;
  priority_queue<long> pq;

  rep(i, 1, n) {
    long a0;
    cin >> a0;
    pq.push(a0);
  }
  rep(i, 1, m) {
    auto tmp = pq.top();
    pq.pop();
    pq.push(tmp / 2);
  }
  while (!pq.empty()) {
    auto tmp = pq.top();
    ans += tmp;
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(500*500)

h, w = map(int, input().split())
grid = []
seen = [[False for y in range(w)] for x in range(h)]

for x in range(h):
    grid.append(input())



blackSeen = 0
whiteSeen = 0
def countFrom(a, b, lastColor):
    global blackSeen, whiteSeen
    if not (0 <= a < h and 0 <= b < w):
        return
    if seen[a][b]:
        return
    #print(a, b)
    

    thisColor = (1 if grid[a][b] == "." else -1)

    if grid[a][b] == "#" and lastColor != -1:
        blackSeen += 1
    elif grid[a][b] == "." and lastColor != 1:
        whiteSeen += 1
    else:
        return
    seen[a][b] = True

    countFrom(a+1, b, thisColor)
    countFrom(a-1, b, thisColor)
    countFrom(a, b+1, thisColor)
    countFrom(a, b-1, thisColor)

tot = 0
for x in range(h):
    for y in range(w):
        blackSeen = 0
        whiteSeen = 0
        countFrom(x, y, 0)
        #print(x, y, blackSeen, whiteSeen)
        tot += blackSeen * whiteSeen

print(tot)

    

Measured memory_bytes: 138736
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int f = scan.nextInt();
		int b = scan.nextInt();
		if(b > m + f) {
			System.out.println("NA");
		} else {
			System.out.println(Math.max(b - m, 0));
		}
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}



Measured memory_bytes: 26412
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n,h,w;

int main() {
    cin >> n >> h >> w;
    put((n-h+1)*(n-w+1));
    return 0;
}




Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(x for x in input()) for _ in range(h)]
b = []
c = []
for i in range(h):
  if '#' in a[i]:
    continue
  else:
    b.append(i)

for j in range(w):
  for k in range(h):
    if '#' == a[k][j]:
      break
    elif k == h-1:
      c.append(j)

for m in range(h):
  count = 0
  if m in b:
    continue
  for n in range(w):
    if n in c:
      continue
    else:
      count +=1
      print(a[m][n], end='')
    if count == (w-len(c)):
      print()

Measured memory_bytes: 4596
N = int(input())

if N == 3:
    print("2 5 63")
    exit()

N -= 4
ls = [2, 3, 4, 9]
tmp = 1
while N > 1 and tmp < 5000:
    ls.append(6*tmp+2)
    ls.append(6*tmp+4)
    N -= 2
    tmp += 1
tmp = 2
while N > 1 and tmp < 5000:
    ls.append(6*tmp+3)
    ls.append(6*tmp+9)
    tmp += 2
    N -= 2
tmp = 1
while N > 0:
    ls.append(6*tmp)
    tmp += 1
    N -= 1

print(*ls)

Measured memory_bytes: 4584
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

while(True):
    dice = [1, 2, 3, 4, 5, 6]
    score = 1
    n = int(input())
    if n == 0:
        break

    for i in range(n):
        action = input().rstrip()
        if action == "North":
            tmp = dice[0]
            dice[0] = dice[1]
            dice[1] = dice[5]
            dice[5] = dice[4]
            dice[4] = tmp
        elif action == "East":
            tmp = dice[0]
            dice[0] = dice[3]
            dice[3] = dice[5]
            dice[5] = dice[2]
            dice[2] = tmp
        elif action == "West":
            tmp = dice[0]
            dice[0] = dice[2]
            dice[2] = dice[5]
            dice[5] = dice[3]
            dice[3] = tmp
        elif action == "South":
            tmp = dice[0]
            dice[0] = dice[4]
            dice[4] = dice[5]
            dice[5] = dice[1]
            dice[1] = tmp
        elif action == "Right":
            tmp = dice[1]
            dice[1] = dice[2]
            dice[2] = dice[4]
            dice[4] = dice[3]
            dice[3] = tmp
        elif action == "Left":
            tmp = dice[1]
            dice[1] = dice[3]
            dice[3] = dice[4]
            dice[4] = dice[2]
            dice[2] = tmp
        score += dice[0]
    print(score)

Measured memory_bytes: 15088
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double th = M_PI * 60.0 / 180.0;	// 夹角 
const double cs = cos(th), sn = sin(th);// 弧度 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C

typedef struct {double x, y;} P; // point

void Koch(int n, P a, P b)
{
	if (n)
	{
		P s = {0}, t = {0}, u = {0};
		
		// 计算的通式要写对。 
		s.x = (2.0*a.x + 1.0*b.x) / 3.0; 
		s.y = (2.0*a.y + 1.0*b.y) / 3.0;
		t.x = (1.0*a.x + 2.0*b.x) / 3.0;
		t.y = (1.0*a.y + 2.0*b.y) / 3.0;
		u.x = (t.x - s.x)*cs - (t.y - s.y)*sn + s.x;
		u.y = (t.x - s.x)*sn + (t.y - s.y)*cs + s.y;
		
		Koch(n-1, a, s);
		printf("%.8f %.8f\n", s.x, s.y);
		Koch(n-1, s, u);
		printf("%.8f %.8f\n", u.x, u.y);
		Koch(n-1, u, t);
		printf("%.8f %.8f\n", t.x, t.y);
		Koch(n-1, t, b);		
	}
}

int main()
{
	int n; cin >> n;
	P a = {0.0, 0.0}, b = {100.0, 0.0};
	
	printf("%.8f %.8f\n", a.x, a.y);
	Koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0 ;
}


Measured memory_bytes: 3232
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll dp[100010][2];
ll sum[110];
void solve()
{
	IN(n)IN(k);
	vl v;
	FOR(i, 0, n)
	{
		IN(in);
		v.pb(in);
	}
	sum[0] = v[0];
	FOR(i, 1, n)
		sum[i] = sum[i - 1] + v[i];
	dp[0][0] = 1;
	dp[0][1] = 1;
	FOR(i, 0, n)
	{
		FOR(j, 1, k + 1)
		{
			if (sum[i] >= j)
				dp[j][1] = (dp[j - 1][1] + dp[j][0]-(j-v[i]>0?dp[j-v[i]-1][0]:0)+MOD)%MOD;
		}
		FOR(j, 1, k + 1)
		{
			//cout << dp[j][1];
			dp[j][0] = dp[j][1];
		}
		//cout << endl;
	}
	cout << dp[k][0]%MOD;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 5148
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int m = sc.nextInt();
    int d = sc.nextInt();
    boolean flag = false;
    
    if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
      if(d==31){
        flag=true;
      }
    }
    
    if(m==4 || m==6 || m==9 || m==11){
      if(d==30){
        flag=true;
      }
    }
    
    if(m==2 && d==28){
      flag=true;
    }
    
    if(flag){
      System.out.println(1);
    }else{
      System.out.println(0);
    }
    
  }
}


Measured memory_bytes: 22996
# include<iostream>
# include<algorithm>
# include<cctype>
# include<cstdio>
# include<cstring>
# include<cmath>
# include<limits.h>
using namespace std;
int main()
{
      int n, a;
      cin >> n;
      int flag = 1;
      for (int i=0; i<n; i++)
      {
            cin >> a;
            if (a%2==0)
            {
                  if (a%3!=0&&a%5!=0) flag = 0;
            }
      }
      if (flag) cout << "APPROVED" << endl;
      else cout << "DENIED" << endl;
      return 0;
}


Measured memory_bytes: 256
N = input()
a = map(int, raw_input().split())

all = sum(a)

mini = 10000000000

x = 0
y = all

for i in range(0,N-1):
    x += a[i]
    y -= a[i]
    ret = abs(x-y)

    if(ret < mini): mini=ret

print mini


Measured memory_bytes: 18440
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main() {
	lint n, m; cin >> n >> m;
	set<pair<lint, lint>> s;
	for (int i = 0; i < m; i++) {
		lint a, b; cin >> a >> b;
		s.insert({ a,b });
	}
	bool h = false;
	for (lint i = 1; i < n; i++) {
		if (s.count({ 1,i })) {
			if (s.count({ i,n })) {
				h = true;
				break;
			}
		}
	}
	if (h)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 16116
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define SORT(x) (sort(x.begin(),x.end()))
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) (reverse(x.begin(),x.end()))

struct RMQRUQ {
	int n;
	vector<int> dat, lazy;
 
	RMQRUQ(){}
	RMQRUQ(int n_) {
		n = 1; while(n < n_) n *= 2;
		dat.assign(n*2, INT_MAX);
		lazy.assign(n*2, INT_MAX);
	}
 
	void eval(int len, int k) {
		if(lazy[k] == INT_MAX) return;
		if(k*2+1 < n*2-1) {
			lazy[2*k+1] = lazy[k];
			lazy[2*k+2] = lazy[k];
		}
		dat[k] = lazy[k];
		lazy[k] = INT_MAX;
	}
 
  // [a, b)
	int update(int a, int b, int x, int k, int l, int r) {
		eval(r-l, k);
		if(b <= l || r <= a) return dat[k];
		if(a <= l && r <= b) {
			lazy[k] = x;
			return lazy[k];
		}
		return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
	}
	int update(int a, int b, int x) { return update(a, b, x, 0, 0, n); }
	// [a, b)
	int query(int a, int b, int k, int l, int r) {
		eval(r-l, k);
		if(b <= l || r <= a) return INT_MAX;
		if(a <= l && r <= b) return dat[k];
		int vl = query(a, b, 2*k+1, l, (l+r)/2);
		int vr = query(a, b, 2*k+2, (l+r)/2, r);
		return min(vl, vr);
	}
	int query(int a, int b) { return query(a, b, 0, 0, n); }
};

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

	int N,Q;
	cin >> N >> Q;
	RMQRUQ tr(Q+8);
	tr.update(0,Q+7,-1);
	vector< pair<int, pair<int,int> > > xst(N);
	FOR(i,0,N){
		int s,t,x;
		cin >> s >> t >> x;
		xst[i] = {x,{s,t}};
	}
	vector<int> D(Q);
	FOR(i,0,Q){
		cin >> D[i];
	}
	D.push_back(INT_MAX);
	SORT(xst);
	REV(xst);
	FOR(i,0,N){
		int s_x = xst[i].second.first - xst[i].first;
		int t_x = xst[i].second.second - xst[i].first;
		int a = POSL(D,s_x);
		int b = POSU(D,t_x-1);
		tr.update(a,b,xst[i].first);
	}
	FOR(i,0,Q){
		cout << tr.query(i,i+1) << endl;
	}
}


Measured memory_bytes: 9200
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    V< V<int> > a(h, V<int>(w)), b(h, V<int>(w));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> b[i][j];
    const int MAXV = 160 * 80 + 1;
    V< V< V<bool> > > dp(h, V< V<bool> >(w, V<bool>(MAXV, false)));
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k <= MAXV; k++) {
                if (i > 0) {
                    if (k + abs(a[i][j] - b[i][j]) <= MAXV) {
                        dp[i][j][k + abs(a[i][j] - b[i][j])] = dp[i][j][k + abs(a[i][j] - b[i][j])] | dp[i - 1][j][k];
                    }
                    dp[i][j][abs(k - abs(a[i][j] - b[i][j]))] = dp[i][j][abs(k - abs(a[i][j] - b[i][j]))] | dp[i - 1][j][k];
                }

                if (j > 0) {
                    if (k + abs(a[i][j] - b[i][j]) <= MAXV) {
                        dp[i][j][k + abs(a[i][j] - b[i][j])] = dp[i][j][k + abs(a[i][j] - b[i][j])] | dp[i][j - 1][k];
                    }
                    dp[i][j][abs(k - abs(a[i][j] - b[i][j]))] = dp[i][j][abs(k - abs(a[i][j] - b[i][j]))] | dp[i][j - 1][k];
                }
            }
        }
    }

    for (int k = 0; k <= MAXV; k++) {
        if (dp[h - 1][w - 1][k]) {
            cout << k << '\n';
            break;
        }
    }
    return 0;
}


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

int main()
{
	char a[105];
		cin>>a;
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++)
		if(a[i]=='1') continue;
		else{
			cout<<a[i]<<endl;
			break;
		}
	if(i==n) cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 384
require 'matrix'

h, w, k = gets.split.map(&:to_i)
rows = Array.new(h){gets.chomp.chars.map{|c| (c == '#') ? 1 : 0}}
z = Matrix.zero(h, w)
cnt = 0
[0, 1].repeated_permutation(h).each do |x|
  m = Matrix.rows(rows.dup.shift(h))
  x.each_with_index do |y, i|
    next if y == 0
    w.times do |j|
      m[i, j] = 0
    end
  end
  [0, 1].repeated_permutation(w) do |u|
    mc = m.dup
    u.each_with_index do |v, j|
      next if v == 0
      h.times do |i|
        mc[i, j] = 0
      end
    end
    cnt += 1 if mc.sum == k
  end
end
puts cnt

Measured memory_bytes: 15124
s = gets.chomp.reverse

f = true
i = 0
while i<s.size
  if s[i..i+4] == 'erase'.reverse then
    i+=5
  elsif s[i..i+4] =='dream'.reverse then
    i+=5
  elsif s[i..i+6] == 'dreamer'.reverse then
    i+=7
  elsif s[i..i+5] == 'eraser'.reverse then
    i+=6
  else
    f = false
    break
  end
end

puts f ? 'YES':'NO'

Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		
		String s = input.readLine();
		String p = input.readLine();
		
		s = s.concat(s);
		int num = s.indexOf(p);
		
		if(num != -1) System.out.println("Yes");
		else          System.out.println("No");
	
		
	}

}

Measured memory_bytes: 17052
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
#include <cmath>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

int main(void)
{
	int n;
	cin >> n;
	vector<ll> as(n);
	vector<ll> bs(n);
	vector<pair<ll,ll>> cs(n);
	rep(i, n) {
		cin >> as[i] >> bs[i];
		cs[i] = make_pair(bs[i], i);
	}
	sort(cs.begin(), cs.end());
	bool ok = true;
	ll current = 0;
	for(auto p : cs){
		current += as[p.second];
		if (current > p.first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 6528
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {


	static Map<Integer, Integer> map = new HashMap<>();
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		for(int i = 0; i < length; i++) {
			int t = scanner.nextInt();
			increment(t - 1);
			increment(t);
			increment(t + 1);
		}
		int max = map.entrySet().stream()
			.max(Comparator.comparingInt(m -> m.getValue()))
			.get().getValue();

		System.out.println(max);
	}
	
	public static void increment(int key) {
		map.put(key, map.getOrDefault(key, 0) + 1);
	}
}


Measured memory_bytes: 66920
#include<stdio.h>
#include<string.h>
 
int main(void){
	char s[200010]; scanf("%s", s);
	char t[200010]; scanf("%s", t);
	int count = 0;
 
	for(int i=0;i<strlen(s);i++){
		if(s[i] != t[i])count++;
	}
 
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 2100
#include<iostream>
#include<cstring>
#define DIM 1000005
using namespace std;
int n, i, ok, x;
int fact[DIM];
char v[DIM];
int impar(){
    int i, nr = 0;
    for(i = 1; i <= n; i++){
        if(v[i] == 1 && fact[n - 1] == fact[i - 1] + fact[n - i]){
            nr++;
        }
    }
    return nr % 2;
}
int main(){
    cin>> n;
    cin>> v + 1;
    for(i = 1; i <= n; i++){
        v[i] -= '1';
    }
    for(i = 1; i <= n; i++){
        fact[i] = fact[i - 1];
        x = i;
        while(x % 2 == 0){
            fact[i]++;
            x /= 2;
        }
    }
    if( impar() ){
        cout<< 1;
    }
    else{
        ok = 0;
        for(i = 1; i <= n; i++){
            if(v[i] == 1){
                ok = 1;
            }
        }
        if(ok == 1){
            cout<< 0;
        }
        else{
            for(i = 1; i <= n; i++){
                v[i] /= 2;
            }
            if( impar() ){
                cout<< 2;
            }
            else{
                cout<< 0;
            }
        }
    }
}


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

vector<int> g[100100];
int h[100100];
int num[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		h[y]++;
	}
	stack<int> st;
	for(int i=0;i<n;i++){
		if(h[i]==0){
			st.push(i);
		}
	}
	vector<int> ans;
	while(st.size()){
		int i=st.top(); st.pop();
		ans.push_back(i);
		for(int j:g[i]){
			h[j]--;
			if(h[j]==0){
				st.push(j);
			}
		}
	}
	int cnt=0;
	for(int i:ans){
		cout << i+1 << endl;
		num[cnt]=i;
		cnt++;
	}
	bool ok=true;
	for(int i=0;i<n-1;i++){
		bool fi=false;
		for(int j:g[num[i]]){
			if(j==num[i+1])fi=true;
		}
		if(!fi)ok=false;
	}
	if(ok){
		cout << 0 << endl;
	}
	else{
		cout << 1 << endl;
	}
}


Measured memory_bytes: 6056
#include <stdio.h>
int main() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int x = (a+d-1)/d, y = (c+b-1)/b;
    if (x >= y) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++)
  {
    cout<<s[i];
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N, M;
	cin >> N >> M;
	vector<P> vec(N);
	for(int i = 0; i < N; i++){
		cin >> vec[i].first >> vec[i].second;
	}

	sort(vec.begin(), vec.end());
	
	priority_queue<int> que;
	int res = 0;
	int pos = 0;
	int prev = -1;
	for(int t = 0; t <= M; t++){
		for(; pos < N and vec[pos].first <= t; pos++){
			if(pos == prev) continue;
			// debug(t);debug(pos);
			prev = pos;
			que.push(vec[pos].second);
		}
		if(que.empty()) continue;
		res += que.top();
		que.pop();
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
#define endl cout << "\n";
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
void i_love_Accepted()
{
    ll x,y;
    cin>>x>>y;
    if(y<2*x || y%2 || y>4*x)
    {
        cout<<"No";
        return;
    }
    cout<<"Yes";
}
int main()
{
    fast;
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        i_love_Accepted();
        endl;
    }
}


Measured memory_bytes: 3652
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
--import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO



getvuil :: IO (VU.Vector Int)
getvuil = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readi :: BSC8.ByteString -> Int
readi = fst . fromJust . BSC8.readInt
readil :: BSC8.ByteString -> [Int]
readil = map readi . BSC8.words
geti :: IO Int
geti = readi <$> BSC8.getLine
getil :: IO [Int]
getil = readil <$> BSC8.getLine

getNis :: Int -> IO [(Int, BSC8.ByteString)]
getNis 0 = return []
getisl n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getisl (n - 1))
    return ((readi aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show a

main :: IO ()
main = do
    [aA, aB] <- getil
    let sumTap = 1 : aA : (map ((+ aA) . (* (aA - 1))) [1 ..])
    let ret    = scan aB 0 sumTap
    print ret

  where
    scan x y sumTap = if sumTap !! y >= x then y else scan x (y + 1) sumTap



Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

typedef deque<int> dq;

ll n, up = 1;

pair<dq, dq> Build(ll n){
  pair<dq, dq> res;

  if(n == 1){
    res.fi.pb(up);
    res.se.pb(up++);
    return res;
  }

  if(n == 2){
    res.fi.pb(up), res.fi.pb(up + 1);
    res.se.pb(up + 1), res.se.pb(up);
    up += 2;
    return res;
  }

  if((n & 1) == 0){
    res = Build(n - 1);
    res.fi.pb(up);
    res.se.push_front(up++);
    return res;
  }

  ll m = (n - 1) / 2;
  res = Build(m);
  res.fi.push_front(up);
  res.se.push_front(up++);
  return res;
}

int main(){
  cin >> n;
  auto _res = Build(n);

  vi res;
  for(int e : _res.fi) res.pb(e);
  for(int e : _res.se) res.pb(e);

  printf("%d\n", sz(res));
  for(int i = 0;i < sz(res);++i)
    printf("%d%c", res[i], i + 1 == sz(res) ? '\n' : ' ');

  return 0;
}


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

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

    std::vector<std::size_t> Anum(N, 0);
    std::vector<std::size_t> As(N);

    for(auto& a : As)
    {
        std::cin >> a;
        a -= 1;
        Anum.at(a) += 1;
    }

    std::size_t total = 0;
    std::vector<std::size_t> Apat(N, 0);
    for(std::size_t i=0; i<Anum.size(); ++i)
    {
        Apat.at(i) = (Anum.at(i) * (Anum.at(i) - 1)) / 2;
        total += Apat.at(i);
    }

// 3C2 -> 2C2
//  3  -2  1
//
// 2C2 -> 1C2
//  1  -1  0
//
//    N * (N-1) / 2 -> (N-1) * (N-2) / 2
//    (N-1) * (N-2+2) / 2
//    (N-1) * (N-2) / 2 + (N-1) * 2 / 2
//    (N-1) * (N-2) / 2 + (N-1)

    for(std::size_t i=0; i<Anum.size(); ++i)
    {
        const auto A = As.at(i);
        std::cout << total - (Anum.at(A) - 1) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 7296
import sys
import decimal

lines = sys.stdin.readlines()
size = int(lines[0])
data = lines[1:len(lines)]
for line in data:
    line = line.split(" ")
    inp = []
    for i in line:
        inp.append(decimal.Decimal(i))
    x = []
    x.append(inp[0])
    x.append(inp[2])
    x.append(inp[4])
    x.append(inp[6])
    y = []
    y.append(inp[1])
    y.append(inp[3])
    y.append(inp[5])
    y.append(inp[7])
    if x[1]==x[0] and x[3]==x[2]:
        print ("YES")
    elif x[1]==x[0] or x[3]==x[2]:
        print ("NO")
    else:
        tilt1 = (y[1]-y[0])/(x[1]-x[0])
        tilt2 = (y[3]-y[2])/(x[3]-x[2])
        if tilt1==tilt2:
            print ("YES")
        else:
            print ("NO")

Measured memory_bytes: 10132
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans = 0;
	vector<string> s(3);
	cin >> n >> s[0] >> s[1] >> s[2];
	for (i = 0; i < n; i++) {
		set<char> ct;
		ct.insert(s[0][i]);
		ct.insert(s[1][i]);
		ct.insert(s[2][i]);

		if (ct.size() == 3) ans += 2;
		else if (ct.size() == 2) ans += 1;
	}
	cout << ans << "\n";

	return 0;
}



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


int main(){
    string X;
    string Y;
    int x,y;
    cin>>X>>Y;
    x=X[0]-'A';
    y=Y[0]-'A';
    if(x>y){
    cout<<">"<<endl;
    }
    else if(x<y){
    cout<<"<"<<endl;
    }else{
    cout<<"="<<endl;}
    return 0;
}



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

using namespace std;

const int INF = 1e9 + 7;

struct product
{
    int weight;
    int value;
};

void solve()
{
    int n, w;
    cin >> n >> w;

    vector<product> v(n);
    vector<vector<long long> > dp(w + 1, vector<long long>(n + 1, 0));

    for(int i = 0; i < n; ++i)
        cin >> v[i].weight >> v[i].value;

    for(int i = 0; i < n; ++i)
        for(int j = 0; j <= w; ++j)
        {
            if(j < v[i].weight)
                dp[j][i + 1] = dp[j][i];
            else
                dp[j][i + 1] = max(dp[j][i], dp[j - v[i].weight][i] + v[i].value);
        }


    cout << dp[w][n] << '\n';


}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //srand (time(0));

    solve();
}






Measured memory_bytes: 82304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		for(int i = A;i <= B;i++){
			if(i%K==0){
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");

	}

}

Measured memory_bytes: 35844
# Exchange
""" Tenka1 Programmer Beginner Contest B """

A, B, K = map(int, input().split())
test = False

def cookie():
    """ プレイヤーp, 所持枚数n """
    takahashi = [A]
    aoki = [B]

    for i in range(K):
        if i%2 == 0:   # 高橋君のターン
            takahashi.append(takahashi[i] // 2)
            aoki.append(aoki[i] + takahashi[i] // 2)
        elif i%2 == 1: # 青木君のターン
            takahashi.append(takahashi[i] + aoki[i] // 2)
            aoki.append(aoki[i] // 2)
        if test:
            print('i =', i)
            print('takahashi', takahashi)
            print('aoki     ', aoki)

    return takahashi[K], aoki[K]


def main():
    print(cookie()[0], cookie()[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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 main(){
    int n;cin>>n;
    V<ll> a(n),b(n),c(n);
    cinf(n,a);
    cinf(n,b);
    cinf(n,c);
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans=0;
    for(int i=0;i<n;i++){
        ll j=lb(all(a),b[i])-a.begin();
        ll k=ub(all(c),b[i])-c.begin();
        ans+=j*(n-k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[100005];
int main(){
   int n;
   cin>>n;
   vector<ll> a(n);
   for(int i=0;i<n;i++)cin>>a.at(i);
   fill(dp,dp+n,inf);
   for(int i=n-1;i>=0;i--){
     *upper_bound(dp,dp+n,a.at(i))=a.at(i);
}
cout<<lower_bound(dp,dp+n,inf)-dp<<endl;
}

Measured memory_bytes: 1792
def fill(x,y,count):
    global board
    if count == n**2:
        return 0
    count += 1
    while board[x%n][y%n] != 0:
        x += 1
        y -= 1
    board[x%n][y%n] = count
    fill(x+1,y+1,count)

    
while(1):
    n = int(input())
    if n == 0:
        break
    board = [[0 for i in range(n)] for j in range(n)]
    fill(int(n/2)+1,int(n/2),0)
    board = [["{: >4}".format(i) for i in j] for j in board]
    [print(*board[i],sep="") for i in range(n)]  


Measured memory_bytes: 5764
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);

using namespace std;
int main() {
    ll A,B,H,M;
    cin>>A>>B>>H>>M;
    double S=double(M)/60*2*PI;
    double T=double(60*H+M)/720*2*PI;
    //cout<<"AAA"<<endl;
    double C=cos(T-S);
    double D=sqrt((pow(A,2)+pow(B,2)-2*A*B*C));

    printf("%.10lf\n",D);
    }

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  if(B == 1)cout << 0 << endl;
  else if(A >= B)cout << 1 << endl;
  else {
    if((B - A) % (A - 1) == 0)cout << (B - A) / (A - 1) + 1 << endl;
    else cout << (B - A) / (A - 1) + 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vi ks(n);
		rep(i,n) cin>>ks[i];
		string s; cin>>s;
		
		vi a(s.size());
		rep(i,a.size()) a[i]=islower(s[i])?s[i]-'a':26+s[i]-'A';
		rep(i,a.size()) a[i]=(a[i]-ks[i%ks.size()]+52)%52;
		rep(i,a.size()) s[i]=a[i]<26?'a'+a[i]:'A'+a[i]-26;
		
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct P
{
  int s,e,cost;
  P(int s=0,int e=0,int cost=0):s(s),e(e),cost(cost){}
  bool operator < (const P& p)const
  {
    if(s!=p.s)return s < p.s;
    return e < p.e;
  } 
};

void printVP(vector<P> vec)
{
  cout << "printVP------" << endl;
  rep(i,vec.size())
    cout<< "(" << vec[i].s << "," << vec[i].e << "," << vec[i].cost << ") ";
  cout << endl;
}

void printVVI(VVI G)
{
  cout << "printVVI ------ "<< endl;
  rep(i,G.size())
    {
      rep(j,G[i].size())
	{
	  if(G[i][j] == 0)cout << "    0 ";
	  else cout << string(5-(log10(G[i][j])+1),' ') << G[i][j] << " "; 
	}
      cout << endl;
    }
  cout << endl;
}

int main()
{
  int N;
  while(cin >> N,N)
    {
      int MAX = 367;
      //dp[i][j] := １つめの部屋がi日めで2つ目の部屋がj日の時の最大利益
      VVI dp(MAX,VI(MAX,0));
      vector<P> requests(N);
      rep(i,N)
	cin >> requests[i].s >> requests[i].e >> requests[i].cost;
      sort(requests.begin(),requests.end());
      //printVP(requests);
  
      rep(k,N)
	{
	  VVI DP = dp;
	  REP(i,1,MAX)
	    {
	      REP(j,1,MAX)
		{
		  if(i == j && j == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     max(dp[requests[k].s][j]+requests[k].cost,
					 dp[i][requests[k].s]+requests[k].cost));
		    }
		  else if(j == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     dp[i][requests[k].s]+requests[k].cost);
		    }
		  else if(i == requests[k].e+1)
		    {
		      assert(requests[k].s-1 >= 0);
		      DP[i][j] = max(DP[i][j],
				     dp[requests[k].s][j]+requests[k].cost);
		    }
		  
		    DP[i][j] = max(DP[i][j],
				   max(DP[i-1][j],DP[i][j-1]));
		}
	    }
	  dp = DP;
	  //cout << "k = " << k << endl;
	  //printVVI(dp);
	}
      cout << dp[MAX-1][MAX-1] << endl;
    }
  return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

void executeCode() {
	char c;
	cin >> c;
	if(isupper(c)) {
		cout << "A" << endl;
	}else {
		cout << "a" << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    vector<ll> a(n,0);
    for(ll i = 0; i < k; i++){
        a[i] = s;
    }
    for(ll i = k; i < n; i++){
        if(s == (ll)1e9)
        a[i] = (ll)1e9 - 1;
        else
        a[i] = s + 1;
    }
    for(ll i = 0; i < n; i++){
        cout << a[i] << (i != n - 1 ? " ": "\n");
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 998244353
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int num[3005];
ll dp[3005][3005];
int main () {
  int n, s;
  scanf("%d %d", &n, &s);
  FOR(i, 1, n) {
    scanf("%d", &num[i]);
  }
  SET(dp, 0);
  dp[0][0] = 1;
  FOR(i, 1, n) {
    FOR(j, 0, s) {
      dp[i][j] = dp[i - 1][j] * 2 % mod;
      if (j >= num[i]) {
        dp[i][j] = (dp[i][j] + dp[i - 1][j - num[i]]) % mod;
      }
    }
  }
  printf("%lld\n", dp[n][s]);
  return 0;
}

Measured memory_bytes: 74380
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

constexpr int cm = 1<<17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
	if (ci - cn == cm) {
    fread(cn, 1, cm, stdin); 
    ci = cn;
  }
	return *ci++;
}
inline int readint() {
	int ret = 0;
	if (ci - cn + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      ret = (ret<<3) + (ret<<1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      ret = (ret<<3) + (ret<<1) + ct - '0';
    }
  }
	return ret;
}

int cnt[202020];
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

int main(){
    int N = readint();
    vector<int> t, x, y;
    for (int i = 0; i < N; ++i) {
        int tt = readint(), xx = readint(), yy = readint();
        t.emplace_back(tt); x.emplace_back(xx); y.emplace_back(yy);
    }

    for (int i = 0; i < N; ++i) {
        if (t[i] % 2 == 0){
            if (abs(x[i]) + abs(y[i]) > t[i] || (abs(x[i]) + abs(y[i])) % 2 == 1){
                cout << "No" << '\n';
                return 0;
            }
        }
        else if (t[i] % 2 == 1){
            if (abs(x[i]) + abs(y[i]) > t[i] || (abs(x[i]) + abs(y[i])) % 2 == 0){
                cout << "No" << '\n';
                return 0;
            }
        }
    }

    cout << "Yes" << '\n';

    return 0;
}




Measured memory_bytes: 1772
package main

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

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
		a[i]-- // 0-indexed
	}
	ans := 0
	for i := 0; i < n-1; i++ {
		if a[i] == i {
			a[i], a[i+1] = a[i+1], a[i]
			ans++
		}
	}
	if a[n-1] == n-1 {
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
n, q = gets.chomp.split(' ').map(&:to_i)
process = readlines.map do |line|
  name, time = line.chomp.split(' ')
  { name: name, time: time.to_i }
end

cnt_time = 0

while !process.empty?
  cur_process = process[0]
  if cur_process[:time] > q
    cnt_time += q
    last_process = { name: cur_process[:name], time: cur_process[:time] - q }
    process.shift
    process << last_process
  else
    cnt_time += cur_process[:time]
    process.shift
    puts "#{cur_process[:name]} #{cnt_time}"
  end
end



Measured memory_bytes: 35680
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int A,B;
  cin>>A>>B;
  cout<<((A*B*(A+B))%3 ? "Impossible" : "Possible");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, M;
	int L, R;

	cin >> N >> M;
	int min = 1, max = 100000;
	bool b = true;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		if (L > max) {
			b = false;
			break;
		}
		if (R < min) {
			b = false;
			break;
		}
		if (min <= L && R <= max) {
			min = L;
			max = R;
		} else if (min <= R && R < max) {
			max = R;
		} else if (min < L && L <= max) {
			min = L;
		}
	}
	if (b) {
		cout << max - min + 1 << "\n";
	} else {
		cout << "0\n";
	}
	return 0;
}


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

typedef long long ll;
int N;
ll G[301][301] = {0};
ll A[301][301] = {0};
bool F[301][301];


int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			cin >> A[i][j];
			G[i][j] = A[i][j];
		}
	}
	for(int k=1;k<=N;k++){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
			}
		}
	}
	bool judge = true;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			if(A[i][j]!=G[i][j]) judge = false;
		}
	}
	if(!judge) cout << -1 << endl;
	else{
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				F[i][j] = true;
			}
		}
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				if(i!=j){
					for(int k=1;k<=N;k++){
						if(k!=i && k != j && G[i][j]==G[i][k]+G[k][j]){
							F[i][j] = false;
						}
					}
				}
			}
		}
		ll ans = 0;
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				if(F[i][j]) ans += G[i][j];
			}
		}
		cout << ans/2 << endl;
	}
}

Measured memory_bytes: 1792