akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"1 6 3"# => "5",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        mut x: [isize; 3],
    }
    x.sort();
   (isize::abs(x[0] - x[1]) + isize::abs(x[1] - x[2])).to_string()
}

Measured memory_bytes: 4352
#include <stdio.h>
int fibo(int);
int f[45];
int main(void){
    int a,i;
    for(i=0;i<=44;i++) f[i]=-1;
    scanf("%d",&a); 
    printf("%d\n",fibo(a));
    return 0;
}
int fibo(int ans){
    if (ans ==0 || ans ==1)return f[ans]=1;
    if (f[ans]!=-1)return f[ans];
    return f[ans]=fibo(ans-1)+fibo(ans-2);
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    vector<vector<char>> b(H, vector<char>(W, 'a'));
    rep(i, H) rep(j, W) cin >> a[i][j];


    rep(i, H) {
        if(a[i][0] == '#') continue;
        char prev = a[i][0];
        bool isSame = true;
        for(int j=1; j<W; j++) {
            if(a[i][j] != prev) {
                isSame = false;
                break;
            }
        }
        if(isSame) rep(j, W) b[i][j] = 'n';
    }

    rep(i, W) {
        if(a[0][i] == '#') continue;
        char prev = a[0][i];
        bool isSame = true;
        for(int j=1; j<H; j++) {
            if(a[j][i] != prev) {
                isSame = false;
                break;
            }
        }
        if(isSame) rep(j, H) b[j][i] = 'n';
    }

   
    rep(i, H) {
        bool ent = false;
        rep(j, W) {
            if(b[i][j] == 'n') continue;
            ent = true;
            cout << a[i][j];
        }
        if(ent) cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

def garden(lst, count):
    if lst == [] or max(lst) == 0:
        return count
    elif 0 not in lst:
        lst = list(map(lambda a: a-1, lst))
        count += 1
        return garden(lst, count)
    elif 0 in lst:
        return count + garden(lst[:lst.index(0)], 0) + garden(lst[lst.index(0) + 1:], 0)

print(garden(h, 0))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main() 
{
  fastio;
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=int('Z');
 // cout<<x;
  for(int i=0;i<s.length();i++)
  {
    s[i]=s[i]+n;
    if(s[i]>'Z')
      s[i]=s[i]-26;

  }
  cout<<s;
 
}

Measured memory_bytes: 3604
#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<char,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 X,N;
    cin>>X>>N;
    vec A(N),B;
    rep(i,0,N) {
        cin>>A[i];
    }
    
    rep(i,0,100) {
        bool ans=true;
        rep(j,0,N) {
            if(X-i==A[j]) {
                ans=false;
            }
            }
            if(ans) {
                cout<<X-i;
                return 0;
            }
            
            bool ans1=true;
            rep(j,0,N) {
            if(X+i==A[j]) {
                ans1=false;
            }
            }
            if(ans1) {
                cout<<X+i;
                return 0;
            
            }
            }
        
            
            
            
            
        }
    

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

if N%2 or 0 in A:
    print('First' if sum(A)%2 else 'Second')
    exit()
if min(A)%2:
    print('First')
else:
    print('First' if sum(A)%2 else 'Second')


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

int n, k, q;
int a[2000];

int sub(int t) {
  vector<vector<int>> vs;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    if (a[i] < t) {
      vs.push_back(v);
      v.clear();
    } else {
      v.push_back(a[i]);
    }
  }
  
  if (!v.empty()) {
    vs.push_back(v);
  }
  
  vector<int> r;
  for (auto&& v : vs) {
    if (v.size() < k) continue;
    sort(v.begin(), v.end());
    int len = v.size() - k + 1;
    for (int i = 0; i < len; ++i) {
      r.push_back(v[i]);
    }
  }
  
  sort(r.begin(), r.end());
  if (r.size() < q) return 2e9;
  return r[q - 1] - t;
}

int main() {
  cin >> n >> k >> q;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  int mn = 2e9;
  for (int i = 0; i < n; ++i) {
    int tmp = sub(a[i]);
    mn = min(mn, tmp);
  }
  cout << mn << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<string> ans = {"AC", "WA", "TLE", "RE"};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<string, int> mp;
  rep(i, n) mp[s[i]]++;
  rep(i, 4) cout << ans[i] << " x " << mp[ans[i]] << '\n';


  




  
  return 0;
}

Measured memory_bytes: 6368
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };



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

	s += a + b;

	int n = atoi(s.c_str());

	int c = (int)sqrt((double)n);
	if (c * c == n) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include <string.h>
#include <iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
const ll mod=1e9+7;


int main(void){
    int des;
    ll dp[105][4][4][4];
    memset(dp,0,sizeof(dp));
    dp[0][3][3][3]=1;
    rep(i,100){
        rep(f,4){
            rep(s,4){
                rep(t,4){
                    if(s==0 && t==1) des=2;
                    else if(s==1 && t==0) des=2;
                    else if(s==0 && t==2) des=1;
                    else if(f==0 && t==1) des=2;
                    else if(f==0 && s==1) des=2;
                    else des=-1;
                    rep(next,4){
                        if(des==next) continue;
                        dp[i+1][s][t][next]+=dp[i][f][s][t];
                        dp[i+1][s][t][next]%=mod;
                    }
                }
            }
        }
    }
    ll ans[105];
    memset(ans,0,sizeof(ans));
    rep(i,102){
        rep(f,4){
            rep(s,4){
                rep(t,4){
                    ans[i]+=dp[i][f][s][t];
                    ans[i]%=mod;
                }
            }
        }
    }
    ll N;
    cin>>N;
    cout<<ans[N]<<endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (a, mut b, mut c): (usize, usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let k: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut count = 0;
    while a >= b {
        b *= 2;
        count += 1;
    }
    while b >= c {
        c *= 2;
        count += 1;
    }

    if count <= k {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n<3)
        printf("0\n");
        else
        {
            printf("%d\n",n/3);
        }

    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int a[100000];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	int u[100001] = {}; u[1] = 1;
	int res = 0, p = 1;
	while(1){
		p = a[p - 1]; res++;
		if(p == 2) break;
		if(u[p]){ res = -1; break; }
		u[p] = 1;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 896
from sys import stdin

n = int(stdin.readline().rstrip())
R = [int(stdin.readline().rstrip()) for i in range(n)]
minval = R[0]
diff = R[1]-minval
for i in range(1, n):
    diff = max(diff, R[i]-minval)
    minval = min(minval, R[i])
    
print(diff)


Measured memory_bytes: 13624
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for(int i = a; i <= b; i++){
		string tmp = to_string(i);
		reverse(tmp.begin(), tmp.end());
		int tmp2 = atoi(tmp.c_str());
		if(i == tmp2){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int w, h, res = 0;
    char c;
    cin>>w>>h>>c;
    cout<<'+';
    rep(i, w - 2){
        cout<<'-';
    }
    cout<<'+'<<endl;
    rep(i, h - 2){
        cout<<'|';
        rep(j, w - 2){
            if(i == h/2 - 1 && j == w/2 - 1) cout<<c;
            else cout<<'.';
        }
        cout<<'|'<<endl;
    }
    cout<<'+';
    rep(i, w - 2){
        cout<<'-';
    }
    cout<<'+'<<endl;
}



Measured memory_bytes: 3212
package main

import (
	"fmt"
	"os"
)

func main() {

	days := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	var s string
	fmt.Scanf("%s", &s)
	for i, d := range days {
		if s == d {
			fmt.Printf("%d\n", 7-i)
			os.Exit(0)
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

#define int long long

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

signed main(){
    int n; cin>>n;
    vector<P> point(n);
    for(int i=0; i<n; i++){
        cin>>point[i].first>>point[i].second;
    }

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

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

    set<P> gap;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            gap.emplace(point[j].first - point[i].first, point[j].second - point[i].second);
        }
    }

    int ans = 1e9;
    for(auto i:gap){
        vector<bool> used(n, false);
        int sum = 0;
        int cnt = 0;
        while(cnt < n){
            sum++;
            bool first = true;
            int px, py;
            for(int j=0; j<n; j++){
                int nx = point[j].first;
                int ny = point[j].second;

                if(first && !used[j]){
                    first = false;
                    used[j] = true;
                    cnt++;
                    px = point[j].first;
                    py = point[j].second;
                }
                else if(!first && !used[j] && px + i.first == nx && py + i.second == ny){
                    used[j] = true;
                    cnt++;
                    px = point[j].first;
                    py = point[j].second;
                }
            }
        }

        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

int main(){
  int n;cin>>n;
  int mn=INFTY;
  int cnt=0;
  rep(i,n){
    int p;cin>>p;
    if(mn<p) continue;
    else {
      cnt++;
      mn = min(mn,p);
    } 
  }
cout<<cnt<<endl;
  return 0;
}

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

int main() {
  int a, b, c, x;
  int cnt = 0;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for (int i=0; i <= a && i <= x/500; i++) {
    int d = x;
    d = d - 500 *i;
    for (int j=0; j <= b && j <= d/100; j++) {
      int e = d;
      e = e - 100*j;
      if (e <= 50 * c) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()

    lim = 10 ** 5

    ans = 0
    for i in range(max(1, k + 1), n + 1):
        tmp1 = (i - k) * (n // i)
        tmp2 = max(n % i - max(k - 1, 0), 0) if n % i else 0
        ans += tmp1 + tmp2
        # print(i, tmp1, tmp2, ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5840
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int N = 55;
int a[N], b[N], c[N], d[N];
int n, m, q;
int ans = 0;

void rec(vector <int> v)
{
	if(v.size() == n) {
		int res = 0;
		for(int i = 0; i < q; i++) {
			if(v[b[i]] - v[a[i]] == c[i])
			res += d[i];
		}
		ans = max(ans, res);
		return;
	}
	int x = (v.size() ? v.back() : 1);
	for(int i = x; i <= m; i++) {
		v.pb(i);
		rec(v);
		v.pop_back();
	}
}
int main()
{
	boost;
	cin >> n >> m >> q;
	for(int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i], --b[i];
	}
	rec({});
	cout << ans;
}


Measured memory_bytes: 3660
n=int(input())
action=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    action.append(tmp)

dp=[[-1]*3 for i in range(n)]
dp[0][0]=action[0][0]
dp[0][1]=action[0][1]
dp[0][2]=action[0][2]

for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+action[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+action[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+action[i][2]

ans=max(dp[n-1][0],dp[n-1][1],dp[n-1][2])
print(ans)

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

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

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

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

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

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

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

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

use std::cmp;
use std::collections::BTreeSet;
use std::iter::FromIterator;

fn main() {
    input! {
        N: usize,
        A: [i32; N],
    }
    let mut A = A;
    A.sort();
    let mut prev: BTreeSet<i32> = BTreeSet::from_iter(A.into_iter());
    let mut min: i32;

    loop {
        min = *prev.iter().next().unwrap();
        if prev.len() == 1 {
            break;
        }
        prev.remove(&min);
        let mut btree = BTreeSet::new();
        for a in prev.iter() {
            if a % min != 0 {
                btree.insert(a % min);
            }
        }
        if btree.contains(&1) || btree == prev {
            min = cmp::min(min, *btree.iter().next().unwrap());
            break;
        }
        btree.insert(min);
        prev = btree;
    }
    println!("{}", min);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  ll N, K;
	cin >> N >> K;
	vector<ll> H(N);
	rep(i, N) cin >> H[i];

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

	ll sum = 0;
	rep(i, N-K) sum += H[i];

	cout << sum << endl;

  
  return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long int a[100005];
long long int abss(long long int x){
    if(x<0) return -x;
    return x;
}
int main(){
    long long int n,i,ans,sum;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    if(a[0]!=0){
        sum=a[0];ans=0;
        for(i=1;i<n;i++){
                if((sum>0&&sum+a[i]<0)||(sum<0&&sum+a[i]>0)){
                    sum+=a[i];
                }
                else{
                    ans+=(abss(sum+a[i])+1);
                    if(sum>0)   sum=-1;
                    else    sum=1;
                }
        }
       // printf("%lld\n",ans);
        long long int pree;
        sum=1;pree=abss(a[0]-sum);
        for(i=1;i<n;i++){
            if((sum>0&&sum+a[i]<0)||(sum<0&&sum+a[i]>0)){
                sum+=a[i];
            }
            else{
                pree+=(abss(sum+a[i])+1);
                if(sum>0)   sum=-1;
                else    sum=1;
            }
        }
        ans=min(ans,pree);
        //printf("%lld\n",ans);
        long long int pre=0;
        sum=-1;
        pre=abss(a[0]-sum);
        for(i=1;i<n;i++){
            if((sum>0&&sum+a[i]<0)||(sum<0&&sum+a[i]>0)){
                sum+=a[i];
            }
            else{
                pre+=(abss(sum+a[i])+1);
                if(sum>0)   sum=-1;
                else    sum=1;
            }
        }
        ans=min(ans,pre);
        printf("%lld\n",ans);
    }
    else{
        long long int pree=1;
        sum=1;
        for(i=1;i<n;i++){
            if((sum>0&&sum+a[i]<0)||(sum<0&&sum+a[i]>0)){
                sum+=a[i];
            }
            else{
                pree+=(abss(sum+a[i])+1);
                if(sum>0)   sum=-1;
                else    sum=1;
            }
        }
        long long int pre=0;
        sum=-1;pre=1;
        for(i=1;i<n;i++){
            if((sum>0&&sum+a[i]<0)||(sum<0&&sum+a[i]>0)){
                sum+=a[i];
            }
            else{
                pre+=(abss(sum+a[i])+1);
                if(sum>0)   sum=-1;
                else    sum=1;
            }
        }
        ans=min(pree,pre);
        printf("%lld\n",ans);
    }

    return 0;
}


Measured memory_bytes: 896
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let (n, q) = read_line_to_tuple!(usize, usize);

    let mut ans = (n - 2) * (n - 2);

    let (mut h, mut w) = (n, n);
    let (mut row, mut column) = (vec![n; n], vec![n; n]);
    for _ in 0..q {
        let (t, x) = read_line_to_tuple!(usize, usize);

        if t == 1 {
            if x < w {
                for y in x..w {
                    column[y] = h;
                }
                w = x;
            }
            ans -= column[x] - 2;
        } else {
            if x < h {
                for y in x..h {
                    row[y] = w;
                }
                h = x;
            }
            ans -= row[x] - 2;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 5104
#include<iostream>

uint32_t  a,b,c,x;

int main(){
    std::string str;

    int N,K;

    std::cin >> N >> K;
    std::cin>>str;
    K = K-1;

    if(str[K]=='A'){
        str[K]='a';

    }else if(str[K]=='B'){
        str[K]='b';
    }else if(str[K]=='C'){
        str[K]='c';
    }

    std::cout<<str<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int mm[1000005];
int pr[1000005];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mm[a[i]]++;
    }
    for(int i=1;i<=1000000;i++)
    {
        if(mm[i])
        {
            for(int j=2*i;j<=1000000;j+=i)
            {
                pr[j]=1;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(mm[a[i]]<2 && pr[a[i]]==0)
            ans++;
    }
    cout<<ans;

} 
    
 


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

flag = 0
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if (i*10000+j*5000+k*1000 == Y) and (i+j+k == N) and (k >= 0):
            print(i,j,k)
            flag = 1
            break
    if flag == 1:
        break

if flag == 0:
    print(-1,-1,-1)

Measured memory_bytes: 3064
A = int(input())
if A % 9 == 0 and len(str(A//9)) == 1:
    print("Yes");exit()
elif A % 8 == 0 and len(str(A//8)) == 1:
    print("Yes");exit()
elif A % 7 == 0 and len(str(A//7)) == 1:
    print("Yes");exit()
elif A % 6 == 0 and len(str(A//6)) == 1:
    print("Yes");exit()
elif A % 5 == 0 and len(str(A//5)) == 1:
    print("Yes");exit()
elif A % 4 == 0 and len(str(A//4)) == 1:
    print("Yes");exit()
elif A % 3 == 0 and len(str(A//3)) == 1:
    print("Yes");exit()
elif A % 2 == 0 and len(str(A//2)) == 1:
    print("Yes");exit()
elif A % 1 == 0 and len(str(A//1)) == 1:
    print("Yes");exit()
else:
    print("No")

Measured memory_bytes: 38528
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846264338327950L
int main(void) {
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);
    printf("%20.20Lf\n", sqrtl(rsq));

  return 0;
}

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

k = 1
if 0 in A:
	print(0)
else:
	for i in A:
		k = k * i
		if k > 10 ** 18:
			print(-1)
			break
	if k <= 10 ** 18:
		print(k)

Measured memory_bytes: 21684
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for i in range(Q)]

P = [0] * (N)
before_a = False
cnt = 0
for i in range(N):
  if before_a and S[i] == 'C':
    cnt += 1
    before_a = False
  elif S[i] == 'A':
    before_a = True
  else:
    before_a = False
  P[i] = cnt
for i in range(Q):
  print(P[LR[i][1]-1] - P[LR[i][0]-1])

Measured memory_bytes: 30704
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc := newScanner(os.Stdin)
	//var n, m int
	//fmt.Scan(&n, &m)
	n := sc.i()
	m := sc.i()
	var node [][]int = make([][]int, m+10)
	for i := 0; i < m; i++ {
		//var a, b int
		//fmt.Scan(&a, &b)
		a := sc.i()
		b := sc.i()
		node[a-1] = append(node[a-1], b-1)
		node[b-1] = append(node[b-1], a-1)
	}
	q := make([]int, 0, n)
	q = append(q, 0)
	ans := make([]int, n)
	for i := range ans {
		ans[i] = -1
	}
	for len(q) > 0 {
		x := q[0]
		q = q[1:]
		for _, dist := range node[x] {
			if ans[dist] == -1 {
				ans[dist] = x
				q = append(q, dist)
			}
		}
	}
	fmt.Println("Yes")
	for _, a := range ans[1:] {
		fmt.Println(a + 1)
	}
}

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

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

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

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

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

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

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

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


Measured memory_bytes: 17712
#include <iostream>
using namespace std;
int main()
{
    int K,A,B;
    cin>>K>>A>>B;
    bool flag=false;
    for(int i=A;i<=B;i++)
    {
        if(i%K==0)
        {
            flag = true;
            break;
        }
    }
    if(flag)
        cout<<"OK";
    else
        cout<<"NG";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string A;
  cin >> A;
  if(A=="ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)























int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    pair<int, int> event[400001];
    for(int i = 0; i < n; i++){
        int s, t, x;
        scanf("%d %d %d", &s, &t, &x);
        event[i * 2] = {s - x, x};
        event[i * 2 + 1] = {t - x, -x};
    }
    sort(event, event + 2 * n);
    event[2 * n] = {1e9 + 7, 1e9 + 7};
    auto *p = event;
    set<int> st;
    for(int i = 0; i < q; i++){
        int d;
        scanf("%d", &d);
        while(p->first <= d){
            int x = p->second;
            if(x > 0) st.insert(x);
            else st.erase(-x);
            p++;
        }
        printf("%d\n", !st.empty()? *st.begin() : -1);
    }
}

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

int main(){
  int N;
  cin >> N;
  int V[N],C[N];
  for (int i=0;i<N;i++){
    cin >> V[i];
  }
  for (int i=0;i<N;i++){
    cin >> C[i];
  }
  long long int XY=0;
  for(int i=0;i<N;i++){
    if (V[i]>C[i]){
      XY+=V[i]-C[i];
    }
  }
  cout << XY << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    string s1, s2;
    cin >> N >> s1 >> s2;
    ll ans = 0;
    ll m = 1e9 + 7;
    int prev = 0;
    int now = 0;
    for(int i = 0; i < N ;){
        if(s1[i] == s2[i]){
            // たて
            now = 1;
            i ++;
        }else if(i < N - 1 && s1[i] == s1[i + 1]){
            // よこ
            now = 2;
            i += 2;
        }
        if(prev == 0 && now == 1){
            ans = 3;
        }
        if(prev == 0 && now == 2){
            ans = 6;
        }

        if(prev == 1){
            ans = (ans * 2) % m;
        }
        if(prev == 2 && now == 2){
            ans = (ans * 3) % m;
        }

        prev = now;

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



Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define SHIRO 0
#define GRAY 1
#define KURO 2

int n,x[N][N];
int color[N],d[N],f[N],t;

void DFSsearch(int );
void dfs();

int main(){
  int i,j,k,u,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) x[i][j] = 0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      x[u][v]=1;
    }
  }
  dfs();

  return 0;
}

void DFSsearch(int u){
  int v;
  color[u] = GRAY;
  d[u]=++t;
  for(v=0;v<n;v++){
    if(x[u][v]==0) continue;
    if(color[v]==SHIRO ){
      DFSsearch(v);
    }
  }
  color[u]=KURO;
  f[u]=++t;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=SHIRO;
  }
  t=0;
  for(u=0;u<n;u++){
    if(color[u]==SHIRO) DFSsearch(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}




Measured memory_bytes: 2104
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	long double a, b;
	cin >> a >> b;

	long double ans = a * b;

	ll p = ans;
	cout << p;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 3792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.S = sc.next();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        if (!Palindrome(S)) {
        	for (int i=0; i<S.length()/2; i++) {
        		if (S.charAt(i) != S.charAt(S.length()-i-1)) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    private boolean Palindrome(String str) {	//回文か判定するメソッド
    	boolean kaibun = false;
    	StringBuilder reverses = new StringBuilder(str).reverse();
    	String reverseS = reverses.toString();
    	
    	if (str.equals(reverseS)) {
    		kaibun = true;
    	}
    	
    	return kaibun;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
#define MAX 100007
#define MOD 1000000007
typedef long long ll;

int n;
string s1,s2;
vector < int > v;
int main(){
	cin >> n;
	cin >> s1;
	cin >> s2;
	for(int i=0;i<s1.size();i++){
		if((i+1)<s1.size() && s1[i]==s1[i+1]){
			v.push_back(1);
			i++;
		}
		else v.push_back(2);
	}
	ll res=0;
	if(v[0]==1)res=6;
	else res=3;
	for(int i=0;i<v.size();i++){
		if(v[i]==2 && v[i-1]==2)res=(res << 1)%MOD;
		if(v[i]==1 && v[i-1]==2)res=(res << 1)%MOD;
		if(v[i]==1 && v[i-1]==1)res=(res * 3)%MOD;
	}
	cout << res << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  int ans = 1e6;
  for (int p = 0; p <= 100; p++) {
    int tmp = 0;
    for (auto x : v) {
      tmp += (x - p) * (x - p);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n,c = list(map(int, input().split()))
W=[]
P=[]
for _ in range(n):
    w,val = list(map(int, input().split()))
    W.append(w)
    P.append(val)
maxV = sum(P)
dp=[]
for i in range(n+1):
    dp.append([sys.maxsize]*(maxV+1))
for i in range(n+1):
    dp[i][0]=0
for i in range(1,n+1):
    for j in range(1,maxV+1):
        inc=sys.maxsize
        exc=sys.maxsize
        if j-P[i-1]>=0:
            inc=W[i-1]+dp[i-1][j-P[i-1]]
        exc=dp[i-1][j]
        dp[i][j]=min(inc,exc)
ans=0
for i in range(1,maxV+1):
    if dp[n][i]<=c:
        ans=i
print(ans)


Measured memory_bytes: 120156
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>

using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}


int main() {
	int n;
	cin >> n;
	
	vector<pair<int,int>> job(n);
	int a,b;
	
	for(int i = 0; i < n; i++) {
		cin >> a >> b;
		job.at(i) = make_pair(a,b);
	}
	
	sort(job.begin(),job.end(), compare_by_b);
	
	//cout << job.at(0).first << ", " << job.at(0).second << endl;
	
	
	int last = job.at(0).second;
	
	for (int i = 0;i < n;i++) {
		last = min(job.at(i).second, last);
		last -= job.at(i).first;
		
	//	cout << i << ": last:" << last << endl;
		
		if (last < 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;

	return 0;
}


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

using namespace std;
bool exist[1000*1000];
int main(){
	int n;
	for(int i = 0;i <= 1000;i++){
		exist[i * (i + 1) / 2] = true;
	}
	while(cin >> n, n){
		int res = 0;
		for(int i = 0;i <= 1000;i++){
			int x = i * (i + 1) / 2;
			if(exist[x + n])res++;
		}
		cout << res-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    vector<ll> x(n), y(n), v(n);
    rep(i,n){
        cin>>x[i]>>y[i];
        v[i]=i;
    }
    double res=0;
    do{
        double tmp=0;
        rep(i,n-1){
            tmp+=sqrt((x[v[i+1]]-x[v[i]])*(x[v[i+1]]-x[v[i]]) + (y[v[i+1]]-y[v[i]])*(y[v[i+1]]-y[v[i]]));
        }
        res+=tmp;
    }while(next_permutation(v.begin(), v.end()));
    ll div=1;
    rep(i,n) div*=i+1;
    cout<<fixed<<setprecision(10)<<res/div<<endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, k; cin >> n >> k;
    string s; cin >> s;

    vector<long> reward;
    vector<int> cost;

    long latest_reward = 0L; int latest_cost = 0;
    reward.push_back(latest_reward);
    cost.push_back(latest_cost);

    char prev = s[0]; int counter = 1;

    for(auto itr = s.begin()+1;itr!=s.end();++itr) {
        if(prev != *itr) {
            latest_reward += counter;
            if(prev=='0') {
                ++latest_cost;                
            }
            reward.push_back(latest_reward);
            cost.push_back(latest_cost);

            counter = 0;
        }
        ++counter;
        prev = *itr;
    }

    latest_reward += counter;
    if(prev=='0') {
        ++latest_cost;                
    }
    reward.push_back(latest_reward);
    cost.push_back(latest_cost);

    int max_array = reward.size();
    int head, tail, offset;
    long max_reward;
    
    if(cost[1]==0) {
        head = 2;
    }
    else {
        head=1;
    }
    max_reward = reward[head-1];

    for(;head<max_array;++head) {
        if(cost[head-1]<cost[head]) {
            offset = 0;
        } else {
            offset = 1;
        }
        tail = max(0, head-2*k-offset);
        max_reward = max(max_reward, reward[head]-reward[tail]);
    }

    cout << max_reward << endl;
    

    return 0;
}


Measured memory_bytes: 2164
import sys
import numpy as np
from itertools import permutations, combinations
def input(): return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    li = list(permutations(range(1, n+1)))
    li.sort()
    print(abs(li.index(p)-li.index(q)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 31936
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

class PriorityQueue{
    heap
    constructor(){
        this.heap = []
    }
    push(x){
        let i = this.heap.length
        let j
        while(i){
            j = i-1 >>1
            if(this.heap[j] <= x) break
            this.heap[i] = this.heap[j]
            i = j
        }
        this.heap[i] = x
    }
    pop(){
        let r = this.heap[0]
        let x = this.heap.pop()
        let i = 0
        let k = this.heap.length >> 1
        let j 
        while(i<k){
            j = (i<<1) + 1
            if(this.heap[j+1] < this.heap[j]) ++j
            if(x<= this.heap[j]) break
            this.heap[i] = this.heap[j]
            i = j
        }
        if(this.heap.length) this.heap[i] = x
        return r
    }
    size(){
        return this.heap.length
    }
    top(){
        return this.heap[0]
    }
}

const Main = () => {
    let [N, M] = nextIntArray()
    const a = nextIntArray()
    a.sort((a,b) => b-a)
    let pq = new PriorityQueue()
    for(let i = 0;i<a.length;i++){
        pq.push(-a[i])
    }
    while(M>0){
        let tmp = -pq.pop()
        tmp = Math.floor(tmp/2)
        pq.push(-tmp)
        M--
    }
  let sum = 0
    while(pq.size()>0){
        sum += -pq.pop()
    }
    console.log(sum)
}
Main()



Measured memory_bytes: 46100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int countMin = 999;
  cin >> N;
  
  for ( int i = 0; i < N; i++) {
    int num;
    int counttmp;
    cin >> num;
    counttmp = 0;
    
    for ( int j = 1; j < 31; j++) {
      if ( num % 2 != 0 ) break;
      counttmp++;
      num = num / 2;
    }
    if ( countMin > counttmp ) {
      countMin = counttmp;
    }
  }
  cout << countMin << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            long a = NextLong, b = NextLong, c = NextLong, k = NextLong;

            if (k <= a)
            {
                System.Console.WriteLine(k);
            }
            else if (k <= a + b)
            {
                System.Console.WriteLine(a);
            }
            else
            {
                System.Console.WriteLine(a - (k - a - b));
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27888