akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	int [] vx = {-1,0,1,0};
	int [] vy = {0,1,0,-1};
	int INF = 1 << 24;
	
	class C{
		int x,y,s;

		public C(int x, int y, int s) {
			super();
			this.x = x;
			this.y = y;
			this.s = s;
		}
		
	}
	
	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0) break;
			int ww = w + w - 1;
			int hh = h + h - 1;
			//System.out.println(ww + " " + hh);
			sc.nextLine();
			int [][]  data = new int[hh][ww];
			for(int i = 0; i < hh; i++){
				String line = sc.nextLine();
				//System.out.println(line);
				String newline;
				if(i % 2 == 0){
					newline = line.replaceAll(" ", "0");
				}
				else{
					newline = line.replaceAll(" ", "1");
				}
				for(int j = 0; j < newline.length(); j++){
					int num = newline.charAt(j) - '0';
					data[i][j] = num;
				}
			}
			
//			//debug
//			for(int i =0; i < hh; i++){
//				for(int j = 0; j < ww; j++){
//					System.out.print(data[i][j]);
//				}
//				System.out.println();
//			}
			LinkedList<C> open = new LinkedList<Main.C>();
			open.add(new C(0,0,1));
			int [][] close = new int[hh][ww];
			for(int i=0; i < hh; i++){
				Arrays.fill(close[i], INF);
			}
			close[0][0] = 0;
			int ans = INF;
			while(! open.isEmpty()){
				C now = open.removeFirst();
				boolean flg = false;
				for(int i=0; i < 4; i++){
					int xx = now.x + vx[i] * 2;
					int yy = now.y + vy[i] * 2;
					if(! isOK(xx,yy, ww,hh)){
						continue;
					}
					int xxx = now.x + vx[i];
					int yyy = now.y + vy[i];
					if(data[yyy][xxx] == 1) continue;
					if(close[yy][xx] <= now.s + 1) continue;
					if(xx == ww -1 && yy == hh -1){
						ans = now.s+1;
						flg = true;
						break;
					}
					open.add(new C(xx,yy,now.s+1));
					close[yy][xx] = now.s + 1;
				}
				if(flg ) break;
			}
			System.out.println(ans == INF ? 0 : ans);
		}
		
	}
	private boolean isOK(int xx, int yy,int w, int h) {
		if(0 <= xx && xx < w && 0<= yy && yy < h){
			return true;
		}
		return false;
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
   
   
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
   
   
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
   
def tree_find(top, k):
    x = top
    while x != None and k != x.key:
        if k < x.key:
            x = x.left
        else:
            x = x.right
    return x


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
   
   
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
   
   
n = int(stdin.readline())
   
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    elif cmd.startswith('f'):
        key = int(cmd[5:])
        if tree_find(top, key) != None:
            print('yes')
        else:
            print('no')
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Measured memory_bytes: 171328
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val tasks = Array(n) {
        val (a, b) = readLongList()
        Pair(a, b)
    }.sortedBy { it.second }

    var current = 0L
    for (task in tasks) {
        current += task.first
        if (current > task.second) {
            out.println("No")
            return
        }
    }
    out.println("Yes")
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 77972
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    A.sort(reverse=True)
    sa = sum(A)
    t = sa / (4 * M)
    flg = True
    for i in range(M):
        if A[i] < t:
            flg = False
            break
    if flg:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


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

int main() {
  int A,B,C; //値段用の箱を宣言
  int X,Y; //個数用の箱を宣言
  int ans=9999999999;
  int sum=0;
  
  /////入力部/////
  cin>>A>>B>>C; //金額
  cin>>X>>Y; //個数
 
  for(int i=0;i<=100000;i++){
    sum=2*C*i + A*max(0,X-i) +B*max(0,Y-i);
    if(sum<ans)ans=sum;
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3584
import sys
import numpy as np 
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n = int(sys.stdin.readline().rstrip())
A = np.array(sys.stdin.read().split(), dtype=np.float64).reshape(n, n)

def main():
    B = floyd_warshall(csr_matrix(A), directed=False)
    if np.any(B < A):
        return -1
        
    np.fill_diagonal(B, np.inf)
    
    total_length = 0
    for v in range(n-1):
        for u in range(v+1, n):
            detours = B[v] + B[u]
            if np.all(detours > B[v, u]):
                total_length += B[v, u]

    return int(total_length)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 28060
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
char s[11];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s;
	int n=strlen(s);
	n--;
	ll ans=0;
	for(int i=0;i<(1<<n);i++){
        ll ret=0;
        for(int j=0;j<n;j++){
            ret=ret*10+s[j]-'0';
            if((i>>j)&1){
                ans+=ret;
                ret=0;
            }
        }
        ret=ret*10+s[n]-'0';
        ans+=ret;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n, q;
	cin >> n >> q;
	Vec s(n), t(n), x(n);
	rep(i, n) cin >> s[i] >> t[i] >> x[i];
	Vec d(q);
	rep(i, q) cin >> d[i];

	rep(i, n) s[i] -= x[i], t[i] -= x[i];

	VecP u(n), v(n);
	rep(i, n) u[i] = {s[i], x[i]};
	rep(i, n) v[i] = {t[i], x[i]};
	sort(all(u));
	sort(all(v));

	multiset<ll> st;

	ll p1 = 0, p2 = 0;
	rep(i, q){
		while(p1 < n){
			if(u[p1].fs > d[i]) break;
			st.insert(u[p1++].sc);
		}
		while(p2 < n){
			if(v[p2].fs > d[i]) break;
			st.erase(st.find(v[p2++].sc));
		}

		auto it = st.lower_bound(0);
		if(it == st.end()) co(-1);
		else co(*it);
	}

	return 0;
}


Measured memory_bytes: 23168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	long long n, a, b;
	cin >> n >> a >> b;
	
	cout << a * (n / (a + b)) + min(a, n % (a + b)) << endl;
}

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

void solve()
{
	int n, d, cnt = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		if(sqrt(x*x + y*y) <= d) cnt++;
	}
	cout << cnt;
}

int main()
{
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
		cout << '\n';
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
	if (A + B < C + D) {
		printf("Right\n");
	}
	else if (A + B > C + D) {
		printf("Left\n");
	}
	else {
		printf("Balanced\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

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

  vec<int> num(26,0);
  REP(i,s.size()) ++num[s[i]-'a'];

  char ans='0';
  REP(i,26){
    if(!num[i]){
      ans = i+'a';
      break;
    }
  }

  if(ans == '0'){
    cout <<"None" <<endl;
  }else{
    cout <<ans <<endl;
  }
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String line = scanner.nextLine();
        final long k = scanner.nextLong();
 
        if (all(line)) {
            System.out.println(line.length() * k / 2);
            return;
        }
 
        long cost = 0;
        for (int i = 0; i < line.length() - 1; i++) {
            if (line.charAt(i) != line.charAt(i + 1)) {
                continue;
            }
 
            cost++;
            i++;
        }
 
        cost *= k;
 
        if (line.charAt(0) == line.charAt(line.length() - 1)) {
            final char begin = line.charAt(0);
            int a;
            for (a = 1; a < line.length() && line.charAt(a) == begin; a++) ;
 
            final char end = line.charAt(line.length() - 1);
            int b;
            for (b = 1; b < line.length() && line.charAt(line.length() - 1 - b) == end; b++) ;
 
            cost += (k - 1) * ((a + b) / 2 - a / 2 - b / 2);
        }
 
        System.out.println(cost);
    }
 
    private static boolean all(final String string) {
        final char c = string.charAt(0);
        for (int i = 1; i < string.length(); i++) {
            if (string.charAt(i) != c) {
                return false;
            }
        }
        return true;
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, K;
  scanf("%d %d", &N, &K);
  vector<ll> X(N), Y(N);
  vector<ll> px(N), py(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &X[i], &Y[i]);
    px[i] = X[i], py[i] = Y[i];
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans = numeric_limits<ll>::max();
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int l = k + 1; l < N; ++l) {
          int cnt = 0;
          ll left = X[i], right = X[j];
          ll bottom = Y[k], top = Y[l];
          for (int p = 0; p < N; ++p) {
            if (left <= px[p] and px[p] <= right and bottom <= py[p] and py[p] <= top) {
              ++cnt;
            }
          }
          if (cnt >= K) {
            ans = min(ans, (right - left) * (top - bottom));
          }
        }
      }
    }
  }

  printf("%lld\n", ans);
  return 0;
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int r, g, b;
            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0] + str[1] + str[2]);

            if (n % 4 == 0)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        Console.ReadLine();
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Count(x => x % 2 == 1) % 2 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 18144
#include <iostream>
using namespace std;
 
int main() 
{
  int n;
  cin >> n;
  int a;
  a = n/100;
  if(a*111 < n){
    a = (a+1)*111;
  }else{
    a = a*111;
  }
  cout << a << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;
using ll = long long;

void bubbleSort(string *s, int n) {
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if ((int)s[j][1] < (int)s[j - 1][1]) {
        string v = s[j];
        s[j] = s[j - 1];
        s[j - 1] = v;
      }
    }
  }
}

void selectionSort(string *s, int n) {
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if ((int)s[j][1] < (int)s[minj][1]) {
        minj = j;
      }
    }
    if (i != minj) {
      string v = s[i];
      s[i] = s[minj];
      s[minj] = v;
    }
  }
}

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

  string s[n], sc[n];
  rep(i, n) {
    cin >> s[i];
    sc[i] = s[i];
  }

  bubbleSort(sc, n);
  selectionSort(s, n);

  string result = "Stable";
  rep(i, n) {
    if (sc[i] != s[i]) {
      result = "Not stable";
    }
  }

  rep(i, n) {
    cout << sc[i];
    if (i != n - 1) cout << " ";
  }
  cout << endl;
  cout << "Stable" << endl;

  rep(i, n) {
    cout << s[i];
    if (i != n - 1) cout << " ";
  }
  cout << endl;
  cout << result << endl;

  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

struct UnionFind {
    vector<int> par;
    vector<int> weight;

    UnionFind(int N) : par(N), weight(N) {
        REP(i, N) {
            par[i] = i;
            weight[i] = 1;
        }
    }

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

    ll unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return 0;
        par[rx] = ry;
        ll res = weight[rx] * weight[ry];
        weight[ry] += weight[rx];
        return res;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    ll N, M; cin >> N >> M;
    vector<int> A(M), B(M); REP(i, M) {cin >> A[i] >> B[i]; A[i]--; B[i]--;}

    UnionFind tree(N);
    vector<ll> inconvinience(M);
    inconvinience[M-1] = N * (N-1) / 2;
    for (int i = M-1; i > 0; i--) {
        inconvinience[i-1] = inconvinience[i] - tree.unite(A[i], B[i]);
    }
    REP(i, M) PRINT(inconvinience[i]);
    return 0;
}

Measured memory_bytes: 5900
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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

   int sum = 0;
  
  int flag = 0;
  
 for(int i = 0;i<1000000;i++){
   
     sum = sum + n;
     
     if(sum%m==l){
       
       cout << "YES" << endl;
       flag = 1;
       break;
     }
     
     
   }
  
  if(flag == 0){
  cout << "NO" << endl;
  
  }
  return 0;
  
}



Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toLong).toArray).head
  val A = ls(0)
  val B = ls(1)
  val ret = if(B % A == 0) A + B else B - A  
  println(ret)
}


Measured memory_bytes: 25540
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int x,y;
int nx,ny;
int main() {
  cin >> x >> y;
  nx = abs(x);
  ny = abs(y);
  int result;
  result = 0;
  if (x == 0 and y == 0){
    cout << 0 << endl;
    return 0;
  }
  if (x != 0 and y == 0){
      if (x > 0){
        result++;
        result += nx;
      }else{//x < 0
        result += nx;
      }
    }
  if (x == 0 and y != 0){
    if (y > 0){
      result += ny;
    }else{//y < 0
      result += ny;
      result++;
    }
  }
  if (x > 0 and y < 0){
    if (abs(x) >= abs(y)){
      result++;
      result += abs(nx - ny);
    }else{//abs(x) < abs(y)
      result += abs(nx - ny);
      result++;
    }
  }else if(x > 0 and y > 0){
    if (abs(x) >= abs(y)){
      result++;
      result += abs(nx - ny);
      result++;
    }else{//x < y
      result += abs(nx - ny);
    }
  }else if(x < 0 and y > 0){
    if (abs(x) >= abs(y)){
      result++;
      result += abs(nx - ny);
    }else{//abs(x) < abs(y)
      result += abs(nx - ny);
      result++;
    }
  }else if(x < 0 and y < 0){
    if (abs(x) >= abs(y)){
      result += abs(nx - ny);

    }else{//abs(x) < abs(y)
      result++;
      result += abs(nx - ny);
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin >> x;
    int y=x%7;
    if(y==1){
        cout << "fri" << endl;
    }
    else if(y==2){
        cout << "sat" << endl;
    }
    else if(y==3){
        cout << "sun" << endl;
    }
    else if(y==4){
        cout << "mon" << endl;
    }
    else if(y==5){
        cout << "tue" << endl;
    }
    else if(y==6){
        cout << "wed" << endl;
    }
    else if(y==0){
        cout << "thu" << endl;
    }
}



Measured memory_bytes: 3104
from string import ascii_lowercase
D = {k:i for i, k in enumerate(ascii_lowercase)}

s = input()
n = len(s)
lst = [[] for _ in range(26)]

for i in range(n):
    lst[D[s[i]]].append(i)
# print(lst)

ans = n//2
for i in range(26):
    nums = lst[i]
    if len(nums) > 0:
        tmp = lst[i][0]
        for j in range(len(nums)-1):
            tmp = max(tmp, lst[i][j+1] - lst[i][j] - 1)
        tmp = max(tmp, n - lst[i][-1] - 1)
        ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 3828
N = gets.to_i
V = gets.split.map &:to_i
E, O = V.partition.with_index{|v, i|
  i.even?
}
M = N / 2
# p E, O

ee = E.group_by(&:itself).map{|k, v| [k, v.size]}.sort_by{|k, v| -v }
oo = O.group_by(&:itself).map{|k, v| [k, v.size]}.sort_by{|k, v| -v }
ee << [-1, 0]
oo << [-1, 0]

ek, ev = ee[0]
ok, ov = oo[0]
ek1, ev1 = ee[1]
ok1, ov1 = oo[1]

# p ee,oo

if ek != ok
  p M - ev + M - ov
else
  if ev + ov1 > ev1 + ov
    p M - ev + M - ov1
  else
    p M - ev1 + M - ov
  end
end


Measured memory_bytes: 25300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  bool flag=false;
  rep(i,n){
   if(a[i]%2==1)flag=true; 
  }
  if(!flag)cout << "second" << endl;
  else cout << "first" << endl;
return 0;}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);

    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    int count = 0;

    for (int i = 1; i < N - 1; i++) {
        int P0 = P[i - 1];
        int P1 = P[i];
        int P2 = P[i + 1];

        if (P0 <= P1 && P1 <= P2) {
            count++;
        }
        else if (P2 <= P1 && P1 <= P0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int simulate(int A, int B, int C)
{
	int ans = 0;
	while (B <= A) {
		B *= 2;
		++ans;
	}
	while (C <= B) {
		C *= 2;
		++ans;
	}
	return ans;
}


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

	if (simulate(A, B, C) <= K) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int myPow(int x, int p) {
  if (p == 0) return 1;
  if (p == 1) return x;
  return x * myPow(x, p-1);
}
int main(){
  int N,K;
  cin>>N>>K;
  if (N==1) cout<<K<<endl;
  else cout<<(K*myPow(K-1,N-1) )<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    ll cnt = 0;
    rep(i, n) if (s[i] != t[i]) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll k, x;
  cin >> k >> x;

  for (ll i = x - k + 1; i <= x + k - 1; i++)
    cout << i << " ";
  cout << en;

  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            HashMap<Character, Integer> m = new HashMap<>();
            for (char c = 'a'; c <= 'z'; c++) {
                m.put(c, 0);
            }
            while (sc.hasNext()) {
                String s = sc.nextLine().toLowerCase();
                for (int i = 0; i < s.length(); i++) {
                    if (Character.isAlphabetic(s.codePointAt(i))) {
                        Integer c = m.get(s.charAt(i));
                        m.put(s.charAt(i), ++c);
                    }
                }
            }
            for (char c = 'a'; c <= 'z'; c++) {
                System.out.println(c + " : " + m.get(c));
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}



Measured memory_bytes: 26040
import scala.collection.mutable._
import scala.math._
object Main {
  def distance(pt1: (Int, Int), pt2: (Int, Int)): Double = {
     val (x1, y1) = pt1
     val (x2, y2) = pt2
     sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
  }
  def main(args: Array[String]): Unit = {
    val N = Console.in.readLine().toInt
    val pts = Buffer.empty[(Int, Int)]
    for(line <- Iterator.continually(Console.in.readLine()).takeWhile(_ != null).toList) {
      val Array(x, y, _*) = line.split(" ")
      pts += ((x.toInt, y.toInt))
    }
    val routes = pts.toList.permutations.toList
    var all = 0.0
    for(route <- routes) {
      all += (route zip route.tail).map{ case (p1, p2) => distance(p1, p2) }.sum
    }
    println(all / routes.length)
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

bool solve(int x, int y, int z) {
  return (x+y>z and y+z>x and z+x>y);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,x; cin>>n>>x;
  
  ll as[n];
  
  rep(i,n) {
    ll a; cin>>a;
    as[i] = a;
  }
  
  ll res = 0;
  
  rep(i,n-1) {
    ll a = as[i];
    ll b = as[i+1];
    
    if(a+b<=x) continue;
    else {
      if(a+b-x<=b) {
        int eat = a+b-x;
        as[i+1] = b - eat;
        res += eat;
          
      } else {
        as[i+1] = 0;
        res += b;
        res += a-x;     
      }
    }
  }
  
  cout<<res;
  return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

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

    sort(as.begin(), as.end());
    cout << (as.back() < accumulate(as.begin(), as.begin() + n - 1, 0) ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int inf = 2e9;
const int N = 2e3 + 15;
int n, k, sz, cnt, d[N], ans, q[N], ql, qr, d2[N];
vector <int> g[N];

void precalc_dist(int v, int p = -1) {
    for(int to : g[v])
        if(to != p) {
            d[to] = d[v] + 1;
            precalc_dist(to, v);
        }
}

void bfs(int s) {
    fill(d2, d2 + N, inf);
    q[ql = qr = 0] = s;
    d2[s] = cnt = 0;
    while(ql <= qr) {
        int v = q[ql++];
        if(d2[v] > k || d[v] > d[s])
            ++cnt;
        for(int to : g[v])
            if(d2[to] == inf) {
                d2[to] = d2[v] + 1;
                q[++qr] = to;
            }
    }
    ans = min(ans, cnt);
}

void dfs(int v, int p = -1) {
    bfs(v);
    for(int to : g[v])
        if(to != p)
            dfs(to, v);
}

main() {
    cin >> n >> k;
    for(int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    ans = n;
    precalc_dist(1);
    dfs(1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
S=input()
out=''

for i in range(len(S)):
    if S[i] == '0':
        out = out +'0'
    elif S[i] =='1':
        out = out + '1'
    else:
        if len(out) !=0:
            out = out[0:len(out)-1]
print(out)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    int sum = 0;
    for(int i = 0; i < s.size(); i++)
    {
        sum += s[i] - '0';
    }
    if(sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main() {
	int T;
	cin >> T;
	for (int tt = 0; tt < T; ++ tt) {
		int N, D;
		cin >> N >> D;
		for (int i = 1; i < N; ++ i) D ^= 127;
		cout << D + 127 * (N-1) << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define fi first
#define se second
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 2e5 + 5;
const int INF = 2e9;

ll dp[MAXN];
ll h[MAXN];
ll a[MAXN];

ll t[4 * MAXN];

ll get(int x, int l, int r, int tl, int tr){
	if(tl > tr){
		return 0;
	}
	if(l == tl && r == tr){
		return t[x];
	}

	int mid = (l + r) / 2;
	ll res = 0;
	res = max(res, get(x * 2, l, mid, tl, min(mid, tr)));
	res = max(res, get(x * 2 + 1, mid + 1, r, max(mid + 1, tl), tr));

	return res;
}

void update(int x, int l, int r, int pos, ll val){
	if(l == r){
		t[x] = val;
		return;
	}

	int mid = (l + r) / 2;

	if(mid < pos){
		update(2 * x + 1, mid + 1, r, pos, val);
	}
	else{
		update(2 * x, l, mid, pos, val);
	}

	t[x] = max(t[2 * x], t[2 * x + 1]);
}
int main(){
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n;
	cin >> n;

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

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

	for(int i = 0; i < n; i++){
		ll cur = 0;

		cur = get(1, 0, n, 0, h[i] - 1);
		dp[h[i]] = max(dp[h[i]], cur + a[i]);
		update(1, 0, n, h[i], dp[h[i]]);
	}

	ll res = 0;
	for(int i = 1; i <= n; i++){
		res = max(res, dp[i]);
	}

	cout << res << "\n";
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2



//Segtree
ll def = 0;
const int MAX_N = 1 << 18;
ll n, dat[2 * MAX_N - 1];

ll comp(ll a, ll b) {
	return max(a, b);
}

void init(ll n_) {
	n = 1;
	while (n < n_) {
		n *= 2;
	}
	rep(i, 0, 2 * n - 1)dat[i] = 0;
}
void update(ll k,ll a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = comp(dat[2*k+1],dat[2*k+2]);
	}
}
ll query(ll a,ll b,ll k,ll l,ll r){
	if (r <= a || b <= l)return def;
	if (a <= l && r <= b)return dat[k];
	else {
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return comp(vl, vr);
	}
}
ll get(ll a,ll b) {
	return query(a,b+1,0,0,n);
}
ll datn(ll x) {
	return get(x, x);
}
//endSegtree


int main(){
	ll N;
	cin >> N;
	init(N);
	vector<ll>H(N);
	vector<ll>A(N);
	rep(i, 0, N) {
		cin >> H[i];
		H[i]--;
	}
	rep(i, 0, N)cin >> A[i];

	rep(i, 0, N) {
		ll opt = get(0,H[i])+A[i];
		update(H[i],max(datn(H[i]),opt));
	}
	cout << get(0,1<<18) << endl;

	return 0;
}


Measured memory_bytes: 7424
<?php
fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);

if (abs($C - $A) <= $D) {
    echo "Yes\n";
} elseif (abs($C - $B) <= $D && abs($B - $A) <= $D) {
    echo "Yes\n";
} else {
    echo "No\n";
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[200], k[200];

int f(int a, int k) {
	while(true) {
		if(a < k) { return 0; }
		if(a % k == 0) { return a / k; }
		a -= ((a % k) / (a / k + 1)) * (a / k + 1);
		if(a % k == 0) { return a / k; }
		a -= a / k + 1;
	}
	return 0;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i] >> k[i]; }
	
	int ans = 0;
	inc(i, n) { ans ^= f(a[i], k[i]); }
	
	cout << (ans != 0 ? "Takahashi" : "Aoki") << endl;
	
	return 0;
}


Measured memory_bytes: 256
import bisect
from itertools import accumulate

T = int(input())

for _ in range(T):
    N = int(input())
    As = list(map(int, input().split()))
    S = input()
    possible_xor = []
    if S[-1] == '1':
        print(1)
        continue
    flg = True
    for c, A in reversed(list(zip(S, As))):
        if c == '0':
            for xor in possible_xor[::-1]:
                if A.bit_length() == xor.bit_length():
                    A ^= xor
                elif A > xor:
                    break
            possible_xor.insert(bisect.bisect_left(possible_xor, A), A)
        else:
            for xor in possible_xor[::-1]:
                if A.bit_length() == xor.bit_length():
                    A ^= xor
            if A != 0:
                flg = False
                break
    if flg:
        print(0)
    else:
        print(1)



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

int main() {
    int a,b,x; cin >> a >> b >> x;

    double rad;
    if(a*a*b >= 2*x){
        rad = atan2(a*b*b, 2*x);
    }else{
        rad = atan2(2*a*a*b - 2*x,a*a*a);
    }
    double deg = 180 * rad / M_PI;
    cout << std::setprecision(10) << deg << endl;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second

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

	int maxDiff=0,start,end;
	for(int i=1;i<n;i++){
		if(a[i] - a[i-1] > maxDiff){
			maxDiff = a[i] - a[i-1];
			start = i-1;
			end = i;
		}
	}
	int td=0;
	if((p+a[0])-a[n-1] > maxDiff){
		start = 0;
		end = n-1;
		for(int i=1;i<n;i++){
		    td += a[i] - a[i-1];
		}
		cout << td << endl;
	}
	else{
	    for(int i=start;i>0;i--){
		td += a[i] - a[i-1]; 
	}
	for(int i=end;i<n-1;i++){
		td += a[i+1]-a[i];
	}
	
	td += (p+a[0])-a[n-1];
		cout << td;
	}
	
	
	


		
	}

	


Measured memory_bytes: 1024
import heapq
a = []
n = int(input())
p_L = list(map(int,input().split()))


heapq.heapify(a)
kotae = 0
for i in p_L:
    heapq.heappush(a, i)
    if i == a[0]:
        kotae += 1

print(kotae)

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   char X,Y;
   cin>>X>>Y;
   int x = X - 'A';
   int y = Y - 'A';
   if(X<Y)cout<<"<"<<endl;
   else if(X>Y)cout<<">"<<endl;
   else cout<<"="<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  vector <int> A(3, -1);
  int N,M;
  cin >>N>>M;
  if(N==1&&M==0){
  cout << 0 << endl;
    return 0;
  }
  

  int a,b;
  rep(i, M){
    
  cin >> a >> b;
    if(a==1&&b==0){
      if(N!=1){
    cout << -1 << endl;
      return 0;
      }
    }
    if(A[a-1]!=-1){
      if(A[a-1]==b){}
    else {cout << -1 << endl;
      return 0;}
    }
    A[a-1]=b;
  }
  rep(i, N){
  if(A[i]==-1&&i==0){
    cout << 1;
    continue;
    
  }
  if(A[i]==-1){
  cout << 0;
    continue;
  }
    cout << A[i];
  }
  cout << endl;
}

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

public class Main {

	static class Reader {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

	static int[][] wv;
	static long[][] dp;
	public static void main(String[] args) {
		Reader r = new Reader();

		int n = r.nextInt();
		int w = r.nextInt();
		wv = new int[n][2];
		for (int i = 0; i < n; i++) {
			wv[i][0] = r.nextInt();
			wv[i][1] = r.nextInt();
		}
		dp = new long[n][w + 1];
		for (int i = 0; i < n; i++) {
			Arrays.fill(dp[i], -1);
		}

		System.out.println(recur(n, w));
	}

	static long recur(int n, int w) {
		if (n == 0 || w == 0) {
			return 0; 
		} else if (dp[n - 1][w] == -1) {
			if (wv[n - 1][0] > w) {
				dp[n - 1][w] = recur(n - 1, w); 
			} else {
				dp[n - 1][w] = Long.max(wv[n - 1][1] + recur(n - 1, w - wv[n - 1][0]), recur(n - 1, w));
			}
		}
		return dp[n - 1][w];
	}
}


Measured memory_bytes: 125080
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}
ll mo = 1000000000+7;
ll powmod (int n,int k){
    ll res = 1;
    for(int i = 0; i < k ; i++){
        res = res * n %mo;
    }
    return res;
}
int main(){
    int n; cin >> n;
    
    ll ans = powmod(10,n) - powmod(9,n) - powmod(9,n) + powmod(8,n);
    ans %= mo;
    ans = (ans + mo)%mo;
    cout << ans <<endl;

    
}





Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using vi = vector<int>;

int main(){
    int n; cin>>n;
    int a;
    bool approvement = true;
    rep(0,i,n){
        cin>>a;
        if(a%2 == 0){
            if(a%3!=0 && a%5!=0){
                approvement = false;
            }
        }
    }
    if(approvement) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll M=1e5+5,Mod=1000000007;
ll fa[M];
vector<ll> mp[M];
ll ans=1,n,k;
inline ll read()
{
	ll x=0,f=1; char ch=0;
	while(!isdigit(ch)) f=(ch=='-'?-1:1),ch=getchar();
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
void dfs(ll x,ll fa,ll sz)
{
	ans=ans*(k-sz)%Mod;
	int flg=1; if(fa==0) flg=0;
	for(register ll i=0;i<mp[x].size();i++){
		ll u=mp[x][i];
		if(u==fa){
			flg=0; continue; 
		}
		dfs(u,x,i+1+flg);
	}
}
int main()
{
	n=read(),k=read();
	for(register ll i=2;i<=n;i++){
		ll x=read(),y=read();
		mp[x].push_back(y); mp[y].push_back(x);
	}
	dfs(1,0,0);
	printf("%lld\n",ans);
	return 0;	
}

Measured memory_bytes: 9216