akhauriyash/Code-Regression huggingface dataset:
def mod_combination(n, k, mod = 10 ** 9 + 7):
    def extended_gcd(a, b):
        if b == 0:
            return (a, 1, 0)
        d, x, y = extended_gcd(b, a % b)
        return (d, y, x - (a // b) * y)
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % mod
    for i in range(2, k + 1):
        q = (q * i) % mod
    return p * (extended_gcd(q, mod)[1] % mod) % mod

mod = 10 ** 9 + 7

r1, c1, r2, c2 = map(int, input().split())

def f(i, j):
    return mod_combination(i + j, i)

print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % mod)

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

int main() {

    ll H;
    cin >> H;

    ll ans = 0;
    ll now = 1;
    while (H > 1) {
        H /= 2;
        ans += now;
        now *= 2;
    }

    cout << ans + now << endl;

    return 0;
}

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

using namespace std;

int main() {

    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;

    if( (e - a) > k){
    	cout << ":(" << endl;
    }else{
    	cout << "Yay!" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define inf 100000000
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int main(){
    int N,T;
    cin >>N>>T;
    int ans=inf;
    rep(i,N){
        int c,t;
        cin >>c>>t;
        if (T<t)
            continue;
        chmin(ans,c);
    }
    if (ans==inf)  cout <<"TLE";
    else cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
 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;
      return 0;
    }

Measured memory_bytes: 3636
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=MI()
    a-=1
    b-=1
    tree[a].append([b,c])
    tree[b].append([a,c])
q,k=MI()
#print(tree)
k-=1
dis=[[-1,0] for i in range(n)]
dis[k][0]=0
def dfs(x):
    for s,t in tree[x]:
        if dis[s][0]>=0:
            continue
        dis[s][0]=dis[x][0]+t
        if x==k:
            dis[s][1]=s
        else:
            dis[s][1]=x
        dfs(s)
dfs(k)
for i in range(q):
    x,y=MI()
    x-=1
    y-=1
    print(dis[x][0]+dis[y][0])

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  vector<int> d(n);
  REP(i,n){
    int in;cin>>in;
  	d[i]=in;
  }
  ll sum=0;
  REP(i,n-1){
  	FOR(j,i+1,n){
      sum+=d[i]*d[j];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
def main():
  s=input()
  ans=0
  now=0
  for i in range(0,len(s)):
    if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
      now+=1
      if ans <now:
        ans=now
    else:
      now=0
  print(ans)
    
main()

Measured memory_bytes: 9108
#include<iostream>
using namespace std;
int a[3][3], p, q, r;
int main() {
	cin >> p >> q >> r;
	a[0][0] = p; a[0][1] = q; a[1][1] = r;
	for (int i = 0; i <= 1000; i++) {
		a[0][2] = 0; a[1][0] = 0; a[1][2] = 0; a[2][0] = 0; a[2][1] = 0; a[2][2] = 0; a[0][2] = i;
		int sum = a[0][0] + a[0][1] + a[0][2];
		a[2][1] = sum - a[0][1] - a[1][1];
		a[2][2] = sum - a[0][0] - a[1][1];
		a[2][0] = sum - a[2][1] - a[2][2];
		a[1][0] = sum - a[0][0] - a[2][0];
		a[1][2] = sum - a[2][2] - a[0][2];
		if (a[0][0] + a[1][0] + a[2][0] != sum)continue;
		if (a[0][1] + a[1][1] + a[2][1] != sum)continue;
		if (a[0][2] + a[1][2] + a[2][2] != sum)continue;
		if (a[0][0] + a[0][1] + a[0][2] != sum)continue;
		if (a[1][0] + a[1][1] + a[1][2] != sum)continue;
		if (a[2][0] + a[2][1] + a[2][2] != sum)continue;
		if (a[0][0] + a[1][1] + a[2][2] != sum)continue;
		if (a[0][2] + a[1][1] + a[2][0] != sum)continue;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k)cout << ' ';
				cout << a[j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; ++i) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());

    int less = d.at(N/2-1);
    int more = d.at(N/2);

    if(less == more) {
        cout << 0 << endl;
    }else {
        cout << more - less << endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <algorithm>

using namespace std;

bool solve() {
    int N, M;
    if(!(cin >> N >> M)) return false;
    if(!N && !M) return false;

    vector<vector<int>> graph(N);
    vector<vector<int>> rev_graph(N);
    map<pair<int,int>,int> edge_dict;
    vector<int> degree(N, 0);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[b].push_back(a);
        rev_graph[a].push_back(b);
        ++degree[a];
        edge_dict[make_pair(b, a)] = i;
    }

    vector<int> dp(N, 0);
    vector<int> prev(N, -1);
    vector<bool> longest_path(N, false);
    for(int i = N-1; i >= 0; --i) {
        if(degree[i] > 0) continue;
        queue<int> q;
        q.push(i);
        while(!q.empty()) {
            const int cur = q.front();
            q.pop();
            for(int neigh : graph[cur]) {
                if(dp[neigh] < dp[cur]+1) {
                    dp[neigh] = dp[cur] + 1;
                    prev[neigh] = cur;
                }
                if(--degree[neigh] == 0) {
                    q.push(neigh);
                }
            }
        }
    }
    const int longest = *max_element(dp.begin(), dp.end());
    bitset<200010> res;
    res.set();
    for(int i = 0; i < N; ++i) {
        bitset<200010> tmp;
        if(dp[i] == longest) {
            vector<int> q[2];
            q[0].push_back(i);
            while(q[0].size() > 0) {
                q[1].clear();
                for(int cur : q[0]) {
                    for(int neigh : rev_graph[cur]) {
                        if(dp[neigh] == dp[cur] - 1) {
                            q[1].push_back(neigh);
                        }
                    }
                }
                sort(q[1].begin(), q[1].end());
                q[1].erase(unique(q[1].begin(), q[1].end()), q[1].end());
                if(q[0].size() == 1 && q[1].size() == 1) {
                    tmp[edge_dict[make_pair(q[1][0], q[0][0])]] = true;
                }
                q[0].swap(q[1]);
            }
            res &= tmp;
        }
    }
    if(res.none()) {
        cout << -1 << endl;
    } else {
        for(int i = 0; i < M; ++i) {
            if(res[i]) cout << i+1 << endl;
        }
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 24228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[3010],dp[3010][3010]={0};
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if((n-(j-i))%2==1){
                dp[i][j]=max(dp[i+1][j]+a[i],(j?dp[i][j-1]:-INF)+a[j]);
            }
            else{
                dp[i][j]=min(dp[i+1][j]-a[i],(j?dp[i][j-1]:INF)-a[j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 71936
#include<iostream>
main(){
  for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M))
    for(M=1<<31,i=s=0;i<n;s+=a[i],k<++i&&(s-=a[i-k-1])&&M<s&&(M=s))
      {
      std::cin>>a[i];
  }
}

Measured memory_bytes: 0
s=input()
lst=[]
countw=0

for i in  reversed(range(len(s))):
    if s[i]=='W':
        countw+=1
    lst.append(countw)
lst=lst[::-1]
for j in range(len(s)):
    if s[j]=='W':
        lst[j]=0
print(sum(lst))


Measured memory_bytes: 55136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i, 0, n) cin >> t[i];

    ll ans = 1;
    rep(i, 0, n) {
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 3) if (s[i] == 'R') ++ans;
    if (ans==2 && s[1]=='S') --ans;
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
    cin >> H.at(i);
  int ans = 0;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    if (i == N - 1)
    {
      ans = max(count, ans);
      break;
    }
    if (H.at(i) >= H.at(i + 1))
    {
      count++;
    }
    else
    {
      ans = max(count, ans);
      count = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define mkp(a,b) make_pair(a,b)
#define scf2(a,b) scanf("%lld%lld",&a,&b)
#define scf(a) scanf("%lld",&a)
#define pf(a) printf("%lld\n",a)
#define mx 100005
using namespace std;

ll a[mx];
ll b[mx];
ll c[mx],sum=0,ans=0,n;
ll ans1[mx];
ll ans2[mx];
ll ans3[mx];

int main()
{
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    ans1[n-1]=a[n-1],ans2[n-1]=b[n-1],ans3[n-1]=c[n-1];
    for(ll i=n-2;i>=0;i--)
    {
        ans1[i]=max(ans2[i+1],ans3[i+1])+a[i];
        ans2[i]=max(ans1[i+1],ans3[i+1])+b[i];
        ans3[i]=max(ans1[i+1],ans2[i+1])+c[i];
    }
    cout << max(ans1[0],max(ans2[0],ans3[0])) << endl;
}









Measured memory_bytes: 4992
#! usr/bin/perl

use strict;
use warnings;

chomp(my $line = <STDIN>);
my ($N,$K) = split ' ',$line;
$line = <STDIN>;
my @a = split ' ',$line;

my $result = ($N-1) / ($K-1);  
if (($N-1) % ($K-1)) {++$result;}
printf "%d\n",$result;

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

using lint = long long;

struct node {
	node *l, *r;
	lint minv, sumv, lazy;
	int lx, rx;
};
void push(node *v) { 
	if(v != nullptr && v->lazy) { 
		v->minv += v->lazy;
		v->sumv += v->lazy * (v->rx - v->lx + 1);
		if(v->l) v->l->lazy += v->lazy;
		if(v->r) v->r->lazy += v->lazy;
		v->lazy = 0;
	}
}
void update(node *v, int lx, int rx, lint delta) {
	push(v);
	if(rx < v->lx || v->rx < lx) return;
	if(lx <= v->lx && v->rx <= rx) {
		v->lazy += delta; 
		push(v);
		return;
	}
	update(v->l, lx, rx, delta);
	update(v->r, lx, rx, delta);	
	push(v->l);
	v->minv = min(v->l->minv, v->r->minv);
	v->sumv = v->l->sumv + v->r->sumv;	
}
// without propagation, way faster in practice
// void upd(node *v, int lx, int rx, lint delta) {
// 	if(rx < v->lx || v->rx < lx) return;
// 	if(v->lx == v->rx) {
// 		v->lazy += delta; 
// 		v->minv += delta;
// 		v->sumv += delta;
// 		return;
// 	}
// 	upd(v->l, lx, rx, delta);
// 	upd(v->r, lx, rx, delta);	
// 	v->minv = min(v->l->minv, v->r->minv) + v->lazy;
// 	v->sumv = v->l->sumv + v->r->sumv + v->lazy * (v->rx - v->lx + 1);		
// }
lint squery(node *v, int lx, int rx) {
	push(v);
	if(rx < v->lx || v->rx < lx) return 0;
	if(lx <= v->lx && v->rx <= rx) return v->sumv;
	return squery(v->l, lx, rx) + squery(v->r, lx, rx);
}
node *build(int lx, int rx, int delta) {
	node *v = new node();
	v->lx = lx; v->rx = rx;
	if(lx == rx) {
		v->lazy = 0;
		v->l = v->r = nullptr;
		v->sumv = delta;
	}
	else {
		v->l = build(lx, (lx + rx)/2, delta);
		v->r = build((lx + rx)/2 + 1, rx, delta);
		v->sumv = v->l->sumv + v->r->sumv;
		v->lazy = 0;
	}
	return v;
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    node *segtree = build(0, n, k);

    while(q--) {
    	int pos;
    	cin >> pos;
    	update(segtree, pos-1, pos-1, 1);
    	update(segtree, 0, n-1, -1);
    }
    for (int i = 0; i < n; ++i) {
    	cout << (squery(segtree, i, i) > 0 ? "Yes" : "No") << '\n';
    }
}

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

using namespace std;

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

	vector<int> d(n);
	for (int i = 0; i < n; i++)
	{
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());

	int ans = 0;
	n--;
	if (d.at(n / 2) < d.at(n / 2 + 1))
	{
		ans = d.at(n / 2 + 1) - d.at(n / 2);
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
 string S;
 cin>>S;
 if(S == "Sunny")cout<<"Cloudy";
 else if(S == "Rainy")cout<<"Sunny";
 else cout<<"Rainy";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
    int h,w;
    cin >> h >> w;
    char field[h][w];
    rep(i,h)
        rep(j,w)
            cin >> field[i][j];
    bool flag = true;
     rep(i,h){
        if(!flag)
            break;
        rep(j,w){
            if(field[i][j]!='#')
                continue;
            if(i!=0&&field[i-1][j]=='#')
                continue;
            if(i!=h&&field[i+1][j]=='#')
                continue;
            if(j!=0&&field[i][j-1]=='#')
                continue;
            if(j!=w&&field[i][j+1]=='#')
                continue;    
            flag = false;
        }           
     }
     if(flag) cout << "Yes" << endl;
     else cout << "No" << endl;
}



Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    vector<int> Y(M-1);
    int ans=0;

    for(int i=0;i<M;i++){
        cin >> X[i];
    }

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

    for(int i=0;i<M-1;i++){
        Y[i] = X[i+1]-X[i];
    }

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

    if(N>=M){
        cout << "0" << endl;
    }else{
        for(int i=0;i<M-N;i++){
            ans += Y[i];
        }
        cout << ans <<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int in_i(){int n;scanf("%d",&n);return n;}
double in_d(){double n;scanf("%lf",&n);return n;}
int main(void){
    int n = in_i();
    rep(i,n){
        int s = in_i(),year = in_i(),m = in_i();
        long long int ma = 0;
        rep(j,m){
            int type = in_i();
            double p = in_d();
            int tax = in_i();
            long long int money = s,t = 0;
            if(type == 0){
                rep(k,year){
                    t += (long long int)(money*p);
                    money -= (long long int)tax;
                }
            }
            else{
                rep(k,year){
                    money += (long long int)(money*p);
                    money -= (long long int)tax;
                }
            }
            ma = max(ma,money+t);
        }
        printf("%lld\n",ma);
    }
    return 0;
}

Measured memory_bytes: 1060
#include <array>
#include <cmath>
#include <cstdio>
int d, g;
std::array<int, 11> p;
std::array<int, 11> c;

int sum = 0;
int ans = 1000000;

signed main()
{
    scanf("%d", &d);
    scanf("%d", &g);
    for (int i = 0; i < d; i++) {
        scanf("%d", &p.at(i));
        scanf("%d", &c.at(i));
    }
    int tmp;
    for (int i = 0; i < static_cast<int>(std::pow(2, d)); i++) {
        int tmp_ans = 0;
        sum = 0;
        bool use = false;
        int max_num = 0;
        for (int j = 0; j < d; j++) {
            use = ((i / static_cast<int>(std::pow(2, j))) % 2 == 1 ? true : false);
            if (use) {
                sum += p.at(j) * (j + 1) * 100 + c.at(j);
                tmp_ans += p.at(j);
            } else {
                max_num = j;
            }
        }
        if (g - sum > 0) {
            tmp = ((g - sum - 1) / ((max_num + 1) * 100)) + 1;
            tmp_ans += tmp;
            if (tmp > p.at(max_num)) {
                continue;
            }
        }
        ans = (ans < tmp_ans ? ans : tmp_ans);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    long long A[100010];
    A[0] = 1;
    A[1] = 1;
    for (int i=2;i<=100000;i++) {
        A[i] = A[i-1] + A[i-2];
        A[i] %= 1000000007;
    }
    //cout << A[100000] << endl;
    
    int N;
    int M;
    int a[100010];
    cin >> N >> M;
    for (int i=0;i<M;i++) {
        cin >> a[i];
    }
    
    for (int i=1;i<M;i++) {
        if (a[i]-a[i-1]==1) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    if (M==0) {
        long long result = 1;
        result *= A[N];
        result %= 1000000007;
        cout << result << endl;
        return 0;
    }
    
    vector<int> list{};
    list.push_back(a[0]-1-0);
    for (int i=1;i<M;i++) {
        list.push_back(a[i]-a[i-1]-2);
    }
    list.push_back(N-a[M-1]-1);
    
//    for (int i=0;i<list.size();i++) {
//        cout << list[i] << endl;
//    }
    
    long long result = 1;
    for (int i=0;i<list.size();i++) {
        result *= A[list[i]];
        result %= 1000000007;
    }
    
    cout << result << endl;
    
    return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> p(M);
	vector<string> S(M);
	for(int i=0;i<M;i++)	cin >> p.at(i) >> S.at(i);

	vector<int> count(N+1,0);
	vector<bool> ok(N+1,false);
	for(int i=0;i<M;i++){
		if(ok.at(p.at(i)))	continue;
		if(S.at(i)=="WA")	count.at(p.at(i))++;
		if(S.at(i)=="AC")	ok.at(p.at(i))=true;
	}
	int ac=0;
	int wa=0;
	for(int i=0;i<N+1;i++){
		if(ok.at(i)){
			ac++;
			wa+=count.at(i);
		}
	}
	cout << ac << " " << wa << endl;

	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <string> 
#include <stack>
#include <utility>
#include <set>
using namespace std;
using P = pair<int, int>;
using PP = pair<P, P>;
using ll = long long int;
string grid[50];
string s;
int pos;
int dir; //北南東西
int dx[4] = { 0,0,1,-1 };
int dy[4] = { -1,1,0,0 };
int x, y;
set<PP> state;
bool check() {
	bool NOT = 0;
	if (s[pos] == '~') NOT = 1, pos++;
	bool ret = 0;
	if (s[pos] == 'N') {
		ret = (dir == 0) ^ NOT;
	}
	else if (s[pos] == 'S') {
		ret = (dir == 1) ^ NOT;
	}
	else if (s[pos] == 'E') {
		ret = (dir == 2) ^ NOT;
	}
	else if (s[pos] == 'W') {
		ret = (dir == 3) ^ NOT;
	}
	else if (s[pos] == 'C') {
		int nx = x + dx[dir], ny = y + dy[dir];
		ret = (grid[ny][nx] == '#') ^ NOT;
	}
	else {
		ret = !NOT;
	}
	pos++;
	return ret;
}
int main() {
	int H, W;
	cin >> H >> W;
	int sx, sy;
	int gx, gy;
	for (int i = 0; i < H; i++) {
		cin >> grid[i];
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == 's') sx = j, sy = i;
			if (grid[i][j] == 'g') gx = j, gy = i;
		}
	}
	stack<int> loop;
	pos = 0;
	dir = 0;
	x = sx, y = sy;
	cin >> s;
	int N = s.size();
	int ans = 0;
	while (pos < N) {
		PP st = PP(P(x, y), P(dir, pos));
		if (state.find(st) != state.end()) {
			cout << -1 << endl;
			return 0;
		}
		state.insert(st);
		if (x == gx && y == gy) {
			cout << ans << endl;
			return 0;
		}
		if (s[pos] == '[') {
			pos++;
			if (!check()) {
				int cnt = 1;
				while (cnt > 0) {
					if (s[pos] == '[') cnt++;
					else if (s[pos] == ']') cnt--;
					pos++;
				}
			}
		}
		else if (s[pos] == ']') {
			pos++;
		}
		else if (s[pos] == '{') {
			if (loop.empty() || loop.top() != pos) loop.push(pos);
			pos++;
			if (!check()) {
				int cnt = 1;
				while (cnt > 0) {
					if (s[pos] == '{') cnt++;
					else if (s[pos] == '}') cnt--;
					pos++;
				}
				loop.pop();
			}
		}
		else if (s[pos] == '}') {
			pos = loop.top();
		}
		else if (s[pos] == '^') {
			int nx = x + dx[dir], ny = y + dy[dir];
			if (grid[ny][nx] != '#') {
				x = nx, y = ny;
			}
			pos++;
			ans++;
		}
		else if (s[pos] == 'v') {
			int nx = x - dx[dir], ny = y - dy[dir];
			if (grid[ny][nx] != '#') {
				x = nx, y = ny;
			}
			pos++;
			ans++;
		}
		else if (s[pos] == '<') {
			if (dir == 0) dir = 3;
			else if (dir == 1) dir = 2;
			else if (dir == 2) dir = 0;
			else dir = 1;
			pos++;
			ans++;
		}
		else if (s[pos] == '>') {
			if (dir == 0) dir = 2;
			else if (dir == 1) dir = 3;
			else if (dir == 2) dir = 1;
			else if (dir == 3) dir = 0;
			pos++;
			ans++;
		}
	}
	if (x == gx && y == gy) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 79248
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb(a) push_back(a)
#define x first
#define y second
//g++-9 -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const ll ms = 1e4 + 5, base = 31, mod = 1e9 + 9;
using namespace std;

vector<char> v = {'R', 'G', 'B'};

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	int N, K, S;
	cin >> N >> K >> S;
	
	for (int i = 0; i < K; i++){
		cout << S;
		if (i != N)
			cout << " ";
	}
	
	for (int i = 0; i < N-K; i++){
		if (S+1 > 1e9)
			cout << S-1;
		else
			cout << S+1;
		if (i < N-K-1)
			cout << " ";
	}
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    ArrayList<Float> inputList = new ArrayList<>();

    while (input.ready())
    {
      inputList.add(Float.parseFloat(input.readLine()));
    }
    final float ans = getDiffHight(inputList);
    System.out.println(ans);
  }

  private static float getDiffHight(ArrayList<Float> list)
  {
    float maxHight = Float.MIN_VALUE;
    float minHight = Float.MAX_VALUE;

    for (Float each : list)
    {
      if (each > maxHight)
      {
        maxHight = each;
      }
      else if (each < minHight)
      {
        minHight = each;
      }
    }
    return maxHight - minHight;
  }
}

Measured memory_bytes: 24264
# -*- coding: utf-8 -*-

import sys
import math

def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            return False
    else:
        return True

def func():
    '''

    '''
    while True:
        l = map(int, raw_input().split())
        a = l[0]
        d = l[1]
        n = l[2]
        if a == 0 and d == 0 and n == 0:
            break
        elem = a
        count = 0
            
        while True:
            if is_prime(elem):
                count += 1
                if count == n:
                    print elem
                    break
            elem += d


if __name__ == '__main__':
    func()
    

Measured memory_bytes: 4416
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=200005;

string s;
int K;

int main() {
    //freopen("in.cpp","r",stdin);
    cin>>s>>K;
    for(int i=0;i<s.size() - 1;i++){
        if(s[i]=='a')continue;
        int ti = 26-(s[i]-'a');
        if (K>=ti){
            K -=ti;
            s[i]='a';
        } else {
            continue;
        }
    }
    K%=26;
    int n = s.size();
    s[n-1] = (s[n-1]-'a' + K)%26 + 'a';
    cout<<s<<endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if (s[0] == '1') ++cnt;
  if (s[1] == '1') ++cnt;
  if (s[2] == '1') ++cnt;
  cout << cnt << endl;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int MAX = 100010;
const int INF = 1 << 30;

vector<int> dp(MAX, INF);

int main(void){

	int N; cin >> N;
	dp[0] = 0;

	FOR(n,1,N+1){
		dp[n] = min(dp[n], 1+dp[n-1]);

		int power = 6;
		while(power <= n){
			if(n-power >= 0) dp[n] = min(dp[n], dp[n-power]+1);

			power *= 6;

		}
		power = 9;
		while(power <= n){
			if(n-power >= 0) dp[n] = min(dp[n], dp[n-power]+1);
			power *= 9;
		}

	}

	cout << dp[N] << endl;


	return 0;

}


Measured memory_bytes: 640
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import bisect


def main():
    s = input()

    b = []
    for i in range(len(s)):
        if s[i] == "B":
            b.append(i)

    b.reverse()
    ans = 0
    for i in range(len(b)):
        ans += len(s) - i - 1 - b[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11744
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } 
ll ans[2000];
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
//#define max(a,b) (a>b ? a : b)
//#define min(a,b) (a<b ? a : b)
 
const int MOD = 998244353;
const int INF = 1000002;
const double PI =4*atan(1);
const double eps = 1e-7;
const long long oo = 1e18;

int solver(const int N, const int W, vector<int> &value, vector<int> &weight){
  vector<vector<int>> dp(N+1,vector<int>(W+1, 0));
  rep(i, N){
    rep(j, W+1){
      if(j<weight[i]) dp[i+1][j]=dp[i][j];
      else{
        dp[i+1][j] = max(dp[i][j], dp[i+1][j-weight[i]]+value[i]);
      }
    }
  }
  return dp[N][W];
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> value(N), weight(N);
  rep(i, N) cin >> value[i] >> weight[i];
  cout << solver(N,W,value,weight) << endl;

}


Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
//#define max(a,b) ((a>b)?a:b)
//#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
// #define assmin(a,b) if(b<=a) { a=b; }
// #define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vll adj;
    ll height;
};

ll find(ll n, ll wt, ll nm)
{
    ll st = 1;
    ll en = nm;
    ll mid = (st) + (en - st)/2;
    while(st<=en)
    {
        if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
        {
            return mid;
        }
        else if(wt+3*(nm+mid)<n)
        {
            st = mid+1;
        }
        else
        {
            en = mid-1;
        }
        mid = (st) + (en - st)/2;
    }
    if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
    {
            return mid;
     }
    return 0;
}
bool my(pair<ll, char> p1, pair<ll, char> p2)
{
    return p1.first > p2.first;
}
ll f(ll a)
{
    return (a*a*a*a*a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    REP(i,-120,121)
    {
        REP(j,-120,121)
        {
            if(f(i) - f(j) == x)
            {
                cout<<i<<" "<<j<<"\n";
                exit(0);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

		for (int i = A; i <= B; i++)
			if (i - A < K || B - i < K)
				System.out.println(i);
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int A,B;
    cin >> A >> B;
    int cnt=1;

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

    while(((A-1)*(cnt-1)+A) < B){
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b,c;
		cin>>a>>b>>c;
		E[a].push_back(c);
		E[b].push_back(c);
	}
	
	int last = -1;
	vector<int> cnt(16,0);
	
	for(int i=0;i<N;i++){
		if(E[i].size()==1){
			if(last==-1){
				last = E[i][0];
				continue;
			}
		}
		int t=  0;
		for(int j=0;j<E[i].size();j++)t^=E[i][j];
		//cout<<t<<endl;
		cnt[t]++;
	}

	for(int i=0;i<16;i++){
		//cout<<cnt[i]<<endl;
		last ^= (cnt[i]%2)*i;
	}
//cout<<last<<endl;
	cnt[last]++;
	
	vector<int> calc(1<<16,0);
	
	for(int i=0;i<(1<<16);i++){
		int t = 0;
		for(int j=0;j<16;j++){
			if((i>>j)&1)t^=j;
		}
		calc[i] = t;
	}
	/*
	for(int i=0;i<cnt.size();i++){
		cout<<cnt[i]<<endl;
	}
	*/
	
	
	vector<vector<int>> dp(16,vector<int>(1<<16,Inf));
	dp[0][0] = 0;
	
	for(int i=0;i<15;i++){
		for(int j=0;j<(1<<16);j++){
			if(dp[i][j]==Inf)continue;
			int cost=  dp[i][j];
			cost += cnt[i+1]/2;
			if(cnt[i+1]%2==0){
				dp[i+1][j] = min(dp[i+1][j],cost);
			}
			else{
				int S = j;
				//cost++;
				for(int T = j;true;T=((T-1)&S)){
					int k = (i+1)^calc[T];
					
					if(k==0){
						dp[i+1][S^T] = min(dp[i+1][S^T],cost);
					}
					else{
						dp[i+1][S^T^(1<<k)] = min(dp[i+1][S^T^(1<<k)],cost+1);
					}

					if(T==0)break;
				}
				
			}
		}
	}
	/*
	for(int i=0;i<16;i++){
		for(int j=0;j<9;j++){
			cout<<dp[i][j]<<',';
		}
		cout<<endl;
	}
	*/
	
	int ans = Inf;
	for(int i=0;i<(1<<16);i++){
		int c = 0;
		for(int j=0;j<16;j++){
			if((i>>j)&1)c++;
		}
		c=0;
		//if(dp.back()[i]!=Inf)cout<<i<<endl;
		ans = min(ans,dp.back()[i]+c);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 13864
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  if (s.back() == 's') {
    s += "es";
  } else {
    s += "s";
  }
  cout << s << endl;
}

Measured memory_bytes: 3616
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <list>

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(void) {

    string S;
    cin >> S;

    vector<int> odd(2);
    vector<int> even(2);
    for(int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0) {
            even[S[i] - '0']++;
        }
        else {
            odd[S[i] - '0']++;
        }
    }

    int ans = S.length() - max(odd[0] + even[1], odd[1] + even[0]);

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


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	while(cin>>n,n){
		vector<pii> v;
		rep(i,n){
			int a,b;
			cin>>a>>b;
			v.PB(mkp(b,a));
		}
		sort(ALL(v));
		int s=0;
		bool f=true;
		rep(i,n){
			s+=v[i].S;
			if(v[i].F<s){
				f=false;
				break;
			}
		}
		if(f) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n;) {
		int r = i + 1;
		while (r < n && a[r] <= a[r - 1]) r++;
		ans = max(ans, r - i - 1);
		i = r;
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1024
// ナニソレイミワカンナイ

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Edge{
    int to, cost, cake;
};

int M, N, K, D; // cake, landmark, calorie per meter, edge
int cs[6];
std::vector<Edge> G[200];
int d[200][1<<6];

int inputTwo(){
    char c;
    scanf("%c", &c);
    
    // printf("%c: ", c);

    int i;
    if(c == 'C'){
        scanf("%d", &i);
        i -= 1;
        // printf("%d\n", i);
        return i+2;
    }else if(c == 'L'){
        scanf("%d", &i);
        i -= 1;
        // printf("%d\n", i);
        return i+M+2;
    }else if(c == 'H'){
        // puts("");
        return 0;
    }else{
        // puts("");
        return 1;
    }
}

int main(){
    while(scanf("%d %d %d %d", &M, &N, &K, &D), M || N || K || D){

        REP(i, 200){G[i].clear();}
        std::fill(&d[0][0], &d[0][0]+200*(1<<6), INF);

        REP(i, M){
            scanf("%d", cs+i);
        }

        REP(i, D){
            int u, v;
            scanf("%*c");
            u = inputTwo();
            scanf("%*c");
            v = inputTwo();
            scanf("%*c");
        
            int d;
            scanf("%d", &d);


            if(2 <= u && u < M+2){
                G[v].push_back({u, K*d, u-2});
            }else{
                G[v].push_back({u, K*d, -1});
            }
            if(2 <= v && v < M+2){
                G[u].push_back({v, K*d, v-2});
            }else{
                G[u].push_back({v, K*d, -1});
            }
        }

        // REP(i, 2+M+N){
        //     printf("%d->\n", i);
        //     for(auto e : G[i]){printf("%d\n", e.to);}
        //     puts("");
        // }

        std::priority_queue<State, std::vector<State>, std::greater<State>> q;
        q.push(mp(0, mp(0, 0)));
        d[0][0] = 0;
        
        while(!q.empty()){
            State s = q.top(); q.pop();
            int calorie = s.first, u = s.second.first, state = s.second.second;

            for(auto e : G[u]){
                int v = e.to, cost = e.cost, cake = e.cake;
                if(cake == -1){
                    if(calorie + cost < d[v][state]){
                        d[v][state] = calorie + cost;
                        q.push(mp(d[v][state], mp(v, state)));
                    }
                }else if((state >> cake & 1) == 0 && calorie + cost - cs[cake] < d[v][state | 1 << cake]){
                    d[v][state | 1 << cake] = calorie + cost - cs[cake];
                    q.push(mp(d[v][state|1<<cake], mp(v, state|1<<cake)));
                }
            }
        }

        int res = INF;
        REP(i, 1<<M){res = std::min(res, d[1][i]);}

        std::cout << res << std::endl;
    }
}

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

int keisan(int x) {
  int ret_val=0;
  while (0<x) {
    ret_val+=x%10;
    x/=10;
  }
  return ret_val;
}

int main() {
  int N; cin >>N;
  cout <<(!(N%keisan(N)) ? "Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 110;

int bubble_sort(int a[], int n) {
    int count = 0;
    for (int i = 0; i < n-1; ++i) {
        for (int j = n-1; j >= i+1; --j) {
            if (a[j] < a[j-1]) {
                int t = a[j]; a[j] = a[j-1]; a[j-1] = t;
                ++count;
            }
        }
    }
    return count;
}

int main()
{
    int N;
    cin >> N;
    int a[MAX];
    for (int i = 0; i < N; ++i) cin >> a[i];
    int count = bubble_sort(a, N);
    for (int i = 0; i < N; ++i) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl << count << endl;

    return 0;
}

Measured memory_bytes: 3100
import sys
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

h1,m1,h2,m2,k = Mi()
ans = h2*60+m2-h1*60-m1-k
print(ans)

Measured memory_bytes: 9180
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    B = list(map(int, input().split()))

    ans = [-1] * N
    for i in range(N):
        cur = -1
        for j in range(len(B)):
            if B[j] == j + 1:
                cur = B[j]

        if cur == -1:
            print(-1)
            exit()

        ans[N-i-1] = cur
        B.pop(cur-1)

    for i in ans:
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
n,m=map(int,input().split())
data = [0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='WA':
        if data[p]<10000000:
            data[p]+=1
    else:
        if data[p]<10000000:
            data[p]+=10000000

wa=0
ac=0
for i in range(n):
    if data[i]>=10000000:
        ac+=1
        wa+=data[i]-10000000
print(ac,wa)


Measured memory_bytes: 7080