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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
ll sz[mxn],dis[mxn];
vi adj[mxn];
bool vis[mxn];

void dfs(int u, int p=-1){
	for(int v:adj[u])
		if(v!=p)dis[v]=dis[u]+1LL,dfs(v,u);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n;
	cin >> n;
	pair<ll,int> dist[n];
	map<ll,int>mp;
	for(int i=0; i<n; i++){
		cin >> dist[i].fi;
		dist[i].se=i;
		sz[i]=1LL;
		mp[dist[i].fi]=i;
	}
	map<ii,bool>edge;
	sort(dist,dist+n);
	for(int i=n-1; i>0; i--){
		int ind = dist[i].se;
		ll next = dist[i].fi-n+2*sz[ind];
		if(mp.find(next)==mp.end()){
			cout << -1 << endl;
			return 0;
		}
		int ptr = mp[next];
		if(ptr==ind){
			cout << -1 << endl;
			return 0;
		}
		sz[ptr] += sz[ind];
		if(ptr>ind)swap(ind,ptr);
		edge[ii(ptr,ind)]=1;
		adj[ind].eb(ptr);
		adj[ptr].eb(ind);
		vis[ind]=1; vis[ptr]=1;
	}
	bool ok=0;
	for(int i=0; i<n&&!ok; i++)
		if(sz[i]==n)ok=1;
	for(int i=0; i<n; i++)
		if(!vis[i])ok=0;
	dfs(dist[0].se);
	ll sum = 0;
	for(int i=0; i<n; i++)sum+=dis[i];
	if(sum!=dist[0].fi)ok=0;
	if(!ok)cout << -1 << endl;
	else{
		for(auto x:edge)
			cout << x.fi.fi+1 << ' ' << x.fi.se+1 << endl;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		String S = scn.nextLine();
		String T = scn.nextLine();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		boolean ans = true;
		for (int i = 0; i < s.length; i++) {
			char as = s[i];
			char at = t[i];
			if (as != at) {
				for (int j = 0; j < s.length; j++) {
					if (j < i) {
						if (s[j] == as || s[j] == at) {
							ans = false;
							break;
						}
					} else {
						if (s[j] == as) {
							s[j] = at;
						} else if (s[j] == at) {
							s[j] = as;
						}
					}
				}
			}
		}
		for (int i = 0; i < s.length; i++) {
			if (s[i] != t[i]) {
				ans = false;
				break;
			}
		}
		System.out.println(ans ? "Yes" : "No");
		scn.close();
	}
}


Measured memory_bytes: 32400
import math
import itertools

def read():
    N = int(input().strip())
    P = []
    for i in range(N):
        x, y = list(map(int, input().strip().split()))
        P.append((x ,y))
    return N, P

def solve(N, P, INF=1000000):
    dist = [[0.0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if P[i] == P[j]:
                dist[i][j] = 0.0
            else:
                dist[i][j] = math.sqrt((P[i][0] - P[j][0])**2 + (P[i][1] - P[j][1])**2)
    
    cities = list(range(N))
    D = []
    for order in itertools.permutations(cities, N):
        d = 0.0
        for i in range(1, N):
            s = order[i-1]
            t = order[i]
            d += dist[s][t]
        D.append(d)
    return sum(D) / math.factorial(N)

if __name__ == '__main__':
    inputs = read()
    output = solve(*inputs)
    print("%.10f" % output)


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


void solve(long long N){
  long long i;
  for(i = 0; i < N; i+=1000){
  }
  cout << (i-N) << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


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


#include <bits/stdc++.h>

using namespace std;

class ASharingCookies {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int a, b;
        cin >> a >> b;
        if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) {
            cout << "Possible";
        } else {
            cout << "Impossible";
        }
    }
};


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


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5,MOD=1e9+7;
int n,m,a[MAXN],b[MAXN];
pii p[MAXN];
inline int mod(int x){return x<MOD?x:x-MOD;}
struct BIT{
	int c[MAXN];
	inline int lb(int x){return x&(-x);}
	void add(int p,int v){for(;p<=n;p+=lb(p))c[p]=mod(c[p]+v);}
	int ask(int p){int r=1;for(;p;p-=lb(p))r=mod(r+c[p]);return r;}
	BIT(){}
}T;
int main() {
	n=read();m=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=m;++i)b[i]=read();
	int cnt=0;vector<int>vec;
	for(int i=1;i<=n;++i){
		if(a[i]<b[1]||a[i]>b[m])continue;
		int t=lob(b+1,b+m+1,a[i])-b;
		assert(t>1&&t<=m);
		p[++cnt]=mk(a[i]-b[t-1],b[t]-a[i]);
		vec.pb(p[cnt].scd);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	n=cnt;sort(p+1,p+cnt+1);
	for(int i=1,j=1;i<=n;i=j){
		int L=p[i].fst;
		while(j<=n&&p[j].fst==L)++j;
		for(int k=j-1;k>=i;--k){
			int R=lob(vec.begin(),vec.end(),p[k].scd)-vec.begin()+1;
			if(k!=j-1&&p[k].scd==p[k+1].scd)continue;
			T.add(R,T.ask(R-1));
		}
	}
	cout<<T.ask(vec.size())<<endl;
	return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
int main () {
    int N,M;
    cin >> N >> M;
    vector<set<int> > fr(N);
    UnionFind uf(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        fr[a].insert(b);
        fr[b].insert(a);
        uf.merge(a,b);
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll mem = uf.size(i); // 同じ連結成分の人数
        ans = max(ans,mem);
    }
    cout << ans << endl;
}

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

int x[5];
int main(){
    for(int i = 0; i < 5; i++){
        scanf("%d", &x[i]);
    }
    int ans;
    for(int i = 0; i < 5; i++){
        if(x[i] == 0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> kuro(n), siro(n);
    if (s[0] == '#') kuro[0] = 1;
    for(int i = 1; i < n; i++){
         if (s[i] == '#') kuro[i] = kuro[i-1] + 1;
         else kuro[i] = kuro[i-1];
    }
    if (s[n-1] == '.') siro[n-1] = 1;
    for(int i = n-2; i >= 0; i--){
        if (s[i] == '.') siro[i] = siro[i+1]+1;
        else siro[i] = siro[i+1];
    }

    int ans = n;
    for(int i = 0; i < n; i++){
        int ope;
        if (i == 0){
            ope = min(siro[0], kuro[n-1]);
        }
        else{
            ope = kuro[i-1] + siro[i];
        }
        ans = min(ans, ope);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5232
s = gets.chomp
p = gets.chomp

ss = s + s
ok = false

for i in 0..(s.length - 1)
    for j in 0..(p.length - 1)
        if ss[i + j] != p[j]
            break
        end
        if j == p.length - 1
            ok = true
        end
    end
end
if ok == true
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 8684
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=604;

int col[N][N];
bool kicked[N][N];
int cnt[2];
int n,d1,d2;
vector<pii> dt1,dt2;

il void dfs(int x,int y,int c,vector<pii> &dt){
	if(kicked[x][y]) return;
	if(~col[x][y]){
		assert(col[x][y]==c);
		return;
	}
	col[x][y]=c;
	++cnt[c];
	rep0(i,dt.size()){
		int nx=x+dt[i].X,ny=y+dt[i].Y;
		if(nx<0||nx>=(n<<1)||ny<0||ny>=(n<<1)) continue;
		dfs(nx,ny,c^1,dt);
	}
}

int main(){
	srand(time(0));
//	fileio("test");
	scanf("%d%d%d",&n,&d1,&d2);
	rep0(i,n<<1){
		rep0(j,n<<1){
			int d=i*i+j*j;
			if(d==d1){
				dt1.pb(mp(i,j));
				if(j) dt1.pb(mp(i,-j));
				if(i) dt1.pb(mp(-i,j));
				if(i&&j) dt1.pb(mp(-i,-j));
			}
			if(d==d2){
				dt2.pb(mp(i,j));
				if(j) dt2.pb(mp(i,-j));
				if(i) dt2.pb(mp(-i,j));
				if(i&&j) dt2.pb(mp(-i,-j));
			}
		}
	}
	cnt[0]=cnt[1]=0;
	rep0(i,n<<1) rep0(j,n<<1) col[i][j]=-1;
	rep0(i,n<<1){
		rep0(j,n<<1){
			if(~col[i][j]) continue;
			dfs(i,j,0,dt1);
		}
	}
	if(cnt[0]<cnt[1]){
		rep0(i,n<<1) rep0(j,n<<1) if(col[i][j]==0) kicked[i][j]=true;
	}else{
		rep0(i,n<<1) rep0(j,n<<1) if(col[i][j]==1) kicked[i][j]=true;
	}
	cnt[0]=cnt[1]=0;
	rep0(i,n<<1) rep0(j,n<<1) col[i][j]=-1;
	rep0(i,n<<1){
		rep0(j,n<<1){
			if(kicked[i][j]||~col[i][j]) continue;
			dfs(i,j,0,dt2);
		}
	}
	assert(qmax(cnt[0],cnt[1])>=n*n);
	int rest=n*n;
	if(cnt[0]>cnt[1]){
		rep0(i,n<<1){
			rep0(j,n<<1){
				if(!kicked[i][j]&&col[i][j]==0){
					printf("%d %d\n",i,j);
					--rest;
				}
				if(!rest) break;
			}
			if(!rest) break;
		}
	}else{
		rep0(i,n<<1){
			rep0(j,n<<1){
				if(!kicked[i][j]&&col[i][j]==1){
					printf("%d %d\n",i,j);
					--rest;
				}
				if(!rest) break;
			}
			if(!rest) break;
		}
	}
	return 0;
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int p[1234];
int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%d", p+i);
	sort(p, p+n);
	int ans = 0;
	REP(i, k) ans += p[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 3824
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
double x;
int main() {
	scanf("%lf",&x);
/*	double r=1.0*x/100;
	ll ans=(ll)ceil((log(r)/log(1.01)));
	printf("%lld\n",ans);*/
	double cur=100.0;
	int cnt=0;
	while (cur<x) {
		++cnt;
		cur*=1.01;
		cur=floor(cur);
	}
	printf("%d\n",cnt);
	return 0;
}

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

using namespace std;

typedef unsigned long long llu;

int main() {
    int N; scanf("%d", &N);
    llu multi = 1;
    llu lst[N + 5];
    for (int i = 0; i < N; i++) { scanf("%llu", &lst[i]); }
    sort(lst, lst + N);
    for (int i = 0; i < N; i++) {
        llu j = lst[i];
        if (multi == 0) {printf("0"); exit(0);}
        else if (j > 1000000000000000000 / multi) { printf("-1"); exit(0); }
        else multi *= j;
    }
    printf("%llu", multi);
}

Measured memory_bytes: 4608
// Problem : B - Frog 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define vi vector<int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;
	
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	vll dp(n, INT_MAX);
	vll h(n);
	scan(h, n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(ll i = 2; i < n; i++){
		for(ll j = 1; j <= k; j++){
			if(i - j >= 0){
				dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
			}
		}
	}
    cout<<dp[n - 1];
    return 0;
}

Measured memory_bytes: 4732
import java.util.*;
public class Main {
    public static long mod(long x, long y) {
    return x%y<0?x%y+(y<0?-y:y):x%y;
    } 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong()-1;
		StringBuilder sb = new StringBuilder();
        String str[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        while(a>=0){int b = (int)mod(a,26);                   
                    sb.append(str[b]);
                    a=a/26-1;
                   }
		String ans = sb.toString();
        StringBuffer sf = new StringBuffer(ans);
		System.out.println(sf.reverse().toString());
	}
}

Measured memory_bytes: 35724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int cmp(pair<string,int>a,pair<string,int>b){
        if(a.second!=b.second)
        return a.second<b.second;
        else
        return a.first>b.first;
}

int cmp1(pair<string,int>a,pair<string,int>b){
        if(a.first!=b.first)
        return a.first<b.first;
        else
        return a.second>b.second;
}

bool cmp2(const string &x,const string &y)
{
  return x<y;
}


int main()
{
    
    int b;
    cin>>b;
    while(b){
    vector<string>name(b);
    int t[31][31];
    int sum1=0;
    vector<int>cnt1;
        vector<string>mmin;
        bool bmin=false;
    for(int i=0;i<b;i++)
    {
        cin>>name[i];
        int c;
        cin>>c;
        if(c==0)
        {
            bmin=true;
            mmin.push_back(name[i]);
        }
        sum1+=c;
        cnt1.push_back(c);
        for(int j=0;j<c;j++)
            cin>>t[i][j];
    }
    int count[30]={0};
    
    for(int i=0;i<b;i++)
        for(int j=0;j<cnt1[i];j++)
        {
            count[t[i][j]]++;
        }
    vector<pair<string,int> >ans(b);
    for(int i=0;i<b;i++)
    for(int j=0;j<cnt1[i];j++)
    {
        ans[i].first=name[i];
        ans[i].second+=b-count[t[i][j]]+1;
    }
        vector<string>mm;
    
        sort(ans.begin(),ans.end(),cmp);
        cout<<ans[0].second;

        for(int i=0;i<b;i++)
        {if(ans[i].second==ans[0].second)
        {
            mm.push_back(ans[i].first);
        }
        }
        sort(mm.begin(),mm.end(),cmp2);
        if(bmin==true)
        {sort(mmin.begin(),mmin.end(),cmp2);
            mm[0]=mmin[0];}
        cout<<" "<<mm[0]<<endl;
       
        cin>>b;
    }
   
    
    return 0;
}




Measured memory_bytes: 3196
s = input()
q = int(input())
d = True
head = []
tail = []
for i in range(q):
    t, *u= input().split()
    if t == "1":
        d = not d
    else:
        f, c = u[0], u[1]
        if d:
            if f == "1":
                head.append(c)
            else:
                tail.append(c)
        else:
            if f == "1":
                tail.append(c)
            else:
                head.append(c)
s = "".join(head)[::-1] + s + "".join(tail)
print(s if d else s[::-1])


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

using namespace std;

int selection_sort(int A[], int N) {
    int count = 0;
    for(int i = 0; i < N; i++) {
        int mini = i;
        for (int j = i; j < N; j++) {
            if(A[mini] > A[j]) mini = j;
        }
        if(i != mini) {
            swap(A[i], A[mini]);
            count++;
        }
    }
    return count;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];

    int count = selection_sort(A, N);

    for(int i = 0; i < N; i++) {
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k;
string ans = "Second";
vector< int > arr( 110 );
vector< bool > dp( 1e5 + 5, false );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	for( int x = 1; x <= k; ++x )
	{
		for( int i = 1; i <= n && x - arr[ i ] >= 0 && !dp[ x ]; ++i )
		{
			dp[ x ] = dp[ x ] | !dp[ x - arr[ i ] ];
		}
	}
	if( dp[ k ] )
	{
		ans = "First";
	}
	cout << ans << "\n";
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> A(N + 1);
    rep(i, M) {
        ll temp;
        cin >> temp;
        A[temp] = 1;
    }
    rep(i, N) {
        A[i + 1] = A[i] + A[i + 1];
    }
    ll left = A[X];
    ll right = A.back() - left;
    cout << min(left, right) << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


ll n;

int main(){
    
    cin >> n;
    
    int a[n];
    inrep(n,a);

    double sum = 0;
    rep(i,0,n)sum += a[i];
    sum /= n;

    int ans = 0;
    rep(i,1,n){
        if(abs(sum - a[i]) < abs(sum - a[ans]))ans = i;
    }
    P(ans);
    
	return  0;
}

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


void func() {
	int n;
	cin >> n;
}


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	vector<int> b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (k >= n) {
		cout << abs(a[0] - a[n - 1]);
		return 0;
	}
	for (int i = 0; i < k; i++) {
		b[n - 1 - i] = abs(a[n - 1 - i] - a[n - 1]);
	}
	for (int i = n - k - 1; i >= 0; i--) {
		int min = 1000000000;
		for (int j = 1; j < k + 1; j++) {
			int p = abs(a[i] - a[i + j]) + b[i + j];
			if (p < min)
				min = p;
		}
		b[i] = min;
	}
	cout << b[0];
}

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

const ll MAXN = 200000;

ll H, W, ans=0, tmp=0, C[10]={0}; 
map<ll, ll> MP;
vector<pair<ll, ll>> adj[10];

void dijkstra(ll start) {
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> PQ;
    ll color[10];
    ll d[10];
    for(int i=0;i<10;i++) {
        d[i] = 1000000000;
        color[i] = 0;
    }
    d[start] = 0;
    PQ.push(make_pair(d[start], start));
    color[start] = 1;
    while(!PQ.empty()) {
        pair<ll, ll> p = PQ.top();
        PQ.pop();
        ll u = p.second;
        color[u] = 2;
        if(d[u]<p.first) continue;
        for(int j=0;j<adj[u].size();j++) {
            ll v = adj[u][j].first;
            if(color[v]==2) continue;
            if(d[v]>d[u]+adj[u][j].second) {
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v], v));
                color[v]=1;
            }
        }
    }
    C[start] = d[1];
}

signed main(){
    cin >> H >> W;
    for(int i=0;i<10;i++) {
        for(int j=0;j<10;j++) {
            ll num;
            cin >> num;
            adj[i].push_back(make_pair(j, num));
        }
    }
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            ll num;
            cin >> num;
            if(num==-1) num = 1;
            MP[num]++;
        }
    }
    for(int i=0;i<10;i++) {
        dijkstra(i);
    }
    for(map<ll, ll>::iterator itr=MP.begin();itr!=MP.end();itr++) {
        pair<ll, ll> p = *itr;
        ans += C[p.first]*p.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<list>
#include<deque>
#include<ctime>
#include<map>
#include<set>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy";
	else if (s == "Rainy")cout << "Sunny";
	else cout << "Rainy";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
using namespace std;
void solve()
{
		int h1,s1,h2,s2;
		cin>>h1>>s1>>h2>>s2;
		if(ceil((double)h2/s1)<=ceil((double)h1/s2))
		cout<<"Yes";
		else
		cout<<"No\n";
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 3624
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = list(input()[0:-1])
# n = int(input())
# A,B,M = map(int, input().split())
a = list(map(int,input().split()))
a = sorted(a)
# b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# xyc=[]
# for i in range(M):
#     x,y,c = map(int, input().split())
#     xyc.append((x,y,c))
     
def main():

    if a[0]==1 and a[1]==4 and a[2]==7 and a[3]==9:
        print("YES")
    else:
        print("NO")

        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int N;
int x[51], y[51];

double dist(double x1, double y1, double x2, double y2) {
    double dx = x1 - x2;
    double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}
typedef pair<double, double> P;
pair<double, P> calc(double x1, double y1, double x2, double y2, double x3, double y3) {
    double alpha = x1 - x2;
    double beta = y1 - y2;
    double gamma = x2 - x3;
    double delta = y2 - y3;
    double fact = 0.5/(alpha*delta - beta*gamma);
    double X1 = x1 * x1 + y1 * y1;
    double X2 = x2 * x2 + y2 * y2;
    double X3 = x3 * x3 + y3 * y3;
    double XX1 = X1 - X2;
    double XX2 = X2 - X3;
    double X = fact*(delta * XX1 - beta * XX2);
    double Y = fact*(-gamma * XX1 + alpha * XX2);
    double r = dist(X, Y, x1, y1);
    return make_pair(r, make_pair(X, Y));
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << calc(0, 0, 1, 0, 0.5, 1).first << " " << calc(0, 0, 1, 0, 0, 1).second.first << " " << calc(0, 0, 1, 0, 0, 1).second.second << endl;
    cin >> N;
    rep(i, N) cin >> x[i] >> y[i];
    double ans = INF;
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            double d = dist(x[i], y[i], x[j], y[j])/2.0;
            double X = (x[i] + x[j]) / 2.0;
            double Y = (y[i] + y[j]) / 2.0;
            bool ok = true;
            rep(k, N) {
                double d2 = dist(X, Y, x[k], y[k]);
                if (d + 1e-12 < d2) ok = false;
                //cout << d2 << endl;
            }
            //cout << X << " " << Y << " " << d << endl;
            if(ok) ans = min(ans, d);
        }
    }
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                if (i == j || j == k || k == i) continue; 
                pair<double, P> p = calc(x[i], y[i], x[j], y[j], x[k], y[k]);
                double r = p.first;
                double X = p.second.first;
                double Y = p.second.second;
                bool ok = true;
                rep(t, N) {
                    double d2 = dist(X, Y, x[t], y[t]);
                    if (r + 1e-12 < d2) ok = false;
                    //cout << d2 << endl;
                }
                //cout << X << " " << Y << " " << d << endl;
                if(ok) ans = min(ans, r);
            }
        }
    }


    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}


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

ll d[5];
int p[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

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

    rep(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') d[0]++;
        if (s[0] == 'A') d[1]++;
        if (s[0] == 'R') d[2]++;
        if (s[0] == 'C') d[3]++;
        if (s[0] == 'H') d[4]++;
    }

    ll ans = 0;
    rep(i, 10) ans += d[p[i]] * d[q[i]] * d[r[i]];

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


Measured memory_bytes: 256
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    S = input()
    N = len(S)
    group = [[]]
    g = []
    l = []
    init = 0
    indice = 0
    group_num = 0
    ind = [-1] * N
    for k in range(N):
        if S[k] == 'R':
            group[group_num].append(k)
            ind[k] = indice
            indice +=1
            g.append(group_num)
            continue
        else:
            if not init:
                l.append(indice-1)
                init = 1
            if k < N-1 and S[k+1] == 'R':
                group[group_num].append(k)
                g.append(group_num)
                group_num += 1
                group.append([])
                init = 0
                ind[k] = indice
                indice=0
            else:
                group[group_num].append(k)
                g.append(group_num)
                ind[k] = indice
                indice+=1

    #print(group)
    #print(ind)
    #print(l)
    #print(g)
    #print('')
    ret = [0] * N
    for i in range(N):
        _l = l[g[i]]
        indice = ind[i]
        if indice <= _l:
            tmp = group[g[i]][_l + (_l - indice) % 2]
            ret[tmp]+=1
        if indice >= _l+1:
            tmp = group[g[i]][_l + (_l - indice) % 2]
            ret[tmp] += 1
        #print(ret)

    print(' '.join([str(s) for s in ret]))

if __name__ == "__main__":
    run()

Measured memory_bytes: 28840
<?php 
//キュー
 $input = STDIN;
//例の場合
list($n, $q) = explode(" ", trim(fgets($input)));
$n = (int)$n;//5
$q = (int)$q;//100

for ($i = 0; $i < $n; $i++) {
    list($name_i, $time_i) = explode(" ", trim(fgets($input)));
    $time_i = (int)$time_i;
    $queue[] = [$name_i, $time_i];//p1 , 150

 }
$head = 0;
$tail = $n;
$result = 0;
$ans = "";

while($head != $tail){
    //dequeue
    list($p_name, $remain) = $queue[$head];//配列の先頭
    if($head == $n){//先頭の要素を繰り返し調べる
        $head =0;
    }else{
        $head ++;
    }
    
    if($remain <= $q){//時間内の場合　時間を代入、
        $result += $remain;
        $ans .= "{$p_name} {$result}\n";
    }else{//時間外の場合　結果にクオンタムを代入,　クオンタムを時間からひく
        $result += $q;
        $remain -= $q;
        
        //enqueue
        $queue[$tail] = [$p_name, $remain];//末尾に要素を追加
        if($tail == $n){
            $tail = 0;
        }else{
            $tail ++;
        }
    }
    
}
print $ans;
 

?>


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

  string S;
  cin >> S;
  for(int i=1; i<S.size(); i++){
    if(S[i]==S[i-1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    string s;
    cin>>s;
    vll v;
    lli sum=0;
    for (int i=0;i<s.length();i++)
    {
        if (s[i]=='R')
        sum++;
        else{
            v.pb(sum);
            sum=0;
        }
    }
    v.pb(sum);
    sort(all(v));
    cout<<v[v.size()-1];
    return 0;
}

Measured memory_bytes: 3656
N = int(input())
H = str(input())
ls_H = H.split(' ')
ls_H_i = [int(s) for s in ls_H]
MAX_H = ls_H_i[0]
count = 1
i = 2
while i <= N:
    if MAX_H <= ls_H_i[i-1]:
#        print (i, ls_H_i[i-1])
        count += 1
        MAX_H = ls_H_i[i-1]
    i += 1
print (count)

Measured memory_bytes: 3064
def main():
    S = input()
    ans = 0

    if S == "RRR":
        ans = 3
    elif S == "RRS" or S == "SRR":
        ans = 2
    else:
        if S.count("R") != 0:
            ans = 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9104
#include <stdio.h>
int main(void){
    
   int i,j,H,W;
   
   while(H!=0 || W!=0){
   scanf("%d %d",&H,&W);
   
for ( i = 1; i <= H; i++ ){
    for ( j = 1; j <= W; j++ ){
        if(i%2!=0 && j%2==0)
            printf(".");
        else if(i%2==0 && j%2!=0)
            printf(".");
        else
            printf("#");
        
    }
    printf("\n");
}
    if(H!=0 || W!=0)
    printf("\n");
}
   return 0;

   }
   


Measured memory_bytes: 2044
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		while (0 == a%2) {
			ans++;
			a /= 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
	int i, n;
	long long a, b, c, k;
	long long ans;
	scanf("%lld %lld %lld %lld\n", &a, &b, &c, &k);
	if(k == 0)
	{
		printf("%lld\n", a - b);
	}
	else 
	{
		if(k % 2 == 0)
		{
			printf("%lld\n", a - b);
		}
		else
		{
			printf("%lld\n", b - a);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int p[5];
    int k;
    REP(i,5) cin>>p[i];
    int ans = 0;
    int hasu = 10;
    REP(i,5) {
        hasu = min(hasu, (p[i]-1)% 10);
        ans += ((p[i] + 9) / 10) * 10;
    }
    cout<<ans + hasu - 9<<endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
h.reverse()
flag = True
for i in range(n-1):
    if h[i]+1==h[i+1]:
        h[i+1] -= 1
    elif h[i]+1<h[i+1]:
        flag = False
        break
print("Yes" if flag==True else "No")

Measured memory_bytes: 14228
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    string s = "";
if(N==0) cout << "0" << endl;
    while(N!=0){
       if(N%2 != 0){
          s += "1";
          N = N-1;
       }
    else{ 
       s += "0";}
      N = N/(-2);
    }
reverse(s.begin(),s.end());
cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
    switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M,X,Y,a;
    vi xi,yi;
    bool Z=false;
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; ++i){
        cin >> a;
        xi.push_back(a);
    }
    for (int i = 0; i < M; ++i){
        cin >> a;
        yi.push_back(a);
    }
    sort(yi.begin(),yi.end());
    sort(xi.begin(),xi.end(),greater<int>());
    if (X<Y&&xi[0]<yi[0]&&X<yi[0]&&Y>xi[0]){
        Z=true;
    }
    cout << (Z?"No War":"War") << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import math


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


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


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


N = z()
yakusu_nums = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        yakusu_nums[j] += 1
ans = 0
for i, yakusu_num in enumerate(yakusu_nums):
    # print(i, yakusu_num)
    ans += i*yakusu_num
print(ans)


Measured memory_bytes: 152384
#include <bits/stdc++.h>
#include <iostream>
typedef long long int ll;
using namespace std;
typedef pair<ll,ll> pp;
ll n;string s;

ll M=1000000007;

bool f(pp p1,pp p2)
{
	return p1.second<p2.second;
}


int main()
{
	ll n,w;
    cin>>n>>w;

    vector<pp> a;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        ll u,v;
        cin>>u>>v;
        a.push_back(make_pair(u,v));
        sum+=v;
    }

    ll dp[n+1][sum+1];
    ll mx=-1,mxs=-1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            if(j==0)
            {
                dp[i][j]=0;
                if(j>=mxs&&dp[i][j]!=-1)
                mxs=j;
                continue;
            }
            if(i==0)
            {
                if(j==a[i].second&&a[i].first<=w)
                dp[i][j]=a[i].first;
                else
                dp[i][j]=-1;
                if(j>=mxs&&dp[i][j]!=-1)
                mxs=j;
                continue;
            }
            else
            {
                if(j-a[i].second>=0&&dp[i-1][j-a[i].second]!=-1&&dp[i-1][j-a[i].second]+a[i].first<=w)
                dp[i][j]=a[i].first+dp[i-1][j-a[i].second];
                else
                dp[i][j]=-1;

                if(dp[i-1][j]!=-1)
                {
                    if(dp[i][j]==-1)
                    dp[i][j]=dp[i-1][j];
                    else
                    {
                        dp[i][j]=min(dp[i][j],dp[i-1][j]);
                    }
                }
                if(j>mxs&&dp[i][j]!=-1)
                mxs=j;
            }
        }
    }
    cout<<mxs<<"\n";
    
 /*   for(int i=0;i<n;i++)
    {
    	for(int j=0;j<=sum;j++)
    	cout<<dp[i][j]<<" ";
    	cout<<"\n";
	}*/

    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 105 ;
vector<ll> to(N,0) ;
void solve()
{
    ll n , m , x , ans = 1 , y ;
    cin >> n >> m;
    vector<ll> a(n) , b(m) ;
    set<ll> sa , sb ;
    rep( i , 0 , n )
    {
        cin >> a[i] ;
        sa.insert(a[i]);
    }
    rep( i , 0 , m )
    {
        cin >> b[i] ;
        sb.insert(b[i]);
    }
    if(sz(sa)<n||sz(sb)<m)
    {
        cout << 0 ;return;
    }
    sort(all(a));
    sort(all(b));
    for( ll i = n*m ; i >= 1 ; i-- )
    {
        if( sa.find(i)==sa.end() && sb.find(i) == sb.end() )
        {
            x = a.end() - upper_bound(all(a),i) , y = b.end() - upper_bound(all(b),i) ;
            ans = ( ans * ( x*y - (n*m-i) ) ) % hell ;
        }
        else if( sa.find(i)==sa.end() )
        {
            x = a.end() - upper_bound(all(a),i) ;
            ans = ( ans * x ) % hell ;
        }
        else if( sb.find(i)==sb.end() )
        {
            y = b.end() - upper_bound(all(b),i) ;
            ans = ( ans * y ) % hell ;
        }
    }
    cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k,sum=0;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(n<=k)
    {
        cout<<"0"<<endl;
    }
    else
    {
         for(int i=0;i<n-k;i++)
         {
             sum+=a[i];
         }
         cout<<sum<<endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
// #define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	FAST_IO;
	int x, n;
	cin >> x >> n;
	set<int> kek;
	for (int i = -101; i <= 101; i++) {
		kek.insert(i);
	}
	forn(i, n) {
		int val;
		cin >> val;
		kek.erase(val);
	}
	int mn = 1e9, ans;
	auto j = lower_bound(all(kek), x);
	mn = abs(*j - x);
	ans = *j;
	j++;
	if (j != kek.end()) {
		if (abs(*j - x) < mn) {
			mn = abs(*j - x);
			ans = *j;
		}
	}
	j--;
	if (j != kek.begin()) {
		j--;
		if (abs(*j - x) <= mn) {
			mn = abs(*j - x);
			ans = *j;
		}
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 3672