akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 200005;
LL fact[N], invfact[N], inv[N], invpow2[N];
const int inv2 = (MOD + 1) / 2;

void init() {
	fact[0] = fact[1] = 1;
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	FOR(i, 2, N) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i] = MOD - (inv[MOD%i] * (MOD / i)) % MOD;
		invfact[i] = (invfact[i - 1] * inv[i]) % MOD;
	}
	invpow2[0] = 1;
	FOR(i, 1, N)invpow2[i] = invpow2[i - 1] * inv2 % MOD;
}

LL nCr(int n, int r) {
	if (n < 0 || r < 0)return 0;
	if (n < r)return 0;
	return ((fact[n] * invfact[n - r] % MOD) * invfact[r]) % MOD;
}

int main() {
	int b, w;
	cin >> b >> w;
	LL p = 0;
	LL q = 0;
	init();
	REP(i, b + w) {
		printf("%lld\n", (inv2 * (1 - p + q + MOD)) % MOD);
		p = (p + invpow2[i+1] * nCr(i, b - 1)) % MOD;
		q = (q + invpow2[i+1] * nCr(i, w - 1)) % MOD;
	}
	return 0;
}

Measured memory_bytes: 8448
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int p = sc.nextInt();
        int q = sc.nextInt();
        double r = sc.nextInt();
        int dis = b * p - (b - a) * q;
        System.out.println(dis / (q + r) + b);
    }
}



Measured memory_bytes: 26376
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    cA = defaultdict(int)
    sv = sum(A)
    for a in A:
        cA[a] += 1
    Q = int(input())
    for _ in range(Q):
        bi, ci = map(int, input().split())
        sv -= cA[bi] * bi
        sv += cA[bi] * ci
        cA[ci] += cA[bi]
        del cA[bi]
        # print(sv, cA)
        print(sv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 89412
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AOddsOfOddness {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            double n = s.nextInt();
            w.println(Math.ceil(n / 2) / n);
        }

    }

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

        public FastReader(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 c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }
}



Measured memory_bytes: 21460
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int fa[MAXN],ind[MAXN],oud[MAXN],v1[MAXN],v2[MAXN];
int n,h;
bool flag[MAXN];
int get_fa(int x){
	if(fa[x]==0)
		return x;
	fa[x]=get_fa(fa[x]);
	return fa[x];	
}
int main(){
	SF("%d%d",&n,&h);
	int x,y,a,b;
	for(int i=1;i<=n;i++){
		SF("%d%d%d%d",&x,&y,&a,&b);
		int u,v;
		if(a==0)
			u=x+200;
		else
			u=a;
		if(b==0)
			v=y;
		else
			v=b+200;
		flag[u]=flag[v]=1;
		oud[u]++;
		ind[v]++;
		if(get_fa(u)!=get_fa(v))
			fa[get_fa(u)]=get_fa(v);
	}
	for(int i=1;i<=400;i++){
		if(ind[i]>oud[i]){
			v1[get_fa(i)]++;
			if(i>200){
				PF("NO");
				return 0;
			}
		}
		if(ind[i]<oud[i]){
			v2[get_fa(i)]++;
			if(i<=200){
				PF("NO");
				return 0;
			}
		}
	}
	for(int i=1;i<=400;i++)
		if(fa[i]==0)
			if(v1[i]==0&&v2[i]==0&&flag[i]){
				PF("NO");	
				return 0;
			}
	PF("YES");
}

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

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define smallk order_of_key
#define kth find_by_order
*/

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;

const int N = (int)1e5 + 123;
const int M = 1e9 + 7;
const int K = 500;

int n, m;
vector<int> g[N];
int d[N];
int dfs(int v){
    if(d[v] != -1){
        return d[v];
    }
    int c = 0;
    for(int to : g[v]){
        c = max(c, dfs(to));
    }
    d[v] = 1 + c;
    return d[v];
}
int main(){

    //ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #ifdef LOCAL
        freopen("B.txt", "r", stdin);
    #endif // LOCAL

    cin >> n >> m;
    while(m--){
        int x, y; cin >> x >> y;
        g[x].pb(y);
    }
    int ans = 0;
    memset(d, -1, sizeof(d));
    for(int i = 1; i <= n; ++i){
        ans = max(ans, dfs(i));
    }
    cout << ans - 1;
    return 0;
}



Measured memory_bytes: 8192
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

N, M, L = map(int, raw_input().split())

def fact(n):
    if n <= 1:
        return 1
    return fact(n - 1) * n
MC = []
for i in range(M + 1):
    MC.append(fact(M) / fact(i) / fact(M - i))

p_lst = []
P_val = []
P_sum = []

for i in range(N):
    P, T, V = map(int, raw_input().split())
    p_lst.append((T, V))
    PP = []
    for k in range(M + 1):
        PP.append(float(MC[k] * (P ** k) * ((100 - P) ** (M - k))) / 100 ** M)
    P_val.append(list(PP))
    for k in range(M, 0, -1):
        PP[k - 1] += PP[k]
    P_sum.append(PP)

def comp(p1, p2, k1, k2):
    T1, V1 = p1
    T2, V2 = p2
    return L * (V2 - V1) < V1 * V2 * (k2 * T2 - k1 * T1)

for i in range(N):
    ans = 0
    index_lst = [0 for j in range(N)]
    for k1 in range(M + 1):
        ret = P_val[i][k1]
        for j in range(N):
            if i == j:
                continue
            while True:
                k2 = index_lst[j]
                if k2 > M:
                    ret *= 0
                    break
                if comp(p_lst[i], p_lst[j], k1, k2):
                    ret *= P_sum[j][k2]
                    break
                index_lst[j] += 1
        ans += ret
    print '%.10f' % ans



Measured memory_bytes: 5184
#include <cstdio>

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int get_colour(int rating)
{
    rating = min(rating, 3200);

    return rating/400;
}

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

    const int NO_OF_COLOURS = 8, SPECIAL = 8;
    int frequency[NO_OF_COLOURS + 1] = {0};

    while(no_of_contestants--)
    {
        int rating;
        scanf("%d", &rating);

        int colour = get_colour(rating);
        frequency[colour]++;
    }

    int normal_colours = 0;
    for(int i = 0; i < SPECIAL; i++)
        normal_colours += (frequency[i] > 0);

    int max_colours = normal_colours + frequency[SPECIAL];
    int min_colours = (normal_colours == 0 ? 1 : normal_colours);

    printf("%d %d", min_colours, max_colours);
    return 0;
}


Measured memory_bytes: 128
for i in range(input()):	
	b=format(int(raw_input(),16),"b").zfill(32)
	a1=0
	a2=0.0
	for i in range(1,25):
		a1+=int(b[i])*2**(24-i)
	for i in range(25,32):
		a2+=int(b[i])*2**(24-i)
	print "-"*int(b[0])+str(a1)+str(a2)[1:]

Measured memory_bytes: 4580
N, K =gets.split.map(&:to_i)
rock_get, scissors_get, paper_get = gets.split.map(&:to_i)
answers = gets.chomp

choice = []
score = 0
# 勝ち続けるのが基本?
# K回制限があるので


(0..(K-1)).each do |i|
  case answers[i]
  when 'r'
    choice << 'p'
    score += paper_get
  when 's'
    choice << 'r'
    score += rock_get
  when 'p'
    choice << 's'
    score += scissors_get
  end
end

(K..(N-1)).each do |i|
  case answers[i]
  when 'r'
    if choice[i - K] != 'p'
      choice << 'p'
      score += paper_get
    elsif answers[i + K] == 's'
      choice << 's'
    elsif answers[i + K] == 'p'
      choice << 'r'
    else
      choice << 'r'
    end
  when 's'
    if choice[i - K] != 'r'
      choice << 'r'
      score += rock_get
    elsif answers[i + K] == 'p'
      choice << 'p'
    elsif answers[i + K] == 'r'
      choice << 's'
    else
      choice << 's'
    end
  when 'p'
    if choice[i - K] != 's'
      choice << 's'
      score += scissors_get
    elsif answers[i + K] == 'r'
      choice << 'r'
    elsif answers[i + K] == 's'
      choice << 'p'
    else
      choice << 'p'
    end
  end
end

puts score


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<P> xy(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        xy[i] = P(x, y);
    }
    sort(all(xy));
    map<P, int> mp;
    rep(i, n) for (int j = i+1; j < n; ++j) {
        mp[P(xy[j].fi - xy[i].fi, xy[j].se - xy[i].se)]++;
    }
    int mx = 0;
    for (auto&& p : mp) chmax(mx, p.se);
    int ans = n - mx;
    cout << ans << endl;
}


Measured memory_bytes: 3672
l = list(map(int, input().split()))
num = -1
fl = 0
na = float(l[0])
nb = float(l[1])
for i in l:
  if 0 < i:
    if i < 10:
      fl += 1
if fl == 2:
  num = l[0] * l[1]
print(num)

Measured memory_bytes: 38256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var price = UInt32.Parse(Console.ReadLine());

            var m = price % 1000u;
            if (m == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1000u - m);
            }
        }
    }
}


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

const int N=2005; 

using namespace std;
 
int n,c,d[N],cnt,res; 

struct edge{
	int u,v,nxt; 
}e[N<<1]; int tail,adj[N]; 

void addedge(int u,int v){ e[++tail]=(edge){u,v,adj[u]}; adj[u]=tail; }

void dfs(int u,int fa){
	for(int k=adj[u]; k!=-1; k=e[k].nxt){
		int v=e[k].v;
		if(v==fa) continue;
		d[v]=d[u]+1; 
		if(d[v]>c) ++cnt;
		dfs(v,u);
	}
}

int main(){
	int u,v; 
	cin>>n>>c;
	tail=1; fill(adj+1,adj+n+1,-1);  
	for(int i=1; i<n; ++i){
		cin>>u>>v; 
		addedge(u,v); 
		addedge(v,u); 
	}
	res=n+1; 
	if(!(c&1)){
		c>>=1; 
		for(int i=1; i<=n; ++i){
			cnt=0; 
			d[i]=0; 
			dfs(i,0);
			res=min(res,cnt);  
		}
	}	else{
		c--; 
		c>>=1; 
		for(int i=2; i<=tail; i+=2){
			cnt=0; 
			d[e[i].u]=0; 
			dfs(e[i].u,e[i].v);
			d[e[i].v]=0;  
			dfs(e[i].v,e[i].u); 
			res=min(res,cnt); 
		}
	}
	cout<<res<<endl; 
	return 0; 
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

bool check(string a, string b) {
    if (a.size() < b.size()) {
        return true;
    }
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] < b[i]) {
            return true;
        } else if (a[i] > b[i]) {
            return false;
        }
    }
    return true;
}

ll two(ll n) {
    return (n * (n - 1)) / 2;
}

ll three(ll n) {
    return (n * (n - 1) * (n - 2)) / 6;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    string n;
    int k;
    cin >> n >> k;
    ll ans = 0;
    if (k == 1) {
        string cur(n.size(), '0');
        for (int i = 0; i < cur.size(); ++i) {
            for (int j = 1; j <= 9; ++j) {
                cur[i] = '0' + j;
                if (check(cur, n)) {
                    ans++;
                }
                cur[i] = '0';
            }
        }
    } else if (k == 2) {
        string cur(n.size(), '0');
        for (int i = 0; i < cur.size(); ++i) {
            for (int j = i + 1; j < cur.size(); ++j) {
                for (int a = 1; a <= 9; ++a) {
                    for (int b = 1; b <= 9; ++b) {
                        cur[i] = '0' + a;
                        cur[j] = '0' + b;
                        if (check(cur, n)) {
                            ans++;
                        }
                        cur[i] = '0';
                        cur[j] = '0';
                    }
                }
            }
        }
    } else {
        string cur(n.size(), '0');
        cur[0] = n[0];
        for (int i = 1; i < cur.size(); ++i) {
            for (int j = i + 1; j < cur.size(); ++j) {
                for (int a = 1; a <= 9; ++a) {
                    for (int b = 1; b <= 9; ++b) {
                        cur[i] = '0' + a;
                        cur[j] = '0' + b;
                        if (check(cur, n)) {
                            ans++;
                        }
                        cur[i] = '0';
                        cur[j] = '0';
                    }
                }
            }
        }
        ans += (cur[0] - '0' - 1) * two(n.size() - 1) * 81;
        ans += three(n.size() - 1) * 729;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var input = irLine(1)
	var A, B = float64(input[0][0]), float64(input[0][1])

	var a int = int(A/8.00*100.00) + 1
	var b int = a

	var ax, bx int = -1, -1

	for ; ; b-- {
		if int(float64(b)*0.08) == int(A) && int(float64(b)*0.10) == int(B) {
			ax = b
		}
		if int(float64(b)*0.10) < int(B) {
			break
		}
	}

	a = int(B/10.00*100.00) + 1
	b = a

	for ; ; b-- {
		if int(float64(b)*0.08) == int(A) && int(float64(b)*0.10) == int(B) {
			bx = b
		}
		if int(float64(b)*0.08) < int(A) {
			break
		}
	}

	switch {
	case ax != -1 && bx != -1:
		fmt.Printf("%d", mini(ax, bx))
	case bx == -1:
		fmt.Printf("%d", ax)
	case ax == -1:
		fmt.Printf("%d", bx)
	default:
		fmt.Printf("%d", -1)
	}
}

func minf(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

func mini(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func paw(f float64, num int) float64 {
	var result float64 = 1
	for i := 0; num > i; i++ {
		result *= f
	}
	return result
}

//StrStdin Read standard input data
func StrStdin(line int) [][]string {
	var stringInput [][]string
	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < line; i++ {
		scanner.Scan()
		if s := scanner.Text(); s != "" {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((scanner.Text())), " "))
		} else {
			break
		}
	}

	return stringInput
}

//rLine Read standard input data
func rLine(line int) [][]string {
	var rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	var buf = make([]byte, 0, 1000000)
	var stringInput [][]string

	for i := 0; i < line; {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((string(buf))), " "))
			buf = []byte{}
			i++
		}
	}
	return stringInput
}

func irLine(i int) [][]int {
	return alitoas(rLine(i))
}

//itoa converts string to integer
func itoa(s string) int {
	var i, _ = strconv.Atoi(s)
	return i
}

func itoas(S []string) []int {
	var result = make([]int, len(S))
	for i, s := range S {
		result[i] = itoa(s)
	}
	return result
}

func alitoas(S [][]string) [][]int {
	var result = make([][]int, len(S))
	for i, s := range S {
		result[i] = itoas(s)
	}
	return result
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd3(a, b, c int) int {
	return gcd(gcd(a, b), c)
}


Measured memory_bytes: 640
rule = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = map(int, input().split())
A = rule.index(a)
B = rule.index(b)
if A > B:
  print('Alice')
elif A == B:
  print('Draw')
else:
  print('Bob')

Measured memory_bytes: 3060
list = [list(map(int,input().split())) for i in range(3)]
N = int(input())
A = [[0] * 3 for i in range(3)]
for i in range(N):
  B = int(input())
  for j in range(3):
    for k in range(3):
      if list[j][k] == B:
        A[j][k] += 1
        
result = A[0][0] * A[0][1] * A[0][2]
result += A[1][0] * A[1][1] * A[1][2]
result += A[2][0] * A[2][1] * A[2][2]
result += A[0][0] * A[1][0] * A[2][0]
result += A[0][1] * A[1][1] * A[2][1]
result += A[0][2] * A[1][2] * A[2][2]
result += A[0][0] * A[1][1] * A[2][2]
result += A[0][2] * A[1][1] * A[2][0]
if result >= 1:
  print('Yes')
else:
  print('No')

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int digits(ll n){
	int cnt = 0;
	while(n > 0){
		cnt++;
		n /= 10;
	}

	return cnt;
}

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

	int ans = digits(n);
	//cout<<ans<<endl;
	for(int i=1;i<=sqrt(n);i++){
		if(n % i == 0){
			ll b = n / i;

			//cout<<'a'<<" "<<i<<" "<<'b'<<" "<<b<<endl; 
			//cout<<ans<<endl;

			ans = min(ans, digits(b));
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import fractions

n = int(input())
a = list(map(int, input().split()))


left_gcd = [0 for _ in range(n)]
right_gcd = [0 for _ in range(n)]

left_gcd[0] = a[0]
right_gcd[-1] = a[-1]

for i in range(1, n):
    left_gcd[i] = fractions.gcd(left_gcd[i-1], a[i])

for i in range(n-2, -1, -1):
    right_gcd[i] = fractions.gcd(right_gcd[i+1], a[i])
# print(left_gcd)
# print(right_gcd)

ans = 1
for i in range(1, n-1):
    num1 = left_gcd[i-1]
    num2 = right_gcd[i+1]
    ans = max(ans, fractions.gcd(num1, num2))

ans = max(ans, right_gcd[1], left_gcd[-2])
print(ans)


Measured memory_bytes: 16148
//{{{
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

vector<string> ss;
int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  set<string> st;
  rep(i, s.size()){
    int r = s.size() - i;
    rep(j, 1, min(5, r) + 1){
      st.insert(s.substr(i, j));
    }
  }
  for(auto it = st.begin(); it != st.end(); it++){
    K--;
    if(K == 0){
      cout << (*it) << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
int main(void)
{
    int N;
    cin >> N;
    for(int i=1;i<=50000;i++)
    {
        if(floor(i*1.08)==N)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# def solve(n: int, k: int) -> int:
def solve(n, k):
    n -= max(0, n // k - 10) * k
    ans = n
    for _ in range(100):
        n = abs(n - k)
        ans = min(ans, n)
    return ans

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  vector<int> A = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (A.at(x) == A.at(y)) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

struct T
{
    int x, y, color;
    bool operator < (const T & other) const
    {
        return x < other.x;
    }
}p[maxn];
int N;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> N;
    for (int i=1; i<=2*N; ++i){
        cin >> p[i].x >> p[i].y;
        if (i <= N) p[i].color = 1;
        else p[i].color = 2;
    }
    sort(p+1, p+1+2*N);
    multiset<int> ms;
    int ans = 0;
    for (int i=1; i<=2*N; ++i){
        int first = i;
        int last = i;
        while (last<=2*N && p[last].x == p[first].x) ++last;
        --last; i = last;
        for (int j=first; j<=last; ++j){
            if (p[j].color == 2){
                if (ms.empty()) continue;
                auto it = ms.lower_bound(p[j].y);
                if (it == ms.begin()) continue;
                --it; ms.erase(it);
                ++ans;
            }
        }
        for (int j=first; j<=last; ++j){
            if (p[j].color == 1){
                ms.insert(p[j].y);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

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

fn mod_pow(n: usize) -> usize {
    let mut ans = 1;
    for _i in 0..n {
        ans *= 2;
        ans %= MOD;
    }
    ans
}

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut cnt = vec![0; n+1];
    for &a in aa.iter() {
        cnt[a] += 1;
    }
    if n%2 == 0 {
        let mut i = 1;
        while i < n {
            if cnt[i] != 2 {
                return println!("{}", 0);
            }
            i += 2;
        }
    } else {
        if cnt[0] != 1 {
            return println!("{}", 0);
        }

        let mut i = 2;
        while i < n {
            if cnt[i] != 2 {
                return println!("{}", 0);
            }
            i += 2;
        }
    }
    println!("{}", mod_pow(n/2));
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll N;
    cin >>N;

    ll a,b;

    vector<ll> ans;

    while(N>0){
        ans.push_back(N%26);
        if(N%26==0){
            N=N-1;
        }
        N=N/26;
    }

    for(ll i=ans.size()-1;i>=0;i--){
        if(ans[i]==1){
            cout << 'a';
        }else if(ans[i]==2){
            cout << 'b';
        }else if(ans[i]==3){
            cout << 'c';
        }else if(ans[i]==4){
            cout << 'd';
        }else if(ans[i]==5){
            cout << 'e';
        }else if(ans[i]==6){
            cout << 'f';
        }else if(ans[i]==7){
            cout << 'g';
        }else if(ans[i]==8){
            cout << 'h';
        }else if(ans[i]==9){
            cout << 'i';
        }else if(ans[i]==10){
            cout << 'j';
        }else if(ans[i]==11){
            cout << 'k';
        }else if(ans[i]==12){
            cout << 'l';
        }else if(ans[i]==13){
            cout << 'm';
        }else if(ans[i]==14){
            cout << 'n';
        }else if(ans[i]==15){
            cout << 'o';
        }else if(ans[i]==16){
            cout << 'p';
        }else if(ans[i]==17){
            cout << 'q';
        }else if(ans[i]==18){
            cout << 'r';
        }else if(ans[i]==19){
            cout << 's';
        }else if(ans[i]==20){
            cout << 't';
        }else if(ans[i]==21){
            cout << 'u';
        }else if(ans[i]==22){
            cout << 'v';
        }else if(ans[i]==23){
            cout << 'w';
        }else if(ans[i]==24){
            cout << 'x';
        }else if(ans[i]==25){
            cout << 'y';
        }else{
            cout << 'z';
        }
    }

    cout <<endl;




    return 0;


}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		if(str.contains("a") && str.contains("b") && str.contains("c")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22740
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

class Main {
    static boolean[] visited;
    static ArrayList<Integer>[] go;
    static int n;
    static int m;
    static Deque<Integer> stack;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        go = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            go[i] = new ArrayList<Integer>();
        }
        stack = new ArrayDeque<Integer>();
        visited = new boolean[n];
        Arrays.fill(visited, false);
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            go[x].add(y);
        }
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                dfs(i);
            }
        }
        int dp[] = new int[n];
        Arrays.fill(dp, -1);
        for (int i = 0; i < n; i++) {
            int pos = stack.pop();
            dp[pos] = Math.max(0, dp[pos]);
            for (Integer next : go[pos]) {
                dp[next] = Math.max(dp[pos] + 1, dp[next]);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);
        sc.close();
    }

    public static void dfs(int v) {
        visited[v] = true;
        for (Integer next : go[v]) {
            if (!visited[next]) {
                dfs(next);
            }
        }
        stack.push(v);
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i += 2){
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int k[1000000];
int p(int A,int B){
  if(!B)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
int c(int A,int B){
  if(A<B)return 0;
  return k[A]*p(k[A-B]*k[B]%mod,mod-2)%mod;
}
signed main(){
  k[0]=1;
  for(int i=1;i<=1000000;i++)k[i]=k[i-1]*i%mod;
  int N,M;
  cin>>N>>M;
  map<int,int> A;
  for(int i=2;i<=M/i;i++)
    for(;M%i==0;M/=i)A[i]++;
  if(M!=1)A[M]++;
  int ans=1;
  for(pair<int,int> p:A)ans=ans*c(N+p.second-1,N-1)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 11448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    string s;
    cin >> s;
    if((s[5] == '0') && (s[6] < '4' || (s[6] == '4' && s[8] <= '3'))) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int i=sc.nextInt();
			if(i==0)break;
			int o=32,k=0;
			int []a=new int[i];
			for(int n=0;n<i;n++)a[n]=sc.nextInt();
			while(true){
				o-=(o-1)%5;
				System.out.println(o);
				o-=a[k];
				if(o<=0){
					System.out.println(0);
					break;
				}
				
				System.out.println(o);
				k++;
				if(k==i)k=0;
			}
		}
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n;
  cin >> n;
  bool ok=false;
  REP(i,n/4+1){
    REP(j,n/7+1){
      if(i*4+j*7==n)ok=true;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}



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

int main(){
  int n;
  cin>>n;
  int sum=0;
  for(int i=n;i>0;i/=10){
    sum+=i%10;
  }
  if(n%sum==0){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  l.sort()
  sm=sum(l)

  l3=[]
  for i in range(m):
    a,b=LI()
    l3.append([b,a])
  l3=sorted(l3,key=lambda x:x[0],reverse=True)

  n2=0
  for x in l3:
    n2+=x[1]

  # if n>n2:
  i=0
  i2=0
  while True:
    if i>n-1:
      break
    if i2>m-1:
      break

    a,b=l3[i2]
    while True:
      if i>n-1:
        break
      if i2>m-1:
        break

      if b==0:
        i2+=1
        break

      x=l[i]
      if x<a:
        sm+=a-x
        b-=1
        i+=1
      else:
        i2+=1
        break

  print(sm)

main()


Measured memory_bytes: 108948
int main(int argc, const char * argv[]) {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(-100<=x&&x<=100&&-100<=y&&y<=100&&0<W&&W<=100&&0<H&&H<=100&&0<r&&r<=100){
        if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
                printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
        
    return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

using Point = pair<int64_t, int64_t>;

struct Solution
{
    vector<int64_t> lengths;
    vector<string> configurations;
};

ostream& operator<<(ostream &os, const Solution &sol)
{
    if (sol.lengths.empty()) {
        os << "-1\n";
        return os;
    }

    os << sol.lengths.size() << "\n";
    for (const auto &len : sol.lengths) {
        os << len << " ";
    }
    os << "\n";

    for (const auto &conf : sol.configurations) {
        os << conf << "\n";
    }
    return os;
}

int64_t Parity(const Point &p)
{
    return (abs(p.first) + abs(p.second)) % 2;
}

bool CanSolve(const vector<Point> &points)
{
    return all_of(points.begin(),
                  points.end(),
                  [par = Parity(points[0])] (const auto &p) {
                        return Parity(p) == par;
                  });
}

static const string kDirs = "UDLR";
static const map<char, char> kReverse = {
    {'U', 'D'}, {'D', 'U'}, {'L', 'R'}, {'R', 'L'}
};
static const map<char, Point> kMods = {
    {'U', {0, 1}}, {'D', {0, -1}}, {'L', {-1, 0}}, {'R', {1, 0}}
};

Point Moved(const Point &p, char dir, int64_t amount)
{
    auto mod = kMods.at(dir);
    return {p.first + mod.first * amount, p.second + mod.second * amount};
}

bool InsideSquare(int64_t limit, const Point &p)
{
    return abs(p.first) + abs(p.second) <= limit;
}

string BuildConfiguration(Point dest, const vector<int64_t> &lengths)
{
    int64_t limit = accumulate(lengths.begin(), lengths.end(), (int64_t)0);
    string conf = "";

    for (const auto &len : lengths) {
        limit -= len;

        for (const auto &dir : kDirs) {
            auto moved = Moved(dest, dir, len);
            if (InsideSquare(limit, moved)) {
                dest = moved;
                conf.push_back(kReverse.at(dir));
                break;
            }
        }
    }
    return conf;
}

Solution Solve(const vector<Point> &points)
{
    Solution sol;
    if (!CanSolve(points)) {
        return sol;
    }

    for (int i = 38; i >= 0; i -= 1) {
        sol.lengths.push_back((1LL << i));
    }
    if (Parity(points[0]) == 0) {
        sol.lengths.push_back(1);
    }

    for (const auto &p : points) {
        sol.configurations.push_back(BuildConfiguration(p, sol.lengths));
    }

    return sol;
}

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

    vector<Point> points(n);
    for (auto &p : points) {
        cin >> p.first >> p.second;
    }

    auto res = Solve(points);
    cout << res << "\n";

    return 0;
}


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

int a, b, c;
int main() {
    while (cin >> a >> b >> c) {
        if (a > b && a > c) cout << "A" << endl;
        else if (b > a && b > c) cout << "B" << endl;
        else cout << "C" << endl;
    }
}



Measured memory_bytes: 3108
#include<iostream>
using namespace std;
const int maxn=100005;
int n,m,fa[maxn],dis[maxn];
bool ok=true;
int find(int x)
{
    if(fa[x]!=x)
    {
        int nf=fa[x];
        fa[x]=find(fa[x]);
        dis[x]+=dis[nf];
    }
    return fa[x];
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        fa[i]=i;
    for(int i=1;i<=m;i++)
    {
        int l,r,d;
        cin>>l>>r>>d;
        int ll=find(l),rr=find(r);
        if(ll==rr&&dis[l]-dis[r]!=d)
            ok=false;
        if(ll!=rr)
        {
            fa[ll]=rr;
            dis[ll]=d+dis[r]-dis[l];
        }
    }
    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int dp[int(1e5) + 2];
int main()
  {int N; cin >> N;
  vector<int> hs(N); for (auto &h : hs) cin >> h;
  for (auto &i : dp) i = 1e9;
  dp[1] = 0;
  for (int i = 1; i < N; ++i)
    {dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i - 1] - hs[i]));
    if (i + 1 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i - 1] - hs[i + 1]));}
  cout << dp[N] << endl;}

Measured memory_bytes: 1024
import sys


def main():
    orders = sys.stdin.readlines()[1:]
    dna_set = set()
    for order in orders:
        command, dna = order.split(" ")
        if command == "insert":
            dna_set.add(dna)
        elif command == "find":
            if dna in dna_set:
                print("yes")
            else:
                print("no")


if __name__ == "__main__":
    main()

Measured memory_bytes: 114640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cfloat>

double MinkowskiLength(const std::vector<double>& x, const std::vector<double>& y, int length, int p);
double ChebyshevLength(const std::vector<double>& x, const std::vector<double>& y, int length);

int main(int argc, char** argv)
{
	int len = 0;
	std::cin >> len;

	std::vector<double> x;
	for (int i = 0; i < len; ++i)
	{
		double tmp;
		std::cin >> tmp;
		x.push_back(tmp);
	}

	std::vector<double> y;
	for (int i = 0; i < len; ++i)
	{
		double tmp;
		std::cin >> tmp;
		y.push_back(tmp);
	}

	double a1 = MinkowskiLength(x, y, len, 1);
	double a2 = MinkowskiLength(x, y, len, 2);
	double a3 = MinkowskiLength(x, y, len, 3);
	double ai = ChebyshevLength(x, y, len);

	printf("%.5lf\n", a1);
	printf("%.5lf\n", a2);
	printf("%.5lf\n", a3);
	printf("%.5lf\n", ai);

	return 0;
}

double MinkowskiLength(const std::vector<double>& x, const std::vector<double>& y, int length, int p)
{
	double result = 0;
	for (int i = 0; i < length; ++i)
	{
		result += pow(abs(x[i] - y[i]), p);
	}

	result = pow(result, 1.0 / p);

	return result;
}

double ChebyshevLength(const std::vector<double>& x, const std::vector<double>& y, int length)
{
	double max = -DBL_MAX;
	for (int i = 0; i < length; ++i)
	{
		double val = abs(x[i] - y[i]);
		if (val > max)
		{
			max = val;
		}
	}

	return max;
}


Measured memory_bytes: 3416
N, Q = map(int, input().split())

S = str(input())

ruisekiwa = [0]
for i in range(len(S)):
    if S[i] == 'C' and S[i-1] == 'A':
        ruisekiwa.append(ruisekiwa[-1]+1)
    else:
        ruisekiwa.append(ruisekiwa[-1])

# print(ruisekiwa)
for i in range(Q):
    l, r = map(int, input().split())
    print(ruisekiwa[r]-ruisekiwa[l])


Measured memory_bytes: 6100
package main

import (
	"bufio"
	"strconv"
	"os"
	"fmt"
	"strings"
)

// (sorted ints, compare count)
func mergeSort(xs []int) ([]int, int) {
	n := len(xs)
	if n <= 1 {
		return xs, 0
	}

	mid := n/2
	leftXs, leftCount := mergeSort(xs[:mid])
	rightXs, rightCount := mergeSort(xs[mid:])

	newXs := make([]int, n)
	leftN, rightN := len(leftXs), len(rightXs)
	ind, leftInd, rightInd := 0, 0, 0
	count := 0

	for leftInd < leftN && rightInd < rightN {
		if leftXs[leftInd] < rightXs[rightInd] {
			newXs[ind] = leftXs[leftInd]
			leftInd++
		} else {
			newXs[ind] = rightXs[rightInd]
			rightInd++
		}
		ind++
		count++
	}
	for leftInd < leftN {
		newXs[ind] = leftXs[leftInd]
		ind++
		leftInd++
		count++
	}
	for rightInd < rightN {
		newXs[ind] = rightXs[rightInd]
		ind++
		rightInd++
		count++
	}

	return newXs, leftCount + rightCount + count
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	xs := make([]int, n)
	for i := 0; i < n; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		xs[i] = x
	}

	sortedXs, count := mergeSort(xs)
	fmt.Println(formatInts(sortedXs))
	fmt.Println(count)
}

func formatInts(xs []int) string {
	n := len(xs)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = strconv.Itoa(xs[i])
	}
	return strings.Join(ss, " ")
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 37248
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
	int i,c;
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].p<<", ";
	cout<<"depth = "<<D[u]<<", ";
	
	if(T[u].p==NIL)cout<<"root, ";
	else if(T[u].l==NIL)cout<<"leaf, ";
	else cout<<"internal node, ";
	
	cout<<"[";
	
	for(i=0, c=T[u].l; c!=NIL; i++, c=T[c].r){
		if(i)cout<<", ";
		cout<<c;
	}
	cout<<"]"<<endl;
}


int rec(int u,int p){
	D[u]=p;
	if(T[u].r!=NIL)rec(T[u].r,p);
	if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
	int i,j,d,v,c,l,r;
	cin>>n;
	for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;
	
	for(i=0;i<n;i++){
		cin>>v>>d;
		for(j=0;j<d;j++){
			cin>>c;
			if(j==0)T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	for(i=0;i<n;i++){
		if(T[i].p==NIL)r=i;
	}
	
	rec(r,0);
	
	for(i=0;i<n;i++)print(i);
	
	return 0;
}


Measured memory_bytes: 7776
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

string s[10009];
string t;
char tp[29];
int ans[10009];

int main(){
	DRI(n);
	REP(i,n){
		RS(tp);
		s[i]=string(tp);
	}
	RS(tp);t=string(tp);
	int a=0,b=0,c=0;//always smaller, always larger, either
	REP(i,n){
		string minv,maxv;
		for(char j:s[i]){
			if(j=='?')minv.PB('a'),maxv.PB('z');
			else minv.PB(j);maxv.PB(j);
		}
		if(t<minv)a++;
		else if(t>maxv)b++;
		else c++;
	}
	//printf("%d %d %d\n",a,b,c);
	REPP(i,b+1,n-a+2){
		if(i!=b+1)printf(" ");
		printf("%d",i);
	}puts("");
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  long long int a[n],b[n];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  int c[m],d[m];
  for(int i=0;i<m;i++) cin >> c[i] >> d[i];
  for(long long int i=0;i<n;i++){
    long long int minl=2000000000,minn=100;
    for(long long int j=0;j<m;j++){
      if(minl>=abs(a[i]-c[j])+abs(b[i]-d[j])){
        if(minl==abs(a[i]-c[j])+abs(b[i]-d[j]))minn=min(minn,j+1);
        else minn=j+1;
        minl=abs(a[i]-c[j])+abs(b[i]-d[j]);
      }      
    }
    cout << minn << endl;
  }
}

Measured memory_bytes: 256