akhauriyash/Code-Regression huggingface dataset:
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let h = split (read_line ()) in
        let rec loop mx cur prev = function
            | [] -> max mx cur
            | hd :: tl ->
                    if hd <= prev then loop mx (cur + 1) hd tl else
                        loop (max mx cur) 0 hd tl
        in
        let r = loop 0 (-1) 1_111_111_111 h in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 16128
N = int(input())
a = list(map(int, input().split()))

mean_a = sum(a)/2

mean_a_disc = 0
ans = 1000000
candidate = 0
#print(mean_a)
for i in range(N):
    if mean_a_disc + a[i] < mean_a:
        mean_a_disc += a[i]
    elif mean_a_disc + a[i] > mean_a:
        candidate = min(mean_a_disc + a[i] -mean_a,mean_a- mean_a_disc)
        break
    else:
        ans = 0
        break
if candidate > 0:
    ans = int(candidate * 2)

print(ans)




Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,k,d;cin>>x>>k>>d;
    x = abs(x);
    if(x/d-k>=0)cout<<x-k*d<<endl;
    else{
        k -= x/d;
        x -= x/d*d;
        if(k%2==0)cout<<x<<endl;
        else cout<<abs(x-d)<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define int ll
#define MOD 1000000007
#define maxn 500001
int N,M;
int fac[maxn];
ll qexp(ll x, ll y) { 
ll res = 1; 
while (y > 0){
if (y & 1){
res = res*x; 
			res %= MOD;
        		}
        		y = y>>1;
        		x = x*x; 
        		x %= MOD;
} 
    return res; 
}
int modinv(int A,int B){
	A %= MOD;
	B = qexp(B,MOD-2);
	A *= B;
	A %= MOD;
	return A;
}

int nck(int n,int k){
	if (k == 0 || n == 0) return 1;
	return modinv(fac[n], (fac[k] * fac[n-k]) % MOD);
}



int32_t main(){
	fast;
	
	cin>>N>>M;
	
	int ans = 0;
	fac[0] = 1;
	FOR(i,1,M) fac[i] = (fac[i-1] * i) % MOD;
	
	FOR(i,1,N){
		int res = ((fac[N - i] * nck(M - i, N - i)) % MOD * nck(N,i)) % MOD;
		if (i % 2 == 1) ans += res;
		else ans -= res;
		ans %= MOD;
	}
	ans = (fac[N] * nck(M,N)) % MOD - ans;
	while (ans < 0) ans += MOD;
	ans %= MOD;
	cout<<((ans * fac[N]) % MOD * nck(M,N)) % MOD;
}


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

using namespace std;

const int   N   = 1e5 + 1;

typedef unordered_map<char,int> mci;

vector<mci> g;
vector<int> c;
vector<int> f;

int add(string s)   {
    int R = 0;

    for(char x : s) {
        if(!g[R].count(x))
            g[R][x] = g.size(),
            g.push_back({}),
            c.push_back(0),
            f.push_back(0);

        c[R = g[R][x]]++;
    }
    f[R]++;

    return  1;
}

string s[N];

int PreCal[N][26][26];
int CntPre[N];

int dfs(int i)  {
    int R = 0;
    int A = 0;

    for(char x : s[i])  {
        for(int j = 0 ; j < 26 ; ++j)   {
            char t = (j + 'a');
            if (g[R].count(t))
                PreCal[i][j][x - 'a'] += c[g[R][t]];
        }
        CntPre[i] += f[R = g[R][x]];
    }
}

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

    int n;  cin >> n;

    g.push_back({});
    c.push_back(0),
    f.push_back(0);

    for(int i = 1 ; i <= n ; ++i)
        cin >> s[i],
        add(s[i]);
    for(int i = 1 ; i <= n ; ++i)
        dfs(i);

    int q;  cin >> q;

    for(int i = 1 ; i <= q ; ++i)   {
        int k;  cin >> k;

        vector<int> pos(26);

        for(int j = 0 ; j < 26 ; ++j)   {
            char x; cin >> x;
            pos[x - 'a'] = j;
        }

        int ans = CntPre[k];

        for(int j = 0 ; j < 26 ; ++j)
        for(int t = 0 ; t < 26 ; ++t)
            if (pos[j] < pos[t])
                ans += PreCal[k][j][t];

        cout << ans << endl;
    }
}

Measured memory_bytes: 283724
#include <bits/stdc++.h>
using namespace std;
int t;
double dp[301][301][301];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  cin >> t;
  short a[3] = {0};
  for(int i=0;i<t;i++) {
    int x; cin >> x;
    a[x-1]++;
  }
  for(int threes = 0;threes <=a[2];threes++) {
    for(int twos = 0;twos <= -threes + a[1] + a[2]; twos++) {
      for(int ones=0;ones<= -threes -twos +a[0]+a[1]+a[2];ones++) {
        double sum = ones + twos + threes;
        if (sum <=0.5 ) continue;
        double p_waste = t / sum;
        auto &p = dp[ones][twos][threes];
        if (ones > 0) {
          p += (ones)*(p_waste + dp[ones-1][twos][threes]);
        }
        if (twos > 0) {
          p += (twos) * (p_waste + dp[ones+1][twos-1][threes]);
        }
        if (threes > 0) {
          p += (threes)*(p_waste + dp[ones][twos+1][threes-1]);
        }
        p /= sum;
      }
    }
  }
  cout << setprecision(10) << dp[a[0]][a[1]][a[2]];
  return 0;
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

struct Edge {
    int to;
    int cost;
};

vector<Edge> G[10];

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

int H,W;
cin >> H >> W;
vvi c(10,vi(10));
rep(i,10) {
    rep(j,10) {
        int c;
        cin >> c;
        G[j].push_back(Edge{i,c});
    }
}

priority_queue <pii, vector<pii>, greater<pii>> que;
vi dp(10,INF);
dp[1] = 0;
que.emplace(0, 1);
while(!que.empty()) {
    pii p = que.top(); que.pop();
    int v = p.second;
    if(dp[v] < p.first) continue;
    for(auto e : G[v]) {
        if (dp[e.to] > dp[v] + e.cost) {
            dp[e.to] = dp[v] + e.cost;
            que.emplace(dp[e.to], e.to);
        }
    }
}

map<int,int> mp;
rep(i,H) {
    rep(j,W) {
        int a;
        cin >> a;
        mp[a]++;
    }
}
ll ans = 0;
rep(i,10) {
    ans += mp[i] * dp[i];
}

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

Measured memory_bytes: 256
import java.math.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	//初期フィールド・メソッド---------------------------------------------
	static Scanner sc = new Scanner(System.in);
	static int min(int... ar) {Arrays.sort(ar); return ar[0];}
	static int max(int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
	//------------------------------------------------------------


	//フィールド追加場所-----------------------------------------------
	//------------------------------------------------------------


	//メソッド追加場所------------------------------------------------
	//------------------------------------------------------------


	//mainメソッド---------------------------------------------------
	public static void main(String[] args) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		BigDecimal bd1 = new BigDecimal(a*b);
		BigDecimal bd2 = new BigDecimal(3.305785);
		BigDecimal ans = bd1.divide(bd2,5,RoundingMode.HALF_UP);
		out.println(ans);
	}
	//------------------------------------------------------------
}


Measured memory_bytes: 26528
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = a-1;
		int d = b-1;
		
		//偶数にならない
		if(a<=1){a=0;}
		else{
		    a = ((a * c)/2);
		}
		if(b<=1){b=0;}
		else{
		     b = ((b * d)/2);
		}
		
		System.out.print(a+b);
      
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
        int n,m,x;
        int z=0;int r=0;
        int c;
        cin >> n >> m >> x;
        for(int i=0;i<m;i++){
          cin >> c;
          if(c<x) z++;
          else r++;
        }
        int a=min(r,z);
        cout << a << endl;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 110
#define MAXM 512
#define MAXC 11
typedef long long ll;

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

edge es[2*MAXM];

int c, n, m, s, d;
int dist[MAXN][MAXN];
int xdist[MAXC][MAXN];

int main(void) {
    while (1) {
        cin >> c >> n >> m >> s >> d;
        if (c == 0 && n == 0 && m == 0 && s == 0 && d == 0) break;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                dist[i][j] = INF;
            }
            dist[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int a, b, f;
            cin >> a >> b >> f;
            dist[a][b] = dist[b][a] = f;
            es[2*i].from = a; es[2*i].to = b; es[2*i].cost = f;
            es[2*i+1].from = b; es[2*i+1].to = a; es[2*i+1].cost = f;
        }
        for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            xdist[0][i] = dist[i][d];
        }
        for (int i = 1; i <= c; i++) {
            for (int j = 1; j <= n; j++) {
                xdist[i][j] = xdist[i-1][j];
                for (int k = 0; k < 2*m; k++) {
                    edge e = es[k];
                    xdist[i][j] = min(xdist[i][j], dist[j][e.from] + e.cost / 2 + xdist[i-1][e.to]);
                }
            }
        }
        cout << xdist[c][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,int> P;

vector<ll> V;

int main(){
    ll a[1100],sum=0,ans=0,temp=1099511627776,count=0;
    int N,K;
    cin>>N>>K;
    for(int i=0;i<N;i++) cin>>a[i];

    for(int i=0;i<N;i++,sum=0){
        V.push_back(a[i]);
        sum+=a[i];
        for(int j=i+1;j<N;j++){
            sum+=a[j];
            V.push_back(sum);
        }
    }

    while(temp!=0){
        for(int i=0;i<(int)V.size();i++){
            if(((ans+temp) & V[i]) == ans+temp){
                count++;
                //cout<<"unko"<<endl;
            } 
        }
        //cout<<count<<endl;
        if(count>=K) ans+=temp;

        temp/=2;
        count=0;
        //cout<<ans<<endl;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<int,int> state;

int N,M;
P t[100];
int f[100][100];
int d[100][100];

void init(){
  memset(f,0,sizeof(f));
  memset(d,1,sizeof(d));
}

int solve(){

  int si=0,ti;
  double mini=1e9;
  for(int i=0;i<N;i++)
    if(t[i].real()<t[si].real())si=i;
  
  deque<state> Q;    
  for(int i=0;i<N;i++)
    if(f[si][i] && arg(t[i]-t[si])< mini)
      ti=i,mini=arg(t[i]-t[si]);
  Q.push_back(state(si,ti));
  d[si][ti]=0;
  

   
  int ans=0;
  while(!Q.empty()){
    state p=Q.front();
    Q.pop_front();
    int from=p.first;
    int to=p.second;
    ans=max(ans,d[from][to]);
    
    if(d[from][to]+1<d[to][from]){
      d[to][from]=d[from][to]+1;
      Q.push_back(state(to,from));
    }
    int id=-1;
    double mini=1e9;
    for(int i=0;i<N;i++){
      if(f[to][i]&&i!=from){
        if( arg( (t[i]-t[to])*conj(t[to]-t[from]) ) < mini){
          id=i;
          mini=arg( (t[i]-t[to])*conj(t[to]-t[from]) );
        }
      }
    }
    if(id!=-1&&d[to][id]>d[from][to]){
      d[to][id]=d[from][to];
      Q.push_front(state(to,id));
    }
  }
  return ans;
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    for(int i=0;i<N;i++){
      int x,y;
      cin>>x>>y;
      t[i]=P(x,y);
    }
    for(int i=0;i<M;i++){
      int x,y;
      cin>>x>>y;
      x--,y--;
      f[x][y]=f[y][x]=true;
    }
    cout<<solve()<<endl;
  }
  return 0;
}

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

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

using namespace std;

using pii = pair<int, int>;

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

    int N;
    cin >> N;
    auto encode = [&](int i, int j) { return i * N + j; };
    unordered_map<int, vector<int>> g;
    unordered_map<int, int> indegree;
    REP(i, N) {
        int u, v;
        REP(j, N - 1) {
            int A;
            cin >> A;
            --A;
            v = encode(min(i, A), max(i, A));
            if (j) {
                g[u].push_back(v);
                ++indegree[v];
            }
            u = v;
        }
    }

    queue<pii> q;
    REP(i, N) FOR(j, i + 1, N) {
        int v = encode(i, j);
        if (indegree[v] == 0) {
            q.emplace(v, 1);
        }
    }

    int result = 0;
    REP(_, N * (N - 1) / 2) {
        if (q.empty()) {
            result = -1;
            break;
        }
        int u, depth;
        tie(u, depth) = q.front();
        q.pop();
        result = max(result, depth);
        for (int v: g[u]) {
            --indegree[v];
            if (indegree[v] == 0) {
                q.emplace(v, depth + 1);
            }
        }
    }

    cout << result << endl;

    return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    if((A - B) % 2){
        cout << "Borys" << "\n";
    } else {
        cout << "Alice" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(){
      int len=par.size(),ans=0;
      vi v(len);
      for(int i=0;i< len;i++){
        v[root(i)]++;
      }
      for(int i=0;i< len;i++){
        if(ans<v[i]){ans=v[i];}
      }
      return ans;
    }
};
int main() {
  int n,m,a,b;
  set<ll> s;
  cin >> n>>m;
  UnionFind tree(n);
  rep(i,m){
    cin >> a>>b;
    tree.unite(a-1,b-1);
  }
  rep(j,n){
    s.insert(tree.root(j));
  }

  cout << s.size()-1 << endl;
  return 0;
}


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

ll mh[1114101],mw[1111041];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,m;
    cin>>n>>m;
    ll a[n],b[m];
    ll mod = 1e9+7;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mh[a[i]] = i+1;
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        mw[b[i]] = i+1;
    }
    ll ans = 1;
    bool uh[n+1]={},uw[m+1]={};
    ll h=0,w=0;
    for(int i=n*m;i>=1;i--){
        if(mh[i] && mw[i]){
            if(!uh[mh[i]]) h++;
            if(!uw[mw[i]]) w++;
            uh[mh[i]] = 1;
            uw[mw[i]] = 1;
        }
        else if(mw[i]){
            ans *= h;
            if(!uw[mw[i]]) w++;
            uw[mw[i]] = 1;
        }
        else if(mh[i]){
            ans *= w;
            if(!uh[mh[i]]) h++;
            uh[mh[i]] = 1;
        }
        else{
            ans *= (h*w-n*m+i)%mod;
            if(ans<0){
                cout << 0 << endl;
                return 0;
            }
        }
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 4480
#include <stdio.h>

int main(void)
{
	int n, a, b, i;
	int ans1, ans2;
	
	while (1){
		ans1 = 0;
		ans2 = 0;
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			if (a > b){
				ans1 += a + b;
			}
			else if (a < b){
				ans2 += a + b;
			}
			else {
				ans1 += a;
				ans2 += b;
			}
		}
		printf("%d %d\n", ans1, ans2);
	}
	
	return (0);
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    int x,n;
    cin>>x>>n;

    if(n==0) {
        cout<<x<<endl;
        return 0;
    }

    vector<int> arr;
    while(n--) {
        int num;
        cin>>num;
        arr.push_back(num);
    }

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

    //for(int i=0;i<arr.size();i++) {
    //    cout<<arr[i]<<' ';
    //}

    vector<int> rng={-1,1};

    for(int i=0;i<=x;i++) {
        for(int j=0;j<2;j++) {
            if(count(arr.begin(), arr.end(), x+(i*rng[j]))==0) {
                cout<<x+(i*rng[j])<<endl;
                return 0;
            }
        }

    }

}




Measured memory_bytes: 3672
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(std::vector<long long> H, std::vector<long long> M, long long K);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
}

void solve(std::vector<long long> H, std::vector<long long> M, long long K){
    int h = (H[1]-H[0]+24)%24;
    if(H[1] == H[0] && M[1] <= M[0]){
        h = 24;
    }
    int m = M[1]-M[0]-K;
    m += h*60;
    int ans = m;
    cout << ans << el;
}



Measured memory_bytes: 3692
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      
      string S=Console.ReadLine();
      char[] Schar=S.ToCharArray();
      int ansA=0;
      int ansB=0;
     if(Schar.Length>1){
   
     for(int i=0;i<Schar.Length;i++){
       if(i%2==0){
         if(Schar[i]=='1'){
           ansA++;
         }
       }else{
         if(Schar[i]=='0'){
           ansA++;
       }
     }
     }
       for(int i=0;i<Schar.Length;i++){
       if(i%2==0){
         if(Schar[i]=='0'){
           ansB++;
         }
       }else{
         if(Schar[i]=='1'){
           ansB++;
       }
     }
       }
       }
           
    
         
         if(ansA<ansB){
           Console.WriteLine(ansA);
         }else{
        Console.WriteLine(ansB);
         }
    }
     
  }

}
  

Measured memory_bytes: 26516
def c_honest_or_unkind_2():
    N = int(input())
    Answers = []
    for _ in range(N):
        a = int(input())
        Answers.append([[int(i) for i in input().split()] for j in range(a)])

    # print(Answers)
    ret = -1
    for bits in range(1 << N):
        honests = set()
        unkinds = set()
        for k in range(N):
            if (bits >> k) & 1 == 1:
                honests.add(k)
            else:
                unkinds.add(k)
        # print(honests, unkinds, end=' ')
        is_contradict = False
        for k, answer in enumerate(Answers):
            if k not in honests:
                continue

            for x, y in answer:
                x -= 1
                if (y == 1 and x in unkinds) or (y == 0 and x in honests):
                    # print(k, x, y)
                    is_contradict = True
                    break
            if is_contradict:
                break
        else:
            # print(honests)
            ret = max(ret, len(honests))
    return ret

print(c_honest_or_unkind_2())

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    vector<char> v;
    string s;
    cin >> s;

    string s_ = s;

    int ans_ = 100000;

    REP(j, s_.size())
    {
        char mode = s_[j];

        s = s_ + mode;

        int ans = 0, cnt = 0;
        REP(i, s.size())
        {
            if (s[i] == mode)
            {
                ans = max(ans, cnt);
                cnt = -1;
            }

            cnt++;
        }

        ans_ = min(ans, ans_);
    }

    cout << ans_ << endl;

    return 0;
}

Measured memory_bytes: 256
/*---Bismillahir Rahmanir Rahim---*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define vi vector <int> 
#define pii pair<int, int>
using namespace std; 

int  gcd(int a,int b){
	return  (b==0)?a: gcd(b,a%b);
}

inline void solve() {
	int  n; cin >> n; 
	int a[n],res=0;
	for (int  &i: a) cin>>i;
	sort(a,a+n,greater<int> ()); 
	if (n>1) res = a[0];
	for (int i=1;i<n/2;i++)
		res += a[i]*2; 
	if (n&1 and n>1) res += a[n/2];
	cout << res << endl;
} 

signed main()
{
	int n = 1;
//	cin >> n;
	while (n--)
		solve();
	return 0;
}

/*
a
4
2 1 p
1
2 2 c
1

*/


Measured memory_bytes: 5148
N = input()
AL = list(map(int,input().split()))

Amax = 0
FD = 0

for Ai in AL:
#  print('FD=%d' % FD)
  if Amax > Ai:
#    print('1')
    FD = FD + (Amax - Ai)
  elif Amax < Ai:
#    print('2')
    Amax = Ai

print(FD)

Measured memory_bytes: 31992
#include <bits/stdc++.h>
        using namespace std;
        #define rep(i,a,b) for(ll i =a; i<b;++i)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        #define pb push_back
        #define print(a)       for(auto x : a) cout << x << " "; cout << endl
        #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
        #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
        #define mk(x,y)  make_pair(x,y)
        typedef  long long  int ll;
        const int N = ( 1e6 + 5 );
        const int mod = 1e9+7;
        ll n,c[10][10],m;
        ll l,r;
ll pow_mod_m(ll a , ll n)
{
    if(!n)
        return 1;
    ll pt =  pow_mod_m(a,n/2);
    pt *= pt ; pt %= mod;
    if(n&1)
        pt *= a , pt %= mod;
    return pt;
}


int main()
{
    IOS;
    int ts = 1;
   // cin>>ts;
	while(ts--)
    {
        cin>>n;
        ll lsb , msb;
        rep(i,1,n+1)
        {
            ll j = i;
            lsb = j%10;
            while(j)
            {
                msb= j%10;
                j/=10;
            }
            c[lsb][msb]++;
           // cout<<"here";
        }
        ll ans=  0;
        rep(i,0,10)
        {
            rep(j,0,10)
            {
                ans += c[i][j]*c[j][i];
            }
        }
        cout<<ans<<endl;
    }
	return 0;
}
/*
10 6
2 6
1 5
2 6
2 4
2 4
1 6
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int X,N;
  cin >> X >> N;
  vector<int> p(102,0);
  for(int i=0;i<N;i++){
    int t;
    cin >> t;
    p[t]=1;
  }

  int ans=501;
  for(int i=0;i<102;i++){
    if(p[i]==0 && abs(X-i)<abs(X-ans)){
      ans=i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{  
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int h = int.Parse(inputs[0]);
        int w = int.Parse(inputs[1]);
        inputs = Console.ReadLine().Split();
        int h2 = int.Parse(inputs[0]);
        int w2 = int.Parse(inputs[1]);
        int result = (h - h2) * (w - w2);
        System.Console.WriteLine(result);

    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


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

using namespace std;

#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)

const long long INF = 1000000000 + 7;
const long long maxn = 1005;

int cost[maxn][maxn];
char cell[maxn][maxn];
long long memo[maxn][maxn];
long long ROW, COL;


/**
- 2D Grid in iterative way.
-Key Observation:
    - we see if pos is [row][0] = [row][1] = [row][2] ... = [row][col] = one way road i.e. 1 way road
    - same for [row][0] = [row][1] = [row][2] = . . .  = [row][col] = 1 way.
    - for [r][c] = [r][c + 1] + [r + 1][c];
     
**/

bool valid (long long row, long long col){
    if(row < ROW && col < COL && cell[row][col] != '#') return true;
    return false;
}

int main(){
    IO;
    cin >> ROW >> COL;
    //int memo[ROW][COL];
    for(long long r = 0; r < ROW; r++)
        for(long long c = 0; c < COL; c++)
            cin >> cell[r][c];
     
    memset(memo,0,sizeof(memo));
    
    memo[0][0] = 0;
    bool ok = true;
    for(long long i = ROW - 1; i >= 0; i--){
        if(cell[i][COL - 1] == '#') ok = false;
        if(ok)
            memo[i][COL - 1] = 1;
        else memo[i][COL - 1] = 0;
    }
    ok = true;
    for(long long i = COL - 1; i >=0; i--){
        if(cell[ROW - 1][i] == '#') ok = false;
        if(ok) memo[ROW - 1][i] = 1;
        else memo[ROW - 1][i] = 0;
    }
    for(long long r = ROW - 2; r >= 0; r--){
        for(long long c = COL - 2; c >= 0; c--){
            if(valid(r, c+1)){
                memo[r][c] += memo[r][c + 1];
                memo[r][c] %= INF;
            }
            else{
                memo[r][c] += 0;
                //memo[r][c] %= INF;
            }
            if(valid(r + 1, c)){
                memo[r][c] += memo[r + 1][c];
                memo[r][c] %= INF;                
            }
            else
                memo[r][c] += 0;
         }
    }
    cout << memo[0][0] % INF << endl;
}


Measured memory_bytes: 10496
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define RG register
using namespace std;
const int N=1e5+10, M=2e5+10;
const long long mod=1e5+7;
struct dabt{ int next,to,dis; }e[M*6],hsh[M*2];
struct node{
	int u,dis;
	bool operator < (const node&x)const{return x.dis<dis;}
};
int n,m,head[N+2*M],k,dist[N+2*M],st[2*M],ed[2*M],cnt,kk;
int kh,h[mod+1];
bool vis[N+2*M];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
inline void add(int from,int to,int d){
	e[++k]=(dabt){head[from],to,d}; head[from]=k;
	e[++k]=(dabt){head[to],from,d}; head[to]=k;
}
inline void adde(int from,int to,int d){hsh[++kh]=(dabt){h[from],to,d}; h[from]=kh;}
inline int id(int a,int b){
	int ss=((long long)a*n%mod+b)%mod;
	for(RG int i=h[ss];i;i=hsh[i].next)
	{
		int v=hsh[i].to;
		if(st[v]==a && ed[v]==b) return hsh[i].dis;
	}
	st[++kk]=a; ed[kk]=b;
	adde(ss,kk,++cnt);
	return cnt;
}
inline void dij()
{
	priority_queue<node> pn;
	while(!pn.empty()) pn.pop();
	for(RG int i=1;i<=n+m*2;i++) dist[i]=2e9;
	pn.push((node){1,0}); dist[1]=0;
	while(!pn.empty())
	{
		node u=pn.top(); pn.pop();
		int x=u.u; vis[x]=1;
		for(RG int i=head[x];i;i=e[i].next)
		{
			int v=e[i].to;
			if(dist[v]>dist[x]+e[i].dis)
			{
				dist[v]=dist[x]+e[i].dis;
				if(!vis[v]) pn.push((node){v,dist[v]});
			}
		}
	}
}
int main()
{
//	freopen("Snuke's Subway Trip.in","r",stdin);
	read(n,m); cnt=n;
	for(RG int i=1,a,b,c;i<=m;i++)
	{
		read(a,b,c);
		int id1=id(a,c), id2=id(b,c);
		add(a,id1,1); add(id1,id2,0); add(id2,b,1);
	}
	dij();
	printf("%d\n",dist[n]==2e9 ? -1 : dist[n]/2);
	return 0;
}

Measured memory_bytes: 29044
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

typedef struct{
    string s;
    int t;
}MUSIC;
int main(){
    int N;
    MUSIC *music;
    string x;
    cin >> N;
    int i;
    ULL time;
    music = new MUSIC[N];
    for(i=0;i<N;i++){
        cin >> music[i].s;
        cin >> music[i].t;
    }
    cin >> x;
    for(i=0;i<N;i++){
        if(x == music[i].s){
            i++;
            break;
        }
    }
    time = 0;
    for(;i<N;i++){
        time += music[i].t;
    }
    cout << time << endl;
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}
void quickSort(struct Card A[],int n, int p, int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable =1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit)stable = 0;
  }
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}
    



Measured memory_bytes: 4032
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 5;
int main()
{
  int n,m,t,cc,i,res=0;
  int c[N_MAX];
  cin >> n >> m;
  fill(c,c+n,-1);
  for(i=0;i<m;i++){
    cin >> t >> cc;
    if(c[t-1]==-1||c[t-1]==cc){
      c[t-1]=cc;
    }else{
      cout << "-1" << endl;
      return 0;
    }
  }
  if(c[0]==0&&n>1){
    cout << "-1" << endl;
    return 0;
  }
  if(c[0]==-1&&n>1){
    res=1;
  }else if(c[0]==-1){
    res=0;
  }else{
    res=c[0];
  }
  for(i=1;i<n;i++){
    res*=10;
    if(c[i]!=-1) res+=c[i];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[100];
	int b[100];
	char op[100];
	int i=0;
	int j;
	
	while(1){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i]=='?')break;
		i++;
	}
	for(j=0;j<i;j++){
		if(op[j]=='+'){
			printf("%d\n",a[j]+b[j]);
		}else if(op[j]=='-'){
			printf("%d\n",a[j]-b[j]);
		}else if(op[j]=='/'){
			printf("%d\n",a[j]/b[j]);
		}else if(op[j]=='*'){
			printf("%d\n",a[j]*b[j]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#ABC120 D - Decayed Bridges
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
        return
    if self.parents[x] > self.parents[y]:
        x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

ans = []
ans.append(N * (N - 1) // 2)
uf = UnionFind(N)
for ab in AB[::-1]:
  a, b = ab
  if not uf.same(a-1, b-1):
    sizea = uf.size(a-1)
    sizeb = uf.size(b-1)
    ans.append(ans[-1] - sizea * sizeb)
  else:
    ans.append(ans[-1])
  uf.union(a - 1, b - 1)

for i in ans[::-1][1:]:
  print(i)
                        


Measured memory_bytes: 36052
n = int(input())
s = input()

ans = 0
for i in range(1,n):
    x = list(set(list(s[:i])))
    y = list(set(list(s[i:])))
    c, d = 0, 0
    for j in x:
        c += y.count(j)
    for j in y:
        d += x.count(j)
    ans = max(c,d,ans)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/perl
my ($n,$a,$b) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $mx = ( $a > $b ? $b : $a );
my $mn = ( $a + $b - $n );
$mn = 0 if $mn < 0;
print "$mx $mn\n";


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define MAX 100005

using namespace std;
typedef unsigned long long ull;

int main(){
  int n;
  double r=0.0;
  int x[10],y[10];
  cin >> n;
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  rep(i, n){
    for(int j=i+1; j<n; j++){
      r+=sqrt((double)pow(x[i]-x[j],2)+(double)pow(y[i]-y[j],2));
    }
  }
  r=r*2.0/(double)n;
  cout << fixed << setprecision(10) << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


template<class X> void divisor(X input, vector<X>& Dnumber){
    for (X i = 2; i*i <= input; i++)
    {
        if (input % i == 0){
            Dnumber.push_back(i);
            if (i * i  != input) Dnumber.push_back(input / i);
        }
    }
    Dnumber.push_back(input);
    sort(Dnumber.begin(), Dnumber.end());
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> div;
    vector<ll> divm;

    divisor(n, div);
    divisor(n-1, divm);

    int ans = divm.size();
    //show(div);
    rep(i, div.size()){
        ll tn = n;
        while(1){
            if (tn%div[i] == 0){
                tn /= div[i];
            } else {
                if (tn == tn%div[i]) break;
                tn %= div[i];
            }
            if (tn==1){
                ans++;
                break;
            }

        }
    }
    if (n==2) ans = 1;
    cout << ans << endl;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  
  int step = M / 2;
  for (int i = 0; i < step; i++) {
    cout << i + 1 << " " << M - i << endl;
  }
  step = (M + 1) / 2;
  for (int i = 0; i < step; i++) {
    cout << i + M + 1 << " " << 2 * M + 1 - i << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	  int H, W;
	  int h, w;
	  int ans = 0;

	  cin >> H >> W;
	  cin >> h >> w;

	  ans = H * W - h * W - (w * H - w * h);
	  cout << ans << endl;


}


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

void solve(){
    ll s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}
   

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //int t;scanf("%d", &t);while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{


        ll n,k,sm=0;
        cin>>n>>k;
        vector<int>v;
        for(int i=0; i<k; i++)
        {
            int x;
            cin>>x;
            v.push_back(x);
            sm+=x;
        }

        ll x=n-sm;

        if(x<0)
        {
            cout<<-1<<endl;
        }
        else
        {
            cout<<x<<endl;
        }






    return 0;
}


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

char pbel(string x) {
	if (x == "11")return 'a';
	else if (x == "12")return 'b';
	else if (x == "13")return 'c';
	else if (x == "14")return 'd';
	else if (x == "15")return 'e';
	else if (x == "21")return 'f';
	else if (x == "22")return 'g';
	else if (x == "23")return'h';
	else if (x == "24")return 'i';
	else if (x == "25")return 'j';
	else if (x == "31")return 'k';
	else if (x == "32")return 'l';
	else if (x == "33")return 'm';
	else if (x == "34")return 'n';
	else if (x == "35")return 'o';
	else if (x == "41")return'p';
	else if (x == "42")return'q';
	else if (x == "43")return'r';
	else if (x == "44")return's';
	else if (x == "45")return't';
	else if (x == "51")return'u';
	else if (x == "52")return'v';
	else if (x == "53")return 'w';
	else if (x == "54")return'x';
	else if (x == "55")return'y';
	else if (x == "61")return'z';
	else if (x == "62")return'.';
	else if (x == "63")return'?';
	else if (x == "64")return'!';
	else if (x == "65")return' ';
	else return'+';
}

int main() {
	string s;
	while (cin >> s) {
		string pr;
		int a = s.size();
		int flg = 0;

		if (a % 2 == 0) {
			for (int i = 0;i < a;i += 2) {
				string sa;
				sa += s[i];
				sa += s[i + 1];
				if (pbel(sa) == '+') {
					flg = 1;
					break;
				}
				else {
					pr += pbel(sa);
				}
			}
		}
		else { flg = 1; }

		if (flg == 1)cout << "NA" << endl;
		else cout << pr << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <cstdio>
#include <algorithm>

using namespace std;

int calc(long long x) {
    int sum = 0;
    
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }
    
    return sum;
}

int main() {
    long long n, x = 1;
    
    scanf("%lld", &n);
    
    while (x * 10 <= n) x *= 10;
    
    printf("%lld\n", max(calc(n), calc(n / x * x - 1)));
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

i64 gcd(i64 a, i64 b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

i64 lcm(i64 a, i64 b) {
  i64 g = gcd(a, b);
  return a / g * b;
}

int main() {
  i64 X;
  cin >> X;
  i64 M = 360;
  cout << lcm(X, 360) / X << endl;
}



Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String a = sc.next();

        if (a.equals("Sunny"))
            System.out.println("Cloudy");
        else if (a.equals("Cloudy"))
            System.out.println("Rainy");
        else if (a.equals("Rainy"))
            System.out.println("Sunny");
    }
}


Measured memory_bytes: 35288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;
const int MOD = 10000;

int pasta[101];
int dp[101][4][4];

int main(){
	int n, k;
	cin >> n >> k;
	rep(i, k){
		int a, b;
		cin >> a >> b;
		pasta[a] = b;
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n; i++){
		if(pasta[i] == 0){
			FOR(j, 1, 4){
				rep(k, 4){
					rep(l, 4){
						if(j == k && k == l) continue;
						dp[i][j][k] += dp[i-1][k][l];
						dp[i][j][k] %= MOD;
					}
				}
			}
		}else{
			rep(k, 4){
				rep(l, 4){
					if(pasta[i] == k && k == l) continue;
					dp[i][pasta[i]][k] += dp[i-1][k][l];
					dp[i][pasta[i]][k] %= MOD;
				}
			}
		}
	}

	int ans = 0;
	rep(i, 4) rep(j, 4){
		ans += dp[n][i][j];
		ans %= MOD;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt(pow((x1 - x2), 2.0) + pow((y1 - y2), 2.0)));

    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n-1;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  vll b(3);
  rep(i,n) cin>>a[i];
  rep(i,n){
    if(a[i]%2==1) b[0]++;
    else if(a[i]%4==0) b[2]++;
    else b[1]++;
  }
  if(b[0]-1>b[2]) COUT("No");
  else if(b[1]==0&&b[0]-1<=b[2]) COUT("Yes");
  else if(b[1]!=0&&b[0]<=b[2]) COUT("Yes");
  else COUT("No");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;

using D = double;

int main(){
    D d;
    scanf("%lf", &d);
    D ans = d;
    ans = max(ans, sqrt(2)*d);
    REP(y, 1, (int)(d + EPS)+1) {
        D x = sqrt(d*d-y*y);
        ans = max(ans, max(x, 1.0)+y);
    }
    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 3232