akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    deque<ll> d;
    d.push_back(a[0]);
    bool sw = true;
    if(n%2!=0) sw = false;
    for(int i=1;i<n;i++){
        if(sw){
            d.push_front(a[i]);
        }else{
            d.push_back(a[i]);
        }
        sw = !sw;
    }
    for(int i=0;i<n;i++){
        cout<<d[i]<<" ";
    }
    cout<<"\n";
    return 0;
}




Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
int solve(int i,int w,vpii &v,vvi &dp){
    if(i==-1 || w==0)return 0;
    if(v[i].ff>w){
        dp[i][w] = solve(i-1,w,v,dp);
        return dp[i][w];
    }
    if(dp[i][w]!=-1)return dp[i][w];
    dp[i][w] = max(v[i].ss+solve(i-1,w-v[i].ff,v,dp),solve(i-1,w,v,dp));
    return dp[i][w];
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w,i;
    cin>>n>>w;
    vpii v(n);
    vvi dp(n,vi(w+1,-1));
    for(i=0;i<n;i++)cin>>v[i].ff>>v[i].ss;
    cout<<solve(n-1,w,v,dp)<<endl;
    return 0;
}

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

typedef long long ll;

ll R, C, N;
map<ll, ll> Pairs;

ll pos(ll x, ll y) {
  if (y == 0) return x;
  if (x == R) return R + y;
  if (y == C) return R + C + (R - x);
  if (x == 0) return R + C + R + (C - y);
  return -1;
}
bool solve() {
  stack<ll> s;
  for (auto ab : Pairs) {
    ll a, b;
    tie(a, b) = ab;
    if (!s.empty() && s.top() == b)
      s.pop();
    else
      s.push(a);
  }
  return s.empty();
}
int main() {
  cin >> R >> C >> N;
  for (ll i = 0; i < N; ++i) {
    ll x, y, x2, y2;
    cin >> x >> y >> x2 >> y2;
    ll a = pos(x, y), b = pos(x2, y2);
    if (a < 0 || b < 0) continue;
    Pairs[a] = b;
    Pairs[b] = a;
  }
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 13568
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

int DP[10001];

//first:value, second:weight
pair<int, int> goods[101];

int main(){
    
    int N, W, ans = 0;
    scanf("%d", &N);
    scanf("%d", &W);

    for (int i = 0; i< N ; i++) {
        scanf("%d %d", &goods[i].first, &goods[i].second);
    }
    
    fill(DP, DP + 10001 , -1);
    DP[0] = 0;
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j + goods[i].second <= W; j++) {
            if (DP[j] != -1){
                DP[j + goods[i].second] = max(DP[j + goods[i].second], DP[j] + goods[i].first);
            }
        }
    }*/
    
    
    for (int i = 0; i < N; i++) {
        for (int j = W; j >=0; j--) {
            if (DP[j] != -1 && j + goods[i].second <= W){
                DP[j + goods[i].second] = max(DP[j + goods[i].second], DP[j] + goods[i].first);
            }
        }
    }
    
    for (int i = 0; i <= W; i++) {
        ans = max(ans, DP[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1248
def func(b,c,balls)
	
	if balls.length==1&&(balls[0]>b||balls[0]>c) then
		return 1
	elsif balls[0]>b&&balls[0]>c then
		return func(b,balls[0],balls[1..(balls.length-1)])+func(balls[0],c,balls[1..(balls.length-1)])
	elsif balls[0]>c then
		return func(b,balls[0],balls[1..(balls.length-1)])
	elsif balls[0]>b then
		return func(balls[0],c,balls[1..(balls.length-1)])
	else
		return 0
	end
end



n=gets.to_i
dataset=Array.new(n)
n.times{|i|
	dataset[i]=gets.chomp
}
n.times{|i|
	balls=dataset[i].split(" ").map(&:to_i)
	if func(0,0,balls)!=0 then
		dataset[i]=true
	else
		dataset[i]=false
	end
	
}
n.times{|i|
	if dataset[i] then
		puts("YES")
	else
		puts("NO")
	end
}

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

#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 EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int cnt[6001][6001];

int main(){
	int n,k;
	cin>>n>>k;
	int x[n],y[n];
	char c[n];
	REP(i,n){
		cin>>x[i]>>y[i]>>c[i];
		if(c[i]=='W'){
			y[i]+=k;
			c[i]='B';
		}
		x[i]%=2*k;
		y[i]%=2*k;
	}
	REP(i,n){
		for(int n=0;n<4;n++){
			for(int m=0;m<4;m++){
				if((n+m)%2!=0)continue;
				cnt[x[i]+n*k][y[i]+m*k]++;
				cnt[x[i]+n*k+k][y[i]+m*k]--;
				cnt[x[i]+n*k][y[i]+m*k+k]--;
				cnt[x[i]+n*k+k][y[i]+m*k+k]++;
			}
		}
	}
	for(int i=0;i<6000;i++){
		for(int j=1;j<6000;j++){
			cnt[i][j]+=cnt[i][j-1];
		}
	}
	for(int i=1;i<6000;i++){
		for(int j=0;j<6000;j++){
			cnt[i][j]+=cnt[i-1][j];
		}
	}

	/*
	for(int i=0;i<4*k;i++){
		for(int j=0;j<4*k;j++){
			cout<<cnt[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/

	int res=0;
	for(int i=0;i<6000;i++){
		for(int j=0;j<6000;j++){
			res=max(res,cnt[i][j]);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 141824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n, q, k;
  cin >> n >> k >> q;
  vector<int> a(n, k - q);
  for (int i = 0; i < q; i++) {
    int id;
    cin >> id;
    id--;
    a[id]++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
} 

Measured memory_bytes: 1024
// AtCoder Grand Contest 013
// A - Sorted Arrays

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


int N;

int main() {

    int pre_a, a;
    int ud;
    int ans;

    cin >> N;
    cin >> a;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    ud = 0;
    ans = 1;
    for (int i = 1; i < N; i++) {
        pre_a = a;
        cin >> a;
        if (ud == 0) {
            ud = a - pre_a;
        } else if ((ud > 0 && a - pre_a < 0) || (ud < 0 && a - pre_a > 0)) {
            ans++;
            ud = 0;
        }
    }

    cout << ans << endl;

    return 0;

}





Measured memory_bytes: 256
# B
# Guidebook

N = int(input())

sp_list = []

for i in range(N):
    
    sp = input().split(" ")
    sp.append(str(i+1))
    sp_list.append(sp)

#print(sp_list)

sp_list.sort(key = lambda x: -int(x[1]))
sp_list.sort(key = lambda x: x[0])

for i in sp_list:
#    print(sp_list)
    print(int(i[2]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < int > inp;
    while(n) {inp.push_back(n%10);n/=10;}
    if ((inp[0]==inp[1]&&inp[1]==inp[2])||(inp[1]==inp[2]&&inp[2]==inp[3])||(inp[0]==inp[1]&&inp[1]==inp[2]&&inp[2]==inp[3])) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<vector<int>> g;

i64 dfs(int u) {
  vector<i64> x;
  for (int v : g[u]) {
    x.push_back(dfs(v));
  }
  sort(begin(x), end(x));
  reverse(begin(x), end(x));
  i64 res = 0;
  for (i64 i = 0; i < x.size(); ++i) {
    res = max(res, x[i] + i + 1);
  }
  return res;
}

int main() {
  cin >> n;
  init_n(g, n + 1);
  for (i64 i = 2; i <= n; ++i) {
    i64 p;
    cin >> p;
    g[p].push_back(i);
  }
  i64 ans = dfs(1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13568
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp.to!(char[]).array;
  auto k = readln.chomp.to!int;
  auto c = s[k-1];
  
  foreach (ref e; s) {
    if (e != c) {
      e = '*';
    }
  }
  s.writeln;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack: 200000000)
#pragma GCC optimize("03")
//#pragma GCC target("avx2")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse, sse2, sse3, ssse3, sse4, popcnt, abm, mmx, avx, tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define ar array
#define M_PIl 3.141592653589793 
#define all(x) (x).begin(), (x).end()
#define inf int(1e9)
#define IOS ios_base::sync_with_stdio(false), cin.tie(0)

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

void solve(){
    int r;
    cin>>r;
    printf("%.20f", r * M_PIl * 2);
}

int32_t main(){
    solve();
    printf("\n");
    /* cin>>tt; */
    /* while(tt--){ */
    /*     //cout<<"Case #" << t++ << ": "; */
    /*     solve(); */
    /*     cout<<"\n"; */
    /* } */
}



Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#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())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{

int n,w;
cin>>n>>w;
long long a[n+1],wt[n+1];
rep(i,1,n+1)
cin>>wt[i]>>a[i];

long long dp[n+1][w+1];

memset(dp,0,sizeof(dp));
for(int j=1;j<=n;j++)
{
	for(int i=1;i<=w;i++)
	{
		if(wt[j]>i)
		{
		dp[j][i]=dp[j-1][i];
		}
		else
		dp[j][i]=max(dp[j-1][i],a[j]+dp[j-1][i-wt[j]]);
//	cout<<dp[j][i]<<" ";		
	}
//	cout<<endl;
}
cout<<dp[n][w] ;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define int unsigned long long
using namespace std;
int ans,a[100005],b[100005],c[100005];
signed main()
{
	int n,i;
	cin>>n;
	n++;
	for(i=1;i<=n;i++)
		cin>>a[i];
	b[1]=1;
	c[n]=a[n];
	for(i=2;i<=n;i++)
		b[i]=(b[i-1]-a[i-1])*2;
	for(i=n-1;i;i--)
		c[i]=c[i+1]+a[i];
	for(i=1;i<=n;i++)
		if(a[i]>b[i])
		{
			cout<<-1;
			return 0;
		}
	for(i=1;i<=n;i++)
		ans+=min(b[i],c[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6020
#include <iostream>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0; i<(int)(n); i++)

const int N = (int)1e5+1;

signed main() {
  int t[N], n;
  rep(i,N) t[i] = 0;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    t[a]++;
  }
  
  int q, s = 0;
  rep(i,N) s += i * t[i];
  cin >> q;
  rep(i,q) {
    int b, c;
    cin >> b >> c;
    s += (c - b) * t[b];
    t[c] += t[b];
    t[b] = 0;
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int dfs(vector<string> c, int a, int h, int w, int k) {
  if (a == h+w) {
    int s = 0;
    rep(i,h) {
      rep(j,w) {
        if (c[i][j] == '#') s++;
      }
    }
    if (s == k) return 1;
    else return 0;
  }


  vector<string> d(h);
  rep(i,h) {
    d[i] = c[i];
  }

  if (a < h) {
    rep(j,w) {
      c[a][j] = '.';
    }
    return dfs(c,a+1,h,w,k) + dfs(d,a+1,h,w,k);
  }

  else {
    rep(i,h) {
      c[i][a-h] = '.';
    }
    return dfs(c,a+1,h,w,k) + dfs(d,a+1,h,w,k);
  }

}

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) {
    cin >> c[i];
  }

  cout << dfs(c,0,h,w,k) << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	ll X,Y;
	cin>>X>>Y;

	int c=0;
	for(ll a=X; a<=Y; a<<=1){
		c++;
	}
	ote(c);
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, m):
        self.M = m + 1
        self.A = a = [True] * self.M
        a[0] = a[1] = 0
        self.T = t = []
        sq = int(math.sqrt(self.M))
        q = 0
        for i in range(2, sq + 1):
            if not a[i]:
                a[i] = q
                continue
            t.append(i)
            a[i] = q
            q += 1
            for j in range(i*i,m,i):
                a[j] = False

        for i in range(sq + 1, self.M):
            if a[i]:
                a[i] = q
                q += 1
                t.append(i)
            else:
                a[i] = q

    def is_prime(self, n):
        return self.A[n]


def main():
    rr = []

    M = 7368792
    pr = Prime(M)

    def f(m, n):
        nn = n
        g = [None] * (m*m)
        for i in range(m, m*m):
            if not g[i]:
                if n == 0:
                    return i
                n -= 1
                for j in range(i, m*m, i):
                    g[j] = 1
        d = pr.A[m*m]
        return pr.T[d+n]

    while True:
        m,n = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())



Measured memory_bytes: 102052
def spaceinput():
    return list(map(int,input().split(" ")))

import numpy as np

H,W=spaceinput()
N=int(input())
a=spaceinput()

field=np.zeros([H,W])
k=0
for i in range(H):
    if i%2==0:
        for j in range(W):
            field[i][j]=k+1
            a[k]-=1
            if a[k]==0:
                k+=1

    else:
        for j in reversed(range(W)):
            field[i][j]=k+1
            a[k]-=1
            if a[k]==0:
                k+=1


for i in range(H):
    a=field[i]
    b=list(map(str,map(int,a.tolist())))
    #print(b)
    print(" ".join(b))

Measured memory_bytes: 18648
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  if(a==0){
    printf("0\n");
  }
  if(a==1){
    printf("1\n");
  }
  if(a==10){
    printf("1\n");
  }
  if(a==11){
    printf("2\n");
  }
  if(a==100){
    printf("1\n");
  }
  if(a==101){
    printf("2\n");
  }
  if(a==110){
    printf("2\n");
  }
  if(a==111){
    printf("3\n");
  }
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}


void go(){
    string s;cin>>s;
    int k=in();
    for(auto &e:s){
        int t='z'-e+1;
        if(e=='a')continue;
        if(t<=k){
            k-=t;
            e='a';
        }
    }
    if(k)s.back()='a'+(s.back()-'a'+k)%26;
    cout<<s<<endl;
        
}





Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll q, h, s, d, n; cin >> q >> h >> s >> d >> n;

    ll mn_hl = min(q*2, h);
    ll mn_l = min(mn_hl*2, s);
    ll mn_dl = min(mn_l*2, d);
    if(n%2==0) cout << mn_dl*(n/2) << ln;
    else cout << mn_dl * (n/2) + mn_l << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<bool>>;
const int MOD = 1e9 + 7;

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

    int N, W;
    cin >> N >> W;
    vector<vector<int>> vl(4);
    int w0 = -1;
    for (int i = 0; i < N; ++i) {
        int w, v;
        cin >> w >> v;
        if (i == 0)
            w0 = w;
        vl[w - w0].push_back(v);
    }

    for (int i = 0; i < 4; ++i) {
        sort(vl[i].begin(), vl[i].end());
        vl[i].push_back(0);
        reverse(vl[i].begin(), vl[i].end());
    }

    for (int i = 0; i < 4; ++i)
        for (int j = 1; j < vl[i].size(); ++j)
            vl[i][j] += vl[i][j - 1];

    int ans = 0;
    for (int i = 0; i < vl[3].size(); ++i) {
        for (int j = 0; j < vl[2].size(); ++j) {
            for (int k = 0; k < vl[1].size(); ++k) {
                ll tmp = W - ((ll)(i + j + k) * w0 + 3 * i + 2 * j + k);
                if (tmp < 0)
                    break;
                int cnt = min<ll>(tmp / w0, vl[0].size() - 1), sum = 0;
                sum += (i >= 0 ? vl[3][i] : 0);
                sum += (j >= 0 ? vl[2][j] : 0);
                sum += (k >= 0 ? vl[1][k] : 0);
                sum += (cnt >= 0 ? vl[0][cnt] : 0);
                ans = max(ans, sum);
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define mod 1000000007
using namespace std;

vector<vector<int> >g;
vector<int> dp;

int dfs(int v){
	if(dp[v]!=-1)
		return dp[v];
	int cnt=0;
	for(auto to: g[v]){
		cnt = max(cnt,dfs(to));
	}
	// cout<<v<<" "<<cnt<<'\n';
	return dp[v] = 1+cnt;
}
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	g.resize(n+1);
	dp.assign(n+1,-1);
	while(m--){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
	}
	int ans=0;
	for(int i=1;i<=n;++i)
		ans= max(ans,dfs(i));
	cout<<ans-1;
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 8192
n = int(input())
a=[]
time=0
ans=True

for i in range(n):
    s,p=map(int,input().split())
    a+=[[s, p] ]
    

import operator as op
a.sort(key = op.itemgetter(1))

for i  in range(n):
    time+=a[i][0]
    if(time>a[i][1]):
        ans=False
        break
    
if ans:
    print("Yes")
else:
    print("No")


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

int Frog2(int a[],int n,int k){

  int dp[n];
  //base case
  dp[0]=0;
  for(int i=1;i<n;i++){
    int mini=INT_MAX;
    for(int j=1;j<=k && i-j >=0 ;j++){
      int temp=dp[i-j]+abs(a[i-j]-a[i]);
      mini=min(mini,temp);
    }
    dp[i]=mini;
  }

  return dp[n-1];
}

int main(){

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

  int ans=Frog2(a,n,k);
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

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

    map<ll, ll> ma;
    rep(i, N) ma[A[i]]++;

    ll total = 0;
    set<ll> se;
    rep(i, N) {
        if (se.find(A[i]) == se.end()) {
            total += (ma[A[i]] * (ma[A[i]] - 1)) / 2;
        }
        se.insert(A[i]);
    }

    rep(i, N) {
        ll cnt = (ma[A[i]] * (ma[A[i]] - 1)) / 2;
        if (cnt) {
            cout << total - cnt + ((ma[A[i]] - 1) * (ma[A[i]] - 2)) / 2 << endl;
        } else {
            cout << total << endl;
        }
    }
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int main(){
    scanf("%s",s);
    int k=strlen(s);
    if(k%2!=0){
        printf("No\n");
        return 0;
    }
    for(int i=0;i<k/2;i++){
        int u=abs(s[i]-s[k-i-1]);
        if(u!=1&&u!=2){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int C = sc.nextInt();
	        int[][] D = new int[C][C];
	        for(int i=0;i<C;i++) {
	        	for(int j=0;j<C;j++) {
	        		D[i][j]=sc.nextInt();
	        	}
	        }
	        int[][] c = new int[N][N];
	        int[][] m = new int[C][3];
	        for(int i=0;i<N;i++) {
	        	for(int j=0;j<N;j++) {
	        		c[i][j]=sc.nextInt()-1;
	        		m[c[i][j]][(i+j)%3]++;
	        	}
	        }

	        long ans=Long.MAX_VALUE;
	        boolean flg =false;
	        int[] d = new int[3];
	        while(d[0]<=C-1) {	        	
	        	if(d[0]==d[1])flg=true;
	        	if(d[1]==d[2])flg=true;
	        	if(d[0]==d[2])flg=true;
	        	long sum =0;
	        	if(flg==false) {
		        	for(int i=0;i<C;i++) {
		        		sum=sum+m[i][0]*D[i][d[0]];
		        		sum=sum+m[i][1]*D[i][d[1]];
		        		sum=sum+m[i][2]*D[i][d[2]];
		        	}	        		
		        	ans=Math.min(ans,sum);
	        	}

	        	
	        	d[2]++;
	        	if(d[2]>=C) {
	        		d[1]++;
	        		d[2]=0;
	        		if(d[1]>=C) {
	        			d[0]++;
	        			d[1]=0;
	        		}
	        	}
	        	flg=false;
	        }
	        
	        
	        
	        System.out.println(ans);
		 }
		 
	 
	}

Measured memory_bytes: 60248
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int W, H, x, y, r, a, b, c, num[5];

int main() {
	cin >> W >> H >> x >> y >> r;
	
	cout << (((r <= x && x + r <= W) && (r <= y && r + y <= H)) ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3128
numarry = Array.new(100,0)

x = gets
until x.nil?
 y = x.chomp.to_i
 indexy = y - 1
 numarry[indexy] += 1
 x = gets
end

arraymax = numarry.max

arryindex = numarry.each_index.select{|i| numarry[i] == arraymax}

k = 0
while k < arryindex.length
 truenum = arryindex[k] + 1
 puts truenum
 k += 1
end



Measured memory_bytes: 6868
require 'mathn'
include Math

D = 10000

loop do
	n = gets.to_i
	break if n == 0
	w, h, r, vx, vy = gets.split.map(&:to_i)
	balls = (1..n).map.with_index { |i| [i] + gets.split.map(&:to_i) }

	if vx < 0
		balls.map! {|i, x, y| [i, w - x, y]}
		vx = -vx
	end
	if vy < 0
		balls.map! {|i, x, y| [i, x, h - y]}
		vy = -vy
	end
	l = hypot(vx, vy)
	vx /= l
	vy /= l
	balls.map! {|i, x, y| [i, x - r, y - r]}
	wa, ha = w - 2 * r, h - 2 * r

	_, x0, y0 = balls.shift

	virtual_balls = []
	
	t = atan2(vy, vx)
	(0 .. 1 + ((y0 + D * sin(t))/ ha).to_i).each do |i|
		(0 .. 1 + ((x0 + D * cos(t)) / wa).to_i).each do |j|
			balls.each do |id, x, y|
				u = (j.even? ? x : wa - x) + wa * j
				v = (i.even? ? y : ha - y) + ha * i
				virtual_balls << [id, u, v]
			end
		end
	end


	min = Float::INFINITY
	virtual_balls.select! do |id, x, y|
		l = hypot(x - x0, y - y0)
		s = vx * (x - x0) + vy * (y - y0)
		d = sqrt(l * l - s * s).abs
		if 0 <= s && s <= D 
			d <= 2 * r
		elsif s > D
			hypot(x0 + D * vx - x, y0 + D * vy - y) <= 2 * r
		else
			hypot(x0 - x, y0 - y) <= 2 * r
		end
	end

	if virtual_balls.empty?
		puts -1
	else
		virtual_balls.sort_by! do |id, x, y|
			l = hypot(x - x0, y - y0)
			s = vx * (x - x0) + vy * (y - y0)
			d = sqrt(l * l - s * s).abs
			s - sqrt(4 * r * r - d * d).abs
		end
		puts virtual_balls[0][0]
	end
end

Measured memory_bytes: 51208
#include <stdio.h>

int main(void){
	int a, n , i;
	long max, min, sum;
	
	sum = 0;

	n = 0;
	
	scanf("%d", &n);

	for(i = 1; n >= i; i++){

		scanf("%d", &a);

		if(i == 1){
			
			max = a;
			min = a;

			sum = sum + a;
		
		}else{

			if(a > max){
				max = a;
			}

			if(a < min){
				min = a;
			}

			sum = sum + a;
		}
	}

	printf("%d %d %lld\n", min, max, sum);

	return(0);

}

Measured memory_bytes: 600
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N,M=list(map(int,input().split()))
if N>1:
  c1=combinations_count(N,2)
else:
  c1=0
if M>1:
  c2=combinations_count(M,2)
else:
  c2=0
print(c1+c2)

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int n,k;
    cin >> n >> k;
    vi p(n);
    REP(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    REP(i,k) ans += p[i];
    cout << ans << endl;
}


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

c2 = 0
c4 = 0
for a in A:
    if a % 4 == 0:
        c4 += 1
    elif a % 2 == 0:
        if c2 == 1:
            c4 += 1
            c2 = 0
        else:
            c2 += 1
if c4 >= N//2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;
const int MAX=1e6+10;
int fac[MAX],finv[MAX],inv[MAX];

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

int powMOD(int x,int p){
  	int res=1;
    while(p>0){
        if(p & 1)res=res*x%MOD;
        x=x*x%MOD;
        p>>=1;
    }
    return res;
}

map<int,int>lar;
void bunkai(int x){
    map<int,int>memo;
    for(int i=2;i<=sqrt(x);i++){
        while(x%i==0){
            x/=i;
            memo[i]++;
        }
        lar[i]=max(memo[i],lar[i]);
    }
    if(x!=0)memo[x]++;
    lar[x]=max(lar[x],memo[x]);
}

signed main(){
    COMinit();
  	int N;cin>>N;
    int A[N];
    int d=1;
    REP(i,N){
        cin>>A[i];
        bunkai(A[i]);
    }
    for(auto it=lar.begin();it!=lar.end();it++){
        int f=it->first;
        int r=it->second;
        d*=powMOD(f,r);
        d%=MOD;
    }
  	int ans=0;
    REP(i,N){
        ans+=d*inv[A[i]]%MOD;
      	ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 24448
A, B, C, X = [int(input()) for _ in range(4)]
cnt = 0

for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if 500 * a + 100 * b + 50 * c == X:
        cnt += 1

print(cnt)

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

using namespace std;

struct Edge {
	int src, dst;
	Edge(int f, int t) {
		src = f;
		dst = t;
	}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

//２重辺連結成分と橋のリストを求める
pair<vector<int>, Edges> bridge(const Graph& g) {
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	vector<int>ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	Edges brdg;
	function<void(int, int)> dfs = [&](int v, int u) {
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for (auto& e : g[v]) {
			int w = e.dst;
			if (ord[w] == -1)dfs(w, v);
			else if (u != w && onS[w])
				while (ord[roots[t - 1]]>ord[w])--t;
		}
		if (v == roots[t - 1]) {
			brdg.emplace_back(u, v);
			while (true) {
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if (v == w)break;
			}
			--t;
			++k;
		}
	};
	for (int u = 0; u<n; ++u) {
		if (ord[u] == -1) {
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return make_pair(cmp, brdg);
}

int main() {
    int V, E;
    cin >> V >> E;
    Graph g(V);
    for (int i = 0; i<E; ++i) {
        int s, t; cin >> s >> t;
        --s;
        --t;
        g[s].emplace_back(s, t);
        g[t].emplace_back(t, s);
    }
    Edges es = bridge(g).second;
    cout<<es.size()<<endl;
}

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

vector <ll> v;

int findIndex( ll value )
{
    auto iter = std::find( v.begin(), v.end(), value);
    size_t index = std::distance( v.begin(), iter );
    if(index == v.size())
        {
            return -1;
        }
    return index;
}

int main(){
    ll n,k,temp;
    cin >> n >> k;
    ll a[n+10];
    ll loop = 0;
    bool already[n+10];
    for(ll i = 0; i < n+1; i++){
        already[i] = false;
    }


    
    ll count = 0;
    ll loop_begin;
    v.push_back(1);
    for(int i = 0; i < n; i++){
        cin >> temp;
        a[i] = temp;
    }
    temp = 1;
  already[1]  =true;
    while(count < n){
        temp = a[temp-1];
        //auto result = findIndex(temp);
        if(already[temp]){
            auto result = findIndex(temp);
            loop_begin = result;
            loop = count - loop_begin+1;
            //count++;
            break;
        }
        v.push_back(temp);
      already[temp] = true;
        count++;
        if(count == k) break;
    }
  //printf("huhu%d\n",loop);
  //printf("huhu%d\n",loop_begin);
  
    if(count < k){
        ll kaisu = (k - loop_begin) % loop;
        temp = v[loop_begin+kaisu];
    }
    cout << temp << endl;

}

Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n;
    cin >> n;
    vector<ll> vehicle(5);
    REP(i,vehicle.size()){
        cin >> vehicle[i];
    }
    ll pass_time = ceil(n/(double)*min_element(all(vehicle)));

    cout << 4 + pass_time << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    while(cin>>t,t){
        int n;
        cin>>n;
        int sum=0;
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            sum+=b-a;
        }
        if(sum>=t)cout<<"OK"<<endl;
        else cout<<t-sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
main = do
    [h,w] <- map read . words <$> getLine :: IO [Int]
    print $ minimum [cut1 h w, cut1 w h, cut2 h w, cut2 w h]

cut1 h w = maximum ps - minimum ps
    where h1 = (h + 1) `div` 3
          h2 = (h - h1) `div` 2
          h3 = h - h1 - h2
          ps = map (w*) [h1,h2,h3]

cut2 h w = maximum ps - minimum ps
    where h1 = (h + 1) `div` 3
          h2 = h - h1
          w1 = w `div` 2
          w2 = w - w1
          ps = [h1*w, h2*w1, h2*w2]

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

int main()
{
  int h,w;
  int i,j;
    
  for( ; ; ){
    cin >> h >> w;
    if(h==0 || w==0) break;
    for(i=0;i<h;i++){
      if(i%2==0){
	for(j=0;j<w;j++){
	  if(j%2==0){
	    cout << "#";
	  }else{
	    cout << ".";
	  }
	}
	cout << endl;
      }else{
	for(j=0;j<w;j++){
	  if(j%2!=0){
	    cout << "#";
	  }else{
	    cout << ".";
	  }
	 }
	cout << endl;
      }
    }
    cout << endl;  
  }   
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int ans=0;
    while(true){
        if((A&1)||(B&1)||(C&1)){
            cout<<ans<<endl;
            return 0;
        }
        if(A==B&&B==C){
            cout<<-1<<endl;
            return 0;
        }
        int AA=(B+C)/2,BB=(C+A)/2,CC=(A+B)/2;
        A=AA;B=BB;C=CC;
        ans++;
    }
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q; char buf[9];
int main() {
	scanf("%d%d", &N, &Q);
	vector<int> tp(Q), a(Q), b(Q), c(Q);
	for (int i = 0; i < Q; i++) {
		scanf("%s%d%d", &buf, &a[i], &b[i]); a[i]--, b[i]--;
		if (buf[0] == 'C') tp[i] = 1;
		if (tp[i] == 0) scanf("%d", &c[i]);
	}
	vector<int> x(N); vector<bool> vis(N);
	vector<vector<int> > g(N); vector<int> r(N);
	for (int i = 0; i < N; i++) g[i] = vector<int>({ i }), r[i] = i;
	for (int i = 0; i < Q; i++) {
		if (tp[i] == 0) {
			if (!vis[b[i]]) {
				x[a[i]] += c[i];
				x[b[i]] = x[a[i]] + c[i];
				r[b[i]] = r[a[i]];
				g[r[a[i]]].push_back(b[i]);
				g[b[i]].clear();
			}
			else if (!vis[a[i]] && vis[b[i]]) {
				x[b[i]] += c[i];
				x[a[i]] = x[b[i]] - c[i];
				r[a[i]] = r[b[i]];
				g[r[b[i]]].push_back(a[i]);
				g[a[i]].clear();
			}
			else {
				if (r[a[i]] != r[b[i]]) {
					int z1 = r[a[i]], z2 = r[b[i]], e = x[a[i]] - x[b[i]] + c[i];
					if (g[z1].size() < g[z2].size()) swap(z1, z2), e = -e;
					g[z1].insert(g[z1].end(), g[z2].begin(), g[z2].end());
					for (int i : g[z2]) x[i] += e, r[i] = r[z1];
					g[z2].clear();
				}
				x[a[i]] += c[i];
				x[b[i]] += c[i];
			}
			vis[a[i]] = vis[b[i]] = true;
		}
		else {
			if (r[a[i]] != r[b[i]]) puts("WARNING");
			else printf("%d\n", x[b[i]] - x[a[i]]);
		}
	}
	return 0;
}

Measured memory_bytes: 10544
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int a = h[0], cnt = 0;
	for (int i = 1; i < n; i++) {
		if (h[i] >= a) {
			cnt++;
			a = h[i];
		}
	}
	cout << cnt+1 << endl;
	return 0;
}

Measured memory_bytes: 256
(defun duplicate-char-counter (str separator)
  (labels ((duplicate-char-counter (char-list cnt)
             (if char-list
                 (duplicate-char-counter (cdr char-list)
                                         (if (find (car char-list) str :start separator :test #'char=)
                                             (1+ cnt)
                                             cnt))
                 cnt)))
    (let ((char-list (coerce (remove-duplicates (subseq str 0 separator)) 'list)))
      (duplicate-char-counter char-list 0))))

(princ (loop for separator from 1 upto (1- (read))
             with input-str = (read-line)
             maximize (duplicate-char-counter input-str separator)))

Measured memory_bytes: 12260
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  #startline-------------------------------------------
    s = input()
    t = input()
    n = len(s)
    ans = 0
    for i in range(n):
        if s[i] != t[i]:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

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

int main()
{
    ll t=0,n,f,i,a,b,c;
    string s;
    scanf("%lld", &f);
    s = to_string(f);
    n = s.size();
    for(i=0;i<n;i++){
        t += (s[i]-'0');
    }
    if(f%t==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0,cnt[105],val=-1000000;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I') x++;
		else x--;
		cnt[i]=x;
	}
	cnt[n]=0;
	for(int i=0;i<=n;i++) val=max(val,cnt[i]);
	cout<<val<<endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<pair<pair<string, int>,int>> vec(n);
  for(int i; i<n;i++){
    string tmp1;
    int tmp2;
    cin>>tmp1>>tmp2;
    vec.at(i).first.first=tmp1;
    vec.at(i).first.second=100-tmp2;
    vec.at(i).second=i+1;
  }
  sort(vec.begin(), vec.end());
  for(int i=0;i<n;i++){
    cout<<vec.at(i).second<<endl;
  }
  
}

Measured memory_bytes: 256
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
void fo (){fflush(stdout);}
using namespace std;
ll fact (int x ){return (x <= 1 ? 1 : 1LL * x * fact (x-1));}
int main ()
{
  int a , b ;
  cin >> a >> b ;
  if (a == b )
  {
    cout <<"Draw\n";
  }else
  {
    if (a == 1 || ( b != 1 && a > b ))
    cout << "Alice\n";
    else
    cout << "Bob\n";
  }
  cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


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

int cnt_digits(LL x) {
  int digits = 0;
  while (x > 0) {
    digits ++;
    x /= 10;
  }

  return digits;
}

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

  int ans = cnt_digits(n);
  for (LL a = 1; a * a <= n; a ++) {
    if (n % a != 0) continue;

    LL b = n / a;
    int tmp = max(cnt_digits(a), cnt_digits(b));
    if (tmp < ans) ans = tmp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5005,Mod=1e9+7;
vector<int> e[N];
int f[N][N],g[N],t[N],sze[N],n;
#define mul(x,y) (1ll*(x)*(y)%Mod)
inline int add(int x, int y)
{	return (x+y>=Mod?x+y-Mod:x+y);
}
inline int sub(int x, int y)
{	return (x-y<0?x-y+Mod:x-y);
}
void dfs(int u, int fa)
{
	sze[u]=1,f[u][1]=1;
	for(auto v:e[u]) if(v!=fa)
	{
		dfs(v,u);
		for(int i=1;i<=sze[u]+sze[v];++i) t[i]=0;
		for(int i=1;i<=sze[u];++i)
			for(int j=0;j<=sze[v];++j)
				t[i+j]=add(t[i+j],mul(f[u][i],f[v][j]));
		sze[u]+=sze[v];
		for(int i=1;i<=sze[u];++i) f[u][i]=t[i];
	}
	for(int i=1;i<=sze[u];++i) f[u][0]=sub(f[u][0],mul(f[u][i],g[i]));
}
int main()
{
	scanf("%d",&n);
	g[0]=1;
	for(int i=2;i<=n;++i) g[i]=mul(i-1,g[i-2]);
	for(int i=1,u,v;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		e[u].push_back(v),e[v].push_back(u);
	}
	dfs(1,0),printf("%d\n",sub(0,f[1][0]));
}


Measured memory_bytes: 97408
from collections import Counter

n=int(input())
a=list(map(int, input().split()))
a.sort()

m=a[-1]+1
dp=[1]*m
c=Counter(a)
ans=0
for i in a:
    if dp[i] and c[i]==1:
        ans+=1

    for j in range(2*i, m, i):
        dp[j]=0

print(ans)
#print(c)


Measured memory_bytes: 120564
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define MAX_W 501
#define MAX_M 500
#define MAX_ps 600
vector<string> pre;
int mod=1e9+7;
int N,M,K;
int a[21][MAX_ps][MAX_W],b[21][MAX_ps][MAX_W];	//len,suffix,last word
int ne[MAX_ps][MAX_W];
bool appear[MAX_ps][MAX_W],twice[MAX_ps][MAX_W],can[MAX_ps][MAX_W];
string from[250],to[250],s[30];
vector<string> words;
vector<int> G[MAX_W];
vector<int> cans[MAX_ps];
inline int wordid(string s){
	return lower_bound(all(words),s)-words.begin();
}
int main(){
	while(true){
		cin>>N>>M>>K;
		if(N==0) break;
		pre.clear();
		words.clear();
		rep(i,N){
			cin>>from[i]>>to[i];
			words.pb(from[i]);
			words.pb(to[i]);
		}
		words.pb("");
		sort(all(words));
		words.erase(unique(all(words)),words.end());
		rep(i,words.size()) G[i].clear();
		rep(i,N){
			G[wordid(from[i])].pb(wordid(to[i]));
		}
		rep1(i,words.size()-1) G[0].pb(i);
		rep(i,K) cin>>s[i];
		rep(i,K){
			rep(j,s[i].size()+1) pre.pb(s[i].substr(0,j));
		}
		sort(all(pre));
		pre.erase(unique(all(pre)),pre.end());
		int ps=pre.size(),ws=words.size();
		rep(i,ps) rep(j,ws) can[i][j]=false;
		rep(i,ps) cans[i].clear();
		rep(i,ps){
			rep(j,ws){
				string st=pre[i]+words[j];
				if(st.size()>20) st=st.substr(st.size()-20);
				int k;
				while(true){
					k=lower_bound(all(pre),st)-pre.begin();
					if(k<ps&&pre[k]==st) break;
					st=st.substr(1);
				}
				ne[i][j]=k;
				can[k][j]=true;
				appear[i][j]=false;
				twice[i][j]=false;
				st=pre[i];
				int cnt=0;
				rep(h,words[j].size()){
					st+=words[j][h];
					rep(p,K) if(st.size()>=s[p].size()&&st.substr(st.size()-s[p].size())==s[p]) cnt++;
					if(cnt>=2) break;
				}
				if(cnt>=1) appear[i][j]=true;
				if(cnt>=2) twice[i][j]=true;
//				if(appear[i][j]) printf("i=%d,j=%d\n",i,j);
			}
		}
		rep(i,ps) rep(j,ws) if(can[i][j]) cans[i].pb(j);
		rep(i,21) rep(j,ps) rep(k,ws) a[i][j][k]=b[i][j][k]=0;
		b[0][0][0]=1;
		rep(i,M){
			int i21=i%21;
			rep(j,ps){
				for(int k:cans[j]){
					for(int u : G[k]){
						if(twice[j][u]) continue;
						int ni=i+words[u].size();
						if(ni>M) continue;
						int ni21=i21+words[u].size();
						if(ni21>=21) ni21-=21;
						if(appear[j][u]){
							a[ni21][ne[j][u]][u]+=b[i21][j][k];
							if(a[ni21][ne[j][u]][u]>=mod) a[ni21][ne[j][u]][u]-=mod;
						}else{
							a[ni21][ne[j][u]][u]+=a[i21][j][k];
							if(a[ni21][ne[j][u]][u]>=mod) a[ni21][ne[j][u]][u]-=mod;
							b[ni21][ne[j][u]][u]+=b[i21][j][k];
							if(b[ni21][ne[j][u]][u]>=mod) b[ni21][ne[j][u]][u]-=mod;
						}
					}
				}
			}
			rep(j,ps) for(int k:cans[j]) a[i21][j][k]=b[i21][j][k]=0;
		}
		int ans=0;
		rep(i,ps) for(int j:cans[i]){
			ans+=a[M%21][i][j];
			if(ans>=mod) ans-=mod;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 52796
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  int s,w;
  cin>>s>>w;
  if(s<=w) out("unsafe");
  else out("safe");
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3640