akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int l = s.size();
	int sc = 0, tc = 0;
	int ans = l;
	for (int i = 0; i < l;) {
		while (i != l && s[i] == 'S') {
			sc++;
			i++;
		}
		while (i != l && s[i] == 'T') {
			tc++;
			i++;
		}
		if (sc <= tc) {
			ans -= sc * 2;
			sc = tc = 0;
		} else {
			ans -= tc * 2;
			sc -= tc;
			tc = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3752
import std.stdio;

void main(){
	string s;
	int[2] score;
	while ((s = readln()) != "0\n") {
		score = 0;
		foreach (ch; s[1..$-1]) score[ch - 'A']++;

		int t = score[0] > score[1] ? 0 : 1;
		score[t]++;

		writeln(score[0], " ", score[1]);
	}
}

Measured memory_bytes: 960
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int  a[100];
int main()
{
    int n;
    cin>>n;
    long long  sum=1;
    int t=n;
    long long  add=1;
    while(t--)
    {
        add*=3;
    }
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
            sum=sum*2;
    }
    //cout<<add<<"_"<<sum<<endl;
    cout<<add-sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n;
  while(cin >> n){
    vector<LLI> A(n); cin >> A;

    vector<LLI> ans(n);
    vector<LLI> diff(n);
    
    REP(i,n){
      diff[i] = A[(i+1)%n] - A[i];
    }

    int j = 0;
    REP(i,n){
      ans[(j+2)%n] = ans[j] + 2*diff[j];
      
      (j += 2) %= n;
    }

    LLI m = *min_element(ALL(ans));

    if(m < 0){
      REP(i,n) ans[i] += abs(m);
    }

    auto check =
      [&](LLI x){
        REP(i,n){
          if(ans[i]/2+ans[(i+1)%n]+2*x < A[i]) return false;
        }

        return true;
      };

    LLI lb = -1, ub = INT_MAX, mid;
    while(abs(lb-ub) > 1){
      mid = (lb+ub)/2;

      if(check(mid)){
        ub = mid;
      }else{
        lb = mid;
      }
    }
    
    REP(i,n) ans[i] += 2*ub;

    

    join(cout, ALL(ans));
  }
  
  return 0;
}


Measured memory_bytes: 3712
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
int main(){
	ll n,l,t;
	cin>>n>>l>>t;
	vp in(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(b==2)b=-1;
		in[i]={a,b};
	}
	vp pos(n);
	rep(i,n){
		ll dis=t%l;
		pos[i].first=(l+in[i].first+in[i].second*dis)%l;
		pos[i].second=in[i].second;
	}
	pii p=pos[0];
	sort(all(pos));
	bool h=false;
	rep(i,n-1)if(pos[i].first==pos[i+1].first)h=true;
//	rep(i,n)cout<<pos[i].first<<" "<<pos[i].second<<endl;
	ll co=0;
	rep(i,n)if(in[i].second!=in[0].second){
		ll T=t;
		co+=T/l*2;
        T%=l;
		ll dis=in[i].first-in[0].first;
		if(in[0].second==-1)dis=l-dis;
		if(2*T>=dis)co++;
		T-=dis;
		dis=l-dis;
		if(2*T>=dis)co++;
	}
	ll ne=(n+in[0].second*(co%n))%n;
	ll it=lower_bound(all(pos),p)-pos.begin();
	rep(i,n)cout<<pos[(n+it-ne+i)%n].first<<endl;
}







Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
using namespace std;

int a[maxn],b[maxn];

int find_(int x){
    return x==a[x]?x:a[x]=find_(a[x]);
}

void solve() {
    int n,m,max_=0;
    cin>>n>>m;
    for (int j = 0; j<=n; ++j)  a[j]=j,b[j]=1;
    for (int i = 0; i < m; ++i) {
        int x,y;
        cin>>x>>y;
        int fx=find_(x);
        int fy=find_(y);
        if (fx!=fy) a[fx]=fy,b[fy]+=b[fx];
    }
    for (int k =1; k <=n; ++k)  if(b[k]>max_) max_=b[k];
    cout<<max_;
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
//    cin>>_;
    while (_--) {
        solve();
    }
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, t[114000], x[114000], y[114000], fl;

int main(){
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> t[i] >> x[i] >> y[i];
		if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1]){
			fl = 1;
		}else if((x[i]+y[i]-x[i-1]-y[i-1]+10000000)%2!=(t[i]-t[i-1])%2){
			fl = 1;
		}
	}
	if(fl==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
x1,y1,x2,y2=map(int,input().split())

xd= x2-x1
yd= y2-y1

if xd >=0 and yd >= 0:
    x3 = x2 - abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 + abs(xd)

elif xd <= 0 and yd >= 0:

    x3 = x2 - abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 - abs(xd)

elif xd <= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 - abs(xd)

elif xd >= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 + abs(xd)


print(x3,y3,x4,y4)


    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int N = in(), K = in(), x = in(), y = in();

  (N < K)?(cout << N * x << endl):(cout << (K * x) + (N - K) * y << endl);

  return (0);
}



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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int main() {
    int n = read(), k = read();
    puts(((n + 1) / 2 >= k) ? "YES" : "NO");
    return 0;
}

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

int main()
{
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
		if(xa1 <= xb2 && xb1 <= xa2 && yb1 <= ya2 && ya1 <= yb2){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::vector<ll> S[100010];

int main()
{
  std::cin >> N;

  ll k = 0;

  while( k*(k-1)/2 < N )
    ++k;

  if( k*(k-1)/2 == N )
  {
    puts("Yes");

    std::cout << k << std::endl;

    ll p = 1;

    rep( i, k )
    {
      repi( j, i+1, k )
      {
        S[i].emplace_back( p );
        S[j].emplace_back( p );

        ++p;
      }
    }

    rep( i, k )
    {
      std::cout << S[i].size() << ' ';

      rep( j, S[i].size() )
        std::cout << S[i][j] << (j==S[i].size()-1?'\n':' ');
    }
  }
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
 long long int n,m,i;
 scanf("%lld",&n);
 m=sqrt(n);
 for(i=m;i>=1;i--){
 	if(n%i==0){
 		printf("%lld",i+(n/i)-2);
 		break;
	 }
 }
 
 
 
 
 
	
 return 0;	
} 



Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a,b,c,d;
int main()
{
    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
    {
        printf("%d\n",min(a,b)+min(c,d));
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M,K,H,W,T,X,Y; cin>>N>>K;
    ll A[N],B[N+1];
    B[0]=0;
    rep(i,N){
        cin>>A[i];
        B[i+1]=A[i];
        B[i+1]+=B[i];
        B[i+1]%=K;
    }
    rep(i,N){
        B[i+1]=B[i+1]-(i+1)+N*K;
        B[i+1]%=K;
    }
    map<ll,ll> mp;
    ll ans=0;
    ++mp[B[0]];
    reps(j,1,N+1){
        ll i=j-K;
        if(i>=0){
            --mp[B[i]];
        }
        ans+=mp[B[j]];
        ++mp[B[j]];
    }
    cout<< ans<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var ans = (A <= 9 && B <= 9) ? A * B : -1;
        WriteLine(ans);
    }
}


Measured memory_bytes: 28252
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	set<int>st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	ios_base::sync_with_stdio(false);
	cout << st.size();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,c,i,count;
    count = 0;
    scanf("%d%d%d",&a,&b,&c);

    for(i = a; i <= b; i++){
        if(c%i == 0)count++;
    }

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

    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, t;  cin >> x >> t;
    if (x <= t) {
      cout << "0" << '\n';
    } else {
      cout << x - t << '\n';
    }

    return 0;
}


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

using namespace std;

int N, M, ans, x[100009], y[100009], lst[100009][409];
bool ap[409];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=M; i++)
{
    for (int j=1; j<=N; j++)
        lst[i][j] = lst[i - 1][j];
    scanf ("%d %d", &x[i], &y[i]);
    lst[i][x[i]] = lst[i][y[i]] = i;
}
for (int i=1; i<=N; i++)
    for (int j=i+1; j<=N; j++)
    {
        for (int k=1; k<=N; k++)
            ap[k] = (k == i || k == j);
        priority_queue < pair < int, int > > PQ;
        PQ.push ({lst[M][i], i}), PQ.push ({lst[M][j], j});
        int lastConsidered = M + 1;
        bool ok = 1;
        while (!PQ.empty () && lastConsidered > 1)
        {
            pair < int, int > curr = PQ.top ();
            PQ.pop ();
            if (curr.first == 0) break;
            lastConsidered = curr.first;
            PQ.push ({lst[curr.first - 1][curr.second], curr.second});
            int k = curr.first;
            if (ap[x[k]] && ap[y[k]])
            {
                ok = 0;
                break;
            }
            if (ap[x[k]])
                ap[y[k]] = 1, PQ.push ({lst[curr.first - 1][y[k]], y[k]});
            else
            if (ap[y[k]])
                ap[x[k]] = 1, PQ.push ({lst[curr.first - 1][x[k]], x[k]});
            else
            {
                printf ("WA\n");
                return 0;
            }
        }
        ans += (ok == 1);
        //if (ok)
          //  printf ("%d %d\n", i, j);
    }
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 160768
using System;
using System.Collections.Generic;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var sList = new int[n][];
            for (var i = 0; i < n - 1; ++i)
            {
                var csf = Console.ReadLine().Split(' ');
                sList[i] = new int[3] { int.Parse(csf[0]), int.Parse(csf[1]), int.Parse(csf[2]) };
            }

            for (var i = 0; i < n; ++i)
            {
                var time = 0;
                for (var st = i; st < n - 1; ++st)
                {
                    time = Next(sList[st], time);
                }
                Console.WriteLine(time);
            }
        }

        static int Next(int[] csf, int time)
        {
            if (time <= csf[1])
            {
                return csf[1] + csf[0];
            }
            else
            {
                return time + (time % csf[2] == 0 ? 0 : (csf[2] - time % csf[2])) + csf[0];
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
int main(){
  string ans = "TBD";
  string now;
  cin>>now;
  int year;
  year = ctoi(now[0])*1000+ctoi(now[1])*100+ctoi(now[2])*10+ctoi(now[3]);
  if(year < 2019)ans = "Heisei";
  int month;
  int day;
  month = ctoi(now[5])*10 + ctoi(now[6]);
  if(year == 2019){
  	
  	if(month < 4){
      ans = "Heisei";
    }
    if(month == 4){

      day = ctoi(now[8])*10 + ctoi(now[9]);
      
      if(day <= 30)ans = "Heisei";
    }
  }
  cout<<ans;
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
struct union_find{
    vector<int> par; 
    vector<int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        size.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size.push_back(1);
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    //頂点aが含まれる木の大きさ(頂点数)
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    union_find tree(n);
    int x,y,z;
    rep(i,m){
        cin >> x >> y >> z;
        tree.unite(x,y);
    }
    set<int> st;
    rep(i,n) st.insert(tree.root(i+1));
    cout << st.size() << endl;
}

Measured memory_bytes: 5748
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

ll gya[2500010];
ll kai[2500010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod2;
        }
        now*=now;
        now%=mod2;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod2-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod2;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod2;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod2;
    ret*=gya[k];
    ret%=mod2;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod2;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    nckinit(2500009);
    ll ans=nck(3*m+n-1,n-1);
    ll sum=0;
    rep(i,1,m+1){
        sum+=nck(m-i+n-2,n-2);
        sum%=mod2;
    }
    sum*=n;
    sum%=mod2;
    ll sum2=0;
    if(n<=m)sum2=0;
    else{
        rep(i,m+1,n+1){
            if(i>3*m)break;
            if(m%2!=i%2)continue;
            sum2+=nck(n,i)*nck((3*m-i)/2+n-1,n-1);
            sum2%=mod2;
        }
    }
   // cout<<ans<<" "<<sum<<" "<<sum2<<endl;
    ans+=-sum-sum2+2*mod2;
    cout<<ans%mod2<<endl;
}


Measured memory_bytes: 39296
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Attention

            //コンソールの設定を変更
            Console.SetIn(new StreamReader(Console.OpenStandardInput(262144),
                                           Console.InputEncoding, false, 262144));

            int n = int.Parse(Console.ReadLine().TrimEnd());
            string line = Console.ReadLine().TrimEnd();

            int allEastern = CountEasternPeople(n, line);

            int min = CountMinimumTurnedPeople(n, line, allEastern);
            Console.WriteLine(min);
        }

        static int CountEasternPeople(int n, string line)
        {
            //[summary]東を向いている人の総数をカウント
            var people = line.ToCharArray();
            return people.Count(c => c == 'E');
        }

        static int CountMinimumTurnedPeople(int n, string line, int allEastern)
        {
            int min = allEastern;
            int allWestern = 0;

            for (int i = 1; i < n; i++)
            {
                if (line[i - 1] == 'W')
                {
                    allWestern++;
                }
                else
                {
                    allEastern--;
                }

                int turnedPeople = allWestern + allEastern;

                if (line[i] == 'E')
                {
                    turnedPeople--;
                }

                if (turnedPeople == 0)
                {
                    return 0;
                }
                else if (turnedPeople < min)
                {
                    min = turnedPeople;
                }
            }

            return min;            
        }
    }
}

Measured memory_bytes: 14688
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int b, r, g, c, s, t, ans;
	for (; ~fscanf(stdin, "%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t), b, r, g, s, c, t; P(d, ans)) {
		ans = 100 + (b + r) * 15 + g * 7 + c * 2 + (b * 5 + r * 3) * 13;
		ans -= (t - (s + b * 5 + r * 3)) * 3;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll dp[MX],ac[MX],arr[105];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N,K; cin >> N >> K;

    F0R(i,N) cin >> arr[i];

    dp[0] = 1LL;
    F0R(i,N) {
        F0R(j,K+1) {
            ac[j+1] = (ac[j]+dp[j])%MOD;
            dp[j] = (ac[j+1]-ac[max(0LL,(ll)j-arr[i])]+MOD)%MOD;
        }
    }

    cout << dp[K] << "\n";

}


Measured memory_bytes: 1792
// B - Training Camp
// https://atcoder.jp/contests/abc055/tasks/abc055_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
using vp = vector<P>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  uli a, b, c, h, k, n, w, ans = 1LL, count = 0;
  string s, t;
  cin >> n;
  repe(i, 1, n)
  {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

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

  n=lcm(360,x);
  
  cout<<n/x<<endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int C = A;
  int a, b, d, e;
  int sum = 0;
    for (int i = 0; i <= B - A; i++) {
      // Cの一の位の数
      a = C % 10;
      // 十の位
      b = (C % 100) / 10;
      // 千の位
      d = (C % 10000) / 1000;
      // 一万の位
      e = C / 10000;
      // 一の位と一万の位、十の位と千の位が等しければ良い
      if ((a == e) && (b == d)){
        sum += 1;
      }
      C += 1;
    }
  cout << sum << endl;
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main() {
    int A, B;
    cin >> A >> B;

    //

    int ans = 0;
    for (int i = A; i <= B; ++i) {
        const char *digits = to_string(i).c_str();
        if(digits[0] == digits[4] && digits[1] == digits[3]){
            ans++;
//            cout << i << endl;
        }
    }


    //
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
c=[['#']*(W+2)]
ten=0
for i in range(H):
    ip=list(input())
    ten+=ip.count('.')
    c.append(['#']+ip+['#'])
c.append(['#']*(W+2))
Q=deque([[1,1,1]])

def move(yxc):
    global Q,c
    y,x,cost=yxc[0],yxc[1],yxc[2]
    if c[y+1][x]=='.':
        c[y+1][x]=cost+1
        Q.append([y+1,x,cost+1])
    if c[y-1][x]=='.':
        c[y-1][x]=cost+1
        Q.append([y-1,x,cost+1])
    if c[y][x+1]=='.':
        c[y][x+1]=cost+1
        Q.append([y,x+1,cost+1])
    if c[y][x-1]=='.':
        c[y][x-1]=cost+1
        Q.append([y,x-1,cost+1])

c[1][1]=1
while len(Q)>0:
    move(Q.popleft())

goal=c[H][W]
if goal=='.' or goal=='#':
    print(-1)
else:
    print(ten-goal)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
 
            int ans = b.Length;
 
            for (int ap = 0; ap <= a.Length - b.Length; ap++)
            {
                int diff = 0;
                for(int bp=0; bp<b.Length;bp++)
                {
                    if (a[ap + bp]!=b[bp])
                    {
                        diff++;
                    }
                }
                ans = ans > diff ? diff : ans; 
            }
 
            Console.WriteLine(ans);
        }
    }
}

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
        }

        long ans = 0;
        for (int i = N - 1; i >= 0; i--)
        {
            A[i] += ans;
            A[i] %= B[i];
            ans += (B[i] - A[i]) % B[i];
        }
        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 17288
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int H,N;
  cin>>H>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  vector<int>dp(10005,INF);
  dp[H]=0;
  for(int j=H;j>=0;j--){
    for(int i=0;i<N;i++){
      chmin(dp[max(0,j-A[i])],dp[j]+B[i]);
    }
  }
  cout<<dp[0]<<endl;
  return 0;  
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

ll X;

int main() {
	
	scanf("%lld", &X);
	ll now = 100;
	int t = 0;
	while (now < X) {
		t++;
		now += now / 100;
	}
	printf("%d\n", t);

	return 0;
}		

Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int main(){
    long n;
    cin >> n;
    long ans = 0;
    for(long i = 1;i <= n;i++){
        if(!(i % 3 == 0 || i % 5 == 0)){
            ans += i;
        }
    }

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

Measured memory_bytes: 3624
class Combination():  # nCr(mod p) #n<=10**6
    def __init__(self, N, MOD):  # cmbの前処理
        self.mod = MOD
        self.FACT = [1, 1]  # 階乗
        self.INV = [0, 1]  # 各iの逆元
        self.FACTINV = [1, 1]  # 階乗の逆元
        for i in range(2, N + 1):
            self.FACT.append((self.FACT[-1] * i) % self.mod)
            self.INV.append(pow(i, self.mod - 2, self.mod))
            self.FACTINV.append((self.FACTINV[-1] * self.INV[-1]) % self.mod)

    def count(self, N, R):  # nCr(mod p) #前処理必要
        if (R < 0) or (N < R):
            return 0
        R = min(R, N - R)
        return self.FACT[N] * self.FACTINV[R] * self.FACTINV[N-R] % self.mod


n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7

ans = 0
cmb = Combination(n, mod)
for i in range(n):
    cnt = cmb.count(i, k - 1) - cmb.count(n - i - 1, k - 1)
    ans += a[i] * cnt % mod
print(ans % mod)


Measured memory_bytes: 20952
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }

    let mut _a = a.clone();
    _a.sort();
    
    for i in 0..n-1 {
        if _a[i] == _a[i+1] {
            println!("NO");
            return;
        }
    }
    println!("YES");

}



Measured memory_bytes: 8444
#include <cassert>
#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>
*/

// 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 <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>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll alp[26] = {0};
  rep(i,s.size()) alp[s[i]-'a']++;
  ll ans = 0;
  rep(i,26) ans += alp[i] * (alp[i] - 1 ) / 2;
  cout<<s.size()*(s.size()-1)/2 - ans +1<<endl;
  
}

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


Measured memory_bytes: 720
import sys

n,m = map(int,input().split())
sc = []

if m == 0 and n == 1:
  print(0)
  sys.exit()
elif m == 0 and n != 1:
  print(10**n // 10)
  sys.exit()


for _ in range(m):
  sc.append(list(map(int,input().split())))

sc.sort()

if n == 1:
  tmp = 0
  for i in range(m):
    if sc[i][0] == 1 and sc[i][1] == 0:
      tmp += 1
    if tmp == m:
      print(0)
      sys.exit()

if sc[0][0] == 1 and sc[0][1] == 0:
  print('-1')
  sys.exit()

ans = [-1 for _ in range(n)]
for i in range(m):
  if ans[sc[i][0]-1] == -1:
    ans[sc[i][0]-1] = sc[i][1]
  else:
    if ans[sc[i][0]-1] != sc[i][1]:
      print('-1')
      sys.exit()

res = ''
if ans[0] == -1:
  ans[0] = 1
for i in range(n):
  if ans[i] == -1:
    ans[i] = 0
  res = res + str(ans[i])

print(res)


Measured memory_bytes: 3064
#include<stdio.h>
int data[101][101];
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&data[i][j]);
      data[n][j]+=data[i][j];
      data[i][m]+=data[i][j];
    }
    data[n][m]+=data[i][m];
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<m;j++){
      printf("%d ",data[i][j]);
    }
    printf("%d\n",data[i][m]);
  }
  return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
    int a,b,maxx;
    cin>>a>>b;
    maxx=max(a*b,max(a+b,a-b));
    cout<<maxx<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int E,V;

int main(){
  cin >> V >> E;
  UnionFind<int> uf(V);
  int l[E],r[E],d[E];
  rep(i,E){
    cin >> l[i] >> r[i] >> d[i];
    l[i]--,r[i]--;
    if(uf.issame(l[i],r[i]) && uf.diff(l[i],r[i])!=d[i]){
      cout << "No" << endl;
      return 0;
    }
    uf.merge(l[i],r[i],d[i]);
  }
  cout << "Yes" << endl;
return 0;}

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

int main(){
  int n,y;
  cin >> n >> y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(10000*i+5000*j+1000*(n-i-j)==y){
        cout << i << " " << j << " " << n-i-j <<endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t h;
    cin>>h;
    int roop=0;
    int64_t tmp=h;
    while(tmp>0){
        tmp /=2;
        roop++;
    }
    //cout<<roop<<endl;
    int64_t sum=0;
    rep(i,roop){
        sum += pow(2,i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 384
from itertools import accumulate
n, k = map(int,input().split())
s = input()
a = []
i = 0
cnt = 0
now = s[0]
while i < n:
    if s[i] == now:
        cnt += 1
    else:
        a.append(cnt)
        now = s[i]
        cnt = 1
    if i == n-1:
        a.append(cnt)
    i += 1

if len(a) == 1 and s[0] == '1':
    print(n)
    exit()

if s[0] == '0':
    a = [0] + a
if s[-1] == '0':
    a.append(0)
    
r = list(accumulate(a))
lr = len(r)
ans = -float('inf')
kk = 2*k+1
for i in range(k*2, lr+1 , 2):
    if i == k*2:
        ans = max(ans, r[i])
    else:
        ans = max(ans, r[i] - r[i-kk])
        
if ans == -float('inf'):
    print(n)
    exit()
print(ans)

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;

int hako[100001]; // 0->white#1 1->red#1 2->none 3->white+red
int haco[100001]; // #-1

int main(){
    int i,j,k,l;
    
    cin>>n>>m;
    
    hako[1]=1;
    haco[1]=0;
    
    int x,y;
    for (i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        assert(0<=haco[x]);
        
        switch(hako[x]){
            case 0:
                switch(hako[y]){
                    case 0:
                        break;
                    case 1:
			            hako[y]=3;
                        break;
                    case 2:
                        hako[y]=0;
                    	break;
                    case 3:
                    	break;
                }
                break;
            case 1:	
                switch(hako[y]){
                    case 0:
                        hako[y]=3;
                        break;
                    case 1:
                        abort(); // [[arienai]]
                        break;
                    case 2:
                        hako[y]=1;
                    	break;
                    case 3:
                        abort(); // [[arienai]]
                    	break;
                }
                break;
            case 3:
                hako[y]=3;
                break;
        }
        haco[x]--;
        haco[y]++;
        if (haco[x]<0) hako[x]=2;
    }
    
    int result=0;
    for (i=1;i<=n;i++){
        if (hako[i]==1 || hako[i]==3)
            result++;
    }
    
    //debuga(hako,n+1)

    cout<<result<<endl;

    return 0;
}

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

int main(){
	string S;
	cin >> S;
	int A = -1;
	for (int i = 0;i < S.size() - 2;++i) {
		int num = stoi(S.substr(i, 3));
		if (A < 0 || abs(num - 753) < A) {
			A = abs(num - 753);
		}
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;


int N;
int p;
int A[200000];
int cons;
int ans;

int max(int a, int b) { if (a > b) { return a; } else { return b; } }

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p);
		A[p-1] = i;
	}

	cons = 1;
	ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] < A[i + 1]) { cons++; }
		if (A[i] > A[i + 1]) { ans = max(ans, cons); cons = 1; }
	}
	ans = max(ans, cons);
	printf("%d\n", N - ans);
}


Measured memory_bytes: 896