akhauriyash/Code-Regression huggingface dataset:
#pragma option -Wparentheses
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

struct query {
	int t, f;
	char c;
	query() : t(0), f(0), c(' ') {}
};

signed main() {
	string s;
	int q;
	cin >> s;
	cin >> q;
	V<query> qs(q);
	REP(i, q) {
		cin >> qs[i].t;
		if (qs[i].t == 2) {
			cin >> qs[i].f >> qs[i].c;
		}
	}

	int rev = 1;
	string front(""), back("");
	REP(i, q) {
		if (qs[i].t == 1) {
			rev *= -1;
			continue;
		}
		if (rev > 0) {
			if (qs[i].f == 1) {
				front += qs[i].c;
			}
			else {
				back += qs[i].c;
			}
		}
		else {
			if (qs[i].f == 1) {
				back += qs[i].c;
			}
			else {
				front += qs[i].c;
			}
		}
	}

	if (rev > 0) {
		reverse(ALL(front));
		s = front + s + back;
	}
	else {
		reverse(ALL(s));
		reverse(ALL(back));
		s = back + s + front;
	}
	col(s);
	return 0;
}


Measured memory_bytes: 6632
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  mll m;
  rep(i,3){
    ll a;
    cin >> a;
    m[a]++;
  }
  ll ans = m.size();
  ANS;
  return 0;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String strN = Integer.toString(N);
		StringBuffer sb = new StringBuffer(strN);
		
		if (strN.equals(sb.reverse().toString())){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		string A,B;
		cin>>A>>B;
		ll n=A.length();
		ll m=B.length();
		ll dp[n+1][m+1];
		mem(dp,0);
		forn(i,n+1)
		{
			forn(j,m+1)
			{
				if(i==0||j==0)
					dp[i][j]=0;
				else if(A[i-1]==B[j-1])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
		ll ind=dp[n][m];
		string ans;
		ll i=n,j=m;
		while(i>0&&j>0)
		{
			if(A[i-1]==B[j-1])
			{
				ans.pb(A[i-1]);
				i--;j--;ind--;
			}
			else if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
		reverse(all(ans));
		cout<<ans<<endl;
		//cout<<dp[n][m]<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 74032
#include <bits/stdc++.h>
using namespace std;
bool is_present(int n,set<int> not_allowed)
{
  while(n)
  {
    if(not_allowed.find(n % 10) != not_allowed.end())
      	return true;
    n /= 10;
   	 
  }
  return false;
  
}
int main()
{
  	int n,k,l;
 	cin>>n>>k;
  	set<int> not_allowed;
  	for(int i=0; i<k; i++)
    {
     	 cin>>l;
      	 not_allowed.insert(l);
    }
  	while(1)
    {
     	if(is_present(n,not_allowed))
        {
          n++;
        }
      else
      {
       	cout<<n;
        return 0;
      }
      
    }
  
}

Measured memory_bytes: 256
#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 eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;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 n,m;
vector<P1>edge[10005];
int par[505],ran[505];
void init(){ for(int i=0;i<505;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
vector<P>G[505];
int cnt[505];
bool used[505];
int dep[505];
vector<P>H[505];

int cnty;
ll sum;

void dfs(int v,int u,int d){
	if(used[v]) return;
	dep[v] = d; used[v] = 1;
	for(int i=0;i<G[v].size();i++){
		int to = G[v][i].fi;
		if(to ==  u) continue;
		if(!used[to]){
			H[v].pb(G[v][i]);
			dfs(to,v,d+1);
			//cout<<v<<" "<<to<<endl;
		}
		else{
			if(dep[v] > dep[to]){
				cnt[v]++;
				cnt[to]--;
			}
			else{
				cnt[v]--;
				cnt[to]++;
			}
			//cout<<v<<"a "<<to<<endl;
		}
	}
}
int dfs2(int v,int u,int add){
	int x = cnt[v];
	for(int i=0;i<H[v].size();i++){
		int to = H[v][i].fi;
		int nm = H[v][i].sc;
		int ret = dfs2(to,v,add);
		if(ret == 0){
			cnty++;
			sum+=add;
		}
		x += ret;
	}
	return x;
}
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,d; cin>>a>>b>>d;
		edge[d].pb(mp(i,mp(a,b)));
	}
	init();
	rep(i,10005){
		rep(i,505){
			G[i].clear();
			H[i].clear();
		}
		rep(j,edge[i].size()){
			int a = edge[i][j].sc.fi;
			int b = edge[i][j].sc.sc;
			a = find(a);
			b = find(b);
			if(a != b){
				G[a].pb(mp(b,edge[i][j].fi));
				G[b].pb(mp(a,edge[i][j].fi));
			}
		}
		memset(used,0,sizeof(used));
		memset(cnt,0,sizeof(cnt));
		rep(j,505){
			if(used[j]) continue;
			dfs(j,-1,0);
			dfs2(j,0,i);
		}
		rep(j,edge[i].size()){
			int a = edge[i][j].sc.fi;
			int b = edge[i][j].sc.sc;
			unite(a,b);
		}
	}
	cout<<cnty<<" "<<sum<<endl;
}


Measured memory_bytes: 4716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		int ans = 0;
		for (int i=0;i<S.length;i++) {
			if (S[i]=='2') {
				ans++;
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<utility>
#include<bitset>
using namespace std;
int main(int argc, char *argv[])
{
  const int N = 100;
  for(int t = 1;; t++) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<bitset<N>> mat;
    auto read = [](){
      int m;
      cin >> m;
      bitset<N> vs;
      for(int j = 0; j < m; j++) {
        int p;
        cin >> p;
        vs[p-1] = true;
      }
      return move(vs);
    };
    for(int i = 0; i < n; i++) {
      mat.push_back(read());
    }
    bitset<N> ls = read();
    int cnt = 0;
    int idx = -1;
    for(int i = 0; i < n; i++) {
      if(ls == (ls & mat[i])) {
        cnt++;
        idx = i + 1;
      }
    }
    cout << (cnt == 1 ? idx : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3012
n,m=map(int,input().split())
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
uf=WeightedUnionFind(n)
for i in range(m):
  l,r,d=map(int,input().split())
  l-=1
  r-=1
  if uf.same(l,r):
    if uf.diff(l,r)!=d:
      print('No')
      exit()
  else:
    uf.union(l,r,d)
print('Yes')

Measured memory_bytes: 11636
#include "bits/stdc++.h"
using namespace std;
int s[510][510];
int main(){
	int n,m,q;cin>>n>>m>>q;
	int l,r;
	for (int i=0; i<m; ++i){
		cin>>l>>r;
		++s[l][r];
	}
	for (int i=1; i<=n; ++i)for (int j=1; j<=n; ++j)s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
	for (int i=0; i<q; ++i){
		cin>>l>>r;
		cout<<s[r][r]-s[r][l-1]-s[l-1][r]+s[l-1][l-1]<<endl;
	}
}

Measured memory_bytes: 1920
N = int(input())
ls = input().strip().split(' ')
T = int(ls[0])
A = int(ls[1])
ls = []
n = 1
for i in input().strip().split(' '):
    ls.append((abs(T - 0.006 * int(i) - A), n))
    n += 1
ls.sort()
print(ls[0][1])


Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

ll m[31][200001] = {};
ll sum[200001] = {};
int main() {
	ll n, C; cin >> n >> C;

	rep(i, 0, n) {
		ll s, t, c; cin >> s >> t >> c;

		//if (m[c][2 * s] < 0) {
		//	m[c][2 * s]++;
		//}
		//else {
		//	m[c][2 * s - 1]++;
		//}

		m[c][2 * s - 1]++;
		m[c][2 * t]--;
	}
	repe(i, 1, C) {
		rep(j, 1, 200001) {
			m[i][j] += m[i][j - 1];
		}
	}

	ll maxV = 0;
	rep(i, 1, 200001) {
		repe(j, 1, C) {
			if (m[j][i] >= 1) {
				sum[i]++;
			}
			//sum[i] += m[j][i]`;
		}
		maxV = max(maxV, sum[i]);
	}

	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 49792
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int *)b - *(int *)a;
}

int main(){
  int A,B,C,X,Y, p[100000],q[100000],r[100000];
  int i,j,p_i,q_i;
  long long p0, q0, pq_del, r_add;
  scanf("%d%d%d%d%d",&X,&Y,&A,&B,&C);
  for(i=0;i<A;i++){
    scanf("%d",p+i);
  }
  for(i=0;i<B;i++){
    scanf("%d",q+i);
  }
  for(i=0;i<C;i++){
    scanf("%d",r+i);
  }
  qsort(p,A,sizeof(int),cmp);
  qsort(q,B,sizeof(int),cmp);
  qsort(r,C,sizeof(int),cmp);
  p0 = 0;
  for(i=0;i<X;i++){
    p0 += p[i];
  }
  q0 = 0;
  for(i=0;i<Y;i++){
    q0 += q[i];
  }
  p_i = X-1;
  q_i = Y-1;
  pq_del = 0;
  r_add = 0;
  for(i=0;i<C;i++){
    if(p_i >= 0 && q_i >= 0){
      if(p[p_i] < q[q_i]){
        if(r[i] > p[p_i]){
          r_add += r[i];
          pq_del += p[p_i];
          p_i--;
        }
        else{
          break;
        }
      }
      else{
        if(r[i] > q[q_i]){
          r_add += r[i];
          pq_del += q[q_i];
          q_i--;
        }
        else{
          break;
        }
      }
    }
    else if(p_i >= 0){
        if(r[i] > p[p_i]){
          r_add += r[i];
          pq_del += p[p_i];
          p_i--;
        }
        else{
          break;
        }
    }
    else if(q_i >= 0){
      if(r[i] > q[q_i]){
        r_add += r[i];
        pq_del += q[q_i];
        q_i--;
      }
      else{
        break;
      }
    }
    else
    {
      break;
    }
  }
  printf("%lld",p0 + q0 + r_add - pq_del);
  //printf("\n%d : %d : %d : %d\n",p0 ,q0, r_add, pq_del);
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    unordered_map<int, int> m;
    bool coprime = true;
    rep(i, 0, n) { 
        cin >> v[i];
        int k = v[i];
        unordered_map<int, int> mm;
        for(int j = 2; j * j <= k; j++) {
            if(k % j == 0) {
                while(k % j == 0) {
                    k /= j;
                    mm[j]++;
                }
            }
        }
        if(k != 1) mm[k]++;
        for(auto it = mm.begin(); it != mm.end(); it++) {
            if(m[it->first] != 0) {
                coprime = false;
            } else {
                m[it->first] += it->second;
            }
        }
    }   
    if(coprime) {
        cout << "pairwise coprime";
    } else {
        int res = v[0];
        for(int i = 1; i < n; i++) {
            res = __gcd(res, v[i]);
        }
        if(res == 1) {
            cout << "setwise coprime";
        } else {
            cout << "not coprime";
        }
    }
}

Measured memory_bytes: 10464
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
    int n; ll c; cin >> n >> c;
    vector<ll> X(n), V(n);
    rep(i, n) cin >> X[i] >> V[i];
    
    vector<ll> SR(n+1), SR_MAX(n+1), SL(n+1), SL_MAX(n+1);
    //R
    rep(i, n){
        ll val = V[i] - (X[i] - (i>0? X[i-1] : 0));
        SR[i+1] = SR[i] + val;
        SR_MAX[i+1] = max(SR_MAX[i], SR[i+1]);        
        //cout << "S:" << SR[i+1] << " SM:" << SR_MAX[i+1] << ln;
    }
    //L
    rep(i, n){
        int ind = n-1-i;
        ll val = V[ind] - (c-X[ind]-(i>0? c-X[ind+1] : 0));
        SL[i+1] = SL[i] + val;
        SL_MAX[i+1] = max(SL_MAX[i], SL[i+1]);
        //cout << "S:" << SL[i+1] << " SM:" << SL_MAX[i+1] << ln;
    }
    ll res = 0;
    rep(i, n+1){
        int R = i, L = n-i;
        chmax(res, SR_MAX[R] + SL_MAX[L] - (i>0?X[R-1]:0));
    }
    reverse(all(X));
    rep(i, n+1){
        int L = i, R = n-i;
        chmax(res, SL_MAX[L] + SR_MAX[R] - (i>0?c-X[L-1]:0));
    }

    cout << res << ln;
}

Measured memory_bytes: 4992
from collections import deque,defaultdict
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
mod =10**7
table=defaultdict(set)
visit=defaultdict(int)
for i in range(M):
    a,b,c=map(int,input().split())
    table[a].add(a+c*mod)
    table[b].add(b+c*mod)
    table[a+c*mod].add(a)
    table[b+c*mod].add(b)
    table[a+c*mod].add(b+c*mod)
    table[b+c*mod].add(a+c*mod)
    visit[a]=0
    visit[b]=0
    visit[b+c*mod]=0
    visit[a+c*mod]=0

H=deque()
H.append((1,0))
visit[1]=1
ans=mod
while H:
    #print(H)
    x,cost=H.popleft()
    visit[x] = 1
    if x==N:
        ans=min(ans,cost)
        break
    for y in table[x]:
        if visit[y]==1:
            continue
        if x<=10**5 and mod<=y:
            H.append((y,cost+1))
        else:
            H.appendleft((y,cost))
if ans==mod:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 214252
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll a,b;
    cin>>a>>b;
    if(a<=b){cout<<"Impossible"<<endl; return 0;}
    ll n=a+b;
    vector<ll> A;
    A.push_back(0);
    for(ll i=1;i<n;i++){
        cout<<"? "<<A.back()<<" "<<i<<endl;
        char ans;
        cin>>ans;
        if(ans=='Y'){
            A.push_back(i);
        }
        else{
            A.pop_back();
            if(A.empty()){
                A.push_back(i+1);
                i++;
            }
        }
    }
    string B;
    for(ll i=0;i<n;i++){
        cout<<"? "<<A.back()<<" "<<i<<endl;
        char ans;
        cin>>ans;
        if(ans=='Y'){B.push_back('1');}
        else{B.push_back('0');}
    }
    cout<<"! "<<B<<endl;
    
    
    return 0;
}


Measured memory_bytes: 724
n = int(input())
l = list(map(int,input().split()))
#print(n,l)

ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if l[i]+l[j]+l[k] - max(l[i],l[j],l[k]) > max(l[i],l[j],l[k]):
                if l[i] != l[j] and l[j]!= l[k] and l[i] !=l[k]:
                    ans+=1
print(ans)


Measured memory_bytes: 9192
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    X = sc.intarr()[0]

    a = X // 100
    b = X - (a*100)

    if a * 5 >= b:
        print("1")
    else:
        print("0")


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()


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

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

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

    string S;
    S = to_string(N);
    int length = (int)S.size();
    bool is_s = false;
    for(int i = 0; i < length; i++){
        if(S.at(i) == '7'){
            is_s = true;
            break;
        }
    }

    if(is_s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;
static const int MAX = 101;
int V, tt;
bool visited[MAX];
int disc[MAX], finish_time[MAX];
vector<int> G[MAX];

void dfs(int current) {
      visited[current] = true;
      disc[current] = ++tt;
      for (int i = 0; i < G[current].size(); i++) {
          int next = G[current][i];
          if (!visited[next]) dfs(next);
      }
      finish_time[current] = ++tt;
}

int main()
{
    int k, source, target;
    tt=0;
    scanf("%d", &V);
    for (int i = 0; i < V; i++) {
        scanf("%d %d", &source, &k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &target);
            G[source].push_back(target);
        }
    }

    fill(visited, visited+V+1, 0);
    fill(disc, disc+V+1, 0);
    fill(finish_time, finish_time+V+1, 0);
    for (int i = 1; i <= V; i++) {
        if (!visited[i]) {
            dfs(i);
        }
    }

    for (int i = 1; i <=V; i++) {
        printf("%d %d %d\n", i, disc[i], finish_time[i]);
    }

    return 0;
}



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

const int N = 1e6 + 5;
#define F first
#define S second

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    string s , t;
    cin >> s >> t;
    int sz1 = s.size() , sz2 = t.size();

    int dd[sz1 + 5][sz2 + 5];
    memset(dd , 0 , sizeof(dd));

    for(int i = 1 ; i <= sz1 ;  i ++) {
        for(int j = 1 ; j <= sz2 ; j ++) {
            if(s[i-1] == t[j-1]) {
                dd[i][j] = dd[i-1][j-1] + 1;
            }
            else
                dd[i][j] = max(dd[i-1][j] , dd[i][j-1]);
        }
    }


    string ans = "";
    int i = sz1 , j = sz2;

    while(i >= 1 && j >= 1) {
        if(s[i-1] == t[j - 1]) {
            ans += t[j - 1];
            //cout << i << " " << j << " " << t[j - 2] << endl;
            j--;
            i--;
        }
        else {
            if(dd[i-1][j] > dd[i][j-1])
                i--;
            else
                j--;    
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;

}

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

int main() {
	double a, b, ave;

	scanf("%lf %lf", &a, &b);

	ave = (a + b) / 2 + 0.9;

	//ave = (a + b) / 2;
	//ceil(ave);

	printf("%d\n", (int)ave);

	return 0;
}

Measured memory_bytes: 256
/**
*    created: 28.06.2020 02:08:12
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

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

    auto ctoi = [&] (char c) {
        if (c >= '0' && c <= '9') return c - '0';
	    return -1;
    };

    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    rep(i,s.size()) sum += ctoi(s[i]);
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3688
/* Arthur Conmy / arthurconmy */
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) for (int j = int(d); j >= int(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())
#define endl "\n"

ll A[100000];
ll B[100000];

int main() // LL OR INT??
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;
	cin>>n;

	ll summ=0;

	REP(i,1,n)
	{
		ll a;
		cin>>a;
		A[i]=a;
	
		summ+=a;
	}

	B[1]=summ;

	REP(i,1,n)
	{
		if(i%2 == 0)
		{
			B[1]-=A[i]+A[i];
		}
	}

	REP(i,2,n)
	{
		B[i]=A[i-1]+A[i-1]-B[i-1];
	}

	REP(i,1,n) cout << B[i] << " ";
	cout << endl;
}

Measured memory_bytes: 2944
using System;
class aizu{
    public static int Main(){
    	int[] n = new int[100];
    	string[] str = new string[100];
    	str = Console.ReadLine().Split(' ');
    	n[0] = int.Parse(str[0]);
    	n[1] = int.Parse(str[1]);
        if(n[0]-n[1]>0)
            Console.WriteLine("a > b");
        else if(n[0]-n[1]<0)
            Console.WriteLine("a < b");
        else if(n[0]-n[1]==0)
            Console.WriteLine("a == b"); 
        return 0;
    }
}

Measured memory_bytes: 8808
/**
 *      ABC 88 A
 *      author  : kyomukyomupurin
 *      created : 2018-08-31 23:52:43
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, A; cin >> N >> A;

    if (N % 500 <= A){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int ans;
bool s[111111];
int dp[111111];
vi adjList[111111];
bool visited[111111];

void dfs(int x){
	for(int i = 0; i < adjList[x].size(); i++){
		if(!visited[adjList[x][i]]){
			visited[adjList[x][i]]=1;
			dfs(adjList[x][i]);
		}
		dp[x]=max(dp[x],1+dp[adjList[x][i]]);
	}
	ans=max(ans,dp[x]);
}

int main(){
	int n, m, u, v;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		adjList[u].pb(v);
		s[v]=0;
	}
	for(int i = 1; i <= n; i++){
		if(!s[i])dfs(i);
	}
	cout<<ans;
	
}


Measured memory_bytes: 8576
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int A = Math.max(one.get(0), one.get(1));
      int B = Math.min(one.get(0), one.get(1));
      if(A > B + 1){
        myout(A + (A - 1));
      }else{
        myout(A + B);
      }
	}
	//Method addition frame start



	//Method addition frame end
}


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

int main(){
	int A,B;
	cin >> A >> B;
	
	REP(i,10000){
		if((i*2)/25 == A && i/10 == B){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, 1, N + 1) {
        string s = to_string(i);
        if (sz(s) % 2) {
            ans++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >>h>>w>>k;
  lol ans=0;
  lol sum=0;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin >>s[i];
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(s[i][j]=='#') sum++;
  for(int bit1=0;bit1<(1LL<<h);bit1++){
    lol tmp=0;
    vector<string> t(h);
    for(int i=0;i<h;i++) t[i]=s[i];
    for(int i=0;i<h;i++){
      if(bit1&(1LL<<i)){
        for(int j=0;j<w;j++){
          if(t[i][j]=='#'){
            tmp++;
            t[i][j]='.';
          }
        }
      }
    }
    //if(tmp>sum) continue;
    for(int bit2=0;bit2<(1LL<<w);bit2++){
      lol p=tmp;
      for(int j=0;j<w;j++){
        if(bit2&(1LL<<j)){
          for(int i=0;i<h;i++){
            if(t[i][j]=='#'){
              p++;
              //r[i][j]='.';
            }
          }
        }
      }
      if(sum-p==k){
        ans++;
        //cout <<bit1<<' '<<bit2<<'\n';
      }
    }
  }
  cout <<ans<<'\n';
  return (0);
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int main() {
	cin>>n;
	ll ans = 0;
	ll now = 1;
	while(n) {
		ans+=now;
		now*=2;
		n/=2;
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#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 < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  int N;
  cin >> N;
  vector<string> A(N);
  REP(i,N){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  string a = "1331345231";
  ll ans = 0;
  REP(i,N){
    if(a!=A.at(i)){
      ans++;
      a = A.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
#define md 1000000007
using namespace std;
int n,m,i,dp[3400][3400][2],ans,k,j;
int main()
{
	scanf("%d %d",&n,&m);
	dp[0][0][1]=1;
	for (i=1;i<=n;i++) dp[0][i][0]=1;
	for (i=0;i<m;i++)
	{
		for (j=0;j<=n;j++)
		{
			for (k=0;k<=1;k++)
			{
				if(j) dp[i+1][j-1][k|(j==1)]=(dp[i][j][k]+dp[i+1][j-1][k|(j==1)])%md;
				if(j) dp[i+1][j][k|(j==1)]=(dp[i][j][k]+dp[i+1][j][k|(j==1)])%md;
				if(n-j) dp[i+1][j][k]=(dp[i][j][k]+dp[i+1][j][k])%md;
				if(n-j) dp[i+1][j+1][k]=(dp[i][j][k]+dp[i+1][j+1][k])%md;
			}
		}
	}
	for (i=0;i<=n;i++)ans=(ans+dp[m][i][1])%md;
	printf("%d\n",ans);
}

Measured memory_bytes: 80128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, M, K = MAP()

for i in range(N+1):
	for j in range(M+1):
		if M*i + N*j - 2*i*j == K:
			print("Yes")
			break
	else:
		continue
	break
else:
	print("No")

Measured memory_bytes: 10588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K; cin >> N >> K;
    vec<lint> h_list(N);
    range(i, 0, N) cin >> h_list.at(i);
    cout << count_if(h_list.begin(), h_list.end(), [&](const lint& a) {return a >= K;}) << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  
  sort(s.begin(), s.end());
  string ans;
  for(int i = 0; i < n; i++){
    ans += s.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

char t[200005], d[200005];

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    int ans = 0;
    int l = 0, r = n + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        int cur = mid - 1;
        bool ok = false;
        for (int i = 0; i < q; i++) {
            if (s[cur] == t[i]) {
                if (d[i] == 'R') {
                    cur++;
                } else {
                    cur--;
                }
            }
            if (cur == -1) {
                ok = true;
                break;
            } else if (cur == n) {
                break;
            }
        }
        if (ok) {
            l = mid;
        } else {
            r = mid;
        }
    }
    ans += l;
    l = 0; r = n + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        int cur = n - mid;
        bool ok = false;
        for (int i = 0; i < q; i++) {
            if (s[cur] == t[i]) {
                if (d[i] == 'R') {
                    cur++;
                } else {
                    cur--;
                }
            }
            if (cur == n) {
                ok = true;
                break;
            } else if (cur == -1) {
                break;
            }
        }
        if (ok) {
            l = mid;
        } else {
            r = mid;
        }
    }
    ans += l;
    printf("%d\n", max(n - ans, 0));
}


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

int main() {
    int n;
    cin>>n;
    ll mod=1000000000+7;
    ll ans=1;
    for(int i=1;i<=n;i++){
        ans=(ans*i)%mod;
    }
    cout<<ans;
}

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

using namespace std;

using ll = long long;


int main(){
    ll n; cin >> n;
    ll t, o;
    t = n / 1000;
    if(n % 1000 == 0)cout << 0;
    else cout << (t + 1) * 1000 - n;
    return 0;

}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))

c = [0, 0, 0]

ans = 1
for i in range(n):
    count = 0
    for _c in c:
        if a[i] == _c:
            count += 1

    ans = ans * count % 1000000007
    if c[0] == a[i]:
        c[0] += 1
    elif c[1] == a[i]:
        c[1] += 1
    else:
        c[2] += 1

print(ans)




Measured memory_bytes: 13964
#include <iostream>
#include <algorithm>
using namespace std;
int m[50];
int main()
{
  int i,j,k,a,b,c,n;
  for(i=1;i<=50;i++){
    if((i%2) != 0) a = 10000;
    else a = ((i+1)/10) * 1520 + ((i+1)%10)/2 * 380;
    if((i%3) !=0) b = 10000;
    else b = ((i+2)/12) * 1870 + ((i+2)%12)/3 * 550;
    if((i%5) !=0) c = 10000;
    else c = ((i+4)/15) * 2244 + ((i+4)%15)/5 * 850;
    n = min(a,min(b,c));
    j = 2; k = i-2;
    while(j <= k){
      if(n > m[j] + m[k]) n = m[j] + m[k];
      j++; k--;
    }
    m[i] = n;
  }
  for(;;){
    cin >> n;
    if(n==0) break;
    cout << m[n/100] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(void){
    int n,p[20],i,cou=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
       scanf("%d",&p[i]);
    }
    for(i=1;i<n-1;i++){
       if((p[i]>p[i-1])&&(p[i]<p[i+1])){
          cou++;
       }else if((p[i]<p[i-1])&&(p[i]>p[i+1])){
          cou++;
       }
    }
    printf("%d",cou);
   return 0;
}


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

int main() {
	int a,b,ans;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '+') {
			ans = a + b;
		}
		else if (op == '-') {
			ans = a - b;
		}
		else if (op == '*') {
			ans = a * b;
		}
		else if (op == '/') {
			ans = a / b;
		}
		else {
			break;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    int dai = max(a,b);
    if(dai * 2 <= 16){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3628
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
cnt2=1
while len(a) > 0:
    b=a.pop()
    cnt+=1
    if len(a)==0:
        break
    cnt2=1
    while cnt2<c:
        if a[-1]<=b+k:
            a.pop()
            cnt2+=1
            if len(a)==0:
                cnt2=1
                break
        else:
            cnt2=1
            break
print(cnt)
    

Measured memory_bytes: 8256
A, B = map(int, input().split())
S = input()
#print(S[A])
#print(len(S))
digits = ['0','1','2','3','4','5','6','7','8','9']
def solve():
    for i in range(A + B + 1):
        if i == A:
            if S[i] != '-':
                return False
        else:
            if S[i] not in digits:
                return False
    return True
if solve():
    print("Yes")
else:
    print("No")


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

int main() {
    int a, b, c, x, y;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

    int ans = a * x + b * y;
    for (int i = 0; i <= max(x, y); i++) {
        int price = a * max(0, (x - i)) + b * max(0, (y - i)) + c * 2 * i;
        ans = min(ans, price);
    }

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

    return 0;
}

Measured memory_bytes: 128