akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*const long long M = 1000000007 , N = 1001;
int r1,r2,r3,c1,c2,c3,c4,n,polycoff[N][N],group2[N][N];
string s1,s2,s3;
void fix(int &a){
	if(a >= M){
		a -= M;
	}else if(a < 0){
		a += M;
	}
}
int main(){
	cin >> n >> r1 >> s1 >> r2 >> s2 >> r3 >> s3;
	for(int i = 0 ; i < n ; i += 1){
		if(s1[i] != s2[i] && s2[i] == s3[i]){
			c1 += 1;
		}else if(s1[i] != s2[i] && s1[i] == s3[i]){
			c2 += 1;
		}else if(s1[i] == s2[i] && s2[i] != s3[i]){
			c3 += 1;
		}else{
			c4 += 1;
		}
	}
	int rr1 = r1-c2-c3-c4 , rr2 = r2-c1-c3-c4 , rr3 = r3-c1-c2-c4;
	for(int i = 0 ; i <= n ; i += 1){
		polycoff[i][0] = polycoff[i][i] = 1;
		for(int j = 1 ; j < i ; j += 1){
			polycoff[i][j] = polycoff[i-1][j] + polycoff[i-1][j-1];
			fix(polycoff[i][j]);
		}
	}
	for(int i = 0 ; i <= c3 ; i += 1){
		for(int j = 0 ; j <= c4 ; j += 1){
			group2[i+j][i-j+c4] = (long long)polycoff[c3][i] * polycoff[c4][j]%M;
		}
	}
	for(int i = 0 ; i <= c3+c4 ; i += 1){
		for(int j = -c4 ; j <= c3 ; j += 1){
			int jj = j+c4;
			group2[i][jj] += (i > 0 ? group2[i-1][jj] : 0) + (jj > 0 ? group2[i][jj-1] : 0);
			fix(group2[i][jj]);
			if(i > 0 && jj > 0){
				group2[i][jj] -= group2[i-1][jj-1];
			}
			fix(group2[i][jj]);
		}
	}
	long long ans = 0;
	for(int i = 0 ; i <= c1 ; i += 1){
		for(int j = 0 ; j <= c2 ; j += 1){
			int rrr1 = rr1 - i + j,rrr2 = rr2 + i - j , rrr3 = rr3 + i + j , rrr4 = max(-rrr1,-rrr2);
			if(rrr4 > c3+c4 || rrr3+c4 < 0){
				continue;
			}
			rrr3 = min(rrr3,c3);
			ans += (polycoff[c1][i]*polycoff[c2][j])*(group2[rrr4][c3+c4]-(rrr3+c4 > 0 ? group2[rrr4][rrr3+c4-1] : 0));
			ans %= M;
		}
	}
	cout << (ans+M)%M << endl;
}
*/
/*
3
1 000
1 100
0 111
*/

int main(){
	long long a,b;
	cin >> a >> b;
	if(500*a >= b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lim 999999999
#define on 100005
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR for(int i=1;i<=n;i++)
typedef long long int lo; 
typedef pair<int,int> PII;
int n,m,a[200005],cev=-lim,buy,kuc,say,k,z,x,y,mn=lim;
char c;
string s;
stack<int> st;
vector<int> v;
int main(){
	scanf("%d %d %d %d",&n,&m,&k,&z);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		cev=max(cev,x);
	}
	for(int i=1;i<=m;i++){
		scanf("%d",&y);
		mn=min(mn,y);
	}
	if(mn<=cev){
		printf("War");
		return 0;
	}
	if(mn<=k || cev>=z){
		printf("War");
		return 0;
	}
	printf("No War");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[333333];
int S[333333];
int sum;

void out(int diff)
{
	cout<<(sum+diff)/2<<' '<<(sum-diff)/2<<'\n'; exit(0);
}

int getS(int l, int r)
{
	if(l==0) return S[r];
	else return S[r]-S[l-1];
}

int dp[333333];
set<ii> SS; 

void add(ii x)
{
	auto it = SS.lower_bound(x);
	if(it!=SS.begin())
	{
		it--; 
		if(it->se<=x.se) return ;
		it++;
	}
	while(it!=SS.end()&&it->se>=x.se) 
	{
		it=SS.erase(it);
	}
	SS.insert(x);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; sum+=a[i];
		if(i%2==0) a[i]*=-1;
		S[i]=a[i]+(i>0?S[i-1]:0);
	}
	if(n%2==0) out(abs(S[n-1]));
	dp[0] = min(0, a[0]);
	int shift = a[0]; add(mp(-int(1e9), 0));
	for(int i=2;i<n;i+=2)
	{
		shift+=a[i-1]+a[i];
		add(mp(dp[i-2], a[i]-shift));
		int lo = -int(1e9); int hi = int(1e9);
		while(lo<=hi)
		{
			int mid=(lo+hi)>>1;
			auto it = SS.upper_bound(mp(mid+1,-int(1e9)));
			bool pos=1;
			if(it==SS.begin()) pos=0;
			else
			{
				it--;
				if(it->se+shift>mid) pos=0;
			}
			if(pos)
			{
				dp[i]=mid; hi=mid-1;
			}
			else
			{
				lo=mid+1;
			}
		}
	}
	out(S[n-1]-2*dp[n-1]);
}


Measured memory_bytes: 3968
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := dec(n)
	c := 0
	for i := 1; i < 10; i++ {
		for k := 1; k < 10; k++ {
			c += count(i, k, n, l) * count(k, i, n, l)
		}
	}
	fmt.Println(c)
}

func count(s, e, n, l int) int {
	if n < 10 {
		if s == e && s <= n {
			return 1
		}
		return 0
	}
	c := 0
	for i := 0; i < l-2; i++ {
		c *= 10
		c++
	}
	if s == e && s <= n {
		c++
	}
	f := n / int(math.Pow10(l-1))
	if f < s {
		return c
	}
	if s < f {
		return c + int(math.Pow10(l-2))
	}
	c += (n % (f * int(math.Pow10(l-1)))) / 10
	if n%10 < e {
		return c
	}
	return c + 1
}

func dec(n int) int {
	c := 1
	for 9 < n {
		n /= 10
		c++
	}
	return c
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    string s; cin >> s;
    ll bc = 0, pos = 0;
    rep(i,s.length()) {
        if (s[i] == 'B') {
            bc++;
            pos += i;
        }
    }
    ll sum = 0;
    rep(i,bc) {
        sum += s.length() - i - 1;
    }
    cout << sum - pos << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
#include<math.h>

int main()

{
	unsigned int a,b;
	while(~scanf("%u%u",&a,&b)){
	    
		unsigned int c=a,d=b;
		while(a>0&&b>0){
			if(a>b)a=a%b;
			else b=b%a;
		}
		printf("%u %u\n",a+b,c/(a+b)*d);
		
	}
	
	return 0;
}


Measured memory_bytes: 2620
while(n=gets.to_i)>0
e=Hash.new{|h,k|h[k]=[]}
l=(1..n).map{a=(i,j=gets.split.map(&:to_i));e[i][j]=1;a}
m=0
l.map{|i,j|l.map{|t,u|x=t-i;y=u-j;(i!=j||t!=u)&&i>-y&&j>x&&t>-y&&u>x&&e[i+y][j-x]&&e[t+y][u-x]&&m<(z=x*x+y*y)&&m=z}}
p m
end

Measured memory_bytes: 127672
<?php


fscanf(STDIN, "%d%d%d", $N, $M, $K);

$friend = array_fill(1, $N, []);
for ($i = 0; $i < $M; $i++) {
    $tmp = explode(" ", trim(fgets(STDIN)));
    $friend[$tmp[0]][$tmp[1]] = 1;
    $friend[$tmp[1]][$tmp[0]] = 1;
}
$block = array_fill(1, $N, []);
for ($i = 0; $i < $K; $i++) {
    $tmp = explode(" ", trim(fgets(STDIN)));
    $block[$tmp[0]][$tmp[1]] = 1;
    $block[$tmp[1]][$tmp[0]] = 1;
}

$group_no = 0;
$group_member = [];
$group_map = array_fill(1, $N, 0);
for ($i = 1; $i <= $N; $i++) {
    if ($group_map[$i] > 0) {
        continue;
    }
    $group_no++;
    $start = $i;
    $queue = [];
    $group_member[$group_no] = 1;

    $group_map[$i] = $group_no;
    if (count($friend[$start]) === 0) {
        continue;
    }
    $q = 0;
//初期キューの登録
    getQueue($friend[$start], $group_no);
    while (isset($queue[$q])) {
        getQueue($friend[$queue[$q][0]], $group_no);
        unset($queue[$q]);
        $q++;
    }
}
foreach ($group_map as $key => $value) {
    $block_num = 0;
    foreach ($block[$key] as $bkey => $bvalue) {
        if ($group_map[$bkey] === $value) {
            $block_num++;
        }
    }
    echo $group_member[$value] - 1 - $block_num - count($friend[$key]) . " ";
}


/**
 * @param array $array
 * @param int $last_vec
 * @param int $count
 * @return int
 */
function getQueue(array $array, int $group_no)
{
    global $queue, $group_map, $group_member;
    foreach ($array as $key => $value) {
        if ($group_map[$key] === 0) {
            $group_map[$key] = $group_no;

            $group_member[$group_no]++;
            $queue[] = [$key, $group_no];
        }
    }

    return 0;

}



Measured memory_bytes: 129908
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
map<ll,ll>mp;
vector<ll>v;
int main()
{
    ll a,b,c,i,j,k;
    string s,d,e;
    cin>>s>>d>>a>>b>>e;
    if(s==e)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int x;
	 cin>>x;
	 if(x>=400 && x<=599)
	 {
		 cout<<"8"<<'\n';
	 }
	 if(x>=600 && x<=799)
	 {
		 cout<<"7"<<'\n';
	 }
	 if(x>=800 && x<=999)
	 {
		 cout<<"6"<<'\n';
	 }
	 if(x>=1000 && x<=1199)
	 {
		 cout<<"5"<<'\n';
	 }
	 if(x>=1200 && x<=1399)
	 {
		 cout<<"4"<<'\n';
	 }
	 if(x>=1400 && x<=1599)
	 {
		 cout<<"3"<<'\n';
	 }
	 if(x>=1600 && x<=1799)
	 {
		 cout<<"2"<<'\n';
	 }
	 if(x>=1800 && x<=1999)
	 {
		 cout<<"1"<<'\n';
	 }
	 return 0;
}


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

int main(){
    int N;
    cin >> N;
    int n7 = 0;
    bool ans = false;

    for (int i = 0;i <= N/7;++i){
        if((N - i*7) % 4 == 0){
            ans = true;
            n7 = i;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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)

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n;
	while (cin >> n, n) {
		ll data[4001] = {};
		bool uni[4001] = {};
		vi order;
		
		REP(i, n) {
			ll a, b, c;
			scanf("%lld %lld %lld", &a, &b, &c);
			if (!uni[a]) {
				uni[a] = true;
				order.push_back(a);
			}
			data[a] += b * c;
		}
		
		bool f = false;
		REP(i, order.size()) {
			int num = order[i];
			if (data[num] >= 1000000) {
				printf("%d\n", num);
				f = true;
			}
		}
		if (!f) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>
 using namespace std;
 int main(){ int a,b;
 double a_d,b_d;
 scanf("%d %d",&a,&b);
 a_d = static_cast<double>(a);
 b_d = static_cast<double>(b);
 printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
 
} 


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

using namespace std;

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

    int n,m=INT_MAX,res=0;
    cin>>n;

    while(n--)
    {
        int x;
        cin>>x;
        if(x<m)
        {
            m=x;
            res++;
        }
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long int li;
typedef long long ll;

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

    int k, a, b; cin >> k >> a >> b;

    for (int i=a; i<=b; i++)
    {
        if ((i%k)==0&&(i/k)>0) {
            cout << "OK" << "\n";
            return 0;
        }
    }

    cout << "NG" << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

map<int, int> a;

int main(){
	int n, m;
	cin>>n;
	rep(i, n){
		int x;
		cin>>x;
		++a[x];
	}
	cin>>m;
	rep(i, m){
		int x;
		cin>>x;
		--a[x];
		if(a[x]<0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 9600
n = int(input())
ans = [0 for _ in range(n+1)]
def calc(n):
    for x in range(1, int(n**0.5)+1):
        for y in range(1, int(n**0.5)+1):
            for z in range(1, int(n**0.5)+1):
                v = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if v < n+1:
                    ans[v] += 1

calc(n)
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 69720
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		
		System.out.println(
			Math.max(A+B, 
				Math.max(A-B, A*B)
			)
		);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 23380
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var a = mutableListOf<Int>()
    var t = 0
    var max = -1
    var max2 = -1
    var dmax = false
    for (i in 0 until n){
        t = readLine()!!.toInt()
        a.add(t)
        if (t > max){
            max = t
        }else if (t > max2){
            max2 = t
        }
    }
    for (i in 0 until n){
        if (a[i] == max) println(max2)
        else println(max)
    }
}

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

void solve()
{
	int n, k;
	cin >> n >> k;
	int p[n];
	for(int i = 0; i < n; i++)
		cin >> p[i];
	sort(p, p+n);
	cout << accumulate(p, p+k, 0) << endl;
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

const int MaxN = 100000 + 5;

struct Graph {
  int cnte;
  int Head[MaxN], Next[MaxN * 2], To[MaxN * 2];

  inline void addEdge(int from, int to) {
    cnte++; To[cnte] = to;
    Next[cnte] = Head[from]; Head[from] = cnte;
  }
};

int N, Mod;
Graph G;
std::vector<int> A[MaxN], Pre[MaxN], Suf[MaxN];
int Dp[MaxN];
int Ans[MaxN];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }

void init() {
  scanf("%d %d", &N, &Mod);
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G.addEdge(u, v);
    G.addEdge(v, u);
  }
}

void dfs1(int u, int fa) {
  int s = 0;
  A[u].push_back(1);
  Dp[u] = 1;
  for (int i = G.Head[u]; i; i = G.Next[i]) {
    int v = G.To[i];
    if (v == fa) continue;
    s++;
    dfs1(v, u);
    Dp[u] = mul(Dp[u], add(Dp[v], 1));
    A[u].push_back(add(Dp[v], 1));
  }
  A[u].push_back(1);
  Pre[u].resize(s + 2), Suf[u].resize(s + 2);
  Pre[u][0] = 1; Suf[u][s + 1] = 1;
  for (int i = 1; i <= s; ++i) Pre[u][i] = mul(Pre[u][i - 1], A[u][i]);
  for (int i = s; i >= 1; --i) Suf[u][i] = mul(Suf[u][i + 1], A[u][i]);
}

void dfs2(int u, int fa, int f) {
  Ans[u] = mul(Dp[u], f);
  for (int i = G.Head[u], c = 0; i; i = G.Next[i]) {
    int v = G.To[i];
    if (v == fa) continue;
    c++;
    int fu = mul(mul(Pre[u][c - 1], Suf[u][c + 1]), f);
    dfs2(v, u, add(fu, 1));
  }
}

void solve() {
  dfs1(1, 0);
  dfs2(1, 0, 1);
  for (int i = 1; i <= N; ++i)
    printf("%d\n", Ans[i]);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
#define INF 10101010

int a[12][12];

int main(){
 int n,m,x,b,money=0;
 bool arc = true;
 cin >> n >> m >> x;

 vector<int> sum(n);
 vector<int> d(m);

 for(int i=0; i<n; i++){
    cin >> sum[i];
    for(int j=0; j<m; j++){
    cin >> a[i][j];
    }
 }
 int ans=INF;
 int cost = 0;
 for(int bit = 0; bit < (1 << n); bit++){
    for(int i=0; i < n; i++){
    if((bit >> i) & 1){
        cost += sum[i];
        for(int j=0; j<m;j++)
            d[j]+=a[i][j];
    }
    }
     arc = true;
    for(int j=0; j<m;j++){
    if(d[j] < x)
        arc = false;
    }
    if(arc)
    ans = min(ans,cost);
    cost = 0;
    for(int j=0; j<m;j++)
    d[j]=0;
 }
 if(ans == INF)
 cout << "-1" << endl;
 else
 cout << ans << endl;
}


Measured memory_bytes: 3608
S = input()
MOD = 10 ** 9 + 7



dp = [0] * 13
dp[0] = 1
for s in S :
    dp_ = [0] * 13
    if s == '?' :
        for i in range(13) :
            for j in range(10) :
                dp_[(i*10+j)%13] += dp[i]
                dp_[(i*10+j)%13] %= MOD
    else :
        s = int(s)
        for i in range(13) :
            dp_[(i*10+s)%13] += dp[i]
            dp_[(i*10+s)%13] %= MOD
    dp = dp_
            
print(dp[5])

Measured memory_bytes: 44220
x = list(input())
x.sort()

if len(x) % 2:
  print('No')

else:
  f = True
  for i in range(0, len(x), 2):
    if x[i] == x[i + 1]:
      continue
    else:
      f = False
      break
  
  print('Yes' if f else 'No')

Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a>8 || b>8){
		cout << ":(" << endl;
		return 0;
	}
	cout << "Yay!" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int sn = 0;
    int nn = n;
    while (nn > 0)
    {
        sn += (nn % 10);
        nn /= 10;
    }
    if (n%sn == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
s1 = input()
s2 = input()

MOD = 10**9+7
res = 1
flg = 2
idx = 0
while idx < N:
    if s1[idx] == s2[idx]:
        if flg==0:
            res *= 2
        elif flg==1:
            res *= 1
        else:
            res *= 3
        flg = 0
        idx += 1
    else:
        if flg==0:
            res *= 2
        elif flg==1:
            res *= 3
        else:
            res *= 6
        idx += 2
        flg = 1
print(res%MOD)


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

int main()
{
    // get a integer
    long long int x,i,k;
    cin >> k;

    x=100;
    for(i=0;i<10000000;i++)
    {
        x=x+x*0.01;
        if(x>=k) break;
    }
    cout << (i+1) ;

    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main( void )
{
    int a;
    int b;
    
    scanf("%d %d",&a,&b);
    
    if( a < b ){
        printf("a < b\n");
    } else if( a > b ){
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
        
    return 0;
}

Measured memory_bytes: 1800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  vector<vector<int>> a(n,vector<int>(26,0));
  rep(i,n){
    cin>>s[i];
    rep(j,s[i].size()){
      a[i][s[i][j]-'a']++;
    }
  }
  rep(i,26){
    int c=M;
    rep(j,n){
      chmin(c,a[j][i]);
    }
    rep(j,c)cout<<(char)('a'+i);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    char b; cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}



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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;

    ll n,k;
    cin>>n>>k;
    
    vector<ll> arr(n);
    for(auto &u: arr)
        cin>>u;
    
    for(ll j=0;j<min(k,50LL);j++){
        vector<ll> prefix(n+1, 0);
        
        for(ll i=0;i<n;i++){
            ll x = (i - arr[i] + 0.4);
            ll y = (i + arr[i] + 0.5);
            prefix[max(0LL,x)]++;
            prefix[min(y+1,n)]--;
        }
        
        for(ll i=1;i<n;i++)
            prefix[i] += prefix[i-1];
            
        for(ll i=0;i<n;i++)
            arr[i] = prefix[i];
    }
    
    for(ll i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<endl;
    
    return 0;
}


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

using namespace std;

const int maxn = 1e5 + 5;

int n, L, Q, x[maxn], go[maxn][20];

inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){u = u * 10 + ch - 48; ch = getchar();} return u * f;
}

inline void PreGo(int n, int L, int *x){
	int pos = 1;
	for(register int i = 1; i <= n; i++){
		while(pos <= n && x[pos] - x[i] <= L)pos++;
		go[i][0] = pos - 1;
	}
	for(register int j = 1; j <= 19; j++)
		for(register int i = 1; i <= n; i++)
			go[i][j] = go[go[i][j - 1]][j - 1];
}

int main(){
	n = read();
	for(register int i = 1; i <= n; i++)x[i] = read();
	L = read(); Q = read();
	PreGo(n, L, x);
	for(register int i = 1; i <= Q; i++){
		int a = read(), b = read(), now, ans = 0;
		if(a > b)swap(a, b);
		now = a;
		for(register int k = 19; ~k; k--)
			if(go[now][k] < b){
				now = go[now][k];
				ans |= (1 << k);
			}
		printf("%d\n", ans + 1);
	}
	return 0;
}
/*
9
1 3 6 13 15 18 19 29 31
10
4
1 8
7 3
6 7
8 5

*/

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
#define ld long double
const ll INF = 1e13;
const ll N = 1e4+5, D=105;
const ll mod= 1e9+7;
/*bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
*/
string s;
ll d,n,dp[N][D][2];
ll f(ll i, ll sum, bool flag)
{
	if(i==n) return sum==0;
	if(dp[i][sum][flag]!=-1) return dp[i][sum][flag];
	ll &ans = dp[i][sum][flag];
	ans = 0;
	ll l = 0, r=9;
	if(!flag) r = (s[i]-'0');
	loop(dig,l,r+1)
	{
		ll nsum = sum+dig;
		nsum%=d;
		bool nflag = flag||(dig<(s[i]-'0'));
		ans = ans+f(i+1,nsum,nflag);
		ans%=mod;
	}
	return ans;
}
void solve()
{
 cin>>s>>d;
 n=s.size();
 memset(dp,-1,sizeof(dp));
 cout<<(f(0,0,0)-1+mod)%mod;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    SORT(S);
    for(auto&& i : S)
    {
        cout << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,K,i;
    cin>>N>>K;
    long long h[N];
    for(i=0;i<N;i++){
        cin>>h[i];
    }
    sort(h,h+N);
    long long ans=2000000000;
    for(i=0;i<N-K+1;i++){
        if(h[i+K-1]-h[i]<ans){
            ans=h[i+K-1]-h[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

const int MAX = 2000005;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
  int n, k;
  cin >> n >> k;
  /*
  n-1 回以下で全パターンの移動が可能
  どこか 1 以上のとこがあるはずで, そこは移動しなくていい

  k 回ちょうどの移動で, 余った分は消費できる
  途中テキトーなとこを経由すればいい

  可能な移動は,
  合計 n
  0 が k 箇所以下

  0 の個数で探索

  n を n-i 箇所に分配
  それぞれ 1 以上
  先に 1 分配

  残り n-(n-i) = i を n-i 箇所に分配
  i + (n-i-1) C i
  i 個の数と n-i-1 個の仕切りから i 個の数を選ぶ組み合わせ
  */
  chmin(k, n - 1);
  COMinit();
  ll ans = 0;
  rep(i, k + 1) {
    add(ans, COM(n, i) * COM(i + (n - i - 1), i) % mod);
  }
  cout << ans << endl;
}


Measured memory_bytes: 47104
from pprint import pprint
n,m = map(int, input().split())
a = list()
for i in range(n):
    a.append(input())
b = list()
for i in range(m):
    b.append(input())
a_len = len(a[0])
b_len = len(b[0])
for i in range(a_len-b_len+1):
    for j in range(n-m+1):
        check = True
        for k in range(m):
            if a[k+j][i:i+b_len] == b[k]:
                pass
            else:
                check = False
                break
        if check == True:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N, K;
    cin >> N >> K;
    if(K%2){
        ll q = N/K;
        cout << q*q*q << endl;
        return 0;
    }else{
        ll q = N/K;
        K /= 2;
        ll q2 = N/K;
        q2 -= q;
        cout << q*q*q + q2*q2*q2 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
//#include<>
using namespace std;

typedef long long int64;
typedef int int32;
typedef char int8;

#define rep(i,j) for(int i=0;i<j;i++)
#define repeat(i,j,k) for(i=(j),i<(k);i++)
#define repeat_eq(i,j,k) for(i=(j),i<=(k);i++)
#define rev_rep(i,j,k) for(i=(j)-1;i>=k;i--)
#define all(v) (v).begin(),(v).end()

const int INF=1<<30;//=10E10

int main()
{
  while(true){
      int n;cin>>n;
      if(n==0)break;
      vector<int> v;
      rep(i,n){
	int t;cin>>t;
	v.push_back(t);
      }
      sort(all(v));
      int ans=0;
      for(int i=1;i<v.size()-1;i++)
	ans+=v[i];
      cout<<ans/(v.size()-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int x);
int pop();

int top=0,S[1000];

int main(){
  int a,b,top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
    printf("%d\n",pop());
  return 0;
}

void push(int x){
  S[++top]=x;
}
int pop(){
  top--;
  return S[top+1];
}


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

void solve()
{
    int x;
    cin >> x;

    if(x <= 599)
    {
        cout << 8;
    }
    else if(x <= 799)
    {
        cout << 7;
    }
    else if(x <= 999)
    {
        cout << 6;
    }
    else if(x <= 1199)
    {
        cout << 5;
    }
    else if(x <= 1399)
    {
        cout << 4;
    }
    else if(x <= 1599)
    {
        cout << 3;
    }
    else if(x <= 1799)
    {
        cout << 2;
    }
    else
    {
        cout << 1;
    }
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    // int t;
    // cin >> t;
    
    // while(t--)
    // {
        solve();
    // }

    return 0;
}


Measured memory_bytes: 3644
#![allow(unused_imports)]
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;
use std::str::FromStr;
use std::cmp::Reverse;

type Error = Box<dyn std::error::Error>;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct Scanner {
    buff: Vec<String>,
    pos: usize,
}


impl Scanner {
    pub fn new() -> Self {
        Scanner {
            buff: Vec::new(),
            pos: 0,
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        while self.buff.len() <= self.pos {
            self.pos = 0;
            self.buff = read_line().split_whitespace().map(|s| s.to_owned()).collect();
        }

        let result = self.buff[self.pos].parse::<T>();
        self.pos += 1;
        result.ok().unwrap()
    }

    pub fn next_line(&mut self) -> String {
        let result  = read_line().trim().to_owned();
        self.buff.clear();
        self.pos = 0;

        result
    }

    pub fn next_vec<T: FromStr>(&mut self) -> Vec<T> {
        self.buff.clear();
        self.pos = 0;
        read_line().trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect()
    }
    
    pub fn next_line_chars(&mut self) -> Vec<char> {
        let result  = read_line().trim().chars().collect();
        self.buff.clear();
        self.pos = 0;

        result
    }
}


fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let k: usize = scan.next();
    let a: Vec<u64> = scan.next_vec(); 

    let mut b = Vec::with_capacity(n * (n+1) / 2);
    for i in 0..n {
        let mut tmp = 0;
        for j in i..n {
            tmp += a[j];
            b.push(tmp);
        }
    }

    let mut ans = 0;

    for i in (0..63).rev() {
        let tar = (1u64 << i) | ans;
        let mut count = 0;
        for &x in b.iter() {
            if (x & tar) == tar {
                count += 1;
            }
        }
        if count >= k {
            ans = tar;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
int a[1234567];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
    cin >> a[i];
    a[i] -= i;
    }
    sort(a+1, a+n+1);
    long long ans1=0,ans2=0;
    int mid = a[(n+1)/2];
    for(int i = 1; i <= n; i++){
        ans1 += abs(a[i] - mid);
    }
    cout<< ans1<<endl;
    return 0;
}


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

int main(){
  int n,x;
  cin>>n>>x;
  vector<int> a;
  int b;
  for(int i=0;i<n;i++){
    cin>>b;
    a.push_back(b);
  }
  int saishou=*min_element(a.begin(),a.end());
  for(int i=0;i<n;i++){
    x-=a[i];
  }
  while(x>0){
    x-=saishou;
    if(x<0){
      break;
    }
    n++;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int n; cin >> n;
  vl a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  deque<ll> b;
  b.push_back(a[0]);
  int j = n-1, k = 1;
  rep(i,n-1) {
    if(i%4 == 0){
      b.push_back(a[j]);
      j--;
    } 
    else if(i%4 == 1){
      b.push_front(a[j]);
      j--;
    }
    
    else if(i%4 == 2){
      b.push_back(a[k]);
      k++;
    }
    
    else if(i%4 == 3){
      b.push_front(a[k]);
      k++;
    }
  }
  ll sum1 = 0LL;
  //rep(i,n) cout << b[i] << " ";cout << endl;
  rep(i,n-1) sum1 += abs(b[i+1]-b[i]);

  reverse(all(a));
  b.resize(0);
  b.push_back(a[0]);
  j = n-1, k = 1;
  rep(i,n-1) {
    if(i%4 == 0){
      b.push_back(a[j]);
      j--;
    } 
    else if(i%4 == 1){
      b.push_front(a[j]);
      j--;
    }
    
    else if(i%4 == 2){
      b.push_back(a[k]);
      k++;
    }
    
    else if(i%4 == 3){
      b.push_front(a[k]);
      k++;
    }
  }
  ll sum2 = 0LL;
  //rep(i,n) cout << b[i] << " ";cout << endl;
  rep(i,n-1) sum2 += abs(b[i+1]-b[i]);

  ll ans = max(sum1,sum2);
  cout << ans << endl;
}


Measured memory_bytes: 1920
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

import math

mod = int(1e9+7)

N = int(input())
S = input()

""" 
##for test
N = 100000
S = 'B'*(2*N)
#print(S)
"""

rest = 0
cnt = 1
for i in range(2*N):
  if (i%2 == 0 and S[i]=='B') or (i%2 == 1 and S[i]=='W'): ## 続行
    rest += 1
  else: ## 枝を一つ繋げる
    if rest < 1: ## 繋げる枝がない場合
      print(0)
      exit()
    else:
      cnt = (cnt * rest) % mod
      rest -= 1
else:
  if rest != 0: ## 繋ぐことのできなかった枝が残っている場合
    print(0)
    exit()

ans = cnt * (math.factorial(N) % mod) % mod
print(ans)

Measured memory_bytes: 4328
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;


ll mpow(ll x, ll n);
int main(void);


__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n>=1){
        if(n%2 == 0){
            x = x * x %MOD;
            n = n/2;
        }else{
            ans = ans * x %MOD;
            n = n-1;
        }
    }
    
    return ans;
}
 

int main(void){
	ll N, M;
    VL s, c;
    vector<pair<ll,ll>> p;
    cin >> N >> M;
    if(M == 0){
        ll ans = mpow(10,N-1);
        if(ans == 1) ans = 0;
         cout << ans << endl;
    }else{

        rep(i,M){
            ll s0, c0;
            pair<ll, ll> p0;
            cin >> s0 >> c0;
            s.PB(s0);
            c.PB(c0);
            p.PB(make_pair(s0,c0));
        }

        ll ans = 0;

        sort(all(p));

        ll max = p[M-1].first;
        if(p[0].first > 1) ans += mpow(10,N-1);
        //cout << max << endl;
        ll fir = 0;
        ll sec = 0;
        rep(i,M){
            if(p[i].first == fir && p[i].second != sec){
                ans = -1;
                break;
            }
            if((p[i].first == 1 && p[i].second == 0) && N>1){
                ans = -1;
                break;
            }
            if(p[i].first > fir){
                ans += p[i].second * mpow(10,N-p[i].first);
                //cout << p[i].second * mpow(10,max-p[i].first) << endl;
            }
            //cout << p[i].first SP p[i].second << endl;
            fir = p[i].first;
            sec = p[i].second;
        }

        
         cout << ans << endl;
    }
   

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int deg[N];
long long mx[N],sum[N],s[N];
vector<int> g[N];
int main(){
	queue<int> q;
	int n,a,b;
	bool flag=true;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&s[i]);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
		deg[a]++;
		deg[b]++;
	}
	for(int i=1;i<=n;i++){
		if(deg[i]==1){
			q.push(i);
			mx[i]=s[i];
			sum[i]=s[i];
		}
	}
	while(!q.empty()){
		int u=q.front();
		//printf("%d\n",u);
		long long left=sum[u]-s[u];
		if(left<0||left>s[u]||sum[u]-mx[u]<left) {
			flag=false;
			break;
		}
		//puts("pass");
		s[u]-=left;
		q.pop();
		if(q.empty()&&s[u]>0) flag=false;
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			deg[v]--;
			mx[v]=max(mx[v],s[u]);
			sum[v]+=s[u];
			if(deg[v]==1) q.push(v);
		}
	}
	if(flag) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 8832
N = int(input())


def isprime(n):
    if n==1:
        return False
    for i in range(2,n):
        if n%i == 0:
            return False
    return True

for i in range(31,55556,30):
    if isprime(i):
        if i != 31:print(" ", end="")
        print(i ,end="")
        N -= 1
    if N==0:
        break
print()


Measured memory_bytes: 3060
while True:
    x=input().split()
    y=[int(x[0]),int(x[1])]
    if y[0]==0 and y[1]==0:
        break
    elif y[0]<y[1]:
        print("{} {}".format(y[0],y[1]))
    elif y[0]>y[1]:
        print("{} {}".format(y[1],y[0]))
    else:
        print("{} {}".format(y[0],y[1]))


Measured memory_bytes: 5620
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Measured memory_bytes: 113752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  int a=1,ans=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    int j=i;
    while(j){
      if(j%2==0)cnt++;
      j/=2;
    }
    if(cnt>ans){
      ans=cnt;
      a=i;
    }
  }
  cout<<a<<endl;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int a;

int main()
{
    _FastIO;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define xll __int128
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

ll max(ll a,ll b){
	if(a>b){return a;}
	return b;	
} 
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	ll m1 = 1LL*a*c;
	ll m2 = 1LL*a*d;
	ll m3= 1LL*b*c;
	ll m4 =1LL*b*d;
	cout<< max(max(m1,m2),max(m3,m4))<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


Measured memory_bytes: 3672
#include <iostream>
#include <queue>

int64_t solve(int k) {
  std::queue<int64_t> q;
  for (int i = 1; i < 10; ++i) q.push(i);
  while (k) {
    int64_t v = q.front();
    if (k == 1) return v;
    q.pop();
    int d = v % 10;
    if (d != 0) q.push(10 * v + d - 1);    
    q.push(10 * v + d);
    if (d != 9) q.push(10 * v + d + 1);
    --k;
  }
}

int main() {
  int k;
  std::cin >> k;
  std::cout << solve(k) << std::endl;
  return 0;
}


Measured memory_bytes: 1792
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        ll n;
        cin >> n;
         set<string>a;
        while(n--)
        {
            string s;

            cin >> s;
            a.insert(s);
        }
        cout<< sz(a)<< endl;



    }
    return 0;
}


Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

int main()
{
  Hello;
  
  long long int a, c=1;
  cin>>a;
  
  while(a>0)
  {
    if(a>1)
    {
      a/=2;
      c*=2;
    }
    else if(a==1)
    {
      a-=1;
      c+=c-1;
    }
  }
  
  cout<<c;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c;
   
    if (a>b) {
        d = a;
        a = b;
        b = d;
        }
    if (b>c){
        d = b;
        b = c;
        c = d;
        }
    if (a>b){
        d = a;
        a = b;
        b = d;
        
        }
    cout << a << " " <<b <<  " " << c <<endl;
    }


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main() {
    int n;cin >> n;int a[n];int count = 0;for (int i = 0; i < n; i++) cin >> a[i];for (int i = 0; i < n; i++) {while (i + 1 < n && a[i] == a[i + 1]) i++; if (i + 1 < n && a[i] > a[i + 1]) while(i + 1 < n && a[i] >= a[i + 1]) i++;else if (i + 1 < n && a[i] < a[i +1]) while (i + 1 < n && a[i] <= a[i + 1]) i++;count++;}cout << count;
}

Measured memory_bytes: 888