akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
ll  MOD = (1e9+7);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;
    vector<Abel> dat;
    BIT(int n) : dat(n+1, UNITY_SUM) {}
    void init(int n) { dat.assign(n+1, UNITY_SUM); }

    inline void add(int a, Abel x) {
        for (int i=a; i<(int)dat.size(); i+=i & -i)
            dat[i] = dat[i] + x;
    }
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i=a; i>0; i-=i & -i)
            res = res + dat[i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sum(b-1) - sum(a-1);
    }
};

// aoj http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, Q; cin >> N >> Q;
    BIT<int> bit(N);
    for (int q=0; q<Q; ++q) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) bit.add(x, y);
        else cout << bit.sum(x, y+1) << endl;
    }
    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b,c,d,e,f,g;cin>>a>>b>>c>>d>>e>>f>>g;
  res=a/2*2+b+d/2*2+e/2*2;
  if(a>=1&&d>=1&&e>=1)chmax(res,(a-1)/2*2+b+(d-1)/2*2+(e-1)/2*2+3);
  cout<<res<<endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int h,w;
  string s[2000];
  cin >> h >> w;
  LOOP(i,h){
    cin >> s[i];
  }
  int wi[2000][2000]={};
  int hi[2000][2000]={};
  //横について考える wid
  LOOP(i,h){
    int left=0;
    LOOP(j,w){
      if(s[i][j]=='#'){
        if(left!=j){
          int score = j-left;
          FOR(k,left,j){
            wi[i][k]=score;
          }
        }
        left=j+1;
      }
    }
    if(left!=w){
      int score = w-left;
      FOR(k,left,w){
        wi[i][k]=score;
      }
    }
  }

  LOOP(i,w){
    int top=0;
    LOOP(j,h){
      if(s[j][i]=='#'){
        if(top!=j){
          int score = j-top;
          FOR(k,top,j){
            hi[k][i]=score;
          }
        }
        top=j+1;
      }
    }
    if(top!=h){
      int score = h-top;
      FOR(k,top,h){
        hi[k][i]=score;
      }
    }
  }

  int ans = 0;
  LOOP(i,h){
    // cerr << i << ":";
    LOOP(j,w){
      ans = max(ans, wi[i][j]+hi[i][j]);
      // cerr << wi[i][j]+hi[i][j] << " ";
    } //cerr << endl;
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
const long long INF =1LL<<60;


int main() {
  
    int n,k;
      cin>>n>>k;
	
  	ll h[110000];
  	for(int i=0;i<n;i++)cin>>h[i];
  
  	ll dp[110000];
  	for(int i=0;i<110000;i++)dp[i]=INF;
  
  	dp[0]=0;
  
  for(int i=0;i<n;i++){
  	for(int j=1;j<=k;j++){
    	chmin(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
    }
  }
  
  cout<<dp[n-1]<<endl;
    
  

	
}

Measured memory_bytes: 5264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 200003;

ll n,c[MAXN];
ll dp[MAXN];

ll lst[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;

    dp[0] = 1;
    REP1 (i,n) {
        cin >> c[i];
        dp[i] = dp[i-1];
        if (lst[c[i]] != 0 && lst[c[i]] != i-1) {
            dp[i] = (dp[i] + dp[lst[c[i]]]) % MOD;
        }
        lst[c[i]] = i;
    }
    pary(dp+1,dp+n+1);
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 4992
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a+b)%24)
    return

#B
def B():
    n, m = LI()
    ab = LIR(n)
    cd = LIR(m)
    for a, b in ab:
        ans = inf
        an = 0
        for num, cdi in enumerate(cd):
            c, d = cdi
            if ans > abs(a - c) + abs(b - d):
                ans = abs(a - c) + abs(b - d)
                an = num
        print(an+1) 
    return

#C
def C():
    n = II()
    ans = inf
    for i in range(1, int(math.sqrt(n)) + 1):
        if not n % i:
            ans = min(ans, max(int(math.log(i, 10)), int(math.log(n // i, 10))))
    print(ans+1)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

struct C{
    int s, t, x;
    bool operator< (const C b) const {
        return x < b.x;
    }
};

int main(){
    fastIO;
    int n, q;
    cin >> n >> q;
    C p[n];
    for(int i = 0 ; i < n ; i ++ ){
        cin >> p[i].s >> p[i].t >> p[i].x;
        p[i].s -= p[i].x;
        p[i].t -= p[i].x;
    }
    sort(p, p + n);
    int answ[q];
    set<pii> people;
    int vv;
    for(int i = 0 ; i < q; i ++ ){
        cin >> vv;
        answ[i] = -1;
        people.insert(mp(vv, i));
    }
    for(int i = 0 ; i < n; i ++ ){
        auto it = people.lower_bound(mp(p[i].s, -1));
        while(it != people.end()){
            if(it->fi >= p[i].t){
                break;
            }
            answ[it->se] = p[i].x;
            it=people.erase(it);
        }
    }
    for(int i = 0 ; i < q; i ++ )
        cout << answ[i] << "\n";
    return 0;
}

Measured memory_bytes: 14464
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int fa(VP &ps, int n) {
    VP lru(n), rru(n);
    lru[0] = ps[0];
    rru[n-1] = ps[n-1];
    REP(i,1,n) {
        lru[i].first = max(lru[i-1].first, ps[i].first);
        lru[i].second = min(lru[i-1].second, ps[i].second);
    }
    RREP(i,0,n-1) {
        rru[i].first = max(rru[i+1].first, ps[i].first);
        rru[i].second = min(rru[i+1].second, ps[i].second);

    }
    int ans = 0;
    REP(i,1,n) {
        int tmp = 0;
        {
            int l = lru[i-1].first, r = lru[i-1].second;
            tmp += max(0, r - l + 1);
        }
        {
            int l = rru[i].first, r = rru[i].second;
            tmp += max(0, r - l + 1);
        }
        ans = max(ans, tmp);
    }
    return ans;
}

void solve() {
    LL n;
    cin >> n;
    int l,r;
    VP ps;
    REP(i,0,n) {
        cin >> l >> r;
        ps.pb(l,r);
    }

    sort(all(ps), [](auto &l, auto &r) {
        return l.second < r.second;
    });
    int ansa = fa(ps, n);

    sort(all(ps), [](auto &l, auto &r) {
        int llen = l.second - l.first;
        int rlen = r.second - r.first;
        if (llen == rlen) return l.second < r.second;
        return llen < rlen;
    });
    int ansb = fa(ps, n);
    cout << max(ansa, ansb) << endl;
}

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

Measured memory_bytes: 2676
n = int(input())
h = list(map(int,input().split()))
h.reverse()
flg =True
for i in range(n-1):
  if h[i+1] > h[i]:
    h[i+1] -= 1
    if h[i+1] > h[i]:
      flg = False
    else:
      pass
  else:
    pass
if flg:
  print('Yes')
else:
  print('No')
  


    
    

Measured memory_bytes: 15020
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<long double> a(n);
    rep(i,n) cin>>a[i];
    long double sum = 0.0;
    rep(i,n) {
        sum += 1.0/a[i];
    }
    cout <<fixed<<setprecision(10);
    cout << 1.0/sum << endl;
    return 0;
}


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

int vis[123456], par[123456];

void dfs(vector <vector<int> > &vec, int n){
     vis[n] = 1;
     for(int i = 0; i < vec[n].size(); i++){
        if(!vis[vec[n][i]]){
           dfs(vec, vec[n][i]);
           par[vec[n][i]] = n;
        }
     }

}

int main() {
	int n;
	cin >> n;
	vector <vector<int> > vec;
	vec.resize(n+1);
	for(int i = 1; i <= n; i++){
        int ai;
        cin >> ai;
        vec[i].push_back(ai);
	}
	dfs(vec, 1);
	if(vis[2]){
       int j = 2;
       int ans = 0;
       while(j != 1){
             ans++;
             j = par[j];
       }
       cout << ans;
	}
	else{
        cout << -1;
	}
	return 0;
}


Measured memory_bytes: 11136
import sys

N = int(sys.stdin.readline().strip())
A = map(int, sys.stdin.readline().strip().split())

not_even = 0
even = 0
four = 0 # % 4 = 0

for a_i in A:
    if a_i % 4 == 0:
        four += 1
    elif a_i % 2 == 0:
        even += 1
    else:
        not_even += 1

if not_even > four + 1:
    print("No")
else:
    if not_even == four + 1:
        if even == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")

Measured memory_bytes: 11096
fn main() {
    let s = read_line();
    let n = s.trim();
    let (fst, snd) = n.split_at(1);
    let fst: i32 = fst.parse().unwrap();
    let len = n.len() as i32;
    if len == 1 {
        println!("{}", fst);
    } else if String::from(snd) == std::iter::repeat("9").take(n.len() - 1).collect::<String>() {
        println!("{}", fst + (len - 1) * 9);
    } else {
        println!("{}", (fst - 1) + (len - 1) * 9);
    }
}

fn read_line() -> String {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
main()
{
    int miss=0;
    int a[5];
    bool flg=false;
    for(int m=0;m<5;m++)
    cin >> a[m];
    for(int m=0;m<=5;m++)
    {
        flg = false;
        for(int k=0;k<5;k++)
        {
            if(a[k]==m)
            flg=true;
        }
        if(flg==false)
        {
            miss=m;
            break;
        }
    }
    cout << miss << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  long double a[n],b[n];
  for (ll i = 0; i < n; ++i){
  	cin >> a[i] >> b[i];
  }
  sort(a,a+n);
  sort(b,b+n);

  if(n % 2 == 0){
  	long double p = (a[n/2 -1] + a[n/2]) /2;
  	long double q = (b[n/2 -1] + b[n/2]) /2;
  	
  	x = (q-p)*2 + 1;
  	cr(x);
  }
  x = a[n/2];
  y = b[n/2];
  c(y-x+1);



  
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 9968
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

void bfs(vector<string> &datas, string s) {
    if (s.size() == 4) {
        datas.push_back(s);
        return;
    }
    for (int i = 0; i < 10; i++) {
        string t = s;
        t += (char) (i + '0');
        bfs(datas, t);
    }
}

bool check(vector<vector<int>> &x, string t) {
    int d = t[0] - '0';
    d = x[0][d];
    for (int i = 1; i < t.size(); i++) {
        d = x[d][t[i] - '0'];
    }
    return d == 0;
}

string getGoodString(vector<vector<int>> &x, string s) {
    int d = s[0] - '0';
    d = x[0][d];
    for (int i = 1; i < s.size(); i++) {
        d = x[d][s[i] - '0'];
    }
    s += (char) (d + '0');
    return s;
}

int main() {

    vector<vector<int>> x(10, vector<int>(10));
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> x[i][j];

    vector<string> datas;
    bfs(datas, "");

    int ans = 0;
    for (int i = 0; i < datas.size(); i++) {
        string s = datas[i];
        s = getGoodString(x, s);
        bool bad = false;
        for (int j = 0; j < 5; j++) {
            for (char k = '0'; k <= '9'; k++) {
                string t = s;
                t[j] = k;
                if (s[j] == k) continue;
                bool result = check(x, t);
                if (result)bad = true;
            }
        }
//
        for (int i = 0; i < 4; i++) {
            string t = s;
            swap(t[i], t[i + 1]);
            if (s == t) continue;
            bool result = check(x, t);
            if (result) bad = true;

        }

        if (bad) ans++;
    }

    cout << ans << endl;

}














































Measured memory_bytes: 3712
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=((ll)x*10+ch-'0')%mod;ch=getc();}
    return x*f;
}
const int MAXN=100010,M=1000000000000000000ll%mod;
int c[MAXN];int n,m;
inline int add(int x,int y){return x=x+y>=mod?x+y-mod:x+y;}
inline int mul(int x,int y){return (ll)x*y%mod;}
struct wy
{
	int f[MAXN],g[MAXN],len;
	int lin[MAXN],ver[MAXN],nex[MAXN];
	inline void add(int x,int y)
	{
		ver[++len]=y;
		nex[len]=lin[x];
		lin[x]=len;
	}
	inline void topsort()
	{
		fep(n,1,j)
		{
			go(j)c[f[tn]]=1;
			int ww=0;
			while(c[ww])++ww;
			f[j]=ww;
			go(j)c[f[tn]]=0;
		}
		int ww=M;
		rep(1,n,i)
		{
			g[f[i]]=(g[f[i]]+ww)%mod;
			ww=mul(ww,M);
			//cout<<g[f[i]]<<' '<<ww<<endl;
		}
	}
}A[3];
int main()
{
	//freopen("1.in","r",stdin);
	get(n);
	rep(0,2,i)
	{
		get(m);
		rep(1,m,j)
		{
			int get(x),get(y);
			if(x>y)swap(x,y);
			A[i].add(x,y);
		}
		A[i].topsort();
	}
	int ans=0;
	rep(0,511,i)rep(0,511,j)
	ans=add(ans,mul(mul(A[0].g[i],A[1].g[j]),A[2].g[i^j]));
	put(ans);return 0;
}


Measured memory_bytes: 8492
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, x = map(int, readline().split())
    if a*a*b/2 < x:
        tan = 2 * b / a - 2 * x / (a ** 3)
        ans = math.degrees(math.atan(tan))
        print(ans)
    else:
        tan = a * b * b / x / 2
        ans = math.degrees(math.atan(tan))
        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 77804
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> edge;
typedef vector<edge> ve;
typedef vector<ve> graph;

int main(){
  int n,m,p;
  while(cin >> n >> m >> p, n){
    graph g(n);
    for(int i=0;i<m;i++){
      int a,b,c;
      cin >> a >> b >> c;
      g[a].push_back(edge(c,b));
      g[b].push_back(edge(c,a));
    }

    vi c(p);
    for(int i=0;i<p;i++)cin >> c[i];

    vi d(n,1e9), order;
    d[0] = 0;
    priority_queue< edge,vector<edge>,greater<edge> > pq;
    pq.push(edge(0,0));

    while(pq.size()){
      int dis = pq.top().first, v = pq.top().second; pq.pop();
      if(d[v] < dis)continue;
      order.push_back(v);

      for(edge e : g[v]){
	int nxtd = dis + e.first, u = e.second;
	if(d[u] > nxtd){
	  d[u] = nxtd;
	  pq.push(edge(nxtd,u));
	}
      }
    }

    vector<long double> cnt(n,0);
    cnt[n-1] = 1;
    for(int i=order.size()-1;i>=0;i--){
      int v = order[i];
      for(edge e : g[v]){
	int dis = e.first, u = e.second;
	if(d[v] == d[u] + dis)cnt[u] += cnt[v];
      }
    }

    vector<long double> prob(n,0);
    prob[0] = 1;
    for(int i=0;i<n;i++){
      int v = order[i];

      for(edge e : g[v]){
	int nxtd = d[v] + e.first, u = e.second;
	if(d[u] == nxtd){
	  prob[u] += cnt[u] / cnt[v] * prob[v];
	}
      }
    }

    for(int i=0;i<p;i++){
      cout << fixed << setprecision(9) << prob[c[i]] << endl;
    }
    cout << endl;
  }
}

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

b=abs(A[0]-A[1])+abs(A[0]-A[2])

c=abs(A[0]-A[1])+abs(A[1]-A[2])
d=abs(A[0]-A[2])+abs(A[1]-A[2])

print(min(b,c,d))


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
 
int a,b,c,K,S,ans;
 
int main() {
	cin >> K >> S;
 
	for(a=0;a<=K;a++){
		for(b=0;b<=K;b++){
			if((S-a-b)<=K&&(S-a-b)>=0)ans++;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,m; cin >> n >> m;
    vc<pi> a(n),b(m);
    rep(i,n) cin >> a[i].first >> a[i].second;
    rep(i,m) cin >> b[i].first >> b[i].second;
    rep(i,n){
        ll mi = INF;
        int ans = 0;
        rep(j,m){
            ll cur = abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
            if(cur < mi){
                mi = cur;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    rep(i, n-2) {
        if ((p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];

void solve() {
	int i, j, n, m;

	string s;

	cin >> s;



	if (s[s.length() - 1] == 's')
	{
		cout << s << "es" << '\n' ;

	}
	else
		cout << s << "s" << '\n' ;

}







int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}







Measured memory_bytes: 10688
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int a[300000];
int main()
{
    int n,k,i,j,ci=0;
    scanf("%d%d",&k,&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,&a[n]);
    for(i=0;i<n-1;i++)
    {
        if(a[i+1]-a[i]>ci)
            ci=a[i+1]-a[i];
    }
    if(k-a[n-1]+a[0]>ci)
        ci=k-a[n-1]+a[0];
    printf("%d\n",k-ci);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

int num[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		num[x-1]^=1;
		num[y-1]^=1;
	}
	FOR(i,N) if(num[i]) return _P("NO\n");
	_P("YES\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=998244353;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す
/*---fast pow---*/
ll mod_pow(ll x,ll n){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}



//*---mint---*/
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint& operator/=(const mint& a){ (x*=a.pow(mod-2).x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  mint operator/(const mint& a)const{ return mint(*this) /= a;}
  mint pow(ll t) const {
    if(!t) return 1;
    mint res = pow(t/2);
    res *= res;
    return (t&1)?res*x:res;
  }
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
mint ex(mint x, ll t) { return x.pow(t);}
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
struct comb {
  vm f, g;
  comb(){}
  comb(int mx):f(mx+1),g(mx+1) {
    f[0] = 1;
    rep(i,1,mx) f[i] = f[i-1]*i;
    g[mx] = f[mx].pow(mod-2);
    for(int i=mx;i>0;i--) g[i-1] = g[i]*i;
  }
  mint c(int a, int b) {
    if (a < b) return 0;
    return f[a]*g[b]*g[a-b];
  }
} c(3e6);
//c.c(a,b)=>aCb mod

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint p[n+1], cc[n+1];
    p[1] = m;
    rep(i,2,n)p[i] = p[i-1] * (mint)(m-1);
    rep(i,0,n)cc[i] = c.c(n-1,i);
    rep(i,0,k)ans += cc[i] * p[n-i];
//  rep(i,0,n)cout << cc[i] << endl;
    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 53012
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int ans=0,cnt=0;
  Int n=s.size();
  for(Int i=0;i<n;i++){
    if(s[i]=='B') cnt++;
    else ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, K; cin >> N >> K;
    set<int> S;
    rep(i,K){
        int d; cin >> d;
        rep(j,d){
            int A; cin >> A;
            S.insert(A);
        }
    }
    int sum = 0;
    for(int i=1; i<=N; i++){
        if(!S.count(i)) sum++;
    }
    cout << sum << endl;
}

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

int main(){
	int i;
	int count = 0;
	while (true){
		cin >> i;
		count++;
		if (i == 0){
			break;
		}
		else {
			cout << "Case " << count << ": " << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long N;
  cin>>N;
  if(N%2==1)
    puts("0");
  else
  {
    long long ans=0;
    N/=10;
    ans=N;
    while(N)
    {
      N/=5;
      ans+=N;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int comp(const void *x, const void *y);


int main()
{
  int n, l;
  char** s;
  
  scanf("%d", &n);
  scanf("%d", &l);
  s = (char**)malloc(n * sizeof(char*));
  for (int i = 0; i < n; i++)
  {
      s[i] = (char*)malloc((l + 1) * sizeof(char));
      scanf("%s", s[i]);
  }

  qsort(s, n, sizeof(s[0]), comp);
  for (int i = 0; i < n; i++)
  {
      printf("%s", s[i]);
  }
  printf("\n");

  return 0;
}

int comp(const void *x, const void *y)
{
    return strcmp(*(char **)x, *(char **)y);
}


Measured memory_bytes: 128
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll dp[200002];
ll seg[800003];
ll query(int le,ll ri,int l,int r,int ind)
{
    if(le>r || l>ri)
    {
        return 0;
    }
    if(le<=l && ri>=r)
    {
        return seg[ind];
    }
    ll mid=(l+r)/2;
    ll a=query(le,ri,l,mid,2*ind);
    a=max(a,query(le,ri,mid+1,r,2*ind+1));
    return a;
}
void update(int in,int l,int r,int ind)
{
    if(l==r)
    {
        seg[ind]=dp[in];
    }
    else
    {
        int mid=(l+r)/2;
        if(mid>=in)
        {
            update(in,l,mid,2*ind);
        }
        else
        {
            update(in,mid+1,r,2*ind+1);
        }
        seg[ind]=max(seg[2*ind],seg[2*ind+1]);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> h(n),a(n);
    for (int i = 0; i < n; ++i)
    {
    	cin>>h[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
   	}
   	for (int i = 0; i < n; ++i)
    {
        ll a1=query(0,h[i]-1,0,n,1);
        dp[h[i]]=max(dp[h[i]],a1+a[i]);
        update(h[i],0,n,1);
    }
    ll ans=0;
    for (int i = 1; i<=n; ++i)
    {
        ans=max(dp[i],ans);
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, r, g, b, k;
	cin >> r >> g >> b >> k;
	while (g <= r) {
		g <<= 1;
		k--;
	}
	while (b <= g) {
		b <<= 1;
		k--;
	}
	if (k < 0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    ll x;
    cin >> x;

    ll p = 100;

    int ans = 0;
    while (p < x) {
        p += p / 100;
        ans++;
    }

    cout << ans;



    return 0;
}


Measured memory_bytes: 3604
S=input()
AB=int(S[:2])
CD=int(S[2:])
if  (1<=AB<=12) and  (1<=CD<=12):
    print('AMBIGUOUS')
elif (AB==0 or AB>=13) and  (1<=CD<=12):
    print('YYMM')
elif (1<=AB<=12) and (CD==0 or CD>=13):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38256
#include<stdio.h>
#define N 101
 
int main()
{
  int i,j,n,cnt=0,v,c,c_1,v_1;
  int G[N][N],col[N],d[N],pi[N],min,i2;
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++)
      G[i][j] = -1;
  }
 
  scanf("%d",&n);
 
  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&c);
    for(j = 0; j < c; j++){
      scanf("%d%d",&v_1,&c_1);
      G[v][v_1] = c_1;
    }
  }
 
  for(i=0;i<n;i++){
    col[i]=0;
    pi[i]=-1;
    d[i]=10000001;
  }
 
  d[0] = 0;
 
  while(1){
    min= 10000001;
    for(i = 0; i < n; i++){
      if(col[i] != 2 && d[i] < min){
        min= d[i];
        i2 = i;
      }
    }
    if(min== 10000001)break;
 
    col[i2] = 2;
 
 
    for(i = 0; i < n; i++){
      if(G[i2][i] != -1 && col[i] != 2 && (G[i2][i]+d[i2]) < d[i]){
        pi[i] = i2;
        d[i] = G[i2][i] + d[i2];
        col[i] = 1;
      }
    }
  }
  for(i = 0; i < n; i++)printf("%d %d\n",i,d[i]);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
struct task{
	int val,t;
}a[200001];
long long res;
bool cmp(task a,task b){
	return a.t<b.t;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].val>>a[i].t;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++){
		res+=a[i].val;
		if(res<=a[i].t) continue;
		else {
		cout<<"No";
		return 0; 	
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 1792
// taken from
// https://codeforces.com/contest/877/submission/31643563


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 1e6+20;
const int Inf = 1000000000;

int n, m, k;
string B[Maxn];
set <int> R[Maxn], C[Maxn];
vector <int> dist[Maxn];
int X1, Y1, X2, Y2;
vector <ii> Q;

void Left(int r, int c, int d)
{
	set <int>::iterator it = R[r].lower_bound(c);
	while (it != R[r].begin()) {
		it--;
		if (abs(*it - c) <= k && B[r][*it] != '@') {
			ii u = ii(r, *it); 
			dist[u.first][u.second] = d + 1; Q.push_back(u);
			C[*it].erase(r);
			R[r].erase(it++);
		} else break;
	}
}

void Up(int r, int c, int d)
{
	set <int>::iterator it = C[c].lower_bound(r);
	while (it != C[c].begin()) {
		it--;
		if (abs(*it - r) <= k && B[*it][c] != '@') {
			ii u = ii(*it, c);
			dist[u.first][u.second] = d + 1; Q.push_back(u);
			R[*it].erase(c);
			C[c].erase(it++);
		} else break;
	}
}

void Right(int r, int c, int d)
{
	set <int>::iterator it = R[r].upper_bound(c);
	while (it != R[r].end() && abs(*it - c) <= k && B[r][*it] != '@') {
		ii u = ii(r, *it);
		dist[u.first][u.second] = d + 1; Q.push_back(u);
		C[*it].erase(r);
		R[r].erase(it++);
	}
}

void Down(int r, int c, int d)
{
	set <int>::iterator it = C[c].upper_bound(r);
	while (it != C[c].end() && abs(*it - r) <= k && B[*it][c] != '@') {
		ii u = ii(*it, c);
		dist[u.first][u.second] = d + 1; Q.push_back(u);
		R[*it].erase(c);
		C[c].erase(it++);
	}
}

int main()
{
	ios::sync_with_stdio(false);

	cin>>n>>m>>k;
	cin>>X1>>Y1>>X2>>Y2;
	for (int i = 1; i <= n; i++) {
		cin>>B[i];
		B[i]="$"+B[i];
		for (int j = 1; j <= m; j++) {
			R[i].insert(j);
			C[j].insert(i);
		}
	}

	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++) dist[i].push_back(Inf);

	dist[X1][Y1]=0;
	Q.push_back(ii(X1, Y1));
	R[X1].erase(Y1); C[Y1].erase(X1);
	for (int i = 0; i < Q.size(); i++) {
		ii v = Q[i];
		int d = dist[v.first][v.second];
		if (v == ii(X2, Y2)) { printf("%d\n", d); return 0; }
		Left(v.first, v.second, d);
		Up(v.first, v.second, d);
		Right(v.first, v.second, d);
		Down(v.first, v.second, d);
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256392
import numpy as np
n,m=map(int,input().split())
x=np.ones((n,2))
y=np.ones((m,2))

for i in range(n):
    x[i]=list(map(int,input().split()))

for i in range(m):
    y[i]=list(map(int,input().split()))
    
def m_d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))

for i in range(n):
    d=[]
    for j in range(m):
        d.append(m_d(x[i],y[j]))
                 
    print(d.index(min(d))+1)
            

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};
int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int A[h][w];
    rep(i,h){
        rep(j,w){
            A[i][j]=0;
        }
    }
    int x[n],y[n],a[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>a[i];
    }

    for(int i=0;i<n;i++){
         if(a[i]==1){
            for(int j=0;j<h;j++){
                for(int k=0;k<x[i];k++){
                    A[j][k]=1;
                }
            }
        }
        else if(a[i]==2){
            for(int j=0;j<h;j++){
                for(int k=x[i];k<w;k++){
                    A[j][k]=1;
                }
            }
        }
        else if(a[i]==3){
            for(int j=0;j<y[i];j++){
                for(int k=0;k<w;k++){
                    A[j][k]=1;
                }
            }
        }
        else{
            for(int j=y[i];j<h;j++){
                for(int k=0;k<w;k++){
                    A[j][k]=1;
                }
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            //cout<<A[i][j];
            if(A[i][j]==0){
                ans++;
            }
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
  val n: Int = readLine()!!.toInt()
  val l: List<Int> = readLine()!!.split(" ").map{it.toInt()}
  var x = 1
  var cnt = 0
  for(i in l){
    when(i){
      x -> x++
      else -> cnt++
    }
  }
  println(if(cnt==n) -1 else cnt)
}


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

int gcd(int p, int q){
  if(p < q) swap(p, q);
  while(q != 0){
    int r = p % q;
    p = q;
    q = r;
  }
  return p;
}

int main(){
  int n; cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int ans = a[0];
  rep(i, n) ans = gcd(ans, a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
s = set()
for i in range(M):
    s.add(int(input()))
l = [0, 1]
for i in range(1, N+1):
    if i in s:
        l.append(0)
    else:
        tmp = (l[-1] + l[-2]) % 1000000007
        l.append(tmp)

ans = l[-1]
print(ans)

Measured memory_bytes: 11884
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_str():
    return readline().strip()


def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        if C-1 != 0:
            cmr = ((cmr * 2) + int(b)) % (C-1)
        cpr = ((cpr * 2) + int(b)) % (C+1)

    ans = []
    for i in range(N):
        t = 1
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
        else:
            x = 0
            t = 0

        while x != 0:
            x = x % bin(x).count('1')
            t += 1

        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_str()
    print(*slv(N, X), sep='\n')


if __name__ == '__main__':
    main()


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

res = 0
for i in range(N - 1):
    if A[i] + A[i + 1] > x:
        d = min(A[i + 1], max(0, A[i] + A[i + 1] - x))
        A[i + 1] -= d
        res += d
    if A[i] + A[i + 1] > x:
        d = min(A[i], max(0, A[i] + A[i + 1] - x))
        A[i] -= d
        res += d

print(res)


Measured memory_bytes: 14548
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		int diag = 0;

		int rect = 0;

		for(;sc.hasNextLine();){

			String buffer = sc.nextLine();

			Scanner scl = new Scanner(buffer.replace(',', ' '));

			int a = scl.nextInt();

			int b = scl.nextInt();

			int c = scl.nextInt();

			if(a == b){

				diag++;

			}

			if(c*c == a*a+b*b){

				rect++;

			}

		}

		System.out.println(rect);

		System.out.println(diag);

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000010
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,up,down,ans;
char s[maxn],t[maxn];
queue<int>Q;
int main()
{
	read(n);
	scanf("%s %s",s+1,t+1);
	if(strcmp(s+1,t+1)==0)
	{
		puts("0");
		return 0;
	}
	up=n,down=n;
	while(down)
	{
		while(down>1&&t[down-1]==t[down])
			down-=1;
		while(up&&(up>down||s[up]!=t[down]))
			up-=1;
		if(!up)
		{
			puts("-1");
			return 0;
		}
		while(!Q.empty()&&Q.front()-(int)Q.size()>=down)
			Q.pop();
		if(up!=down)
			Q.push(up);
		ans=max(ans,(int)Q.size()+1);
		down-=1;
	}
	printf("%d\n",ans);
    return 0;
}


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

int main() {
	int N;
	bool check = false;
	char s;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (s == 'Y') check = true;
	}
	if (check) cout << "Four" << endl;
	else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int n=0,q=0;
int A[2100];


int s(int i,int m){
  int tu=0;
  if(m==0)return 1;
  if(i>=n)return 0;
  if(s(i+1,m)==1||s(i+1,m-A[i])==1)tu=1;
  else tu=0;
  return tu;
}

int main(){
  
  int m=0;
  int M[2100];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>M[i];
    if(s(0,M[i])==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 3112