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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

// イテレータを受け取り、次の組み合わせに入れ替える（次があるかどうかを返す）
template <typename BIt> // BIt:bidirectional_iterator
bool next_combination (BIt first1, BIt last1, BIt first2, BIt last2)
{
    if ((first1 == last1) || (first2 == last2)) return false;

    BIt m1 = last1;
    BIt m2 = last2; --m2;

    do {
        --m1;
    } while (m1 != first1 && !(*m1 < *m2));

    bool result = ((m1 == first1) && !(*first1 < *m2));

    if (!result){
        while (first2 != m2 && !(*m1 < *first2)){
            ++first2;
        }
        first1 = m1;
        std::iter_swap(first1, first2);
        ++first1;
        ++first2;
    }
    if ((first1 != last1) && (first2 != last2)){
        m1 = last1;
        m2 = first2;
        while ((m1 != first1) && (m2 != last2)){
            --m1;
            std::iter_swap(m1, m2);
            ++m2;
        }
        std::reverse(first1, m1);
        std::reverse(first1, last1);
        std::reverse(m2, last2);
        std::reverse(first2, last2);
    }
    return !result;
}

// イテレータを受け取り、次の組み合わせに入れ替える（次があるかどうかを返す）
template <typename BIt> // BIt:bidirectional_iterator
inline
bool next_combination (BIt first, BIt middle, BIt last)
{
    return next_combination(first, middle, middle, last);
}

// イテレータを受け取り、前の組み合わせに入れ替える（前があるかどうかを返す）
template <typename BIt> // BIt:bidirectional_iterator
inline
bool prev_combination (BIt first, BIt middle, BIt last)
{
  return next_combination(middle, last, first, middle);
}

int main()
{
    scanInt(D);
    scanInt(G);
    vector<int> P(D);
    vector<int> C(D);
    REP(i, D) cin >> P[i] >> C[i];
    vector<int> v; v.reserve(D);
    REP(i, D) v.emplace_back(i);
    int result = 0;
    REP(i, D) result += P[i];
    do {
        int score = 0;
        int times = 0;
        REP(i, D){
            if (G <= score + (v[i] + 1) * 100 * (P[v[i]] - 1)){
                times += (G - score - 1) / ((v[i] + 1) * 100) + 1;
                break;
            }else if (G <= score + (v[i] + 1) * 100 * P[v[i]] + C[v[i]]){
                times += P[v[i]];
                break;
            }else{
                score += (v[i] + 1) * 100 * P[v[i]] + C[v[i]];
                times += P[v[i]];
            }
            if (G <= score) break;
        }
        result = min(result, times);
    } while (next_permutation(v.begin(), v.end()));
    cout << result << endl;
}


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


public class A
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());

		LinkedList<int> b = new LinkedList<int>();
		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			b.AddLast(Int32.Parse(args[i]));
		
		bool isExist = true;
		int[] ans = new int[N];
		for(int i = 0; i < N; i++)
		{
			LinkedListNode<int> del = null;
			int pos = 1;
			for(LinkedListNode<int> node = b.First; node != null; node = node.Next)
			{				
				if(node.Value == pos)
					del = node;
				pos++;
			}

			if(del == null)
			{
				isExist = false;
				break;
			}
			else
			{				
				ans[i] = del.Value;
				b.Remove(del);
			}
		}

		if(isExist)
			for(int i = N - 1; i >= 0; i--)
				Console.WriteLine(ans[i]);
		else
			Console.WriteLine(-1);
	}
}





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

using namespace std;

int main()
{
    long n, k;
    cin >> n >> k;
    long option1, option2;
    option1 = n - n / k * k;
    option2 = abs(option1 - k);
    if(option1 > option2) cout << option2 << endl;
    else cout << option1 << endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
public static void main(String[] args){
try (Scanner sc = new Scanner(System.in)){
while(true){
int n = sc.nextInt();
if(n == 0){
break;
}
int[] score = new int[n];
for(int i = 0; i< score.length; i++){
score[i] = sc.nextInt();
}
double avg = 0, var = 0, tot = 0;
int sum = 0;
for(int i = 0; i<score.length; i++){
sum = sum + score[i];
}
avg = (double) sum / n;
for(int i = 0; i<score.length; i++){
tot = tot + (score[i] - avg) * (score[i] - avg);
}
var = tot / n;
System.out.println(Math.sqrt(var));
}
}
}
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  
  vector<int> cards(N);
  rep(i, N){
    cin >> cards.at(i);
  }
  
  //大きい順に並び替える
  rep(i, N){
    int max = 0;
    int index;
    for(int j=i; j<N; j++){
      if(cards.at(j) > max){
        index = j;
        max = cards.at(j);
      }
    }
    int tmp = cards.at(i);
    cards.at(i) = max;
    cards.at(index) = tmp;
  }
  int score = 0;
  rep(i, N){
    if(i % 2 == 0)
      score += cards.at(i);
    else
      score -= cards.at(i);
  }
  cout << score << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

void solve(){
  int n; cin >> n;
  int a[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      a[i][j] = 0;
    }
  }
  for(int i = 1; i <= n; i++){
    if(i % 10 == 0) continue;
    string s = to_string(i);
    a[s[0] - '0'][s[s.size() - 1] - '0']++;
  }
  int ans = 0;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      if(i == 0 || j == 0) continue;
      ans += a[i][j] * a[j][i];
      //cout << i << " ~ " << j << " : " << a[i][j] << endl;
    }
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
type order = Push of int | Pop

let order_of_int n =
    match n with
    | 0 -> Pop
    | n -> Push(n)

let () =
    let cars = Stack.create () in
    try
        while true do
            let n     = read_int () in
            let order = order_of_int n in
            match order with
            | Push(n) -> Stack.push n cars
            | Pop     -> Printf.printf "%d\n" (Stack.pop cars)
        done
    with
        End_of_file -> ()

Measured memory_bytes: 2304
fun main(args:Array<String>):Unit {
    val (n, q) = readLine()!!.split(' ').map(String::toInt)
    val stacks = Array(n){Stack<Int>()}
    repeat(q){
        val query = readLine()!!.split(' ').map(String::toInt)
        when(query.first()){
            0 -> stacks[query[1]].push(query.last())
            1 -> if (stacks[query.last()].isNotEmpty) println(stacks[query.last()].top())
            else -> if (stacks[query.last()].isNotEmpty) stacks[query.last()].pop()
        }
    }
}

sealed class ImmutableList<out T>{
    object Nil:ImmutableList<Nothing>()
    data class Cons<out T>(val head:T, val tail:ImmutableList<T>):ImmutableList<T>()
}
class Stack<T>{
    private var mStack:ImmutableList<T> = ImmutableList.Nil
    fun push(value:T):Unit {
        mStack = ImmutableList.Cons(value, mStack)
    }
    fun top():T = (mStack as ImmutableList.Cons).head
    fun pop():Unit {
        mStack = (mStack as ImmutableList.Cons).tail
    }
    val isEmpty:Boolean
        get() = mStack == ImmutableList.Nil
    val isNotEmpty:Boolean
        get() = !isEmpty
}


Measured memory_bytes: 118596
#include <bits/stdc++.h>
#define FASTIO
#define endl "\n" // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)             \
	for (int i = 0; i < (n); i++) \
		cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)           \
	for (auto i : (c))      \
		cout << i << " "; \
	cout << "\n";
#define display(c, n)           \
	for (int i = 0; i < (n); i++) \
		cout << (c)[i] << " ";    \
	cout << "\n";
#define forl(i, a, n) for (int (i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;

	return res;
}

const int N = 3000 + 5;
string s, t;

int cache[N][N] = {};
int path[N][N] = {};

int solve(int i, int j)
{
	if (i >= (int) s.length() || j >= (int) t.length())
		return 0;
	
	int &ans = cache[i][j], &pax = path[i][j];
	if (ans != -1)
		return ans;

	if (s[i] == t[j])
	{
		ans = 1 + solve(i + 1, j + 1);
		pax = 3;
	}
	else
	{
		int t1 = solve(i + 1, j);
		int t2 = solve(i, j + 1);
		if (t1 > t2)
			ans = t1, pax = 1;
		else
			ans = t2, pax = 2;
	}
	
	return ans;
}

int32_t main()
{
#ifdef FASTIO
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	// freopen("in.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	memset(cache, -1, sizeof cache);
	memset(path, -1, sizeof path);

	cin >> s >> t;
	int ans = solve(0, 0);
	int i = 0, j = 0;
	while (i < (int) s.length() && j < (int) t.length())
	{
		int pax = path[i][j];
		// cout << "i : " << i << " j : " << j << " p : " << path[i][j] << "\n";
		if (pax == 3)
		{
			cout << s[i];
			i++, j++;
		}
		else
		{
			i += pax % 2;
			j += (pax - 1);
		}
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 71040
#include <iostream>

using namespace std;

int main() {
    int l1, l2, l3;
    char c1, c2;
    int rect = 0, diamond = 0;

    while(cin >> l1 >> c1 >> l2 >> c2 >> l3) {
        if(l1*l1+l2*l2 == l3*l3) ++rect;
        if(l1 == l2) ++diamond;
    }
    cout << rect << endl;
    cout << diamond << endl;

    return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        int[] HW = Stream.of(br.readLine().split(" ")).mapToInt(
                item -> new Integer(item)).toArray();
        Stream<String> lines = br.lines();
        
        // データからパラメータを割り出す
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);

        // 変換処理、出力
        Stream<String> border_s = Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> border_e = Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> out = Stream.concat(border_s, Stream.concat(a, border_e));
        
        System.out.print(out.map(item -> "#" + item + "#").collect(
                Collectors.joining("\n")).replaceFirst("\n$", ""));
    }
}


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a[1000];
    cin>>n;
    rep(n) cin>>a[i];
    int ans = 0;
    stack<int> s;
    s.push(a[0]);
    for(int i = 1;i<n;)
    {
    	while(i<n && (s.empty()||s.top()>a[i]))
    	s.push(a[i++]);	
    	while(!s.empty() && s.top()<=a[i] )
    		s.pop();
    	if(s.empty()) ans++;
    }
    cout<<ans+1<<endl;
    return 0;

}
    

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
int loop(int m){
  int res;
  m*=2;
  rep1(i,m){
    if(m%i==0){
      if(m/i-1==i){
	res=i;
	return res;
      }
    }
  }
  return -1;
}
void solve(){
  int m=loop(n);
  if(m==-1){
    prin("No");
    return ;
  }
  else{
    prin("Yes");
    prin(m+1);
    int res[600][600];
    int i=0,j=0,l=0,p=1;
    while(i<m){
      rep(k,m-l){
	res[i][k+j]=k+p;
	res[k+i+1][j]=k+p;
      }
      p=1+res[i][m-1];
      i++;j++;l++;
    }
    rep(a,m+1){
      cout<<m<<" ";
      rep(b,m){
	cout<<res[a][b]<<" ";
      }
      cout<<"\n";
    }
    return ;
    }
  
}
int main(){
  cin>>n;
  solve();

  return 0;
}


Measured memory_bytes: 2432
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 62)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

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

    cout << (1000 - n%1000)%1000 << endl;
    return 0;
}


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

int main(){
  char a, b;
  cin >> a >> b;
  int m, n;
  if(a=='1') m=1;
  if(a=='2') m=2;
  if(a=='3') m=3;
  if(a=='4') m=4;
  if(a=='5') m=5;
  if(a=='6') m=6;
  if(a=='7') m=7;
  if(a=='8') m=8;
  if(a=='9') m=9;
  
  if(b=='1') n=1;
  if(b=='2') n=2;
  if(b=='3') n=3;
  if(b=='4') n=4;
  if(b=='5') n=5;
  if(b=='6') n=6;
  if(b=='7') n=7;
  if(b=='8') n=8;
  if(b=='9') n=9;
  
  if(m>=n){
    for(int i=0; i<m; ++i){
      cout << b;
    }
  }
  else{
    for(int i=0; i<n; ++i){
      cout << a;
    }
  }
  cout << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  vector<int> dp(1000010, 0);
  sort(all(A));
  REP(i, N) {
    if(dp[A[i]] > 1) continue;
    for(int k = A[i]; k < 1000010; k += A[i]) {
      dp[k]++;
      if(k > A[N - 1]) break; 
    }
  }
  int ans = 0;
  REP(i, N) {
    if(dp[A[i]] == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7944
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,k;
    cin>>n>>m>>k;
    for (int i=0;i<=n;i++) {
        for (int j=0;j<=m;j++) {
            if ( i*(m-j)+j*(n-i)==k) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
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;}

//main code
int main(int argc, char *argv[])
{
	int a,b;
	cin >> a >> b;
	int c = min(a,b);
	int d = max(a,b);
	LL ans = c;
	for (int i = 1; i < d; i++) {
		ans *= 10;
		ans += c;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (1) {
		int n, m, p, sum = 0;
		cin >> n >> m >> p;
		if (!n) break;
		vector<int> v(n);
		REP(i, n) {
			cin >> v[i];
			sum += v[i];
		}
		int geld = sum*(100-p);
		sum *= 100;
		if (v[m - 1] == 0) cout << 0 << endl;
		else cout << double(geld / v[m - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3240
def main():
    mod = 1000000007
    n = int(input())
    cnt = [0] * (n + 2)
    cnt[0] = 3
    res = 1
    for x in input().split():
        v = int(x)
        res *= cnt[v] - cnt[v + 1]
        res %= mod
        cnt[v + 1] += 1
    print(res)

main()



Measured memory_bytes: 11412
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

typedef complex<double> P;
const double r = 1.0;


vector<P> GetCrossPoint(P a, P b)
{
	vector<P> res;
	
	// ツ堕スツ閉ェツつャツづィツつャツづィツ静堋触ツつオツづつ「ツづゥ
	if(abs(abs(b - a) - r * 2) < EPS)
	{
		P c = a + b;
		res.push_back( P(c.real() / 2,c.imag() / 2) );
	}
	// ツ閉津環づ可古ーツづュツづづつ「ツづゥ
	else if(abs(b - a) < r * 2)
	{
		P ab = b - a;
		P center = a + P(ab.real() / 2, ab.imag() / 2);
		
		P u1 = (ab * P(0, +1)) / abs(ab);
		P u2 = (ab * P(0, -1)) / abs(ab);
		
		double dist = sqrt(1 - pow(abs(ab) / 2, 2));
		P c1 = center + u1 * dist;
		P c2 = center + u2 * dist;
		
		res.push_back(c1);
		res.push_back(c2);
	}
	
	return res;
}


int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<P> c(n);
		
		double x, y;
		
		rep(i, n)
		{
			cin >> x >> y;
			
			c[i] = P(x, y);
		}
		
		
		int res = 1;
		
		rep(i, n) REP(j, i + 1, n)
		{
			vector<P> crs(GetCrossPoint(c[i], c[j]));
			
			rep(k, crs.size())
			{
				int cover = 2;
				
				rep(l, n) if(l != i && l != j && abs(crs[k] - c[l]) - 1.0 < EPS)
				{
					cover++;
				}
				
				chmax(res, cover);
			}
		}
		
		cout << res << endl;
	}
}

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

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    if(s.size() % 2 == 1) ans = "No";
    else{
        rep(i, s.size()) {
            if(i % 2 == 0) {
                if(s[i] != 'h') ans = "No";
            }
            else {
                if(s[i] != 'i') ans = "No";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a==0&&b==0) break;
		if(a<b)	printf("%d %d\n",a,b);
		else printf("%d %d\n",b,a);
	}
	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((a!=b && b!= c && c!=a) || (a== b && b==c && c==a)){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}

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

int bubbleSort(int* A, int n){
	bool flag = true;
	int cnt = 0;
	while(flag){
		flag = false;
		for(int j=n-1; j>0; j--){
			if(A[j-1] > A[j]){
				swap(A[j-1], A[j]);
				flag = true;
				cnt++;
			}
		}
	}
	return cnt;
}

int main(){
	int n;
	cin >> n;
	int A[100];
	int cnt;
	
	for(int i=0; i<n; i++) cin >> A[i];
	cnt = bubbleSort(A, n);
	
	cout << A[0];
	for(int i=1; i<n; i++) cout << " " << A[i];
	cout << "\n" << cnt << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int X1[1005],X2[1005],Y1[1005],Y2[1005];
int f[3030][3030];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int W,H,N;
int ans=0;
int compress(int* x1,int* x2,int t)
{
	vector<int> xs;
	for(int i=0;i<N;i++)
	{
		int tx1=x1[i],tx2=x2[i];
		if(1<=tx1&&tx1<t)xs.pb(tx1);
		if(1<=tx2&&tx2<t)xs.pb(tx2);
	}
	xs.pb(0);xs.pb(t);
	SORT(xs);
	xs.erase(unique(all(xs)),xs.end());
	for(int i=0;i<N;i++)
	{
		x1[i]=find(all(xs),x1[i])-xs.begin();
		x2[i]=find(all(xs),x2[i])-xs.begin();
	}
	return xs.size()-1;
}
int main()
{
	while(1)
	{
		memset(f,0,sizeof(f));
		ans=0;
		cin >> W >> H;
		if(W==0&&H==0)return 0;
		cin >> N;
		for(int i=0;i<N;i++)
		{
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
		W=compress(X1,X2,W);
		H=compress(Y1,Y2,H);
		for(int i=0;i<N;i++)
		{
			f[Y1[i]][X1[i]]++;
			f[Y2[i]][X2[i]]++;
			f[Y1[i]][X2[i]]--;
			f[Y2[i]][X1[i]]--;
		}
		for(int i=0;i<H;i++)
		{
			for(int j=1;j<W;j++)
			{
				f[i][j]+=f[i][j-1];
			}
		}
		for(int i=1;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				f[i][j]+=f[i-1][j];
			}
		}
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(f[i][j])continue;
				ans++;
				queue<P> q;
				q.push(mp(j,i));
				while(!q.empty())
				{
					int tx=q.front().fi,ty=q.front().sec;
					q.pop();
					for(int k=0;k<4;k++)
					{
						int ttx=tx+dx[k],tty=ty+dy[k];
						if(ttx<0||ttx>W||tty<0||tty>H||f[tty][ttx]>0)continue;
						q.push(mp(ttx,tty));
						f[tty][ttx]=1;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 37108
import java.util.Scanner;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args) {
		Scanner  s = new Scanner(System.in);
		int n =  s.nextInt();
	  double sum = 100000;
	  double dept=0;
	 for(int i=0;i<n;i++){
		 sum*=1.05;
		 dept =sum%1000;
		 if(dept!=0){
			 sum+=(1000-dept);
		 }
	 }
	 System.out.println((int)sum);
	}
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s1,s2;cin>>s1>>s2;
    auto tmp1=s1;
    auto tmp2=s2;
    reverse(all(s1));
    reverse(all(s2));
    if(s1==tmp2&&s2==tmp1) cout<<"YES";
    else cout<<"NO";
    cout<<endl;

    return 0;
}



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

using namespace std;

int main() {
    int n;
    while(cin >> n){
         if(n < 1200 ) cout << "ABC" << endl;
         else if(n < 2800) cout << "ARC" << endl;
         else cout << "AGC" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
//Created by Aminul on 8/2/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int k = in.nextInt();
        pw.println(solve(k));
        pw.close();
    }

    static int solve(int k) {
        int cnt = 1, val = 7 % k;
        while (val != 0 && cnt < 2e6) {
            val = ((val * 10) + 7) % k;
            cnt++;
        }
        return val == 0 ? cnt : -1;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 27240
#include<stdio.h>

int main(){
	int n,i,sum;
	int fee[6]={500,100,50,10,5,1};
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		n=1000-n;
		sum=0;
		for(i=0;i<6;i++){
			sum+=n/fee[i];
			n=n%fee[i];
		}
		printf("%d\n",sum);
	}
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  ll x;
  cin>>x;
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
      if(pow(i,5)-pow(j,5)==x){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4032
#include<iostream>
#include<cassert>
#include<algorithm>
#include<vector>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  string tag;
  int x1,y1,x2,y2,depth,cnt;
  P(string tag="$",int x1=inf,int y1=inf,int x2=inf,int y2=inf,int depth=inf,int cnt=inf):tag(tag),x1(x1),y1(y1),x2(x2),y2(y2),depth(depth),cnt(cnt){}
};

string par;
vector<P> info;
int pos;

string getTag()
{
  assert(par[pos] == '<');
  pos++;
  string tag = "";
  while(par[pos] != '>')
    {
      tag += par[pos];
      pos++;
    }
  assert(par[pos] == '>');
  pos++;
  if(tag[0] == '/')tag = tag.substr(1,tag.size()-1);
  return tag;
}

bool exp(int depth)
{
  if(par[pos+1] == '/')
    {
      return false;
    }

  string tag = getTag();

  vector<int> coor;
  int value = 0;
  while(par[pos] != '<')
    {

      value *= 10;
      value += (par[pos]-'0');
      pos++;
      if(par[pos] == ',')
	{
	  coor.push_back(value);
	  value = 0;
	  pos++;
	}

    }

  coor.push_back(value);

  assert((int)coor.size() == 4);

  int cnt = 0;
  while(exp(depth+1))
    {
      cnt++;
    }

  assert(pos+1 < par.size() && par[pos+1] == '/');

  info.push_back(P(tag,coor[0],coor[1],coor[2],coor[3],depth,cnt));

  string tag2 = getTag();
  assert(tag == tag2);

  return true;

}

int main()
{
  int n;
  while(cin >> n,n)
    {
      info.clear();
      cin >> par;


      pos = 0;
      exp(0);
      /*
      cout << "INFO" << endl;
      rep(i,info.size())
	{
	  cout << info[i].tag << " (" << info[i].x1 << "," << info[i].y1 << ") (" << info[i].x2 << "," << info[i].y2 << ") depth = " << info[i].depth << " cnt = " << info[i].cnt << endl; 
	}
      */


      int p;
      rep(i,n)
	{
	  int x,y;
	  cin >> x >> y;
	  p = inf;
	  rep(j,info.size())
	    {
	      int x1 = info[j].x1, x2 = info[j].x2;
	      int y1 = info[j].y1, y2 = info[j].y2;
	      if(x1 <= x && x <= x2 && y1 <= y && y <= y2)
		{

		  if(p == inf)p = j;
		  else if(info[p].depth < info[j].depth)
		    {
		      assert(info[p].depth != info[j].depth);
		      p = j;
		    }
		}
	    }
	  if(p == inf)cout << "OUT OF MAIN PANEL 1" << endl;
	  else cout << info[p].tag << " " << info[p].cnt << endl;
	}
    }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>

using namespace std;



int main()
{
	string S;

	cin >> S;

	const int LEN = 3;
	const int GOAL = 753;
	int min_dif = 999;
	int dif;

	int num;
	for (int si = 0; si <= S.length() - LEN; si++) {
		num = atoi(S.substr(si, LEN).c_str());
		dif = abs(num - GOAL);
		if (dif < min_dif) {
			min_dif = dif;
		}
	}

	cout << min_dif;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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,T;
    cin >> N >> T;
    vector<Pii> C(N);
    multiset<int> s;
    rep(i,N){
        int A,B;
        cin >> A >> B;
        s.insert(B);
        C[i]=Pii(A,B);
    }
    sort(C.begin(),C.end());
    vector<vector<int>> dp(N,vector<int>(T,0));
    int ans=0;
    rep(i,N-1){
        rep(j,T){
            dp[i+1][j]=dp[i][j];
            if (j-C[i].first>=0) chmax(dp[i+1][j],dp[i][j-C[i].first]+C[i].second);
        }
        int m=0;
        rep(j,T) chmax(m,dp[i+1][j]);
        s.erase(s.lower_bound(C[i].second));
        int M=*s.rbegin();
        chmax(ans,m+M);
    }
    cout << ans << endl;
}

Measured memory_bytes: 35712
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  REP(i,100){
    if(n < i*4) break;
    if((n-i*4)%7==0){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import *
import random

def readln():
    return list(map(int,(input().split(" "))))

n,z,w = readln()
a = readln()
f = [0 for i in range(n)]
min_f = [0 for i in range(n)]
max_min_f = [0 for i in range(n)]

s = [a[n - i - 1] for i in range(n)]
s.append(w)

f[0] = abs(s[0] - s[1])
min_f[0] = f[0]
max_min_f[0] = f[0]
for i in range(1,n):
    f[i] = max(abs(s[0] - s[i + 1]), max_min_f[i-1])
    min_f[i] = min(f[i],min_f[i-1])
    max_min_f[i] = max(min_f[i], max_min_f[i-1])


print(f[n-1])


# F[i] 表示y手里是i，x的最优解


Measured memory_bytes: 5224
#include <stdio.h>
int main(){
    int N,M;
    int i;
    int A,B;
    int pay=0;
    int max=0;
    
    scanf("%d %d",&N,&M);
    
    for(i=0;i<M;i++)
    {
        scanf("%d %d",&A,&B);
        
        if(N-A>0) pay=pay+N-A;
        if(max<N-A) max=N-A;
    }
    
    printf("%d\n",pay-max);
    
    return 0;   
}

Measured memory_bytes: 600
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for a_ in a:
    k=0
    for i in range(len(a_)):
        k+=a_[i]*b[i]
    k+=c
    if k>0:
        ans+=1
print(ans)

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

using namespace std;

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

  int input;
  vector<int> vec;
  rep (i, N) {
    cin >> input;
    vec.push_back(input);
  }
  sort(vec.begin(), vec.end());
  int ttl = 0;
  int before = -1;
  rep(i, vec.size()) {
    if (before != vec.at(i)) {
      ttl += 1;
    }
    before = vec.at(i);
  }

  cout << ttl << endl;
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
h_list = list(map(int, input().split()))
ar = np.zeros(N+2)
ar[1:N+1] = np.array(h_list)


cnt = 0
search_flag = False
ss = 0
while True:
    for i in range(N + 2):
        if search_flag:
            if ar[i] == 0:
                search_flag = False
                end_i = i
                cnt += 1
                ar[start_i:end_i] -= 1
        if not search_flag:
            if ar[i] > 0:
                search_flag = True
                start_i = i
    if sum(ar) == 0:
        break
    ss += 1
print(cnt)

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

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

		while (in.hasNext()) {
			int N = in.nextInt();
			Task[] t = new Task[N];

			for (int i = 0; i < t.length; ++i) {
				t[i] = new Task(in.nextInt(), in.nextInt());
			}
			
			Arrays.sort(t);
			
			long time = 0;
			boolean canCompleteAll = true;
			for (int i = 0; i < t.length; ++i) {
				time += t[i].unit;
				
				if (time > t[i].deadline) {
					canCompleteAll = false;
					break;
				}
			}
			
			if (canCompleteAll) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

	private static class Task implements Comparable<Task>{
		int unit;
		int deadline;

		Task(int startTime, int endTime) {
			this.unit = startTime;
			this.deadline = endTime;
		}

		@Override
		public int compareTo(Task o) {
			if (this.deadline != o.deadline) {
				return this.deadline - o.deadline;
			} else {
				return this.unit - o.unit;
			}
		}
	}

}


Measured memory_bytes: 102260
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC121_1 solver = new ABC121_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC121_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int h = in.nextInt();
            int w = in.nextInt();

            int ttl = H * W;
            out.println(ttl - ((h * W) + ((H - h) * w)));

        }

    }
}



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

int main(){
    int box[3];
    for(unsigned i = 0;i < 3;i++){
        cin>>box[i];
    }
    int tmp;
    tmp = box[0];
    box[0] = box[1];
    box[1] = tmp;

    tmp = box[0];
    box[0] = box[2];
    box[2] = tmp;

    for(unsigned i = 0;i < 3;i++){
        cout<<box[i]<<" ";
    }
    cout<<endl;

    return 0;
} 

Measured memory_bytes: 256
N=int(input())
if N%2:
    print(N*(N-2)//2+1)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if i+j!=N:
                print(i,j)
else:
    print(N*(N-2)//2)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if i+j!=N+1:
                print(i,j)

Measured memory_bytes: 3612
N,M=map(int,input().split())
ab=[[] for i in range(N)]
AB=[]
for i in range(M):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ab[a].append(b)
    ab[b].append(a)
    AB.append([a,b])
ans=0
for i in range(M):
    x,y=AB[i]
    ab[x].remove(y)
    ab[y].remove(x)
    stack=[i for i in ab[0]]
    reached=[0]*N
    reached[0]=1
    while(stack):
        b=stack.pop()
        if reached[b]==1:
            continue
        for k in ab[b]:
            stack.append(k)
        reached[b]=1
    ab[x].append(y)
    ab[y].append(x)
    if reached!=[1]*N:
        ans+=1
print(ans)


Measured memory_bytes: 40176
N,W = map(int,input().split())
wv = []
for i in range(N):
    wv.append(list(map(int,input().split())))
    
#- dp[i][j] i番目より後ろの品物から、重さjまで許して荷物を入れた時の価値の最大
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N-1,-1,-1):#N番目以降は品物がもうないので0。→N-1からやる
    for j in range(W,-1,-1): #重いほうから見ていく
        if j<wv[i][0]:#i番目の荷物の重さがそもそも許容値よりも大きい→いれられない
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-wv[i][0]]+wv[i][1])#いれない or いれる　の大きいほう
#最後の出力は、0番目以降の品物(つまり、全部)から、重さWまで許したときの価値の最大
print(dp[0][W])


Measured memory_bytes: 147956
#include<cstdio>
#include<vector>
#include<utility>
#include<stack>
using namespace std;

int main(){
	int N;
	scanf("%d", &N);
	vector<pair<int, long long> > adj[N];
	for (int i = 0; i < N-1; ++i){
		int from, to;
		long long cost;
		scanf("%d %d %lld", &from, &to, &cost);
		from--, to--;
		adj[from].push_back(make_pair(to, cost));
		adj[to].push_back(make_pair(from, cost));
	}
	int Q, K;
	scanf("%d %d", &Q, &K);
	K--;
	bool has_been_discovered[N];
	for (int i = 0; i < N; ++i) has_been_discovered[i] = false;
	long long d[N];
	stack<int> S;
	S.push(K);
	has_been_discovered[K] = true;
	d[K] = 0;
	while(!S.empty()){
		int u = S.top(); S.pop();
		for (int i = 0; i < adj[u].size(); ++i){
			int v = adj[u][i].first;
			if(!has_been_discovered[v]){
				has_been_discovered[v] = true;
				d[v] = d[u] + adj[u][i].second;
				S.push(v);
			}
		}
	}
	for (int i = 0; i < Q; ++i){
		int x, y;
		scanf("%d %d", &x, &y);
		printf("%lld\n", d[x-1] + d[y-1]);
	}
	return 0;
}

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

int grid[105][105];

int main(){
    int h,w; cin >> h >> w;
    vector<int> count(26,0);
    rep(i,h)rep(j,w){
        char a;cin >> a;
        count[a-'a']++;
    }

    vector<int> num(4);
    rep(i,26) num[count[i]%4]++;
    //rep(i,4) cout << num[i] << endl;

    if(h%2 == 0 && w%2 == 0){
        if(num[1] || num[2] || num[3]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }else if(h%2 == 1 && w%2 == 0){
        if(num[1]==0&&num[3]==0&&num[2]<=w/2) cout << "Yes" << endl;
        else cout <<"No"<< endl;
    }else if(w%2 == 1 && h%2 == 0){
        if(num[1]==0&&num[3]==0&&num[2]<=h/2) cout << "Yes" << endl;
        else cout <<"No"<< endl;
    }else{
        //cout << max(w/2,h/2) << endl;
        if(num[1]==1&&num[3]==0&&num[2]<=(w/2+h/2)) cout << "Yes" << endl;
        else if(num[1]==0&&num[3]==1&&num[2]<=(w/2+h/2-1)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

Measured memory_bytes: 3500
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    string s; cin >> s;
    int left = 0; int right = n-1;
    int ans = 0;
    while(left < right) {
        while(s[left]!='W' and left < n) left++;
        while(s[right]!='R' and right >= 0) right--;
        if(left >= right) break;
        ans ++;
        left++; right--;
    }
    cout << ans <<  endl;
    return 0;
}


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

#include <bits/stdc++.h>

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

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

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

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    if (a + b == c + d) cout << "Balanced" << endl;
    if (a + b > c + d) cout << "Left" << endl;
    if (a + b < c + d) cout << "Right" << endl;
  }

  return 0;
}


Measured memory_bytes: 256