akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintf(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func CreateList(n int, input string) []int {
	list := make([]int, n)
	elements := strings.Split(input, " ")
	for i := 0; i < n; i++ {
		list[i], _ = strconv.Atoi(elements[i])
	}
	return list
}

func Compare(lhs *[]int, rhs *[]int) int {
	for i := 0; i < len(*lhs) || i < len(*rhs); i++ {
		if len(*lhs) <= i {
			return 1
		}
		if len(*rhs) <= i {
			return -1
		}

		if (*lhs)[i] < (*rhs)[i] {
			return 1
		}
		if (*rhs)[i] < (*lhs)[i] {
			return -1
		}
	}
	return 0
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := ReadLongLines(1)
	listA := CreateList(n, lines[0])
	fmt.Scanf("%d", &n)
	lines, _ = ReadLongLines(1)
	listB := CreateList(n, lines[0])
	
	if Compare(&listA, &listB) == 1 {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}


Measured memory_bytes: 1200
N = int(input())
S = input()
n = int(N/2)
count = 0
if N%2 == 1:
  print("No")
else:
  for i in range(n):
    if S[i] != S[i+n]:
      print("No")
      break
    else:
      count += 1
  if count == n:
    print("Yes")

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

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

	for(int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

  long a=2,b=1;
  
  if(n == 0)
    P(2);
  else if(n == 1)
    P(1);
  else{
    for(int i = 2 ; i <= n ; i++ ){
      long tmp = b;
      b = a+b;
      a = tmp;
    }
    P(b);
  }
  

  ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n,k;cin>>n>>k;
    int h[n];REP(i,n)cin>>h[i];
    vector<ll>dp(n,1e9);dp[0]=0;
    REP(i,n)
        for(int j=1;j<=k;j++)
            if(i+j<n)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    cout<<dp[n-1]<<endl;
}

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


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
	int N,*A,a;
	int i;
	char str[10000000];
 
	fgets(str, sizeof(str), stdin);
	N=atoi(strtok(str," "));
	
	A = (int*)calloc(N,sizeof(int));

	fgets(str, sizeof(str), stdin);	
	a=atoi(strtok(str," "))-1;	

	A[a]+=1;
	for(i=1;i<(N-1);i++){
		a=atoi(strtok(NULL," "))-1;
		A[a]+=1;
	}

	for(i=0;i<N;i++){
		printf("%d\n",A[i]);
	}

	free(A);

	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 1e5+1;



void solve()
{    
    
    ll n,m; cin >> n >> m;
    ll degree[n+1];
    fill(degree, degree+n+1, 0);
    while(m--){
        ll u,v; cin >> u >> v;
        degree[u]++;
        degree[v]++;
    }
    ll sum=0;
    f(i,1,n+1){
        sum+= degree[i]%2;
    }
    if(sum)
        cout << "NO";
    else
        cout << "YES";

    
}   


int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
          //factorial();
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false), cin.tie(NULL);
typedef vector < int > VI;
const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input

    //cin>>testCase;
    while(testCase--){

        ll n;
        cin>>n;
        ll cnt=1, sum=0;
        while(n>0){
            sum+=cnt;
            n/=2;
            cnt*=2;
        }
        cout<<sum<<endl;
    }
    return 0;
}

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

class Program
{
    static bool Solve(int N, long[] A)
    {
        long sum = A.Sum();
        long sigma = Math.BigMul(N, N + 1) / 2;
        if (sum % sigma != 0) { return false; }
        long steps = sum / sigma;
        long count = 0;
        for (int i = 0; i < N; ++i)
        {
            long dif = A[(i + 1) % N] - A[i];
            if (dif > steps) { return false; }
            if ((steps - dif) % N != 0) { return false; }
            count += (steps - dif) / N;
        }
        return count == steps;
    }
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        long[] A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        Console.WriteLine(Solve(N, A) ? "YES" : "NO");
    }
}


Measured memory_bytes: 12632
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val edges = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .toArray

  val graph = {
    val arr = Array.ofDim[Boolean](n+1,n+1)
    for(edge <- edges) {
      arr(edge(0))(edge(1)) = true
      arr(edge(1))(edge(0)) = true
    }
    arr
  }
  var visit = Array.ofDim[Boolean](n+1)

  def dfs(v:Int):Unit = {
    if(visit(v)) return
    visit(v) = true
    for(i <- 1 to n) {
      if(graph(v)(i)) dfs(i)
    }
  }

  val ans = {
    for(edge <- edges) yield {
      visit = Array.fill(n+1)(false)
      graph(edge(0))(edge(1)) = false
      graph(edge(1))(edge(0)) = false
      dfs(edge(0))
      // println(visit.mkString(" "))
      graph(edge(0))(edge(1)) = true
      graph(edge(1))(edge(0)) = true
      visit.tail.forall(_ == true)
    }
  }

  println(ans.count(_ == false))
}

Measured memory_bytes: 27204
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int N, M;
vector<pair<int, int>> edge_list;
vector<vector<int>> adj;
vector<vector<bool>> reach;

void reach_dfs(int source, int node) {
    reach[source][node] = true;

    for (int neighbor : adj[node])
        if (!reach[source][neighbor])
            reach_dfs(source, neighbor);
}

vector<vector<bool>> reach_without;
vector<int> best_index;

void without_dfs(int index, int node) {
    best_index[node] = index;

    for (int neighbor : adj[node])
        if (best_index[neighbor] < 0)
            without_dfs(index, neighbor);
}

void solve_reach_without(int source) {
    reach_without[source][source] = true;
    int neighbors = adj[source].size();
    best_index.assign(N, -1);
    best_index[source] = N;

    for (int i = 0; i < neighbors; i++)
        if (best_index[adj[source][i]] < 0)
            without_dfs(i, adj[source][i]);

    for (int i = 0; i < neighbors; i++) {
        int neighbor = adj[source][i];

        if (best_index[neighbor] >= 0 && best_index[neighbor] != i)
            reach_without[source][neighbor] = true;
    }

    best_index.assign(N, -1);
    best_index[source] = N;

    for (int i = neighbors - 1; i >= 0; i--)
        if (best_index[adj[source][i]] < 0)
            without_dfs(i, adj[source][i]);

    for (int i = 0; i < neighbors; i++) {
        int neighbor = adj[source][i];

        if (best_index[neighbor] >= 0 && best_index[neighbor] != i)
            reach_without[source][neighbor] = true;
    }
}

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

    cin >> N >> M;
    edge_list.resize(M);
    adj.assign(N, {});

    for (pair<int, int> &edge : edge_list) {
        cin >> edge.first >> edge.second;
        edge.first--; edge.second--;
        adj[edge.first].push_back(edge.second);
    }

    reach.assign(N, vector<bool>(N, false));

    for (int i = 0; i < N; i++)
        reach_dfs(i, i);

    reach_without.assign(N, vector<bool>(N, false));

    for (int i = 0; i < N; i++)
        solve_reach_without(i);

    for (pair<int, int> &edge : edge_list) {
        bool answer1 = reach_without[edge.first][edge.second];
        bool answer2 = reach[edge.second][edge.first];
        cout << (answer1 ^ answer2 ? "diff" : "same") << '\n';
    }
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(i!=a)
		{
			if(!isdigit(s[i]))
			{
				cout<<"No";
				return 0;
			}
		}
		else
		{
			if(s[i]!='-')
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

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

int N;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> N;
    long long sum;
    long a;
    for(int i=0; i<N; i++){
        cin >> a;
        sum += a;
    }
    cout << sum -N  << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int bi_search1(ll key,vector<ll> &a){
    
    ll left = 0;
    ll right = (ll)a.size();
    if(a[0]>=key) return -1 ;
    while (right-left>1)
    {
      ll mid = (right+left)/2;
      if(a[mid]>=key){
          right = mid;
      }else{
          left = mid;
      }
    }
    return left;
}

int bi_search2(ll key,vector<ll> &a){
    
    ll left = -1;
    ll right = (ll)a.size()-1;
    if(a[right]<=key) return right+1 ;
    while (right-left>1)
    {
      ll mid = (right+left)/2;
      if(a[mid]<=key){
          left = mid;
      }else{
          right = mid;
      }
    }
    return right;
}

int main() {
    int n;
    cin >> n ;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);

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

   sort(a.begin(),a.end());
   sort(c.begin(),c.end());

   ll ans= 0 ;
   for(int i=0;i<n;i++){
       ll a_ind = bi_search1(b[i],a)+1;
       ll c_ind = n-bi_search2(b[i],c);
       //cout << a_ind << " " << c_ind << endl;
       ans+=a_ind*c_ind;
   }

   cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    set<string> s;
    cin.ignore();
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
         s.insert(str);
    }
    int count=0;
    for(auto x:s)
    {
        count++;
    }
    cout<<count;
}


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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);int A = int.Parse(input[1]);int B = int.Parse(input[2]);

            if(A>=B){
            Console.WriteLine("delicious");
            }else{
                Console.WriteLine(Math.Abs(A-B)<=X? "safe":"dangerous" );
            }
        }
    }
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)


int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    REP(i,N) cin >> H[i];

    vector<bool> G(N, true);
    REP(i,M){
        ll A,B;
        cin >> A >> B;
        A--; B--;
        if( H[A] > H[B] ){
            G[B] = false;
        }else if( H[A] == H[B] ){
            G[B] = false;
            G[A] = false;
        }else{
            G[A] = false;
        }
    }

    ll count = 0;
    REP(i,N){
       if( G[i] ) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N; long double A[100]; cin >> N;
  long double ans = 0.0;
  REP(i, N){
    cin >> A[i];
    ans += (1.0 / A[i]);    
  }
  coutdb << 1.0 / ans << endl;

}

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int A[100000];
int R[100000];
int L[100000];
int n;

int gcd(int a, int b) {
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    int r;
      r = a % b;

  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int calc_l(int max_i) {
    if (max_i < 0)
        return 0;
    if (L[max_i] != 0)
        return L[max_i];
    if (max_i == 0)
        return L[0] = A[0];
    return L[max_i] = gcd(calc_l(max_i-1), A[max_i]);
}

int calc_r(int min_i) {
    if (min_i > n-1)
        return 0;
    if (R[min_i] != 0)
        return R[min_i];
    if (min_i == n-1)
        return R[n-1] = A[n-1];
    return R[min_i] = gcd(calc_r(min_i+1), A[min_i]);
}

int exclude_gcd(int ex_i) {
    return gcd(calc_l(ex_i-1), calc_r(ex_i+1));
}

int main() {
    cin >> n;
    REP(i, n) {
        cin >> A[i];
    }
    int max_gcd = 0;

    // i を除いたときのgcd
    REP(i, n) {
        int cur_gcd = exclude_gcd(i);
        max_gcd = max(max_gcd, cur_gcd);
    }
    cout << max_gcd << endl;
}


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

int main()
{
  int x,y;
  cin >> x >> y;
  
  int flag = 0;
  if( (y % 2) == 1){
    flag = 0;
  }else if( (4 * x) < y ){
    flag = 0;
  }else{
    for(int i = 0; i <= x; i++){
      for(int j = 0; j <= x; j++){
        if( (i + j == x) && (4 * i + 2 * j == y) ){
          flag = 1;
          break;
        }
      }//for
      if(flag == 1){
        break;
      }//if
    }//for
  }//else
    
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

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

    ll total = 0;
    for(int i = 0; i <= n; ++i){
        total += abs(a.at(i) - a.at(i + 1));
    }

    for(int i = 1; i <= n; ++i){
        cout << total - abs(a.at(i - 1) - a.at(i)) - abs(a.at(i) - a.at(i + 1))
            + abs(a.at(i - 1) - a.at(i + 1)) << endl;
    }
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  string answer = "";

  if (N == 0) {
    answer = "0";
  } else {
    while (N != 0) {
      if (N % 2 != 0) {
        N--;
        answer = "1" + answer;
      } else {
        answer = "0" + answer;
      }
      N /= -2;
    }
  }

  cout << answer << endl;

  return 0;

}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################

int main() {
  int n=D(),m=D(),k=D();
  int a[n],b[m];
  ll cm1[n+1],cm2[m+1];
  cm1[0]=0,cm2[0]=0;
  for(int i=0;i<=n;i++){
      if(i<n)
      a[i]=D();
      if(i)
        cm1[i]=cm1[i-1]+a[i-1];
  }

  for(int i=0;i<=m;i++){
      if(i<m)
      b[i]=D();
      if(i)
          cm2[i]=cm2[i-1]+b[i-1];
  }
  int ans=0;
  for(int i=0;i<=n&&cm1[i]<=k;i++){
        if(cm1[i]>k)break;
        int it=upper_bound(cm2,cm2+m+1,(k-cm1[i]))-cm2;
        ans=max(ans,i+it-1);
  }
  cout<<ans;


}

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

int main() {
	int a;
	while (cin >> a, a) {
		vector<int>V[100]{};
		bool hannin[100];
		memset(hannin,true, a);
		for (int b = 0; b < a; b++) {
			int c;
			cin >> c;
			for (int d = 0; d < c; d++) {
				int e;
				cin >> e;
				e--;
				V[e].push_back(b);
			}
		}
		int x;
		cin >> x;
		for (int y = 0; y < x; y++) {
			int z;
			cin >> z;
			z--;
			for (int i = 0,sum=0; i < a; i++) {
				if (sum < V[z].size() && V[z][sum] == i)sum++;
				else hannin[i] = false;
			}
		}
		int s = 0, l = 0;
		for (int k = 0; k < a; k++) {
			if (hannin[k]) { s++; l = k + 1; }
		}
		if (s == 1)cout << l << endl;
		else puts("-1");
	}
}

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

namespace ConsoleApp62 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow((double)N, 3));
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int calc(int H,int W){
    int res=1e18;
    for(int i=1;i<=H-1;i++){
        int a=i*W;
        int b=(H-i)*(W/2);
        int c=(H-i)*(W-W/2);
        res=min(res,max(a,c)-min(a,b));
    }
    return res;
}

signed main()
{
    int H,W; cin>>H>>W;
    int ans;
    if(H%3==0 or W%3==0) ans=0;
    else{
        ans=min(H,W);
        ans=min(ans,calc(H,W));
        ans=min(ans,calc(W,H));
    }
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  
  int res = 0;
  for (int i = 1; i < N - 1; i++) {
    if ((p[i-1] < p[i]) && (p[i] < p[i+1])) res++;
    else if ((p[i-1] > p[i]) && (p[i] > p[i+1])) res++;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<(x-z)/(y+z)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  while( a != b )
    {
      if( a > b )
	{
	  a = a- b;
	}
      else if( a < b )
	{
	  b = b - a;
	}
    }
  printf("%d\n", a); 
 return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>

using namespace std;

typedef struct NodeData * Node;

typedef struct NodeData {
    int rank;
    int val;
    Node parent;
}* Node;

Node make_set(int val)
{
    Node node = new NodeData();
    node->rank = 0;
    node->val = val;
    node->parent = node;

    return node;
}

Node find_parent(Node node)
{
    while (node->parent != node)
        node = node->parent;

    return node;
}

void union_set(Node x, Node y)
{
    auto x_parent = find_parent(x);
    auto y_parent = find_parent(y);

    if (x->parent->rank > y->parent->rank)
        y_parent->parent = x_parent;
    else if (x_parent->rank < y_parent->rank)
        x_parent->parent = y_parent;
    else if (x_parent != y_parent) {
        y_parent->parent = x_parent;
        x_parent->rank++;
    }
}

int main(void)
{
    int n, q;
    cin >> n >> q;
    vector<Node> disj_set(n);

    for (int i = 0; i < n; i++) 
        disj_set[i] = make_set(i);

    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) // unite
            union_set(disj_set[x], disj_set[y]);
        else { // same
            bool is_same = find_parent(disj_set[x]) == find_parent(disj_set[y]);
            cout << (is_same ? 1 : 0) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1580
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
int score[1000][1000][3];
const string JOI = "JOI";
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<string> fld(n);
    for(auto& x : fld) cin >> x;
    vector<string> joi(2);
    for(auto& x : joi) cin >> x;
    int sum = 0;
    for(int i : in(n - 1)) for(int j : in(m - 1)) {
        int cnt = 0, cx = 0, cy = 0;
        for(int y : in(2)) for(int x : in(2)) {
            char aim = fld[i + y][j + x];
            if(aim == joi[y][x])
              ++cnt;
            else
              cy = y, cx = x;
        }
        if(cnt == 4) {
            ++sum;
            for(int y : in(i, i + 2))
              for(int x : in(j, j + 2))
                for(int k : in(3))
                  if(fld[y][x] != JOI[k])
                    --score[y][x][k];
        }
        else if(cnt == 3) {
            int kk = 0;
            for(int k : in(3))
              if(JOI[k] == joi[cy][cx])
                kk = k;
            ++score[cy + i][cx + j][kk];
        }
    }
    int ma = 0;
    for(int i : in(n)) for(int j : in(m)) for(int k : in(3))
      ma = max(ma, score[i][j][k]);
    cout << sum + ma << endl;
}

Measured memory_bytes: 15412
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  ll N, A, B, W, H, D;
  string S;
  cin >> A >> B;
  ll ans;
  ans = ((A+B)%2==0?(A+B)/2:((A+B)/2)+1);

  cout << ans << endl;

}


Measured memory_bytes: 256
S = str(input())
K = int(input())

# Sのsubstring全列挙を行う
ans = []

for i in range(len(S)):
    for j in range(i+1, i+K+1):
        ans.append(S[i:j])

ans = list(set(ans))
ans.sort()

print(ans[K-1])


Measured memory_bytes: 40944
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int p = 0;
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'p')p++;
  }
  cout << s.size() / 2 - p << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

#define SIZE 200000


using namespace std;

int main() {
   long long N,i;
    long long A[SIZE];
    long long B[SIZE];


 cin >> N;
for (i=0;i<N;i++)
  cin >> A[i] >> B[i];

  sort(A,A+N);
  sort(B,B+N);

  long long mini,maxi;

  if (N % 2) {
    mini = A[N/2];
    maxi = B[N/2];
  }
  else {
    mini = A[N/2-1]+A[N/2];
    maxi = B[N/2-1]+B[N/2];
  //  cerr << mini << " " << maxi << endl;
  }
  cout << maxi-mini+1 << endl;


  return 0;

}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,A,B,C,D;

int main(){
    cin >> N >> A >> B >> C >> D;

    ll n = N-1;

    ll dif = abs(B-A);


    for(int i=0;i<N;i++){
        ll up = i;
        ll down = n-up;
        pair<ll,ll> p1 = mp(A+up*C,A+up*D);
        pair<ll,ll> p2 = mp(p1.fi-down*C,p1.se-down*D);
        if(p2.fi <= B and B <= p2.se){
            cout << "YES" << endl;
            return 0;
        }
        p1 = mp(A-up*C,A-up*D);
        p2 = mp(p1.fi+down*D,p1.se+down*C);
        if(p2.se <= B and B <= p2.fi){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

flag=0
ans=[]
for a in A:
  if a%2==0:#odd
    count=0
    while a%2==0:
      a=a/2
      count=count+1
    ans.append(count)
  else:#even
    flag=1
    
if flag==0:
  print(int(min(ans)))
else:
  print(0)                                 

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
const int M = 2e5 + 10;
typedef long long ll;
ll a[M] , sum[M];
int main() {
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    for(int i = 1 ; i <= n ; i++) sum[i] = sum[i - 1] + a[i];
    ll ans = abs(sum[n] - sum[1] - sum[1]);
    for(int i = 2 ; i <= n - 1 ; i++) ans = min(ans , abs(sum[n] - sum[i] - sum[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
 
using namespace std;
 
int main(){
 
    int n, m, l;
 
    long long A[100][100], B[100][100], C[100][100];
 
    cin >> n >> m >> l;
 
    for( int i = 0; i < n; i++)
 
        for( int j = 0; j < m; j++) cin >> A[i][j];
 
    for( int i = 0; i < m; i++)
 
        for( int j = 0; j < l; j++) cin >> B[i][j];
 
 
    for ( int i = 0; i < n; i++){
 
        for( int j = 0; j < l; j++){
 
            C[i][j] = 0;
 
            for( int k = 0; k < m; k++){
 
                C[i][j] += A[i][k]*B[k][j];
 
            }
 
        }
 
    }
 
 
    for( int i = 0; i < n; i++){
 
        for ( int j = 0; j < l; j++){
 
            if( j ) cout << " ";
 
            cout << C[i][j];
 
        }
 
        cout << endl;
 
    }
 
    return 0;
 
}

Measured memory_bytes: 3220
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
pair<int,int> p[500100];
signed main() {
  int N; cin >> N;
  
  for (int i = 0; i < N*3; i+=3) {
    int a,b; cin >> a >> b;
    p[i] = make_pair(a, 1);
    p[i+1] = make_pair(b+1, -1);
  }
  
  sort(p, p+N*3);

  int ans = 0; 
  int s = 0;
  for (int i = 0; i < N*3; i++) {
    s += p[i].second;
    ans = max(ans, s);
  }
  
  cout << ans << endl;
}



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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	vector<ll>v(n,0);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	unordered_map<ll,ll>u;
	for(ll i=0;i<n;i++)
	{
		u[v[i]]++;
	}
	ll ans=0;
	for(auto i: u)
	{
		if(i.first>i.second)
		{
			ans = ans + i.second;
		}
		else
		{
			ans = ans + (i.second - i.first);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5028
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool x = 0;
    while(1)
    {
        if(!x)
        {
            c -= b;
            if(c<=0)
            {
                cout << "Yes" << endl;
                return;
            }
        }
        else
        {
            a -= d;
            if(a<=0)
            {
                cout << "No" << endl;
                return;
            }
        }
        x ^= 1;
    }
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
string s[10100];
int main()
{
     int n;
     cin>>n;
     int couts=0;
     int a=0;
     int b=0;
     int c=0;
     for(int i=0;i<n;i++)
     {
          cin>>s[i];
          int len=s[i].size();
         if(s[i][0]=='B'&&s[i][len-1]=='A')
           c++;
         if(s[i][0]=='B')
            b++;
          if(s[i][len-1]=='A')
            a++;
            for(int j=0;j<len-1;j++)
            {

                if(s[i][j]=='A'&&s[i][j+1]=='B')
                    couts++;
            }
     }
   couts+=min(a,b);
    if(c==a&&c==b&&c)
        couts--;
cout<<couts<<endl;

    return 0;
}


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

int n,m,mod=1000000007;
char a[1001][1001];
int dp[1001][1001];
int go(int i,int j)
{
	if(i==n-1 && j==m-1)
	  return 1;
	else if(i>=n || j>=m)
	  return 0;
	else
	  {
	  	 if(a[i][j]=='#')
	  	   return 0;
	  	 else {
	  	   if(dp[i][j]==-1)
	  		dp[i][j]=(go(i+1,j)+go(i,j+1))%mod;
	  	  return dp[i][j];	
	  	 }
	  }
}

int main() {
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	  {
	  	 for(int j=0;j<m;j++)
	  	   cin>>a[i][j];
	  }
	cout<<go(0,0)<<'\n';  
	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#define M 200000

int main(){

  int i,n,min,max;
  int I[M];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&I[i]);
  }

  min=I[0];
  max=I[1]-I[0];

  for(i=1;i<n;++i){
    max=(max<(I[i]-min))?(I[i]-min) : max;
    min=(min>I[i])?I[i] : min;
  }

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

  return 0;
}

 



Measured memory_bytes: 2644
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, k, a[N], pos[N], deg[N], f[N];
vector<int> g[N];

int main() {
	scanf("%d%d", &n, &k);
	REP(i,1,n) scanf("%d", a+i);
	REP(i,1,n) pos[a[i]]=i;
	set<int> L, R;
	REP(i,1,k) R.insert(a[i]);
	REP(i,1,n) {
		auto p = L.upper_bound(a[i]);
		if (p!=L.end()) {
			g[pos[*p]].pb(i);
			++deg[i];
		}
		p = R.upper_bound(a[i]);
		if (p!=R.end()) {
			g[pos[*p]].pb(i);
			++deg[i];
		}
		L.insert(a[i]), R.erase(a[i]);
		if (i-k+1>0) L.erase(a[i-k+1]);
		if (i+k<=n) R.insert(a[i+k]);
	}
	priority_queue<int> q;
	REP(i,1,n) if (!deg[i]) q.push(i);
	PER(i,1,n) {
		int u = q.top(); q.pop();
		f[i] = u;
		for (int v:g[u]) {
			if (!--deg[v]) q.push(v);
		}
	}
	REP(i,1,n) a[f[i]] = i;
	REP(i,1,n) printf("%d\n",a[i]);
}









Measured memory_bytes: 82048
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101], c[101];
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

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



Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N, M;
string S = "";
int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		S += '.';
	}
	for (int i = 0; i < M; i++) {
		int s;
		char c;
		cin >> s >> c;
		s--;

		if (S[s] == '.' || S[s] == c) {
			S[s] = c;
		}
		else {
			cout << -1;
			return 0;
		}
	}

	for (int i = 0; i < S.length(); i++) {
		if (i == 0) {
			if (S[i] == '.') {
				if (S.length() == 1) S[i] = '0';
				else S[i] = '1';
			}
		}
		else if (S[i] == '.') S[i] = '0';
	}

	if (S[0] == '0') {
		if (S.length() == 1) {
			cout << 0;
			return 0;
		}
		cout << -1;
		return 0;
	}

	cout << S;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int func(int a, int b) {
  string aa = to_string(a);
  string bb = to_string(b);
  return max(aa.size(), bb.size());
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vi A(n); rep(i,n) cin >> A[i];
    sort(all(A), greater<int>());
    ll tmp = 0;
    ll t = 0; rep(i,n) t+=A[i];
    double tt = t*(1/(4.0*m));
    rep(i,n) {
        if (A[i]<tt) continue;
        tmp++;
    }
    if (tmp>=m) {
        ct("Yes");
    } else {
        ct("No");
    }
}



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

int main() {
  int N, R;
  int in_rate, out_rate;
  
  cin >> N;
  cin >> R;
  out_rate=R;
  
  if(N>=10){
    in_rate=out_rate;
  }else{
    in_rate=out_rate+100*(10-N);
  }
  cout << in_rate << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
int main()
{
    fio;
    string s1;
    cin>>s1;
    int n = s1.size();
    if(s1[n-1]=='s')
        cout<<s1<<"es\n";
    else
        cout<<s1<<"s\n";
    return 0;
}


Measured memory_bytes: 3600
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

vector<vector<int>>lst;
map<long long,pair<int,int>>m;

pair<int,int> dfs(int d,int cur){
	long long key=(long long)d<<32|cur;
	if(m.find(key)!=m.end())return m[key];
	pair<int,int> r={cur,cur};
	if(cur>0){
		auto it=upper_bound(lst[cur].begin(),lst[cur].end(),d);
		if(it!=lst[cur].end()){
			r.first=dfs(*it,cur-1).first;
		}
	}
	if(cur<lst.size()-1){
		auto it=upper_bound(lst[cur+1].begin(),lst[cur+1].end(),d);
		if(it!=lst[cur+1].end()){
			r.second=dfs(*it,cur+1).second;
		}
	}
	return m[key]=r;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	vector<pair<int,int>>v(k);
	for(int i=0;i<k;i++){
		scanf("%d%d",&v[i].first,&v[i].second);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	lst.resize(n);
	for(int i=0;i<k;i++){
		lst[v[i].second].push_back(i);
	}
	for(int i=0;i<n;i++){
		auto p=dfs(-1,i);
		printf(i<n-1 ? "%d " : "%d\n",p.second-p.first+1);
	}
}

Measured memory_bytes: 35584
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BMakingTriangle {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> L(N);
        REP(i, N) cin >> L[i];

        int res = 0;
        REP(i, N) {
            FOR(j, i + 1, N - 1) {
                FOR(k, j + 1, N - 1) {
                    if (L[i] == L[j]) continue;
                    if (L[i] == L[k]) continue;
                    if (L[j] == L[k]) continue;
                    if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) res++;
                }
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BMakingTriangle solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;

int main() {
  LL N;
  cin >> N;
  
  vector <LL> A(N+1);
  rep(i, N+1) cin >> A[i];

  vector <LL> B(N);
  rep(i, N) cin >> B[i];
  
  LL answer = 0;
  rep(i, N) {
    LL rest = min(A[i], B[i]);
    answer += rest;
    LL rest2 = min(A[i+1], B[i] - rest);
    answer += rest2;
    A[i+1] -= rest2;
  }
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>

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

using namespace std;
int n;
void solve() {
	int sum=0;
	int maxi=-1;
	int mini=1000;
	int a;
	rep(i,n) {
		rep(j,5) {
			cin>>a;
			sum+=a;
		}
		maxi=max(maxi,sum);
		mini=min(mini,sum);
		sum=0;
	}
	cout<<maxi<<" "<<mini<<endl;
}

int main() {

	while (cin>>n)
	{
		if(!n) return 0;
		solve();
			
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    map<long long, int> a;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        long long  p;
        cin >> p;
        a[p]++;
        if(a[p] != 1){
          cout << "NO" << endl;
          return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 12800