akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
using namespace std;

int main()
{
    int x, y, z;
    ni(x), ni(y), ni(z);
    ll a = x, b = y, c = z;
    ll k = 0;
    nl(k);
    if (abs(a - b) > INF)
        return !printf("Unfair\n");
    else
    {
        if (k & 1)
            printf("%I64d\n", b - a);
        else
            printf("%I64d\n", a - b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int b[n - 1];
    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &b[i]);
    }

    long sum = b[n - 2];

#define MIN(a, b) (((a) < (b)) ? (a) : (b))

    for (int i = n - 2; i >= 1; i--) {
        sum += MIN(b[i], b[i - 1]);
    }
    sum += b[0];

    printf("%ld\n", sum);
}


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

void Main()
{
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for(int64_t i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    map<int64_t, int64_t> m;
    for(int64_t i = 0; i < N; ++i)
    {
        decltype(m)::iterator it = m.find(A[i]);
        if(it != m.end())
        {
            ++it->second;
        }
        else
        {
            m.insert(make_pair(A[i], 1));
        }
    }

    map<int64_t, int64_t> mm;
    int64_t r = 0;
    for(auto p : m)
    {
        r += p.second != 1 ? p.second * (p.second - 1) / 2 : 0;
    }
    for(int64_t i = 0; i < N; ++i)
    {
        decltype(m)::iterator it = m.find(A[i]);
        int64_t a = it->second != 1 ? it->second * (it->second - 1) / 2 : 0;
        int64_t b = it->second - 1 != 1 ? (it->second - 1) * (it->second - 2) / 2 : 0;
        cout << r - a + b << endl;
    }
}

int main()
{
    Main();
}


Measured memory_bytes: 12672
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
#define ll long long
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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll l(n); REP(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    for (int i=n-1; i>=0; i--) {
        for (int j=i-1; j>=0; j--) {
            ll l1 = l[i], l2 = l[j];
            auto it = lower_bound(ALL(l), l1+l2);
            ll tmp = l.end() - it;
            ans += n-1-i - tmp;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=0;
    if(a>=0&&b>=0&&c<=0&&d<=0){
        ans = a*d;
    }else if(a<=0&&b<=0&&c>=0&&d>=0){
        ans = b*c;
    }else{
        if(a*c>b*d){
            ans = a*c;
        }else{
            ans = b*d;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int M=in(),D=in();
	int num = 0;
	for(int m=1;m<=M;m++){
		for(int d=1;d<=D;d++){
			int d1 = d%10,d2 = d/10;
			if(d1>=2 && d2>=2 && d1*d2==m){
				num++;
			}
		}
	}
	
	out(num);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
const long long mod = 1e9 + 7;

void noOfWays(vector<vector<char>>& grid, vector<vector<int>>& dp, int h, int w){
    // first row
    for(int i=0; i<w; i++){
        if(dp[0][i] == -1){
            break;
        }
        dp[0][i] = 1;
    }
    // first col
    for(int i=0; i<h; i++){
        if(dp[i][0] == -1){
            break;
        }
        dp[i][0] = 1;
    }
    for(int i=1; i<h; i++){
        for(int j=1; j<w; j++){
            if(dp[i][j] == -1)
                continue;
            if(dp[i-1][j] != -1)
                dp[i][j] = ((dp[i][j] % mod) + (dp[i-1][j] % mod)) % mod;
            if(dp[i][j-1] != -1)
                dp[i][j] = ((dp[i][j] % mod) + (dp[i][j-1] % mod)) % mod;
        }
    }
}

int32_t main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    vector<vector<int>> dp(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> grid[i][j];
            if(grid[i][j] == '#'){
                dp[i][j] = -1;
            }
        }
    }
    noOfWays(grid, dp, h, w);
    cout << dp[h-1][w-1] << "\n";
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//整数型を宣言して読み込む
		int r = sc.nextInt();
		int D = sc.nextInt();			
		int x2000 = sc.nextInt();				
		int ans=x2000;
		for (int i=0;i<10;i++){
		ans=r*ans-D;		
		System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;

int main() {
	int N, R;
	cin >> N >> R;
	if (N >= 10) {
		cout << R << endl;
	
	}
	else {
		cout << R + (100 * (10 - N)) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int x=1;x<=n;x++)
    {
        for(int y=1;y<=m;y++)
        {
            if(s[x-1]==t[y-1])
                {dp[x][y]=max(dp[x-1][y-1]+1,dp[x][y-1]);
                }
            else
                dp[x][y]=max(dp[x][y-1],dp[x-1][y]);
        }
    }
    string w;
    while( m && n)
    {
        if(s[n-1]==t[m-1])
            {w=s[n-1]+w;
            --n;--m;}
        else
        {
            if(dp[n][m-1]>dp[n-1][m])
                --m;
            else
                --n;
        }
    }
    cout<<w<<endl;
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main(){
  int A, B; cin >> A >> B;
  int M = max({A+B, A-B, A*B});
  cout << M;
  return 0;
}

Measured memory_bytes: 256
//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
const char lf = '\n', splf[] = " \n";
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#define TCC template<class C
#define OSO ostream &operator<<(ostream &os, const
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
class DSU//{
{
    vector<int> dsupar;
public:
    int cntDSU;
    vector<int> siz;

    void reset(int nd) {
        for (int i = 0; i <= nd; i++) dsupar[i] = i, siz[i] = 1;
        cntDSU = nd;
    }

    DSU(int N, int noOfSets = -1) {
        dsupar.resize(N+5), siz.resize(N+5);
        reset(N+4);
        cntDSU = noOfSets==-1 ? N : noOfSets;
    }

    int find(int x) {
        return dsupar[x]==x ? x : dsupar[x] = find(dsupar[x]);
    }

    void union_(int u, int v) {
        if ((u = find(u))==(v = find(v))) return;
        if (siz[u]<siz[v]) swap(u, v);
        dsupar[v] = u, siz[u] += siz[v], siz[v] = 0;
        cntDSU--;
    }
    
    bool same(int u, int v) { return find(u)==find(v); }
    
    int size(int u) { return siz[find(u)]; }
    
    vector<vector<int>> groups(int mnNode, int mxNode) {
        vector<vector<int>> ret(mxNode+1);
        for (int i = mnNode; i <= mxNode; ++i) {
            ret[find(i)].push_back(i);
        }
        ret.erase(
            remove_if(ret.begin(), ret.end(), [](const vector<int> &v) { return v.empty(); }),
            ret.end());
        return ret;
    }
};//}

const int inf = 1000000007;
int TC=1, CN;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        int n,m;
        cin>>n>>m;
        DSU dsu(n);
        for(int i=0;i<m;++i){
            int a,b;
            cin>>a>>b;
            dsu.union_(a,b);
        }
        cout<<dsu.cntDSU-1<<lf;
    };
    while (CN++!=TC) kase();
}


Measured memory_bytes: 3972
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
	final int type = 4;
	final int figure = 13;
	Scanner in =new Scanner(System.in);
	
	boolean[][] card = new boolean[type][figure];

	for(int i=0;i<type;i++){
	    for(int j=0; j<figure; j++){
		card[i][j]=false;
	    }
	}

	int n = in.nextInt();
	for(int i=0;i<n;i++){
	    String str = in.next();
	    int num = in.nextInt();
	    if(str.equals("S"))card[0][num-1]=true;
	    else if(str.equals("H"))card[1][num-1]=true;
	    else if(str.equals("C"))card[2][num-1]=true;
	    else if(str.equals("D"))card[3][num-1]=true;
	}

	for(int i=0;i<type;i++){
	    for(int j=0; j<figure; j++){
		if(card[i][j]==false){
		    if(i==0)System.out.println("S "+ (j+1));
		    else if (i==1)System.out.println("H "+ (j+1));
		    else if (i==2)System.out.println("C "+ (j+1));
		    else if (i==3)System.out.println("D "+ (j+1));
		}
	    }
	}
    }
}



Measured memory_bytes: 26312
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=1;i<n;i++)ans+=s[i]!=s[i-1];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
li = []
cp = []
ans = 4*10**8
anscp = 0
for i in range(n):
    a, b = map(int, input().split())
    li.append((a, b))
for j in range(m):
    c, d = map(int, input().split())
    cp.append((c, d))
for k in range(n):
    for l in range(m):
        num = abs(li[k][0]-cp[l][0]) + abs(li[k][1]-cp[l][1])
        if num < ans:
            ans = num
            anscp = l+1
    print(anscp)
    ans = 4*10**8

Measured memory_bytes: 3064
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var s = o.a(1);
  var t = s[0], x = 0;
  for(var i = 1; i < n; i++){
    if(t !== s[i]){
      t = s[i];
      x++;
    }
  }
  x = Math.max(0,x-k*2)
  return n-1-x;
}

Measured memory_bytes: 7372
s=input()
i=1
while i<len(s):
	if s[-i-4:-i]+s[-i]=="erase" \
	or s[-i-4:-i]+s[-i]=="dream":
		i+=5
	elif s[-i-5:-i]+s[-i]=="eraser":
		i+=6
	elif s[-i-6:-i]+s[-i]=="dreamer":
		i+=7
	else:
		print("NO")
		exit()
print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

const int N = 200200;
long long p2[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	p2[0] = 1; 
	for (int i=1; i<N; i++){
		p2[i] = (p2[i-1]*2)%mod;
	} 
	int n;
	cin>>n;
	
	map<pair<long long, long long>, pair<int, int>> m;
	int zeros = 0;
	
	for (int i=0; i<n; i++){
		long long a, b;
		cin>>a>>b;
		if (a==0 && b==0) {
			zeros++;
			continue;
		}
		
		long long g = __gcd(abs(a), abs(b));
		a /= g;
		b /= g;
		
		if (a>0 and b>=0){
			m[{b, a}].first++;
		}
		else if (a<0 and b<=0){
			m[{-b,-a}].first++;
		}
		else if(a>=0 and b<0){
			m[{a,-b}].second++;
		}
		else if (a<=0 and b>0){
			m[{-a, b}].second++;
		}	
	}

	long long ans = 1;
	for (auto e: m){
		pair<int, int> cnt = e.second;
		ans = ans * (p2[cnt.first] + p2[cnt.second] - 1) % mod;
	}
	ans = (ans+zeros-1+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 17604
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  ll ans = 1;
  REP(p, 2, 10) {
    REP(b, 1, x) {
      ll tmp = pow(b, p);
      // cout << b << p << tmp << endl;
      if (tmp <= x)
        ans = max(ans, tmp);
      else
        break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n,a,i,cont=0,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==0){
            cont++;
            if(a%3==0 || a%5==0){
                count++;
            }
        }
    }
    if(count==cont)printf("APPROVED");
    else printf("DENIED");
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] page = new int[n];
			for(int i = 0;i < n;i++){
				page[i] = scan.nextInt();
			}
			Arrays.sort(page);
			int[] dif = new int[n-1];
			for(int i = 0;i < n-1;i++){
				dif[i] = page[i+1] - page[i];
			}
			String ans = String.valueOf(page[0]);
			boolean fl = true;
			boolean sw = false;
			for(int i = 0;i < n-1;i++){
				sw = true;
				if(fl && dif[i] == 1){
					ans += "-";
					fl = false;
				}else if(dif[i] > 1 && !fl){
					ans += page[i] + " " + page[i+1];
					fl = true;
					sw = false;
				}else if(dif[i] > 1){
					ans += " " + page[i+1];
					sw = false;
				}
			}
			if(sw){
				ans += page[n-1];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 27192
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll train[505][505];
ll ans[505][505];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, M, Q;
    cin >> N >> M >> Q;

    rep(i,M){
        ll l,r;
        cin >> l >> r;
        //train[l][r] ++;
        for(ll j = l; j >= 1 ;j--){
            train[j][r] ++;
        }
    }
    
    for(ll i = 1; i <= N ; i++){
        ll now = 0;
        for(ll j = 1; j <= N ; j++){
            now += train[i][j];
            train[i][j] = now;
        }
    }
    
    
    rep(i,Q){
        ll p,q;
        cin >> p >> q;
        cout << train[p][q] << endl;
    }
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
#define MOD 1000000000000000000007
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,cmp1=0,cmp2=0,ans=1000000000000000000LL;
    cin >> n;
    vector<ll> x;
    for(ll i=0;i<n;i++){
        cin >> a;
        x.push_back(a);
        cmp1+=a;
    }
    for(ll i=0;i<n;i++){
        cmp2+=x[i];
        if(i+1<n){
            ans=min(ans,abs(cmp1-2*cmp2));
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c){
		cout<<a<<" "<<b<<" "<<c;
	}
	else if(a<=c&&c<=b){
		cout<<a<<" "<<c<<" "<<b;
	}
	else if(b<=a&&a<=c){
		cout<<b<<" "<<a<<" "<<c;
	}
	else if(b<=c&&c<=a){
		cout<<b<<" "<<c<<" "<<a;
	}
	else if(c<=a&&a<=b){
		cout<<c<<" "<<a<<" "<<b;
	}
	else{
		cout<<c<<" "<<b<<" "<<a;
	}
	cout<<endl;
}



Measured memory_bytes: 3112
def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())

    sum_cell = H * W
    v_sel = h * W
    h_sel = w * H
    dupli = h * w

    while_cell = sum_cell - (v_sel + h_sel - dupli)

    print(while_cell)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    cout << max((ll)0,(n-2)*(b-a)+1) << endl;
}

Measured memory_bytes: 256
import networkx as nx
n,m=map(int,input().split())
if m==0:print(1);exit()
a=[[i for i in input().split()] for _ in range(m)]
g=nx.Graph()
for x in a:
     g.add_edge(x[0],x[1])
print(len(sorted(nx.connected_components(g),key=len,reverse=True)[0]))

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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define SIZE 1000005

/*char sieve[SIZE];
vector<int>v;

void isprime()
{
	sieve[0] = 1;
	sieve[1] = 1;
	sieve[2] = 0;
	for(int i = 4; i <= 1000000; i+=2)
	{
		sieve[i] = 1;
	}
	int len = sqrt(1000000);
	for(int i = 3; i <= len; i+=2)
	{
		if(sieve[i] == 0)
		{
			for(int j = i*i; j <= 1000000; j+= 2*i)
			{
				sieve[j] = 1;
			}
		}
	}
	v.push_back(2);
	for(int i = 3; i <= 1000000; i+=2)
	{
		if(sieve[i] == 0) v.push_back(i);
	}
}*/


int main()
{
	int n,arr[55];
	
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	sort(arr+1,arr+n+1);
	
	double sum = arr[1];
	
	for(int i = 2; i <= n; i++)
	{
		sum = (sum + arr[i]) / (2*1.0);
	}
	cout << setprecision(5) << fixed << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class A {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n;
      while(cin >> n) {
        vector<int> dp(n+1);
        rep(i, n+1) {
          if (i<=1000) {
            dp[i] = i+1;
          } else if (i<=2000) {
            dp[i] = 2001-i;
          }
        }
        ll ans = 0;
        for(int i=0; i<=n; i++) {
          int j = n-i;
          ans += dp[i]*dp[j];
        }
        cout << ans << endl;
      }

    }
};

signed main() {
  A solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3208
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias TD = Tuple!(int, "t", long, "d");

TD[10^^5] SS;
int[10^^5+1] MEMO;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    foreach (i; 0..N) {
        auto td = readln.split.to!(int[]);
        SS[i] = TD(td[0], td[1]);
    }

    sort!"a.d > b.d"(SS[0..N]);
    long max_d, bns;
    foreach (i; 0..K) {
        max_d += SS[i].d;
        auto t = SS[i].t;
        if (!MEMO[t]) ++bns;
        ++MEMO[t];
    }
    int i = K-1;
    long ret = max_d + bns^^2;
ml:
    foreach (j; K..N) {
        auto it = SS[i].t;
        while (MEMO[it] <= 1) {
            if (--i < 0) break ml;
            it = SS[i].t;
        }
        auto jt = SS[j].t;
        if (MEMO[jt]) continue;
        max_d = max_d - SS[i].d + SS[j].d;
        ++bns;
        ret = max(ret, max_d + bns^^2);
        --MEMO[it];
        ++MEMO[jt];
        --i;
    }

    writeln(ret);
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m; cin>>n>>m;
  map<int,int> memo;
  map<int,bool> judge;
  bool ansjudge=1;
  rep(i,m){
    int s,c; cin>>s>>c;
    if(judge[s]&&memo[s]!=c) ansjudge=0;
    else {memo[s]=c;
          judge[s]=1;
         }
  }
  if(!ansjudge) cout<<-1<<endl;
  else if(n==1) cout<<memo[1]<<endl;
  else if(memo[1]==0&&judge[1]) cout<<-1<<endl;
  else if(memo[1]==0){
    cout<<1;
    rep(i,n-1) cout<<memo[i+2];
  }else rep(i,n) cout<<memo[i+1];
}

Measured memory_bytes: 256
N = int(input())

table = [0] * (N + 1)
s = {6 ** i for i in range(7) if 6 ** i <= N} | {9 ** i for i in range(6) if 9 ** i <= N}
for i in range(1, N + 1):
    table[i] = min(table[i - j] for j in s if i - j >= 0) + 1
print(table[N])

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    int cnt = 0;
    for(int i=0;i<S.length();i++){
        if(S[i] == 'o'){
            cnt++;
        }
    }
    
    if(cnt+(15-S.length())>=8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,h,m,s;
	cin>>n;//second
	s=n%60;
	n=(n-s)/60;//minutes
	m=n%60;
	n=(n-m)/60;//hour
    h=n;
    cout<<h<<":"<<m<<":"<<s<<endl;


	
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a,ans=0;
  cin>>n;
  priority_queue<long long int>pq;
  for(int i=0;i<3*n;i++){
    cin>>a;
    pq.push(a);
  }
  for(int i=0;i<n;i++){
    pq.pop();
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
  return(0);
}


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

int main() {
	int a,b,c;
	int k;
	cin >> a >> b >> c;
	cin >> k;
	bool ans = false;
	rep(i, 1<<k) {
		int nowb, nowc;
		nowb = b;
		nowc = c;
		for (int j = 0; j < k; j++) {
			if ( (i >> j) & 1) {
				nowc *= 2;
			} else
				nowb *= 2;
		}
		if (a < nowb && nowb < nowc) {
			ans = true;
			break;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        if (a == 0) {
            System.out.println(b / x + 1);
        } else {
            System.out.println(b / x - ((a - 1) / x));
        }
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
struct edge{ int to,cost; };

double p;
int N;
vector<edge> G[100005];

double x[100005];

void dfs(int pos,int prev){
  x[pos]=0;
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    dfs(e.to,pos);
    x[pos]+=(double)(x[e.to]+e.cost)*p;
  }
}

double solve(int pos,int prev){
  double res=x[0];
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    res+=( solve(e.to,pos) + e.cost )*p;
  }
  return res;
}

int main(){
  cin>>p;
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back( (edge){b,c} );
    G[b].push_back( (edge){a,c} );
  }
  dfs(0,-1);
  /*
  for(int id=0;id<N;id++){
    printf("%d %.10f\n", id,x[id]);
  }
  */
  printf("%.10f\n", solve(0,-1));
  return 0;
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    int n;cin>>n;
    int A[n+1],B[n];
    int sum=0;
    rep(i,n+1){
        cin>>A[i];
        sum+=A[i];
    }
    rep(i,n)cin>>B[i];
    rep(i,n){
        if(A[i]>=B[i])A[i]-=B[i];
        else{
            A[i+1]-=min(A[i+1],(B[i]-A[i]));
            A[i]=0;
        }
    }
    int sum0=0;
    rep(i,n+1)sum0+=A[i];
    //cout<<sum<<' '<<sum0<<endl;
    cout<<sum-sum0<<endl;
    
    
}

Measured memory_bytes: 1920
import java.util.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    String s=sc.next();
	    String t=sc.next();
	    
	    int ans=0;
	    for(int i=0;i<s.length();i++) {
	    	if(s.charAt(i)!=t.charAt(i))ans++;
	    }
	    
	    
	    System.out.println(ans);
	}
}


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

int main() {
  int d, n;
  cin >> d >> n;
  if (n == 100) ++n;
  rep(i, d) n *= 100;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3600
#input
N, M = map(int,input().split())
KS = [list(map(int,input().split())) for i in range(M)]
P = list(map(int,input().split()))

count = 0
for i in range(2 ** N):
    add = True
    for j in range(M):
        k = KS[j]
        cnt = 0
        for s in k[1:]:
            if (1 << (s - 1)) & i > 0 :
                cnt += 1
        if cnt % 2 != P[j]:
            add = False
            break
    if add :
        count += 1
 
print(count)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	string s;
	int k;
	cin >> s >> k;
	for (int i = 0;i < s.length() - 1;++i) {
		if (s[i] != 'a') {
			if ((int)'z' - s[i] < k) {
				k -= (int)'z' - s[i] + 1;
				s[i] = 'a';
			}
		}
	}
	int hoge = (int)s[s.length() - 1] - 'a';
	hoge += k;
	hoge %= 26;
	REP(i, s.length() - 1) {
		cout << s[i];
	}
	cout << (char)(hoge + 'a') << endl;
	return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

def is_ok(x):
    c = 0
    for i in range(n):
        a = A[i]
        f = F[i]
        if a >= x//f:
            c += a-x//f
    if c <= k:
        return True
    else:
        return False

if is_ok(0):
    print(0)
    exit()

l = 0
r = 10**18
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c
print(r)


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

int main()
{
	int A, B, C, D, L, R;
	cin >> A >> B >> C >> D;

	L = A + B;
	R = C + D;

	if (L > R) {
		cout << "Left" << endl;
	}
	if (L == R) {
		cout << "Balanced" << endl;
	}
	if (L < R) {
		cout << "Right" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def generator(n, r):
    if r == 0:
        yield []
    else:
        a = 0
        for A in generator(n, r - 1):
            if r > 1:
                a = A[-1]
            for i in range(a, n):
                A.append(i)
                yield A
                A.pop()


n, m, q = map(int, input().split())
ABCD = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0
for X in generator(m, n):
    scr = 0
    for a, b, c, d in ABCD:
        if X[b - 1] - X[a - 1] == c:
            scr += d
    ans = max(ans, scr)
print(ans)


Measured memory_bytes: 9260
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

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

  ll N,K; cin >> N>>K;
  vl A(N); REP(i,N) cin>>A[i];
  vl F(N); REP(i,N) cin>>F[i];

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());

  ll l = 0, r = 1e12;
  while (l < r) {
      ll m = (l + r) / 2;
      
      ll sum = 0;      
      REP(i,N) sum += max(A[i]-m/F[i], 0LL);
      
      if (sum <= K) r = m;
      else l = m + 1;
  }
  
  ll ans = (l + r) / 2;  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int A = 1e5+5;
ll n, mod, dp[A], sol[A];
vector <int> v[A], pref[A], suff[A];
int mul(int a, int b) {return (1ll * (a % mod) * (b % mod)) % mod;}
int add(int a, int b) {return (mod + (a % mod) + (b % mod)) % mod;}
void dfs(int node, int par)
{
	dp[node] = 1;
	int sz = v[node].size();
	pref[node].resize(sz);
	suff[node].resize(sz);
	for (int i = 0; i < sz; i++)
	{
		int to = v[node][i];
		if (to != par)
		{
			dfs(to, node);
			dp[node] = mul(dp[node], dp[to]);
		}
		pref[node][i] = dp[node];
	}
	dp[node] = add(dp[node], 1);
	int suf = 1;
	for (int i = sz-1; ~i; i--)
	{
		int to = v[node][i];
		if (to != par)
			suf = mul(suf, dp[to]);
		suff[node][i] = suf;
	}
}
void solve(int node, int par)
{
	sol[node] = add(dp[node], -1);
	int sz = v[node].size();
	for (int i = 0; i < sz; i++)
	{
		int to = v[node][i];
		if (to == par) continue;
		int tmp_node = dp[node], tmp_to = dp[to];
		dp[node] = mul(i? pref[node][i-1] : 1, i+1 == sz? 1 : suff[node][i+1]);
		dp[node] = add(1, mul(dp[node], dp[par]));
		dp[to] = add(mul(add(dp[to], -1), dp[node]), 1);
		solve(to, node);
		dp[node] = tmp_node, dp[to] = tmp_to;
	}
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> mod;
	for (int i = 1; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y), v[y].pb(x);
	}
	dfs(1, 1), dp[0] = 1, solve(1, 0);
	for (int i = 1; i <= n; i++)
		cout << sol[i] << '\n';
	return 0;
}


Measured memory_bytes: 27008
let rec h n a = if n = 0 then a else h (n / 10) (n mod 10 :: a)
let ns, ds = Scanf.(scanf " %d %d" @@ fun n k -> h n [], Array.(to_list @@ init k @@ fun _ -> scanf " %d" (+) 0))
let rec f n = if n > 9 then 10 * f 1 + if f 0 = 0 then 0 else f 1 else if List.mem n ds then f (n + 1) else n
let rec g b a = function [] -> a | n :: ns -> g (b || f n > n) ((if b then f 0 else f n) :: a) ns
let rec k b a = function [] -> a | n :: ns -> let m = if b then f (n + 1) else n in k (m > 9) ((if m > 9 && ns <> [] then f 0 else m) :: a) ns
let ns = g false [] ns |> k false [] |> List.fold_left (fun a n -> 10 * a + n) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

const MOD: usize = 1e9 as usize + 7;

fn main() {
	let (s, w): (usize, usize) = (read(), read());
	let ans = if s <= w { "unsafe" } else { "safe" };
	println!("{}", ans);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2080
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = read();
    let mut s: Vec<i32> = (0..n).map(|_| read()).collect();
    s.sort();

    let sum: i32 = s.iter().sum();
    let ans = if sum % 10 == 0 {
        sum - *s.iter().find(|&&x| x % 10 != 0).unwrap_or(&sum)
    } else {
        sum
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import Counter
#cotest_temp
n = int(input())
lst1 = [input() for i in range(n)]
m = int(input())
lst2 = [input() for i in range(m)]
#n,m = map(int,input().split())
#lst1 = list(map(int,input().split()))

l = Counter(lst1)
k = Counter(lst2)

ans = 0

for i in l:
    if i in lst2:
        ans = max(ans,l[i]-k[i])
    else:
        ans = max(ans,l[i])

print(ans)

Measured memory_bytes: 38256
import java.util.Scanner;

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

        char c = sc.next().charAt(0);
        
        char ans = 'A';
        switch (c) {
            case 'A': ans = 'T'; break;
            case 'C': ans = 'G'; break;
            case 'G': ans = 'C'; break;
            case 'T': ans = 'A'; break;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 24020
import sys

def S(): return sys.stdin.readline().rstrip()

N,X = map(int,S().split())

def f(A,B):  # レベルAバーガーの下からB層に何枚パティがあるか
    if A == 0 and B == 1:
        res = 1
    else:
        if B == 1:
            res = 0
        elif 2 <= B <= 2**(A+1)-2:
            res = f(A-1,B-1)
        elif B == 2**(A+1)-1:
            res = 2**A
        elif 2**(A+1) <= B <= 2**(A+2)-2:
            res = 2**A + f(A-1,B-2**(A+1)+1)
        else:
            res = 2**(A+1)-1
    return res

print(f(N,X))

Measured memory_bytes: 61976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve_old(long long N, long long M, std::vector<long long> A){
  ll old_j = N-2;
  bool flg = false;
  vector<ll>::iterator max_itr;
  // sort(all(A), greater<ll>());
  if(N==1){
    rep(i, M) A[0] = A[0]/2;
    std::cout << A[0] << std::endl;
    return;
  }
  for (ll i = 0; i < M; i++) {
    sort(all(A), greater<ll>());
    A[0]/=2;
    // for (ll j = 0; j < N; j++)
    // {
      // if(A[j]<A[old_j+1]) {
      //   // j=old_j;
      //   A[old_j+1] = A[old_j+1]/2;
      //   break;
      // }
      // if(A[j]>=A[j+1] && A[j]>=A[old_j+1]){
      //   A[j] = A[j]/2;
      //   if(flg==false){
      //     old_j=j;
      //   }
      //   break;
      // }else if(A[j]<A[old_j+1]){
      //   A[old_j+1]=A[old_j+1]/2;
      //   old_j++;
      //   flg=true;
      //   break;
      // }
    // }
    // max_itr = max_element(A.begin(), A.end());
    // *max_itr = *max_itr / 2;
  }
  // rep(i, N) cout << A[i];
  ll sum = accumulate(A.begin(), A.end(), 0LL);
  std::cout << sum << std::endl;
}

void solve(long long N, long long M, std::vector<long long> A){
  ll sum=0;
  priority_queue<ll> que;
  for (ll i = 0; i < N; i++) {
    que.push(A[i]);
  }
  for (ll i = 0; i < M; i++) {
    que.push(que.top()/2);
    que.pop();
  }
  // ll sum = accumulate(que.begin(), que.end(), 0LL);
  for (ll i = 0; i < N; i++) {
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;

	vector<tuple<string, int, int>> a;
	for(int i=1;i<=n;i++){
		string s;
		int p;
		cin >> s >> p;
		p = -p;
		a.emplace_back(s, p, i);
	}
	sort(a.begin(), a.end());

	for(int i=0;i<n;i++)
		cout << get<2>(a.at(i)) << endl;
}

Measured memory_bytes: 256
using System;

namespace pro
{




    class MainClass
    {
        public static void Main()
        {
          int n = int.Parse(Console.ReadLine());
            string[] str0 = Console.ReadLine().Split(' ');
            string[] str1 = Console.ReadLine().Split(' ');
            int[] a = new int[n+1];
            int[] b = new int[n];
            for (int i = 0; i < n+1; i++)
            {
                a[i] = int.Parse(str0[i]);
            }
            for (int i = 0; i < n; i++)
            {
                b[i] = int.Parse(str1[i]);
            }
            long count = 0;
            for (int i = 0; i < n; i++)
            {
                if (b[i] > a[i])
                {
                    b[i] -= a[i];
                    count += a[i];
                    if (b[i] > a[i+1])
                    {
                        count += a[i + 1];
                        a[i+1] = 0;
                    }
                    else
                    {
                        a[i+1] -= b[i];
                        count += b[i];
                    }
                }
                else
                {
                    count += b[i];
                }
            }

                Console.WriteLine(count);

        }
    }


}

Measured memory_bytes: 31188
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
typedef long long ll;


ll Stoi(string s){
    ll ret = 0;
    for(int i = 0; i < s.size();++i){
        ll tmp = (s[i]-'0');
        for(int j = 0; j < s.size()-i-1;++j) tmp *= 10;
        ret += tmp;
    }
    return ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int N = (int)s.size();
    ll ans = 0;
    for(int bit = 0; bit < (1<<(N-1));++bit){
        string tmp = "";
        for(int i = 0; i < N; ++i){
            tmp += s[i];
            if(bit & (1<<i)){
                ans += Stoi(tmp);
                tmp = "";
            }
        }
        ans += Stoi(tmp);
    }
    cout << ans << '\n';
    return 0;
}

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

ll row[300005],col[300005];
map<pair<ll,ll>,bool >mp;

int main(){

   ll h,w,m,r,c;
   cin>>h>>w>>m;
   for(int i=0; i<m; i++){
        cin>>r>>c;
        row[r]++;
        col[c]++;
        mp[{r,c}]=true;
   }
   ll row_max=*max_element(row+1,row+h+1);
   ll col_max=*max_element(col+1,col+w+1);
   vector<ll>v1,v2;
   for(int i=1; i<=h; i++)
       if(row[i]==row_max)
           v1.push_back(i);
   for(int i=1; i<=w; i++)
       if(col[i]==col_max)
           v2.push_back(i);
   /*for(int i=0; i<v1.size(); i++)
       cout<<v1[i]<<" ";
   cout<<endl;
   for(int i=0; i<v2.size(); i++)
       cout<<v2[i]<<" ";
   cout<<endl;*/
   ll cnt=0;
   bool flag=false;
   for(int i=0; i<v1.size(); i++){
       for(int j=0; j<v2.size(); j++){
            if((mp[{v1[i],v2[j]}]==false)){
                flag=true;
                break;
            }
       }
   }
   if(flag)
       cout<<(row_max+col_max)<<endl;
   else
       cout<<(row_max+col_max)-1<<endl;
}


Measured memory_bytes: 50096
n= int(input())
l = list(map(int,input().split()))
l.sort()
def ok(a,b,c):
    return a < b+c and b < a+c and c < a+b
ans = 0
for i in range(n):
    for j in range(i+1,n):
        e1 = l[i]
        e2 = l[j]
        top = n
        bot = j
        while top - bot > 1:
            mid = (top+bot)//2
            if ok(l[mid],e1,e2):bot = mid
            else:top  = mid
        
        ans += top-j-1
print(ans)
    
        
        

Measured memory_bytes: 43868