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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

ll dp[200][200];

ll comb(ll n, ll k) {
  if (dp[n][k]) return dp[n][k];
  if (n == k) return 1;
  if (k == 0) return 1;
  return dp[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> V(N);
  map<ll,ll> cnt;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
    cnt[V[i]]++;
  }
  sort(V.rbegin(), V.rend());
  double sum = 0;
  int c = 0;
  for (int i = 0; i < A; i++) {
    sum += V[i];
    if (V[i] == V[A - 1]) c++;
  }
  cout << sum / A << endl;

  ll n = cnt[V[A - 1]];
  ll ans = comb(n, c);
  if (V[A - 1] == V[0]) {
    for(ll k = 1; k < min(B - A + 1, n - c + 1); k++) {
      ans += comb(n, c + k);
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

int const N=1e5+5, M=10+5, OO = 0x3f3f3f3f;


long long  q,h,s,d,n;
long long ans;


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
//    freopen("mo3gza.txt","wt",stdout);
    cin>>q>>h>>s>>d>>n;
    pair <long double,bool> arr[]={{q*4,0},{h*2,0},{s,0},{d/2.0,1}};
    sort(arr,arr+4);
    if(arr[0].second)
    {
        ans+=(n/2)*d;
        if(n%2)
            ans+=arr[1].first;
    }
    else
        ans=arr[0].first * n;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
string S;
bool flug;

void fn(int sum,int i,string op){
	if(i==4 && flug==false){
		if(sum==7){
			REP(i,4) printf("%c%c",S[i],op[i+1]);
			print("7");
			flug=true;
		}
		return;
	}else if(flug==false){
		fn(sum+(S[i]-'0'),i+1,op);
		op[i]='-';
		fn(sum-(S[i]-'0'),i+1,op);
	}
}

int main(void){
	cin>>S;
	flug=false;
	string op="++++=";
	fn((S[0]-'0'),1,op);
	return 0;
}


Measured memory_bytes: 256
n,m,s = map(int,input().split())

uvab = [tuple(map(int,input().split())) for _ in range(m)]
cd = [tuple(map(int,input().split())) for _ in range(n)]

links = [[] for _ in range(5001 * n)]
for tmp in uvab:
    u,v,a,b = tmp
    u -= 1
    v -= 1
    for i in range(4999,0,-1):
        if(i-a >= 0):
            links[u*5001+i].append((b, v*5001+i-a))
            links[v*5001+i].append((b, u*5001+i-a))
        else:
            break
    links[u*5001+5000].append((b, v*5001+5000))
    links[v*5001+5000].append((b, u*5001+5000))

for i,tmp in enumerate(cd):
    c,d = tmp
    for j in range(5000):
        links[i*5001+j].append((d ,i*5001 + min(j+c, 5000)))

# dijkstra
import heapq
def dijkstra(links, start, n):
    inf = 10**10
    d = [inf] * (n)
    d[start] = 0
    hq = []
    used = set()
    used.add(start)
    for i in links[start]:
        heapq.heappush(hq, i)
    while(hq):
        cost,i = heapq.heappop(hq)
        if( i in used):
            continue
        d[i] = cost
        used.add(i)
        for tmp in links[i]:
            cost_next, j = tmp
            if(not j in used):
                heapq.heappush(hq, (cost+cost_next, j))
    return d

s = min(s, 5000)
d = dijkstra(links, s, 5001*n)
for i in range(1,n):
    ans = d[i*5001]
    for j in range(1,5001):
        ans = min(ans, d[i*5001+j])
    print(ans)

Measured memory_bytes: 222336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll perm(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*finv[a-b]%mod;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int S;cin>>S;
    
    make();
    
    ll ans=0;
    
    for(int i=1;i<=S/3;i++){
        ans+=comb(S-i*3+i-1,i-1);
        ans%=mod;
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vi d;
void dijkstra(v(vp) &G,int V,int s) {
// G[f][i] = P(t,c) means that from `f` to `t` 's cost is `c` 
  d = vi(V,INF);
  priority_queue<P,vp, greater<P>> que;
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int tar = p.second;
    if(d[tar] < p.first) continue;
    rep(i,sz(G[tar])) {
      P e = G[tar][i];
      if(d[e.first] > d[tar] + e.second) {
        d[e.first] = d[tar] + e.second;
        que.push(P(d[e.first],e.first));
      }
    }
  }
}
  
int main() {
  int N;
  cin >> N;
  v(vp) G(N);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(P(b,1));
    G[b].push_back(P(a,1));
  }
  dijkstra(G,N,0);
  vi fennec = d;
  dijkstra(G,N,N-1);
  vi snuke = d;
  int fsum = 0;
  int ssum = 0;
  rep(i,N) {
    if(fennec[i] <= snuke[i]) {
      fsum++;
    } else {
      ssum++;
    }
  }
  if(fsum > ssum) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}

Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int par[100005],a[100005],b[100005];
int findpar(int node)
{
	if(par[node]==node)
		return node;
	return par[node]=findpar(par[node]);
}
int main()
{
	int i,j,k;
	int n,m;
	sd(n);
	sd(m);
	for(i=0;i<n;i++)
	{
		par[i]=i;
		sd(a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	int comp=n-m;
	comp=2*(comp-1);
	if(comp==0)
	{
		printf("0\n");
		return 0;
	}
	while(m--)
	{
		sd(i);
		sd(j);
		int x=findpar(i);
		int y=findpar(j);
		par[x]=y;
		a[y]=min(a[y],a[x]);
	}
	set<int>parents;
	multiset<int>s;
	for(i=0;i<n;i++)
		parents.insert(findpar(i));
	ll ans=0;
	for(auto it:parents)
	{
		ans+=a[it];
		comp--;
		s.insert(a[it]);
	}
	for(i=0;i<n&&comp>0;i++)
	{
		if(s.find(b[i])==s.end())
		{
			ans+=b[i];
			comp--;
		}
		else
			s.erase(s.find(b[i]));
	}
	if(comp)
	{
		printf("Impossible\n");
		return 0;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10752
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
 
using namespace std;
 
int AffineCipher(int a, int b, const char c){
	return (a*(c-'a')+b)%26 + 'a';
}

int main(){
    string s, s2;
	string kw[] = {"this", "that"};
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	char decode[256];

	int n;
	getline(cin, s);
	n = atoi(s.c_str());
	const int sc = 1000;

    while(n--){
		getline(cin, s);
		string ckw[2] = {kw[0], kw[1]};
		bool found = false;
		int p;

		for(int a = 1; a < sc && !found; a+=2){
			for(int b = 0; b < 26; b++){
				for(int i = 0; i < kw[0].size();i++){
					ckw[0][i] = AffineCipher(a, b, kw[0][i]);
					ckw[1][i] = AffineCipher(a, b, kw[1][i]);
				}
				if(s.find(ckw[0]) != -1 || s.find(ckw[1]) != -1){
//					cout << a << " " << b << endl;
					for(int i = 0; i < 26; i++){
						decode[AffineCipher(a, b, alpha[i])] = alpha[i];
					}
					for(int i = 0; i < s.size(); i++){
						if(isalpha(s[i])){
							s[i] = decode[s[i]];
						}
					}
					cout << s << endl;
					found = true;
					break;
				}
			}
		}
	}
  
    return 0;
}

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

using namespace std;

typedef long long LL;

#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;
typedef tuple<int,int> T;
int main(){
    int N;
    cin>>N;
    V a(N*N,-1);
    vector<vector<T>> q(N*N);
    REP(i,N){
        int x;
        cin>>x;
        x--;
        if(x==0&&i>0){
            cout<<"No"<<endl;
            return 0;
        }
        if(x==N*N-1&&i<N-1){
            cout<<"No"<<endl;
            return 0;
        }
        REP(j,i)q[0].push_back(T(x-1,i+1));
        q[x].push_back(T(x,i+1));
        REP(j,N-i-1)q[x+1].push_back(T(N*N-1,i+1));
    }
    priority_queue<T,vector<T>,greater<T>> que;
    REP(i,N*N){
        for(auto &it:q[i])que.push(it);
        if(que.size()>0){
            int t,v;
            tie(t,v)=que.top();que.pop();
            if(t<i){
                cout<<"No"<<endl;
                return 0;
            }
            a[i]=v;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }

    }
    cout<<"Yes"<<endl;
    REP(i,N*N)cout<<(!i)+" "<<a[i];cout<<endl;
    
    return 0;
}


Measured memory_bytes: 11888
a, b, c, x, y = map(int, input().split())

max = max(x,y)

total = min(a*x + b*y, c*max*2)
if x == max:
    total = min(total, c*y*2 + (x-y)*a)
else:
    total = min(total, c*x*2 + (y-x)*b)
print(total)

Measured memory_bytes: 61884
T = 26


def score(d, c, s, t):
    total = 0
    for i in range(d):
        total += s[i][t[i]]
    return max(10**6+total, 0)


def main():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    t = [int(input()) for i in range(d)]
    last = [-1]*T
    total = 0
    for i in range(d):
        total += s[i][t[i]-1]
        last[t[i]-1] = i
        for j in range(T):
            total -= c[j] * (i - last[j])
        print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9260
require "date"

while (str = gets) != "0 0\n" do
	strArray = str.split("\s")
	month, day =  strArray[0], strArray[1]
	week = Date.new(2004, month.to_i, day.to_i).wday.to_i
	case week
		when 0 then
			puts "Sunday"
		when 1 then
			puts "Monday"
		when 2 then
			puts "Tuesday"
		when 3 then
			puts "Wednesday"
		when 4 then
			puts "Thursday"
		when 5 then
			puts "Friday"
		when 6 then
			puts "Saturday"
		else
	end
end

Measured memory_bytes: 6224
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;

vvi field(102, vi(102, 0));

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

void dfs(int c, int x, int y) {
	field[y][x] = 0;
	REP(i, 4) {
		if(c == field[y+dy[i]][x+dx[i]]) {
			dfs(c, x+dx[i], y+dy[i]);
		}
	}
}

int main() {
	int H, W;

	while(cin >> H >> W, H) {
		string str;
		REP(i, H) {
			cin >> str;
			REP(j, W) {
				field[i+1][j+1] = str[j];
			}
		}

		int num = 0;
		FOR(i, 1, H) {
			FOR(j, 1, W) {
				if(field[i][j]) {
					dfs(field[i][j], j, i);
					num++;
				}
			}
		}

		cout << num << endl;
	}

	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5, mod = 998244353;
int inv[maxn + 10], fac[maxn + 10], ifac[maxn + 10];
int pn[maxn + 10], pm[maxn + 10], ans;
int n, m;

void init() {
	fac[0] = ifac[0] = pn[0] = pm[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = i == 1 ? 1 : mod - 1ll * (mod / i) * inv[mod % i] % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
		pn[i] = 1ll * pn[i - 1] * (n + 1) % mod;
		pm[i] = 1ll * pm[i - 1] * (m + 1) % mod;
	}
}

inline int comb(int x, int y) {
	return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}

int main() {
	scanf("%d%d", &n, &m);
	init();
	for (int i = 0; i <= n && i <= m; ++i) {
		int w = 1ll * comb(n, i) % mod * comb(m, i) % mod * fac[i] % mod;
		w = 1ll * w * pm[n - i] % mod * pn[m - i] % mod;
		if (i & 1) ans = (ans - w + mod) % mod;
		else (ans += w) %= mod;
	}
	printf("%d", ans);
}


Measured memory_bytes: 9984
#include <cstdio>
#include <algorithm>
using namespace std;

int researchRoop(int *s, int *pos, int p, int min){
    int tmp;
    int rmin = 10000;
    int size = 0;
    int sum = 0;

    while(s[p]>=0){
        tmp = s[p];
        if(tmp<rmin)rmin = tmp;
        sum += tmp;
        size++;
        s[p] = -1;
        p = pos[tmp];
    }

    int ans1 = rmin + sum + (size+1)*min;
    int ans2 = (size-2)*rmin + sum;
    return std::min(ans1,ans2);
}

void quickSort(int *s, int n){
    if(n<=1)return;
    int i=0;
    int tmp;
    int key = s[n-1];
    for(int j=0;j<n;j++){
        if(s[j]>key)continue;
        if(i<j){
            tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
        i++;
    }

    quickSort(s,i-1);
    quickSort(s+i-1,n-i+1);
}

int main(){
    int w[1000];
    int s[1000];
    int pos[10001];
    int i,n,c=0;
    int min = 10000;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",w+i);
        s[i] = w[i];
        pos[w[i]] = i;
        if(w[i]<min)min=w[i];
    }
    quickSort(s,n);
    for(i=0;i<n;i++)if(s[i]==w[i])s[i]=-1;

    for(i=0;i<n;i++){
        if(s[i]<0)continue;
        c += researchRoop(s,pos,i,min);
    }

    printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 2760
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

import bisect

abc="abcdefghijklmnopqrstuvwxyz"

def main():

    r=ii()
    ans=3.141592653589793238*r*2 
    print(ans)

        
# region fastio

 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Measured memory_bytes: 65864
#include <iostream>
#include <cstdio>
using namespace std;
int n, ans;

//選択しきっていないのに答え以上か、繰り返し初期値が９を超えているなら
bool isIllegal(int pos, int sum, int before) {
    return(sum > ans || before > 9);
}
//深さ優先探索
int dfs(int pos, int sum, int before) {
    int ret = 0;
    if(pos == n) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(isIllegal(pos, sum, before)) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(pos + 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    while(cin >> n >> ans, n + ans != 0) {
        cout << dfs(0, 0, 0) << endl;
    }
    return(0);
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
 
const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
int n;
long long a[maxi];
 
 
void dfs(int x, int pred)
{
    a[x]+=a[pred];
 
    for (int i:v[x])
        if (i!=pred) dfs(i,x);
}
int main()
{
     int q;
     cin>>n>>q;
 
     for (int i=1;i<n;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         v[x].pb(y);
         v[y].pb(x);
     }
 
     while(q--)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         a[x]+=y;
     }
 
     dfs(1,0);
 
     for (int i=1;i<=n;i++)
        printf("%lld ",a[i]);
 
     printf("\n");
 
    return 0;
}
//pisacu joj pisma duga
//iz Zagore iz Drnisa
//razglednice tople s juga
//z Banata poslije Nisa
 
//ti si sunce moga neba
//tebi mogu reci
//ti si jedina od svih
//koja tajne moje cuva
//ti si moja ljubav prva <3

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

long long spf[200009];

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k;
        long long cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w,prime; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld",&n);

        long long x,y,z,mx=200007,lp,lim,tp; lim=sqrt(mx)+4;
      prime.push_back(2); sz++;

      for(lp=3; lp<=mx; lp+=2)
      {
        if(spf[lp]==0)
        {
            spf[lp]=lp; prime.push_back(lp);  sz++;

            if(lp<=lim)
            {
                y=lp << 1;

                for(tp=lp+y; tp<=mx; tp+=y)
                {
                    if(spf[tp]==0){  spf[tp]=lp;  }
                }

            }

        }

      }

      vector<long long>::iterator it;

      it=lower_bound(prime.begin(),prime.end(),n); fr=it-prime.begin();  printf("%lld\n",prime[fr]);












    return 0;
}





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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b(n + 1);
	b[0] = abs(a[0]);
	for (int i = 1; i < n; i++) {
		b[i] = abs(a[i] - a[i - 1]);
	}
	b[n] = abs(a[n - 1]);
	long long int sum = 0;
	for (int i = 0; i <= n; i++) {
		sum += (long long int)b[i];
	}
	//cout << sum << endl;
	cout << sum - b[0] - b[1] + abs(a[1]) << endl;
	for (int i = 1; i < n-1; i++) {
		cout << sum - b[i] - b[i + 1] + abs(a[i + 1] - a[i - 1]) << endl;
	}
		cout << sum - b[n - 1] - b[n] + abs(a[n - 2]) << endl;
	
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){int i,j,n,k;
long long int ans=0;
char ch;
cin>>n;
string s;
cin>>s;
int r[n+1]={0};
int g[n+1]={0};
int b[n+1]={0};
for(i=1;i<=n;i++){
    r[i]=r[i-1];
    b[i]=b[i-1];
    g[i]=g[i-1];
    if(s[i-1]=='R')r[i]++;
    if(s[i-1]=='G')g[i]++;
    if(s[i-1]=='B')b[i]++;
}
for(i=1;i<n;i++){
   for(j=i+2;j<=n;j++){
        if(s[i-1]==s[j-1])continue;
        if(s[i-1]!='R'&&s[j-1]!='R'){
            ans+=r[j]-r[i];
        if((i+j)%2)continue;
        k=(i+j)/2;
        if(s[k-1]=='R')ans--;
        }
        if(s[i-1]!='G'&&s[j-1]!='G'){
            ans+=g[j]-g[i];
        if((i+j)%2)continue;
        k=(i+j)/2;
        if(s[k-1]=='G')ans--;
        }
        if(s[i-1]!='B'&&s[j-1]!='B'){
            ans+=b[j]-b[i];
        if((i+j)%2)continue;
        k=(i+j)/2;
        if(s[k-1]=='B')ans--;
        }
   }
}cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  REP (i, n) {
    REP (j, n) cin >> a[i][j];
  }
  vector<int> dp(1 << n);
  REP (S, 1 << n) {
    REP (i, n) if (S >> i & 1) {
      REPI (j, i + 1, n) if (S >> j & 1) {
        dp[S] += a[i][j];
      }
    }
    // Sの部分集合の列挙
    for (int T = S;; T = (T - 1) & S) {
      chmax(dp[S], dp[T] + dp[S & ~T]);
      if (T == 0) break;
    }
  }
  cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	long long a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);
  	b = ((b * 100) + c);
	printf("%lld\n", (a * b) / 100);
	return 0;
}

Measured memory_bytes: 3816
S = gets.chomp

n = S.size
ans = 'Yes'
(0...n/2).each{|i|
  (ans = 'No'; break) if S[i] != S[n-i-1]
}
(0...n/4).each{|i|
  (ans = 'No'; break) if S[i] != S[(n-1)/2-i-1]
}

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;int main() {int N; cin >> N;for(int i=0;i<N;i++){int k, p, u=-1; cin >> k >> p;while(k) {k--;
u++;
if(u==p)u=0;
}cout << u+1 << endl;}return 0;}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)
		cout << c << endl;
	else if (a == c)
		cout << b << endl;
	else
		cout << a << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int n, m;
    cin >> n >> m;
    vector<tuple<int,int,int>>data(m);
    rep(i, 0, m){
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(p, y, i);
    }
    sort(data.begin(),data.end());
    vector<pii>ans(m);
    vector<int>town(n+1,0);
    rep(i, 0, m){
        int p, y, num;
        tie(p, y, num)= data[i];
        town[p]++;
        ans[num].first = p;
        ans[num].second = town[p];
    }
    rep(i, 0, m){
        cout << setw(6) << setfill('0') << ans[i].first;
        cout << setw(6) << setfill('0') << ans[i].second << endl;
    }
}

Measured memory_bytes: 3968
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
int main(){
	cin>>n>>k;
	if(k==1){
		cout<<0<<endl;
		return 0;
	}
	cout<<n-k<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s[3];
  cin >> s[0] >> s[1] >> s[2];

  rep(i, 3) {
    cout << s[i][0];
  }
  cout << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int cc[n + 1] = {};
	for (int i = 1; i < n; i++) {
		int v;
		cin >> v;
		cc[v]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << cc[i] << "\n";
	}
}


Measured memory_bytes: 4416
def main():
    import sys
    input = sys.stdin.readline

    H = int(input())

    ans = 0
    k = 1
    while True:
        if H == 1:
            ans += k
            break
        else:
            ans += k
            H //= 2
            k *= 2
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
from collections import defaultdict
s = list(input())
d = defaultdict(list)

for i in range(len(s)):
    if d[s[i]]:
        ld = i - d[s[i]][-1]
        if ld <= 2:
            print(i - ld + 1, i + 1)
            break
    d[s[i]].append(i)
else: print(-1, -1)


Measured memory_bytes: 8364
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int b,s,n,w;
	char r[100];
	while(cin>>r){
		b=0;s=0;w=0;
		for(int i=0;i<100;i++){
			switch(r[i]){
			case 'I':n=1;break;
			case 'V':n=5;break;
			case 'X':n=10;break;
			case 'L':n=50;break;
			case 'C':n=100;break;
			case 'D':n=500;break;
			case 'M':n=1000;break;
			default:w=1;
			}
			if(w)break;
			if(b!=0){
				if(n>b)s-=b;
				else s+=b;
			}
			b=n;
		}
		cout<<s+b<<endl;
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<10)
#define MODULO (1000000007)

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

int n, m;

inline int Fact(int x)
{
	long long y = 1LL;
	for (int i = 1;i <= x;i++)
	{
		y *= (long long)i;
		y %= (long long)MODULO;
	}
	return (int)y;
}

int main()
{
	scanf("%d%d", &n, &m);
	if (n > m)
	{
		swap(n, m);
	}
	if (m > n + 1)
	{
		printf("0\n");
		return 0;
	}
	if (m == n)
	{
		long long Res = (long long)Fact(n);
		Res *= Res;
		Res *= 2LL;
		printf("%d\n", (int)(Res % (long long)MODULO));
	}
	else
	{
		long long Res = (long long)Fact(n);
		Res *= Res;
		Res %= (long long)MODULO;
		Res *= (long long)m;
		printf("%d\n", (int)(Res % (long long)MODULO));
	}
	//system("pause");
	return 0;
}



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

int main() {
    int n, r;
    cin >> n >> r;
    int inner = r;
    if (n < 10) {
        inner = 100 * (10 - n) + r;
    }
    
    cout << inner << endl;
    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
#AGC21 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = input()
m = len(n)
if m == 1:
    print(int(n))
else:
    flg = False
    for i in range(1,m):
        if int(n[i]) != 9:
            flg = True
            break
    if flg:
        ans = int(n[0])-1
        ans += 9*(m-1)
        print(ans)
    else:
        print(sum(list(map(int,list(n)))))


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

void solve()
{
	ll n,m;
	cin>>n>>m;
	vector<vector<int> > v(n);
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>h[i];
	}
	for (int i = 0; i < m ;++i)
	{
		int a,b;
		cin>>a>>b;
		if(h[a-1]>=h[b-1])
			v[b-1].push_back(a-1);
		if(h[a-1]<=h[b-1])
			v[a-1].push_back(b-1);
	}
	int cn = 0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if(v[i].empty())
			cn++;
	}
	cout<<cn<<endl;
}

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

Measured memory_bytes: 7748
#include <iostream>

using namespace std;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c) {
		int s = 20 - (a + b);
		int d[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		for (int i = 0; i < 10; i++) {
			if (d[i] == a || d[i] == b || d[i] == c) {
				d[i] = 100;
			}
		}
		int counter = 0;
		for (int i = 0; i < 10; i++) {
			if (d[i] <= s) {
				counter++;
			}
		}
		double e = (double)counter / 7.0 * 100.0;
		if (e >= 50.0) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0; 
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    c++;
    int a[k+2],b[k+2];

    int add1=0;
    int t=0;
    while(add1<k&&t<n)
    {
        while(s[t]=='x')
        {
            t++;
            if(t==n)    break;
        }
        if(t==n)    break;
        a[add1++]=t;
        t+=c;
    }
    int add2=0;
    t=n-1;

    while(add2<k&&t>=0)
    {
        while(s[t]=='x')
        {
            t--;
            if(t==-1)    break;
        }
        if(t==-1)    break;
        b[add2++]=t;
        t-=c;
    }

    if(add1==add2 && add1 == k)
    {
        for(int i=0,j=add2-1;i<add1;i++,j--)
        {
            if(a[i]==b[j])  cout<<a[i]+1<<endl;
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    int count=0;
    rep(i,3){
        if(s[i]=='o') count++;
    }
    cout << 700+100*count <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N,sum=0;cin>>N;
    VI d(N);
    REP(i,N)cin>>d[i];
    REP(i,N){
        FOR(j,i+1,N){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
}


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

using namespace std;
typedef long long lint;

lint N, Y;

int main() {
    cin >> N >> Y;
    
    if(Y % 1000 != 0
       || Y < 1000 * N
       || 10000 * N < Y) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    
    // すべて千円札の場合から順に減らしていく
    //     -- 5,000 に替えると -4枚
    //     -- 10,000に替えると -9枚

    // 減らすべき枚数 D = Y / 1000 - N = 9*x + 4*y
    lint D = Y / 1000 - N , y;

    for(lint x = 0; x <= D; x++) {
        if((D - 9 * x) % 4 != 0) continue;
        y = (D - 9 * x) / 4;
        if(y < 0 || N - x - y < 0) continue;
        cout << x << " " << y << " " << N - x - y << endl;
        return 0;
    }
    
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}



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

int main() {
    int N;
    cin>>N;
    int tsuri=N%1000;
    if(tsuri>0)cout<<1000-tsuri<<endl;
    else cout<<0<<endl;
    return 0;
}

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

long long int t;

void solve() {
	string s1, s2;
	cin >> s1 >> s2;
	if (s2.substr(0, s2.length() - 1) == s1)
		cout << "Yes";
	else
		cout << "No";

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	solve();

	return 0;
}

Measured memory_bytes: 3684
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    x = 0
    for a in A:
        x ^= a

    idx = 0
    for i in range(59, -1, -1):
        if x >> i & 1 == 0:
            for j, a in enumerate(A[idx:], idx):
                if a >> i & 1:
                    break
            else:
                continue
            A[idx], A[j] = A[j], A[idx]
            for j in range(N):
                if j != idx and A[j] >> i & 1:
                    A[j] ^= a
            idx += 1

    # for a in A:
    #    print(bin(a))

    s = 0
    for a in A:
        s ^= a
    # print(f"s={bin(s)}")

    for i in range(60):
        if x >> i & 1 == 1 and s >> i & 1:
            s ^= 1 << i

    # print(x, s)
    print(x + (s << 1))



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

#define ll long long

using namespace std;

int n,m;

int s1[105]={};
int s2[105]={};


int main(){
    while(1){
        int sum1=0;
        int sum2=0;
        
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0) break;
        for(int i=0;i<n;i++){
            scanf("%d",&s1[i]);
        }
        for(int i=0;i<m;i++){
            scanf("%d",&s2[i]);
        }
        for(int i=0;i<n;i++) sum1 += s1[i];
        for(int i=0;i<m;i++) sum2 += s2[i];
    
        int d = sum1 - sum2;
        if(d & 1){
            printf("-1\n");
        }else{
            sort(s1,s1+n);
            sort(s2,s2+m);

            int judge = 0;
            int a,b;

            for(int i=0;i<m;i++){
                a = s2[i];
                b = a + d/2;
                if(b < 0 || b > 100) continue;
                for(int j=0;j<n;j++){
                    if(b == s1[j]){
                        judge = 1;
                        break;
                    }
                    if(b < s1[j]) break;
                }
                if(judge) break;
            }
            if(judge) printf("%d %d\n",b,a);
            else printf("-1\n");
        }
    }
}


Measured memory_bytes: 3292
#include<iostream>
#include<algorithm>
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	if(a.size()!=1)
	    for(int i=0;i<=a.size()-2;i++)
	        for(int j=i+1;j<=a.size()-1;j++)
	            if(a[i]>a[j]) swap(a[i],a[j]);
	if(b.size()!=1)
	    for(int i=0;i<=b.size()-2;i++)
	        for(int j=i+1;j<=b.size()-1;j++)
	            if(b[i]<b[j]) swap(b[i],b[j]);
	if(b>a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
const int no_of_chars = 256; 
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
    //cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        ll a[n][2];
        rep(i,0,n)
        {
            cin>>a[i][0]>>a[i][1];
        }
        ll x=0;
        rep(i,2,n)
        {
            if( a[i][0] == a[i][1] && a[i-1][0]==a[i-1][1] && a[i-2][0]==a[i-2][1] )
            {
                x=1;
                break;
            }
        }
        if( x )
        cout<<"Yes\n";
        else 
        cout<<"No\n";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  
  for(int i = 0; i < h + 2; i++) {
    for(int j = 0; j < w + 2; j++) {
      if (i>0 && i<h+1 && j>0 && j<w+1) {
        char c;
        cin >> c;
        cout << c;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(var,init,end) for(int var=init;var<end;var++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	FOR(i, 0, N) {
		cin >> x[i];
	}

	vector<int> y(M);
	FOR(i, 0, M) {
		cin >> y[i];
	}

	int war = 1;
	int x_max = *max_element(x.begin(), x.end());
	int y_min = *min_element(y.begin(), y.end());
	if (x_max < y_min) {
		if (X<y_min && y_min <= Y) {
			war = 0;
		}
	}
	

	if (war) {
		cout << "War";
	}
	else {
		cout << "No War";
	}

	return 0;
}

Measured memory_bytes: 256
H,W,N = map(int,input().split())
D = {}

while N:
  N-=1
  x,y = map(int,input().split())
  
  for i in range(9):
    a = (x+i%3,y+i//3)
    D[a] = D.get(a,0)+(H>=a[0]>2<a[1]<=W)

c = [list(D.values()).count(i+1) for i in range(9)]
print((H-2)*(W-2)-sum(c))

for i in range(9):
    print(c[i])

Measured memory_bytes: 171040
#include<iostream>
#include <algorithm>
using namespace std;
#define MAX_LIST 10000000 



int main(){
	bool *prime=(bool *)malloc(sizeof(bool)*MAX_LIST);
	//bool prime[MAX_LIST];
	for(int i=0;i<MAX_LIST;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<MAX_LIST;i++){
		if(prime[i]==1){ 
			for(int j=i*2;j<MAX_LIST;j=j+i){
				prime[j]=0;
			}
		}
	}
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=n;i>0;i--){
			if((prime[i]==1)
				&&(prime[i-2]==1)
				&&(prime[i-6]==1)
				&&(prime[i-8]==1)){
				ans=i;
				break;
			}
			
		}
		
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 10944
A = []
queries = [input().split() for _ in range(int(input()))]
for query in queries:
    if query[0] == "0":
        A.append(int(query[1]))
    elif query[0] == "1":
        print(A[int(query[1])])
    elif query[0] == "2":
        A.pop()


Measured memory_bytes: 59564
#include<stdio.h>
#include<string.h>
int main(){
	int n;
  	char s[100];
  	scanf("%d",&n);
  	scanf("%s",s);
  	int c=0;
  	for(int i=0;i<n;i++){
      	if(s[i]=='R') c++;
    }
  	if(c>(n-c)){
      	printf("Yes");
    }else{
      	printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
 
const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
 
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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(){
  long X,A,B;
  
  cin >> X >> A >> B;

  if( A >= B )
    cout << "delicious" << endl;
  else if( B - A  <= X )
    P("safe");
  else
    P("dangerous");

  return 0;
}

Measured memory_bytes: 256