akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, ans=0;
  cin >> n;
  /* 入力 */
  vector<int> a(n), b(n), c(n-1);
  for(int i=0;i<(n);i++){
    cin >> a.at(i);
  }
  for(int i=0;i<(n);i++){
    cin >> b.at(i);
  }
  for(int i=0;i<(n-1);i++){
  cin >> c.at(i);
  }
  /* 計算 */
  ans += accumulate(b.begin(), b.end(), 0);
  for(int i=0;i<(n-1);i++){
    if(a.at(i) == a.at(i+1)-1) ans+=  c.at(a.at(i)-1);
  }
  /* 出力 */
  cout << ans;
}

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

bool comp(vector<ll> x1, vector<ll> x2) {
  return x1[0] < x2[0];
}

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

  ll add;
  if (s == 1e9) {
    add = -1;
  } else {
    add = 1;
  }
  for (ll i = 0; i < k; i++) {
    cout << s << " ";
  }
  for (ll i = k; i < n; i++) {
    cout << s + add << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  ll L,R;
  cin>>L>>R;
  ll ans=MAX;
  Loop(i,L,R){
    Loop(j,i+1,R+1){
      ans=min(ans,(i*j)%2019);
      if(ans==0)goto skip;
    }
  }
  skip:
  putout(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7, N = 100010;
ll dp[N][4];

int main() {
    string s;
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;
    REP(i,n){
        if (s[i] == 'A' || s[i] == '?'){
            REP(j,4){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                if (j == 0) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
            }
        }
        if (s[i] == 'B' || s[i] == '?'){
            REP(j,4){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                if (j == 1) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
            }
        }
        if (s[i] == 'C' || s[i] == '?'){
            REP(j,4){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                if (j == 2) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[n][3] << endl;
    return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;

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

  cin>>n; pri1((n-1)/2);
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define INF 1e+9
#define MAX_N 200000
#define PI 3.14159265358979323846

int dp[MAX_N+1];
vector<pair<long long, long long>> inputs;

int main() {


	long long sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	long long N;
	cin >> N;
	for (long long i = 0; i < N; i++) {
		long long tmp_x, tmp_y;
		cin >> tmp_x >> tmp_y;
		if (   ((sx <= tmp_x && tmp_x <= gx) || (sx >= tmp_x && tmp_x >= gx))
			&& ((sy <= tmp_y && tmp_y <= gy) || (sy >= tmp_y && tmp_y >= gy))) {
			pair<long long, long long> tmp;
			tmp.first = tmp_x;
			if ((sx - gx) * (sy - gy) >= 0 ) tmp.second = tmp_y;
			else tmp.second = -1 * tmp_y;
			inputs.push_back(tmp);
		}
	}
	sort(inputs.begin(), inputs.end());

	fill(dp, dp + inputs.size(), INF);
	for (long long i = 0; i < inputs.size(); ++i) {
		*lower_bound(dp, dp + inputs.size(), inputs[i].second) = inputs[i].second; // 最初に見つかるinputs[i]以上の要素をinputs[i]で置き換える
	}

	long long load_num = abs(sx - gx) + abs(sy - gy);
	long long spring_num = (lower_bound(dp, dp + inputs.size(), INF) - dp);

	if (sx == gx || sy == gy) {
		double dist = load_num * 100.0;
		dist += spring_num * (PI - 2) * 10.0;
		cout << setprecision(20) << dist << endl;
	}
	else if (spring_num == min(abs(sx - gx), abs(sy - gy)) + 1) {
		double dist = load_num * 100.0;
		dist += (spring_num - 1) * (PI / 2 - 2) * 10.0 + (PI - 2) * 10.0;
		cout << setprecision(20) << dist << endl;
	}
	else {
		double dist = load_num * 100.0;
		dist += spring_num * (PI / 2 - 2) * 10.0;
		cout << setprecision(20) << dist << endl;
	}

	return 0;
}



Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int N, M;
vector<string> vec;

bool check(const string& s, string& t) {
  for(int i=0; i<N; i++) {
    bool ok = 1;
    for(int j=0; j<8; j++) {
      if(s[j] == vec[i][j] || vec[i][j] == '*') continue;
      ok = 0;
    }
    if(ok) {
      t = vec[i];
      return true;
    }
  }
  return false;
}

int main() {
  while(cin >> N >> M && (N|M)) {
    map<string, long long> mp;
    vec.clear();
    vec.resize(N);
    for(int i=0; i<N; i++) {
      cin >> vec[i];
      long long a; cin >> a;
      mp[vec[i]] = a;
    }
    
    string s;
    int ans = 0;
    for(int i=0; i<M; i++) {
      string s, t; cin >> s;
      if(check(s, t)) {
	ans += mp[t];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
from functools import reduce
from fractions import gcd
from collections import defaultdict
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    S = input()[:-1]

    l = 0
    r = 0
    for i in range(N):
        if S[i] == ".":
            r += 1
    
    ans = l + r
    for i in range(N):
        if S[i] == "#":
            l += 1
        else:
            r -= 1
        ans = min(ans, l + r)
    
    print(ans)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 5564
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range;

void main() {
    auto tmp = readln.split.to!(int[]).sort().array;
    int cnt = 0;
    while (tmp[0] != tmp[2]) {
        if (tmp[2] - tmp[0] >= 2) tmp[0] += 2;
        else {
            ++tmp[0..2];
        }
        cnt++;
        tmp = tmp.sort().array;
    }
    writeln(cnt);
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ATransfer {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int ans = c - (a - b);
            if (ans > 0) {
                out.println(ans);
            } else {
                out.println(0);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
char grid[1005][1005];
ll dp[1005][1005];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   
   int h, w;cin>>h>>w;
   repA(i,1,h){
      repA(j,1,w){
         cin>>grid[i][j];
      }
   }
   repA(i,1,h){
      if(grid[i][1]!='#')
         dp[i][1] = 1;
      else{
         dp[i][1] = 0;
         repA(l,i+1,h){
            dp[l][1] = 0;
         }
         break;
      }
   }
    repA(j,1,w){
      if(grid[1][j]!='#')
         dp[1][j] = 1;
      else{
         dp[1][j] = 0;
         repA(l,j+1,w){
            dp[1][l] = 0;
         }
         break;
      }
   }

   repA(i,2,h){
      repA(j,2,w){
         if(grid[i][j]!='#'){
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
         }
         else{
            dp[i][j] = 0;
         }
      }
   }
   
   cout<<dp[h][w];

    return 0;
}  

Measured memory_bytes: 9088
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

ll comb(ll n, ll k)
{
    ll ans = 1;
    ll i;

    if (n < k || n < 0 || k < 0)
    {
        return 0;
    }

    rep(i, 0, k)
    {
        ans *= n - i;
        ans %= MOD;
        ans *= power(i + 1, MOD - 2);
        ans %= MOD;
    }

    return ans;
}

int main(void)
{
    int n, m;

    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

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

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

    string ans="Yes";
    bool flag=true;
    for(int i=a-1; i<max(c,d)-1; i++){
        if(s[i]=='#' && s[i+1]=='#'){
            ans = "No";
            break;
        }
        if(c>d && i>=b-2 && i<d-1 && flag){
            ans = "No";
            if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
                ans="Yes";
                flag = false;
            }
        }
    }

    cout<<ans<<endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  int ans = max(0, (B-1+A-2) / (A-1));
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){
    int n,m,t;
    cin >> n >> m >> t;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int time=0,now=0;
    if(m < a[0]){
        time+=a[0]-m;
    }
    now=a[0];
    
    for(int i=1; i<n; i++){
        if(now+2*m < a[i]){
            time+=a[i]-(now+2*m);
        }
        now = a[i];
    }
    if(now+m < t){
        time+=t-(now+m);
    }
    
    cout << time << endl;
    return 0;
}

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

int main() {
  size_t w, h, x, y;
  std::cin >> w >> h >> x >> y;
  const auto is_center = (2 * x == w && 2 * y == h);
  std::cout << double(w * h) / 2.0 << ' ' << (is_center ? 1 : 0) << std::endl;
}


Measured memory_bytes: 256
N=int(input())
hcost=list(map(int,input().split()))
dp=[0]*(N+1)
dp[1]=abs(hcost[1]-hcost[0])

for i in range(2,N):
  dp[i]=min(dp[i-2]+abs(hcost[i-2]-hcost[i]),dp[i-1]+abs(hcost[i-1]-hcost[i]))
  
print(dp[N-1])


Measured memory_bytes: 20412
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

tot = 0
flag = [0]*K

for i in range(N):
    if T[i] == 'r':
        if i < K or T[i] != T[i-K]:
            tot += P
            flag[i%K] = 0
        elif flag[i%K] == 0:
            flag[i%K] = 1
        else:
            tot += P
            flag[i%K] = 0
    elif T[i] == 's':
        if i < K or T[i] != T[i-K]:
            tot += R
            flag[i%K] = 0
        elif flag[i%K] == 0:
            flag[i%K] = 1
        else:
            tot += R
            flag[i%K] = 0
    else:
        if i < K or T[i] != T[i-K]:
            tot += S
            flag[i%K] = 0
        elif flag[i%K] == 0:
            flag[i%K] = 1
        else:
            tot += S
            flag[i%K] = 0
print(tot)

Measured memory_bytes: 3956
n, m, x = map(int, input().split()) 
a = [list(map(int, input().split())) for i in range(n)]
ans = 12*(10**5) + 1
for j in range(2**n):  
    mlist = [0]*m 
    money = 0
    for k in range(n): 
        if (j >> k) & 1 == 1:
            money += a[k][0]
            for l in range(1, m+1): 
                mlist[l-1] += a[k][l]
    if min(mlist) >= x:
        ans = min(ans, money)
if ans == 12*(10**5) + 1 :
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9168
/**
*    created: 21.06.2020 01:17:11
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#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(a) (a).begin(),(a).end()
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    vector<int> ans(3, -1);

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= (N - i); j++){
            int sum = 10000 * i + 5000 * j + 1000 * (N - i - j);
            if(sum == Y){
                ans.at(0) = i;
                ans.at(1) = j;
                ans.at(2) = N - i - j;
            }
        }
    }
    cout << ans.at(0) << " " << ans.at(1) << " " << ans.at(2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[n], j=1;
  for (int i=0; i<n; i++)
    scanf("%d", a+i);
  for (int i=0; i<n; i++) {
    if (a[i] == j) j++;
  }
  if (j == 1) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", n-j+1);
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long[][] xyz = new long[N][3];
        long[][] ans = new long[N][8];
        long[] A = new long[8];
        for (int i = 0; i < N; i++) {
            xyz[i][0] = sc.nextLong();
            xyz[i][1] = sc.nextLong();
            xyz[i][2] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            ans[i][0] = xyz[i][0] + xyz[i][1] + xyz[i][2];
            ans[i][1] = xyz[i][0] + xyz[i][1] - xyz[i][2];
            ans[i][2] = xyz[i][0] - xyz[i][1] + xyz[i][2];
            ans[i][3] = xyz[i][0] - xyz[i][1] - xyz[i][2];
            ans[i][4] = -xyz[i][0] + xyz[i][1] + xyz[i][2];
            ans[i][5] = -xyz[i][0] + xyz[i][1] - xyz[i][2];
            ans[i][6] = -xyz[i][0] - xyz[i][1] + xyz[i][2];
            ans[i][7] = -xyz[i][0] - xyz[i][1] - xyz[i][2];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[0], b[0]));
        for (int i = 0; i < M; i++) {
            A[0] += ans[N - 1 - i][0];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[1], b[1]));
        for (int i = 0; i < M; i++) {
            A[1] += ans[N - 1 - i][1];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[2], b[2]));
        for (int i = 0; i < M; i++) {
            A[2] += ans[N - 1 - i][2];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[3], b[3]));
        for (int i = 0; i < M; i++) {
            A[3] += ans[N - 1 - i][3];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[4], b[4]));
        for (int i = 0; i < M; i++) {
            A[4] += ans[N - 1 - i][4];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[5], b[5]));
        for (int i = 0; i < M; i++) {
            A[5] += ans[N - 1 - i][5];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[6], b[6]));
        for (int i = 0; i < M; i++) {
            A[6] += ans[N - 1 - i][6];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[7], b[7]));
        for (int i = 0; i < M; i++) {
            A[7] += ans[N - 1 - i][7];
        }
        Arrays.sort(A);
        System.out.println(A[7]);
    }

}

Measured memory_bytes: 29176
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=300010,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
int n,i,a[N],p[N],f[N],g[N];
int main(){
	//freopen("1.out","w",stdout);
	n=read();
	for(i=1;i<=n;i++)p[a[i]=read()]=i;
	f[n]=n;for(i=n-1;i;i--)
	if(!g[i+1]){
		if(p[i]>p[i+1])g[i]=1,f[i]=i+1;
		else g[i]=g[i+1],f[i]=f[i+1];
	}else{
		if(((p[i]<p[i+1])+(p[f[i+1]]<p[i])+(p[i+1]<p[f[i+1]]))==2)
		g[i]=g[i+1],f[i]=f[i+1];else g[i]=g[i+1]+1,f[i]=i+1;
	}printf("%d\n",g[1]);
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<climits>
#define INF INT_MAX;
void merge(int*, int, int, int);
void mergeSort(int*, int, int);
int cnt=0;
int main(){
  int n;
  std::cin >> n;
  int A[n];
  for(int i=0; i<n; i++) std::cin >> A[i];
  mergeSort(A, 0, n);
  for(int i=0; i<n;i ++) std::cout << A[i] << (i != n-1 ? " " : "\n");
  std::cout << cnt << "\n";
  return 0;
}
void merge(int *A, int l, int m, int r){
  int n1=m-l, n2=r-m, i, j, L[n1+1], R[n2+1];
  for(i=0; i<n1; i++) L[i] = A[l+i];
  for(i=0; i<n2; i++) R[i] = A[m+i];
  i = j = 0, L[n1] = R[n2] = INF;
  for(int k=l;k<r;k++){
    if(L[i] <= R[j]) A[k] = L[i], i++, cnt++;
    else A[k] = R[j], j++, cnt++;
  }
}
void mergeSort(int *A, int l, int r){
  int m;
  if(l+1 < r){
    m = (l + r) / 2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m, r);
  }
}

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

#define lli long long int
#define LLI(n) lli n; scanf("%lld", &n);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes puts("Yes");
#define no puts("No");

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  LLI(a)
  LLI(b)
  double u;
  u = (double)a  + (double)b;
  u /= 2;
  a = u;
  if(u-a>=0.5) {
    a++;
  }
  printf("%lld\n", a);
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import sys

n = int(input())
a = [int(input()) for i in range(n)]

already_nums = set()
push_count = 0
i = 0
while i != 1:
    if i not in already_nums:
        already_nums.add(i)
        i = a[i]-1
        push_count += 1
    else:
        print(-1)
        sys.exit()
print(push_count)


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    cin >> n;

    vector<pii> games;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            games.emplace_back(i, j);
        }
    }

    int k = games.size();
    vector<vi> graph(k);
    vi in_degree(k, 0);
    vi dp(k, 1);

    for (int i = 0; i < n; ++i) {
        vi a(n - 1);
        for (auto& x : a) {
            cin >> x;
            --x;
        }

        for (int j = 1; j < n - 1; ++j) {
            pii x = a[j - 1] < i ? pii{a[j - 1], i} : pii{i, a[j - 1]};
            pii y = a[j] < i ? pii{a[j], i} : pii{i, a[j]};
            int idx1 = lower_bound(all(games), x) - begin(games);
            int idx2 = lower_bound(all(games), y) - begin(games);

            graph[idx1].push_back(idx2);
            ++in_degree[idx2];
        }
    }

    queue<int> q;
    for (int i = 0; i < k; ++i) {
        if (in_degree[i] == 0) {
            q.push(i);
        }
    }

    int hits = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        ++hits;

        for (int v : graph[u]) {
            dp[v] = max(dp[v], dp[u] + 1);
            if (--in_degree[v] == 0) {
                q.push(v);
            }
        }
    }

    /*
    for (int i = 0; i < k; ++i) {
        cout << games[i].first << ' ' << games[i].second << ' ' << dp[i] << '\n';
    }
    */

    if (hits < k) {
        cout << "-1\n";
    } else {
        cout << *max_element(all(dp)) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 35436
#include <string>
#include <iostream>
using namespace std;
int n, power[12];
void solve(int x, int v, string S) {
	if (v == n) { printf("%s\n", S.c_str()); return; }
	if (x == 12) return;
	solve(x + 1, v - power[x], '-' + S);
	solve(x + 1, v, '0' + S);
	solve(x + 1, v + power[x], '+' + S);
}
int main() {
	power[0] = 1;
	for (int i = 1; i < 12; i++) power[i] = power[i - 1] * 3;
	scanf("%d", &n); solve(0, 0, "");
	return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
LL dp[100002];

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  str s;
  while(cin >> s){
    str ans = "Yes";
    char c1,c2;
    int cnt1=0,cnt2=0;
    c1=s[0];
    if(s[1]!=c1){
      c2 = s[1];
      if(s[2]==c1) cnt1++;
      else if(s[2]==c2) cnt2++;
      else ans = "No";
      if(s[3]==c1&&cnt1==1) ans = "No";
      if(s[3]==c2&&cnt2==1) ans = "No";
      if(s[3]!=c1&&s[3]!=c2) ans = "No";
    }else{
      cnt2++;
      c2 = s[2];
      if(s[2]==c1) ans = "No"; 
      if(s[3]==c1) ans = "No";
      if(s[3]!=c2) ans = "No"; 
    }  


    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int dp[44];
bool dpf[44] = { false };

int fib(int n){
	if(n == 0 || n == 1) return dp[n] = 1;
	if(dpf[n] == true) return dp[n];
	dpf[n] = true;
	return dp[n] = fib(n-1)+fib(n-2);
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", fib(n));
	return 0;
}

Measured memory_bytes: 1024
import bisect as bi

li6 = [6 ** i for i in range(7)]
li9 = [9 ** i for i in range(6)]

def s69(n):
  if n < 6:
    return n
  else:
    s6 = li6[bi.bisect(li6, n)-1]
    s9 = li9[bi.bisect(li9, n)-1]
    return min(n // s6 + s69(n % s6), 1 + s69(n-s9))
  
print (s69(int(input())))

Measured memory_bytes: 3060
//#pragma Gbb optimize("Ofast") 
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<time.h>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int a[100050], b[100050];

int main()
{
	int n, m, t, l, r;
	l = r = inf;
	scanf("%d%d%d", &n, &m, &t);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), l = min(l, a[i]);
	for (int i = 1; i <= m; i++) scanf("%d", &b[i]), r = min(r, b[i]);
	int ans = l + r;
	for (int i = 1; i <= t; i++)
	{
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		ans = min(a[x] + b[y] - z, ans);
	}
	printf("%d", ans);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  if ((int)s.size() == n) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}

Measured memory_bytes: 9600
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = 0;
    let mut cnt = 0;
    for &c in s.iter() {
        if c == 'A' || c == 'T' || c == 'G' || c == 'C' {
            cnt += 1;
            ans = std::cmp::max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
a = int(input())
b = int(input())
if a == 1 and b == 2:
  print ("3")
elif a == 1 and b == 3:
  print ("2")
elif a == 2 and b == 1:
  print ("3")
elif a == 2 and b == 3:
  print ("1")
elif a == 3 and b == 1:
  print ("2")
elif a == 3 and b == 2:
  print ("1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int x[4];
    rep(i, 4) cin >> x[i];
    sort(x, x + 4);
    cout << abs((x[0] + x[3]) - (x[1] + x[2])) << endl;

    return 0;
}


Measured memory_bytes: 3216
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val n = readint()
    var cnt = IntArray(4)
    repeat(n){
        val s = read()
        if(s == "AC") cnt[0]++
        else if(s == "WA") cnt[1]++
        else if(s == "TLE") cnt[2]++
        else cnt[3]++
    }
    println("AC x ${cnt[0]}")
    println("WA x ${cnt[1]}")
    println("TLE x ${cnt[2]}")
    println("RE x ${cnt[3]}")
}



fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}



Measured memory_bytes: 57508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";


int main(){
    int n; cin >> n;
    if(1<=n & n <=99){
        if(n <= 9) cout << n << endl;
        else cout << 9 << endl;

    }else if(100<=n & n <= 9999){
        if(n <= 999) cout << 9 + n-99 << endl;
        else cout << 9 + (999-99) << endl;

    }else if(10000 <= n & n <= 99999){
        cout << 9 + 900 + (n-9999) << endl;

    }
    else cout << 90909 <<endl;
        

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int A, B; cin >> A >> B;
  if(B <= A) swap(A, B);
  cout << max(A, B) + max(max(A, B-1), A) << endl;

  return 0;
}


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

const int N = 1e5 + 2 ;
int a[N], b[N], c[N], dp[N][4] ;
int n ;

int rec(int i, int last)
{
    if(i >= n) return 0;
    if(dp[i][last] != -1) return dp[i][last] ;
    dp[i][last] = 0;
    if(last == 0)
        dp[i][last] = max(b[i] + rec(i+1, 1), c[i] + rec(i+1, 2));
    else if(last == 1)
        dp[i][last] = max(a[i] + rec(i+1, 0), c[i] + rec(i+1, 2));
    else if(last == 2)
        dp[i][last] = max(b[i] + rec(i+1, 1), a[i] + rec(i+1, 0));
    else
        dp[i][last] = max(b[i] + rec(i+1, 1), max(a[i] + rec(i+1, 0), c[i] + rec(i+1, 2)));
    return dp[i][last] ;
}

int main()
{
    cin >> n ;
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i] ;
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 3);
}


Measured memory_bytes: 7680
# include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    char color;
    scanf("%c", &color);
    if (color == 'Y'){
      printf("%s\n","Four");
      return 0;
    }
  }
  printf("%s\n","Three");
  return 0;
}


Measured memory_bytes: 128
from itertools import product

N = int(input())
A = [int(a) for a in input().split()]

count = 0
for diffs in product((-1, 0, 1), repeat=N):
    for a, d in zip(A, diffs):
        if (a % 2 == 0 and d == 0) or (a % 2 == 1 and d != 0):
            count += 1
            break

print(count)

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;

    vector<Pair> ba; // b, a
    REP(i, n) {
        ll a_in, b_in;
        cin >> a_in >> b_in;
        ba.emplace_back(b_in, a_in);
    }

    sort(ba.begin(), ba.end());
    // sort(ba.begin(), ba.end(), greater<Pair>());

    ll count = 0;
    REP(i, n) {
        count += ba[i].second;
        // COUT(count);
        if (count > ba[i].first) {
            COUT("No");
            return;
        }
    }
    COUT("Yes");

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 7424
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        
        String[] slimes = str.split("", 0);
        
        int count=0;
        for(int i=0;i<n-1;i++){
            if(! slimes[i].equals(slimes[i+1])){
                count ++;
            }
        }
        
        System.out.println(count+1);
        
    }
}


Measured memory_bytes: 32480
#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; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
//-------------------
constexpr int MX = 2e5+3;
int n;
int h[MX];
ll a[MX];

ll bit[MX];
void update(int p, ll x) {
    for(; p < MX; p+=p&-p) {
        chmax(bit[p], x);
    }
}

ll get(int p) {
    ll res = 0;
    for(; p>0; p-=p&-p) {
        chmax(res, bit[p]);
    }
    return res;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    rep(i,n) cin >> h[i];
    rep(i,n) cin >> a[i];

    rep(i,n) {
        update(h[i], get(h[i])+a[i]);
    }

    cout << get(MX-1) << endl;
    return 0;
}


Measured memory_bytes: 7548
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out, true);
		int n=in.nextInt();
		int a[]=new int[n];
		int count=0;
		for(int i=0;i<n;i++){
			a[i]=in.nextInt();
		}
		for(int i=0;i<n;i++){
			int min=i;
			
			for(int j=i;j<n;j++){
				if(a[j]<a[min]){
					min=j;
				}
			}
			if(i!=min)
				count++;
			int temp=a[i];
			a[i]=a[min];
			a[min]=temp;
		}
		for(int i=0;i<n;i++){
			if(i==n-1)
				out.printf(a[i]+"\n");
			else
				out.print(a[i]+" ");
		}
		out.println(count);
	}
}


Measured memory_bytes: 26440
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ds(n, vector<int>(n, M));
    vector<int> as(m), bs(m), cs(m);
    for(int i = 0; i < m; i++){
        cin >> as[i] >> bs[i] >> cs[i];
        as[i]--; bs[i]--;
        ds[as[i]][bs[i]] = ds[bs[i]][as[i]] = cs[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                ds[j][k] = min(ds[j][k], ds[j][i] + ds[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(ds[as[i]][bs[i]] != cs[i]){
            ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
/********************************************
 *Author*        :Kwansy
 *Created Time*  : 2018年12月22日 星期六 20时02分08秒
 * Ended  Time*  : 2018年12月22日 星期六 20时03分35秒
*********************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
    int N;
    scanf("%d", &N);
    int count = 0;
    if (N%10 == 2) count++;
    if (N/10%10 == 2) count++;
    if (N/100%10 == 2) count++;
    if (N/1000 == 2) count++;
    printf("%d", count);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    string s;cin >> s;
    vector<vector<LL>> dp(s.size()+1, vector<LL>(2));
    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i = 0;i < s.size();i++){
        int j = s.at(i)-'0';
        if(j == 1){
            dp[i+1][0] += dp[i][0] * 2;
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] += dp[i][1] * 3;
            dp[i+1][0] %= MOD;
            dp[i+1][1] %= MOD;
        }else{
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1] * 3;
            dp[i+1][0] %= MOD;
            dp[i+1][1] %= MOD;
        }
    }
    cout<<(dp[(int)s.size()][1]+dp[(int)s.size()][0])%MOD<<endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int limit=10;
int c[10][10];

void warshall_floyd(int n){
    for(int k=0;k<n;k++){ 
        for(int i=0;i<n;i++){ 
            for(int j=0;j<n;j++){ 
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
}

int main(){
    int h,w;cin>>h>>w;
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>c[i][j];
        }
    }
    warshall_floyd(10);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;cin>>a;
            if(a==-1) continue;
            ans+=c[a][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	score := []int{0, 0}
	for i := 0; i < n; i++ {
		sc.Scan()
		s := sc.Text()
		cards := strings.Split(s, " ")
		cmp := strings.Compare(cards[0], cards[1])
		if cmp == 1 {
			score[0] += 3
		} else if cmp == -1 {
			score[1] += 3
		} else {
			score[0]++
			score[1]++
		}
	}
	fmt.Println(score[0], score[1])
}



Measured memory_bytes: 1128
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
a,b = rl()
c=a%4
d=b%4
ans=0
for i in range(4-c):
    ans^=a+i
for i in range(d+1):
    ans^=b-i
print(ans)

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

using namespace std;

const int N = int(1e6);
int pref[N];
int suf[N];
int a[N];

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

	int n;

	cin >> n;

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

	for(int i = 1 ; i <= n ; i++){
		pref[i] = __gcd(a[i], pref[i - 1]);
	}

	for(int i = n ; i >= 1 ; i--){
		suf[i] = __gcd(a[i], suf[i + 1]);
	}

	int best = 0;

	for(int i = 1 ; i <= n ; i++){
		best = max(best, __gcd(pref[i - 1], suf[i + 1]));
	}

	cout << best << endl;

	return 0;
}

Measured memory_bytes: 8832
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: i32 = s.trim().parse().unwrap();
	let ans = (0..).map(|i| i * 4).take_while(|&i| i <= n).any(|i| (n - i) % 7 == 0);
	println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352