akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int lower = n / 1.08;
  int upper = (n + 1) /1.08;
  ++upper;
  bool flag = false;
  int x = lower;
  for (; x <= upper; ++x) {
    int v = (int)(x * 1.08);
    if (v == n) {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << x << '\n';
  else
    cout << ":(\n";
  return 0;
}
// (int)(x * 1.08) = n
// x * 1.08 = n + 0....
// x = (n + 0....)/1.08 = 


Measured memory_bytes: 3632
<?php
	$n = trim( fgets( STDIN ) );
	$nums = [];
	for( $i=0; $i<$n; $i++ ) {
		array_push( $nums, intval( trim( fgets( STDIN ) ) ) );
	}
	$cnt = $n;
	$end = max( $nums );
	
	for( $i=2; $i*$i<=$end; $i++ ) {
		$nums2 = [];
		for( $j=0; $j<count($nums); $j++ ) {
			if( 0 == $nums[$j]%$i )  {
				if( $nums[$j] != $i ) {
					$cnt--;
				}
			} else {
				array_push( $nums2, $nums[$j] );
			}
		}
		$nums = $nums2;
	}
	print $cnt;
?>

Measured memory_bytes: 17356
#include<stdio.h>

int main() {
    int a, b, c; //変数の宣言
    int x;
    
    //入力
    scanf("%d %d %d", &a, &b, &c);
    
    //aが一番小さいつもりで
    
    //処理
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    
    //この時点で確実にa<b
    

    if (b > c) {
        x = b;
        b = c;
        c = x;
    }
    
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }

    
    //出力
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}



Measured memory_bytes: 2032
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
typedef long long LL;
typedef long double LD;

using namespace std;

int main()
{
	double a,b,h,m,w1,w2,t1,t2,t3,l3;
	cin >> a >> b >> h >> m;
	w1 = 2*M_PI/720.0;
	w2 = 2*M_PI/60.0;
	t1 = w1*(h*60+m);
	t2 = w2*m;
	t3 = abs(t1-t2);
	l3 = sqrt(a*a+b*b-(2*a*b*cos(t3)));
	printf("%.20lf",l3);
	
	return 0;
} 

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

int main(){
  int a, b;
  cin >> a >> b;

  int count = 0;
  rep(i,a,b){
    auto isP = [](int n){
      ostringstream sout;
      sout << n;
      string s = sout.str();
      string b = s.substr(0, (s.size()+1)/2);
      string a = s.substr((s.size()-1)/2, string::npos);
      reverse(a.begin(), a.end());
      return b == a;
    };
    if (isP(i)){
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3588
cl = []
for i in range(3):
  c = list(map(int, input().split( )))
  cl.append(c)
rcl, trcl, acl, bcl = [], [], [], []
tcl = [x for x in zip(*cl)]
for i in range(3):
  rcb = []
  trca = []
  for j in range(3):
    if j < 2:
      rc = cl[i][j] - cl[i][j + 1]
      trc = tcl[i][j] - tcl[i][j + 1]
    else:
      rc = cl[i][j] - cl[i][j - 2]
      trc = tcl[i][j] - tcl[i][j - 2]
    rcb.append(rc)
    trca.append(trc)
  rcl.append(rcb)
  trcl.append(trca)
for i in range(3):
  if i < 2:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i + 1])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i + 1])]
  else:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i - 2])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i - 2])]
  bcl.append(bc)
  acl.append(ac)
f = lambda x: True if x == 0 else False
aclb = [all([f(n) for n in acl[m]]) for m in range(3)]
bclb = [all([f(n) for n in bcl[m]]) for m in range(3)]
if all(aclb) & all(bclb):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	map<int, vector<int> > a;

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

	priority_queue<int> q;

	int r=0;

	for(int i=0; i<m; i++){
		for(int j=0; j<(int)a[i].size(); j++){
			q.push(a[i][j]);
		}
		if(!q.empty()){
			r+=q.top();
			q.pop();
		}
	}

	cout << r << endl;

	return 0;

}






Measured memory_bytes: 10880
"""
author : halo2halo
date : 11, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, read().split())

l, r = B - (A - 1), B + (A - 1)
ans = [str(i) for i in range(l, r + 1)]
print(' '.join(ans))


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

struct graph_t {
	std::vector<std::vector<std::pair<int, int>>> G;
	void add_edge(int u, int v, int w) {
		G[u].emplace_back(w, v);
		//std::cout << u << " -> " << v << ": " << w << '\n';
	}
	int size() {
		return G.size();
	}
	int new_var() {
		int res = size();
		G.emplace_back();
		return res;
	}
	int64_t dijkstra(int s, int t) {
		std::priority_queue<std::pair<int64_t, int>, std::vector<std::pair<int64_t, int>>, std::greater<std::pair<int64_t, int>>> q;
		std::vector<int64_t> dis(size(), LLONG_MAX);
		q.emplace(dis[s] = 0, s);
		while (!q.empty()) {
			int64_t w = q.top().first;
			int u = q.top().second;
			q.pop();
			if (w != dis[u]) continue;
			for (std::pair<int, int>& it : G[u]) {
				if (dis[u] + it.first < dis[it.second]) {
					dis[it.second] = dis[u] + it.first;
					q.emplace(dis[it.second], it.second);
				}
			}
		}
		return dis[t] == LLONG_MAX ? -1 : dis[t];
	}
};

struct seg_t {
	const int n;
	std::vector<int> seg;
	template <class Fun>
	seg_t(int n, graph_t& graph, Fun&& fun): n(n), seg(n + n) {
		for (int i = 0; i < n; i++)
			seg[i + n] = i;
		for (int i = n - 1; i; i--) {
			seg[i] = graph.new_var();
			fun(seg[i], seg[i + i + 0]);
			fun(seg[i], seg[i + i + 1]);
		}
	}
	template <class Fun>
	void travel(int l, int r, Fun&& fun) {
		for (l += n, r += n; l < r; l /= 2, r /= 2) {
			if (l & 1) fun(seg[l++]);
			if (r & 1) fun(seg[--r]);
		}
	}
};

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	graph_t graph;
	for (int i = 0; i < n; i++)
		graph.new_var();
	seg_t segA(n, graph, [&](int u, int v) {
		graph.add_edge(u, v, 0);
	});
	seg_t segB(n, graph, [&](int u, int v) {
		graph.add_edge(v, u, 0);
	});
	for (int i = 0, l, r, w; i < m; i++) {
		scanf("%d%d%d", &l, &r, &w);
		--l;
		int var = graph.new_var();
		segA.travel(l, r, [&](int v) {
			graph.add_edge(var, v, 0);
		});
		segB.travel(l, r, [&](int v) {
			graph.add_edge(v, var, w);
		});
	}
	printf("%lld\n", graph.dijkstra(0, n - 1));
	return 0;
}

Measured memory_bytes: 57704
import sys
import bisect
input = sys.stdin.readline

pi = 3.1415926535897938
x1, y1, x2, y2 = [int(v) for v in input().split()]
if x1 > x2:
    x1, x2 = x2, x1
    y1, y2 = y2, y1
ans = 100*(abs(x2-x1) + abs(y2-y1))
d = -1 if y1 > y2 else 1

xmax, xmin = max(x1,x2), min(x1,x2)
ymax, ymin = max(y1,y2), min(y1,y2)
n = int(input())
fountains = []
for i in range(n):
    x, y = [int(v) for v in input().split()]
    if xmin <= x <= xmax and ymin <= y <= ymax:
        fountains.append([x, y])

if x1 == x2 or y1 == y2:
    if len(fountains) == 1:
        ans += 10*pi - 20
else:
    fountains.sort()
    fountains = [-10**9] + [ i[1]*d for i in fountains ]
    m = len(fountains)
    lis_list = [ 10**9 for i in range(m) ]
    for i in fountains:
        a = bisect.bisect_left(lis_list, i)
        lis_list[a] = i

    k = -1
    for i in lis_list:
        if i != 10**9:
            k += 1

    if xmax - xmin + 1 == k or ymax - ymin + 1 == k:
        ans -= (k-1)*(20-5*pi)
        ans += 10*pi - 20
    else:       
        ans -= k*(20-5*pi)

print(ans)

Measured memory_bytes: 88616
import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
S={}
cd=[0]*26
for i in range(D):
  S[i] = [int(x) for x in input().rstrip('\n').split()]
for i in range(D):
  s1 = S[i]
  s1_s=sorted(s1,reverse=True)
  if i!=D-1:
    s2=S[i+1]
    s1_a=[x-y for x,y in zip(s1,cd)]
    s2_i=[x-y for x,y in zip(s2,cd)]
    s1_b=sorted(s1_a,reverse=True)
    if s2_i.index(max(s2_i))==s1_a.index(s1_b[0]):
      x = s1_a.index(s1_b[1])+1
      cd = [y+z for y,z in zip(cd,cs)]
      cd[x-1]=0
      print(x)
    else:
      x = s1_a.index(s1_b[0])+1
      cd = [y+z for y,z in zip(cd,cs)]
      cd[x-1]=0
      print(x)
  else:
    s1_a=[x-y for x,y in zip(s1,cd)]
    print(s1_a.index(max(s1_a))+1)

Measured memory_bytes: 9544
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;



int main() {
  //
  string s; int K;
  cin >> s;
  cin >> K;


  set<string> str_set;
  for (int i = 1; i <= K; ++i) {
    for (int j = 0; j < s.size(); ++j) {
      str_set.insert(s.substr(j, i));
    }
  }

  vector<string> strs;
  for(string str: str_set) strs.push_back(str);
  sort(strs.begin(), strs.end());

//  for (string str: strs) {
//    cout << str << endl;
//  }
  cout << strs[K-1] << endl;

  return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << static_cast<char>(s1[0] - 32) << static_cast<char>(s2[0] - 32) << static_cast<char>(s3[0] - 32) << endl;
  return 0;
}


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

struct Dice {
  int faces[6 + 1];
  Dice() : faces{0, 1, 2, 3, 4, 5, 6} {}
  void order(char cmd) {
    switch (cmd) {
      case 'E':swap(faces[1], faces[4]);
        swap(faces[4], faces[6]);
        swap(faces[6], faces[3]);
        break;
      case 'N':swap(faces[1], faces[2]);
        swap(faces[2], faces[6]);
        swap(faces[6], faces[5]);
        break;
      case 'S':swap(faces[1], faces[5]);
        swap(faces[5], faces[6]);
        swap(faces[6], faces[2]);
        break;
      case 'W':swap(faces[1], faces[3]);
        swap(faces[3], faces[6]);
        swap(faces[6], faces[4]);
        break;
      case 'L':swap(faces[2], faces[4]);
        swap(faces[4], faces[5]);
        swap(faces[5], faces[3]);
        break;
      case 'R':swap(faces[2], faces[3]);
        swap(faces[3], faces[5]);
        swap(faces[5], faces[4]);
        break;
    }
  }
};

enum Faces { Top = 1, Front = 2, Right = 3, Left = 4, Back = 5, Bottom = 6 };

int A[6 + 1], B[6 + 1];
Dice b;

bool dfs(Dice a, int cnt) {
  if (A[a.faces[Top]] == B[b.faces[Top]] &&
      A[a.faces[Front]] == B[b.faces[Front]] &&
      A[a.faces[Right]] == B[b.faces[Right]] &&
      A[a.faces[Left]] == B[b.faces[Left]] &&
      A[a.faces[Back]] == B[b.faces[Back]] &&
      A[a.faces[Bottom]] == B[b.faces[Bottom]]) {
    return true;
  }
  // ざっくり言って4回ころがせば正解があるはず
  if (cnt == 4)
    return false;

  ++cnt;
  a.order('E');
  if (dfs(a, cnt)) return true;
  a.order('W');

  a.order('W');
  if (dfs(a, cnt)) return true;
  a.order('E');

  a.order('S');
  if (dfs(a, cnt)) return true;
  a.order('N');

  a.order('N');
  if (dfs(a, cnt)) return true;
  a.order('S');

  return false;
}

int main() {
  for (int i{1}; i <= 6; ++i)
    cin >> A[i];
  for (int i{1}; i <= 6; ++i)
    cin >> B[i];

  Dice a;
  cout << (dfs(a, 0) ? "Yes" : "No") << endl;
}



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

int main(){
    int m, f, b;
    cin >> m >> f >> b;
    if(m >= b) cout << 0 << endl;
    else if(m < b && b <= m + f) cout << b - m << endl;
    else cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const long long int INF= (long long int)1e15 + 1;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
int main() {
    int N;
    cin >> N;
    vector<vector<long long int>> D(N, vector<long long int>(N, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> D[i][j];
        }
    }
 
    long long int ans = 0;
    bool invalid = false;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += D[i][j];
            for (int k = 0; k < N; k++) {
                if (i == k || j == k) continue;
                if (D[i][k] + D[k][j] < D[i][j]) {
                    invalid = true;
                    break;
                }
                if (D[i][k] + D[k][j] == D[i][j]) {
                    ans -= D[i][j];
                    break;
                }
            }
            if (invalid) break;
        }
        if (invalid) break;
    }
 
    if (invalid) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string S;
int N;
int main()
{
    cin >> S;
    N = S.size();
    ll black_cnt = 0;
    ll result = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'W')
        {
            result += black_cnt;
        }
        else
        {
            black_cnt++;
        }
    }
    cout << result << endl;
    return 0;
}


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll asum = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        asum += A[i];
    }
    vector<ll> div;
    for ( ll i = 1; i * i <= asum ; i++ ) {
        if ( asum % i == 0 ) {
            div.push_back(i);
            if ( i * i != asum ) div.push_back(asum / i);
        }
    }
    sort(div.begin(), div.end(), greater<>());
    for ( ll d : div ) {
        if ( d == 1 ) return 1;
        priority_queue<ll> qp, qn;
        ll sp = 0, sn = 0;
        for ( int i = 0; i < N; i++ ) {
            ll x = A[i] % d;
            if ( x <= d/2 ) {
                qn.push(x);
                sn += x;
            } else {
                qp.push(d-x);
                sp += d-x;
            }
        }
        while ( sn != sp ) {
            if ( sn > sp ) {
                ll x = qn.top();
                qn.pop();
                sn -= x;
                qp.push(d-x);
                sp += d-x;
            } else {
                ll x = qp.top();
                qp.pop();
                sp -= x;
                qn.push(d-x);
                sn += d-x;
            }
        }
        if ( sp <= K ) return d;
    }
    return 1;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

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

  vector<int> v(n);
  vector<int> m(n+1);
  m[0] = 200001;
  for(int i=0; i < n; i++) cin >> v[i];

  int result = 0;
  for(int i=0; i < n; i++) {
    if(i==0 || m[i] > v[i]) result++;
    m[i+1] = min(v[i], m[i]);
  }
  cout << result << endl;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
//#define ld long double
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;
typedef long double ld;
bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}




ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a+b)%r;
}
ll mulmod(ll a,ll b,ll r)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    a-=b;
    if(a<0)a+=mod;
    return a%mod;
}
struct CustomCompare
{
    bool operator()(ll a,ll b)
    {
        return a>b;
    }
};
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll a,b,c,d; cin>>a>>b>>c>>d;
ll ans = LLONG_MIN;
if(a<0&&c<0)ans= max(ans,a*c);
ans = max(ans,d*b);
if((a<=0&&b>=0)||(c<=0&&d>=0))ans = max(ans,0LL);

if(b<0)ans = max(ans,b*c);
if(d<0)ans = max(ans,d*a);
cout<<ans<<"\n";
return 0;
}
/*
1
3 1
023l
2 3
*/


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  vector<ll>a(3);
  rep(i,0,3)cin>>a[i];
  rep(i,0,3)rep(j,i+1,3){
    if(a[i]==a[j]&&a[i]!=a[3^i^j])judge=false;
  }
  ans1(!judge);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b[100]={},c[100]={},count_same=0,flag=0;
  scanf("%d",&a);
  for(int i=0;i<a;i++){
      scanf("%d%d",&b[i],&c[i]);
    if(b[i]==c[i]) count_same++;
    else count_same=0;
    if(count_same==3){
      flag++;
      break;
    }
  }
  
  if(flag)printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	vector<int> A(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> A[i];
	}
	int k;
	cin >> k;
	for (int i = 0; i < 5; i++)
	{
		for (int j = 0; j  < i; j ++)
		{
			int d = abs(A[i] - A[j]);
			if (d > k)
			{
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;
}


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

int mod = 1000000007;

int main()
{
    vector<vector<int>> list(3, vector<int>(3));
    vector<vector<bool>> result(3, vector<bool>(3, false));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> list[i][j];
        }
    }
    int N;
    cin >> N;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (tmp == list[j][k])
                    result[j][k] = true;
            }
        }
    }
    bool ans = false;
    for (int i = 0; i < 3; i++)
    {
        if(result[0][i]&&result[1][i]&&result[2][i])
            ans = true;
    }
    for (int i = 0; i < 3; i++)
    {
        if (result[i][0] && result[i][1] && result[i][2])
            ans = true;
    }
    if (result[0][0] && result[1][1] && result[2][2])
        ans = true;
    if (result[2][0] && result[1][1] && result[0][2])
        ans = true;

    cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int x = N/1000;
		int y = 0;
		if (N%1000 != 0) {
			y = 1000*(x+1) - N;
		} else {
			y = 1000*x - N;
		}
		System.out.println(y);
	}
}


Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+5];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans = 0;
	for(ll i=2;i<n;i++)
	{
		for(ll j=0;j<i;j++)
		{
			ll val = a[i]-a[j];
			ll idx = upper_bound(a,a+n,val)-a;
			if (idx>=0)
			{
				ll m = max(0ll,i-idx);
				if(idx<=j)
					m--;
				ans+=m;
			}
		}
	}
	cout<<ans/2;
}

Measured memory_bytes: 256
#sizeありversion
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}
        self._size = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0
        self._size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
            self._size[x] += self._size[y]
            self._size[y] = 0
        else:
            self.p[x] = y
            self._size[y] += self._size[x]
            self._size[x] = 0
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    #頂点xが属するグループと同じグループに属する頂点数を得る
    def size(self, x):
        return self._size[self.findSet(x)]

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]


N, M = map(int, input().split())
l = [[int(i) for i in input().split()] for i in range(M)]

ds = DisjointSet()
for i in range(N):
    ds.makeSet(i+1)

ans = [0] * M
ans[M-1] = N * (N - 1) // 2

for i in range(M-1, 0, -1):
    a, b = l[i]
    if ds.same(a, b):
        ans[i-1] = ans[i]
    else:
        x = ds.size(a)
        y = ds.size(b)
        ans[i-1] = ans[i] - x * y
        ds.unite(a, b)

for a in ans:
    print(a)

Measured memory_bytes: 141388
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	vector<pair<int, int>> p(N);
	rep(i, N) {
		int x; cin >> x;
		p[i] = make_pair(x,i);
	}

	sort(p.begin(), p.end());
	
	rep(i, N) {
		cout << p[i].second + 1 << " " << flush;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3956
#include <iostream>

using namespace std;
typedef long long ll;
bool f[100010];
ll a[100010];
int main(){
    ll i,n,x,m; cin >> n >> x >> m;
    for(i=0;i<m;i++) f[i] = false;
    a[0] = x;
    for(i=1;i<=m;i++) a[i] = a[i - 1]*a[i - 1]%m; 
    int l = -1,r = -1;
    for(i=1;i<=m;i++){
        if(f[a[i]]){
            r = i;
            break;
        }
        f[a[i]]= true;
    }
    for(i=0;i<=m;i++){
        if(a[i]==a[r]){
            l = i; break;
        }
    }
    ll sum = 0,sum1 = 0;
    for(i=0;i<l;i++) sum += a[i];
    for(i=l;i<r;i++) sum1 += a[i];
    n -= l;
    ll ti = n/(r - l),ans = ti*sum1 + sum;
    n -= ti*(r - l);
    for(i=l;i<n + l;i++) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 4488
N = int(input())
A = list(map(int, input().split()))
flag = None
c = 1 
def check(i):
        for j in range(i, N - 1): 
                if A[j] - A[j + 1] < 0:
                        return 1 
                elif A[j] - A[j + 1] > 0:
                        return -1
flag = check(0)
for i in range(N - 1): 
        if flag == None:
                break
        elif flag == 1:
                if A[i] - A[i + 1] > 0:
                        c += 1
                        flag = check(i + 1)
        elif flag == -1: 
                if A[i] - A[i + 1] < 0:
                        c += 1
                        flag = check(i + 1)
print(c)

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

#define N 50 //生徒の最大人数

int main(void) {
	int s;
	double w, h;
	int id[N];
	int count = 0;
	
	while(scanf("%d,%lf,%lf", &s, &w, &h) != EOF) {
		double BMI = w / (h * h);
		if(BMI >= 25) {
			id[count] = s;
			++count;
		}
	}
	
	for(int i = 0; i < count; ++i) {
		cout << id[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
using System;

namespace ALDS1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            string[] str1 = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for (int i = 0; i < n; ++i)
            {
                A[i] = int.Parse(str1[i]);
            }

            Output(A);

            for (int i = 1; i < n; ++i)
            {
                int v = A[i];
                int j = i - 1;
                while ((j >= 0) & (A[j] > v))
                {
                    A[j + 1] = A[j];
                    j--;
                    if (j < 0)
                    {
                        break;
                    }
                }
                A[j + 1] = v;

                Output(A);
            }
        }

        static private void Output(int[] A)
        {
            for (int i = 0; i < A.Length; ++i)
            {
                Console.Write("{0}", A[i]);
                if (i < A.Length - 1)
                {
                    Console.Write(" ");
                }
                else
                {
                    Console.Write("\n");
                }
            }
        }
    }
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, W;
vector<ll> w(110);
vector<ll> v(110);

vector<vector<ll>> dp(110, vector<ll>(100100, 0));

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

    cin >> N >> W;
    REP(i, N) cin >> w.at(i) >> v.at(i);

    dp.at(0).at(0) = 0;

    for (int i = 0; i < N; i++) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w < w.at(i)) {
                chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
            } else {
                chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
                chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - w.at(i)) + v.at(i));
            }
        }
    }

    cout << dp.at(N).at(W) << endl;

    return 0;
}

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

// chmax, chmin
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 <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long A, long long B)
{

  LL ans = 0;
  ans += N / (A + B) * A;
  LL remain = N % (A + B);
  remain = min(remain, A);
  ans += remain;
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final int INF = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[100001];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		long ans = 1;
		for(int i = 0 ; i < n ; i++) b[a[i]]++;
		if(n % 2 == 0) {
			boolean ok = true;
			for(int j = 0 ; j * j < n ; j++) {
				if(b[2 * j + 1] != 2) ok = false;
			}
			if(ok) {
				for(int i = 0 ; i < n / 2 ; i++) {
					ans = ans * 2 % INF;
				}
			} else {
				System.out.println(0);
				return;
			}
		} else {
			boolean ok = true;
			for(int j = 0 ; j * j < n ; j++) {
				if(j == 0) {
					if(b[j] != 1) ok = false;
				} else if(b[j * 2] != 2) ok = false;
			}
			if(ok) {
				for(int i = 0 ; i < n / 2 ; i++) {
					ans = ans * 2 % INF;
				}
			} else {
				System.out.println(0);
				return;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 58112
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, sum = 0; cin >> n;
    vi a(n+1, 0);
    repf(i, n){
        cin >> a[i];
        if(a[i-1] > a[i]){
            ll sub = (a[i-1]-a[i]);
            a[i] += sub;
            sum += sub;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4776
#include <iostream>

int main()
{
    std::string s;
    std::cin >> s;

    std::string right = "CODEFESTIVAL2016";

    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != right[i]) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn divisors(x: i64) -> Vec<i64> {
    let mut d = 1;
    let mut ds = vec![];
    while d * d <= x {
        if x % d == 0 {
            ds.push(d);
            ds.push(x / d);
        }
        d += 1
    }
    ds.sort();
    ds.dedup();
    ds
}

// x を d で割った余り
fn rep(x: i64, d: i64) -> i64 {
    x % d
}

// x に足すと d の倍数になる最小値
fn complement(x: i64, d: i64) -> i64 {
    (d - x % d) % d
}

fn solve(A: &mut [i64], K: i64) -> i64 {
    let N = A.len();
    let sum = A.iter().sum::<i64>();

    for d in divisors(sum).into_iter().rev() {
        // d で割った余りだけ考える。
        // 余りの小さい値を -1 して、大きい値を +1 するため、余りに関して昇順にする。
        A.sort_by(|&l, &r| rep(l, d).cmp(&(rep(r, d))));

        // A[..i] を減少させる量
        let mut neg = 0;
        // A[i..] を増加させる量
        let mut pos = A.iter().map(|&a| complement(a, d)).sum::<i64>();

        for i in 0..N + 1 {
            // 減少量と増加量が一致して操作回数がどちらも K 以下なら操作が存在する
            if neg <= K && pos <= K && neg == pos {
                return d;
            }

            if i < N {
                neg += A[i] % d;
                pos -= complement(A[i], d);
            }
        }
    }

    1
}

fn main() {
    let (_, K) = read!(usize, i64);
    let mut A = read![[i64]];
    println!("{}", solve(&mut A, K))
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
ll power(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=((c*c)%mod);
	return res;
}
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	int s,w;
	cin>>s>>w;
	if(s>w)
		cout1("safe");
	else
		cout1("unsafe");
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}


Measured memory_bytes: 3632
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	long ans = min(RD, RD);
	ans     += min(RD, RD);

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	int best = BIG;
	for (int g=0;g<100;g++)
	{
		for (int x = 0; x <= 50; ++x)
		{
			for (int y = 0; y <= 50; ++y)
			{
				for (int z = 0; z <= 50; ++z)
				{
					int da = g - a - x - z;
					int db = g - b - x - y;
					int dc = g - c - y - z;

					if (da >= 0 && db >= 0 && dc >= 0 && da % 2 == 0 && db % 2 == 0 && dc % 2 == 0)
					{
						int num = x + y + z + da / 2 + db / 2 + dc / 2;
						amin(best, num);

					}



				}

			}

		}


	}

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



	return 0;
}


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

const int N = 100010;

typedef long long LL;

LL D[N]; int id[N], sz[N];
map<LL, int> mp;

inline void Fuck() {
	puts("-1"), exit(0);
}

vector<int> G[N];

inline void adde(int from, int to) {
	G[from].push_back(to), G[to].push_back(from);
}

LL dfs(int u, int f) {
	LL res = 0;
	for (auto v : G[u]) if (v != f) 
		res += dfs(v, u) + sz[v];
	return res;
}

int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &D[i]), mp[D[i]] = i, sz[i] = 1, id[i] = i;
	sort(id + 1, id + n + 1, [](int a, int b){return D[a] > D[b];});
	for (int i = 1; i < n; i++) {
		int v = id[i];
		LL tmp = D[v] - n + sz[v] * 2;
		if (!mp.count(tmp) || tmp >= D[v]) Fuck();
		adde(v, mp[tmp]), sz[mp[tmp]] += sz[v];
	}
	if (dfs(id[n], 0) != D[id[n]]) Fuck();
	for (int i = 1; i <= n; i++)
		for (auto v : G[i]) if (v > i) printf("%d %d\n", i, v);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    ll ans = 0;
    if (A >= 13){
        ans = B;
    } else if (6 <= A && A <= 12){
        ans = B / 2;
    }
    cout << ans << endl;
}


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


Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	int n,a,b;

	while(true){

	cin >> n;

	if(n==0) break;

	int p=0; int q=0;
	rep(i,n){

	cin >> a >> b;

	if(a>b) p+=a+b;
	else if(a<b) q+=a+b;
	else{ p+=a; q+=b; }

	}

	cout << p << " " << q << endl;

	}

    return 0;

}

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

using namespace std;
typedef long long ll;

int main (){
    ll l,r;
    cin >> l >> r;
    ll res=2019;
    ll tmp;
    r=min(r,(l+4038));
    for (ll i = l; i < r; i++){
        for (ll j = i+1; j <= r; j++){
            tmp=i*j%2019;
            if(tmp < res){
                res = tmp;
            }
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(b>a+w){
    cout << b-(a+w) << endl;
  }
  else if(b+w<a){
    cout << a-(b+w) << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a[5],b,i,j,k,A=0;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
  }
  for(j=0;j<5;j++){
    for(k=j+1;k<5;k++){
      if(a[j] < a[k]){
	b = a[j];
	a[j] = a[k];
	a[k] = b;
      }
    }
  }
  for(i=0;i<5;i++){
    if(A < 4){
      printf("%d ",a[i]);
    }
    else{
      printf("%d\n",a[i]);
    }
    A++;
  }
  return 0;
}

Measured memory_bytes: 596