akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

int main() {
  ll a,b,h,m;
  cin >> a >> b >> h >> m;
  double angle;
  angle = 30*h - 5.5*m;
  
  
  
 double ans =  a*a + b*b - 2*a*b*cos(3.141592653589793 / 180 * angle);
 cout << fixed << setprecision(11);
 cout << sqrt(ans) << endl;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
int n;
vector<pair<pair<int,int>,int> >edg;
int main() {
	read(n);
	int p=1,m=n;n=min(524288,n);
	while((1<<(p-1))<n)
		p++;
//	cout<<p<<endl;
	for(int i=1;i<p-1;++i)
		edg.push_back(make_pair(make_pair(i,i+1),0)),
		edg.push_back(make_pair(make_pair(i,i+1),1<<(i-1)));
	edg.push_back(make_pair(make_pair(p-1,p),0));
	int tmp=n;
	n-=(1<<(p-2));
//	cout<<tmp<<" "<<n<<" "<<p<<endl;
	int q=1;
	for(int i=0;i<p-1;++i,q<<=1)
		if(n>>i&1)
			edg.push_back(make_pair(make_pair(i+1,p),tmp-q)),tmp-=q;
	if(m>(1<<19)) {
		tmp=m;
		m-=(1<<19);
		int qi=1;
//		cout<<m<<" "<<oi<<" "<<qi<<endl;
		for(int i=0;i<p-1;++i,qi<<=1)
			if(m>>i&1)
				edg.push_back(make_pair(make_pair(i+1,p),tmp-qi)),tmp-=qi;
	}
	printf("%d %d\n",p,edg.size());
	for(int i=0;i<edg.size();++i)
		printf("%d %d %d\n",edg[i].first.first,edg[i].first.second,edg[i].second);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){

	set<int> s, ans;
	int x;
	rep(i, 4) {
		cin >> x;
		s.insert(x);
	}
	ans.insert(1);
	ans.insert(7);
	ans.insert(9);
	ans.insert(4);

	if (ans == s) cout << "YES" << endl;
	else cout << "NO" << endl;



	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val s = sc.next

  val res = s match {
    case "SUN" => 7
    case "MON" => 6
    case "TUE" => 5
    case "WED" => 4
    case "THU" => 3
    case "FRI" => 2
    case "SAT" => 1
  }

  println(res)
}


Measured memory_bytes: 25876
n = int(input())
for i in range(n):
    x1, y1, r1, x2, y2, r2 = map(float, input().split())
    a = complex(x1, y1)
    b = complex(x2, y2)
    d = abs(a - b)
    if d < r1 - r2:
        print(2)
    elif d < r2 - r1:
        print(-2)
    elif d <= r1 + r2:
        print(1)
    else:
        print(0)

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, c, k; cin >> n >> c >> k;
  int t[n];
  for (int i = 0; i < n; i++) cin >> t[i];
  sort(t, t + n);
  int res = 0;
  int i = 0;
  while (i < n) {
    if (t[min(i + c - 1, n - 1)] <= t[i] + k) {
      i += c;
    } else {
      int j;
      for (j = 1; j < c; j++) if (t[i + j] > t[i] + k) break;
      i += j;
    }
    res++;
  }
  cout << res << "\n";
  return 0;
}

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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N,M,X;
  cin>>N>>M>>X;
  int A[M];
  int cost[N+1];
  memset(cost,0,sizeof(cost));
  for (int i=0; i<M; i++) {
    cin>>A[i];
    cost[A[i]]=1;
  }
  int X_before=0;
  for (int i=X; i>=0; i--) {
    X_before+=cost[i];
  }
  int X_after=0;
  for (int i=X; i<N+1; i++) {
    X_after+=cost[i];
  }
  cout<<min(X_before,X_after)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll dp[N][2],arr[N];
void solve()
{
	int n;
	cin >> n;

	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	memset(dp, 0, sizeof(dp));
	dp[2][1] = arr[2];
	dp[2][0] = arr[1];
	for (int i = 3; i < n + 1; i++)
	{
		if (i & 1)
		{
			ll temp = max({dp[i-3][1],dp[i-3][0],dp[i-2][1],dp[i-2][0]});
			//i为奇数 i要选x个  x=i/2
			//i-1 位置已经维护好 x个  那么只能从 选了x-1的 地方进行转移，很明显i-2   i-3  是维护好了x-1个
			dp[i][1] = arr[i] + temp;

			//dp[i][0]=max({dp[i-1][1],})
			dp[i][0]=max({dp[i-1][1],arr[i-1]+dp[i-3][1],
			arr[i-1]+dp[i-3][0],arr[i-2]+dp[i-3][0]});
			//该位置不选，从 x-1 的两个位置：i-2,i-3转移
		}
		else
		{
			dp[i][1]=arr[i]+max({dp[i-2][1],dp[i-2][0],dp[i-1][0]});///偶数位置 i  要选 i/2个 i-2的位置（i/2-1）
			//以及前一个不选
			dp[i][0] = arr[i-1]+dp[i-2][0];//i不选，一定选i-1  维护前i个必须选i/2个的特性
		}
	}
	cout << max(dp[n][1], dp[n][0]) << endl;
	return;
}

int main()
{
	solve();
	return 0;
}
/*
没有两个相邻的被选上
8
1 2 3 4 -1 -2 -3 -4
*/


Measured memory_bytes: 8284
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, j) = Scanf.sscanf (read_line ())"%d %d" @@ fun n j -> (n, j)
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()
let v = Array.make n 0

let rec tp acc i =
  if v.(i) = 1 then (i, List.rev acc)
  else (v.(i) <- 1; tp (i :: acc) (a.(i) - 1))
let tp = tp [] 0

let rec loop (p, acc) i =
  if i = 0 then print_int (List.hd acc + 1)
  else if p = (List.hd acc) then print_int ((List.nth acc (i mod (List.length acc))) + 1)
  else loop (p, (List.tl acc)) (i - 1)

let () = loop tp j


Measured memory_bytes: 33100
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int IsACGT(char *ch,int n){
    int check=1;
    
    while(n-->0){
        if(*ch!='A' && *ch!='C' && *ch!='G' && *ch!='T')
            return 0;
        ch++;
    }
    
    return 1;
}

int main(void){
    char buf[100];

    my_gets(buf,100,stdin);
    for(int i=strlen(buf);i>0;i--){
        for(int j=0; j<= strlen(buf)-i; j++){
            if(IsACGT(buf+j,i)){
                printf("%d\n",i);
                return 0;
            }
        }
    }
    puts("0");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

int main(){
    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    int sum = 0;
    for(char c:s){
        sum += (c-'0');
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
 cin >> n;
 if(n >63){
	cout << "64" << endl;
  }else if(n >31){
	cout <<"32" << endl;
  }else if(n > 15){
	cout << "16" << endl;
  }else if(n > 7){
	cout << "8" << endl;
  }else if(n > 3){
	cout << "4" << endl;
  }else if(n >2){
 	cout << "2" << endl;
  }else{
	cout << "1" << endl;
  }
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    string S;
    cin >> S;
    bool is_bad = false;
    for(int i = 0; i < 3; i++){
        if(S[i] == S[i+1]){
            is_bad = true;
        }
    }

    if(is_bad){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }


    return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    REP(i,0,100) {
        if(1 + (A - 1) * i >= B) {
            PR(i);
            break;
        }
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3588
a,b,c=map(int,input().split())
if a==b and b==c:
    print(1)
    exit()
elif a==b and a!=c:
    print(2)
    exit()
elif b==c and c!=a:
    print(2)
    exit()
elif c==a and a!=b:
    print(2)
    exit()
else:
    print(3)
    

Measured memory_bytes: 9096
import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val edges = Array<MutableSet<Int>>(n) { mutableSetOf() }

    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt()-1 }
        edges[a].add(b)
        edges[b].add(a)
    }

    val bfs = ArrayDeque<Pair<Int, Int>>(n)
    bfs.addLast(Pair(0, 0))
    val seen = Array(n) {false}
    seen[0] = true

    while(bfs.isNotEmpty()) {
        val node = bfs.removeFirst()

        if (node.first == n-1 && node.second == 2) {
            println("POSSIBLE")
            return
        }

        edges[node.first].forEach {
            if (!seen[it]) {
                seen[it] = true
                bfs.addLast(Pair(it, node.second+1))
            }
        }
    }

    println("IMPOSSIBLE")
}



Measured memory_bytes: 158408
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n, m;
	cin >> n >> m;
	double p = 0;
	int t = m;
	double r = 1;
	double g = 1;
	
	for (int i = n; i >= 1; i--) {
		while (r*i < m) {
			r *= 2;
			g *= 0.5;
		}
		p += g / (double)n;
	//	cout << p << endl;

	}
	cout << setprecision(30);
	cout << p << endl;

	return 0;

}

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

int main(){
    int n, m, i;
    double count=0, all=0;

    cin >> n >> m;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
        all += a[i];
    }
    for(i=0;i<n;i++){
        if(a[i] >= all/(4*m)){
            count++;
        }
    }
    if(count >= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

def f(n, x):
  if x == 1:
    return 1 if n == 0 else 0
  elif x <= 2**(n + 1) - 2:
    return f(n - 1, x - 1)
  elif x == 2**(n + 1) - 1:
    return 2**n
  elif x <= 2**(n + 2) - 4:
    return f(n -1, x - 2**(n + 1) + 1) + 2**n
  else:
     return 2**(n + 1) - 1

ans = f(N, X)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int n, m;
int a[100000];
int good[200002];

signed main() {
	int i;
	
	cin >> n >> m;
	rep(i, n) { cin >> a[i]; a[i]--; }
	
	int iniCnt = 0;
	rep(i, n - 1) {
		int s = a[i];
		int t = a[i + 1];
		if (t < s) { t += m; }
		//cout << "(s, t) = " << s << " " << t << endl;
		iniCnt += t - s;
	}
	//cout << "iniCnt = " << iniCnt << endl;
	
	rep(i, n - 1) {
		int s = a[i];
		int t = a[i + 1];
		if (t < s) { t += m; }
		good[s + 2]++;
		good[t + 1] -= t - s;
		good[t + 2] += (t - s) - 1;
	}
	
	//cout << "good" << endl;
	//rep(i, 2 * m) cout << good[i] << " "; cout << endl;
	
	rep(i, 2 * m) if (i > 0) good[i] += good[i - 1];
	
	//cout << "good" << endl;
	//rep(i, 2 * m) cout << good[i] << " "; cout << endl;
	
	
	rep(i, 2 * m) if (i > 0) good[i] += good[i - 1];
	
	//cout << "good" << endl;
	//rep(i, 2 * m) cout << good[i] << " "; cout << endl;
	
	
	//for (int j = 0; j < m; j++) {
	//	cout << good[j] << "+" << good[m + j] << endl;
	//}
	
	int ans = 1e+15;
	rep(i, m) {
		ans = min(ans, iniCnt - good[i] - good[m + i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func DoWithExostiveBits(n int, fn func([]bool)) {
	N := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < N; i++ {
		for j := 0; j < n; j++ {
			k := n - j - 1
			if i&(1<<uint(j)) == 0 {
				a[k] = false
			} else {
				a[k] = true
			}
		}
		fn(a)
	}
}

func main() {
	defer stdout.Flush()

	s := readString()

	var ans int64
	DoWithExostiveBits(len(s)-1, func(b []bool) {
		prev := 0
		for i, f := range b {
			if f {
				t := s[prev : i+1]
				x, _ := strconv.ParseInt(t, 0, 64)
				ans += x
				prev = i + 1
			}
		}
		t := s[prev:len(s)]
		x, _ := strconv.ParseInt(t, 0, 64)
		ans += x
	})
	println(ans)
}


Measured memory_bytes: 640
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])


Measured memory_bytes: 13908
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int d = sc.nextInt();
        
        if (d < 22) {
            System.out.println(0);
            return;
        }
        if (m < 4) {
            System.out.println(0);
            return;
        }
        
        int count = 0;
        for (int i = 22; i <= d; i++) {
            int a = i / 10;
            int b = i - a * 10;
            
            if (b < 2) continue;
            
            if (a * b <= m) {
                count++;
            }
        }
        
        
        System.out.println(count);
    }
}


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

int main(){
  int X;
  cin >> X;
  
  if (X >= 1800){
    cout << 1 << endl;
  }
  else if (X >= 1600){
    cout << 2 << endl;
  }
  else if (X >= 1400){
    cout << 3 << endl;
  }
  else if (X >= 1200){
    cout << 4 << endl;
  }
  else if (X >= 1000){
    cout << 5 << endl;
  }
  else if (X >= 800){
    cout << 6 << endl;
  }
  else if (X >= 600){
    cout << 7 << endl;
  }
  else if (X >= 400){
    cout << 8 << endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N, K; cin >> N >> K;
    vector<ll> H(N+5,0);
    REP(i,N) cin >> H[i+1];
    ll dp[N+5][K+1];
    REP(i,N+5)REP(j,K+1) dp[i][j] = INF;
    REP(j,K+1)dp[0][j] = 0;
    REP(i,N+5)REP(j,K+1){
        REP(l,K+1){
            if(i+l+1<=N+4 && j+l<=K && dp[i][j] != INF) {
                dp[i+l+1][j+l] = min(dp[i+l+1][j+l], dp[i][j]+max(0LL,H[i+l+1]-H[i]));
            }
        }
    }
    ll ans = INF;
    REP(i,K+1) ans = min(ans, dp[N+1][i]);
    cout << ans << endl;
    return 0;
}

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

int main() {
  vector<int> primes{2};  
  for ( int i = 3; i < 102000; i += 2 ) {
    bool flag = true;
    for ( int j = 3; j <= sqrt(i); j += 2 ) {
      if ( i%j == 0 ) {
	flag = false;
	break;
      }
    }
    if ( flag ) primes.push_back(i);
  }

  int N, P;
  while ( cin >> N >> P, N >= 0 ) {
    int p = upper_bound(primes.begin(), primes.end(), N)-primes.begin();
    vector<int> dat;
    for ( int i = p; i < p+110; i++ ) {
      for ( int j = i; j < p+110; j++ ) {
	dat.push_back(primes[i]+primes[j]);	
      }	
    }

    sort(dat.begin(), dat.end());

    cout << dat[P-1] << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 3160
"use strict"
const YES = 'Yes'
const NO = 'No'
Object.entries = function (object) {
  return Object.keys(object).map(key => [key, object[key]])
}
const countChars = str =>
  Object.entries(str.split('')
    .reduce((c, curr, i) => {
      c[curr] = c[curr] || []
      c[curr].push(i)
      return c
    }, {})
  ).sort((a,b) => a[1].length - b[1].length || a[0].charCodeAt()-b[0].charCodeAt())

    
;(stdin => {
  const input = stdin.split('\n')
  const S = input[0]
  const T = input[1]
  if (S === T) return console.log(YES);
  const charsS = countChars(S)
  const charsT = countChars(T)
  if (charsS.length !== charsT.length) return console.log(NO)
  const startS = charsS.splice(0, 1)[0]
  const startT = charsT.splice(0, 1)[0]
  const startCharS = startS[0]
  const startCharT = startT[0]
  const startIndexesS = startS[1]
  const startIndexesT = startT[1]
  if (startCharS !== startCharT) return console.log(NO)
  if (startIndexesS.length !== startIndexesT.length) return console.log(NO)
  const rotations = []
  const len = S.length
  for (const iS of startIndexesS) {
    for (const iT of startIndexesT) {
      const gap = (iT - iS + len) % len
      if (rotations.indexOf(gap) !== -1) continue;
      rotations.push(gap)
    }
  }
  
  for (let i = 0; i<charsS.length; i++) {
    const charS = charsS[i][0]
    const indexesS = charsS[i][1]
    const charT = charsT[i][0]
    const indexesT = charsT[i][1]
    if (charS !== charT) return console.log(NO)
    if (indexesS.length !== indexesT.length) return console.log(NO)
    for (const iS of indexesS) {
      for (let i=0; i<rotations.length; i++) {
        const rotated = (iS + rotations[i]) % len
        if (indexesT.indexOf(rotated) !== -1) continue;
        rotations.splice(i--, 1)
      }
      if (!rotations.length) return console.log(NO)
    }
  }
  console.log(YES)
})(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7500
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "begin", long, "end");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();
    auto diff = new long[](n - 1);
    long x = a[0];
    foreach (i; iota(1, n))
        x = gcd(a[i], x);
    long m = a.reduce!(max);
    // x.writeln();
    if (k <= m && k % x == 0)
        writeln("POSSIBLE");
    else
        writeln("IMPOSSIBLE");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 6200
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll r=10, ans=0;
    while(N/r!=0){
        ans+=N/r;
        r*=5;
    }
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string input;
  sc.scan(input);

  char[] S = new char[input.length];

  long len = input.length;
  int zeroNum = 0;
  int oneNum = 0;
  foreach (i; 0 .. len) {
    S[i] = to!char(input[0]);
    input.popFront;
    if (S[i] == '0')
      zeroNum++;
    else if (S[i] == '1')
      oneNum++;
  }

  if (oneNum == zeroNum) {
    writeln(oneNum + zeroNum);
    return;
  }

  writeln((zeroNum + oneNum) - abs(zeroNum - oneNum));
}


Measured memory_bytes: 2584
#include<stdio.h>
#include<string.h>

int main(void){
  char in[250];
  int i;
  gets(in);

  for(i=0;i<strlen(in);i++){
    if(in[i]>=97&&in[i]<=122){
      in[i]-=32;
    }
  }

  for(i=0;i<strlen(in);i++){
    printf("%c",in[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 524
// author - shreyanshjn (Shreyansh Jain)
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
/* #define input 1 */
#define INF 100000000000000000
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
const int mod = 1e9 + 7;
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string trim(const string& str) {
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
class Vacation {
public:
    int a, b, c;
};

int main() { 
    #ifdef input
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(15);
    int n; cin >> n;
    Vacation arr[n];
    fori(0, n) {
        cin >> arr[i].a >> arr[i].b >> arr[i].c;
    }
    int dp[n][3];
    dp[0][0] = arr[0].a;
    dp[0][1] = arr[0].b;
    dp[0][2] = arr[0].c;
    fori(1, n) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + arr[i].a;
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + arr[i].b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[i].c;
    }
    cout << max(max(dp[n-1][0], dp[n-1][1]),dp[n-1][2]) << endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


Measured memory_bytes: 6080
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        char[] sc = S.toCharArray();
        char[] tc = T.toCharArray();

        if((tc.length - sc.length) > 1) {
            System.out.println("No");
        }

        // char[] ns = new char[sc.length+1];

        for (int i = 0; i < tc.length; i++) {
            if(i < sc.length && sc[i] != tc[i]){
                System.out.println("No");
                break;
            }

            if(i == tc.length-1) {
                System.out.println("Yes");
            }
        }

    }
}

Measured memory_bytes: 35636
#include<iostream>
#include<cstring>
using namespace std;
void dfs(int b[11],int c[11],int m,int k,int t);//a中，b中，c中游标
int a[10];
int flag;
int main()
{
	int N;
	cin >> N;
	while (N--)
	{
		for (int i = 0; i < 10; i++)
			cin >> a[i];
		int b[10];
		int c[10];
		b[0] = 0;
		c[0] = 0;
		flag = 0;
		dfs(b, c, 0, 0, 0);
		if (flag== 1)
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
	}
	return 0;
}
void dfs(int b[11], int c[11], int m, int k, int t)
{
	int ma = m;
	int kb = k;
	int tc = t;
	int i;
	int x[11], y[11];             //用x,y去中间值，好进行回溯
	if (ma == 10)
		flag=1;
	else
	{
		for (i = 0; i <= kb; i++)
		{
			x[i] = b[i];
		}
		for (i = 0; i <= tc; i++)
		{
			y[i] = c[i];
		}
		/*if (x[kb] > a[ma] && y[tc] > a[ma])  //两个都大  不要直接return 应该返回 找其他的枝丫
			return 0;*/
		if (x[kb] > a[ma] && y[tc] < a[ma])
		{ 
			tc++;
			y[tc] = a[ma];
			ma++;
			dfs(x, y, ma, kb, tc);
		}
		else if (x[kb] < a[ma] && y[tc] > a[ma])
		{
			kb++;
			x[kb] = a[ma];
			ma++; 
			dfs(x, y, ma, kb, tc);
		}
		else if (x[kb] < a[ma] && y[tc] < a[ma])
		{
			kb++;
			x[kb] = a[ma];
			ma++;
			dfs(x, y, ma, kb, tc);
			ma--; kb--;
            tc++;
			y[tc] = a[ma];
			ma++;
			dfs(x, y, ma, kb, tc);
			ma--; tc--;
		}
	}
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define pb push_back
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ll long long int
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}


void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	//cin>>n;
    char c;
  cin>>c;
  if(c>=97)
    cout<<'a';
  else cout<<'A';
    
}
int main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
from collections import deque

N = int(input())
A = list(map(int, input().split()))

A.sort()
A = A[::-1]

comfort_queue = deque()
comfort_queue.append(A[0])

score=0
for i in range(1,N):
    comfort_queue.extend([A[i],A[i]])
    now_score = comfort_queue.popleft()
    score += now_score

print(score)

Measured memory_bytes: 32408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 300;
const int maxm = 10000;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n;
int A[maxn],b[maxn];
int c[maxn],d[maxn];
int a[305][305];
int vis[maxn];
int mode[maxn];
int find(int x)
{
    for(int i = 1;i<=n+n;i++)
    {
        if(a[x][i]&&!vis[i])
        {
            vis[i] = 1;
            if(!mode[i]||find(mode[i]))
            {
                mode[i] = x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    cin>>n;
    for(int i = 1;i<=n;i++) cin>>A[i]>>b[i];
    for(int i = 1;i<=n;i++) cin>>c[i]>>d[i];
    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            if(A[i]<c[j]&&b[i]<d[j])a[i][j+n] = 1;
        }
    }
    for(int i = 1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        if(find(i)) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n >> k ;
	if(n >= 13)
		cout << k << endl ;
	else if(n < 13 && n > 5)
		cout << (k / 2) << endl ;
	else
		cout << 0 << endl ;
}





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


int main()
{
  vector<int> zahyou(5);
  bool judge=0;
  int k;
  
  for(int i=0;i<5;i++){
    cin >> zahyou.at(i);
  }
  
  cin >> k;
  
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(zahyou[j]-zahyou[i]>k){
        judge = 1;
      }
    }
  }
  
        
  if(judge==1)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/*int Search(vector <long long int>v3,long long int n,long long int x){
      long long int low=0;
      long long int high=(n-1);
      while(low<=high){
         long long int mid=low+(high-low)/2;
          if(x==v3[mid]) return mid;
          if(x<v3[mid]) high=mid-1;
          if(x>v3[mid]) low=mid+1;
      }
    return -1;
}*/
int main()
{
    long long int ne,n,k,x,i,count=500,h,g,l,ish=500,r;
    vector<long long int> v;
    vector<long long int> v2;
    vector<long long int> v3;
    vector<long long int> fv;
    long long a[10];
    cin>>n>>k;
    for(i=0;i<10;i++){a[i]=0;}
    for(i=0;i<k;i++){
        cin>>x;
        a[x]++;
    }
  //cout<<a[0];
  for(i=0;i<10;i++){if(a[i]==0){v2.push_back(i);}}
  //cout<<v2[0];
   while(n>0){
       r=n%10;
      v3.push_back(r);
      n=n/10;
    }
    //cout<<v3[3]<<" "<<v3[2]<<" "<<v3[1]<<" "<<v3[0]<<"finish ";
    for(i=v3.size()-1;i>-1;i--){
        //cout<<a[v3[i]];
        if(a[v3[i]]==0)
        {fv.push_back(v3[i]);}
        else{
            if(v3[i]<9){
                while(a[v3[i]]!=0){v3[i]++;}
                if(v3[i]==10){g=i;count*=0;break;}
                ish*=0;fv.push_back(v3[i]);g=i;break;}
            else{g=i;
                count*=0;break;
            }
        }    
    }
    
    if(ish==0){for(h=g-1;h>=0;h--){fv.push_back(v2[0]);}}
    if(count==0&&ish!=0){for(h=g;h>=-1;h--){fv.push_back(v2[0]);}}
    for(l=0;l<fv.size();l++){cout<<fv[l];}
    return 0;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N, L = map(int, input().split())
a = [0]*( N+1)

for i in range(1, N+1):
    a[i] = L + i - 1

tmp = sum(a)

cnt = int(1e18)
ans = int(1e18)

for i in range(1, N+1):
    now = tmp - (tmp - a[i])
    if abs(now) < cnt:
        cnt = abs(now)
        ans = tmp - a[i]
print(ans)


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int cnt = 0;
L1:
    while(true) {
        for(int i = 0; i < n; i++) {
            if(a[i] % 2 != 0) {
                cout << cnt << endl;
                return 0;
            }
            a[i] /= 2;
        }
        cnt++;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

ll modpow(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) {
		return x % MOD;
	}
	else if (y % 2 == 0) {
		ll dst = modpow(x, y / 2);
		return dst * dst % MOD;
	}
	else if (y % 2 == 1) {
		ll dst = modpow(x, y / 2);
		return dst * dst * x % MOD;
	}
}

ll calc(ll N) {
	ll dst1 = modpow(N, 3)*2;
	ll dst2 = modpow(N, 2)*3;
	return (((dst1 * dst2) % MOD) * N) % MOD / 6;
}

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());

	ll N, M;
	cin >> N >> M;

	vl S(N), T(M);
	rep(i, N) {
		cin >> S[i];
	}
	rep(i, M) {
		cin >> T[i];
	}

	vvl DP(3000, vector<ll>(3000, 1));
	vvl SUM(3000, vector<ll>(3000, 0));
	ll A;

	ll count = 0;
	//ll DP[3000];
	//DP[0] = 1;

	rep(i, N) {
		rep(k, M) {
			if (S[i] == T[k]) {
				DP[i + 1][k + 1] = (DP[i + 1][k] + DP[i][k + 1]) % MOD;
			}
			else {
				DP[i + 1][k + 1] = (DP[i + 1][k] + DP[i][k + 1] - DP[i][k]) % MOD;
			}
		}
	}


	cout << (DP[N][M]+MOD)%MOD << endl;


	return 0;
}



Measured memory_bytes: 141184
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;


int a, b, c;
int ans;

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


  if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
      cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

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

int main()
{
	vector<char> alphabet{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
						  'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
	string s;
	cin >> s;

	bool flag = false;

	rep(i, alphabet.size())
	{
		rep(j, s.length())
		{
			if (alphabet[i] == s[j])
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout << alphabet[i] << endl;
			return 0;
		}
		flag = false;
	}
	cout << "None" << endl;
	return 0;
}

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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int n, m; cin>>n>>m;
	vector< int > s(m), c(m);
	for(int i = 0; i<m; i++){
		cin>>s[i]>>c[i];
		s[i]--;
	}
	for(int i = 0; i<1000; i++){
		bool ok = 1;
		vector< int > num;
		int x = i;
		while(x){
			num.push_back(x%10);
			x /= 10;
		}
		if(i == 0) num.push_back(0);
		reverse(num.begin(), num.end());
		for(int j = 0; j<m; j++){
			if(num[s[j]] != c[j]) ok = 0;
		}
		if(n != 1 && (0 <= i && i <= 9)) ok = 0;
		else if(n != 2 && (10 <= i && i <= 99)) ok = 0;
		else if(n != 3 && (100 <= i && i <= 999)) ok = 0;
		if(ok){
			cout<<i<<endl;
			return;
		}
	}
	cout<<-1<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

signed main()
{
    
    speed
    set <int> s;
    fn(i,3){
      int x;cin>>x;
      s.insert(x);
    }
    if(s.size()==2){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }

   
 
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>

using namespace std;


int main() {
	int n, k,ans = 0;
	cin >> n >> k;

	vector<int> d(100);
	vector<int> a(100);
	vector<int> sunu(n);

	for (int i = 0; i < n; i++) {
		sunu[i] = i + 1;
	}
	for (int i = 0; i < k; i++) {
		cin >> d[i];
		for (int j = 0; j < d[i]; j++) {
			cin >> a[j];
			for (int k = 0; k < n; k++) {
				if (sunu[k] == a[j]) {
					sunu[k] = 0;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (sunu[i] == 0) {
			ans++;
		}
	}
	
	cout << n - ans << endl;
}


Measured memory_bytes: 3192
n,k=map(int,input().split())

d={}
for _ in range(n):
    a_i,b_i=map(int,input().split())
    if a_i in d:
        d[a_i]+=b_i
    else:
        d[a_i]=b_i


a=[]
b=[]

d=sorted(d.items(),key=lambda x: x[0])


prev=0
for key,value in d:
    a.append(key)
    b.append(prev+value)

    prev+=value


for j in range(len(b)):
    if k<=b[j]:
        break

print(a[j])


Measured memory_bytes: 15584
n,m = map(int,input().split())

a_list = []
b_list = []
ans = "No"

for i in range(n):
    a_list.append(input())

for i in range(m):
    b_list.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        match = True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][l+j] != b_list[k][l]:
                    match = False
        if match:
            ans = "Yes"
            break

print(ans)


Measured memory_bytes: 9100
n = input()
a_list = list(map(int, input().split())) 
cnt = 0
tmp = 0

for a in range(len(a_list)-1):
    if (a_list[a] > a_list[a+1]):
        cnt += a_list[a] -a_list[a+1]
        a_list[a+1] += a_list[a] -a_list[a+1]
        # print(cnt)

print(cnt)


Measured memory_bytes: 32388
import java.util.*;

// ARC 84-A
// https://beta.atcoder.jp/contests/arc084/tasks/arc084_a

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

		int N = in.nextInt();
		
		ArrayList<Integer> A = new ArrayList<Integer>();
		ArrayList<Integer> B = new ArrayList<Integer>();
		ArrayList<Integer> C = new ArrayList<Integer>();
		
		TreeSet<Integer> aSet = new TreeSet<Integer>();
		TreeSet<Integer> bSet = new TreeSet<Integer>();
		TreeSet<Integer> cSet = new TreeSet<Integer>();
		
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			A.add(n);
		}
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			B.add(n);
			bSet.add(n);
		}
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			C.add(n);
			cSet.add(n);
		}
		
		A.sort(null);
		B.sort(null);
		C.sort(null);
		
		long[] temp = new long[N];
		for (int i = 0; i < N; i++) {
			Integer c = cSet.higher(B.get(i));
			
			if (c != null) {
				int index = binarySearch3(C, c);
				temp[i] = (N - index);
			}
		}
		
		for (int i = N - 2; i >= 0; i--) {
			temp[i] += temp[i + 1];
		}
		
		long answer = 0;
		for (int i = 0; i < A.size(); i++) {
			Integer b = bSet.higher(A.get(i));
			
			if (b != null) {
				int index = binarySearch3(B, b);
				answer += temp[index];
			}
		}
		System.out.println(answer);
	}
	
	public static int binarySearch1(int[] arr, int n) {
		int low = 0;
		int high = arr.length - 1;
		
		while (low <= high) {
			int mid = (low + high) / 2;
			
			if (arr[mid] == n && (mid == arr.length - 1 || arr[mid + 1] != arr[mid])) {
				return mid;
			} else if (arr[mid] > n) {
				high = mid - 1;
			} else {
				low = mid + 1;
			}
		}
		return -1;
	}
	
	public static int binarySearch2(int[] arr, int n) {
		int low = 0;
		int high = arr.length - 1;
		
		while (low <= high) {
			int mid = (low + high) / 2;
			
			if (arr[mid] == n && (mid == 0 || (mid > 0 && arr[mid - 1] != arr[mid]))) {
				return mid;
			} else if (arr[mid] < n) {
				low = mid + 1;
			} else {
				high = mid - 1;
			}
		}
		return -1;
	}
	
	public static int binarySearch3(ArrayList<Integer> arr, int n) {
		int low = 0;
		int high = arr.size() - 1;
		
		while (low <= high) {
			int mid = (low + high) / 2;
			
			if (arr.get(mid) == n && (mid == 0 || (mid > 0 && !arr.get(mid - 1).equals(arr.get(mid))))) {
				return mid;
			} else if (arr.get(mid) < n) {
				low = mid + 1;
			} else {
				high = mid - 1;
			}
		}
		return -1;
	}
}


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

#define x first
#define y second

typedef std::pair<int, int> point;
const int N = 600005;

int totx, toty, vx[N], vy[N], ans;
int w, h, n;

point p[N];

int tag[N << 2], max[N << 2];

void pushup(int o) { max[o] = std::max(max[o << 1], max[o << 1 | 1]) + tag[o]; }
void build(int o = 1, int l = 0, int r = toty - 1) {
	tag[o] = 0;
	if (l == r) { max[o] = -vy[l] + w; return; }
	int mid = l + r >> 1;
	build(o << 1, l, mid), build(o << 1 | 1, mid + 1, r), pushup(o);
}
void modify(int L, int R, int v, int o = 1, int l = 0, int r = toty - 1) {
	if (L > R) return;
	if (L <= l && R >= r) { tag[o] += v, max[o] += v; return; }
	int mid = l + r >> 1;
	if (L <= mid) modify(L, R, v, o << 1, l, mid);
	if (R > mid) modify(L, R, v, o << 1 | 1, mid + 1, r);
	pushup(o);
}

void solve() {
	int mid = std::upper_bound(vx, vx + totx, w >> 1) - vx - 1;
	build();
	std::sort(p + 1, p + n + 1, [&] (point a, point b) { return a.y != b.y ? a.y < b.y : std::abs(a.x - mid) > std::abs(b.x - mid); });
	std::stack<int> L, R;
	p[0] = point(mid, 0), L.emplace(0), R.emplace(0);
	for (int y = 0, i = 0; y < toty; ++y) {
		ans = std::max(ans, vy[y] + max[1]);
		for (; i <= n && p[i].y == y; ++i)
			if (p[i].x <= mid) {
				modify(p[L.top()].y, y - 1, -vx[p[i].x]);
				while (p[L.top()].x < p[i].x) {
					point lst = p[L.top()]; L.pop();	
					modify(p[L.top()].y, lst.y - 1, vx[lst.x] - vx[p[i].x]);
				}
				L.emplace(i);
			} else {
				modify(p[R.top()].y, y - 1, vx[p[i].x] - w);
				while (p[R.top()].x > p[i].x) {
					point lst = p[R.top()]; R.pop();
					modify(p[R.top()].y, lst.y - 1, vx[p[i].x] - vx[lst.x]);
				}
				R.emplace(i);
			}
	}
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> w >> h >> n, ans = std::max(w, h) + 1;
	vx[0] = vy[0] = 0;
	for (int i = 1; i <= n; ++i) {
		std::cin >> p[i].x >> p[i].y; 
		if (p[i].x == 0 || p[i].x == w || p[i].y == 0 || p[i].y == h)
			{--i, --n; continue; }
		vx[i] = p[i].x, vy[i] = p[i].y;
	}
	vx[n + 1] = w, vy[n + 1] = h;
	totx = toty = n + 2;
	totx = (std::sort(vx, vx + totx), std::unique(vx, vx + totx) - vx);
	toty = (std::sort(vy, vy + toty), std::unique(vy, vy + toty) - vy);
	for (int i = 1; i <= n; ++i)
		p[i].x = std::lower_bound(vx, vx + totx, p[i].x) - vx, p[i].y = std::lower_bound(vy, vy + toty, p[i].y) - vy;
	solve();
	std::swap(w, h), std::swap(totx, toty), std::swap(vx, vy);
	for (int i = 1; i <= n; ++i) std::swap(p[i].x, p[i].y);
	solve();
	std::cout << ans * 2 << '\n';
	return 0;
}

Measured memory_bytes: 22924
N=int(input())
S=list(map(int,input().split()))

ans=10**10

for i in range(0,N-1):
    B_goukei=0
    A_goukei=0
    for j in range(0,i+1):
        B_goukei+=S[j]
    for j in range(i+1,N):
        A_goukei+=S[j]

    if ans>abs(B_goukei-A_goukei):
        ans=abs(B_goukei-A_goukei)
print(ans)
    

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

int main()
{
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  rep(i, N) {
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }

  bool can = true;

  rep(i, N) {
    // 経過秒数
    int dt = t[i+1] - t[i];

    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }

  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 4732