akhauriyash/Code-Regression huggingface dataset:
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    N, M = map(int, file().split())
    broken = set()
    for i in range(M): broken |= {int(file())}

    DP = [0] * (N + 1)
    DP[0] = 1
    for i in range(N):
        if i + 1 not in broken: 
            DP[i+1] += DP[i]
            DP[i+1] %= mod
        if i + 2 <= N:
            if i + 2 not in broken:
                DP[i+2] += DP[i]
                DP[i+2] %= mod
    print(DP[N])
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 12392
#include <iostream>
using namespace std;
int main()
{
	int n,m,x=0;
	cin>>n>>m;
	for(int i=n;i<=m;i++)
	{
		if(i/10000==i%10&&i/1000%10==i%100/10)
		x++;
	}cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
/* Author rumoisen */
/* created 2018/11/08 */

#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <iostream>

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

using namespace std;

int main(void)
{
    int r,g;
    cin>>r>>g;
    cout<<g*2-r<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
int a[111111],b[111111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	int cnt=0;
	rep(i,n){
		if(a[i]<b[i]){
			cnt+=ceil2(b[i]-a[i],2);
			a[i]+=ceil2(b[i]-a[i],2)*2;
		}
	}
	rep(i,n){
		if(a[i]>b[i]){
			cnt-=(a[i]-b[i]);
		}
	}
	if(cnt<0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll digit_sum(ll n) {
    if (n < 10) return n;
    return digit_sum(n / 10) + n % 10;
}
#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t; cin >> s >> t;
    int SL = s.size();
    int TL = t.size();

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    bool ok = false;
    REP(i,SL) {
        if (s[i] < t[i]) {
            ok = true;
            break;
        }
    }

    if (SL < TL && s==t.substr(0, SL)) ok = true;

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
unsigned long long MOD = 1e9 + 7;
ll INF = 1e18;
long long modMult(long long a, long long b, long long m)
{
    long long res = 0;
    long long exp = a % m;
    while (b)
    {
        if (b & 1)
        {
            res += exp;
            if (res > m)
                res -= m;
        }
        exp <<= 1;
        if (exp > m)
            exp -= m;
        b >>= 1;
    }
    return res;
}
long long powMod(long long a, long long b, long long m)
{
    long long res = 1;
    long long exp = a % m;
    while (b)
    {
        if (b & 1)
            res = modMult(res, exp, m);
        exp = modMult(exp, exp, m);
        b >>= 1;
    }
    return res;
}
//powMod(a,b,MOD)
//O(log(b))?
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> vec(n);
    vector<ll> reg(100, 0);
    rep(i, n)
    {
        cin >> vec[i];
    }
    rep(i, n)
    {
        for (ll j = 61; j >= 0; j--)
        {
            ll k=j;
         //   cout<<(1<<k)<<endl;
            if (((ll)1<<j) <= vec[i])
            {
                reg[j]++;
                vec[i] -= ((ll)1<<j);
            }
        }
    }
  //  rep(i,61)cout<<reg[i]<<" ";
    cout<<endl;
    ll res=0;
  	ll g=1;
    rep(i, 62)
    {
        ll k=g;
        ll f=reg[i]*(n-reg[i]);
        f%=MOD;
        ll p=k*f%MOD;
        res += p;
        res %= MOD;
        g*=2;
        g%=MOD;
    }
    cout << res%MOD << endl;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	string a, b, c;
	cin >> a >> b >> c;

	cout << (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
r=0
for i in range (n-2):
    for j in range (i+1,n-1):
        for k in range (j+1,n):
            if a[i]+a[j]>a[k] and a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i]:
                r+=1
                #print(a[i],a[j],a[k])
print(r)

Measured memory_bytes: 9180
def main():
    n = int(input())
    a = list(map(int,input().split()))
    x = []
    q = 0
    ans_list = []
    x = a[0]
    s = a[0]
    for i in range(n):
        while True:
            if q == n-1:
                ans_list.append((i,q))
                break
            else:
                tx = x^a[q+1]
                ts = x+a[q+1]
                if tx != ts:
                    ans_list.append((i,q))
                    x ^= a[i]
                    s -= a[i]
                    if i == q:
                        q += 1
                        x = a[q]
                        y = a[q]
                    break
                else:
                    q += 1
                    x = tx
                    s = ts
    ans = 0
    for i in ans_list:
        ans += i[1]-i[0]+1
    print(ans)
    
if __name__ == '__main__':
    main()

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  lol a=100;
  int i=0;
  while(a<n){
    a+=a/100;
    i++;
  }
  cout <<i<<'\n';
  return (0);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x,y,z;
    IN(x,y,z);
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,x,y,s[3],i,min;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	s[0]=(a*x)+(b*y);
	if(x>y){ 
	    s[1]=(x*2)*c;
	    s[2]=(y*2*c)+(x-y)*a;
	}
	else{
	    s[1]=(y*2)*c;
	    s[2]=(x*c*2)+(y-x)*b;
	}
	min=s[0];
	for(i=0;i<3;i++){
	    if(min>s[i]) min=s[i];

	}
	printf("%d\n",min);
	return 0;
}


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

#define mo 1000000007

int n;
int a[111111];
int b[111111];
pair<int, int> ran[111111];

int mul(int a, int b) {
	return 1LL*a*b%mo;
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	for(int i=1;i<=n;i++) scanf("%d", &b[i]);
	a[0] = b[n+1] = -1;
	for(int i=1;i<=n;i++)
		if(a[i] > a[i-1]) ran[i] = make_pair(a[i], a[i]);
		else ran[i] = make_pair(1, a[i]);
	for(int i=n;i>0;i--) {
		pair<int, int> p;
		if(b[i] > b[i+1]) p = make_pair(b[i], b[i]);
		else p = make_pair(1, b[i]);
		ran[i].first = max(ran[i].first, p.first);
		ran[i].second = min(ran[i].second, p.second);
	}
	int ans = 1;
	for(int i=1;i<=n;i++)
		if(ran[i].first > ran[i].second) ans = 0;
		else ans = mul(ans, ran[i].second - ran[i].first + 1);
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1792
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];


    int ans = 0;
    REP(i, 500000) {
        REP(j, a.size()) {
            if (a[j] >= N) {
                int num = a[j] / N;
                ans += num;
                a[j] -= N * num;
                REP(k, a.size()) if (k != j) a[k] += num;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
import java.io.*;
 
public class Main{
    
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        String S = s.next();
        if(S.length() <= K){
            System.out.println(S);
        }else{
            for(int i = 0; i < K; i++){
                System.out.print(S.charAt(i));
            }
            System.out.println("...");
        }
        

 
	}
} 

Measured memory_bytes: 35708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		long k = sc.nextLong();

		long x = 0;
		for (int i=1; i<=k; i++){

			x = x * 10 + 7;

			if (x % k ==0){
				System.out.println(i);
				return;
			}
			x %= k;
		}

		System.out.println("-1");
	}


}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> c(n + 1);
	c[0] = 3;
	ll ans = 1;
	rep(i, n) {
		if (c[a[i]] == 0) {
			cout << 0 << endl;
			return 0;
		}
		ans *= c[a[i]];
		ans %= mod;
		c[a[i]]--;
		c[a[i] + 1]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3996
N,M = list(map(int,input().strip().split(' ')))
P = list(map(int,input().strip().split(' ')))
X =[]
for i in range(M):
    X.append( list(map(int,input().strip().split(' '))))
    
    #initialize union-find tree
par = [i for i in range(1,N+1)]

def GetRoot(a):
    ind = a-1
    if par[ind]==a:
        return a
    else:
        par[ind] = GetRoot(par[ind])
        return par[ind]

def unite(a,b):
    aRoot,bRoot = GetRoot(a),GetRoot(b)
    if aRoot >= bRoot:
        par[aRoot-1] = bRoot
    else:
        par[bRoot-1] = aRoot
        
for j in X:
    unite(j[0],j[1])

result = 0
for p in P:
    if GetRoot(p) == GetRoot(P[p-1]):
        result = result+1
print(result)



Measured memory_bytes: 35292
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
int main(){
	int debt=100000;
	int n;
	cin >> n;
	rep(i,n){
	   if(debt%20000==0)debt = debt*1.05;
	   else debt = (int)(debt*1.05/1000+1)*1000;
	}
	cout << debt << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<functional>
using namespace std;
pair<long long int,int> dish[100001];
 
int main() {
	int n;
	cin>>n;
	long long int a[100001];long long int b[100001];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		dish[i]=make_pair(a[i]+b[i],i);
	}
	sort(dish,dish+n);
	long long int ans=0;
	for(int i=0;i<n;i++){
		if((n-1-i)%2==0){ans+=a[dish[i].second];}
		else{ans-=b[dish[i].second];}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    Set<String> set = new HashSet<String>();
    int n = scan.nextInt();
    String[] s = new String[n];
    for(int i = 0; i < n; i++){
      s[i] = scan.next();
      set.add(s[i]);
    }
    System.out.println(set.size());
  }
}

Measured memory_bytes: 79264
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
l = list(itertools.permutations(range(1,N+1)))
a = 0
b = 0
for n, val in enumerate(l):
    if list(val) == P:
        a = n+1
    if list(val) == Q:
        b = n+1
        if a != 0:
            break
print(abs(a-b))

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

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

	stringstream ans;
	if (s.length() <= k) {
		ans << s;
	} else {
		ans << s.substr(0, k) << "...";
	}
	cout << ans.str() << endl;
	return 0;
}

Measured memory_bytes: 3636
using System;

class Program
{
    static void Main()
    {
        //３つの整数 a、b、c を読み込み、a から b までの整数の中に、
        //c の約数がいくつあるかを求めるプログラムを作成してください。
        var line = Console.ReadLine().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var counter = 0;

        for (var i = a; i <= b; i++)
        {
            if (c % i == 0) counter++;
        }
 Console.WriteLine(counter);
    }
}


Measured memory_bytes: 7856
import itertools
N = int(input())
S = input()
out = S.count('R') * S.count('G') * S.count('B')

RGBs = list(itertools.permutations(['R', 'G', 'B'], 3))

for i in range(1, N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      out -= 1
print(out)

Measured memory_bytes: 68244
#include<iostream>
using namespace std;
int main(){
	int x,y;
	
	while(1){
		cin>>x>>y;
		if(x==0 && y==0)
			break;
		if(x<=y)
			cout<<x<<" "<<y<<"\n";
		else if(y<=x)
			cout<<y<<" "<<x<<"\n";
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int dic[101];
	int data;
	int max_data = 0;
	
	for (int i=0; i<101; i++) dic[i] = 0;
	while (cin >> data)
	{
		dic[data]++;
		max_data = max(max_data, dic[data]);
	}
	for (int i=0; i<101; i++)
	{
		if (dic[i] == max_data)
		{
			cout << i << endl;
		}
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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


void solve() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        cout << s << "\n";
        cout << s << "\n";
    }
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) Yes();
  else No();
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

work_days_early = []
counter = 0
i = 0
while i < N:
    if S[i] == 'o':
        work_days_early.append(i+1)
        counter += 1
        if counter >= K:
            break
        i += C
    i += 1

work_days_late = []
counter = 0
i = N-1
while i >= 0:
    if S[i] == 'o':
        work_days_late.append(i+1)
        counter += 1
        if counter >= K:
            break
        i -= C
    i -= 1
work_days_late.reverse()

work_days_necessary = []
for day1, day2 in zip(work_days_early , work_days_late):
    if day1 == day2:
        work_days_necessary.append(day1)

print(*work_days_necessary, sep = '\n')

Measured memory_bytes: 25356
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

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

// 二項係数計算
long long 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;
}



int main()
{
	ll  i, j, k, l, m, sum, flag, N,  M, K, H, W, B;
	sum = 0;
	flag = 0;
	cin >> N;
	vector<ll>x(N);
	vector<ll>y(N);
	vector<ll>h(N);
	REP(i, 0, N) {
		cin >> x[i] >> y[i] >> h[i];
	}
	REP(i, 0, 101) {
		REP(j, 0, 101) {
			flag = 0;
			REP(k, 0, N) {
				if (h[k] != 0) {
					H = abs(x[k] - i) + abs(y[k] - j) + h[k];
					break;
					
				}
			}
			REP(k, 0, N) {
				if (fmax(H - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]) {
					flag = 1;
					break;
				
				}
				}
			if(flag==0){
				break;
			}

		}
		if (flag == 0) {
			break;
		}
	}
	cout << i << " " << j << " " << H;
	
}













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

const int N = 220000;
const int INF = 1e9 + 1e8;

char str[N];
int dp[1 << 26];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	cin >> str;
	int len = strlen(str);
	
	for (int s = 0; s < (1 << 26); s++) dp[s] = INF;
	int cur = 0;
	dp[0] = 0;
	int ans = 0;
	for (int i = 0; i < len; i++) {
		cur ^= 1 << str[i] - 'a';
		int ret = INF;
		ret = min(ret, dp[cur] + 1);
		for (int j = 0; j < 26; j++) ret = min(ret, dp[cur ^ (1 << j)] + 1);
		dp[cur] = min(dp[cur], ret);
		ans = ret;
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 265956
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
int i;
main()
{
    char s[123];
    cin>>s;
    if(s[3]==s[2] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	ll b[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	ll c;
	for(int i = 0; i < n; i++){
		cin >> c;
		b[i] = a[i]-c;
	}
	sort(b, b+n);
	ll minus = 0;
	int ans = 0;
	int i;
	for(i = 0; i < n; i++){
		if(b[i] < 0)minus -= b[i], ans++;
		else break;
	}
	for(int j = n-1; j > i-2; j--){
		if(j == i-1){
			if(minus > 0)cout << -1 << endl;
			else cout << ans << endl;
			break;
		}
		if(minus > 0)minus -= b[j], ans++;
		else{
		    cout << ans << endl;
			break;
		}
	}
	return 0;
}

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


int main(){
int N;
cin>>N;
pair<pair<string, int>,int> p[110];
for(int i = 0; i < N; i++){
    string s;
    int t;
    cin >> s>>t;
p[i]=make_pair(make_pair(s,-t),i);

}sort(p,p+N);
for(int i = 0;i<N;i++)cout<<p[i].second+1<<endl;

}



Measured memory_bytes: 256
import heapq
import math


def main():
    nvertices, nedges, s = map(int, input().split())
    edges = [[] for i in range(nvertices)]
    for i in range(nedges):
        u, v, w = map(int, input().split())
        edges[u].append((v, w))
    INF = float('inf')
    hq = [(0, s)]
    weights = [INF] * nvertices
    weights[s] = 0
    while hq:
        d, u = heapq.heappop(hq)
        if d > weights[u]:
            continue
        for v, w in edges[u]:
            if weights[u] + w < weights[v]:
                weights[v] = weights[u] + w
                heapq.heappush(hq, (weights[v], v))

    for w in weights:
        print("INF" if math.isinf(w) else w)


main()

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

using namespace std;
typedef long long ll;
const int mod = (int) 1e9 + 7;

ll modPow(ll n, ll k) {
	ll res = 1;
	for (n %= mod; k; k >>= 1) {
		if (k & 1)
			res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}

ll modInv(ll x) {
	return modPow(x, mod - 2);
}

const int MaxN = 3002;

const ll Half = modInv(2);
ll dp[MaxN + 1][MaxN + 1];

void avg(ll &x, ll &y) {
	x = y = (x + y) % mod * Half % mod;
}

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

	int n, Q;
	cin >> n >> Q;

	{
		static ll a[MaxN + 9];
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				dp[i][j] = a[i] > a[j];
	}

	for (int rep = 0; rep < Q; ++rep) {
		int i, j;
		cin >> i >> j;
		--i, --j;

		avg(dp[i][j], dp[j][i]);

		for (int k = 0; k < n; ++k)
			if (k != i && k != j) {
				avg(dp[i][k], dp[j][k]);
				avg(dp[k][i], dp[k][j]);
			}
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			(ans += dp[i][j]) %= mod;

	ans *= modPow(2, Q);

	cout << (ans % mod + mod) % mod;
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	int m;
	cin>>m;
	if(m%1000)
	cout<<1000-m%1000<<endl;
	else
	cout<<0<<endl;
}



Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));


int dp[11000];

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

    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    for(int i=0;i<M;i++) cin>>A[i];
    int need[]={0,2,5,5,4,5,6,3,7,6};
    for(int i=0;i<N;i++){
        if(i!=0 && dp[i]==0) continue;
        for(int j=0;j<M;j++){
            int x=need[A[j]];
            chmax(dp[i+x],dp[i]+1);
        }
    }
    int now=N;
    sort(A.rbegin(),A.rend());
    while(now!=0){
        for(int i=0;i<M;i++){
            int x=need[A[i]];
            if(now-x<0 || (now-x!=0 && dp[now-x]==0)) continue;
            if(dp[now]==dp[now-x]+1){
                cout<<A[i];
                now-=x;
                break;
            }
        }
    }
    cout<<endl;


}

Measured memory_bytes: 256
def f(a):
    for i in a:
        if i % 2 == 1:
            pass
        elif i % 2 == 0 and (i % 3 == 0 or i % 5 == 0):
            pass
        else:
            print('DENIED')
            break
    else:
        print('APPROVED')

n = int(input())
a = list(map(int, input().split()))
f(a)


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

string s[55];
int cnt[55][26];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
        for(int j=0;j<s[i].length();j++){
            cnt[i][s[i][j]-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        int mn = 1e9;
        for(int j=0;j<n;j++){
            mn = min(mn, cnt[j][i]);
        }
        for(int j=0;j<mn;j++) printf("%c", i+'a');
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;

typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1e9 + 7;

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

    int n; string s1, s2;
    cin >> n >> s1 >> s2;
    
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (s1[i] == s2[i]) {
            if (i == 0) ans = 3;
            else if (s1[i - 1] == s2[i - 1]) ans = (ans * 2) % MOD;
        }
        else {
            if (i == 0) ans = 6;
            else if (s1[i - 1] == s2[i - 1]) ans = (ans * 2) % MOD;
            else ans = (ans * 3) % MOD;
            i++;
        }
    }

    cout << ans << endl;
}

/*
USE LONG LONG!!!!

:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:

          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools


def main():
  H, W = map(int, input().split())
  M = list(itertools.chain.from_iterable([[c == '.' for c in input().strip()] for _ in range(H)]))
  size = W * H
  dist = [[size] * (size) for _ in range(size)]

  for i in range(size):
    if not M[i]:
      continue

    x, y = i % W, i // W

    dist[i][i] = 0

    if x > 0 and M[i - 1]:
      dist[i][i - 1] = 1
      dist[i - 1][i] = 1

    if y > 0 and M[i - W]:
      dist[i][i - W] = 1
      dist[i - W][i] = 1

  for i in range(size):
    for j in range(size):
      for k in range(size):
        if M[j] and M[k]:
          dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

  r = 1

  for v in itertools.chain.from_iterable(dist):
    if v < size:
      r = max(r, v)

  print(r)


if __name__ == '__main__':
  main()


Measured memory_bytes: 42224
#include "bits/stdc++.h"
using namespace std;

// 2数の最大公約数を求める
int GCD(int b, int a){
	
	int c = a;
	if(a<b){
		int temp = a;
		a = b;
		b = temp;
	}
	while (c!= 0){
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}


int main(){

	int N; 
	long tmp;
	vector<long> A;

	cin >> N;
	
	for (int i = 0 ; i < N; i++){
		cin >> tmp;
		A.push_back(tmp);
	}

	sort(A.begin(),A.end());
	//A.erase(unique(A.begin(), A.end()), A.end());

	int L = A.size();

	

	long ans;
	long tmp_skip_number;
	long max_ans = 1;
	for (int skip_number = 0 ; skip_number < L; skip_number++){

		if (A[skip_number]==tmp_skip_number){
			continue;
		}
		tmp_skip_number = A[skip_number];

		if (skip_number==0){
			ans = A[1];
		}else{
			ans = A[0];
		}

		for (int i = 0 ; i < L; i++){

			if (i != skip_number){
				ans = GCD(ans, A[i]);
			}
			
		}
		if (ans > max_ans){
			max_ans = ans;
		}
	}
	cout << max_ans << endl;
	

	return 0;
}



Measured memory_bytes: 1400
import numpy as np

n,m=map(int,input().split())
A=np.zeros([m,n])
for i in range(m):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        A[i][a[j+1]-1]=1
p=list(map(int,input().split()))
count=0
for i in range(2**n):
    ss=bin(i)
    s=ss[2:len(ss)].zfill(n)
    flag=1
    for j in range(m):
        x=0
        for h in range(n):
            x+=int(s[h])*A[j,h]
        if(x%2!=p[j]):
            flag=0
            break
    if(flag==1):
        count+=1
print(count)


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

#define MOD 1000000007
typedef long long LL;

struct node{
	char c;
	LL l;
	};

node a[2005],b[1005],c[1005],d[2005];
int na,nb,nc,nd;

int main(){
	char e;
	int i,j,k;
	while(scanf(" %c",&e)&&e!='$'){
		a[na].c=e;
		scanf("%lld",&a[na++].l);
		}
	while(scanf(" %c",&e)&&e!='$'){
		b[nb].c=e;
		scanf("%lld",&b[nb++].l);
		}
	while(scanf(" %c",&e)&&e!='$'){
		c[nc].c=e;
		scanf("%lld",&c[nc++].l);
		}
	for(i=0;i<=na-nb;i++){
		if(a[i].c!=b[0].c||a[i].l<b[0].l)	continue;
		if(nb==1){
			for(nd=0;nd<i;nd++)
				d[nd]=a[nd];
			for(k=0;k<nc;k++)
				d[nd++]=c[k];
			if(a[i].l>b[0].l){
				d[nd]=a[i];
				d[nd++].l-=b[0].l;
				}
			for(k=i+1;k<na;k++)
				d[nd++]=a[k];
				break;
				}
			else{
				for(j=1;j<nb;j++){
					if(a[i+j].c!=b[j].c||a[i+j].l!=b[j].l)	break;
					}
				if(j>=nb-1){
					if(a[i+nb-1].c==b[nb-1].c&&a[i+nb-1].l>=b[nb-1].l){
						for(nd=0;nd<i;nd++)
							d[nd]=a[nd];
						if(a[i].l>b[0].l){
							d[nd]=a[i];
							d[nd++].l-=b[0].l;
							}
						for(k=0;k<nc;k++)
							d[nd++]=c[k];
						if(a[i+nb-1].l>b[nb-1].l){
							d[nd]=a[i+nb-1];
							d[nd++].l-=b[nb-1].l;
							}
						for(k=i+nb;k<na;k++)
							d[nd++]=a[k];
						break;
						}
					}
				}
			}
		if(i<=na-nb){
		na=0;
		a[na]=d[0];
		for(i=1;i<nd;i++){
			if(d[i].c==a[na].c)
				a[na].l+=d[i].l;
			else
				a[++na]=d[i];
			}
		na++;
		}
	for(i=0;i<na;i++)
		printf("%c %lld ",a[i].c,a[i].l);
	printf("$\n");
	return 0;
	}

Measured memory_bytes: 2824
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

const long long  INF = 1e18;

int main(){
   int n;
   cin >> n;
   long long a[n], b[n];
   float ave = 0;
   for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i]-i-1;
   }
   sort(b, b+n);
   ave = b[n/2];

   long long tmp = INF;
   for (int b = (int)ave-90; b < (int)ave+90; b++){
      long long z = 0;
      for (int i = 0; i < n; i++){
         z += abs(a[i]-i-1-b);
      }
      tmp = min(tmp, z);
   }
   cout << tmp << endl;
}


Measured memory_bytes: 3328
//2017-5-25 20:32
//2017-5-25 21:04
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;

LL n, m;

int main(){
	while(~scanf("%lld %lld", &n, &m)){
		if(n % 3 == 0 || m % 3 == 0){ printf("0\n"); continue;}
		LL ans = 1LL << 60;
		for(int i = 1; i <= n; i++){
			LL s[3];
			s[0] = m * i;
			s[1] = m / 2 * (n - i);
			s[2] = (m + 1) / 2 * (n - i);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
			s[0] = m * i;
			s[1] = (n - i) / 2 * m;
			s[2] = (n - i + 1) / 2 * m;
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
		}
		for(int i = 1; i <= m; i++){
			LL s[3];
			s[0] = n * i;
			s[1] = n / 2 * (m - i);
			s[2] = (n + 1) / 2 * (m - i);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
			s[0] = n * i;
			s[1] = (m - i) / 2 * n;
			s[2] = (m - i + 1) / 2 * n;
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Q, Group[int(1e4 + 5)];
int C, X, Y;

int Unite(){
  int GX = Group[X], GY = Group[Y];
  while (GX != Group[GX]) GX = Group[GX];
  while (GY != Group[GY]) GY = Group[GY];
  
  int G = min(GX, GY);
  Group[GX] = G; Group[GY] = G;
  Group[X] = G; Group[Y] = G;
  return 0;
}

int Same(){
  int GX = Group[X], GY = Group[Y];
  while (GX != Group[GX]) GX = Group[GX];
  while (GY != Group[GY]) GY = Group[GY];

  if (GX == GY) printf("1\n");
  else printf("0\n");

  Group[X] = GX;
  Group[Y] = GY;

  return 0;
}

int main(){
  scanf("%d%d", &N, &Q);
  for (int i = 0; i < N; i++) Group[i] = i;

  for (int i = 0; i < Q; i++){
    scanf("%d%d%d", &C, &X, &Y);
    if (C == 0) Unite();
    else Same();
  }
  
  return 0;
}



Measured memory_bytes: 3196
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, m: usize,
        scv: [(Usize1, char); m]
    };

    let mut res = std::usize::MAX;
    for x in 0..10.pow(n as u32) {
        let digits = x.to_string().chars().collect::<Vec<char>>();
        if digits.len() != n {
            continue;
        }
        let is_ok = scv.iter().all(|&(s, c)| s < digits.len() && digits[s] == c);
        if is_ok && x < res {
            res = x;
        }
    }
    let res = if res == std::usize::MAX {
        -1
    } else {
        res as isize
    };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2252
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

double eps = 1e-7;

struct point{
    double x,y;
    
    point(){}
    point(double _x, double _y) : x(_x), y(_y) {}
    
    point operator + (point P){
        return point(x + P.x,y + P.y);
    }
    
    point operator - (point P){
        return point(x - P.x,y - P.y);
    }
    
    point operator * (double t){
        return point(x * t,y * t);
    }
    
    double dot(point P){
        return x * P.x + y * P.y;
    }
    
    double cross(point P){
        return x * P.y - y * P.x;
    }
    
    double dist(point P){
        return sqrt((x - P.x) * (x - P.x) + (y - P.y) * (y - P.y));
    }
}s,e,M[5][2];

int n,ind[6];

double area(point a, point b, point c){
    return a.x * b.y + b.x * c.y + c.x * a.y - a.y * b.x - b.y * c.x - c.y * a.x;
}

bool cross(point a, point b, point c, point d){
    return area(a,b,c) * area(a,b,d) < eps && area(c,d,a) * area(c,d,b) < eps;
}

point intersection(point a, point b, point c, point d){
    return a + (b - a) * ((c - a).cross(d - c) / (b - a).cross(d - c));
}

point projection(point x, point a, point b){
    return a + (b - a) * ((x - a).dot(b - a) / (b - a).dot(b - a));
}

point reflection(point x, point a, point b){
    return x + (projection(x,a,b) - x) * 2;
}

bool check(int m, point E){
    int prev = -1,cur;
    point S = s;
    
    for(int i = m - 1;i >= 0;--i){
        cur = ind[i];
        
        if(!cross(S,E,M[cur][0],M[cur][1])) return false;
        
        point X = intersection(S,E,M[cur][0],M[cur][1]);
        
        for(int j = 0;j < n;++j)
            if(j != prev && j != cur && cross(S,X,M[j][0],M[j][1]))
                return false;
        
        S = X;
        E = reflection(E,M[cur][0],M[cur][1]);
        prev = cur;
    }
    
    for(int j = 0;j < n;++j)
        if(j != prev && cross(S,E,M[j][0],M[j][1]))
            return false;
    
    return true;
}

double ans;

void dfs(int m, int last){
    if(m == 6) return;
    
    point e2 = e;
    
    for(int i = 0;i < m;++i)
        e2 = reflection(e2,M[ ind[i] ][0],M[ ind[i] ][1]);
    
    if(check(m,e2)) ans = min(ans,s.dist(e2));
    
    for(int i = 0;i < n;++i){
        if(i != last){
            ind[m] = i;
            dfs(m + 1,i);
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    
    while(true){
        cin >> n;
        
        if(n == 0) break;
        
        for(int i = 0;i < n;++i)
            cin >> M[i][0].x >> M[i][0].y >> M[i][1].x >> M[i][1].y;
        
        cin >> s.x >> s.y;
        cin >> e.x >> e.y;
        
        ans = 1e15;
        
        dfs(0,-1);
        
        cout << fixed << setprecision(4) << ans << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{
	long long int N, a[200005],sum  = 0,x = 0,ans = 1000000000000;

	cin >> N;

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

	for (int i = 0; i < N-1; i++) {
		x += a[i];
		ans = min(ans, abs(2 * x - sum));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
  lint N, K; cin >> N >> K;
  string s; cin >> s;
  vector<lint> data;
  if(s[0] == '0') data.push_back(0);
  for(lint i = 0; i < s.size();) {
    lint j = i;
    while (j < s.size() && s[j] == s[i]) ++j; 
    data.push_back(j - i);
    i = j;
  }
  if(s.back() == '0') data.push_back(0);
  vector<lint> sum(data.size() + 1, 0);
  for(lint i = 0; i < data.size(); i++) sum[i + 1] = sum[i] + data[i];
  lint ans = 0;
  for(lint left = 0; left < sum.size(); left += 2){
    lint right = left + 2 * K + 1;
    right = min(right, lint(sum.size() - 1));
    ans = max(ans, sum[right] - sum[left]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2164
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 200;
const int MAXRET = 100000;

int n;
int p[MAXN];

int ret[MAXRET], nret;
void addret(int x) { assert(nret < MAXRET); ret[nret++] = x; }

void run() {
	scanf("%d", &n); REP(i, n) scanf("%d", &p[i]);
	//n = 200; REP(i, n) p[i] = i; random_shuffle(p, p + n);

	int off = 0;
	for (int now = n - 1; now >= 0; --now) {
		REP(i, 1) {
			addret(1); off = (off + 1) % n;
			//printf("p:"); REP(j, n) printf(" %d", p[j]); printf(" (off=%d)\n", off);
		}
		REP(i, now) {
			int a = off, b = (off + n - 1) % n;
			if (p[a] < p[b]) { addret(n - 1); swap(p[a], p[b]); }
			addret(1); off = (off + 1) % n;
			//printf("p:"); REP(j, n) printf(" %d", p[j]); printf(" (off=%d)\n", off);
		}
		REP(i, n - now - 1) {
			addret(1); off = (off + 1) % n;
			//printf("p:"); REP(j, n) printf(" %d", p[j]); printf(" (off=%d)\n", off);
		}
	}
	//printf("p:"); REP(j, n) printf(" %d", p[j]); printf(" (off=%d,nret=%d)\n", off,nret);
	printf("%d\n", nret); REP(i, nret) printf("%d\n", ret[i]);

}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x;
	cin>>x;
	long long n=100;
	for(int i=1;i<=3760;i++){
		n=(n/100)+n;
		if(n>=x){
			cout<<i;
			break;
		}
	}
	return 0;
}

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

using namespace std;
int main() {
  vector<long> v;
  int n;
  cin >> n;
  v.push_back(2);
  v.push_back(1);

  for (int i = 2; i <= n; i++) {
    v.push_back(v[i - 1] + v[i - 2]);
  }
  cout << v.back() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
#include <queue>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;



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

    cout << pow(a,3) + pow(a, 2) + a << endl;
}

Measured memory_bytes: 4124
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

#define MAXN 300

double dp[MAXN+1][MAXN+1][MAXN+1];
int n;

double dfs(int c0, int c1, int c2){
  int c3 = n-c0-c1-c2;
  if(dp[c0][c1][c2]!=-1.0) return dp[c0][c1][c2];
  else if(c0==n){
    dp[c0][c1][c2] = 0.0;
    return dp[c0][c1][c2];
  }else{
    double p = ((double)c0)/n, q = ((double)c1)/n, r = ((double)c2)/n, s = ((double)c3)/n;
    double e1 = (q==0.0) ? 0.0 : q*(1+dfs(c0+1,c1-1,c2));
    double e2 = (r==0.0) ? 0.0 : r*(1+dfs(c0,c1+1,c2-1));
    double e3 = (s==0.0) ? 0.0 : s*(1+dfs(c0,c1,c2+1));
    dp[c0][c1][c2]=(p+e1+e2+e3)/(1-p);
    return dp[c0][c1][c2];
  }
}

int main(){
  cin >> n;
  int cnt[4];
  fill(cnt,cnt+4,0);
  REP(i,n){
    int a; cin >> a;
    cnt[a]++;
  }
  fill(dp[0][0],dp[n+1][0],-1.0);
  printf("%.10f\n", dfs(cnt[0],cnt[1],cnt[2]));
  return 0;
}


Measured memory_bytes: 213376