akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

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

    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s0 = sc.next(), s1 = sc.next(), s2 = sc.next();
        String ans = String.valueOf(s0.charAt(0)) + String.valueOf(s1.charAt(1)) + String.valueOf(s2.charAt(2));
        System.out.println(ans);
        sc.close();
    }
}

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

#define fi first
#define se second

const int N = 100100;
const long long mod = 1e9 + 9;

using namespace std;

int n;
int k;
long long d[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> k;
        for(int i = 1; i < N; i++){
                d[i] = 1e18;
        }
        for(int i = 1;i  <= n; i++){
                int x, y;
                cin >> x >> y;
                for(int j = N - 1; j >= y; j--){
                        d[j] = min(d[j], d[j - y] + x);
                }
        }
        int res = 0;
        for(int i = 1; i < N; i++){
                if(d[i] <= k){
                        res = i;
                }
        }
        cout << res << "\n";
}



Measured memory_bytes: 1024
#include <stdio.h>

int main (void) {
	int i;
	double a;
	
	while ( scanf("%lf",&a) != EOF ) {
		double sum = 0;
		for( i = 1; i <= 10; i++ ) {
			if ( i == 1 ) {
				sum += a;
			}
			else if ( i % 2 == 0 ) {
				a *= 2;
				sum += a;
			}
			else {
				a /= 3;
				sum += a;
			}
		}
		printf("%f\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int cicle[51],cicile_index,cicle_num,wait_time,tmp_time;
	bool is_queue;
};

int N,Time_Limit;
Info info[100];

void func(){

	int tmp;

	for(int i = 0; i < N; i++){
		info[i].cicile_index = 0;
		info[i].wait_time = 0;
		info[i].tmp_time = 0;
		info[i].is_queue = false;

		for(int k = 0; ;k++){
			scanf("%d",&tmp);
			if(tmp != 0){
				info[i].cicle[k] = tmp;
			}else{
				info[i].cicle_num = k;
				break;
			}
		}
	}

	queue<int> Q;
	bool Finished;

	for(int time = 0; time < Time_Limit; time++){
		Finished = false;
		for(int i = 0; i < N; i++){
			if(info[i].is_queue == false){
				info[i].tmp_time++;
				if(info[i].tmp_time == info[i].cicle[info[i].cicile_index]){
					info[i].tmp_time = 0;
					info[i].cicile_index++;
					Q.push(i);
					info[i].is_queue = true;
				}
			}else{
				if(i == Q.front()){
					info[i].tmp_time++;
					if(info[i].tmp_time == info[i].cicle[info[i].cicile_index]){
						info[i].tmp_time = 0;
						if(info[i].cicile_index == info[i].cicle_num-1){
							info[i].cicile_index = 0;
						}else{
							info[i].cicile_index++;
						}
						info[i].is_queue = false;
						Finished = true;
					}
				}else{
					info[i].wait_time++;
				}
			}
		}
		if(Finished)Q.pop();
	}

	int ans = 0;

	for(int i = 0; i < N; i++){
		ans += info[i].wait_time;
	}

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&Time_Limit);
		if(N == 0 && Time_Limit == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3236
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	int ma=0,sum=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		sum+=a;
		ma=max(ma,a);
	}
	if(sum-ma>ma){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
#define ll long long
#define ull unsigned long long

int s[maxn][maxn];

int n, m, t, p, sx, sy,ex,ey;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
    int _;
    int d, c, x, y;
    //scanf("%d", &_);
    while (scanf("%d %d %d %d", &n, &m, &t, &p)!=EOF) {
        if(n==0&&m==0&&t==0&&p==0) break;
        ex = n,ey = m;
        sx = 0, sy = 0;
        memset(s, 0, sizeof(s));
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                s[i][j] = 1;
        while (t--) {
            scanf("%d %d", &d, &c);
            if (d == 1) {
                for (int i = 0; i < c; i++) {
                    for (int j = sy; j <= ey; j++) {
                        s[sx + c + i][j] += s[sx + c - i - 1][j];
                    }
                }
                ex = max(ex,sx+c+c);
                sx += c;
            } else {
                for (int i = sx; i <= ex; i++) {
                    for (int j = 0; j < c; j++) {
                        s[i][sy + c + j] += s[i][sy + c - j - 1];
                    }
                }
                ey = max(ey,sy+c+c);

                sy += c;
            }
        }
        int ans = 0;
//        cout<<endl;
//        for(int i=0;i<ex;i++){
//            for(int j=0;j<ey;j++){
//                cout<<s[i][j]<<" ";
//            }
//            cout<<endl;
//        }
        while (p--) {
            scanf("%d %d", &x, &y);

            printf("%d\n", s[sx + x][sy + y]);

        }
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

ll dp[110][2][5];

ll solve(int ind, int match, int rem, string& digits) {
    if(ind == digits.size()) {
        if(rem != 0) return 0;
        return 1;
    }

    if(rem < 0) return 0;

    if(dp[ind][match][rem] != -1) return dp[ind][match][rem];

    int res = 0;

    if(match) {
        if(digits[ind] == '0') {
            // need to put 0, no other option
            res = res + solve(ind + 1, 1, rem, digits);
        } else {
            // try putting the same digit (non-zero)
            res = res + solve(ind + 1, 1, rem - 1, digits);

            // try putting lower digit which is non zero
            res = res + (digits[ind]-'0'-1)*solve(ind + 1, 0, rem - 1, digits);

            // try putting zero which is lower digit
            res = res + solve(ind + 1, 0, rem, digits);
        }
    } else {
        res = res + solve(ind + 1, 0, rem, digits);

        res = res + 9*solve(ind + 1, 0, rem - 1, digits);
    }

    dp[ind][match][rem] = res;
    return res;

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string digits;
    int k;
    cin>>digits>>k;

    
    memset(dp, -1, sizeof(dp));

    cout<<solve(0, 1, k, digits)<<endl;

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B && A != C && B != C){
    cout << "Yes" << endl;
  }
  
  else if (A == C && A != B && B != C){
    cout << "Yes" << endl;
  }
  
  else if (B == C && A != B && A != C){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

int n;
int a[MAXN];
set<int> s;

vector<int> divisors (int k) {
	vector<int> ret;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			ret.push_back(i);
			ret.push_back(k / i);
		}
	}
	ret.push_back(k);
	return ret;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	a[n] = MAXN;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (a[i + 1] == a[i]) {
			s.insert(a[i]);
			continue;
		}
		vector<int> d = divisors(a[i]);
		int ok = 1;
		for (auto& cur : d) {
			if (s.count(cur)) {
				ok = 0;
				break;
			}
		}
		s.insert(a[i]);
		ret += ok;
	}
	cout << ret << endl;
	return 0;
}


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

int main() {
    // 素因数分解する＝＞二つの約数のペアを作る＝＞(a, b)とする
    // 必要な移動回数の最小値=(a-1)+(b-1) = a+b-2 
    // 対称性からa<=bとしてよいので，a<=√Nまでを全探索すれば解ける
    ll N;
    cin >> N;
    ll a = pow(N, 0.5);
    ll minimum = 1000000010000;
    for (int i = 1; i <= a; i++) {
        if (N % i == 0) {
            ll b = N/i;
            ll localmin = b+i-2;
            minimum = min(minimum, localmin);
        }
    }
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    unsigned int x,a,b;
    cin >> x;
    a = x/500;
    x = x-a*500;
    b = x/5;
    cout << (a*1000)+(b*5) << endl;
    return 0;
}


Measured memory_bytes: 256
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ll N,ans=0,K;
	cin >> N >> K;
	vector<ll> l(N);
	FOR(i,0,N)cin >> l[i];
	sort(l.begin(),l.end());
	FOR(i,0,K)ans+=l[N-1-i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int n, k;
Int a[110];
Int dp[110000];

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

    for(int i = 0;i <= k;i++){
        dp[i] = false;
        for(int j = 0;j < n;j++){
            if(i - a[j] >= 0)dp[i] = dp[i] | !dp[i-a[j]];
        }
    }
    if(dp[k])cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 1024
def A():
    s = input()
    if s == 'SSS': print(0)
    elif s=='RRR': print(3)
    elif s=='RRS' or s=='SRR': print(2)
    else: print(1)

def B():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            if a[i] == a[j]: continue
            for k in range(j+1, n):
                if a[i]==a[k] or a[j] == a[k]: continue
                s = a[i] + a[j] + a[k]
                if s > 2 * max(a[i], a[j], a[k]):
                    cnt += 1
    print(cnt)

def C():
    x, k, d = map(int, input().split())
    if abs(x) > k * d:
        print(abs(x) - k*d)
    else:
        tm = abs(x) // d
        x = abs(x) % d
        k -= tm
        if k % 2 == 0:
            print(x)
        else:
            print(d-x)
A()


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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9


int main(){
    int n, m; cin >> n >> m;
    vector<pair<bool, bool>> vec(n);
    
    //初期化
    rep(i, n){
        vec[i].first = false;
        vec[i].second = false;
    }
    
    rep(i, m){
        int a,b; cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        
        if(a == 0) {
            vec[b].first = true;
            
        }
        if(b == n-1){
            vec[a].second = true;
        }
    }

    
    rep(i,n) {
        if((vec[i].first == vec[i].second)&&(vec[i].first == true)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;


}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<vector<int>> a(n, vector<int>(3));
    int r = 0, g = 0, b = 0;
    roop(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;

        a[i][0] = r;
        a[i][1] = g;
        a[i][2] = b;
    }

    ll ans = 0;

    int temp = 0;
    for(int i = 0;i < n-2;i++){
        for(int j = i+1;j < n-1;j++){
            if(s[i] != s[j]){
                if(s[i] == 'R' || s[j] == 'R') temp += 1;
                if(s[i] == 'G' || s[j] == 'G') temp += 2;
                if(s[i] == 'B' || s[j] == 'B') temp += 4;

                if(j+(j-i) < n){
                    if(7 - temp == 1 && s[j+(j-i)] == 'R') ans--;
                    if(7 - temp == 2 && s[j+(j-i)] == 'G') ans--;
                    if(7 - temp == 4 && s[j+(j-i)] == 'B') ans--;
                }

                if(7 - temp == 1) ans += a[n-1][0]-a[j][0];
                if(7 - temp == 2) ans += a[n-1][1]-a[j][1];
                if(7 - temp == 4) ans += a[n-1][2]-a[j][2];
            }
            temp = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, y, ans = 0;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; i + j <= n; j++) {
			for (int k = 0; i + j + k <= n; k++) {
				if (10 * i + 5 * j + k == y && i + j + k == n) {
					cout << i << ' ' << j << ' ' << k;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<string>W(N);
    vector<map<char,ll>>ms(N);
    rep(i,N){
        cin>>W[i];
        rep(j,W[i].size()){
            ms[i][W[i][j]]++;
        }
    }

    string ans;
    for (const auto& [key, value] : ms[0]){
        ll mn=value;
        rep(i,N){
            chmin(mn,ms[i][key]);
        }
        rep(i,mn){
            ans+=key;
        }
    }

   
    cout<<ans<<endl;


    return 0;
    

}

Measured memory_bytes: 3640
n,m=map(int,input().split())
ks=[[] for i in range(m)]
for i in range(m):
    ks[i]=list(map(int,input().split()))
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    a=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            a[j]=1
    f=0
    for j in range(m):
        x=0
        for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
        if x%2==p[j]:
            f+=1
    if f==m:
        ans+=1
print(ans)
        
        
        
            
    

    
    

        


Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0LL;                       // to be set
    vector<Abel> dat;
   
    // [1, n]
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    // a is 1-indexed
    inline void add(ll a, Abel x) {
        for (ll i = a; i < (ll)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    // [1, a], a is 1-indexed
    inline Abel sum(ll a) {
        Abel res = UNITY_SUM;
        for (ll i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    // [a, b), a and b are 1-indexed
    inline Abel sum(ll a, ll b) {
        return sum(b - 1) - sum(a - 1);
    }
};

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, ri = 0LL, le = INF, mid, N = 100005LL;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i], ri = max(ri, a[i]), le = min(le, a[i]);
    ri++;
    while(ri - le > 1LL){ 
    	mid = (ri + le) / 2LL;
    	vector<ll> b(n+1, 0LL);
    	for(ll i=0LL;i<n;i++){
    		if(a[i] >= mid) b[i+1] = 1LL;
    		else b[i+1] = -1LL;
        }
        for(ll i=0;i<n;i++) b[i+1] += b[i];
        BIT<ll> bit(n + N * 2LL);
        ll ans = 0LL;
        for(ll i=0;i<=n;i++){
        	ans += bit.sum(b[i] + N);
        	bit.add(b[i] + N, 1LL);
        }
        if(n*(n+1LL) <= ans * 4LL) le = mid;
        else ri = mid;
    }
    cout << le << endl;
    return 0;
}


Measured memory_bytes: 4224
import sys

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

count = 0
def dfs(graph, v, seen):

    if not False in seen:
        global count
        count += 1
        return

    # 頂点vから行ける頂点を全探索
    for i in graph[v]:
        if seen[i]:
            continue
        seen[i] = True
        dfs(graph, i, seen)
        seen[i] = False
    
    return

# ここから本文
N, M = map(int, input().split())

# グラフ構造を作る
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

seen = [False for i in range(N)]
seen[0] = True
dfs(graph, 0, seen)

print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}



	return 0;
}


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

using ll = long long;
const ll A = 1e9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll s;
  cin >> s;
  
  ll x1 = 0, y1 = 0, x2 = 1e9, y2 = 1, x3, y3;
  
  y3 = s / A + 1;
  x3 = A * y3 - s;
  
  if (s == 1e18) y2 = x3 = 0, y3 = 1e9;
  
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 50005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,m;
char answ1;
int answ2;

int main(){
    cin>>n>>m;
    char x = char('A' + m - 1);
    for(int i=1;i<=n;i++){
        for(char j='A';j<=x;j++){
            string s;
            cin>>s;
            if(s == "snuke"){
                answ1 = j;
                answ2 = i;
            }
        }
    }
    cout<<answ1<<answ2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char x[1001]={'0'};
    int sum,i;
    while(1){
        sum=0;
        scanf("%s",x);
        if(x[0]=='0'){
            break;
        }
        for(i=0;i<1001;i++){
            if(x[i]!='\0'){
                sum+=x[i]-'0';
            }else{
                break;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2068
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    w = [input().strip() for _ in range(n)]
    if len(w) == len(set(w)) and all([i[-1] == j[0] for i, j in zip(w[:-1], w[1:])]):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
def main():
    n = int(input())
    t = []
    a = []
    for i in range(n):
        in_t,in_a = map(int,input().split(' '))
        t.append(in_t)
        a.append(in_a)
    if n == 1:
        return t[0]+a[0]
    tmp_t = t[0]
    tmp_a = a[0]
    for i in range(1,n):
        if tmp_t%t[i] != 0:
            x = (tmp_t - tmp_t%t[i] + t[i])//t[i]
        else:
            x = tmp_t//t[i]

        if tmp_a%a[i] != 0:
            y = (tmp_a - tmp_a%a[i] + a[i])//a[i]
        else:
            y = tmp_a//a[i]

        if x <= y:
            x = y
        else:
            y = x
        tmp_t = t[i]*x
        tmp_a = a[i]*y
    return tmp_t+tmp_a

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

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

using namespace std;

int main() {
    /*int A,B,C,D,seconds,minutes;
    cin >> A >> B >> C >> D;
    seconds = A + B + C + D;
    minutes = seconds / 60;
    seconds = seconds - minutes *60;
    cout << minutes << endl << seconds << endl;*/
    
    int AB,BC,CA,answer;
    cin >> AB >> BC >> CA;
    answer = AB * BC / 2;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,k = input().split()
n = int(n)
k = int(k)
s = input()
if s[k-1] == "A":
    ans = s[:k-1] + "a" +s[k:]
elif s[k-1] == "B":
    ans = s[:k-1] + "b" +s[k:]
else:
    ans = s[:k-1] + "c" +s[k:]
print(ans)

Measured memory_bytes: 3064
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

let S = input.split('\n')[0]
let count1 = 0
let count2 = 0
if (S.length === 2 && S !== "10" && S !== "01") {
  console.log(1)
}
else if (S.length === 1) {
  console.log(0)
}
else {
  for (let i = 0; i < S.length; i += 2) {
    let slice = S.slice(i, i + 2)
    if (slice.length === 1) {
      if (slice === '0') {
        count2++
      } else {
        count1++
      }
    }
    else {
      if (slice !== '01') {
        if (slice === '10') {
          count1 += 2
        }
        else {
          count1++
        }
      }
      if (slice !== '10') {
        if (slice === '01') {
          count2 += 2
        }
        else {
          count2++
        }
      }
    }
  }
  console.log(Math.min(count1, count2))
}

Measured memory_bytes: 8504
//
//  main.cpp
//  Testing_main
//
//  Created by Davidia on 2019-02-05.
//  Copyright © 2019 Davidia. All rights reserved.
//

#include <bits/stdc++.h>
/*
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




*/


using namespace std;

typedef pair<int,int> va;
#define LEFT 0
#define DIAG 1
#define UP 2
// 0 LEFT, 1 DIAGONALLY UP, 2 UP

void build_string(string &answer, int r, int c, vector<vector<va>> &dp,  string &s){
    if (r == 0 || c == 0){
        return;
    }
    if (dp.at(r).at(c).second == UP){
        build_string(answer, r-1, c, dp,s);
    }
    else if (dp.at(r).at(c).second == LEFT){
        build_string(answer, r, c-1, dp,s);
    }
    else{
        answer.push_back(s.at(r-1));
        build_string(answer, r-1, c-1, dp,s);
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t; cin >> s >> t;
    vector<vector<va>> dp(s.length()+1, vector<va>(t.length()+1, make_pair(0, 0)));
    for (int i = 1; i <= s.length(); i++){
        for (int j = 1; j <= t.length(); j++){
            if (s.at(i-1) == t.at(j-1)){
                dp.at(i).at(j) = make_pair(1+dp.at(i-1).at(j-1).first, DIAG);
            }
            else{
                if (dp.at(i-1).at(j) > dp.at(i).at(j-1)){
                    dp.at(i).at(j) = make_pair(dp.at(i-1).at(j).first, UP);
                }
                else{
                    dp.at(i).at(j) = make_pair(dp.at(i).at(j-1).first, LEFT);
                }
            }
        }
    }
    string answer;
    build_string(answer, (int)s.length(), (int)t.length(), dp, s);
    reverse(answer.begin(), answer.end());
    cout << answer << '\n';
    return 0;
}


Measured memory_bytes: 71424
#include <stdio.h>

int main(){
  long k, a, b;
  scanf("%ld%ld%ld", &k, &a, &b);
  long ans;
  if(a <= b-2  &&  k >= a+1)
    ans = a + (b-a) * ((k-a+1)/2) + (k-a+1)%2;
  else
    ans = 1 + k;

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


Measured memory_bytes: 128
#include<stdio.h>
long long int ans;
int N, i;
int MOD = 1000000007;
int main(){
  scanf("%d\n", &N);
  ans=1;
  for(i=2; i<=N; ++i){
    ans *= i;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
<?php
  $tmp = explode(" ", trim(fgets(STDIN)));

  $a = $tmp[0];
  $b = $tmp[1];
  $c = $tmp[2];
  $k = $tmp[3];

  if($a>=$k){
    echo $k;
  }else if($a+$b>$k){
    echo $a;
  }else{
    echo $a-($k-$a-$b);
  }

echo "\n";


Measured memory_bytes: 16172
n = int(input())
A = [int(input()) for _ in range(n)]
INF = 10**18

dp = [INF]*(n+1)

dp[0] = -1

import bisect

for i in range(n):
    r_idx = bisect.bisect_right(dp, A[i])
    #print(r_idx)
    if dp[r_idx-1]<A[i] and dp[r_idx]>A[i]:
        dp[r_idx] = A[i]
        
ans = -1
dp.append(INF)
for i in range(n+2):
    if dp[i]==INF:
        ans = i-1 
        break

print(ans)


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

int main(){

    int n,w;

    cin >> n >> w;

    vector<int> c(n),v(n);

    rep(i,n)cin >> c[i]>> v[i];

    vector<ll> dp(w+1,0);

    dp[0]=0;

    for(int j=0;j<n;j++){
        for(int i=w;i>=0;i--){
            if(i-c[j]>=0){
                dp[i]=max(dp[i],dp[i-c[j]]+v[j]);
            }
        }
    }

    cout << dp[w] << endl;

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python

if __name__ == '__main__':
    s = map(ord, list(raw_input()))
    for i in range(len(s)):
        if s[i] > 0x40 and (s[i]-0x41)%0x20 < 0x1a:
            s[i]^=0x20
    print ''.join(map(chr, s))



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

int main(){
	int n,x,i,a;
	while(cin >> n){
		a = 0;
		x = 600 / n;
		for(i = 1;i < x;++i){
			a += n * (n * i * n * i);
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 0
//
// Created by Hideaki Imamura on 2020-03-18.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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 EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, K;
string S;

int main() {
    cin >> N >> K >> S;
    int h = 0;
    if (S[0] == 'R' && S[1] == 'R') h++;
    if (S[N-1] == 'L' && S[N-2] == 'L') h++;
    for (int i = 1; i < N - 1; ++i) {
        if ((S[i] == 'R' && S[i+1] == 'R') || (S[i] == 'L' && S[i-1] == 'L')) h++;
    }
    cout << min(N - 1, h + 2 * K) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int NN,k;
int ran[100005];
int tmp[100005];
int sa[100005];

bool compare_sa(int i,int j)
{
	if(ran[i] != ran[j]) return ran[i] < ran[j];
	else
	{
		int ri = i+k<=NN ? ran[i+k]: -1;
		int rj = j+k<=NN ? ran[j+k]: -1;
		
		return ri < rj;
	}
}

void construct_sa(string S)
{
	NN = S.size();
	for(int i=0;i<=NN;i++)
	{
		sa[i] = i;
		ran[i] = i<NN?S[i]:-1;
	}
	
	for(k=1;k<=NN;k*=2)
	{
		sort(sa,sa+NN+1,compare_sa);
		
		tmp[sa[0]] = 0;
		for(int i=1;i<=NN;i++)
		{
			tmp[sa[i]] = tmp[sa[i-1]] + compare_sa(sa[i-1],sa[i]);
		}
		for(int i=0;i<=NN;i++)
		{
			ran[i] = tmp[i];
		}
	}
}
int lcp[100005];
void construct_lcp(string S)
{
	int n = S.size();
	for(int i=0;i<=n;i++) ran[sa[i]] = i;
	
	int h = 0;
	lcp[0] = 0;
	
	for(int i=0;i<n;i++)
	{
		int j = sa[ran[i]-1];
		
		if(h) h--;
		for(;j+h<n && i+h<n;h++)
		{
			if(S[j+h] != S[i+h]) break;
		}
		lcp[ran[i]-1] = h;
	}
}

int seg[(1<<18)+5];
void update(int k,int a){
	k+=(1<<17)-1; seg[k] = a;
	while(k>0){
		k=(k-1)/2;
		seg[k]=min(seg[k*2+1],seg[k*2+2]);
	}
}
int query(int a,int b,int k,int l,int r){
	if(r<a || b<l) return INF;
	if(a<=l && r<=b) return seg[k];
	else{
		int vl=query(a,b,k*2+1,l,(l+r)/2);
		int vr=query(a,b,k*2+2,(l+r)/2+1,r);
		return min(vl,vr);
	}
}
string s;
int main(){
	cin >> s;
	construct_sa(s);
	construct_lcp(s);
	for(int i=0;i<s.size();i++){
		update(i,lcp[i]);
	}
	int q; cin >> q;
	for(int i=0;i<q;i++){
		int L,R,T; cin >> L >> R >> T;
		if(R-L+1 <= T){
			puts("Yes"); continue;
		}
		int P = ran[L-1];
		int Q = ran[L+T-1];
		int len = query(min(P,Q),max(P,Q)-1,0,0,(1<<17)-1); //cout << len << endl;
		if(len >= R-L+1-T){
			puts("Yes");
		}
		else{
			P = ran[L-1+len+1];
			Q = ran[L+T-1+len+1];
			int len2 = query(min(P,Q),max(P,Q)-1,0,0,(1<<17)-1);//cout << len << endl;
			int D = (T-1-len%T); D = min(D,R-L-T-len);//cout << D ;
			if(len2<D) puts("No");
			else{
				if(D != T-1-len%T) puts("Yes");
				else{
					if(L-1+T+T+len+D+1 <= R){
						P = ran[L-1+T+len+D+1]; 
						Q = ran[L-1+T+T+len+D+1];
						int len3 = query(min(P,Q),max(P,Q)-1,0,0,(1<<17)-1);
						if(len3 < R-L-T-T-len-D){
							puts("No"); continue;
						}
					}
					P = ran[L-1];
					Q = ran[L-1+T+len+D+1];
					int len4 = query(min(P,Q),max(P,Q)-1,0,0,(1<<17)-1);
					int E = min(T,R-L-T-len-D);
					P = ran[L-1+len+D+1];
					Q = ran[L-1+T+len+D+1];
					int len5 = query(min(P,Q),max(P,Q)-1,0,0,(1<<17)-1);
					int F = min(T,R-L-T-len-D);
					puts((len4 >= E)||(len5 >= F)?"Yes":"No");
				}
			}
		}
	}
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;

int main() {
	cin >> N;
	printf("%.10f\n", double((N + 1) / 2) / N);
}

Measured memory_bytes: 256
#include<stdio.h>
void kansu(void);
void back(int,int);
char a[13][13];
int main(void)
{
	int h,m,s,ss,i;
	while(scanf("%s",&a[0])!=EOF){
		for(i=1;i<12;i++){
			scanf("%s",a[i]);
		}
		kansu();
	}
	return 0;
}
void kansu(void)
{
	int i,j,n;
	n=0;
	for(i=0;i<12;i++){
		for(j=0;j<12;j++){
			if(a[i][j]=='1'){
				n++;
				back(i,j);
			}
		}
	}
	printf("%d\n",n);
}
void back(int i,int j)
{
	a[i][j]='0';
	if(i+1<12){
		if(a[i+1][j]=='1'){
			back(i+1,j);
		}
	}
	if(j+1<12){
		if(a[i][j+1]=='1'){
			back(i,j+1);
		}
	}
	if(i-1>=0){
		if(a[i-1][j]=='1'){
			back(i-1,j);
		}
	}
	if(j-1>=0){
		if(a[i][j-1]=='1'){
			back(i,j-1);
		}
	}
}


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

int main() {
    int n;
    scanf("%d", &n);
    set< string> st;
    string a, b;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        if(i) {
            if(st.count(a)) return !printf("No\n");
            if(b.back() != a[0]) return !printf("No\n");
        }
        b = a;
        st.emplace(a);
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        constexpr int M = 1e6;
        int x; cin >> x;

        vector<bool> t(M, true);
        t[1] = false;

        for (int i = 2; i < M; i++) {
                if (t[i]) {
                        for (int j = 2; i * j < M; j++) {
                                t[i * j] = false;
                        }
                }
        }

        for (int i = x; i < M; i++) {
                if (t[i]) {
                        cout << i << endl;
                        return 0;
                }
        }

        return 0;
}


Measured memory_bytes: 384
A,B,C,K = map(int,input().split())
ans = 0
count = 0
# for i in range(A):
#     ans += 1
#     if i 

# while count != K:
#     if count <= A:
#         ans +=1
#         count+=1
#     elif count <= B:
#         count+=1
#     else:
#         ans -= 1
#         count+=1

if A+B>=K:
    if A >= K:
        ans += K
    else:
        ans += A
else:
    ans += A
    
    count = K-(A+B) # 残り枚数
    ans-=count
        
    
print(ans)
        

Measured memory_bytes: 9172
#include<iostream>
using namespace std;
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  int ar[m];
  for(int i=0;i<m;i++){
    cin>>ar[i];
    sum+=ar[i];
  }
  if(sum<=n)
    cout<<n-sum;
   else
     cout<<-1;
}
  

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

int main(){
    while (true){
        string x;
        cin >> x;
        if (x == "0") break;
        int sum = 0;
        for (int i = 0; i < x.size(); i++) sum += x[i] - '0';
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int a[5];
    for(int i=0; i<5; i++) cin>>a[i];
    for(int i=0; i<5; i++){
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3580
#include <iostream>
#include<string.h>
using namespace std;

int main(){
  int a,b;
  int i = 0,k = 0;
  string s0 = ".";
  string s1 = "#";
  while(1){
    cin >> a >> b;
    while(i < a){
      while(k < b ){
        if(i == 0 || i == a-1 || k == 0 || k == b-1){
          cout << s1;
        } else {
          cout << s0;
        }
        k++;
      }
      k = 0;
      i++;
      cout << endl;
    }
     i = 0;
    if( a == 0 && b ==0){
      break;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3124
import java.util.Scanner;

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

        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == t.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23508
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> sc(M);
  cin >> sc;

  vi d(N, -1);
  rep(i, M) {
    int s = sc[i].first;
    int c = sc[i].second;

    if (d[s - 1] == -1) {
      d[s - 1] = c;
    } else if (d[s - 1] != c) {
      out(-1);
      return 0;
    }
  }

  if (d[0] == 0) {
    if (N == 1) {
      out(0);
    } else {
      out(-1);
    }
    return 0;
  }

  if (d[0] == -1) {
    if (N == 1) {
      out(0);
      return 0;
    } else {
      d[0] = 1;
    }
  }
  if (d[1] == -1) {
    if (N == 2) {
      cout << d[0] << 0 << endl;
      return 0;
    } else {
      d[1] = 0;
    }
  }
  if (d[2] == -1) {
    cout << d[0] << d[1] << 0 << endl;
    return 0;
  }
  rep(i, N) {
    cout << d[i];
  }
  cout << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y, m;
string s, t;

ll rem;
ll cnt[3];


// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s ;
	if (s == "Sunny") s = "Cloudy";
	else if (s == "Cloudy") s = "Rainy";
	else s = "Sunny";
	cout << s;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3548
using System;

public class p0206
{
	p0206(){
		string str;
		string[] st;
		long n, sm;
		bool f;
		long[] a = new long[12];
		
		while((str=Console.ReadLine())!=null && str != "0"){
			n = long.Parse(str);
			sm = 0;
			f = true;
			
			for(int i = 0; i < 12; ++i){
				st = (Console.ReadLine()).Split(' ');
				a[i] = long.Parse(st[0]) - long.Parse(st[1]);
			}
			
			for(int i = 0; i < 12; ++i){
				sm += a[i];
				if(sm >= n){
					Console.WriteLine("{0}", i+1);
					f = false;
					break;
				}
			}
			if(f) Console.WriteLine("NA");
		}
	}
	
	public static int Main(string[] args){
		new p0206();
		return 0;
	}
}

Measured memory_bytes: 5780
#include <cstdio>
long long a[100];
int main(){
	int n;
	scanf("%d",&n);
	int mxf=1,posf=-1;
	int mxz=-1,posz=-1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(a[i]>=0){
			if(a[i]>mxz){
				mxz=a[i];
				posz=i;
			}
		}else{
			if(a[i]<mxf){
				mxf=a[i];
				posf=i;
			}
		}
	}
	printf("%d\n",n*2-2);
	if(-mxf>mxz){
		for(int i=1;i<=n;i++){
			if(i!=posf){
				printf("%d %d\n",posf,i);
			}
		}
		for(int i=n-1;i>=1;i--){
			printf("%d %d\n",i+1,i);
		}
	}else{
		for(int i=1;i<=n;i++){
			if(i!=posz){
				printf("%d %d\n",posz,i);
			}
		}
		for(int i=1;i<=n-1;i++){
			printf("%d %d\n",i,i+1);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx=5e5+10;
ll dp[mx],ans[mx];

int main()
{
    ll h,w,m;
    cin>>h>>w>>m;
    ll height=0,width=0;
    map<pair<ll,ll>,ll> mp;
    vector<ll> a,b;
    while(m--)
    {
        ll H,W;
        cin>>H>>W;
        dp[H]++;
        ans[W]++;
        height =max(height,dp[H]);
        width  =max(width,ans[W]);
        mp[ {H,W}]=1;
    }
    for(ll i=1; i<=h; i++) if(dp[i]==height) a.push_back(i);
    for(ll i=1; i<=w; i++) if(ans[i]==width) b.push_back(i);
    for(ll i=0; i<a.size(); i++)
    {
        for(ll j=0; j<b.size(); j++)
        {
            if(mp[ {a[i],b[j]}]==0)
            {
                cout<<dp[a[i]]+ans[b[j]]<<endl;
                return 0;
            }
        }
    }
    cout<<height+width-1<<endl;
}


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

int n;
string s;
LL Fact[1000005];
int mo = 2;
vector < int > diff;

int mut( int x ){
	if ( x < 0 ) return -x;
	return x;
}

int C( int n, int k ){
	int f = Fact[n];
	int l = Fact[n-k], r = Fact[k];
	if ( l + r >= f ) return 1;
	return 0;
}

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	Fact[0] = 0;
	for ( int i = 1; i <= 1000000; i++ ){
		Fact[i] = Fact[i-1];
		int x = i;
		while ( x % 2 == 0 ){
			Fact[i]++;
			x /= 2;
		}
	}
	
	cin >> n;
	cin >> s;
//	for ( int i = 0; i < n; i++ ) s += "1";
	for ( int i = 1; i < n; i++ ){
		diff.push_back(mut(s[i]-s[i-1]));
	}
	
	int ans = 0;
	for ( int i = 0; i < diff.size(); i++ ){
		if ( C(diff.size()-1, i) == 1 ) ans = mut( ans - diff[i] );
	}
	int cnt = 0;
	while ( diff.size() > 1 && cnt < 100 ){
		vector < int > tmp = diff;
		diff.clear();
		for ( int i = 1; i < tmp.size(); i++ ){
			diff.push_back(mut(tmp[i]- tmp[i-1]));
		}
		int ans2 = 0;
		for ( int i = 0; i < diff.size(); i++ ){
			if ( C(diff.size()-1, i) == 1 ) ans2 = mut( ans2 - diff[i] );
		}
		if ( ans2 != ans ) {
			ans = ans2;
		}
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17940
#include <bits/stdc++.h>
using namespace std;
int x[150];
int main()
{
   string s;
   cin>>s;
   for(int i=0;i<s.length();i++)
   {
       x[s[i]]++;
   }
   for(int i=97;i<=127;i++)
   {
       if(x[i]>1)
       {
           cout<<"no"<<endl;
           return 0;
       }
   }
   cout<<"yes"<<endl;


    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0] + list(map(int,input().split()))
dic = {0:1}
for i in range(1,n+1):
    a[i] += a[i-1]
    if a[i]%m in dic:
        dic[a[i]%m] += 1
    else:
        dic[a[i]%m] = 1
ans = 0
for key in dic:
    ans += dic[key]*(dic[key]-1)//2
print(ans)

Measured memory_bytes: 62576