akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  priority_queue<ll,vector<ll>,greater<ll> > que;
  rep(i,n) {
    ll x;
    R x;
    que.push(x);
  }
  P p[m];
  rep(i,m) cin >> p[i].S >> p[i].F;
  sort(p,p+m,greater<P>());
  rep(i,m) {
    rep(j,p[i].S) {
      if(que.top()>=p[i].F) break;
      que.pop();
      que.push(p[i].F);
    }
  }
  ll ans=0;
  while(!que.empty()) {
    ans+=que.top();que.pop();
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll x, n;
    double b;
    ll p[200010];
    string s;
  
    cin >> x >> n;

    ll eq = 1;
    REP(i, n){
        cin >> p[i];
        if (p[i] == x){
            eq = 0;
        }
    }

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

    REP(i, 100){
        auto diff = i+1;
        auto match = 0;
        REP(j, n){
            if (p[j] == x-diff){
                match = 1;
                break;
            }
        }
        if (match == 0){
            cout << x-diff << endl;
            return 0;
        }

        match = 0;
        REP(k, n){
            if (p[k] == x+diff){
                match = 1;
                break;
            }
        }
        if (match == 0){
            cout << x+diff << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

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

    String x = sc.next();
    String y = sc.next();
    String a[] = x.split("");
    String b[] = y.split("");

    Arrays.sort(a);
    Arrays.sort(b, Comparator.reverseOrder());

    String as = String.join("", a);
    String bs = String.join("", b);

    //System.out.println(as);
    //System.out.println(bs);

    if (as.compareTo(bs) < 0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
typedef long long ll;
#define m 1000000007
using namespace std;
ll mod(ll x,ll y)
{ ll ans=1;

    while(y>0)
    {
        if(y&1)
            ans=ans*x %m;
        y/=2;
        x=(x*x) %m;

    }
    return ans;
}
int main()
{
 /*ll a,b,c,d,m,n,res=0;
 cin>>a>>b>>c>>d;
 cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;*/

 ll n;
 cin>>n;
 ll ans= (mod(10,n)-(mod(9,n)*2-mod(8,n)))%m;
 //ll ans=mod(8,n);
 if(ans<0)
    ans+=m;
 cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[101];
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	int m;
	cin>>m;
	while(m--)
	{
		int ppp=sum;
		int a,b;
		cin>>a>>b;
		cout<<sum-arr[a]+b<<endl;
	}
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			short ze = 0, on = 0, tw = 0, th = 0, fo = 0, fi = 0, si = 0, se = 0, ei = 0, ni = 0;
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				if (Character.toString(input.charAt(i)).equals("0")) {
					ze++;
				} else if (Character.toString(input.charAt(i)).equals("1")) {
					on++;
				} else if (Character.toString(input.charAt(i)).equals("2")) {
					tw++;
				} else if (Character.toString(input.charAt(i)).equals("3")) {
					th++;
				} else if (Character.toString(input.charAt(i)).equals("4")) {
					fo++;
				} else if (Character.toString(input.charAt(i)).equals("5")) {
					fi++;
				} else if (Character.toString(input.charAt(i)).equals("6")) {
					si++;
				} else if (Character.toString(input.charAt(i)).equals("7")) {
					se++;
				} else if (Character.toString(input.charAt(i)).equals("8")) {
					ei++;
				} else if (Character.toString(input.charAt(i)).equals("9")) {
					ni++;
				}
				sum = (short) (0 * ze + 1 * on + 2 * tw + 3 * th + 4 * fo + 5
						* fi + 6 * si + 7 * se + 8 * ei + 9 * ni);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 19872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
const ll MOD=1000000007;


bool prohibited(int a, int b, int c, int d){
  if(      b==1&&c==2&&d==3){return true;}
  if(      b==2&&c==1&&d==3){return true;}
  if(      b==1&&c==3&&d==2){return true;}
  if(a==1&&      c==2&&d==3){return true;}
  if(a==1&&b==2&&      d==3){return true;}
  return false;
}


int main(){
  int N;cin >> N;
  ll dp[N+10][256][2]={};
  dp[0][0][0]=1;

  for (int n=0;n<N;++n){
    for (int a=0;a<4;++a){
      for (int b=0;b<4;++b){
        for (int c=0;c<4;++c){
          for (int d=0;d<4;++d){
            int abcd=a*64+b*16+c*4+d;
            for (int e=0;e<4;++e){
              int bcde=b*64+c*16+d*4+e;
              bool t=prohibited(b,c,d,e);
              (dp[n+1][bcde][1]+=dp[n][abcd][1])%=MOD;
              if (t==true){
                (dp[n+1][bcde][1]+=dp[n][abcd][0])%=MOD;
              }
              if(t==false){
                (dp[n+1][bcde][0]+=dp[n][abcd][0])%=MOD;
              }
            }
          }
        }
      }
    }
  }

  ll ans=0;
  for (int i=0;i<256;++i){
    ans+=dp[N][i][0];
  }
  ans%=MOD;

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

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

int main() {
    string S;
    cin >> S;

    int ans = 0;
    for (int i = 1; 2 * i < S.size(); i++) {
        if (S.substr(0, i) == S.substr(i, i)) {
            ans = 2 * i;
        }
    }
    cout << ans << endl;

    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vvi dp ( 2 , vi ( 3 ) ) ;

    for ( int i=0 ; i < 3 ; i ++ )
        cin >> dp[0][i] ;

    for ( int i = 1 ; i < n ; i ++ )
    {
        for ( int j = 0 ; j < 3 ; j ++ )
        {
            cin >> dp[1][j] ;
        }

        for ( int j = 0 ; j < 3 ; j ++ )
        {
            int M = -1 ;
            for ( int jj = 0 ; jj < 3 ; jj ++ )
            {
                if ( j == jj ) C ;
                M = max ( M , dp[0][jj] ) ;
            }

            dp[1][j] += M ;
        }

        for ( int j = 0 ; j < 3 ; j ++ )
            dp[0][j] = dp[1][j] ;
    }

    int ans = -1 ;

    for ( int i=0 ; i < 3 ; i ++ )
        ans = max ( ans , dp[0][i] ) ;

    cout << ans << "\n" ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
typedef long long ll;
const int MOD = 1000000007;
#define PI 3.141592653589
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int len = 2 * m + 1;
	if (m % 2 == 1) {
		for (int i = 1; i <= m / 2; i++)
				cout << i << ' ' << m - i + 1 << endl;
		for (int i = 1; i <= m / 2 + 1; i++)
			cout << m + i << ' ' << len - i + 1 << endl;

	}
	else {
		for (int i = 1; i <= m / 2; i++)
			cout << i << ' ' << m + 2 - i << endl;
		for (int i = 1; i <= m / 2; i++)
			cout << m + 1 + i << ' ' << len - i + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3524
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

class unionfind():
    def __init__(self, n):
        self.n = n
        # 中身が負の数なら根であり、数字の絶対値はグループ数
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0: return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]
    def union(self, x, y):
        x,y = self.find(x), self.find(y)
        if x == y: return
        if self.parents[x] > self.parents[y]: x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x): return -self.parents[self.find(x)]
    def same(self, x, y): return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self): return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self): return len(self.roots())

n,m,k = imap()
uf = unionfind(n)
f,ng,anss = iarr(n),iarr(n),iarr(n)

for i in range(m):
    a,b = imap()
    a,b = a-1,b-1
    f[a] += 1
    f[b] += 1
    uf.union(a,b)

for i in range(n):
    anss[i] = uf.size(i) - f[i] - 1

for i in range(k):
    c,d = imap()
    c,d = c-1,d-1
    if uf.same(c,d):
        anss[c] -= 1
        anss[d] -= 1

print(*anss)


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

int main(){
    int n; cin >> n;
    int luca0=2, luca1=1;
    int64_t ans=0, temp1=2, temp2=1;
    for(int i=2; i<=n; ++i){
        ans = temp1+temp2;
        temp1 = temp2;
        temp2 = ans;
    }

    if(n==0) ans=2;
    if(n==1) ans=1;

    cout << ans << endl;
}

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

int gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
int lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
        bool flag=true;
    ll g=gcd(n,m);
    ll ans=n*m/g;
    n/=g;
    m/=g;
        for(ll i=0;i<g;i++){
            if(s[i*n]!=t[i*m])flag=false;
        }
        if(flag)cout<<ans<<endl;
        else cout<<-1<<endl;
}

Measured memory_bytes: 512
input()
a = [int(x) for x in input().split(' ')]

neg = [x for x in a if x < 0]

b = len(neg) % 2 == 0

if b:
    print(sum([abs(x) for x in a]))
else:
    a.remove(max(neg))
    flip = [abs(x) for x in a]
    if -max(neg) > min(flip):
        print(sum(flip) - min(flip) * 2- max(neg))
    else:
        print(sum(flip) + max(neg))


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    int alice = 0;
    int bob = 0;
    vector<int> a(100);
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());

    for(int i=0; i<n; i+=2){
        alice += a[i];
    }
    for(int i=1; i<n; i+=2){
        bob += a[i];
    }

    cout << alice-bob << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[] for _ in range(n)]
 
for i in range(n):
  a[i] = list(map(int, input().split()))
 
b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())
 
for i in range(n):
  c = 0
 
  for j in range(m):
    c += a[i][j]*b[j]
 
  print(c)


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

int main() {
  int D; cin >> D;
  int N = 26;
  int C[N]; for (int i = 0; i < N; i++) cin >> C[i];
  int S[D][N];
  for (int d = 0; d < D; d++) {
    for (int i = 0; i < N; i++) {
      cin >> S[d][i];
    }
  }
  int L[N]; for (int i = 0; i < N; i++) L[i] = -1000;
  for (int d = 0; d < D; d++) {
    int max_select = -1, max_num = -1e+9;
    for (int i = 0; i < N; i++) {
      int num = S[d][i];
      if (L[i] >= 0) num += L[i] * C[i];
      if (num >= max_num) {
        max_select = i; max_num = num;
      }
    }
    cout << max_select + 1 << endl;
    L[max_select] = 0;
    for (int i = 0; i < N; i++) L[i]++;
  }
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = split[0];
        int X = split[1];
        int[] L = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n_bound = 1;
        int bound_zahyou = 0;
        for (int i = 0; i < N; i++)
        {
            bound_zahyou += L[i];
            if (bound_zahyou <= X)
            {
                n_bound++;

            }
            else
            {
                break;
            }

        }
        Console.WriteLine(n_bound);


    }



}

Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
using namespace std;

#define TEST 0 //??\??????????????????(1:??????????????\??? 0:?¨??????\???)
#if TEST
#define FNAME "A"
FILE *in = freopen("./Q/"FNAME, "r", stdin);
FILE *out = freopen("./A/"FNAME, "w", stdout);
#endif


// 12x12????????¢???
char mp[12][13];

// 4????????¢?´¢??¨
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };
// ??±???????????¢?´¢
void dfs(int x, int y){
	mp[x][y] = '0';

	for (int i = 0; i < 4; i++){
		int nx = x + dx[i], ny = y + dy[i];
		if (mp[nx][ny] == '1') dfs(nx, ny);
	}
}

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

	while (cin >> mp[0]){
		for (int i = 1; i < 12; i++){
			cin >> mp[i];
		}

		int islands = 0;
		for (int x = 0; x < 12; x++){
			for (int y = 0; y < 12; y++){
				if (mp[x][y] == '1'){
					islands++;
					dfs(x, y);
				}
			}
		}

		cout << islands << endl;
	}

#if TEST
	fclose(in);
	fclose(out);
#endif
}

Measured memory_bytes: 3112
#include<stdio.h>

int main(){
	int m,i;
	scanf("%d",&m); 
	int a[m],b[m];
	for(i=0;i<m;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<m;i++){
		b[(a[i]-1)]=i+1;
	}
	for(i=0;i<m;i++){
		printf("%d ",b[i]);
	}
	return 0;
} 


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  vi L(n);
  rep(i,n)cin>>L[i];
  sort(rng(L));
  int mx = L[n-1];
  int sum =0;
  rep(i,n-1){
    sum+=L[i];
  }
  if(sum>mx)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int H, W, h ,w;

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

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

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a[3],d;
    cin>>a[0]>>a[1]>>a[2]>>d;


    if (abs(a[1]-a[0])<=d && abs(a[2]-a[1])<=d)
    cout<<"Yes\n";

    else if (abs(a[2]-a[0])<=d)

    cout<<"Yes\n";

    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1005;

int n, i, j;
char tab[N][N];

string tab3[3] = {"..a", "..a", "aa."};
string tab4[4] = {"aacd", "bbcd", "cdaa", "cdbb"};
string tab5[5] = {"aabba", "b..ca", "b..cb", "acc.b", "abbaa"};
string tab6[6] = {"aacd..", "bbcd..", "..aacd", "..bbcd", "cd..aa", "cd..bb"};
string tab7[7] = {"abc....", "abc....", "bca....", "bca....", "a..bbcc", "a..ccbb", ".aabbaa"};

void go(int start) {
	for (int i=0;i<4;i++) for (int j=0;j<4;j++) {
		int k1 = i + start;
		int k2 = j + start;
		while (k1 < n) {
			tab[k1][k2] = tab4[i][j];
			k1 += 4;
			k2 += 4;
		}
	}
}

int main() {
scanf("%d", &n);
if (n <= 2) {
	printf("-1\n");
	return 0;
}
for (i=0;i<n;i++) for(j=0;j<n;j++) tab[i][j] = '.';
if (n == 3) {
	for (i=0;i<n;i++) printf("%s\n", tab3[i].c_str()); 
	return 0;
}
else if (n == 4) {
	for (i=0;i<n;i++) printf("%s\n", tab4[i].c_str()); 
	return 0;
}
else if (n == 5) {
	for (i=0;i<n;i++) printf("%s\n", tab5[i].c_str()); 
	return 0;
}
else if (n == 6) {
	for (i=0;i<n;i++) printf("%s\n", tab6[i].c_str()); 
	return 0;
}
else if (n == 7) {
	for (i=0;i<n;i++) printf("%s\n", tab7[i].c_str()); 
	return 0;
} else if (n % 2 == 0) {
	if (n % 4 == 0) go(0); else {
		for (i=0;i<6;i++) for (j=0;j<6;j++) tab[i][j] = tab6[i][j];
		go(6);		
	}
} else {
	if (n % 4 == 1) {
		for (i=0;i<5;i++) for (j=0;j<5;j++) tab[i][j] = tab5[i][j];
		go(5);
	} else {
		for (i=0;i<7;i++) for (j=0;j<7;j++) tab[i][j] = tab7[i][j];
		go(7);
	}
}
for (i=0;i<n;i++) {
	for (j=0;j<n;j++) printf("%c", tab[i][j]);
	printf("\n");
}
return 0;
}





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


int main(void){
    // Your code here!
    int a,b;
    string s;
    cin>>a>>b;
    cin>>s;
    bool flag =true;
    int temp=0;
    for(temp=0;temp<a;temp++){
        if(s[temp]=='0'||s[temp]=='1'||s[temp]=='2'||s[temp]=='3'||s[temp]=='4'||s[temp]=='5'||s[temp]=='6'||s[temp]=='7'||s[temp]=='8'||s[temp]=='9')    continue;
        else if(s[temp]=='-')flag = false;
    }
    if(s[a]!='-')flag = false;
    for(temp=a+1;temp<a+b+1;temp++){
        if(s[temp]=='0'||s[temp]=='1'||s[temp]=='2'||s[temp]=='3'||s[temp]=='4'||s[temp]=='5'||s[temp]=='6'||s[temp]=='7'||s[temp]=='8'||s[temp]=='9')    continue;
        else if(s[temp]=='-')flag = false;
    }
    if(flag==true)cout<<"Yes"<<endl;
    else cout<< "No"<<endl;
    return 0;
}


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

const int INF = 1e10;

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

  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];

  int min_1 = INF;
  int max_1 = -INF;
  int min_2 = INF;
  int max_2 = -INF;

  rep(i,n) {
    min_1 = min(min_1, x[i] + y[i]);
    max_1 = max(max_1, x[i] + y[i]);
    min_2 = min(min_2, x[i] - y[i]);
    max_2 = max(max_2, x[i] - y[i]);
  }

  int best = 0;
  best = max({best, max_1 - min_1, max_2 - min_2});

  cout << best << '\n';
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 7654321
#define IINF 87654321987654321LL
#define MAXV 200500

ll mod = 1e9 + 7;
int N;
vector<int> E[100500];
int deg[100500];
bool die[100500];
int deg2[100500];
int main(){
	geti(N);
	repp(i,N-1){
		int a,b; geti(a,b);
		deg[a]++; deg[b]++;
		E[a].pb(b); E[b].pb(a);
	}

	bool chk = true;
	rep(i,N){
		if( deg[i] >= 3 ) chk = false;
	}
	if( chk ){
		printf("1\n");
		return 0;
	}



	int cnt = 0;
	queue<int> q;
	rep(i,N){
		if( deg[i] == 1 ) q.push(i);
	}

	while(!q.empty()){
		int x = q.front(); q.pop();
		for(auto e : E[x]) if(!die[e]){
			if( deg[e] == 2 ){
				die[x] = true;
				q.push(e);
				deg[e]--;
			}
		}
	}
	
	rep(i,N) if(!die[i]){
		if( deg[i] == 1 ){
			for(auto e : E[i])if(!die[e]){
				deg2[e] ++ ;
			}
		}
	}
	int ans = 0;
	rep(i,N)if(!die[i]){
		if( deg2[i] > 1 ) ans += deg2[i]-1;
	}
	printf("%d\n",ans);

}

Measured memory_bytes: 7524
package main

import (
	"fmt"
)

type ll int64


func main() {

	var N int
	fmt.Scan(&N)

	slice := make([]int,N)

	max_first := 0
	max_second := 0

	var buffer int = 0

	for i:=0;i< N ;i++  {
		fmt.Scan(&buffer)
		slice[i] = buffer
		if buffer >= max_first {
			max_second = max_first
			max_first = buffer
		} else if buffer >= max_second {
			max_second = buffer
		}

	}

	for i:=0;i<N;i++  {
		if slice[i] == max_first {
			fmt.Println(max_second)
		}else {
			fmt.Println(max_first)
		}
	}


}


Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
 
int a[101];
int rate[8];
 
int main(){
	int n;
	
	int over = 0;
	
	cin >> n;
	
	REP(i,n){
		scanf("%d", &a[i]);
		
		if (a[i] < 3200) rate[a[i]/400]++;
		else over++;
	}
	
	int sum = 0;
	
	REP(i,8){
		if (rate[i]) sum++;
	}
	
	if (sum) cout << sum << endl;
	else cout << "1" << endl;
	
	cout << sum+over << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
   double p[n];
   for(int i=0;i<n;i++)
        cin>>p[i];

  double dp[n+1][n+1];
  memset(dp,0.0,sizeof(dp));
  dp[0][0]=1.0;
  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<=i;j++)
      {
          if(j==0)
         dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
         else
         {
             dp[i][j]=dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*(p[i-1]);
         }
      }
  }
   double ans = 0.0; 

   for(int i=(n+1)/2;i<=n;i++)
   {
       ans=ans+dp[n][i];
   }
   cout<<setprecision(10)<<fixed<<ans;

}

Measured memory_bytes: 70656
#include <stdio.h>          // printf(), scanf()
#include <ctype.h>          // isdigit()

int
main(int argc, char **argv)
{
	int c;

	int N = 0;
	c = getc(stdin);
	while (isdigit(c))
	{
		N = N * 10 + c - '0';
		c = getc(stdin);
	}

	long sum = 0;
	for (int i = 0; i < N; ++i)
	{
		while (!isdigit(c) && c != EOF)
			c = getc(stdin);

		int a = 0;
		while (isdigit(c))
		{
			a = a * 10 + c - '0';
			c = getc(stdin);
		}

		sum += a;
	}

	int avr = sum / N;
	printf("%d\n", avr);
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  ll N;
  ios::sync_with_stdio(false);
  cin >> N;
  vector<ll> A(N);
  ll A_max=0;
  ll A_max_i=0;
  rep(i, 0, N){
    cin >> A[i];
    if(A_max < A[i]){
      A_max = A[i];
      A_max_i = i;
    }
  }

  A[A_max_i] = A[N-1];
  A.pop_back();

  ll A_middle=0;
  ll A_middle_num=A_max;
  rep(i, 0, N-1){
    if(A_middle_num > abs((A_max/2)-A[i])){
      A_middle_num = abs((A_max/2)-A[i]);
      A_middle = A[i];
    }
  }

  cout << A_max << " " << A_middle << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main() {
  int H, W;
  std::cin >> H >> W;
  std::string c[H];
  for (int i = 0; i < H; ++i) {
    std::cin >> c[i];
  }

  for (int i = 0; i < H; ++i) {
    std::cout << c[i] << std::endl;
    std::cout << c[i] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  string A;
  cin >> A;
  ll cnt[26] = {};
  ll len = A.length();
  ll ans = len*(len-1)/2 + 1;
  REP(i,len) cnt[(int)(A[i] - 'a')]++;
  REP(i,26){
    ans -= cnt[i]*(cnt[i]-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <queue>
#include <cstdio>
using namespace std;
 
const int INF = 0x3f3f3f3f;
const int MAXN = 5e5 + 5;
 
template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}
 
template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}
 
template<typename _T>
_T MIN( const _T a, const _T b )
{
	return a < b ? a : b;
}
 
template<typename _T>
_T MAX( const _T a, const _T b )
{
	return a > b ? a : b;
}
 
struct edge
{
	int to, nxt;
}Graph[MAXN << 1];
 
priority_queue<int, vector<int>, greater<int> > q;
 
int mn[MAXN << 2];
 
int seq[MAXN], ans[MAXN];
int A[MAXN], P[MAXN], head[MAXN], deg[MAXN];
int N, K, cnt;
 
void addEdge( const int from, const int to )
{
	Graph[++ cnt].to = to, Graph[cnt].nxt = head[from];
	head[from] = cnt, deg[to] ++;
}
 
void upt( const int x ) { mn[x] = MIN( mn[x << 1], mn[x << 1 | 1] ); }
 
void build( const int x, const int l, const int r )
{
	if( l > r ) return ; mn[x] = INF;
	if( l == r ) return ;
	int mid = l + r >> 1;
	build( x << 1, l, mid );
	build( x << 1 | 1, mid + 1, r );
}
 
void update( const int x, const int l, const int r, const int p, const int v )
{
	if( l == r ) { mn[x] = v; return ; }
	int mid = l + r >> 1;
	if( p <= mid ) update( x << 1, l, mid, p, v );
	else update( x << 1 | 1, mid + 1, r, p, v );
	upt( x );
}
 
int query( const int x, const int l, const int r, const int segL, const int segR )
{
	if( segL <= l && r <= segR ) return mn[x];
	int mid = l + r >> 1, ret = INF;
	if( segL <= mid ) ret = MIN( ret, query( x << 1, l, mid, segL, segR ) );
	if( mid < segR ) ret = MIN( ret, query( x << 1 | 1, mid + 1, r, segL, segR ) );
	return ret;
}
 
int query( const int l, const int r ) { return query( 1, 1, N, MAX( 1, l ), MIN( N, r ) ); }
 
int main()
{
	read( N ), read( K );
	for( int i = 1 ; i <= N ; i ++ ) read( P[i] ), A[P[i]] = i;
	build( 1, 1, N );
	for( int i = N ; i ; i -- )
	{
		int pre = query( A[i] - K + 1, A[i] ),
			nxt = query( A[i], A[i] + K - 1 );
		if( pre < INF ) addEdge( A[i], A[pre] );
		if( nxt < INF ) addEdge( A[i], A[nxt] );  
		update( 1, 1, N, A[i], i );
	}
	for( int i = 1 ; i <= N ; i ++ )
		if( ! deg[i] ) q.push( i );
	int u, v, tot = 0;
	while( ! q.empty() )
	{
		u = seq[++ tot] = q.top(), q.pop();
		for( int i = head[u] ; i ; i = Graph[i].nxt )
			if( ! ( -- deg[v = Graph[i].to] ) )
				q.push( v );
	}
	for( int i = 1 ; i <= N ; i ++ ) ans[seq[i]] = i;
	for( int i = 1 ; i <= N ; i ++ ) write( ans[i] ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 27528
n = int(input())
a = list(map(int, input().split()))

sum = 0
for i in range(n):
    sum += a[i]
sum %= 1000000007

ans = 0
for i in range(n):
    sum -= a[i]
    if sum < 0:
        sum += 1000000007
    ans += a[i] * sum
    ans %= 1000000007
print(ans)


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

int a, b, h;

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

    int res = (a + b) * h / 2;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int d, t, s, a;
	scanf("%d%d%d", &d, &t, &s);
	a = t * s;
	d = d - a;
	if (d <= 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    ans[A[i]-1]=i+1;
  }
  for(int i=0;i<N-1;i++){
    cout<<ans[i]<<" ";
  }
  cout<<ans[N-1]<<endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;

bool is_prime(int n){
    for(int i=2; i<=sqrt(n);i++){
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int n, a;
    int count{0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        if (is_prime(a)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

vector<int> shuffle(vector<int> a, int p, int c, int n)
{
  vector<int> b;

  FOR(i,p-1,p+c-1) b.push_back(a[i]);
  FOR(i,0,p-1) b.push_back(a[i]);
  FOR(i,p+c-1,n) b.push_back(a[i]);

  //REP(i,n) cout<<b[i]<<" ";

  return b;
}

int solve(int n,int r)
{
  vector<int> a;
  int p, c;

  REP(i,n) a.push_back(n-i);
  //REP(i,n) cout<<a[i]<<" ";

  REP(i,r){
    cin>>p>>c;
    a = shuffle(a, p, c, n);
  }

  return a[0];
}

int main()
{
  int n, r;

  while(1) {
    cin>>n>>r;
    if (n == 0 && r == 0) break;
    cout<<solve(n,r)<<endl;
  }


  return 0;
}



Measured memory_bytes: 3120
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split('\n');
    for (var i = 0; i < inputs.length; i++) {
    	if (inputs[i] === '0 0'){
    		break;
    	}
    	var input = inputs[i].split(' ')
    	.map(Number).sort(function(a,b){
    		return a - b;
    	
    	})
    	.join (' ');
    	console.log (input);
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    for (int s = 0; s < 1 << n; s++)
    {
        cout << s << ':';
        for (int i = 0; i < n; i++)
        {
            if (s >> i & 1)
            {
                cout << ' ' << i;
            }
        }
        cout << '\n';
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
    std::string fizzBuzzString;
    
    if(n % 15 == 0)
    {
        fizzBuzzString = "FizzBuzz";
    }
    else if(n % 5 == 0)
    {
        fizzBuzzString = "Buzz";
    }
    else if(n % 3 == 0)
    {
        fizzBuzzString = "Fizz";
    }
    else
    {
        fizzBuzzString = std::to_string(n);
    }
    
    return fizzBuzzString;
}

void fizzBuzzGame(int num_of_players, int num_of_remarks)
{
    std::list<int> player_list;

	/* ?????¬???????????????????????¨???????????¬?????????????????????push?????? */
    for(int i = 1; i <= num_of_players; i++ )
    {
        player_list.push_back(i);
    }

	/* fizz buzz ?????????????§? */
    for(int i = 1; i <= num_of_remarks; i++)
    {
        /* ??\??????????????? */
        std::string remarks;
        std::cin >> remarks;

        /* ?????¬??????????????????????????£?????????????£???°??? */
        if(player_list.size() <= 1)
        {
            continue;
        }

        /* ?????¬?????????????????? */
        int player = *(player_list.begin());
        player_list.pop_front();

        /* ?????????????????? */
        std::string expect_remarks = getFizzBuzzString(i);
        
        /* ??£??????????¨??????????????????°????????????push???????????? */
        /* ????????£????????????????????????push??????????????¨??§??¢??±???????????¨????????? */
        if(remarks == expect_remarks)
        {
            player_list.push_back(player);
        }
    }
    
    /* ???????????????????????£??????????????¬????????????????????????????????? */
    player_list.sort();
	for(auto itr = player_list.begin(); itr != player_list.end(); ++itr)
	{
		if(itr != player_list.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
    std::cout << std::endl;
	
	return;
}

void volume2_0221()
{
    int num_of_players;
    int num_of_remarks;
    
    for(;;)
    {
        /* ?????¬???????????°??¨????¨??????°??????????????? */
        std::cin >> num_of_players >> num_of_remarks;
        
        /* ?????¬???????????°???????¨??????°??±??? 0 ????????\????????? */
        if( num_of_players == 0 && num_of_remarks == 0 )
        {
            break;
        }
        
    	/* FizzBuzzGame ?????? */
    	fizzBuzzGame(num_of_players, num_of_remarks);
    }

    return;
}

int main(void)
{
    volume2_0221();
    
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int D, G;
int p[10], c[10];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = 1 << 30;
  for (int i = 0; i < 1 << D; i++) {
    int sum = 0, tmp = 0;
    for (int j = 0; j < D; j++) {
      if (i >> j & 1) {
        sum += p[j] * (j + 1) * 100 + c[j];
        tmp += p[j];
      }
    }
    int rem = G - sum;
    if (rem > 0) {
      for (int j = D - 1; j >= 0; j--) {
        if (i >> j & 1) continue;
        int pt = (j + 1) * 100;
        if (rem - pt * (p[j] - 1) > 0) {
          rem -= pt * (p[j] - 1);
          tmp += p[j] - 1;
        } else {
          tmp += (rem + pt - 1) / pt;
          rem -= (rem + pt - 1) / pt * pt;
          break;
        }
      }
    }
    if (rem <= 0) ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=9 && B<=9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

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

	int aNum = 0;
	int zNum = 0;


	for (int i = 0; i<s.length(); ++i){
		if (s[i] == 'A'){
			aNum = i;
			break;
		}
	}

	for (int i = s.length(); i>0; --i){
			if (s[i] == 'Z'){
				zNum = i;
				break;
			}
		}

	cout << zNum-aNum+1 << endl;



	return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(n) cout<<n<<endl
ll h, w,ans=INF;
int main() {
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0)print(0),exit(0);
	for (ll i = 1; i < h;++i) {
		ans = min(ans, max({ w*i, w / 2 * (h - i),(w - w / 2)*(h - i) })-min({ w*i, w / 2 * (h - i),(w - w / 2)*(h - i) }));
	}
	ans = min(ans, w);
	for (ll i = 1; i < w; ++i) {
		ans = min(ans, max({ h*i, h / 2 * (w - i),(h - h / 2)*(w - i) })-min({ h*i, h / 2 * (w - i),(h - h / 2)*(w - i) }));
	}
	ans = min(ans, h);
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<set> 
#include<queue>
#include<list> 
#include<vector>
const int maxn=500000+5;
using namespace std;

vector<int> v[maxn];
long long zero=0,one=0;
struct pp{
	int data;
	int zt;
};
int vis[maxn]; 
queue<int> p;
int bj[maxn];
void bfs(){
	while(!p.empty()){
	      int x=p.front();
//		  if(x.zt==0)
//		  zero++;
//		  else
//		  one++;
		  p.pop();
		  for(int i=0;i<v[x].size();i++){
		  	    if(vis[v[x][i]]==0){
		vis[v[x][i]]=1;
				  bj[v[x][i]]=x;
		  	    p.push(v[x][i]);}
		  }
		}
	} 
int main()
{  
	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<m;i++){
			int a,b;
			cin>>a>>b;
			v[a].push_back(b);
			v[b].push_back(a);
		
		}
		 p.push(1);
		 vis[1]=1;
		 bfs();
		 int k=0;
		 for(int i=2;i<=n;i++){
		 	if(bj[i]==0)
		 	{ k==1;
		 	  break;
			 }
		 } 
		 if(k==1)
		 cout<<"No"<<endl;
		 else
		 {
		  cout<<"Yes"<<endl; 
		 for(int i=2;i<=n;i++){
		 	cout<<bj[i]<<endl;
		 }
}

	
	
	
}


Measured memory_bytes: 19800
#include <stdio.h>
#include <stdlib.h>

int syojun_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
int kojun_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
// qsort(data, N, sizeof(int), syojun/kojun_int);

int main(){
  int i,N,M,X[100001],Xd[100001],sum=0,big;
  scanf("%d %d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d",&X[i]);
  }
  if(N>M){
    printf("0\n");
    return 0;
  }
  qsort(X, M, sizeof(int), kojun_int);
  for(i=1;i<M;i++){
    Xd[i-1]=X[i]-X[i-1];
    sum+=X[i]-X[i-1];
  }
  //if(N==1){
    //printf("%d\n",sum+1);
    //return 0;
  //}
  qsort(Xd, M, sizeof(int), syojun_int);
  for(i=0;i<N-1;i++){
    sum-=Xd[i];
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 1268
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#G = [input() for i in range(0, H)] #文字列を複数行に渡って

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)


#a[始まりの位置: 終わりの位置: スライスの増分] # (a は配列)


#import numpy as np  #importに100 ms 程度かかる。
import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = int(10**18) #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。
#np.gcd.reduce(A) #(Aは配列) で、Aの全ての要素の gcd が計算できる。


N = int(input())
A = [int(x) for x in input().split()]

sum = 0
sum2 = 0
for i in range(0, N):
    sum += A[i]
    sum2 += A[i] * A[i]
#

res = sum * sum - sum2
res //= 2
res %= MOD
print(res)

















Measured memory_bytes: 32532
S = str(input())
al = [chr(ord('a') + i) for i in range(26)]
data = []
for x in S:
    if not x in data:
        data.append(x)
ans = list(set(al) ^ set(data))
ans.sort()
if len(ans) == 0:
    print('None') 
else:
    print(ans[0])

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

const int MOD = 1000000007;
int N, M;
vector<bool> a;

int dp[100010];

int main() {
    
    cin >> N >> M;
    a.assign(N+1, true);
    rep(i, M) {
        int x;
        cin >> x;
        a[x] = false;
    }
    dp[0] = 1;
    rep(i, N+1) {
        if(!a[i]) continue;
            if(a[i + 1]) {
               ( dp[i + 1] += dp[i]) %= MOD;
            }
            if (a[i + 2]) {
                (dp[i + 2] += dp[i])  %= MOD;
            }
    }
    cout << dp[N] << "\n";
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();
            var list = new List<long>();
            list.Add(0);
            list.Add(A[0]);
            var answer = 0L;
            for (var i = 1; list.Count < N; i++)
            {
                list.Add(A[i]);
                list.Add(A[i]);
            }
            answer = list.Sum();
            if (list.Count > N) answer -= list[list.Count - 1];
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 55384