akhauriyash/Code-Regression huggingface dataset:
N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u,v,w = map(int,input().split())
    w = w%2
    G[u-1].append((v,w))
    G[v-1].append((u,w))
ans = [ -1 for i in range(N)]
ans[0] = 0
stack = [1]

while len(stack) > 0:
    x = stack.pop()
    p = ans[x-1]
    g = len(G[x-1])
    for i in range(g):
        y = G[x-1][i][0]
        z = G[x-1][i][1]
        a = ans[y-1]
        if a == -1:
            stack.append(y)
            if z == 0:
                ans[y-1] = p
            else:
                ans[y-1] = 1-p
for i in range(N):
    print(ans[i])

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

using namespace std;

typedef long long ll;

int main(int argc, const char *argv[]) {
  set<vector<ll>> se;
  vector<ll> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
    if (a[i] & 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  sort(a.begin(), a.end());
  se.insert(a);
  int cnt = 1;
  while (true) {
    ll sum = 0;
    for (auto x : a) {
      sum += x/2;
    }
    vector<ll> b(3);
    for (int i = 0; i < 3; i++) {
      b[i] = sum - a[i] / 2;
      if (b[i] & 1) {
        cout << cnt << endl;
        return 0;
      }
    }
    sort(b.begin(), b.end());
    if (se.count(b)) {
      cout << -1 << endl;
      return 0;
    }
    cnt++;
    se.insert(b);
    a = b;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s; getline(cin,s);
  rep(i,0,s.size()){
    if(65<=s[i] && s[i]<=90) s[i]+=32;
    else if(97<=s[i] && s[i]<=122) s[i]-=32;
  }
  co(s);
  return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
bool dat[100000];
int now[100000];
int main()
{
	int num,query;
	scanf("%d%d",&num,&query);
	fill(dat,dat+num,false);
	fill(now,now+num,1);
	dat[0]=true;
	for(int i=0;i<query;i++)
	{
		int za,zb;
		scanf("%d%d",&za,&zb);
		za--;
		zb--;
		dat[zb]|=dat[za];
		now[za]--;
		now[zb]++;
		if(now[za]==0)dat[za]=false;
	}
	int c=0;
	for(int i=0;i<num;i++)c+=dat[i];
	printf("%d\n",c);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pb                  push_back
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int r,g,b;cin>>r>>g>>b;
    int k;cin>>k;

    int cr,cg,cb;
    cr=2*r,cg=2*g,cb=2*b;

    while(g<=r){
        g*=2;
        ans++;
    }

    while(b<=g){
        b*=2;
        ans++;
    }
    // cout<<b<<" "<<g<<" "<<r<<endl;
    if(ans<=k)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<fixed<<setprecision(3)<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3800
x = int(input())
cnt = 0
if x>11:
    cnt += 2*(x//11)
    x %= 11

while True:
    if x<=0:
        break
    x -= 6
    cnt += 1
    if x <= 0:
        break
    x -= 5
    cnt += 1
    if x<=0:
        break
print(cnt)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int main(){
  int x,c=0;
for(int j=0; j<10000; j++){
    cin>>x;
    c++;
 
    if(x==0){
      break;
    }
  

    
    cout<<"Case"<<" "<<c<<":"<<" "<<x<<"\n";
    
    
  

  }
  return 0;
}



Measured memory_bytes: 3088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
        rep(i,n) a[i] %=k;
    vector<int> sum(n,0);
    sum[0]=a[0];
    rep(i,n-1) sum[i+1]=(a[i+1]+sum[i])%k;
    rep(i,n){
        sum[i]=(i+1)-sum[i]+k;
        sum[i] %= k;
    }
    unordered_map<int,in> x;
    rep(i,min(n,k-1)) x[sum[i]] ++;
    int key=0;
    in ans=0;
    rep(i,n){
        ans += x[key];
        key ++;
        key -= a[i];
        key += k;
        key %= k;
        x[sum[i]] --;
        if(i+k<=n) x[sum[i+k-1]] ++;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 12912
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a[200005],ans;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
    }
    sort(a,a+n+1);
    for(int i=0;i<=n-k;i++)
    ans+=a[i];
    cout<<ans;
	//system("pause");
	return 0;
}
//1 1 1 2 2 3 3 4 4 5

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x[] = new int[4];
            int y[] = new int[4];
            for (int i = 0; i < 2; i++) {
                x[i] = Integer.parseInt(in.next());
                y[i] = Integer.parseInt(in.next());
            }

            int xx = x[1] - x[0];
            int yy = y[1] - y[0];

            out.printf("%d %d %d %d\n", x[1] - yy, y[1] + xx, x[0] - yy, y[0] + xx);

        }

    }
}



Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;

int main(void) {
	int x, a, b;
	cin >> x >> a >> b;
	int c = abs(x - a);
	int d = abs(x - b);
	if (c >= d) {
		cout << "B" << endl;
	}
	else cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

INF = 10**9
dst = [[INF]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw)])
while dq:
    h, w = dq.popleft()

    for dh in range(-2, 3):
        for dw in range(-2, 3): # [dh,dw]:[-2,-2]~[2,2]
            nh = h + dh; nw = w + dw
            if dh*dh + dw*dw == 1:
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] < dst[nh][nw]:
                    dst[nh][nw] = dst[h][w]
                    dq.appendleft((nh, nw))
            elif dh*dh + dw*dw > 1:
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] + 1 < dst[nh][nw]:
                    dst[nh][nw] = dst[h][w] + 1
                    dq.append((nh, nw))

print(-1 if dst[eh][ew]==INF else dst[eh][ew])


Measured memory_bytes: 90836
// atcoder/abc155/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  str s;
  while (cin >> s) {
    vector<int> v(s.begin(), s.end());
    each (i, v) i -= '0';
    reverse(v.begin(), v.end());

    const int N = 1e6 + 5;
    const int M = 2;
    static lli dp[N][M];
    const lli inf = 1LL << 60;
    fill(&dp[0][0], &dp[N - 1][M - 1] + 1, inf);
    dp[0][false] = 0;

    for (int i = 0; i < v.size(); ++i) {
      {
        setmin(dp[i + 1][true],  dp[i][false] + (10 - v[i]));
        setmin(dp[i + 1][false], dp[i][false] + v[i]);
      }
      {
        setmin(dp[i + 1][true],  dp[i][true] + (10 - v[i] - 1));
        setmin(dp[i + 1][false], dp[i][true] + v[i] + 1);
      }
    }

    cout << min(dp[s.size()][0], dp[s.size()][1] + 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 20892
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>
#include <limits.h>

using namespace std;

// Used to track farthest node. 
int x;

// Sets maxCount as maximum distance from node. 
void dfsUtil(int node, int count, bool visited[],
	int& maxCount, list<int>* adj)
{
	visited[node] = true;
	count++;
	for (auto i = adj[node].begin(); i != adj[node].end(); ++i) {
		if (!visited[*i]) {
			if (count >= maxCount) {
				maxCount = count;
				x = *i;
			}
			dfsUtil(*i, count, visited, maxCount, adj);
		}
	}
}

// The function to do DFS traversal. It uses recursive 
// dfsUtil() 
void dfs(int node, int n, list<int>* adj, int& maxCount)
{
	bool visited[n + 1];
	int count = 0;

	// Mark all the vertices as not visited 
	for (int i = 1; i <= n; ++i)
		visited[i] = false;

	// Increment count by 1 for visited node 
	dfsUtil(node, count + 1, visited, maxCount, adj);
}

// Returns diameter of binary tree represented 
// as adjacency list. 
int diameter(list<int>* adj, int n)
{
	int maxCount = INT_MIN;

	/* DFS from a random node and then see
	farthest node X from it*/
	dfs(1, n, adj, maxCount);

	/* DFS from X and check the farthest node
	from it */
	dfs(x, n, adj, maxCount);

	return maxCount;
}

int main() {
	int n, i, j, c[555], flag[555], flag2 =0,ans,flag3,min=555,k;
	char a[555][555];
	cin >> n;
	ans = n;
	for (i = 0; i < n; i++)
		cin >> a[i];
	for (i = 0; i < n; i++) {
		c[i] = 0;
		flag[i] = 0;
	}
	for (j = 0; j < n; j++) {
		flag3 = 1;
		for (i = 0; i < n; i++) {
			if (a[i][j] == '#') {
				c[i]++;
				flag[j] = 1;
				flag2 = 1;
			}
			else
				flag3 = 0;
		}
		if (flag3 == 1)
			ans--;
	}
	if (flag2 == 0) {
		cout << "-1" << endl;
		return 0;
	}
	for (i = 0; i < n; i++) {
		k = n - c[i];
		if (flag[i] == 0)
			k++;
		if (k < min)
			min = k;
	}
	ans += min;
	cout << ans << endl;
}


Measured memory_bytes: 640
import numpy as np

XN=np.array(input().split(" "),dtype=np.int32)
X=XN[0]
N=XN[1]

if(N==0):
    print(X)
else:
    p=np.array(input().split(" "),dtype=np.int32)
    p=np.sort(p)
    ABS=0
    results=[]
    length=0
    while(True):
        upper=X+ABS
        lower=X-ABS
        
        if(upper in p):
            pass
        else:
            results.append(upper)
            length+=1
        if(lower in p):
            pass
        else:
            results.append(lower)
            length+=1
        
        if(length>0):
            break
        ABS+=1
    print(min(results))

Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;;
#define fori(i,a,b) for(int i=a;i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}

void solve(){
    int n,m;
    vector<int> g[100005];
    cin>>n>>m;
    vector<int> cnt(n,0);
    repi(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
        cnt[y]++;
    }

    queue<int> q;
    repi(i,n)if(!cnt[i])q.push(i);
    vector<int> dp(n,0);
    while(!q.empty()){
        int from=q.front();
        q.pop();
        for(int to:g[from]){
            if(cnt[to]>0){
                chmax(dp[to],dp[from]+1);
                cnt[to]--;
                if(cnt[to]==0)q.push(to);
            }
        }
    }

    int ans=0;
    repi(i,n)chmax(ans,dp[i]);
    cout<<ans<<endl;
}

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


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

using namespace std;

int main(void){

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

    int ans = 0;

    for(int i = 0;i < a.length();i++){
        if(a[i] != b[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   int ans = 1;
   while(ans <= n)
      ans*=2;
   cout << ans/2 << nl;



   return 0;
}


Measured memory_bytes: 3576
N=int(input())
a=[]
count=0
ischecked=[0]*N
q=[0]
for i in range(N):
    a.append(int(input())-1)
while q:
    now=q.pop()
    count+=1
    nex=a[now]
    if nex==1:
        print(count)
    elif ischecked[now]==1:
        print(-1)
    else:
        ischecked[now]=1
        q.append(nex)

Measured memory_bytes: 7852
s = input()
s = list(s)

flag = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] == 'L':
        flag += 1
    elif i % 2 == 1 and s[i] == 'R':
        flag += 1

if flag > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n][m];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  int sumc[m];
  for(int i = 0; i < m; i++) sumc[i] = 0;
  int sum = 0;
  for(int i = 0; i < n; i++){
    int sumr = 0;
    for(int j = 0; j < m; j++){
      printf("%d ", a[i][j]);
      sumr += a[i][j];
      sumc[j] += a[i][j];
      sum += a[i][j];
    }
    printf("%d\n", sumr);
  }
  for(int i = 0; i < m; i++) printf("%d ", sumc[i]);
  printf("%d\n", sum);
}


Measured memory_bytes: 2752
#include<stdio.h>
int main(void){
    int c,i,b,card[4][13]={0};
    char a;
    scanf("%d",&c);
    for(i=0;i<=c*2;i++){
        scanf("%c %d",&a,&b);
        switch(a){
            case 'S':
                card[0][b-1]=b;
                break;
            case 'H':
                card[1][b-1]=b;
                break;
            case 'C':
                card[2][b-1]=b;
                break;
            case 'D':
                card[3][b-1]=b;
                break;
        }
    }
    for(i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(card[i][j-1]==0){
                switch(i){
                    case 0:
                        printf("S %d\n",j);
                        break;
                    case 1:
                        printf("H %d\n",j);
                        break;
                    case 2:
                        printf("C %d\n",j);
                        break;
                    case 3:
                        printf("D %d\n",j);
                        break;
                }
            }
        }
    }
    return 0;
}


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

int formula(string const& s, int P, int Q, int R, int& p) {
    if(s[p] == 'P') {
        p++;
        return P;
    } else if(s[p] == 'Q') {
        p++;
        return Q;
    } else if(s[p] == 'R') {
        p++;
        return R;
    } else if('0' <= s[p] && s[p] <= '2') {
        return s[p++] - '0';
    } else if(s[p] == '-') {
        int res = formula(s, P, Q, R, ++p);
        if(res == 0) {
            return 2;
        } else if(res == 1) {
            return 1;
        } else {
            return 0;
        }
    } else { // '('
        int val = formula(s, P, Q, R, ++p);
        char op = s[p++];
        int val2 = formula(s, P, Q, R, p);
        p++;
        if(op == '*') {
            if(val == 0 || val2 == 0) {
                return 0;
            } else if(val == 1 || val2 == 1) {
                return 1;
            } else {
                return 2;
            }
        } else {
            if(val == 2 || val2 == 2) {
                return 2;
            } else if(val == 1 || val2 == 1) {
                return 1;
            } else {
                return 0;
            }
        }
    }
}


int main() {
    string s;
    while(cin >> s, s != ".") {
        int res = 0;
        for(int p=0; p<=2; ++p) {
            for(int q=0; q<=2; ++q) {
                for(int r=0; r<=2; ++r) {
                    int pos = 0;
                    if(formula(s, p, q, r, pos) == 2) {
                        res++;
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3048
N,M=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
l=1
r=N
for lr in LR:
    if l<lr[0]:
        l=lr[0]
    if lr[1]<r:
        r=lr[1]
print(max(0,r-l+1))


Measured memory_bytes: 29388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>A(N + 2, 0);
	int cnt = 0;
	rep(i, 1, N + 1) {
		int a; cin >> a;
		A[i] = a;
		cnt += abs(A[i - 1] - A[i]);
	}
	cnt += abs(A[N] - A[N + 1]);
	rep(i, 1, N + 1) {
		if (A[i - 1] <= A[i] && A[i] <= A[i + 1]) {
			cout << cnt << "\n";
		}
		else if (A[i - 1] >= A[i] && A[i] >= A[i + 1]) {
			cout << cnt << "\n";
		}
		else {
			ll x = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]);
			ll y = abs(A[i - 1] - A[i + 1]);
			cout << cnt - x + y << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  cin>>k;
  vector<int>dp(10000000);
  long long int ans=1;
  long long int mod=0;
  while(true)
  {
    long long int mod=((mod*10)+7)%k;
    if(mod==0)
    {
      cout<<ans;
      break;
    }
    else if(dp[mod])
    {
       cout<<"-1";
      break;
    }
    dp[mod]=1;
    
    ans++;
  }
  return 0;
}

Measured memory_bytes: 42280
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, m;
    cin >> n >> m;

    vi a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];


    vi c = convolution(a, b);
    rep(i, n + m - 1) cout << c[i] << (i != n + m - 2 ? " " : "\n");
}

Measured memory_bytes: 27268
/* Dedication has no limitation 
                   - Ulisses Jr.
*/
// 10 MAY  2019
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  // case1: when a is pressed twice.
  // case2: when b is pressed twice.
  // case3: when a and b each are pressed once.
  int case1 = a+a-1;
  int case2 = b+b-1;
  int case3 = a+b;
  cout << max(case1, max(case2,case3)) << endl;
  
}




 

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

int main(){
  long long A, B, N;
  cin >> N >> A >> B;
  
  long long ans = 0;
  ans += (N / (A + B)) * A;
  if(N % (A + B) - A >= 0){
    ans += A;
  }else{
    ans += N % (A + B);
  }
  
  cout << ans << endl;  
}


Measured memory_bytes: 256
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include<cstdio>
#include<ctime>
#include<cstdlib>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			std::cout << *p << ' ';
		}
		std::cout << std::endl;
	}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;

//--------------------------------------------------------


int c[30];
int s[400][30];
pii done[400][30];
int donepro[400];
int lastdone[30];



int main(){
	chrono::system_clock::time_point start, end;
	double jikan;

    start = chrono::system_clock::now();

	int d;
	cin >> d;
	rep(i,26) cin >> c[i];
	rep1(i,d)rep(j,26) cin >> s[i][j];
	//srand(time(NULL));
	//rep1(i,d) donepro[i] = rand()%26;

	rep1(dtmp,d){
		int tmp = 0;
		rep(i,26) tmp += (lastdone[i] - dtmp) * c[i];
		int maxtmp = _inf;
		int doday = 0;
		rep(i,26){
			if(maxtmp <= tmp + (dtmp-lastdone[i])*c[i] +s[dtmp][i]){
				maxtmp = tmp + (dtmp-lastdone[i])*c[i] +s[dtmp][i];
				doday = i;
			}
		}
		donepro[dtmp] = doday;
		lastdone[doday] = dtmp;
	}

	rep1(i,d) prints(donepro[i]+1);






    end = chrono::system_clock::now();

    jikan = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);



	return 0;
}




Measured memory_bytes: 3236
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,l;
    cin >> n >> l;

    ll sum = 0;
    ll absmin = INF;

    ll idx = -1;

    for(int i = 1; i <= n; i++){
        if(absmin > abs(l + i - 1) ){
            absmin = abs(l + i - 1);
            idx = i;
        }
        sum += l + i - 1;
    }

    cout << sum - (l + idx - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int M = 1e9 + 7;

int n, m;
struct Node {int x, y, z;} a[ff];
bool cmp(Node A, Node B) { return A.z < B.z;
}
void init()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d));
}
signed main()
{
	int Ts = 1;
	while(Ts--)
		init();
}

Measured memory_bytes: 3676
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
min(a,b,c,d)==min({a,b,c,d});
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll             long long int
#define endl           '\n'
#define mod            1000000007
#define fo(i,n)        for(int i=1;i<=n;i++)
#define tol(s)         transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s)         transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x)         (x).begin(), (x).end()
#define pb             push_back
#define lb             lower_bound
#define ub             upper_bound
#define tr(it, a)      for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b)       __gcd(a,b)
#define pq             priority_queue
#define fr             first
#define sc             second
#define sz(x)          x.size()

const int inf=0x3f3f3f3f;
bool ispalindrome(string s) 
{ 
    ll len=s.length(); 
    for(ll i=0;i<len;i++){ 
        if(s[i]!=s[len-i-1]) 
        return false; 
    } 
    return true; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif



int x,y;
cin>>x>>y;
for(int i=1;i<=x;i++)
{
if(((i*2+4*(x-i))==y) ||(i*4+2*(x-i)==y)){cout<<"Yes";
return 0;}
}
cout<<"No";
return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	int a[100001] = {0};
	int d = 0;
	int ans[100000] = {0};
	
	cin >> n;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for (int i = 1; i <= n; i++) {
		d += abs(a[i] - a[i - 1]);
	}
	d += abs(a[n]);
	
	for (int i = 1; i <= n; i++) {
		ans[i] += d - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i - 1] - a[i + 1]);
	}
	
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    vector<int> nums;
    int f = 0, s = 0;
    for (int i = 0; i < 3; ++i) {
        int n;
        cin >> n;
        if (n == 5) {
            f++;
        } else if (n == 7) {
            s++;
        }
    }

    cout << (f == 2 && s == 1 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import fractions


def main():
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

    C_D = (C * D) // fractions.gcd(C, D)

    z = B//C_D - A//C_D

    if A % C == 0:
        x = (B//C) - (A//C) + 1
    else:
        x = (B//C) - (A//C)

    y = B//D - A//D

    print((B-A+1)-(x+y-z))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5048
// AtCoder ABC134: B - Golden Apple
// 2019.8.26 bal4u

#include <stdio.h>
 
int main()
{
	int N, D;
	
	scanf("%d%d", &N, &D);
	printf("%d\n", (N-1)/(2*D+1)+1);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast			ios_base::sync_with_stdio(0);cin.tie(0)
#define f0(a,b,c) 		for(int a=b;a<c;a++)
#define f1(a,b,c) 		for(int a=b;a<=c;a++)
#define rev(a,b,c) 		for(int a=b;a>=c;a--)
#define trav(a,x)		for(auto &a:x)
#define ini(a,x)		memset(a,x,sizeof(a))
#define pb 				push_back
#define eb				emplace_back
#define fi 				first
#define se 				second
#define all(con) 		con.begin(),con.end()
#define ll 				long long
#define vi 				vector<int> 
#define vll 			vector<ll>
#define mod 			1000000007
#define pi 				pair<int,int>
#define pll 			pair<ll,ll>
#define mi 				map<int,int> 
#define mll				map<ll,ll>
#define umi 			unordered_map<int,int>
#define umll 			unordered_map<ll,ll>
#define lb 				lower_bound
#define ub 				upper_bound
#define pq 				priority_queue<ll,ll>
#define st				stack<int>
#define qu				queue<int>
#define endl            "\n"
#define sz(a)			(int)a.size()
using namespace std;
using ull = unsigned long long;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}
 
template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}
 
template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

ll powm(ll a , ll n)
{
	ll res = 1;
	
	while(n)
	{
		if(n & 1)
		res = (res * a);
		
		n >>= 1;
		a = (a * a);
	}
	
	return res;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

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

int main()
{
	int t=1;
	//cin>>t;
	while(t--)
	{
		int h,w;
		cin>>h>>w;
		int u,v;
		cin>>u>>v;
		u--;v--;
		int x,y;
		cin>>x>>y;
		x--,y--;
		int vis[h][w];
		memset(vis,0,sizeof(vis));
		ll dist[h][w];
		char s[h][w];
		f0(i,0,h)
		{	cin>>s[i];
			f0(j,0,w)
			{
				vis[i][j]=(s[i][j]=='#');
				dist[i][j]=1e9+5;
			}
		}
		deque<pair<int,int>> q;
		
		q.push_front({u,v});
		
		dist[u][v]=0;
		
		while(!q.empty())
		{
			pi a=q.front();
			
			q.pop_front();
			
			if(vis[a.fi][a.se])	continue;
			
			vis[a.fi][a.se]=1;
			
			ll d=dist[a.fi][a.se];
			
			f0(i,0,4)//for horizontally and vertically valid cells
			{
				int xx=a.fi+dx[i];
				int yy=a.se+dy[i];
				if(xx<0 || xx>=h || yy<0 || yy>=w)
					continue;
				if(dist[xx][yy]<=d)
					continue;
				if(vis[xx][yy])
					continue;
				dist[xx][yy]=d;
				q.push_front({xx,yy}); //important
			}
			
			f1(i,-2,2)//for elements present in the 5X5 square around the element
			{
				f1(j,-2,2)
				{
					int xx=a.fi+i;
					int yy=a.se+j;
					if(xx<0 || xx>=h || yy<0 || yy>=w)
						continue;
					if(dist[xx][yy]<=d+1)
						continue;
					if(vis[xx][yy])
						continue;
					dist[xx][yy]=d+1;
					q.push_back({xx,yy});	//important
				}
			}
			
		}
		dist[x][y]==1e9+5?cout<<-1:cout<<dist[x][y];
	}
	return 0;
}

Measured memory_bytes: 16432
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
#define forv(v,u) for (auto &v: u)
using namespace std;
const int maxn = 1e5+100;
vector<int> ke[maxn];
int f[maxn],dd[maxn];
int n,m,x,y;
int kq=0;
void dfs(int s)
{
    if (dd[s]==1) return;
    dd[s] = 1;
    forv(v,ke[s])
    {
        dfs(v);
        f[s] = max(f[s],f[v] + 1);
    }
}

int main()
{
    //freopen("task.inp","r",stdin);
    cin>>n>>m;
    // directed graph
    fori(i,1,m)
    {
        cin>>x>>y;
        ke[x].push_back(y);

    }
    fori(i,1,n)
    {
        if (dd[i]==0) dfs(i);
    }
    fori(i,1,n) kq = max(f[i],kq);
    cout<<kq;
}



Measured memory_bytes: 7808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;                       
typedef long long ll;
  ll a[100005];
  ll b[100005];
  int main()
  { ll n,m,sum=0,t,t1;
    cin>>n>>m;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(int i=1;i<=n;i++)
     cin>>a[i];
     for(int i=1;i<=m;i++)
     { cin>>t>>t1;
       if(a[t1]>a[t])
          b[t]=1;
        else if(a[t1]==a[t])
         {  b[t]=1;
            b[t1]=1;
		 }
		 else
        b[t1]=1;
       
       
	 }
	 for(int i=1;i<=n;i++)
	  { if(b[i]==0)
	     sum++;
	  }
	  cout<<sum<<endl;
	 
  }

Measured memory_bytes: 5156
#include <bits/stdc++.h>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define mp std::make_pair
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
#define Yes std::cout << "Yes" << std::endl
#define No std::cout << "No" << std::endl
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
unsigned long long modpow(int x__, int n__,  long long mod__);
template <typename T> void debug(const T& t);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    debug(modpow(10, 3, mod));
    int n;
    cin >> n;
    ll ans = modpow(10, n, mod) - modpow(9, n, mod) - modpow(9, n, mod) + modpow(8, n, mod);
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}

unsigned long long modpow(int x__, int n__, long long mod__)
{
    long long ret__ = 1;
    for (long long i__ = 0; i__ < n__; ++i__) {
        ret__ = ret__ * x__ % mod__;
    }
    return ret__;
}

template <typename T> void debug(const T& t)
{
#ifdef local
    dbg(t);
#endif
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int inf = 1e9;
int dp[maxn], h[maxn];
int main()
{
   int n;
   cin >> n;
   for(int i=0;i<n;i++)cin >> h[i],dp[i]=inf;
   dp[0] = 0;
   for(int i=0;i<n;i++){
      for(int j=i+1;j<=i+2;j++){
         if(j<n)dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
      }
   }  
   cout << dp[n-1] << endl;
   return 0;
}
/*
4
0 1 2 3
10 30 40 20

*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,x,m;
set<int> hs;
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",&x);
		hs.insert(x);
	}
	m=SZ(hs);
	if (m%2==0) --m;
	printf("%d\n",m);
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S, T;
int nex[MAX_N][26]; //1 indexed!!

void solve() {
	cin >> S >> T;
	N = sz(S);
	S += S;
	rep(i, 0, 26) nex[2 * N][i] = -1;
	rer(i, N * 2, 0) {
		rep(j, 0, 26) {
			nex[i][j] = nex[i + 1][j];
		}
		nex[i][S[i] - 'a'] = i;
	}

	ll res = 0;
	int at = N - 1;
	rep(i, 0, sz(T)) {
		int v = nex[at + 1][T[i] - 'a'];
		if(v == -1) {
			cout << -1 << "\n";
			return;
		}
		else {
			res += v - at;
			at = v % N;
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main()
{
    int a,b,c,d,m;
    scanf("%d",&m);
    d=m%10;m/=10;c=m%10;m/=10;b=m%10;m/=10;a=m%10;
    while(1)
    {
    if(a+b+c+d==7){printf("%d+%d+%d+%d=7\n",a,b,c,d);break;}
    if(a+b+c-d==7){printf("%d+%d+%d-%d=7\n",a,b,c,d);break;}
    if(a+b-c+d==7){printf("%d+%d-%d+%d=7\n",a,b,c,d);break;}
    if(a+b-c-d==7){printf("%d+%d-%d-%d=7\n",a,b,c,d);break;}
    if(a-b+c+d==7){printf("%d-%d+%d+%d=7\n",a,b,c,d);break;}
    if(a-b+c-d==7){printf("%d-%d+%d-%d=7\n",a,b,c,d);break;}
    if(a-b-c+d==7){printf("%d-%d-%d+%d=7\n",a,b,c,d);break;}
    if(a-b-c-d==7){printf("%d-%d-%d-%d=7\n",a,b,c,d);break;}
    if(-a+b+c+d==7){printf("-%d+%d+%d+%d=7\n",a,b,c,d);break;}
    if(-a+b+c-d==7){printf("-%d+%d+%d-%d=7\n",a,b,c,d);break;}
    if(-a+b-c+d==7){printf("-%d+%d-%d+%d=7\n",a,b,c,d);break;}
    if(-a+b-c-d==7){printf("-%d+%d-%d-%d=7\n",a,b,c,d);break;}
    if(-a-b+c+d==7){printf("-%d-%d+%d+%d=7\n",a,b,c,d);break;}
    if(-a-b+c-d==7){printf("-%d-%d+%d-%d=7\n",a,b,c,d);break;}
    if(-a-b-c+d==7){printf("-%d-%d-%d+%d=7\n",a,b,c,d);break;}
    if(-a-b-c-d==7){printf("-%d-%d-%d-%d=7\n",a,b,c,d);break;}
    }
    return 0;
}


Measured memory_bytes: 128