akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();
		if((n-1)*(n-2)/2 < k) {
	        out.println(-1);
	        out.flush();
			return;
		}
		
		int s=(n-1)*(n-2)/2;
	    out.println(n-1+s-k);
		for (int i = 1; i <= n-1 ; i++) {
	        out.println(1+" "+(i+1));			
		}
//		db(s);
		
		lp:
		for (int i = 2; i < n ; i++) {
			for (int t = i+1; t <= n; t++) {
		        if(s==k)break lp;
		        s--;
		        out.println(i+" "+t);
			}
		}
//        out.println();
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return b-p.b;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n, temp, tarosP = 0, hanakosP = 0;
		String taro, hanako;
		
		// input
		n = scan.nextInt();
		
		// loop
		for (int i = 0; i < n; i++) {
			taro = scan.next(); hanako = scan.next();
			temp = taro.compareTo(hanako);
			if (temp > 0) tarosP += 3;
			else if (temp < 0) hanakosP += 3;
			else {
				tarosP++; hanakosP++;
			}
		}
		
		// output
		System.out.println(tarosP + " " + hanakosP);
	}
}



Measured memory_bytes: 29672
#include<iostream>
#include<cstdio>
#include<complex>
using namespace std;
typedef complex<long long> xy_t;

int s_check(xy_t a, xy_t b, xy_t x, xy_t y) {
	long long s, t;
	long long x1 = a.real(), y1 = a.imag(),
		x2 = b.real(), y2 = b.imag();
	s = (y2 - y1)*x.real() - (x2 - x1)*x.imag() - x1*y2 + x2*y1;
	t = (y2 - y1)*y.real() - (x2 - x1)*y.imag() - x1*y2 + x2*y1;
	if ((s > 0 && t > 0) || (s < 0 && t < 0)) return 0;
	if ((s > 0 && t < 0) || (s < 0 && t > 0)) return 2;
	return 1;
}
int check(xy_t a, xy_t b, xy_t x, xy_t y) {
	if (s_check(a, b, x, y)) {
		return s_check(x, y, a, b);
	}
	return 0;
}

int main() {
	int n,q;
	long long x, y;
	xy_t p[103], pp, pp2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		p[i] = xy_t(x, y);
	}
	for (cin >> q; q > 0; q--) {
		int s = 0;
		cin >> x >> y;
		pp = xy_t(x, y);
		pp2 = xy_t(x + 20011, y + 1);
		for (int i = 0; i < n; i++) {
			int c = check(pp, pp2, p[i], p[(i == n - 1 ? 0 : i + 1)]);
			if (c == 0) continue;
			if (c == 1) {
				cout << 1 << endl;
				goto next_query;
			}
			s++;
		}
		if (s & 1)
			cout << 2 << endl;
		else
			cout << 0 << endl;
	next_query:
		;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
using namespace std;
 
int main(){
    string S1, S2;
    cin >> S1 >> S2;
    if(S1[0] == S2[2] && S1[2] == S2[0] && S1[1] == S2[1]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 768
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int s = n % 2;
		int t;
		if (s == 0)
			t = n;
		else
			t = 2 * n;

		System.out.println(t);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = a * a;
    int c = b * a;
    System.out.println(a + b + c);
  }
}


Measured memory_bytes: 35636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

 private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1);

 private String inputData = null;

 private String[] data;

 private int[] values;

 public static void main(String args[]) {
  new Main().start();
 }

 public void start() {
  try {
   this.inputData = reader.readLine();
  } catch (IOException e) {
   e.printStackTrace();
  }

  this.data = this.inputData.split(" ");
  this.values = new int[this.data.length];
  for (int i = 0; i < this.data.length; i++) {
   this.values[i] = Integer.parseInt(this.data[i]);
  }

  Arrays.sort(this.values);

  for (int i = 0; i < this.values.length-1; i++) {
   System.out.print(this.values[i] + " ");
  }
  System.out.println(this.values[this.values.length-1]);
 }

}

Measured memory_bytes: 17076
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Map
import scala.collection.mutable.Queue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt

  var ans = List((1, 2), (2, N+3), (3, 1), (N+2, 3), (N+1, N+2))
  if (N <= 2)
    println("No")
  else {
    for (i <- 4 until N by 2) {
      ans = (i, 1) :: (N+i+1, i) :: (i+1, 1) :: (N+i, i+1) :: ans
    }

    var flag = false
    if (N % 2 == 0) {
      breakable {
        for (i <- 2 to N-1 if (i ^ (N+1)) < N) {
          ans = (i, N) :: (i ^ (N+1), N+N) :: ans
          flag = true
          break
        }
      }
    }
    else
      flag = true

    if(flag) {
      pw.println("Yes")
      ans.foreach { case (a, b) => pw.println(s"$a $b") }
    }
    else
      pw.println("No")

    pw.flush()
  }

}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	ll a[n], b[n];
	ll ans = 0;
	REP(i, n){
		cin >> a[i] >> b[i];
		ans += a[i];
	}
	ll dif[n];
	REP(i, n) dif[i] = a[i]+b[i];
	sort(dif, dif+n);
	REP(i, n){
		if(i%2 == 1) ans -= dif[n-1-i];
	}
	cout << ans << endl;
} 

Measured memory_bytes: 2560
#include<stdio.h>
int main(void) {
	int N,X,Y,Z,k,a[100],b[100],c[100],sum=0;
	scanf("%d", &N);
	scanf("%d", &X);
	for (int i = 0; i < X; i++) {
		scanf("%d", &a[i]);
	}
	scanf("%d", &Y);
	for (int i = 0; i < Y; i++) {
		scanf("%d", &b[i]);
	}
	scanf("%d", &Z);
	for (int i = 0; i < Z; i++) {
		scanf("%d", &c[i]);
	}
	for (int j = 0; j < Z; j++) {
		for ( k = 0; k < X; k++) {
			if (c[j] == a[k]) {
				break;
			}
		}
		if (k == X) {
			c[j] = N + 1;
			sum++;
		}
		for ( k = 0; k < Y; k++) {
			if (c[j] == b[k]) {
				sum++;
				break;
			}
		}
	}
	printf("%d\n", sum);
	return 0;
}


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

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

	long long x;
	cin >> x;

	long long res = 0;

	res += (x / 500) * 1000;
	x = x % 500;
	res += (x / 5) * 5;

	cout << res;

	return 0;
}



Measured memory_bytes: 256
X, N = map(int, input().split())
P = list(map(int, input().split()))
sub_min = 100
P_bar = [x for x in range(102)]

for p in P:  
    P_bar.remove(p)

for p_bar in P_bar:
    sub = abs(X - p_bar)
    if sub < sub_min:
        sub_min = sub
        answer = p_bar

print(answer)

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

int main() {
  int n;
  cin >> n;
  
  char s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == 'Y') {
      cout << "Four" << endl;
      break;
    }
  }
  
  if (s != 'Y') {
    cout << "Three" << endl;
  }
}

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

using namespace std;

main(){
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < (int)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;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
double d,x;

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>d>>x;
	double sum=0;
	rep(i,2*n){
		sum+=d+i*x;
	}
	double p1=0,p2=0;
	repl(i,1,n+1){
		double ii=i;
		p2=1/(2*ii)+((ii-1)/ii)*(1+1/ii)*p1;
		p1=p2;
	}
	printf("%.15f\n", sum*p2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int n,m;
    cin>>n>>m;
    cout<<n*n-m<<endl;
    return 0;
}


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

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

    int A[n][m];
    int b[m];
    int c[n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int j = 0; j < m; j++) {
        cin >> b[j];
    }

    for (int i = 0; i < n; i++) {
        c[i] = 0;
        for (int j = 0; j < m; j++) {
            c[i] += A[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
}



Measured memory_bytes: 3128
s=str(input())
head = s[:2]
tail = s[2:]

yymm = False
mmyy = False

if (int(tail)>0)&(int(tail)<=12):
    yymm = True

if (int(head)>0)&(int(head)<=12):
    mmyy = True
    
if (yymm == True)&(mmyy == True):
    print("AMBIGUOUS")
elif (yymm == True):
    print("YYMM")
elif (mmyy == True):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 38256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		long ans;
		ans=N/3;

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
import sys

#@profile
def max_heapify(A, i):
    j = i
    largest = i
    H = len(A) -1
    while True:
        l = j * 2
        r = l + 1
        if l <= H and A[l] > A[j]:
            largest = l
        if r <= H and A[r] > A[largest]:
            largest = r
        if largest != j:
            A[j], A[largest] = A[largest], A[j]
            #max_heapify(A, largest)
            j = largest
            
        else:
            break
        

#@profile
def build_max_heap(A):
    i = len(A)-1
    last = A[i]
    parent = i//2
    while  parent > 0 and A[parent] < last:
        A[i] = A[parent]
        i = parent
        parent = i //2
    A[i] = last

#@profile
def extract(A):
    print(A[1])
    A[1] = A[-1]
    del A[-1]
    max_heapify(A, 1)
    
A = [0]

#@profile
def main():
    out = ""
    for l in sys.stdin.readlines():
        if l[0] == "i":
            #insert k
            A.append(int(l[7:]))
            build_max_heap(A)
        #print(A)
        elif l[1] == "n":
            #end
            print(out, end = "")
            return
        else:
            if len(A) <= 1:
                pass
            elif len(A) == 2:
                out += str(A.pop()) + "\n"
                #print(A.pop())
            #extract(A)
            else:
                out += str(A[1]) + "\n"
                A[1] = A.pop()
                max_heapify(A, 1)
                
if __name__ == "__main__":
    main()

Measured memory_bytes: 194040
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 998244353;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 3e5 + 20;
ll ans, fac[N], n, a, b, k;

ll powmod(ll x, ll y, ll MODD = MOD) {
    if (y == 0) return 1LL;
    ll tmp = powmod(x, y / 2, MODD);
    tmp = sqr(tmp) % MODD;
    return (tmp * (y % 2 ? (x % MODD) : 1LL)) % MODD;
}

ll divmod(ll x, ll y, ll MODD = MOD) {
	return ((x % MODD) * powmod(y, MODD - 2, MODD)) % MODD;
}

ll CR(ll r, ll n, ll MODD = MOD) {
    return divmod(fac[n], (fac[r] * fac[n - r]) % MODD, MODD);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	fac[0] = 1;
	for (ll i = 1; i < N; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	cin >> n >> a >> b >> k;
	for (ll x = 0; x <= n; x++) {
		if (k >= x * a && (k - x * a) % b == 0) {
			ll y = (k - x * a) / b;
			if (y > n) continue;
			ans = (ans + CR(y, n) * CR(x, n)) % MOD;
		}
	}
	cout << ans << endl;
}








































Measured memory_bytes: 2560
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int[] array2 = new int[n];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt() - (i + 1);
            array2[i] = array[i];
        }
        Arrays.sort(array2);
        for (int i = 0; i < n; i++) {
            ans += Math.abs(array[i] - array2[n / 2]);
        }
        System.out.println(ans);
    }    
}


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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main(){
    int n,k;cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    vector<mint> cntmin(n),cntmax(n);
    combination c(100005);
    rep(i,n){
        if(i<=n-k)cntmin[i]=c(n-i-1,k-1);
        if(i>=k-1)cntmax[i] = c(i,k-1);
    }
    mint ans = 0;
    rep(i,n){
        ans += (cntmax[i]-cntmin[i])*mint(a[i]);
    }

    cout << ans << endl;
    //rep(i,n) printf("%d %d\n",cntmin[i],cntmax[i]);
    

}


Measured memory_bytes: 6568
from itertools import accumulate
n = int(input())
As  = list(map(int, input().split()))

# ノードが1個しかないとき
if n == 0:
    if As[0] == 1:print(1)
    else:print(-1)
    exit()
    
# 深さが2以上のとき、初め0ならアウト
if As[0] != 0:
    print(-1)
    exit()    

acc_r = list(accumulate(As[::-1]))
acc_r = acc_r[::-1]
# 一個ずれる
acc = acc_r[1:] + [acc_r[-1]]
p = 1
ans = 1
for s, a in zip(acc,As):
    p = min((p-a)*2, s)
    if p < 0:
        print(-1)
        exit()
    ans += p
print(ans)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    vector<int> data(5);
    for (int i = 0; i < 5; i++) {
        cin >> data[i];
    }

    int ans = INF;
    sort(all(data));

    do {
        int t = 0;
        rep(i, data.size()-1) {
            t += data[i];
            while (t % 10) t++;
        }
        ans = min(ans, t + data.back());
    } while (next_permutation(all(data)));

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

    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {


  val rn = StdIn.readLine().trim.toInt
  val ina = StdIn.readLine().trim.split(' ').map(_.toInt)
  
  final val infity = Int.MaxValue
  def mergeSort(): Long = {
    @inline def copyToArray(start: Int, end: Int): Array[Int] = {
      val alsize = end - start + 1
      val temp = new Array[Int](alsize)
      Array.copy(ina, start, temp, 0, alsize - 1)
      temp(alsize-1) = infity
      temp
    }

    def merge(left: Int, mid: Int, right: Int): Long ={
      val al = copyToArray(left, mid)
      val ar = copyToArray(mid, right)
      var i = 0
      var j = 0
      var cnt = 0L
      //println("left:" + al.toList)
      //println("right:" + ar.toList)
      (left until right).foreach{ k =>
        if(al(i) <= ar(j)){
          ina(k) = al(i)
          i += 1
        } else {
          ina(k) = ar(j)
          j += 1
          cnt += mid - left - i
        }
      }
      //println("all:" + ar2.toList.mkString(" "))
      cnt
    }

    def innerMergeSort(left: Int, right: Int): Long ={
      
      if(left+1 < right){
        val mid = (left + right) / 2
        val rleft = innerMergeSort(left, mid)
        val rright = innerMergeSort(mid, right)
        val rmerge = merge(left, mid, right)
        
        rleft + rright + rmerge
      } else {
        0L
      }
    }

    innerMergeSort(0, rn)

  }
  
  println(mergeSort)

  
}




Measured memory_bytes: 120940
#include <iostream>
#include <vector>
using namespace std;
int arr[1005];
long long s[2];
vector<int> v;
int main()
{
	int n,mx=0;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		s[i%2]+=max(arr[i],0);
		if (arr[i]>arr[mx])
		mx=i;
	}
	int st=0;
	if (s[1]>s[0])
	st++;
	n--;
	if (arr[mx]<=0)
	{
		printf("%d\n%d",arr[mx],n);
		while (n!=mx)
		printf("\n%d",(n--)+1);
		while (mx--)
		printf("\n1");
		return 0;
	}
	printf("%lld\n",s[st]);
	while (n%2!=st || arr[n]<=0)
	{
		v.push_back(n);
		n--;
	}
	for (;n!=st;n-=2)
	{
		if (arr[n-2]<=0)
		{
			v.push_back(n-2);
			if (n==2)
			v.push_back(0);
		}
		else
		v.push_back(n-1);
	}
	if (st==1)
	v.push_back(0);
	printf("%d",v.size());
	for (int i:v)
	printf("\n%d",i+1);
}


Measured memory_bytes: 3764
import java.util.*;
import java.io.*;
public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		
		Scanner in = new Scanner(System.in);
		
		
		int[]arr = new int[3];
		String empty = "";
		for(int i = 0; i < arr.length; i++)
		{
			arr[i] = in.nextInt();
			empty += arr[i];
		}
			
		int num = Integer.parseInt(empty);
			
		if(num % 4 == 0) {
				System.out.println("YES");
				//System.out.println(num + " is a multiple of 4, and thus YES should be printed.");
			}
		else {
				System.out.println("NO");
				//System.out.println(num + " is not a multiple of 4, and thus NO should be printed.");
			}
				
		}
		
		
		

	}




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

int main()
{
    string s;
    int o = 0, z = 0;
    cin >> s;
    for (auto c : s)
    {
        if (c == '1')
            o++;
        else
            z++;
    }
    cout << min(o, z) * 2 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
int main(){
	int W,H,x,y,r,i[5];
	char c,suuti[5][20];
	int a,b;
	for( a = 0;a < 5;a++){

		for( b = 0;b < 19 && (c =getchar()) != ' ' && c != '\n';b++){
			suuti[a][b] = c;
		}suuti[a][b] = 0;
		i[a] = atoi(suuti[a]);
	}suuti[a][b] = 0;
	W = i[0];
	H = i[1];
	x = i[2];
	y = i[3];
	r = i[4];
	if(r <= W-x && r <= x && r <= H-y && r <= y){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    int cnt = 1;
    for(int i = 2; i < 1000003; i++){
        if(g%i!=0) continue;
        cnt++;
        while(g%i == 0)g /= i;
    }
    if(g > 1)cnt++;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
import numpy as np

n, m, c = map(int, input().split(' '))
b = np.array(list(map(int, input().split(' '))))
cnt = 0
for _ in range(n):
    a = np.array(list(map(int, input().split(' '))))
    if a.dot(b) + c > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12504
# coding: utf-8
# Your code here!
def ren(a,b,c,d,e,f):
    x=(c*e-f*b)/(a*e-b*d)
    y=(c*d-f*a)/(b*d-e*a)
    
    print(f'{x+0:.3f} {y+0:.3f}')

while True:
    try:
        a,b,c,d,e,f=map(int,input().split())
    except EOFError:
        break
    ren(a,b,c,d,e,f)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;



int main(void) {
  ll N, K;
  cin >> N >> K;
  ll i;
  
  
  ll id=0, min=INF;
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
  }
  
  pt((N-1+K-2)/(K-1));
  
}






Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int main()
{
	int n; cin >> n;
	ll s = 0;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
		s += a[i];
	}
	for (int i = 1; i < n; i += 2)s -= 2 * a[i];
	rep(i, n)
	{
		cout << s << " ";
		s = 2 * a[i] - s;
	}
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3] = {0};
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a,a+3);
    for(int i=0;i<k;i++) a[2]*=2;
    int sum = a[0] + a[1] + a[2];
    cout << sum << endl;
}

Measured memory_bytes: 256
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(l)
  (let ((ll (/ l 3)))
    (* ll ll ll)))
(let ((line (parse-integer (read-line nil nil))))
  (format t "~,7F~%" (f line)))


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

using namespace std;


int main(){

  string s, strc;

  while(getline(cin,s)){

    for(int j=0;j<26;j++){
      

      if(s.find("the")!=string::npos ||s.find("this")!=string::npos||s.find("that")!=string::npos ){
	cout << s << endl;
      }
      for(int i=0;i<s.size();i++){//size()ツづ債閉カツ篠堋療アツづ個陳キツつウツづーツ陛板つキ
	
	if(s[i]=='z')s[i]='a';
	else if(s[i]>='a'&&s[i]<='z')s[i]++;
      }

    }

  }
  

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int A, B;

int main(void){
        scanf("%d%d", &A, &B);
        if(0<=A&&A<=100&&2<=B&&B<=1000){
            if(13 <= A){
                printf("%d\n",B);
            }else if(6<=A&&A<=12){
                printf("%d\n",B/2);
            }else if(A<=5){
                printf("0\n");
            }
        }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1000000007;
int main() {
    string s;
    cin>>s;
    if(!s.compare("Sunny"))cout<<"Cloudy"<<endl;
    if(!s.compare("Cloudy"))cout<<"Rainy"<<endl;
    if(!s.compare("Rainy"))cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;
int n, dp[2][5050][2],t[10000];
int main() {
    scanf("%d",&n);
    for (int i=0; i<n-1; i++) {
        scanf("%d",&t[i]);
    }
    for (int i=0; i<2; i++) for (int j=0; j<5050; j++) for (int k=0; k<2; k++) dp[i][j][k]=INT_MAX/2;
    dp[0][0][0]=0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<=min(5009,i); j++) {
            dp[(i+1)&1][j+1][0]=min(dp[i&1][j][0], dp[i&1][j][1]+t[i]);
            dp[(i+1)&1][j][1]=min(dp[i&1][j][0]+t[i], dp[i&1][j][1]);
        }
        dp[i&1][0][0]=INT_MAX/2;
    }
    printf("%d\n",dp[n%2][n/2][0]);
}

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

string s, t;
ll dp[3010][3010];
string prev_s[3010][10010];

int main(int argc, char **argv)
{
	cin >> s >> t;
	dp[0][0] = 0;

	for (ll i = 0; i < (int)s.size(); ++i)
	{
		for (ll j = 0; j < (int)t.size(); ++j)
		{
			if (s[i] == t[j]) dp[i+1][j+1] = max({dp[i][j]+1, dp[i+1][j+1]});
			dp[i+1][j+1] = max({dp[i][j+1], dp[i+1][j], dp[i+1][j+1]});
		}
	}

	string res = "";
	ll i = (int)s.size(), j = (int)t.size();
	while (i > 0 && j > 0)
	{
		if (dp[i][j] == dp[i-1][j])
		{
			--i;
		}
		else if(dp[i][j] == dp[i][j-1])
		{
			--j;
		}
		else
		{
			res = s[i-1] + res;
			--i, --j;
		}
	}
	
	std::cout << res << std::endl;
}

Measured memory_bytes: 306176
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<lint,lint> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
pi ps[1005];
void ng(){
  puts("-1");
  exit(0);
}

int main(){
  cin>>n;
  int cnt=0;
  REP(i,n){
    cin>>ps[i].fr>>ps[i].sc;
    if((abs(ps[i].fr)+abs(ps[i].sc))%2!=(abs(ps[0].fr)+abs(ps[0].sc))%2){
      ng();
    }
  }
  vector<lint> d;
  REP(i,32){
    d.pb(1ll<<(i+1));
  }
  lint tot=accumulate(ALL(d),0ll);
  bool type=false;
  if((abs(ps[0].fr)+abs(ps[0].sc))%2==0){
    d.pb(1);d.pb(1);
  }else{
    d.pb(1);
    type=true;
  }
  int m=d.size();
  cout<<d.size()<<endl;
  for(auto e:d) cout<<e<<" ";
  puts("");

  REP(i,n){
    string res(m,' ');
    lint xx=ps[i].fr,yy=ps[i].sc;
    if(abs(yy)&1){
      if(abs(xx+yy-1)%4!=0){
        --yy;
        res[m-1]='U';
      }else{
        ++yy;
        res[m-1]='D';
      }
    }
    if(abs(xx)&1){
      if(abs(xx+yy-1)%4!=0){
        --xx;
        if(type) res[m-1]='R';
        else res[m-2]='R';
      }else{
        ++xx;
        if(type) res[m-1]='L';
        else res[m-2]='L';
      }
    }

    if(!type && res[m-1]==' '){
      if(abs(xx+yy)%4!=0){
        res[m-1]='L';
        res[m-2]='R';
      }else{
        res[m-1]=res[m-2]='L';
        xx+=2;
      }
    }
    dump(xx);dump(yy);

    lint x=(xx+yy),y=(xx-yy);
    x+=tot;
    y+=tot;
    assert(x%4==0);assert(y%4==0);
    dump(x);dump(y);

    int idx=0;
    for(auto e:d) if(e!=1){
      int bit=0;
      if(x&(e*2)) bit|=2;
      if(y&(e*2)) bit|=1;

      string code="LDUR";
      res[idx]=code[bit];
      ++idx;
    }
    cout<<res<<endl;
  }
  return 0;
}





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){

		String str = null;
		BufferedReader br = null;
		br = new BufferedReader(new InputStreamReader(System.in));
		
		for(int i=1;;i++){
			
		
		try {str = br.readLine();} 
		
		catch (IOException e) {e.printStackTrace();}
		
		int j = Integer.parseInt(str);
		
		if(0==j){
			break;
			}else{
		System.out.println("Case "+ i +": "+j);
		}
		}
		
		
		}
}

Measured memory_bytes: 31428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
ll lookup[101][501];

ll power(ll a,ll b)
{
    ll res=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res * a)%mod;
        }
        b/=2;
        a = (a*a)%mod;
    }
    return res;
}

 

int main()
{
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;


}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$v = explode(" ", trim(fgets(STDIN)));
sort($v);
foreach ($v as $k => $x) {
    if ($k === 0) {
        $ans = $x;
    } else {
        $ans += $x;
        $ans /= 2;
    }
}
printf("%.f", $ans);


Measured memory_bytes: 4604
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    stk = []
    ans = collections.deque()

    for i in S:
        if i == '(':
            stk.append(i)
            ans.append(i)
        else:
            if stk and stk[-1] == '(':
                stk.pop()
                ans.append(i)
            else:
                ans.appendleft('(')
                ans.append(i)
    
    while stk:
        ans.append(')')
        stk.pop()

    print(''.join(ans))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10008
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 1007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, b1, b2, sum = 0;
   cin >> n >> b1;
   b2 = b1;
   sum = b1;
   for (int i = 1; i < n - 1; i++)
   {
      cin >> b2;
      sum += min(b1, b2);
      b1 = b2;
   }
   sum += b2;
   cout << sum << endl;
   return 0;
}


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

using namespace std;

const int N = 100 + 77 , L = 17;
long long n , p , A = 1;
map < long long , int > M;
long long Pow(long long x , int y){
   long long res = 1;
   while(y --)
      res *= x;
   return res;
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> p;
   for(long long i = 2;i * i <= p;++ i)
      while(p % i == 0)
         ++ M[i] , p /= i;
   ++ M[p];
   for(auto x : M)
      A *= Pow(x.first , x.second / n);
   cout << A;

   return 0;
}


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

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

fn main() {
    let d: i64 = read();
    println!(
        "{}",
        match d {
            22 => "Christmas Eve Eve Eve",
            23 => "Christmas Eve Eve",
            24 => "Christmas Eve",
            25 => "Christmas",
            _ => "",
        },
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
  IOS
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && b != c) {
    cout << "Yes\n";
  } else if(a == c && c != b) {
    cout << "Yes\n";
  } else if(b == c && b != a) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int n, q, k;
	std::vector<long> a;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	
	a.resize(n);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a[i];
#else
		std::cin >> a[i];
#endif
	}

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> k;
#else
		std::cin >> k;
#endif
		std::vector<long>::iterator it = std::lower_bound(a.begin(), a.end(), k);
		std::cout << (it - a.begin()) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3560
import java.util.*;

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

      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());

      int ans = 0;

      if(2*b>=a){
        ans = 0;
      }
      else{
        ans = a - 2*b;
      }

      System.out.println(ans);

    }
}

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

int main(){
	int a[6];
	for(int i = 0; i < 6; ++i) cin >> a[i];
	for(int i = 0; i < 4; ++i){
		for(int j = i + 1; j < 5; ++j){
			if(abs(a[i] - a[j]) > a[5]){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
}


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

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//fill(score, score+202020, 0);

int main(){
  ll h, w, d;
  cin >> h >> w >> d;

  vector<ll> A[h*w];
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      ll tmp;
      cin >> tmp;
      A[tmp-1].push_back(i);
      A[tmp-1].push_back(j);
    }
  }

  //for (int i=0;i<h*w;i++){
  //  cout << A[i][0] << " " << A[i][1] << endl;
  //}

  ll Ra[h*w];
  ll x1, x2, y1, y2;
  for (int i=0;i<h*w;i++){
    x1 = A[i][0];
    y1 = A[i][1];
    if (i+d < h*w){
      x2 = A[i+d][0];
      y2 = A[i+d][1];
      Ra[i] = abs(x1 - x2) + abs(y1 - y2);
    }
    else{
      Ra[i] = 0;
    }
  }

  //cout << endl;
  //for (int i=0;i<h*w;i++){
  //  cout << Ra[i] << " ";
  //}
  //cout << endl;

  ll Rs[h*w];
  for (int i=0;i<h*w;i++){
    if (i<d) Rs[i] = 0;
    else Rs[i] = Ra[i-d] + Rs[i-d];
  }

  //for (int i=0;i<h*w;i++){
  //  cout << Rs[i] << " ";
  //}
  //cout << endl;

  ll Q, L, R;
  cin >> Q;

  for (int i=0;i<Q;i++){
    cin >> L >> R;
    cout << Rs[R-1] - Rs[L-1] << endl;
  }
}


Measured memory_bytes: 7424
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>

const int Maxv = 300010; 

inline char fgc() {
    static char buf[1 << 15], *p1 = buf, *p2 = buf; 
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 15, stdin), p1 == p2) ? EOF : *p1++; 
}

inline int read() {
    static int x, f, ch; 
    x = 0, f = 0, ch = fgc(); 
    while (ch < '0' || ch > '9') ch == '-' ? f = 1 : 0, ch = fgc(); 
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = fgc(); 
    return f ? -x : x; 
}

inline void Yes() {
    puts("Yes"); 
}

inline void No() {
    puts("No"); 
}

int num[Maxv], n; 

int main() {
    std::srand(std::time(NULL)); 

    n = read(); 
    for (int i = 1; i <= n; i++) {
        num[i] = read(); 
        if ((i & 1) ^ (num[i] & 1)) {
            puts("No"); 
            return 0;
        }
    }

    int lim = std::rand() % 100; 
    for (int t = 0; t <= lim + 50; t++) {
        for (int i = n - 2; i >= 1; i--) {
            if (num[i] > num[i + 1] && num[i + 1] > num[i + 2])
                std::swap(num[i], num[i + 2]); 
        }
    }

    for (int i = 2; i < n; i++) {
        if (num[i - 1] > num[i + 1] && (num[i - 1] < num[i] || num[i] < num[i + 1])) {
            puts("No"); 
            return 0; 
        }
    }

    puts("Yes"); 

    return 0; 
}

Measured memory_bytes: 1408
def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  sx,sy,tx,ty=map(int,input().split())
  b=[[-1]*(w+2)]
  for i in range(h):
    s=input()
    bb=[-1]
    for j in s:
      if j==".":bb.append(0)
      else:bb.append(-1)
    bb.append(-1)
    b.append(bb)
  b.append([-1]*(w+2))
  d=[]
  d.append((sx,sy))
  for ss in d:
    x,y=ss
    if x==tx and y==ty:
      exit(print(b[x][y]))
    for i in range(1,k+1):
      if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
      if b[x+i][y]==0:d.append((x+i,y))
      b[x+i][y]=b[x][y]+1
    for i in range(1,k+1):
      if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
      if b[x-i][y]==0:d.append((x-i,y))
      b[x-i][y]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
      if b[x][y+j]==0:d.append((x,y+j))
      b[x][y+j]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
      if b[x][y-j]==0:d.append((x,y-j))
      b[x][y-j]=b[x][y]+1
  print(-1)
if __name__ == "__main__":
  main()


Measured memory_bytes: 113852
import numpy as np
import itertools

n=int(input())
s=[]
for i in range(n):
  s.append(list(map(float,input().split())))

def dist(a,b):
  return ((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2)
  
a=[]
for i in range(n):
  b=[]
  for j in range(n):
      b.append(dist(s[i],s[j]))
  a.append(b)

t=np.arange(n)      

sum=0
k=0
for v in itertools.permutations(t, n):
  k+=1
  for m in range(n-1):
    sum += a[v[m]][v[m+1]]

print(sum/k)

Measured memory_bytes: 12512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10;
const int mod=1e9+7;
const int inf=1e9;

ll dp[N][2];
bool vis[N];
vector<int> g[N];

void dfs(int u){
    if(vis[u]) return;
    vis[u]=true;
    dp[u][0]=1;
    dp[u][1]=1;
    for(auto v : g[u]){
        if(vis[v]) continue;
        dfs(v);
        dp[u][0]=(dp[u][0]*(dp[v][0] + dp[v][1]))%mod;
        dp[u][1]=(dp[u][1]*dp[v][0])%mod;
    }
}

int main(){
    int n;
    cin>>n;
    int a,b;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1);
    ll ans=(dp[1][0] + dp[1][1])%mod;
    cout<<ans<<'\n';
    return 0;
}


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

int main()
{
  int a,n,b;
  cin>>n;
  cin>>a;
  b=n%500;

  if(b<=a)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int X, A, B;
  scanf("%d %d %d", &X, &A, &B);
  int distA = (X > A) ? X - A : A - X;
  int distB = (X > B) ? X - B : B - X;
  (distA < distB) ? puts("A") : puts("B");
  return 0;
}

Measured memory_bytes: 1604
n = int(input())
a = list(map(int,input().split()))
result_1 = 0
result_1 += abs(a[0])
for i in range(n-1):
    result_1 += abs(a[i+1]-a[i])
result_1 += abs(a[n-1])
a.insert(0,0)
a.insert(n+1,0)
for i in range(n):
    if a[i+2] >= a[i+1] >= a[i] or a[i+2] <= a[i+1] <= a[i]:
        print(result_1)
    else:
        b = abs(a[i+2]-a[i+1])
        c = abs(a[i+1]-a[i])
        d = abs(a[i+2]-a[i])
        result = result_1 - (b + c - d)
        print(result)

Measured memory_bytes: 14048