akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <functional>
#include <sstream>
#include <fstream>
#include <valarray>
#include <complex>
#include <queue>
#include <cassert>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define debug_flag 1
#else
	#define debug_flag 0
#endif

template <class T1, class T2 >
std::ostream& operator << (std::ostream& os, const pair<T1, T2> &p) 
{
	os << "[" << p.first << ", " << p.second << "]";
	return os;
}

template <class T >
std::ostream& operator << (std::ostream& os, const std::vector<T>& v) 
{
	os << "[";
	bool first = true;
	for (typename std::vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
	{
		if (!first)
			os << ", ";
		first = false;
		os << *it;
	}
	os << "]";
	return os;
}

#define dbg(args...) { if (debug_flag) { _print(_split(#args, ',').begin(), args); cerr << endl; } else { void(0);} }

vector<string> _split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return v;
}

void _print(vector<string>::iterator) {}
template<typename T, typename... Args>
void _print(vector<string>::iterator it, T a, Args... args) {
    string name = it -> substr((*it)[0] == ' ', it -> length());
    if (isalpha(name[0]))
	    cerr << name  << " = " << a << " ";
	else
	    cerr << name << " ";
	_print(++it, args...);
}

typedef long long int int64;

int main()
{
#ifdef LOCAL
	freopen ("input.txt", "r", stdin);
#endif

  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <= m; y++) {
      int cnt = x * m + y * n - 2 * x * y;
      if (cnt == k) {
        printf("Yes\n");
        return 0;
      }
    }
  }

  printf("No\n");

	return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
LL dp[101][64];
LL mod = 1e9 + 7;
LL add(LL a, LL b){
	LL t = a + b;
	if(t >= mod)
		t -= mod;
	return t;
}
int check(int j, int k){
	if(k == 1){
		if((j/4) == 2)
			return 0;
		if((j/16) == 0 && (j % 4) == 2)
			return 0;
	}
	return 1;
}
int main(){
	IO();
	LL n;
	cin>>n;
	rep(i,0,64){
		if(i != 6 && i != 9 && i != 33)
			dp[3][i] = 1;
	}
	for(LL i=3;i<n;i++){
		for(LL j=0;j<64;j++){
			if(j == 6 || j == 9 || j == 33)
				continue;
			for(LL k=0;k<4;k++){
				int t = j % 16;
				int p = t*4 + k;
				if(p == 6 || p == 9 || p == 33)
					continue;
				if(check(j, k))
					dp[i+1][p] = add(dp[i][j], dp[i+1][p]);
			}
		}
	}
	LL ans = 0;
	rep(i,0,64){
		ans = add(ans, dp[n][i]);
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string O, E;
  cin >> O >> E;
  for(int i=0; i<O.size(); i++){
    cout << O[i];
    if(i==E.size()) break;
    cout << E[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm> //fillを使うため
#include <vector>
#include <queue>

using namespace std;

#define MAX_V 1000
#define INF 10000000

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

int main()
{
    int V; //頂点の数
    int side; //辺の数
    int S; //始点
    int G; //終点
    vector<int> d(V, 1e9); //始点からそこまで行くのにかかるコスト
    vector<edge> edges; //移動の情報を保存する

    cin >> V;
    cin >> side;
    int P;cin >> P;
    S = 0;
    G = V-1;
    vector<vector<int>> vec(V);
    vector<vector<int>> v(V);
    d[S] = 0; //始点を0にする
    for (int i = 0; i < side; i++) {
        struct edge add;
        cin >> add.from;
        add.from--;
        cin >> add.to;
        add.to--;
        cin >> add.cost;
        vec.at(add.to).push_back(add.from);
        v.at(add.from).push_back(add.to);
        add.cost  = P - add.cost;
        edges.push_back(add);
    }

    vector<bool> f(V, false);
    queue<int> que;
    //f.back() = true;
    que.push(V-1);
    while(!que.empty()){
        int q = que.front();
        que.pop();
        if(f[q])continue;
        f[q] = true;
        for(int a : vec.at(q)){
            if(!f[a])que.push(a);
        }
    }
    vector<bool> ef(V, false);
    queue<int> nque;
    //f.back() = true;
    nque.push(0);
    while(!nque.empty()){
        int q = nque.front();
        nque.pop();
        if(ef[q])continue;
        ef[q] = true;
        for(int a : v.at(q)){
            if(!ef[a])nque.push(a);
        }
    }

    /*
    for(int i = 0;i < V;i++){
        cout<<f[i]<<endl;
    }
    */
    vector<edge> nq;
    for(auto a : edges){
        if(f[a.from] && f[a.to] && ef[a.from] && ef[a.to]){
            nq.push_back(a);
        }
    }
    edges = nq;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < (int)edges.size(); j++) {

            struct edge e = edges[j];

            if (d[e.to] > d[e.from] + e.cost) {  //移動した後のコストが小さいと、頂点のコストを更新
                d[e.to] = d[e.from] + e.cost;
                if (i == V-1) {         //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
                    cout << -1<< endl;
                    return 0;
                }
            }
        }
    }
    cout<<max(0,-d[G])<<endl;
}


Measured memory_bytes: 896
// ConsoleApplication3.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

using namespace std;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
db = [0] * (max(d)+1)
MOD = 998244353

#距離iの頂点の数をdb[i]に保存
for i in range(n):
    db[d[i]] += 1

if (d[0] != 0)|(db[0] != 1):
    print(0)
    exit()

ans = 1

for i in range(len(db)-1):
    ans *= pow(db[i],db[i+1],MOD)

print(ans%MOD)


Measured memory_bytes: 13908
import os

def main():
    char = input()
    list_ = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","w","x","y","z"]
    for i,v in enumerate(list_):
        if char == v:
            print(list_[i+1])

if __name__ == "__main__":
    main()



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef long double ld;
vector<pair<ld,int>> p;
vector<ll> v;
ll a[200010],b[200010],dp[200010][40],c[200010];
int main(){
	ll i,j,n,t;
	cin >> n >> t; t++;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
		a[i]++; b[i]++;
		if(a[i]>=2){
			p.push_back({(ld)(a[i] - 1)/(ld)b[i],i});
		}else{
			v.push_back(b[i]);
		}
	}
	sort(p.rbegin(),p.rend());
	sort(v.begin(),v.end());
	for(i=0;i<=p.size();i++){
		for(j=0;j<40;j++){
			dp[i][j] = 100000000000;
		}
	}
	dp[0][0] = 1;
	for(i=1;i<=p.size();i++){
		for(j=0;j<40;j++){
			int k = p[i - 1].second;
			if(dp[i - 1][j]<=t) dp[i][j] = min(dp[i][j],dp[i - 1][j]);
			if(j>=1 && dp[i - 1][j - 1]<=t && a[k]*dp[i - 1][j - 1] + b[k]<=t) dp[i][j] = min(dp[i][j],a[k]*dp[i - 1][j - 1] + b[k]);
		}
	}
	ll sum = 0;
	int k = 0;
	for(j=39;j>=0;j--){
		while(k<v.size() && dp[p.size()][j] + sum + v[k]<=t){
			sum += v[k];
			k++;
		}
		c[j] = k;
	}
	ll ans = 0;
	for(j=0;j<40;j++){
		if(dp[p.size()][j]<=t){
			ans = max(ans,j + c[j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 73832
(function() {
    'use strict';
 
    var lines = [];
    require('readline').createInterface({
      input: process.stdin,
      output: process.stdout
    }).on('line', function(line) {
      lines.push(line);
    });
    process.stdin.on('end', function() {
      //lines.forEach(function(line) {
        //var tokens = line.split(' ').map(Number);
        //    console.log(tokens[0] + ' ' + tokens[1]);
      //}
      //)
      ;
      
    // ToDo start
      var N = parseInt(lines[0])
      var K = parseInt(lines[1])
      
      var denko = 1;

      for ( var i=1;i<N+1;i++){
//        console.log(i)
        if ( denko > K ){
            denko += K;
        } else {
            denko = denko * 2;
        }
    }
      console.log( denko )
    // ToDo end

    });

    
})();
  
  

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans: Vec<usize> = Vec::new();
    let mut w = v.clone();
    while w.len() > 0 {
        let mut f = false;
        for i in (0..w.len()).rev() {
            if w[i] == i + 1 {
                ans.push(i + 1);
                w.remove(i);
                f = true;
                break;
            }
        }
        if !f {
            println!("-1");
            return;
        }
    }
    ans.reverse();
    for i in 0..n {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 4352
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  // ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }
 


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      
  ll n;
  cin>>n;
  ll nn = n;
  ll ans = 0;
  set<ll> have;
  for (ll i = 2;i*i<=n;i++){
    ll v = i;
    
    // cout<<nn<<" "<<v<<endl;
    if (!have.count(v))
    while (nn%v==0){
      have.insert(v);
      ans++;
      nn/=v;
       v*=i;
    //    cout<<nn<<" "<<v<<endl;
    // cout<<ans<<endl;
    }
    while (nn%i==0) nn/=i;
    
  }
  // cout<<nn<<endl;
  // cout<<ans<<endl;
  bool ok = true;
  for (ll i = 2;i*i<=nn;i++){
    if (nn%i==0) ok = false;
  }
  // cout<<ans<<endl;

if (ok && !have.count(nn) && nn!=1) ans++;
cout<<ans<<"\n"; 
}


Measured memory_bytes: 3192
N, K = map(int,input().split())
nums = list(map(int,input().split()))
ans = []

for i in range(N):
  ans.append((nums[i]+1)/2)

M = sum(ans[0:K])
S = M
for i in range(K,N):
  S = S + ans[i] - ans[i-K]
  M = max(M,S)

print(M)

Measured memory_bytes: 25060
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        long k=sc.nextLong()+1,a=sc.nextLong(),b=sc.nextLong();
        long ans=0;
        if(a+2>=b){
            out.println(k);
        }else {
            long turn=0;
            while (turn<k){
                if(ans>=a&&turn+2<=k){
                    ans+=b-a;
                    turn+=2;
                }else{
                    ans++;
                    turn++;
                }
            }
            out.println(ans);
        }
        /*
        a回の操作でA枚ふやせる
        A+1回の操作で1円得られる
        A+2回の操作でB枚得られる
        A+2とBを比較してでかいほうを繰り返す→最後のほう（残り回数がA+2未満ならポケットを叩く操作だけ行う）
        初回はA+1回の操作でB枚得られる←k=k+1,初期0枚とすればよい
         */
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int f=0;
  int a=N;
  
  while(a != 0) {
  f += a % 10;
  a = a / 10;
  }
  
  if ( N % f == 0 ){ cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}
  
  

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  int a[6];
} cube;

int main(){
  cube x,tmp;
  int i;
  char c,dekoi;
  for(i=0;i<6;i++){
    scanf("%d",&x.a[i]);
  }
  scanf("%c",&dekoi);
  while(1){
    for(i=0;i<6;i++){
      tmp.a[i] = x.a[i];
    }
    scanf("%c",&c);
    if(c == '\n') break;
    x = tmp;
    if(c == 'E'){
      x.a[0] = tmp.a[3];
      x.a[1] = tmp.a[1];
      x.a[2] = tmp.a[0];
      x.a[3] = tmp.a[5];
      x.a[4] = tmp.a[4];
      x.a[5] = tmp.a[2];
    }
       else if(c == 'W'){
      x.a[0] = tmp.a[2];
      x.a[1] = tmp.a[1];
      x.a[2] = tmp.a[5];
      x.a[3] = tmp.a[0];
      x.a[4] = tmp.a[4];
      x.a[5] = tmp.a[3];
    }
    else if(c == 'N'){
      x.a[0] = tmp.a[1];
      x.a[1] = tmp.a[5];
      x.a[2] = tmp.a[2];
      x.a[3] = tmp.a[3];
      x.a[4] = tmp.a[0];
      x.a[5] = tmp.a[4];
    }
    else if(c == 'S'){
      x.a[0] = tmp.a[4];
      x.a[1] = tmp.a[0];
      x.a[2] = tmp.a[2];
      x.a[3] = tmp.a[3];
      x.a[4] = tmp.a[5];
      x.a[5] = tmp.a[1];
    }
  }
  printf("%d\n",x.a[0]);
  return 0;
}



Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
class Program{
  
  static void Main()
  {
    string Sh=Console.ReadLine();
    int i=1;
    int j=0;
   
    
    if(Sh=="1")
    {
      Console.WriteLine(j);
    }
    else
    {
      Console.WriteLine(i);
    }
  }
  
}



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

int main() {
	// your code goes here
	int N;
	cin >> N;

	vector<int> a(N);
	for(int i=0;i<N;i++) cin >> a[i];
	
	// i ... number of sorted elements
	// j ... location of bubble (right end)
	
	int swapped = 0;
	for(int i=0;i<N;i++){
		int min_j = i;
		for(int j=i; j<N; j++){
			if(a[min_j] > a[j]) min_j = j;
		}
		if(i != min_j){
			swap(a[i],a[min_j]);
			swapped++;
		}
	}
	
	for(int i=0;i<N;i++){
		cout << a[i];
		if(i<N-1) cout << ' ';
		else cout << endl;
	}
	cout << swapped << endl;
	
	return 0;
}


Measured memory_bytes: 3140
a, b, c, x, y = gets.chomp.split.map(&:to_i)

arr = []
arr.push(a * x + b * y)

if x >= y
  arr.push(c * y * 2 + (x - y) * a)
else
  arr.push(c * x * 2 + (y - x) * b)
end

arr.push(c * [x, y].max * 2)

p arr.min


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

int main() {
  char N[5];
  scanf("%s" ,&N) ;

  if ( (N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]) ) {
    puts("Yes" );
  }
  
  else puts("No") ;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("test.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 100005

i64 cnt[30], p[maxn] ;
char s[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    p[0] = 1LL ;
    for(i=1 ; i<maxn ; i++) p[i] = (p[i-1]*2LL)%mod ;

    scanf("%lld",&n) ;
    scanf("%s",s) ;

    for(i=0 ; s[i]!='\0' ; i++ ) cnt[ s[i]-'a' ]++ ;

    i64 ans = 1LL ;

    for(i=0 ; i<26 ; i++)
    {
        ans = (ans*(cnt[i]+1) )%mod ;
    }

    ans-- ;

    printf("%lld\n", (ans%mod + mod)%mod ) ;

    return 0 ;
}


Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys
import numpy as np


def solve(S: str):
    if S=="ARC":
        print("ABC")
        return
    print("ARC")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26984
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,k,m,n;
	string s1,s2;
	cin>>s1>>s2;
	int ans=0;
	for(register int i=0;i<3;i++)if(s1[i]==s2[i])ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

const int MAX_N = 100000 + 10;
int A[MAX_N];
vector<int> g[MAX_N];
bool ans;

ll f(int v, int p) {
  if (!ans) return 0;
  ll T = 0;
  if (g[v].size() == 1 && p == -1) {
    ll ci = f(g[v][0], v);
    if (A[v] != ci) { ans = false; }
    return 0;
  } else if (g[v].size() == 1 && p != -1) {
    T = A[v];
  } else {
    ll L = 0;
    vector<ll> c;
    for (int u : g[v]) if (u != p) {
      ll ci = f(u, v);
      L += ci;
      c.push_back(ci);
    }
    T = 2 * A[v] - L;
    if (T < 0 || T > A[v]) { ans = false; }
    if ((L - T) % 2 != 0) { ans = false; }
    if ((L - T) < 0) { ans = false; }
    ll P = (L - T) / 2;
    ll Q = L/2;
    REP(i, c.size()) {
      Q = min(Q, L-c[i]);
    }
    // if (ans) {
      // cout << "v=" << v << ", Q=" << Q << ", p=" << P << endl;
    // }
    if (Q < P) { ans = false; }
  }
  return T;
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  int N;
  scanf("%d", &N);
  REP(i, N) {
    scanf("%d", &A[i]);
  }
  REP(i, N-1) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (N == 2) {
    cout << (A[0] == A[1] ? "YES":"NO") << endl;
    return 0;
  }
  int root = 0;
  REP(i, N) if (g[i].size() > 1) {
    root = i;
    break;
  }
  ans = true;
  ll T = f(root, -1);
  if (T != 0) ans = false;
  cout << (ans ? "YES":"NO") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 15488
def parindrome(s):
    if s[::] == s[::-1]:
        return True
    return False

def string_parindrome(s):
    if parindrome(s):
        N = len(s)
        if parindrome(s[:((N-1)//2):]) and parindrome(s[((N+3)//2)-1::]):
            return "Yes"
    return "No"
    

S = input()
print(string_parindrome(S))


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;

		for (int i = 1; i <= n; i++) {
			int x = i;
			int s = 0;
			while (x > 0) {
				s += x % 10;
				x /= 10;
			}
			if (a <= s && s <= b) {
				ans += i;
			}
		}

		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = (m); i < (n); i++)
 
int main() {
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> inputs(N);
  rep(i,0,N) cin >> inputs[i];
  vector<int> vec(W);
  bool is_odd = false;
  int pos_h = 0, pos_w = 0;
  rep(i,0,N){
  	rep(j,0,inputs[i]){
      if (!is_odd){
        vec[pos_w] = i+1;
        pos_w++;
        if(pos_w == W){
          is_odd = true;
          pos_w--;
          for(int v:vec)
            cout << v << " ";
          cout << endl;
        }
      }
      else{
        vec[pos_w] = i+1;
        pos_w--;
        if(pos_w == -1){
          is_odd = false;
          pos_w++;
          for(int v:vec)
            cout << v << " ";
          cout << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 384
// Problem : L - Deque
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_l
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(long long int i=0;i<n;i++)
#define FORR(i,n) for(long long int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<long long int>
#define slli set<long long int>
#define mlli map<long long int,long long int>
#define lli long long int 
#define test lli tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define MOD 1000000007
using namespace std;
lli n, arr[3001],dp[3001][3001][2];
lli go(lli s,lli e,lli t){
	if(s>e) return 0;
	if(dp[s][e][t]!=-1) return dp[s][e][t]; 
	if(t==0){
		return dp[s][e][t]=max(arr[s]+go(s+1,e,1),arr[e]+go(s,e-1,1));
	}
		return dp[s][e][t]=min(-arr[s]+go(s+1,e,0),-arr[e]+go(s,e-1,0));
}


void solve(){
	cin>>n;
	FOR(i,n)cin>>arr[i];	
	cout<<go(0,n-1,0);
}


int32_t main() {
    	set(dp,-1);
    	solve();
    return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename t>
    inline void read(t& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 2000 + 10;

int n, arr[MAXN], sum;

bitset<MAXN * MAXN> f;

int main() {
    IO::read(n);
    rep(i, 1, n) IO::read(arr[i]), sum += arr[i];
    f[0] = 1;
    rep(i, 1, n) f |= f << arr[i];
    rep(i, ceil(1.* sum / 2), sum) { if (f[i]) { printf("%d\n", i); return 0; } }
    return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, k, ans = 0;
    cin >> n >> k; n++;
    vector<ll> sum(n+1, 0);
    rep(i, n)sum[i+1] = sum[i]+i;
    for(int i = k; i <= n; i++){
        ans = ans + (sum[n] - sum[n-i]) - sum[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
}  

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  
  ll g = gcd(n, m);
  bool ok = true;
  ll ans = lcm(n, m);
  n /= g, m /= g;
  for(ll i = 0; i < g; i++){
    if(s[i*n] != t[i*m]) ok = false;
  }

  if(ok) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}

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

int main(){
	stack<int> st;
	int n, a;

	while(cin >> n){
		if(n!=0){
			st.push( n );
		}else{
			a = st.top();
			cout << a << endl;
			st.pop();
		}
	}
}

Measured memory_bytes: 0
function main(input) {
  var n = input[0]-0;
  var ans = ":(";
  for(var i=1;i<=n;i++){
    if(Math.trunc(i*1.08) == n) ans = i;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 7500
import java.util.*;

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

        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();

        System.out.println(Math.ceil((double)d / s) > t ? "No" :"Yes");

    }
}


Measured memory_bytes: 35652
#include <cstdio>
using namespace std;

int gcd(int a,int b){return b? gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a,b) * b;}

int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b) != EOF) {
		printf("%d %d\n",gcd(a,b),lcm(a,b));
	}
	return 0;
}

Measured memory_bytes: 1024
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    while (n) {
        if (n % 10 == 7) {
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});


int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	if (b - a + 2 > 2 * k) {
		for (int i = 0;i < k;++i) {
			ll ans = a + i;
			cout << ans << endl;
		}
		for (int i = k - 1;i >= 0;--i) {
			ll ans = b - i;
			cout << ans << endl;
		}
	}
	else {
		for (int i = a;i <= b;++i) {
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long N, long long A, long long B){
    cout << min(B, A * N) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
struct point{
  double x,y;
};
 
double INF = 1e9;
double PI = acos(-1);
double EPS = (1e-10);
double dp[10001][20][20];
int n;
double Ti;
double r,ti;
point t[20];
 
double mem[20][20][20];
double check(int to,int from,int prev){
  if(mem[to][from][prev]!=-INF)return mem[to][from][prev];
 
  if(to==from||to==prev)return INF;
  double vax=t[to].x-t[from].x;
  double vay=t[to].y-t[from].y;
  double vbx=t[from].x-t[prev].x;
  double vby=t[from].y-t[prev].y;
  double ar=(vax*vbx+vay*vby)/(sqrt(vax*vax+vay*vay)*sqrt(vbx*vbx+vby*vby));
  ar=acos(ar);
  if(ar<ti+EPS){
    mem[to][from][prev]=sqrt(vax*vax+vay*vay);
  }else{
    mem[to][from][prev]=INF;
  }
  return mem[to][from][prev];
}
 
void solve(int i,int j,int k){
  for(int to=0;to<n;to++){
    dp[i+1][to][j]=min(dp[i+1][to][j],dp[i][j][k]+check(to,j,k));
 
    //dp[i][j][k]+sqrt(vax*vax+vay*vay));
    //    if(ar<ti+EPS){
    // dp[i+1][to][j]=min(dp[i+1][to][j],dp[i][j][k]+sqrt(vax*vax+vay*vay));
    //    }
  }
}
 
int main(){
 
  for(int i=0;i<10001;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<20;k++)
    dp[i][j][k]=INF;
   
  for(int i=0;i<20;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<20;k++)
    mem[i][j][k]=-INF;
 
  cin>>n>>r>>Ti;
  ti=Ti/360.0*2.0*PI;
 
  for(int i=0;i<n;i++)
    cin>>t[i].x>>t[i].y;
   
  for(int i=1;i<n;i++){
    double x=t[i].x-t[0].x;
    double y=t[i].y-t[0].y;
    dp[1][i][0]=sqrt(x*x+y*y);
  }
 
  int ans=0;
  for(int i=1;i<=10000;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
    if(dp[i][j][k]>r+EPS)continue;
    ans=max(ans,i);
    solve(i,j,k);
      }
    }
  }
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 32616
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll K, S, cnt = 0;
  cin >> K >> S;
  for(ll x = 0; x <= K; x++) {
    for(ll y = 0; y <= K; y++) {
      if((S - x - y >= 0) && (S - x - y <= K)) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  long long i,n,sum = 0;
  cin >> n;
  for ( i = 0; i <= n; i++){
    if (i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
  cout << sum << '\n';
  return 0; 
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        String[] inputs = reader.readLine().split(" ");
        int min = 1000;
        int max = 0;
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(inputs[i]);
            if (max < a) {
                max = a;
            }
            if (a < min) {
                min = a;
            }
        }
        System.out.println(max-min);

    }
}

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

using namespace std;
using ll = long long;

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

int dp[100005][3];

int convert(char c) {
  int x;
  if (c == 'r') x = 0;
  if (c == 's') x = 1;
  if (c == 'p') x = 2;
  return x;
}

int main() {
  int n, k, a[3];
  cin >> n >> k;
  rep(i, 3) cin >> a[i];
  string t;
  cin >> t;

  auto b = vector<vector<int>>(k);

  for (int i = 0; i < n; ++i) {
    int x = convert(t[i]);
    b[i % k].push_back(x);
  }

  int ans = 0;
  rep(order, k) {
    int m = b[order].size();
    int dp[m + 1][3];
    rep(i, m + 1) rep(j, 3) dp[i][j] = 0;

    for (int i = 0; i < m; ++i) {
      int score[3];
      rep(j, 3) score[j] = 0;
      if (b[order][i] == 0) score[2] = a[2];
      if (b[order][i] == 1) score[0] = a[0];
      if (b[order][i] == 2) score[1] = a[1];

      rep(j, 3) rep(k, 3) {
        if (j == k) continue;
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + score[k]);
      }
    }

    int now = 0;
    rep(i, 3) now = max(now, dp[m][i]);
    ans += now;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1

ll n;
db t, a, _, an, col = 9999999999999999999.0, re;


start;
    cin3(n, t, a);

    rep(i, 0, n){
        cin1( _ );
        re = t - _ * .006;
        re = abs(re - a);
        if ( re <= col ){
            col = re;
            an = i+1;
        }
    }

    coul(an);

finish



/*



2 5 4 8 7 3 2 9 6
3 8 6 5 9 2 7 1 4
7 2 9 6 4 1 8 3 5
8 2 3 7 2 5 1 4 9
9 7 5 3 1 4 6 2 8
4 1 2 9 6 8 3 5 7
6 3 2 4 5 7 9 8 2
5 9 8 2 3 6 4 7 1
2 4 7 1 8 9 5 6 3






*/







Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<int, int> mp;
    int N, M;
    bool test = true;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int t, p;
        cin >> t >> p;
        if (t == 1 && p == 0 && N != 1)
        {
            test = false;
        }
        else if ((mp.find(t) == mp.end()))
        {
            mp[t] = p;
        }
        else if (mp.find(t)->second == p)
        {
        }
        else
        {
            test = false;
        }
    }

    if (test == false)
    {
        cout << -1 << endl;
        return 0;
    }

    int i = 1;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        if (i < itr->first)
        {
            while (i < itr->first)
            {
                if (i == 1)
                {
                    cout << 1;
                }
                else
                {
                    cout << 0;
                }
                i++;
            }
        }
        cout << itr->second;
        i++;
    }
    for (; i <= N; i++)
    {
        if (i == 1&&N!=1)
        {
            cout << 1;
        }
        else
        {
            cout << 0;
        }
    }
    cout << endl;
}


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

using namespace std;

int main()
{
	int ans = INT_MAX;
	int n, a, b, c;
	vector<int> kadomatu;
	vector<int> takechoice;
	int wk;

	int wa, wb, wc;
	int mpa, mpb, mpc;


	cin >> n >> a >> b >> c;

	for (int i = 0; i < n; i++) {
		cin >> wk;
		kadomatu.push_back(wk);
		takechoice.push_back(0);
	}

	int loop = pow(4, n);
	int wkans;
	for (int i = 0; i < loop; i++) {
		wkans = 0;
		wk = i;
		for (int j = 0; j < n; j++) {
			takechoice[j] = wk % 4;
			wk /= 4;
		}

		wa = 0;
		wb = 0;
		wc = 0;

		for (int j = 0; j < n; j++) {
			if (takechoice[j] == 0) {
				wa += kadomatu[j];
				if (wa != kadomatu[j])wkans += 10;

			}
			else if (takechoice[j] == 1) {
				wb += kadomatu[j];
				if (wb != kadomatu[j])wkans += 10;

			}
			else if(takechoice[j] == 2){
				wc += kadomatu[j];
				if (wc != kadomatu[j])wkans += 10;

			}
		}

		if (wa * wb * wc == 0)continue;

		wkans += abs(a - wa);
		wkans += abs(b - wb);
		wkans += abs(c - wc);

		if (wkans < ans)ans = wkans;






	}



	cout << ans << endl;




	return 0;



}



Measured memory_bytes: 892
/*
      author  : nishi5451
      created : 14.08.2020 15:56:18
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<ll> l(n+1);
    l[0]=2;
    l[1]=1;
    for(int i=1; i<n; i++){
        l[i+1] = l[i] + l[i-1];
    }
    cout << l[n] << endl;
    
    return 0;
}

Measured memory_bytes: 3588
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
map<ll, ll> memo;
ll di[3] = {2, 3, 5};
vector<ll> cost;
ll rec(ll n, ll d, vector<ll> cost){
    if(n == 0){
        return 0;
    }
    if(n == 1){
        return d;
    }

    if(memo.find(n) != memo.end()){
        return memo[n];
    }

    ll res = INF;

    for(ll i = 0; i < 3; i++){
        if(n < di[i]) continue;
        if(n % di[i] == 0){
            res = min(res, rec(n / di[i], d, cost) + cost[i]);
        } else {
            res = min(res, rec(n / di[i], d, cost) + d * (n % di[i]) + cost[i]);
            res = min(res, rec(n / di[i] + 1, d, cost) + d * (di[i] - (n % di[i])) + cost[i]);
        }
    }
    if(n <= INF / d) res = min(res, n * d);

    return memo[n] = res;
}
int main(void){
    ll t;
    cin >> t;
    rep(i, t){
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        cost.clear();
        cost.push_back(a);
        cost.push_back(b);
        cost.push_back(c);
        memo.clear();
        cout << rec(n, d, cost) << endl;
    }
}


Measured memory_bytes: 4348
s = list(input())
ans = [0]*(len(s)+1)
for i in range(len(s)) :
    if s[i] == '<' :
        ans[i+1] = ans[i]+1 
for i in range(len(s),0,-1) :
    if s[i-1] == '>' :
        ans[i-1] = max(ans[i-1],ans[i]+1)
print(sum(ans))

Measured memory_bytes: 26808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		if(n > k) {
			n -= k * (n/k);
			if(k -n < n) {
				System.out.println(k-n);
			}else {
				System.out.println(n);
			}
		}else {
			if(k -n < n) {
				System.out.println(k-n);
			}else {
				System.out.println(n);
			}
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)
#define roop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int i,j;

int main(void) {
  int h,w;
  cin>>h>>w;
  string s;
  rep(i,h){
    cin>>s;
    cout<<s<<endl;
    cout<<s<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;

  while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
    if(d==0){
      y=(c*d-a*f)/(b*d-a*e);
      x=(c-(b*y))/a;
    }
    else{
      y=(a*f-c*d)/(a*e-b*d);
      x=(f-(e*y))/d;
    }
    if(x==-0)
      x=0;
    printf("%.3f %.3f\n",x,y);
  }
  return(0);
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int r; cin >> r;
  cout << 3 * r * r << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int gcd (ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main() {
    int N;  cin >> N;
    vector<ll> A(N);
    rep(i, N)  cin >> A[i];
    
    ll x = A[0];
    rep(i, N) {
        x = gcd(x, A[i]);
    }
    print(x);
}


Measured memory_bytes: 1024
k = int(input())
a, b = map(int, input().split())

a_div_k = a // k
b_div_k = b // k

a_mod_k = a % k
b_mod_k = b % k

if b < k:
    print("NG")
elif k == 1:
    print("OK")
elif k == b:
    print("OK")
elif (a_mod_k == 0) or (b_mod_k == 0) and (a_div_k == b_div_k):
    print("OK")
elif (k < a) and (a_div_k == b_div_k):
    print("NG")
else:
    print("OK")


Measured memory_bytes: 9196
#include <stdio.h>

int main(void)
{
    int num_datasets=0, input[10001];
    do
    {
        scanf("%d", &input[num_datasets]);

    } while (input[num_datasets++]);

    int i = 0;
    while (input[i] != 0)
    {
        printf("Case %d: %d\n", i+1, input[i]);
        i++;
    }

    return(0);
}


Measured memory_bytes: 2028