akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define BeatMeScanf    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tc(x)          int x; cin >> x; while(x--)
#define ll             long long
#define vi             vector<int>
#define pii            pair<int,int>
#define mii            map<int,int>
#define inf            1<<28
#define mem(x,y)       memset(x, y, sizeof(x))
#define ps(x,y)        fixed<<setprecision(y)<<x
#define show(val)      cout<< #val << " -> " << val << endl
#define Case           cout<< "Case "<< ++cs << ": "
#define all(v)         (v).begin(), (v).end()
#define rall(v)        (v).rbegin(), (v).rend()
#define mod            1000000007

int main()
{
    BeatMeScanf;
    int x, y, z;
    cin >> x >> y >> z;
    cout<< z <<" "<< x <<" "<< y <<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int y;
	int x;
	int opex;
	int opey;
	cin >> x >> y;

	if (x==2)
	{
		opex = 1;
	}else if (x==4 or x==6 or x==9 or x==11)
	{
		opex = 2;
	}else if (x==1 or x==3 or x==5 or x==7 or x==8 or x==10 or x==12)
	{
		opex = 3;
	}
	if (y==2)
	{
		opey = 1;
	}else if (y==4 or y==6 or y==9 or y==11)
	{
		opey = 2;
	}else if (y==1 or y==3 or y==5 or y==7 or y==8 or y==10 or y==12)
	{
		opey = 3;
	}

	if (opex==opey)
	{
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
brk = 0
i = 0
real = 1
while i < n:
  if a[i] == real:
    real = real + 1
  else:
    brk = brk + 1
  i = i + 1

if brk == n:
  print(-1)
else:
  print(brk)

Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
#define inf 5000
#define perMax 10

int Calc(int *a,int *b,int *c,int N,int Ma,int Mb,int SN,int **frd){
    int **sum;
    sum=new int*[SN*perMax+1];
    for(int i=0;i<=SN*perMax;i++)
        sum[i]=new int[SN*perMax+1];
    for(int i=0;i<=SN*perMax;i++)
            for(int j=0;j<=SN*perMax;j++)
                sum[i][j]=inf;    

    sum[0][0]=0; 
    if(SN==0) return Calc(a,b,c,N,Ma,Mb,SN+1,sum);
    for(int an=0;an<=(SN-1)*perMax;an++)
        for(int bn=0;bn<=(SN-1)*perMax;bn++){
            sum[an][bn] = min(sum[an][bn],frd[an][bn]);
            sum[an+a[SN-1]][bn+b[SN-1]] = min(frd[an][bn]+c[SN-1],sum[an+a[SN-1]][bn+b[SN-1]]);
        }

    if(SN!=N) return Calc(a,b,c,N,Ma,Mb,SN+1,sum);
    int res=inf;
    for(int an=0;an<=N*perMax;an++)
        for(int bn=0;bn<=N*perMax;bn++)
            if((an!=0||bn!=0)&&an*Mb==bn*Ma)res=min(sum[an][bn],res);
    if(res==inf) return -1;
    else return res;
}

int main(){
    int N,Ma,Mb;
    cin>>N>>Ma>>Mb;
    int a[N],b[N],c[N];
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<Calc(a,b,c,N,Ma,Mb,0,NULL)<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }

    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans, calc(t));
    }

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


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

int main() {
  string s;
  cin >> s;
  if(s.back() == 's') s += "es";
  else s += "s";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		String str = null;
		
		calc:
		for (int x = 0; x <= N; x++) {
			for (int y = 0; y <= N; y++) {
				if ( N == 4*x + 7*y) {
					str = "Yes";
					break calc;
				}
			}
			str ="No";
		}
		
		System.out.println(str);
    }
}

Measured memory_bytes: 22484
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 3e5 + 5;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct seg{
	int dat[1 << 20];
	int sz;
	seg(int s){
		sz = s;
		for(int i = 0; i < (1 << 20); i++){
			dat[i] = 0;
		}
	}
	void update(int i, int s, int e, int x, int v){
		if(s == e){
			dat[i] = max(dat[i], v);
			return;
		}
		int m = (s + e) / 2;
		if(x <= m) update(i << 1, s, m, x, v);
		else update(i << 1 | 1, m + 1, e, x, v);
		dat[i] = max(dat[i << 1], dat[i << 1 | 1]);
	}
	void update(int x, int v){
		update(1, 0, sz, x, v);
	}
	int maxQ(int i, int s, int e, int x, int y){
		if(e < x || y < s) return 0;
		if(x <= s && e <= y) return dat[i];
		int m = (s + e) / 2;
		return max(maxQ(i << 1, s, m, x, y), maxQ(i << 1 | 1, m + 1, e, x, y));
	}
	int maxQ(int x, int y){
		return maxQ(1, 0, sz, x, y);
	}
};

int dp[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	seg tree(mxN);
	rep(i, n){
		dp[i] = 1;
		dp[i] += tree.maxQ(max(0, a[i] - k), min(mxN, a[i] + k));
		tree.update(a[i], dp[i]);
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 9792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
    long long int a,b;
    scanf("%lld%lld",&a,&b);
    long long int t=a-b;
    //cout<<t<<endl;
    if(t<0)
        t=0;
    cout<<t<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain, count

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    a_max = max(A)
    ans = 0
    for i in count(0):
        mask = 2**i
        if mask > a_max:
            return ans
        c0 = 0
        c1 = 0
        for a in A:
            if a & mask:
                c1 += 1
            else:
                c0 += 1
        mask = mask % MOD
        ans = (ans + mask*(c0 * c1)) % MOD 

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, A)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49588
import java.util.Scanner;

public class Main {
  static String str;

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

    str = sc.next();
    int n = str.length();

    boolean[] dp = new boolean[n + 1];
    dp[0] = true;
    for(int i = 5; i <= n; i++){
      if(str.substring(i - 5, i).equals("dream")){
        dp[i] |= dp[i - 5];
      }
      if(str.substring(i - 5, i).equals("erase")){
        dp[i] |= dp[i - 5];
      }
      if(i - 7 >= 0 
        && str.substring(i - 7, i).equals("dreamer")){
          dp[i] |= dp[i - 7];
      }
      if(i - 6 >= 0
        && str.substring(i - 6, i).equals("eraser")){
        dp[i] |= dp[i - 6];
      }
    }

    if(dp[n]){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 28380
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
void solve(vector<ll>& vec , ll n ){
	for(ll i=1;i*i<=n ;i++){
		if(n%i==0){
			if(i*i==n)vec.pb(i);
			else{
				vec.pb(i);
				vec.pb(n/i);
			}
		}
	}
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	vector<ll> st;
	solve(st, n);
	ll ans = 0 ;
	for(auto x: st){
		if(x==1)continue;
		ll ps=n ;
		while(ps%x==0)ps=ps/x;
		if(ps%x==1)ans++;
	}
	st.clear();
	solve(st,n-1);
	ans+=st.size()-1;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  double N;
  cin >> N;
 
  cout << round((double)N/2) << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int a;
    int b;
    cin >> a >> b;
    int c = a;
    if (b == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    while (c < b)
    {
        c = (c - 1) + a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N,K;
    
    scanf("%d %d",&N,&K);
    
    if(N%2==0){
        if(N/2>=K){
            printf("YES");
        }else{
            printf("NO");
        }
    }else if(N%2==1){
        if((N+1)/2>=K){
            printf("YES");
        }else{
            printf("NO");
        }
        
    }
}


Measured memory_bytes: 128
a=input()
b1,b2,b3=0,0,0
if a[0]=='9':
    b1='1'
else:
    b1='9'
if a[1]=='9':
    b2='1'
else:
    b2='9'
if a[2]=='9':
    b3='1'
else:
    b3='9'
print(b1+b2+b3)

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

using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


int main() {

	int N,K;
	cin >> N >> K;
	vector<int> a(N,0);
	rep(i,N){
		cin >> a[i];
	}

	sort(all(a));
	vector<int> rui(N-K+1,0);
	rep(i,N-K+1){
		rui[i]=a[i+K-1]-a[i];
	}
	//sort(all(rui));
	//debug(rui);
	int ans=*min_element(all(rui));
	p(ans);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int x,a,b;
  cin>>x>>a>>b;
  if(a>=b)cout<<"delicious"<<endl;
  else if(abs(a-b)<=x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;


return 0;

}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#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++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n ;
    cin >> a >> b >> n ;
    ll ans = 0 ;
    if(b>n){
        ans = (a*n)/b - a*(n/b) ;
    }
    else{
        ans = (a*(b-1))/b ;
    }

    
    cout << ans <<endl ;

    return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    bool isok = false;
    int X = N * 100 / 108;
    while (true) {
        int Y = X * 108 / 100;
        if (Y > N)
            break;
        if (Y == N) {
            isok = true;
            break;
        }
        X++;
    }
    if (isok)
        cout << X << endl;
    else
        cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i = 0, data[100000] ={0}, j;
	
	for(i = 0; i <= 99999; i++) {
		scanf("%d", &data[i]);
		if (data[i] == 0) {
			break;
		}
	}
	
	for (j = 0; j < i; j++) {
		printf("Case %d: %d\n", j+1, data[j]);
	}
	
	return 0;
}

Measured memory_bytes: 996
import java.io.*;
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       int    a = in.nextInt();
       String op = in.next(); 
       int    b = in.nextInt();
       int    x;
       
      
       while(!op.equals("?")){
          if(op.equals("+")){
              System.out.println(a+b);
          }
          if(op.equals("-")){
              System.out.println(a-b);
          }
          if(op.equals("*")){
              System.out.println(a*b);
          }
          if(op.equals("/")){
              System.out.println(a/b);
          }

          a = in.nextInt();
          op = in.next();
          b = in.nextInt();
       }


}
}

Measured memory_bytes: 18056
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
x,y = MI()
c = 0
for i in range(0,x+1):
  if 2*(x-i)+4*i == y:
    c = 1
if c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9164
#include <iostream>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  set<int> s;
  for (int i = 1; ; ++i) {
    if (s.find(N) != s.end()) {
      out(i);
      break;
    }
    s.insert(N);
    if (N % 2 == 0)
      N /= 2;
    else
      N = 3 * N + 1;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<functional>

using namespace std;

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

	int n,m;
	cin >> n >> m;

	if(n<=m) cout << n << "\n";
	else cout << n-1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#define N 400005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
LL c[N],w[N],col[N];
LL n,x,y,cnt;
vector<LL>a[N];
LL fac[N],ifac[N];
LL ksm(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld %lld %lld",&n,&x,&y);
	LL mminw=INF;
	int minc;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&c[i],&w[i]);
		a[c[i]].push_back(i);
		if(w[i]<mminw)
		{
			mminw=w[i];
			minc=c[i];	
		}
	}
	LL mminw1=INF;
	for(int i=1;i<=n;i++)
	{
		LL minw=INF;
		for(int j=0;j<a[i].size();j++)	
			minw=min(minw,w[a[i][j]]);
		for(int j=0;j<a[i].size();j++)
			if(w[a[i][j]]+minw<=x)
				w[a[i][j]]=minw;
		if(minc!=i)
			mminw1=min(mminw1,minw);
	}
	for(int i=1;i<=n;i++)
	{
		if(c[i]==minc)
		{
			if(w[i]+mminw1<=y)
			{
				col[c[i]]++;
				cnt++;	
			}
		}
		else if(w[i]+mminw<=y)
		{
			col[c[i]]++;
			cnt++;
		}
	}
	fac[0]=1;
	for(int i=1;i<=cnt;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[cnt]=ksm(fac[cnt],MOD-2);
	for(int i=cnt;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
	LL ans=fac[cnt];
	for(int i=1;i<=n;i++)
		ans=ans*ifac[col[i]]%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n,a,s,g;
  while(cin>>n>>a>>s>>g,n){
    using P = pair<int, string>;
    vector<vector<P> > G(n);
    vector<vector<int> > rG(n);
    for(int i=0;i<a;i++){
      int x,y;
      string c;
      cin>>x>>y>>c;
      G[x].emplace_back(y,c);
      rG[y].push_back(x);
    }
    vector<int> r(n,0);
    {
      queue<int> q;
      r[g]=1;
      q.push(g);
      while(!q.empty()){
	int v=q.front();q.pop();
	for(int u:rG[v]){
	  if(r[u]) continue;
	  r[u]=1;
	  q.push(u);
	}
      }
      if(!r[s]){
	cout<<"NO"<<endl;
	continue;
      }
    }
    using T = tuple<string, int, int>;
    string INF="{";
    vector<vector<string> > d(n,vector<string>(n*20,INF));
    priority_queue<T,vector<T>,greater<T> > q;
    d[s][0]="";
    q.emplace(d[s][0],s,0);
    while(!q.empty()){
      int v,l;
      tie(ignore,v,l)=q.top();q.pop();
      for(P p:G[v]){
	int u=p.first;
	string c=d[v][l]+p.second;
	int nl=c.length();
	if(nl>=n*20) continue;
	if(less<string>()(c,d[u][nl])){
	  d[u][nl]=c;
	  q.emplace(d[u][nl],u,nl);
	}
      }
    }
    string ans=INF;
    for(int i=0;i<n*20;i++) ans=min(ans,d[g][i]);
    if(ans==INF||(int)ans.length()>n*15) cout<<"NO"<<endl;
    else cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 23136
#include<iostream>
using namespace std;
#define ll long long

int main()
{
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n ; i++)
        cin >> a[i];
    n = n - x;
    ll c = 1;
    c = c + n / (x-1);
    if(n % (x-1) != 0)
        c++;
    cout << c <<endl;

    return 0;
}


Measured memory_bytes: 640
import numpy as np
n,m = map(int, input().split())
h = input().split() # list
for i in range(n):
    h[i] = int(h[i])
bridge = np.zeros((m,2), dtype="int")
for i in range(m):
    a,b = map(int, input().split())
    bridge[i,0] = int(a)
    bridge[i,1] = int(b)

good = [1]*n
for i in range(m):
    if h[bridge[i,0]-1] > h[bridge[i,1]-1]:
        good[bridge[i,1]-1] = 0
    elif h[bridge[i,0]-1] < h[bridge[i,1]-1]:
        good[bridge[i,0]-1] = 0
    else :
        good[bridge[i,0]-1] = 0
        good[bridge[i,1]-1] = 0
        #if good[bridge[i,0]-1] == 1 and good[bridge[i,1]-1] == 1:
        #    pass
        #elif good[bridge[i,0]-1] == 0 or good[bridge[i,1]-1] == 0:
         #   good[bridge[i,0]-1] = 0
         #   good[bridge[i,1]-1] = 0
print(sum(good))

Measured memory_bytes: 36484
import sys

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

ans = 1
lim = pow(10, 18)

if 0 in a:
    print(0)
    sys.exit()

for i in range(n):
    ans *= a[i]
    if ans > lim:
        print(-1)
        sys.exit()
    
print(ans)

Measured memory_bytes: 21784
train = []
for i in range(2):
    train.append(int(input()))
bus = []
for i in range(2):
    bus.append(int(input()))

trainAns = train[0]
for i in range(2):
	if train[i] < trainAns:
		trainAns = train[i]
busAns = bus[0]
for i in range(2):
	if bus[i] < busAns:
		busAns = bus[i]


print(trainAns  + busAns)

Measured memory_bytes: 3064
// Problem E

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 300000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int N, K, C;
char s[MAXN];
ii suffissi[MAXN], prefissi[MAXN]; // numero di giorni lavorati, numero di giorni di vacanza dopo/prima dell'ultimo lavorato

int main() {
  cin >> N >> K >> C;
  cin >> s;
  
  // prefissi
  if (s[0] == 'x') prefissi[0]=mp(0, C);
  else prefissi[0] = mp(1, 0);
  for (int i=1; i<N; i++) {
    if (s[i] == 'o' && prefissi[i-1].second >= C) prefissi[i] = mp(prefissi[i-1].first+1, 0);
    else prefissi[i] = mp(prefissi[i-1].first, prefissi[i-1].second+1); // vacanza obbligata
  }
  
  // suffissi
  if (s[N-1] == 'x') suffissi[N-1] = mp(0, C);
  else suffissi[N-1] = mp(1, 0);
  for (int i=N-2; i>=0; i--) {
    if (s[i] == 'o' && suffissi[i+1].second >= C) suffissi[i] = mp(suffissi[i+1].first+1, 0);
    else suffissi[i] = mp(suffissi[i+1].first, suffissi[i+1].second+1); // vacanza obbligata
  }
  
  if (N == 1) {
    cout << "1" << endl;
    return 0;
  }
  
  if (suffissi[1].first < K) cout << "1" << endl;
  for (int i=1; i<N-1; i++)
    if (!(prefissi[i-1].first + suffissi[i+1].first > K || (prefissi[i-1].first + suffissi[i+1].first == K && 1+prefissi[i-1].second+suffissi[i+1].second >= C)))
      cout << i+1 << endl;
  if (prefissi[N-2].first < K) cout << N << endl;
  
  assert(prefissi[N-1].first >= K);
  assert(suffissi[0].first >= K);
  
  return 0;
}


Measured memory_bytes: 6964
#include <iostream>
#include <stdio.h>
using namespace std;

void houteisiki(double a, double b, double c, double d, double e, double f)
{
	double x, y;
    y = (c*d - a*f) / (b*d - a*e);
    x = (c - (b*y)) / a;
   
    printf("%4.3f %4.3f\n",x,y);
}

int main()
{
	double a, b, c, d, e, f;

	while(cin >> a >> b >> c >> d >> e >> f)
		houteisiki(a, b, c, d, e, f);

	return 0;
}

Measured memory_bytes: 3068
#!/usr/bin/env python3
import sys
import numpy as np


def solve(S: str, T: str):
    ans = 0
    for i in range(len(S)):
        if S[i]!=T[i]:
            ans += 1

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27372
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long  x, y, a, b, c;

  cin >> x >> y >> a >> b >> c;

  vector<long long> p(a);
  vector<long long> q(b);
  vector<long long> r(c);
  vector<pair<long long,long long>> al(a+b+c);
  for(int i = 0; i < a; i++){
    cin >> p[i];
  }
  for(int i = 0; i < b; i++){
    cin >> q[i];
  }
  for(int i = 0; i < c; i++){
    cin >> r[i];
  }

  for(int i = 0; i < (a+b+c); i++){
    if( i < a ){
      al[i] = make_pair(p[i], 1);
    }else if(a<=i && i < (a+b)){
      al[i] = make_pair(q[i-a], 2);
    }else if((a+b)<=i && i < (a+b+c)){
      al[i] = make_pair(r[i-(a+b)], 3);
    }
  }
  sort(al.begin(), al.end());
  reverse(al.begin(), al.end());
  
  long long ans = 0;
  long long tx = 0;
  long long ty = 0;
  long long tz = 0;
  long long xyz = x+y;

  for(int i = 0; i < (a+b+c); i++){
    // cout << i << "th first = " << al[i].first << ", second = "<< al[i].second << endl;
 
    if(al[i].second == 1){
      if(tx >= x){
        // cout << "x max" << endl;
        continue;
      }
      tx++;
      ans += al[i].first;
      // cout << "x = " << tx << ", ans = " << ans << endl;
    }

    if(al[i].second == 2){
      if(ty >= y){
        // cout << "y max" << endl;
        continue;
      }
      ty++;
      ans += al[i].first;
      // cout << "y = " << ty << ", ans = " << ans << endl;
   }

    if(al[i].second == 3){
      tz++;
      ans += al[i].first;
      // cout << "z = " << tz << ", ans = " << ans << endl;
    }

    if((tx+ty+tz) == xyz){
      break;
    }
  }

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


Measured memory_bytes: 7296
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  l=[LI() for _ in range(h)]

  ans=[]
  for i in range(h):
    for j in range(w):
      if l[i][j]%2!=0:
        if j!=w-1:
          l[i][j+1]+=1
          ans.append([i+1,j+1,i+1,j+2])
        elif i!=h-1:
          l[i+1][j]+=1
          ans.append([i+1,j+1,i+2,j+1])

  print(len(ans))
  for x in ans:
    print(x[0],x[1],x[2],x[3])

main()
# print(main())


Measured memory_bytes: 32656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
long calc(long x,long y){
	long z = ((x - 1) * x * (x + 1) / 6) % mod;
	return (z * y * y) % mod;
}
long modfact(long n,long p){//n! mod p
    if(n >= p) return 0;
    long res = 1;
    rep(i,1,n+1) (res *= i) %= p;
    return res;
}
long modperm(long n,long r,long p){//nPr mod p
    if( n-r >= p || r%p > n%p) return 0;
    long res = 1;
    rep(i,n-r+1,n+1) (res*=i) %= p;
    return res;
}
long modcomb(long n,long r,long p){//nCr mod p
    long x = modfact(max(n-r,r),p);
    long y = modperm(n,max(n-r,r),p);
	int i = 0;
	while( (p-2) >= (1<<i) ){
		if( (p-2) & (1<<i) ) (y*=x)%=p;
		i++; x = x * x % p;
	}
	return y;
}
long modpow(long x,int n,long p){
	int i = 0;long res = 1;
	while(n >= (1<<i)){
		if(n & (1<<i)) (res *= x) %= p;
		i++;
		x = (x * x) % p;
	}return res;
}
int main(){
	long N,M,K;cin>>N>>M>>K;
	long res = (calc(N, M) + calc(M, N)) % mod;
	(res *= modperm(N * M - 2, K - 2, mod)) %= mod;
	(res *= ((K - 1) * K) % mod) %= mod;
    (res *= modpow(modfact(K, mod), mod-2, mod)) %= mod;
	cout<<res<<endl;
}

Measured memory_bytes: 256
/*  ex3_2
    Rikuta  */

#include <stdio.h>

int main(void){

    int number,ones_place;
    //input number
    scanf("%d",&number);
    //computing ones_place
    ones_place = number%10;
    //ones_placeの値によって分岐してそれぞれで読み方を出力
    switch (ones_place)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    case 3:
        printf("bon\n");
        break;
    //デフォルトの指示としてswitch文からの脱出
    default:
        break;
    }

    return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll k; cin>>k;
ll m = k;
if(k<=50){
cout << 4 << endl;
ll n = m/4;
ll h = m%4;
ll g = 3;
rep(i,h){
cout << n + g + 1   << " ";
g--;
}
repl(i,h,4){
cout << n + g << " ";
g--;
}
}
else{
cout << 50 << endl;
ll n = m/50;
ll h = m%50;
ll g = 50;
rep(i,h){
cout << n + g  << " ";
g--;
}
repl(i,h,50){
cout << n + g - 1 << " ";
g--;
}
}
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define nl '\n'
#define vi vector<long int>
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define int long int
using namespace std;

signed main(){
    ios;
    int n;
    cin>>n;
    vector<vector<long int>> vec(n);
    int x;
    for(int i=0;i<n;i++) {
        cin>>x;
        vec[i].push_back(x);
        cin>>x;
        vec[i].push_back(x);
        cin>>x;
        vec[i].push_back(x);
    }
//    cout<<"vir"<<nl;
    vi c1(n),c2(n),c3(n);
    c1[n-1]=vec[n-1][0];
    c2[n-1]=vec[n-1][1];
    c3[n-1]=vec[n-1][2];
    for(int i=n-2;i>=0;i--){
//        cout<<"vir"<<nl;
        c1[i]=vec[i][0]+max(c2[i+1],c3[i+1]);
        c2[i]=vec[i][1]+max(c1[i+1],c3[i+1]);
        c3[i]=vec[i][2]+max(c2[i+1],c1[i+1]);
    }
    cout<<max(c1[0],max(c2[0],c3[0]));
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int Alice = 0;
  int Bob = 0;

  
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      Alice += a.at(i);
    }else{
      Bob += a.at(i);
    }
  }
  
  int ans = Alice - Bob;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 1e3 + 10;
const int inf = 0x3f3f3f3f;

char s[maxN][maxN];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int f[maxN][maxN];
int n, m;
int a, b, x, y;

bool ok(int i, int j) {
  return (i > 0 && j > 0 && i <= n && j <= m && s[i][j] != '#');
}

struct abc {
  int vtime, u, v;
  abc(int _vt = 0, int _u = 0, int _v = 0) : vtime(_vt), u(_u), v(_v) {}
  bool operator < (const abc &op) const {
    return vtime > op.vtime;
  }
};

int main(){
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> m;
  cin >> a >> b;
  cin >> x >> y;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      cin >> s[i][j];
  priority_queue< abc > dq;
  dq.push(abc(0, a, b));
  memset(f, inf, sizeof f);
  f[a][b] = 0;
  while (!dq.empty()) {
    abc tp = dq.top(); dq.pop();
    int vtime = tp.vtime, u = tp.u, v = tp.v;
    if (f[u][v] < vtime) continue;
    for (int id = 0; id < 4; ++id) {
      int l = u + dx[id], r = v + dy[id];
      if (ok(l, r)) {
        if (f[l][r] > f[u][v]) {
          f[l][r] = f[u][v];
          dq.push(abc(f[l][r], l, r));
        }
      }
    }
    for (int i = -2; i <= 2; ++i)
    for (int j = -2; j <= 2; ++j) {
        int l = u + i, r = v + j;
        if (ok(l, r)) {
          if (f[l][r] > f[u][v] + 1) {
            f[l][r] = f[u][v] + 1;
            dq.push(abc(f[l][r], l, r));
          }
        }
    }
  }
  cout << (f[x][y] == inf ? -1 : f[x][y]) << '\n';
return 0;
}


Measured memory_bytes: 8656
object Main extends App {
  val Array(a, b) = scala.io.StdIn.readLine.split(" ")
  val ab = (a + b).toInt

  import scala.math.sqrt

  val sq = sqrt(ab).toInt

  if (sq * sq == ab) {
    println("Yes")
  } else {
    println("No")
  }
}


Measured memory_bytes: 54692
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll h,n;
cin>>h>>n;
vector<int> A(n);
ll total=0;
rep(i,n){
    cin>>A[i];
    total+=A[i];
}
string ans="No";
if(total>=h){
    ans="Yes";
}
cout<<ans<<endl;
//system("pause");
return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;

  ll M=max(X,Y);
  ll Min=INF;
  for(ll i=0;i<=M;i++){
    ll a=max(0LL,X-i);
    ll b=max(0LL,Y-i);
    ll AA=a*A;
    ll BB=b*B;
    ll MM=i*C*2;
    ll sum=AA+BB+MM;
    Min=min(Min,sum);
  }
  cout<<Min<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    ans=1
    
    for i in range(N):
        ans=ans*A[i]
        if ans>pow(10,18):
            ans=-1
            break
        
    if 0 in A:
        ans=0
        
    print(ans)

main()


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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#define SPEC(name) CONCAT(name, __LINE__)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
#define clog cerr << string(__db_level * 2, ' ')
struct debug_block {
    string msg;
    debug_block(const string& s): msg(s) { clog << "{ " << msg << endl; ++__db_level; }
    ~debug_block() { --__db_level; clog << "} " << msg << endl; }
};
#define DB(args...) stringstream SPEC(ss); SPEC(ss)<< args; debug_block SPEC(dbbl)(SPEC(ss).str())
#else
#define clog if (0) cerr
#define DB(...)
#endif
#define db(val) "[" #val " = " << val << "]; "
template<class U, class V> ostream& operator<<(ostream& out, const pair<U, V>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")";
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup);
}
template<class ...U>
ostream& operator<<(ostream& out, const tuple<U...>& tup) { return print_tuple_utils<0, tuple<U...>>(out, tup); }
template<class, typename = void> struct has_const_iterator : false_type {};
template<class T> struct has_const_iterator<T, void_t<typename T::const_iterator>> : true_type {};
template<class T>
typename enable_if<has_const_iterator<T>::value && !is_same<T, string>::value, ostream&>::type
operator<<(ostream& out, const T& container) { 
    auto beg = container.begin(), end = container.end();
    out << "(" << container.size() << ") {";
    if (beg != end) out << *(beg++);
    while (beg != end) out << ", " << *(beg++);
    return out << "}";
}
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////


int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << !x;

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker



Measured memory_bytes: 3620
h, w = map(int, input().split())
s = []
s.append(["."] * (w + 1))
for i in range(h):
    s.append(["."] + list(input()))
s2 = []
for i in range(h + 1):
    s2.append([0] * (w + 1))

for i in range(w - 1):
    if s[1][i + 1] == "#":
        if s[1][i] != "#":
            s2[0][i + 2] = s2[0][i + 1] + 1
        else:
            s2[0][i + 2] = s2[0][i + 1]
    else:
        s2[0][i + 2] = s2[0][i + 1]
for i in range(h - 1):
    if s[i + 1][1] == "#":
        if s[i][1] != "#":
            s2[i + 2][0] = s2[i + 1][0] + 1
        else:
            s2[i + 2][0] = s2[i + 1][0]
    else:
        s2[i + 2][0] = s2[i + 1][0]

for i in range(h):
    for j in range(w):
        if s[i + 1][j + 1] == ".":
            s2[i + 1][j + 1] = min(s2[i][j + 1], s2[i + 1][j])
        else:
            if s[i][j + 1] == "#":
                if s[i + 1][j] == "#":
                    s2[i + 1][j + 1] = min(s2[i][j + 1], s2[i + 1][j])
                else:
                    s2[i + 1][j + 1] = min(s2[i][j + 1], s2[i + 1][j] + 1)
            else:
                if s[i + 1][j] == "#":
                    s2[i + 1][j + 1] = min(s2[i][j + 1] + 1, s2[i + 1][j])
                else:
                    s2[i + 1][j + 1] = min(s2[i][j + 1], s2[i + 1][j]) + 1
print(s2[h][w])

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>  P(N);
    rep(i, N) cin >> P[i];
    int ans = 0;
    int tempmin = 1e7;
    rep(i, N) {
        tempmin = min(tempmin, P[i]);
        if (tempmin == P[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

int n;
long long ans;
long long a[MAXN];
map<long long, long long> mp;
set<long long> st;

inline long long anti(long long x) {
	for (long long i = 2; i <= 2500; i++){
		long long c = i * i * i;
		if(x < c) 
            return x;
		while(x % c == 0) 
            x /= c;
	}
	return x;
}

int main(void) {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) 
        cin >> a[i];
	for(int i = 1; i <= n; i++) {
        a[i] = anti(a[i]);
        mp[a[i]]++;
    }
	
    for (auto y: mp) {
        if (y.ff == 1) {
            ans++;
            continue;
        }
        if (st.count(y.ff))
            continue;
        long long tmp = anti(y.ff * y.ff);
        ans += max(y.ss, mp[tmp]);
        st.insert(tmp);
    }

	cout << ans << '\n';
	return 0;
}



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

int main() {
int n;
long long m,p=1000000007;
string s,t;
bool q;
cin>>n>>s>>t;
for(int i=0;i<n;i++){
    if(s[i]==t[i]){
        if(i==0){
            m=3;
        }else if(q){
            m=(m*2)%p;
        }
        q=true;
    }else{
        if(i==0){
            m=6;
        }else if(q){
            m=(m*2)%p;
        }else{
            m=(m*3)%p;
        }
        
        
        q=false;
        i++;
    }
}
cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long a, b, c, k;
    long max = 1;
    int i = 0;
    unsigned long ulk = 0;
    char input[64];

    long ans;

    for (i = 0; i < 18; i++){
        max *= 10;
    }

    fgets(input, 64, stdin);
    sscanf(input, "%lu %lu %lu %lu\n", &a, &b, &c, &k);

    if (k % 2 == 0){
        ans = a - b;
    }
    else{
        ans = b - a;
    }

    if (ans < -1 && ans * -1 > max || ans > max){
        printf("Unfair\n");
    }
    else{
        printf("%ld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;
int maxh;

int main() {
  int n, i, x;
  char com[20];

  scanf("%d", &n);
  maxh = 0;

  for(i = 0 ; i < n ; i++) {
    scanf("%s", com);
    if (strcmp(com, "insert") == 0) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp(com, "print") == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

int insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL) {
    root = z;
  }
  else {
    if(z->key < y->key) {
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

int inorder(Node x) {
  if(x == NIL) return 0;
  inorder(x->left);
  printf(" %d", x->key);
  inorder(x->right);
}
int preorder(Node x) {
  if (x == NIL) return 0;
  printf(" %d", x->key);
  preorder(x->left);
  preorder(x->right);
}    



Measured memory_bytes: 25128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int N, K;
  cin >> N >> K;
  cout << N - K + 1 << endl;

  return 0;
}


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

int main(){
  
  int a, s1=0, s2=0;

  for(int i=0;i<8;i++){
    cin>>a;
    if(i<4) s1+=a;
    else s2+=a;
  }

  cout<<max(s1, s2)<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3088
N, M = map(int, input().split())
A = list(map(int, input().split()))
num = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [0]*(N+1)
INF = -float('inf')

for i in range(1, N+1):
    dp[i] = max([dp[i-num[j]] if i - num[j] >= 0 else INF for j in A]) + 1

A.sort(reverse = True)
ans = ''
tmp = N
while tmp > 0:
    for a in A:
        if tmp-num[a] >=0:
            if dp[tmp-num[a]] == dp[tmp] - 1:
                break
    ans += str(a)
    tmp -= num[a]
    
print(ans)    

Measured memory_bytes: 3316