akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a[] = new int[3];
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            Arrays.sort(a);
            for (int i = 0; i < 3; i++) {
                if (i != 2)
                    out.print(a[i] + " ");
                else
                    out.print(a[i] + "\n");
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}




Measured memory_bytes: 24308
# -*- coding: utf-8 -*-
x,y = map(int,input().split())
A = {1,3,5,7,8,10,12}
B = {4,6,9,11}
C = {2}
S = {x,y}
if (S <= A or S <= B) is True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector> 
#include <string>
#include <set>
#include <unordered_set>
using namespace std;
 
int main() {
	
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size() - 1 ; i++) {
  	if(s[i] == s[i+1]) {
  		cout << "Bad";
  		return 0;
  	}
  }
  cout << "Good" << "\n";
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vi l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int ans = INT_MAX;
  for (int i = 1; i < pow(4, n); i++) {
    int a_tmp = a;
    int a_cnt = 0;
    int b_tmp = b;
    int b_cnt = 0;
    int c_tmp = c;
    int c_cnt = 0;
    for (int j = 0; j < n; j++) {
      int state = (i >> (j * 2)) & 0x3;
      if (state == 1) {
        a_tmp -= l[j];
        a_cnt++;
      } else if (state == 2) {
        b_tmp -= l[j];
        b_cnt++;
      } else if (state == 3) {
        c_tmp -= l[j];
        c_cnt++;
      }
    }
    // printf("i=%x, a_tmp=%d, b_tmp=%d, c_tmp=%d\n", i, a_tmp, b_tmp, c_tmp);
    if (a_cnt > 0 && b_cnt > 0 && c_cnt > 0) {
      int tmp_ans = (max(a_cnt, 1) - 1) * 10 + abs(a_tmp) +
                    (max(b_cnt, 1) - 1) * 10 + abs(b_tmp) +
                    (max(c_cnt, 1) - 1) * 10 + abs(c_tmp);
      // printf("hit: tmp_ans=%d\n", tmp_ans);
      // if (ans > tmp_ans) {
      //   printf("i=%x, tmp_ans=%d\n", i, tmp_ans);
      // }
      ans = min(ans, tmp_ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool solve(){
    int A,B,C,N,t[1000][3],r[1000];
    cin>>A>>B>>C;
    if(A==0&&B==0&&C==0)return false;
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>t[i][j];
            t[i][j]--;
        }
        cin>>r[i];
    }

    int S[1000]={0};
    for(int _=0;_<N;_++){
        for(int i=0;i<N;i++){
            if(r[i]){
                for(int j=0;j<3;j++){
                    S[t[i][j]]=1;
                }
            }
            else{
                int sum=0;
                for(int j=0;j<3;j++){
                    if(S[t[i][j]]==1)sum++;
                }
                if(sum!=2)continue;
                for(int j=0;j<3;j++){
                    if(S[t[i][j]]!=1)S[t[i][j]]=-1;
                }
            }
        }
    }

    for(int i=0;i<A+B+C;i++){
        if(S[i]==-1)cout<<0<<endl;
        else if(S[i])cout<<1<<endl;
        else cout<<2<<endl;
    }
    return true;
}

int main(){
    while(solve());
}

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

int main(){
	int x, n, a;
	cin >> x >> n;
	
	unordered_set<int> uns;
	for ( int i = 0 ; i < n; i++ ){
		cin >> a;
		uns.emplace(a);
	}
	
	int y = x, less = y--;
	while ( uns.find(less) != uns.end() ){
		less--;
	}
	
	y = x;
	int bigger = y;
	while ( uns.find(bigger) != uns.end() ){
		bigger++;
	}
	
//	cout << less << " " << bigger << endl; 

	if ( abs(x - less) == abs(x - bigger) )
		cout << less << endl;
	else if ( abs(x - less) < abs(x - bigger))
		cout << less << endl;
	else
		cout << bigger << endl;
	
	return 0;
}

Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,n;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&n);
	e=min(min(8*a,4*b),min(2*c,d));
	f=min(min(4*a,2*b),c);
	if(n&1)printf("%lld\n",(long long)(n-1)/2*e+(n&1)*f);
	else printf("%lld\n",(long long)(n+1)/2*e);
	return 0;
}

Measured memory_bytes: 256
import heapq
N = int(input())
L = []
edge = [[] for i in range(N)]
for i in range(N-1):
  x,y,z = map(int,input().split())
  edge[x-1].append([x-1,y-1,z])
  edge[y-1].append([x-1,y-1,z])
ans = ['TBD']*N
ans[0] = 0
edgelist = []
for i in edge[0]:
  heapq.heappush(edgelist,i)
while len(edgelist) != 0:
  ed = heapq.heappop(edgelist)
  if ans[ed[1]] == 'TBD':
    if ed[2]%2 == 0:
      if ans[ed[0]] == 0:
        ans[ed[1]] = 0
      else:
        ans[ed[1]] = 1
    else:
      if ans[ed[0]] == 0:
        ans[ed[1]] = 1
      else:
        ans[ed[1]] = 0
    for e in edge[ed[1]]:
      if ans[e[1]] == 'TBD':
        heapq.heappush(edgelist,e)
      elif ans[e[0]] == 'TBD':
        heapq.heappush(edgelist,e)
  elif ans[ed[0]] == 'TBD':
    if ed[2]%2 == 0:
      if ans[ed[1]] == 0:
        ans[ed[0]] = 0
      else:
        ans[ed[0]] = 1
    else:
      if ans[ed[1]] == 0:
        ans[ed[0]] = 1
      else:
        ans[ed[0]] = 0
    for e in edge[ed[0]]:
      if ans[e[1]] == 'TBD':
        heapq.heappush(edgelist,e)
      elif ans[e[0]] == 'TBD':
        heapq.heappush(edgelist,e)
for i in range(N):
  print(ans[i])

Measured memory_bytes: 51416
s = input().split()

stack = []

for a in s:
    if a == '+':
        stack.append(stack.pop() + stack.pop())
    elif a == '-':
        stack.append(-(stack.pop() - stack.pop()))
    elif a == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(a))

print(stack[0])

Measured memory_bytes: 7700
n=int(input())
dic={}
cnt=1
s=[input() for i in range(n)]
for i in s:
    if i in dic:
        dic[i]+=1
        cnt=max(cnt,dic[i])
    else:
        dic[i]=1
ans=[]
for i in s:
    if dic[i]==cnt:
        ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 169200
//
//  main.cpp
//  AtCoderD
//
//  Created by Shivam on 19/09/20.
//  Copyright © 2020 Shivam. All rights reserved.
//

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<climits>
#include<cmath>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<list>
using namespace std;
//#define x first
//#define y second
#define mp make_pair
#define endl "\n"
typedef long long ll;
int mod=998244353;
ll next(ll a,ll m) {
    return (a*a)%m;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,m;
    cin>>n>>x>>m;
    set<ll> s;
    ll sum=x;
    for(int i=1;i<n;++i) {
        x=next(x,m);
        if(x==0)
            break;
        else if(s.count(x)==0) {
            s.insert(x);
            sum+=x;
        }
        else {
            ll y=next(x,m);
            int len=1;
            ll msum=x;
            while(y!=x){
                msum+=y;
                y=next(y,m);
                len++;
            }
            ll quo,rem;
            quo=(n-i)/len;
            rem=(n-i)%len;
            sum+=msum*quo;
            while(rem--) {
                sum+=x;
                x=next(x,m);
            }
            break;
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5952
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

const int MAXN = 113;
const int MAXW = 1e5 + 13;

ll w[MAXN], v[MAXN], dp[2][MAXW], N, W;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    memset(dp, 0, sizeof dp);

    cin >> N >> W;
    for(int i = 1; i <= N; ++i) cin >> w[i] >> v[i];

    for(int i = 1, d = 1; i <= N; ++i, d = 1-d){
        for(int j = 1; j <= W; ++j){
            if(w[i] <= j) dp[d][j] = max(dp[1-d][j], dp[1-d][j-w[i]] + v[i]);
            else dp[d][j] = dp[1-d][j];
        }
    }
    cout << max(dp[0][W], dp[1][W]) << endl;

    return 0;
}

//cikisir



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    vl a(n);
    VIN(a);

    sort(ALL(a), greater<ll>());

    ll ans=a[0];

    FOR(i,2,n){
        int comfort = (i/2);
        //DEBUG2(comfort, a[comfort]);
        ans += a[comfort];
    }

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

Measured memory_bytes: 4696
N = int(input())
a = list(map(int,input().split()))
l,r = 0,1
ans = 0

# a中の区間[l,r)について見ていく
nowx = 0
nows = 0
while True:
    if l == N:
        break
    if r == N+1:
        break
    if nowx^a[r-1] == nows+a[r-1]: # いま条件を満たしていればansに変更を加えてしきりを右側に移す
        nowx ^= a[r-1]
        nows += a[r-1]
        ans += r-l
        r += 1
        #l += 1 ### 2の場合
    elif r == l:
        r += 1
        l += 1
    else:
        nowx ^= a[l]
        nows -= a[l]
        l += 1
        #r += 1 ### 2の場合
print(ans)


Measured memory_bytes: 77772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a>> b;
 if((a-b)>0){
     cout << a-b << endl;
 }else{
     cout << 0 << endl;
 }
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			
			final long times = N / (A + B);
			final long mod = N % (A + B);
			
			System.out.println(times * A + Math.min(mod, A));
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

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

    int32_t l = s.length();
    bool temp = false;
    if (l >= 3) {
        for (int32_t i = 0; i <= l - 3; i++) {
            if (s.at(i) == s.at(i + 1) || s.at(i) == s.at(i + 2) || s.at(i + 1) == s.at(i + 2)) {
                cout << i + 1 << ' ' << i + 3 << endl;
                temp = true;
                break;
            }
        }
        if (!temp) {
            cout << "-1 -1" << endl;
        }
    } else {
        if (s.at(0) == s.at(1)) {
            cout << "1 2" << endl;
        } else {
            cout << "-1 -1" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,q;cin>>n>>k>>q;
    int a[n];
    for(int i=0;i<n;i++)a[i]=0;
    for(int i=0;i<q;i++){
        int x;cin>>x;
        x--;
        a[x]++;
    }
    int boder=q-k;
    for(int i=0;i<n;i++){
        //cout<<a[i]<<endl;
        if(a[i]>boder)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

int main(){

    string s;
    cin >> s;


    if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]){
        cout << "No" << endl;
    }
    else if(s[0] == s[1] && s[2] == s[3]){
        cout << "Yes" << endl;
    }
    else if(s[0] == s[2] && s[1] == s[3]){
        cout << "Yes" << endl;
    }
    else if(s[0] == s[3] && s[1] == s[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main(){

  string S;
  char c;

  cin >> S;

  c = char(S[0]);
  for(int i = 1; i < 4; i++){
    if(c == char(S[i])){
      cout << "Bad" << endl;
      return 0;
    }
    else{
      c = char(S[i]);
    }
  }

  cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

H, W = map(int, input().split())
sx = 0
sy = 0
gx = W-1
gy = H-1
ans = 0
A = [list(i for i in input()) for _ in range(H)]
for j in A:
    ans += j.count(".")
inf = -1
distance = [[inf] * W for _ in range(H)]
queue = []
queue.insert(0, (sy, sx))
distance[sy][sx] = 0
X = 0
while True:
    try:
        y, x = queue.pop()
        # print(y,x)
    except:
        # print("Fail")
        break
    for i in range(4):
        nx = x + (-1, 0, 1, 0)[i]
        ny = y + (0, -1, 0, 1)[i]
        # print("nynx",ny,nx)
        if (0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and A[ny][nx] != '#' and distance[ny][nx] == inf):
            queue.insert(0, (ny, nx))
            distance[ny][nx] = distance[y][x] + 1
            A[ny][nx] = "!"
    # print(queue,"Q")

if distance[H-1][W-1] != inf:
    #print(distance[gy][gx])
    ans -= distance[gy][gx] + 1
    print(ans)
else:
    print(-1)


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

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

const int N = 1e5;

struct point{
	int x,y,id;
	point(int _x = 0, int _y = 0, int _id = 0) : x(_x), y(_y), id(_id){}
}p[N + 5], pp[N + 5];

int n;
int par[N + 5];
int cntx[N + 5], cnty[N + 5];
map < int , bool > visx[N + 5], visy[N + 5];

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

void reset(){
	FOR(i,N+2){
		par[i] = i;
	}
}

bool cmp(point a, point b){
	return a.x < b.x;
}

bool cmp2(point a, point b){
	return a.y < b.y;
}

void getSet(){
	sort(pp+1,pp+n+1,cmp);
	REP(i,1,n-1){
		int u = pp[i].id;
		int v = pp[i+1].id;
		if(p[u].x != p[v].x) continue;
		int pu = find(u);
		int pv = find(v);
		if(pu != pv) par[pu] = pv;
	}
	sort(pp+1,pp+n+1,cmp2);
	REP(i,1,n-1){
		int u = pp[i].id;
		int v = pp[i+1].id;
		if(p[u].y != p[v].y) continue;
		int pu = find(u);
		int pv = find(v);
		if(pu != pv) par[pu] = pv;
	}
}

ll solve(){
	getSet();
	REP(i,1,n){
		int idd = find(i);
		if(!visx[idd][p[i].x]){
			visx[idd][p[i].x] = true;
			cntx[idd]++;
		}
		if(!visy[idd][p[i].y]){
			visy[idd][p[i].y] = true;
			cnty[idd]++;
		}
		
	}
	ll ret = 0;
	REP(i,1,n){
		int idd = find(i);
		if(idd = i){
			ret += (ll)cntx[i] * (ll)cnty[i];
		}
	}
	return ret - n;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	reset();
	cin >> n;
	REP(i,1,n){
		cin >> p[i].x >> p[i].y;
		p[i].id = i;
		pp[i] = p[i];
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 17792
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif // LOCAL
#include <bits/stdc++.h>

#define sz(c) int((c).size())

using namespace std;

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    long long s;
    cin >> s;

    const int x1 = int(1e9);
    const int y2 = int((s + x1 - 1) / x1);

    const long long diff = x1 * 1LL * y2 - s;
    assert(0 <= diff && diff < x1);

    const int x2 = int(diff), y1 = 1;

    assert(x1 * 1LL * y2 - x2 * 1LL * y1 == s);
    cout << 0 << ' ' << 0 << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
}

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

#ifdef LOCAL
    ifstream in ("input.txt");
    ofstream out ("output.txt");
    solve (in, out);

    cout << setprecision (4);
    cout << "clock: " << clock () / (double) CLOCKS_PER_SEC << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


Measured memory_bytes: 256
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+max(a,b)+1)
	f[0], f[a], f[b] = 1, 1, 1
	s = min(a, b)
	for k in range(s, n+1):
		if f[k]: f[a+k] = 1; f[b+k] = 1
	print(n-sum(f[s:n+1]))



Measured memory_bytes: 21144
n = int(input())
ratings = list(map(int, input().split(" ")))
colors = [400*i for i in range(1, 9)]
flags = [False for i in range(8)]
over3200 = 0
for rate in ratings:
    for i, border in enumerate(colors):
        if rate < border:
            flags[i] = True
            break
        elif i == 7:
            over3200 += 1
minAns = 0
for f in flags:
    if f:
        minAns += 1

maxAns = minAns + over3200
if minAns == 0 and over3200 > 0:
    minAns = 1
print(minAns, maxAns)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i,10)rep(j,10)rep(k,10) {
        int now = 0;
        bool ok = false;
        for (int x = now; x < s.size()-2; ++x) {
            if ((s[x]-'0')==i) {
                ok = true;
                now = x;
                break;
            }
        }
        if (!ok) continue;

        ok = false;
        for (int x = now+1; x < s.size()-1; ++x) {
            if ((s[x]-'0')==j) {
                ok = true;
                now = x;
                break;
            }
        }
        if (!ok) continue;

        ok = false;
        for (int x = now+1; x < s.size(); ++x) {
            if ((s[x]-'0')==k) {
                ok = true;
                now = x;
                break;
            }
        }
        if (ok) ++ans;
    }
    cout << ans << endl;

    return 0;
}


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

ans=1000
kabu=0
flag=0

for i in range(n-1):
    if a[i]<a[i+1]:
        if flag <=0:
            kabu=int(ans/a[i])
            ans-=(kabu*a[i])
            #print(a[i],ans,kabu)
        flag=1
    elif a[i]>a[i+1]:
        if flag >0:
            ans+=(kabu*a[i])
            #print(ans)
        flag=-1
    else:
        if flag>0:
            flag=2
        else:
            flag=-2
    if i==(n-2) and flag>0:
        ans+=(kabu*a[i+1])
        #print(a[i+1],ans)

print(ans)

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

#define  loop(i,m,n)      for(int i=m;i<n;i++)
#define  rloop(i,m,n)     for(int i=m;i>=n;i--)
#define  mod              1000000007                    
#define  mp(x,y)          make_pair(x,y)
#define  Push(x)          push_back(x)
#define  F                first
#define  S                second

typedef  vector<int>      vi;
typedef  pair<int,int>    pi;
typedef  map<int,int>     mi;
typedef  long long        ll;

int main(){
    ll n,d;
    cin>>n>>d;
    ll a[n],b[n];
    loop(i,0,n) cin>>a[i]>>b[i];
    ll res=0;
    loop(i,0,n){
        ll t1=a[i]*a[i],t2=b[i]*b[i];
        long double x=sqrtl(t1+t2);
        if(x<=d) res++;
    }
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 6740
#include<stdio.h>
int main(){
  int n,i,a=0,b=0,sum;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  for(i=0;i<n;i++){
    if(s[i] == '.')
      a++;
  }

  sum = a;

  for(i=0;i<n;i++){
    if(s[i] == '#')
      b++;
    if(s[i] == '.')
      a--;
    if(a+b < sum)
      sum = a+b;
  }

    printf("%d",sum);
  return 0;
}

Measured memory_bytes: 384
#include <cstring>
#include <iostream>
#include <vector>

#define MODULO 998244353

using namespace std;

long long moveCountCache[200001] = {0, 1};
long long moveCountSumCache[200001] = {0, 1};

int main() {
    int n;
    int k;

    cin >> n >> k;

    vector<pair<int, int>> moveSegments(k);

    for (int i = 0; i < k; i++) {
        cin >> moveSegments[i].first >> moveSegments[i].second;
    }

    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            int leftEndIndex = max(i - moveSegments[j].second, 1);
            int rightEndIndex = i - moveSegments[j].first;

            if (rightEndIndex < 0) continue;

            moveCountCache[i] += moveCountSumCache[rightEndIndex] - moveCountSumCache[leftEndIndex - 1];
            moveCountCache[i] %= MODULO;
        }

        moveCountSumCache[i] = moveCountSumCache[i - 1] + moveCountCache[i];
    }

    cout << moveCountCache[n] << endl;

    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    bool flag = true;
    int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') {
                int cnt = 0;
                rep(k, 4) {
                    int ny = i + dy[k], nx = j + dx[k];
                    if(ny>=0&&ny<H&&nx>=0&&nx<W&&S[ny][nx]=='#')
                        ++cnt;
                }
                if(cnt==0)
                    flag = false;
            }
        }
    }

    flag ? cout << "Yes": cout << "No";
    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(){
  int n;
  string s;
  cin>>n>>s;
  int l = s.size();
  if(l<=n){
    cout<<s<<"\n";
  }else{
    string r = s.substr(0,n);
    r+="...\n";
    cout<<r<<endl;
  }
}

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

public class Main {
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n = in.nextInt();
        String st=""+n;
        char[]arr=st.toCharArray();
        long sum=0;
       for(int i=0;i<st.length();i++){
           sum+=Integer.parseInt(""+arr[i]);
       }
       if(n%sum==0){
           System.out.println("Yes");
       }
else{
           System.out.println("No");
       }
    }
}


class Fast {
    BufferedReader br;
    StringTokenizer st;

    public Fast() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  vector<int> num(4,0);
  for(int i = 0;i < 3;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    num.at(a)++; num.at(b)++;
  }

  for(int i = 0;i < 4;i++) {
    if(num.at(i) == 3) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}



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

int vals[3 * 101 * 1005];
int64_t //maxs[3 * 101 * 1005],
mins[3 * 101 * 1005];

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

   int n;
   while (cin >> n)
   {
      for (int i = 0; i < 3*n; i++)
         cin >> vals[i];

      int64_t ans = numeric_limits<int64_t>::min(), sum =0, sum2=0;

      map<int, int> m, m2;
      {//min
         for (int i = 2*n; i < 3*n; i++) {
            m2[vals[i]]++; sum2 += vals[i];
         }
         mins[2*n] = sum2;

         for (int ri_exc = 2*n-1; n <= ri_exc; --ri_exc)
         {
            auto itma = m2.end(); --itma;
            auto delta = vals[ri_exc] - itma->first;
            if (delta < 0)
            {
               sum2 += delta;
               if (0 == (--(itma->second)))
                  m2.erase(itma);

               m2[vals[ri_exc]]++;
            }
            mins[ri_exc] = sum2;
         }
      }
      {//max
         for (int i = 0; i < n; i++) {
            m[vals[i]]++; sum += vals[i];
         }
         //maxs[n - 1] = sum;
         {
            auto cand = sum - mins[n];
            ans = max(ans, cand);
         }
         for (int ri_exc = n; ri_exc < 2 * n; ri_exc++)
         {
            auto itmi = m.begin();
            auto delta = vals[ri_exc] - itmi->first;
            if (0 < delta)
            {
               sum += delta;
               if (0 == (--(itmi->second)))
                  m.erase(itmi);

               m[vals[ri_exc]]++;
            }
            //maxs[ri_exc] = sum;
            auto cand = sum - mins[ri_exc+1];
            ans = max(ans, cand);
         }
      }
      cout << ans << '\n';
   }
   return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

class UnionFind{
    vector<int> pyon, rank;

    int root(int x){
        if(pyon[x] == -1) return x;
        else return pyon[x] = root(pyon[x]);
    }

public:
    UnionFind(int N): pyon(N, -1), rank(N, 1){}

    void merge(int x, int y){
        int rx = root(x), ry = root(y);
        if(rank[rx] < rank[ry]){
            pyon[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            pyon[rx] = ry;
            rank[y]++;
        }else{
            pyon[ry] = rx;
        }
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }
};


pair<long,int> xp[100010], yp[100010], dd[200020];

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N;
    scanf("%d",&N);
    times(N, i) {
        long X, Y;
        scanf("%lld%lld",&X,&Y);
        xp[i] = {X, i};
        yp[i] = {Y, i};
    }
    sort(xp, xp+N);
    sort(yp, yp+N);
    times(N-1, i) {
        dd[i*2]   = {xp[i+1].first - xp[i].first, i*2};
        dd[i*2+1] = {yp[i+1].first - yp[i].first, i*2+1};
    }
    sort(dd, dd+N*2-2);

    if(debug) {
        times(N, i) cout << xp[i].first sp << xp[i].second tb; cout ln;
        times(N, i) cout << yp[i].first sp << yp[i].second tb; cout ln;
        times(N*2-2, i) cout << dd[i].first sp << dd[i].second tb; cout ln;
    }

    long ans = 0;
    UnionFind uf(N);
    times(N*2-2, i) {
        int j = dd[i].second / 2;
        if(dd[i].second % 2 == 0) { // x
            int a = xp[j].second, b = xp[j+1].second;
            if(!uf.isSame(a, b)) {
                uf.merge(a, b);
                ans += dd[i].first;
                if(debug) cout << i tb << 'x' tb << j tb << ans tb << dd[i].first tb << a tb << b ln;
            }
        } else {
            int a = yp[j].second, b = yp[j+1].second;
            if(!uf.isSame(a, b)) {
                uf.merge(a, b);
                ans += dd[i].first;
                if(debug) cout << i tb << 'y' tb << j tb << ans tb << dd[i].first tb << a tb << b ln;
            }
        }
    }

    cout << ans ln;

    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S, T;

int main(){
	cin >> S >> T;
	for (int i = S.size() - T.size(); i >= 0; --i) {
		bool f = true;
		for (int j = 0; j < T.size(); ++j) {
			if (S[i + j] != T[j] && S[i + j] != '?') {
				f = false;
				break;
			}
		}
		if (f) {
			for (int j = 0; j < i; ++j) {
				if (S[j] == '?')cout << 'a';
				else cout << S[j];
			}
			cout << T;
			for (int j = i + T.size(); j < S.size(); ++j) {
				if (S[j] == '?')cout << 'a';
				else cout << S[j];
			}
			cout << endl;
			return 0;
		}
	}
	puts("UNRESTORABLE");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

template<typename T>
class RangeUpdateQuery {
public:
    explicit RangeUpdateQuery(int n, T def) : N(calcN_(n)) {
        mVal.assign(2*N+1, make_pair(-1, def));
    }
    void update(int l, int r, T value, int ts){
        updateImpl_(l, r, make_pair(ts, value), 0, 0, N);
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            res = max(mVal[i], res);
        }
        return res.second;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, pair<int, T> value, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            mVal[idx] = value;
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
        }
    }
    const int N;
    vector<pair<int,T>> mVal;
};

bool valid(const vector<int>& a, const vector<int>& upper){
    const int N = a.size();
    RangeUpdateQuery<int> seg(N, 0);
    for(int i=1;i<a.size();i++){
        if(a[i] <= a[i-1]){
            int c = a[i];
            while(c >= 0){
                int v = seg.get(c);
                if(v == upper[c]-1){
                    seg.update(c, c+1, 0, i);
                    --c;
                } else {
                    seg.update(c, c+1, v+1, i);
                    break;
                }
            }
            if(c < 0) return false;
        } else {
            seg.update(a[i-1]+1, a[i]+1, 0, i);
        }
    }
    return true;
}

long long pow(long long a, long long p){
    if(a == 1) return 1;
    if(p == 0) return 1;
    auto res = pow(a, p/2);
    res *= res;
    if(p%2 == 1) res *= a;
    return min(res, 200000LL);
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    vector<int> v;
    for(auto& t : a){
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    map<int, int> idx;
    for(int i=0;i<v.size();i++) idx[v[i]] = i;
    for(auto& t : a) t = idx[t];
    int L = 0, R = N;
    vector<int> upper(N);
    while(R-L > 1){
        int mid = (L+R)/2;
        upper[0] = pow(mid, v[0]);
        for(int i=1;i<N;i++) upper[i] = pow(mid, v[i]-v[i-1]);
        if(valid(a, upper)) R = mid;
        else L = mid;
    }
    cout << R << endl;
}

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

using namespace std;

typedef vector<int> vi;

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

	vector<bool> seen(n);
	vector<vi> adj(n);

	int x, y;

	for (int i = 0; i < m; ++i){
		cin >> x >> y;
		x--; y--;

		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	seen[x] = seen[y] = true;

	vi path;
	bool change = true;

	while (change){
		path.push_back( x );
		change = false;

		for (auto u : adj[x])
			if (!seen[u]){
				seen[u] = true;
				x = u;
				change = true;
				break;
			}
	}

	change = true;

	reverse(path.begin(), path.end());

	while (change){
		path.push_back(y);
		change = false;

		for (auto u : adj[y])
			if (!seen[u]){
				seen[u] = change = true;
				y = u;
				break;
			}
	}

	cout << path.size() << endl;

	for (auto u : path)
		cout << u + 1 << " ";

	cout << endl;

}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++){
        int tmp = (i%10) + ((i%100)/10) + ((i%1000)/100) + ((i%10000)/1000) + (i/10000);
        if(tmp >= A && tmp <= B ){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	char sinp[2048] = {0};
	int n=0,s=0,w=0,e=0,i;
	scanf("%s",sinp);
	for(i=0;i<=2047;i++){
		if(sinp[i]=='N'){n=1;}
		if(sinp[i]=='S'){s=1;}
		if(sinp[i]=='W'){w=1;}
		if(sinp[i]=='E'){e=1;}
		if(sinp[i]=='\0'){break;}
	}
	if((n+s == 0 || n+s == 2) && (w+e == 0 || w+e == 2)){printf("Yes\n");}
	else{printf("No\n");}
	return 0;
}

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

typedef long long LL;

const int N=200000;

int n,m,a[N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int sta[N+9],cst;
int pre[N+9],suf[N+9],spre[N+9],ssuf[N+9];
LL ans;

void Get_ans0(){
  int now=sta[cst],cnt=0;
  for (;cst&&sta[cst]==now;--cst) ++cnt;
  if (cnt<m){
	for (;cst;) Get_ans0();
	return;
  }
  int c=cnt/m;
  for (int i=1;i<=cnt;++i) spre[i]=spre[i-1]+pre[i+cst],ssuf[i]=ssuf[i-1]+suf[i+cst];
  for (int i=m;i<=cnt;++i) ans+=(LL)spre[i-m+1]*suf[i+cst];
  for (int i=1;i<=c;++i){
	pre[i+cst]=spre[cnt-m*(c-i+1)+1]-spre[max(cnt-m*(c-i+2)+1,0)];
	suf[i+cst]=ssuf[min(m*(i+1)-1,cnt)]-ssuf[m*i-1];
  }
  for (int i=m,s=0;i<=c;++i) ans-=(LL)(s+=pre[cst+i-m+1])*suf[i+cst];
  for (int i=1;i<=c;++i) sta[++cst]=now+1;
}

void Get_ans(){
  for (int i=1;i<=n;++i){
	for (;cst&&sta[cst]<a[i];) Get_ans0();
	sta[++cst]=a[i];
	pre[cst]=suf[cst]=1;
  }
  for (;cst;) Get_ans0();
}

void work(){
  Get_ans();
}

void outo(){
  printf("%lld\n",ans+n);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 7184
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>bool chmax(T &a, const T &b);
template <class T>bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t,std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &&i : a)
  {
    cin >> i;
  }

  sort(all(a));

  std::cout << a[n - 1] - a[0] << std::endl;

  return;
}

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

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 (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }
  
  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if(n % i == 0){
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }
  
  return res;
}

Measured memory_bytes: 256
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
plus=0;minus=0;co=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
        if c%2==1:
            co+=1
    elif c > 0:
        plus+=c

print("Yes" if minus >= plus*2+co else "No")


Measured memory_bytes: 4596
//
//  main.cpp
//  dictionary
//
//  Created by ???????????? on 2017/10/06.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstring>
#include <stdio.h>


#define NIL (0)

using namespace std;

int m = 1000207;

int char_to_int(char str){
    if(str == 'A'){
        return 1;
    }
    else if(str == 'C'){
        return 2;
    }
    else if(str == 'G'){
        return 3;
    }
    else if(str == 'T'){
        return 4;
    }
    cout << "Unexpected input given" << endl;
    return 0;
}

long long get_key(char string[]){
    long long key_str = 0, p = 1;
    size_t n = strlen(string);
    for (int i = 0; i < n; i++){
        key_str += p*char_to_int(string[i]);
        p *= 5;
    }
    return key_str;
}

int h1(int key){
    return key % m;
}

int h2(int key){
    return 1+(key % (m-1));
}

int h(int key, int i){
    return (h1(key) + i*h2(key)) % m;
}

void insert(int T[], int key){
    int i = 0;
    while(true){
        int j = h(key, i);
        if (T[j] == NIL){
            T[j] = key;
            break;
        }
        else{
            i++;
        }
    }
}

bool search(int T[], int key){
    int i = 0;
    while(true){
        int j = h(key, i);
        if(T[j] == key){
            return true;
        }
        else if(T[j] == NIL || i > m){
            return false;
        }
        else{
            i++;
        }
    }
}

int main(int argc, const char * argv[]) {
    int n, i;
    long long key;
    char com[10], string[10];
    int T[m];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, string);
        key = get_key(string);
        if(com[0] == 'i'){
            insert(T, key);
        }
        else if(com[0] == 'f'){
            if(search(T, key)){
                cout<<"yes"<<endl;
            }
            else{
                cout<<"no"<<endl;
            }
        }
        else{
            cout << "Got unexpected command" << endl;
        }
    }
    
    
    
    return 0;
}

Measured memory_bytes: 7048
#include<stdio.h>
int main()
{
int a,b;
long int c;
  scanf("%d %d %ld",&a,&b,&c);
  for(int i=0;i<10;i++)
  {
    c=a*c-b;
   printf("%ld",c);
     printf("\n");
  }
  return 0;
}

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


using namespace std;

int main(){
    string str;
    int a, b;
    bool is = true;
    cin >> a >> b;
    cin >>str;
    if(str[a] != '-') is = false;
    for(int i = 0; i < a + b  + 1; i++)
        if(!isdigit(str[i]) && i != a) is = false;
    if(is) cout << "Yes" << endl;
    else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool isValid(string s){
  if(s.size() == 1) return true;
  if(s[0] != '0' && stoi(s) <= 255) return true;
  return false;
}

int main(){
  string s;
  int ans = 0;
  
  cin >> s;

  for(int i=1;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      for(int k=j+1;k<s.size();k++){
        // [0,i), [i,j), [j,k), [k,n)

        bool f = true;
        f &= isValid(s.substr(0,i));
        f &= isValid(s.substr(i,j-i));
        f &= isValid(s.substr(j,k-j));
        f &= isValid(s.substr(k,s.size()-k));        

        ans += f;
      }
    }
  }
  

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



Measured memory_bytes: 3204