akhauriyash/Code-Regression huggingface dataset:
import os
import sys
from io import BytesIO, IOBase
import math
def inputIntArray():
    return list(map(int, input().rstrip().split()))


def inputArray():
    return input().rstrip().split()


def inputVars():
    return map(int, input().rstrip().split())


def inputNum():
    return int(input())


def main():
    x, n = inputVars()
    if n == 0:
        print(x)
        return
    arr = inputIntArray()
    minRes = x
    if x not in arr:
        print(x)
        return
    minRes = float('inf')
    # arr.sort()
    for num in range(-1, 110):
        if num not in arr:
            minRes = num if abs(num - x) < abs(x - minRes) else minRes
    print(minRes)


#.........................................FAST INPUT OUTPUT.......................................
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#....................................END OF FAST I/O............................................

if __name__ == "__main__":
    main()

Measured memory_bytes: 63120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A1 = new int[N];
        int[] A2 = new int[N];
        for (int i = 0; i < N; i++) {
            A1[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            A2[i] = sc.nextInt();
        }

        List<Integer> result_list = new ArrayList<Integer>();
        int firstline_result = 0;
        for (int i=0; i < A1.length; i++) {
            firstline_result += A1[i];
            int tmp = firstline_result;
            for (int k=i; k < A2.length; k++) {
                tmp += A2[k];
            }
            result_list.add(tmp);
        }

        int max = result_list.get(0);
        for (int i = 1; i < result_list.size(); i++) {
            int v = result_list.get(i);
            if (v > max) {
                max = v;
            }
        }

        System.out.println(max);
    }
}


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


int main(){
	string input;
	int A=10000000,Z=-1;
	
	cin >> input;
	for(int i=0;i<input.size();i++){
		if(input[i]=='A'){
			A = min(A,i);
		}
		if(input[i] == 'Z'){
			Z = max(Z,i);
		}
	}
	cout << Z - A + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
        int n;
        vector<int> a;
         
        cin >> n;
        int maxim = 0, input;
        for(int i = 0;i < n;++i){
                cin >> input;
                a.push_back(input);
                maxim = max(maxim, input);
        }
         
        vector<int> li;
        for(int i = 1;i <= maxim;++i){
                if(maxim % i == 0){
                        li.push_back(i);
                }
        }
         
        int ans = 0;
        for(int i = 0;i < n;i++){
                int ba = lower_bound(li.begin(), li.end(), a[i]) - li.begin();
                ans += li[ba]-a[i];
        }
         
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 3524
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)


typedef struct { int b, c; } x;

int c_dsc(const void *a, const void *b) {
  x s = *(x *)a, t = *(x *)b;
  return t.c - s.c;
}

int dsc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n, m;
  x p[200010];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i].c);
    p[i].b = 1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &p[n + i].b, &p[n + i].c);
  }

  qsort(p, n + m, sizeof(x), c_dsc);
  
  int k = 0, cnt = 0;
  long long ans = 0;
  while (k < n + m && cnt < n) {
    cnt += p[k].b;
    ans += ((ll)p[k].c) * ((ll)p[k].b);
    k++;
  }
  k--;
  ans -= ((ll)p[k].c) * ((ll)(cnt - n));
  printf("%lld\n", ans);

  return 0;
}
  


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int INF = 1e9;
int PREP = (cout << fixed << setprecision(16), 0);
int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    int a = (x1 > x2 ? -1 : 1);
    int b = (y1 > y2 ? -1 : 1);
    for (int i = 0; i < N; i++) {
        X[i] = (X[i] - x1) * a;
        Y[i] = (Y[i] - y1) * b;
    }
    x2 = (x2 - x1) * a;
    y2 = (y2 - y1) * b;
    x1 = y1 = 0;
    vector<int> dp(N + 1, INF);
    dp[0] = -1;
    map<int, int> fountain;
    for (int i = 0; i < N; i++) {
        if (0 <= X[i] && X[i] <= x2 && 0 <= Y[i] && Y[i] <= y2) {
            fountain[Y[i]] = X[i];
        }
    }
    for (auto p : fountain) {
        auto it = lower_bound(begin(dp), end(dp), p.second);
        *it = p.second;
    }
    int k = 0;
    for (int i = N; i >= 0; i--) if (dp[i] != INF) {
        k = i;
        break;
    }
    if (k == min(y2, x2) + 1) {
        cout << (x2 + y2) * 100.0 + (k - 1) * (-20 + 5 * PI) - 20 + 10 * PI << endl;
    } else {
        cout << (x2 + y2) * 100.0 + k * (-20 + 5 * PI) << endl;
    }
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define ld long double
using namespace std;

long double dp[301][301][301];

long double solve(int i, int j, int k, int n)
{
    if (i == 0 && j == 0 && k == 0)
        return 0;
    else if (dp[i][j][k] != 0)
        return dp[i][j][k];
    long double x = 0, y = 0, z = 0, w = n;
    int total = 3;
    if (i != 0)
        x = (i / (ld)(i + j + k)) * (solve(i - 1, j, k, n) + w / (i + j + k));
    if (j != 0)
        y = (j / (ld)(i + j + k)) * (solve(i + 1, j - 1, k, n) + w / (i + j + k));
    if (k != 0)
        z = (k / (ld)(i + j + k)) * (solve(i, j + 1, k - 1, n) + w / (i + j + k));
    dp[i][j][k] = (x + y + z);
    return dp[i][j][k];
}

int main()
{
    int n, x = 0, y = 0, z = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 1)
            x++;
        else if (a[i] == 2)
            y++;
        else if (a[i] == 3)
            z++;
    }
    memset(dp, 0, sizeof(dp));
    cout << fixed;
    cout << setprecision(12) << solve(x, y, z, n) << endl;
    return 0;
}

Measured memory_bytes: 426496
#include <iostream>
using namespace std;
int main() {
    int X,Y;
    cin >> X >> Y;
    if (Y%2==1) {
        cout << "No" << endl;
    }
    else {
        if (X*4<Y||X*2>Y) 
           cout << "No" << endl;
        else {
            cout << "Yes" << endl;
        }
    }
}


Measured memory_bytes: 3604
n=int(input())
#n,m=map(int,input().split())
#t=int(input())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

difl=[al[i-1]-i for i in range(1,n+1)]

def sadness(b):
    res=0
    for dif in difl:
        res+=abs(dif-b)
    return res
difsort=sorted(difl)
if n%2==0:
    ind1=n//2
    ind2=n//2-1
    ans=min(sadness(difsort[ind1]),sadness(difsort[ind2]))
else:
    ind=n//2
    ans=sadness(difsort[ind])
print(ans)

Measured memory_bytes: 30916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 5e3;
vector<int> es[MAX_V];
ll A[MAX_V];
ll dp[MAX_V][MAX_V][2];
ll memo[MAX_V][2];

int dfs(int now, int pre){
    int sum = 1;
    if(A[now] > 0) dp[now][0][0] = A[now];
    else dp[now][0][1] = A[now];
    for(auto &e: es[now]){
        if(e == pre) continue;
        int tmp = dfs(e, now);
        rep(i, MAX_V) rep(j, 2) memo[i][j] = INF;
        rep(i, sum){
            rep(j, tmp){
                if(dp[e][j][0] < INF || dp[e][j][1] < 0){
                    chmin(memo[i+j+1][0], dp[now][i][0]);
                    chmin(memo[i+j+1][1], dp[now][i][1]);
                }
                rep(p, 2) rep(q, 2){
                    int r = (p != 0 || q != 0);
                    chmin(memo[i+j][r], dp[now][i][p]+dp[e][j][q]);
                }
            }
        }
        rep(i, MAX_V) rep(j, 2) dp[now][i][j] = memo[i][j];
        sum += tmp;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    rep(i, N) rep(j, N) rep(k, 2) dp[i][j][k] = INF;
    dfs(0, -1);
    rep(i, N){
        if(dp[0][i][0] < INF || dp[0][i][1] < 0){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 391680
#include <bits/stdc++.h>
using namespace std;
int n,i,a[110],mini;
int dist(int x)
{
    int d=0;
    for(int i=1;i<=n;i++)
        d+=(a[i]-x)*(a[i]-x);
    return d;
}
int main()
{
    mini=1999999999;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=100;i++)
        mini=min(mini,dist(i));
    cout<<mini;
    return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {	
	string n;
	cin >> n;

	rep(i, 3) {
		if(n[i] == '1') {
			n[i] = '9';
		} else {
			n[i] = '1';
		}
	}

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextStr(), sc.nextInt()
	keta := len(N)
	dp0 := make([][]int, keta+1)
	dp1 := make([][]int, keta+1)
	for i := 0; i < keta+1; i++ {
		dp0[i] = make([]int, K+1)
		dp1[i] = make([]int, K+1)
	}
	dp1[0][0] = 1
	for i := 0; i < keta; i++ {
		n, _ := strconv.Atoi(string(N[i]))
		for j := 0; j <= K; j++ {
			for x := 0; x < 10; x++ {
				if x == n {
					if x == 0 {
						dp1[i+1][j] += dp1[i][j]
						dp0[i+1][j] += dp0[i][j]
					} else if 0 < j {
						dp1[i+1][j] += dp1[i][j-1]
						dp0[i+1][j] += dp0[i][j-1]
					}
				} else {
					if x == 0 {
						dp0[i+1][j] += dp0[i][j]
					} else if 0 < j {
						dp0[i+1][j] += dp0[i][j-1]
					}
					if x < n {
						if x == 0 {
							dp0[i+1][j] += dp1[i][j]
						} else if 0 < j {
							dp0[i+1][j] += dp1[i][j-1]
						}
					}
				}
			}
		}
	}

	fmt.Fprintln(wtr, dp0[keta][K]+dp1[keta][K])
}


Measured memory_bytes: 640
module A = Array
module L = List
module Q = Queue

let read_int() = Scanf.scanf "%d " (fun x -> x)
let println = Printf.printf "%d\n"

let main =
  let a = read_int() in
  let b = read_int() in
  let c = read_int() in
  [a; b; c] |> L.sort_uniq compare |> L.length |> println


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  
  ll n,m;
  cin>>n>>m;
  
  ll H[n];
  rep(i,n) cin>>H[i];
  
  ll C[n];
  rep(i,n) C[i]=0;
  
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(H[a-1]<H[b-1]) C[a-1]++;
    else if(H[a-1]>H[b-1]) C[b-1]++;
    else{
      C[a-1]++;
      C[b-1]++;
    }
  }
  
  ll ans=0;
  rep(i,n){
    if(C[i]==0) ans++;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

typedef pair<int, int> P;
const int M = 1000000007;

vector<int> dijkstra(int s, vector<vector<P>> edge) {
    int n = edge.size();
    vector<int> dist(n, M);
    priority_queue<P, vector<P>, greater<P>> q;
    dist[s] = 0;
    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        for (auto& e : edge[p.second]) {
            if (dist[e.second] > p.first + e.first) {
                dist[e.second] = p.first + e.first;
                q.push(P(p.first + e.first, e.second));
            }
        }
    }
    return dist;
}


int main() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        if (i != u) exit(1);
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            edge[i].push_back(P(c, v));
        }
    }
    vector<int> d = dijkstra(0, edge);
    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 11728
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var s = input.ReadLine();

        if(s.Length <= n) {
            return s;
        }

        return s.Substring(0, n) + "...";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<long long>A(3*N);
  for(int i=0;i<3*N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  long long sum=0;
  int count=0;
  for(int i=0;i<3*N;i++){
    if(i%2==1){
      sum=sum+A.at(i);
      count++;
      A.at(3*N-count)=0;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 5624
import std.stdio,
       std.string;

void main() {
    long[dchar] table = ['I' : 1, 'V' : 5, 'X' : 10, 'L' : 50, 'C' : 100, 'D' : 500, 'M' : 1000];
    foreach(input; stdin.byLine) {
        dchar current = 'I';
        long sum = 0;
        foreach_reverse(dchar c; input) {
            if(table[c] < table[current]) {
                sum -= table[c];
            }
            else {
                sum += table[c];
                current = c;
            }
        }
        sum.writeln;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end());
  int ret = 0;
  for (int i = 0; i < N - 2; i++) {
    int k = i + 2;
    for (int j = i + 1; j < N - 1; j++) {
      k = max(j + 1, k);
      while (L[i] + L[j] > L[k] && k < N) k++;
      ret += (k - j - 1);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define INFT 99999999
#define N 102

#define siro 0
#define hai 1
#define kuro 2

int iro[N],p[N],d[N];
int o;

void pri(void);
void kyo(int M[N][N]){
  
  int u,i,mini;

  for(i=0;i<o;i++){          
    iro[i]=siro;
    d[i]=INFT;
  }
 p[0]=-1;
  d[0]=0;        
 
  while(1){
    mini=INFT;

    for(i=0;i<o;i++){            
      if(iro[i]!=kuro && d[i]<mini){
        mini=d[i];
        u=i;
      }
    }

    if(mini==INFT) break;
    
    iro[u]=kuro;     

    for(i=0;i<o;i++){
      if(iro[i]!=kuro && M[u][i]!=-1 && d[i]>M[u][i]+d[u]){

        d[i]=M[u][i]+d[u];
        p[i]=u;
        iro[i]=hai;
	
      }
    }
  }
}



int main(){
  int M[N][N],i,j;
  int l,p,k,h;
  
  scanf("%d",&o);
  for(i=0;i<o;i++){
    for(j=0;j<o;j++){
      M[i][j]=-1;
    }
  }

  for(i=0;i<o;i++){
    scanf("%d%d",&h,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&p,&l);
      M[h][p]=l;
    }
  }
    kyo(M);
      
    pri();
      
      return 0;
  }
  
void pri(void){
  int i;
  for(i=0;i<o;i++){  
    printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2048
import java.math.BigInteger;
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int k=sc.nextInt();
	if(k%2==0||k%5==0) {
		System.out.println(-1);
	}else {
		
		int y=7;
			s:for(int i=1;;i++) {
			if(y%k==0) {
					System.out.println(i);
					break s;
				}
			y=(10*y+7)%k;
			}
	}
	}

}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



int main()
{
    int n, m;
    int nr = 1;
    int mr = 1;

    cin >> n >> m;

    for (int i = 0; i < 2; i++)
    {
        nr = nr * (n - i);
    }

    for (int i = 0; i < 2; i++)
    {
        mr = mr * (m - i);
    }

    int res = nr/2 + mr/2;

    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char ch;
	while((ch = getchar()) != EOF){
			if(ch >= 97 && ch <= 122)
				printf("%c",ch-32);
			else if(ch >= 65 && ch <= 90)
				printf("%c",ch+32);
			else
				printf("%c",ch);
	}
}



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

int main(){
	string a,b;
	cin >>a>>b;
	for(int i=0;i<b.size();++i){
		cout <<a[i]<<b[i];
	}
	if(a.size()>b.size())cout<<a[a.size()-1];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int a,b; cin>>a>>b;
    if((a+b)%3 == 0|| a%3 == 0|| b%3 == 0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1e18;

int main() {
  ll h,w;
  cin >> h >> w;
  ll ans=inf;
  for(ll i=1;i<h;i++) {
    ll s1=i*w;
    ll tans=0;
    if(w%2==0||(h-i)%2==0) {
      tans=abs(s1-(h*w-s1)/2);
    }
    else if(h-i<w) {
      ll s2=w/2*(h-i);
      ll s3=(w-w/2)*(h-i);
      tans=max({abs(s1-s2),abs(s2-s3),abs(s3-s1)});
    }
    else {
      ll s2=(h-i)/2*w;
      ll s3=(h-i-(h-i)/2)*w;
      tans=max({abs(s1-s2),abs(s2-s3),abs(s3-s1)});
    }
    ans=min(ans,tans);
  }

  for(ll i=1;i<w;i++) {
    ll s1=i*h;
    ll tans=0;
    if((w-i)%2==0||h%2==0) {
      tans=abs(s1-(h*w-s1)/2);
    }
    else if(w-i<h) {
      ll s2=h/2*(w-i);
      ll s3=(h-h/2)*(w-i);
      tans=max({abs(s1-s2),abs(s2-s3),abs(s3-s1)});
    }
    else {
      ll s2=(w-i)/2*h;
      ll s3=(w-i-(w-i)/2)*h;
      tans=max({abs(s1-s2),abs(s2-s3),abs(s3-s1)});
    }
    ans=min(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int main(){
  unsigned char **var = malloc(3 * sizeof(unsigned char *));
	for(int i = 0; i < 3; i++)
		var[i] = malloc(10 * sizeof(unsigned char));
  scanf("%s[^" "]", var[0]);
  scanf(" %s[^" "]", var[1]);
  scanf(" %s[^\n]", var[2]);
  printf("%c%c%c\n", toupper(var[0][0]), toupper(var[1][0]), toupper(var[2][0]));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h)cin >> s[i];
	vector<vector<int>> ans(h,vector<int>(w,0));

	int now=1;
	rep(i,h)
	{
		rep(j,w)
		{
			if(s[i][j]=='#')
			{
				ans[i][j]=now++;
			}
		}
	}
	now=0;
	rep(i,h)
	{
		now=0;
		rep(j,w)
		{
			if(ans[i][j]!=0)now=ans[i][j];
			if(now!=0&&ans[i][j]==0)ans[i][j]=now;
		}
		now=0;
		rep(j,w)
		{
			if(ans[i][w-j-1]!=0)now=ans[i][w-j-1];
			if(now!=0&&ans[i][w-j-1]==0)ans[i][w-j-1]=now;
		}
	}

	vector<int> save;
	rep(i,h)
	{
		if(ans[i][0]!=0)save = ans[i];
		if(!save.empty()&&ans[i][0]==0)ans[i]=save;
	}
	save.clear();
	for(int i=h-1;i>=0;i--)
	{
		if(ans[i][0]!=0)save = ans[i];
		if(!save.empty()&&ans[i][0]==0)ans[i]=save;
	}
	rep(i,h)
	{
		rep(j,w)
		{
			cout<<ans[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int r, g, b;
  cin >> r >> g >> b;
  int s;
  s = r * 100 + g * 10 + b;

  if ((s % 4) == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

i64 gcd(i64 a,i64 b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
    int N,M,K;
    cin >> N >> M >> K;

    bool ok=false;
    rep(i,0,N+1) rep(j,0,M+1) if(i*(M-j)+(N-i)*j==K) ok=true;

    cout << (ok?"Yes":"No") << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;


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

		int X = Integer.parseInt(str.split(" ")[0]);
		int A = Integer.parseInt(str.split(" ")[1]);

		int ans = 10;

		if(X<A){
			ans = 0;
		}



		System.out.println(ans);


	}

	//2次元配列
	public static class Data  {
        long a, b;
        public Data(long a, long b) {
            this.a = a;
            this.b = b;
        }
    }
    // Comparator インターフェースを実装する
    public static class MyComparator implements Comparator<Data> {
        public int compare(Data d1, Data d2) {
            if (d1.b == d2.b) {
                return (int)(d1.a - d2.a);
            } else {
                return (int)(d1.b - d2.b);
            }

        }
    }

}


Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int DP[301*301*301];
void Calc(){
	string S = res();
	int K = rei();
	int N = S.length();
	for(int i=0;i<N;i++){
		for(int j=N-1;j>i;j--){
			for(int k=0;k<=K;k++){
				DP[(i+1)*301*301+j*301+k] = max(DP[i*301*301+j*301+k],DP[(i+1)*301*301+(j+1)*301+k]);
				if(S[i] == S[j]){
					DP[(i+1)*301*301+j*301+k] = max(DP[(i+1)*301*301+j*301+k],DP[i*301*301+(j+1)*301+k]+1);
				}
				else if(k != 0){
					DP[(i+1)*301*301+j*301+k] = max(DP[(i+1)*301*301+j*301+k],DP[i*301*301+(j+1)*301+k-1]+1);
				}
			}
		}
	}
	int ans = 1;
	for(int k=0;k<=K;k++){
		for(int i=0;i<N-1;i++){
			ans = max(DP[(i+1)*301*301+(i+1)*301+k]*2,ans);
		}
		for(int i=0;i<N-2;i++){
			ans = max(DP[(i+1)*301*301+(i+2)*301+k]*2+1,ans);
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 106368
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100007];
void dfs(int i, vector<int>& vis, stack<int>& s){
  vis[i] = 1;
  for(int j=0;j<v[i].size();j++){
    if(vis[v[i][j]]==0){
      dfs(v[i][j],vis,s);
    }
  }
  s.push(i);
}
int main(){
  int n,m;
  cin >> n >> m;
  stack<int> s;
  vector<int> vis(n+1,0);
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  vector<int> dp(n+1, INT_MIN);
  for(int i=1;i<=n;i++){
    if(!vis[i]){
      dp[i]=0;
      dfs(i,vis,s);
    }
  }
  int ans = 0;
  while(!s.empty()){
    int u = s.top();
    s.pop();
    if(dp[u]!=INT_MIN){
      for(int j=0;j<v[u].size();j++){
        if(dp[v[u][j]]<dp[u]+1){
          dp[v[u][j]]=dp[u]+1;
        }
      }
    }
  }
  for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 8960
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)

	for i := range a {
		fmt.Scan(&a[i])
	}

	printa(a)

	for i := 1; i < n; i++ {
		key := a[i]
		j := i - 1
		for j >= 0 && a[j] > key {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = key

		printa(a)
	}
}

func printa(a []int) {
	for i := range a {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(a[i])
	}
	fmt.Println()
}



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

int main()
{
  long n,a;
  string ans="YES";
  map<long, bool> A;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    cin >> a;
    if(A[a]==true)
    {
      ans = "NO";
      break;
    }
    
    A[a]=true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    long long int max=0;
    long long int ans;
    cin >> N;
    int A[N];
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    long long int B[N+1];
    for (int i=0; i<N+1; i++) B[i] = 0;
    for (int i=0; i<N; i++){
        B[A[i]] ++;
    }
    for (int i=0; i<N+1; i++){
        max = max + B[i] * (B[i]-1) / 2;
    }
    for (int i=0; i<N; i++){
        ans = max - B[A[i]] * (B[A[i]]-1) / 2 + (B[A[i]]-1) * (B[A[i]]-2) /2;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin>>a.at(i);

  sort(a.begin(), a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


string s;
int k;
set<string> st;

int main(){
	cin >> s;
	cin >> k;
	int n = s.size();
	
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= n-i && j <= k; j++){
			st.insert(s.substr(i,j));
		}
	}
	
	for(auto i = st.begin(); ; i++, k--){
		if(k == 1){
			cout << *i << endl;
			break;
		} 
	}
	
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);

            b = int.Parse(word[1]);
            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    map<ll, ll> count;
    rep(i, n) {
        ll num = a[i];
        if (count[num] == 0) {
            count[num] = 1;
        } else {
            count[num]++;
        }
    }
    ll v0 = 0, v1 = 0;

    for (auto iter = count.begin(); iter != count.end(); iter++) {
        if (iter->second >= 4) {
            v0 = iter->first;
            v1 = iter->first;
        } else if (iter->second >= 2) {
            v1 = v0;
            v0 = iter->first;
        }
    }
    cout << v0 * v1 << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 7296
#include<stdio.h>
int main(void)
{
    int n,i;
    double x1,x2,x3,x4,y1,y2,y3,y4,a,b;
    scanf("%d",&n);
        for(i=0;i<n;i++){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        a=(y1-y2)/(x1-x2);
        b=(y3-y4)/(x3-x4);
        if(a==b)printf("YES\n");
        else if(a!=b)printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 0
from operator import mul
from functools import reduce

# 素因数分解して、重複組み合わせを数える。
n,m = map(int,input().split())
MOD = 10**9+7

# 素因数分解
def factorize(n):
    fct = [] # Prime Factor
    b, e = 2, 0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b, e = b+1, 0
    if n>1:
        fct.append((n,1))
    return fct

# 組み合わせ計算(nCr)
def nCr(n,r):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under

f = factorize(m)
ans=1
for p,num in f:
    ans *= nCr(num+n-1,num)
    ans %= MOD
    
print(ans)

Measured memory_bytes: 3828
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void vecOutPadding(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}

template <typename T>
void matOut(vector<vector<T>>& mat) {
	for (const auto& row : mat) {
		for (const T& col : row)
			cout << col << " ";
		cout << endl;
	}
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	ll A, B, C;
	cin >> A >> B >> C;

	if (B >= C) cout << B + C << endl;
	else {
		ll ans = 2 * B;
		C -= B;
		if (A >= C)
			ans += C;
		else
			ans += A + 1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

type City struct {
	n int
	p int
	y int
	c int
}

type Citys []City

func (l Citys) Len() int {
	return len(l)
}

func (l Citys) Less(i, j int) bool {
	return l[i].y < l[j].y
}

func (l Citys) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	citys := make(Citys, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())
		citys[i] = City{i, p, y, 0}
	}

	sort.Sort(citys)
	ans := make([]string, m)
	pl := make(map[int]int, n)
	for i, c := range citys {
		pl[c.p]++
		citys[i].c = pl[c.p]
		ans[c.n] = fmt.Sprintf("%06d%06d", c.p, citys[i].c)
	}

	for _, a := range ans {
		fmt.Println(a)
	}
}


Measured memory_bytes: 14080
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
	char str[101], answer[101];
	scanf("%s", str);
	int lens = strlen(str), i, lena = 0;
	for (i = 0; i < lens; i++)
		switch (str[i])
	{
		case '0':answer[lena] = '0'; lena++; break;
		case '1':answer[lena] = '1'; lena++; break;
		case 'B':if (lena != 0) lena--; break;
	}
	for (i = 0; i < lena; i++)
		printf("%c", answer[i]);
	printf("\n");
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
c = []
for _ in range(h):
    cc = input()
    c.append(cc)

d = 0
kk = 0
g= []
gb=[]
for i in range(2 ** h):
    gg=[]
    for j in range(h):
        if ((i>>j) &1):
            gg.append(j)
    g.append(gg)
for i in range(2 ** w):
    gg=[]
    for j in range(w):
        if ((i>>j) &1):
            gg.append(j)
    gb.append(gg)

for lis in g:
    ii = lis
    for lisj in gb:
        jj = lisj
        for i in range(h):
            if i in ii:
                continue
            for j in range(w):
                if j in jj:
                    continue
                if c[i][j]=='#':
                    kk+=1

        if kk==k:
            d+=1
        kk = 0
print(d)


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

int main(){
	int n; cin >> n;
	string s; cin >> s;
	for(int i = 0; i < s.length(); i++){
		s[i] = 'A' + (s[i] + n - 'A')%26;
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for j in range(n):
    bind = j
    top = n
    bot = -1
    while top-bot > 1:
        mid = (top+bot)//2
        if b[bind] > a[mid]:bot = mid
        else:top = mid
    
    aind = bot
    l = -1
    r = n
   
    while r-l> 1:
   
        cen = (l+r)//2
        if b[bind] < c[cen]:r = cen
        else:l = cen
    cind = r
    ans +=(aind+1)*(n-cind)
    
print(ans)
    

Measured memory_bytes: 23328
from collections import deque


def calc(k):
    if k == 1:
        return 1
    d = {1: 1}
    q = deque([[1, 1]])
    while q:
        n, c = q.popleft()
        a = (n * 10) % k
        if a not in d or c < d[a]:
            d[a] = c
            q.appendleft([a, c])
        b = (n + 1) % k
        if b not in d or c + 1 < d[b]:
            d[b] = c + 1
            q.append([b, c + 1])
    return d[0]


print(calc(int(input())))

Measured memory_bytes: 19728
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var A = sc.nextInt();
	var B = sc.nextInt();
	var C = sc.nextInt();
	var K = sc.nextInt();
	var cnt = K;
	var max = 0;
	
	var oldCnt = cnt;
	cnt -= A;
	max += (cnt > 0) ? A : oldCnt;
	
	if (cnt > 0) {
		cnt -= B;
	}
	if (cnt > 0) {
		var oldCnt = cnt;
		cnt -= C;
		max += (cnt > 0) ? C *-1 : oldCnt*-1;
	}
	
	console.log(max);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


Measured memory_bytes: 29824
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i]=scanner.nextInt();
        }
        bubbleSort(A,N);
    }
     
    static void bubbleSort(int[] A,int N){
    	int count = 0;
    	//i is "sorted"
        //for(int i=N-1;i>0;i--){
        for(int i=0;i<N-1;i++){
        	//for(int j=N-1;j>N-1-i;j--){
            for(int j=N-1;j>i;j--){
        		if(A[j-1] > A[j]){
        			int v = A[j];
        			A[j] = A[j-1];
        			A[j-1] = v;
        			count++;
        		}
        	}
        }
    	printList(A,N);
        System.out.println(count);
    }
    static void printList(int[] A,int N){
        StringBuilder builder = new StringBuilder();
        for(int i=0;i<N;i++){
            if(i>0){
                builder.append(" ");
            }
            builder.append(A[i]);
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 26436
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt(),a = sc.nextInt(),b = sc.nextInt();
    int dis;
    if(a < b){
      dis = b-a;
    }else{
      dis = a-b;
    }
    if(dis <= w){
      System.out.println(0);
    }else{
      System.out.println(dis - w);
    }
  }
}


Measured memory_bytes: 21844