akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b&&a!=0&&b!=0){
		int c[a][b],dp[a][b];
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				c[i][j]=1;dp[i][j]=0;
			}
		}
		int d;
		cin>>d;
		for(int i=0;i<d;i++){
			int e,f;
			cin>>e>>f;
			c[e-1][f-1]=0;
		}
		for(int i=0;i<a;i++){if(c[i][0]==1)dp[i][0]=1;if(c[i][0]==0)break;}
		for(int i=0;i<b;i++){if(c[0][i]==1)dp[0][i]=1;if(c[0][i]==0)break;}
		for(int i=1;i<a;i++){
			for(int j=1;j<b;j++){ 
				if(c[i][j]!=0){
					dp[i][j]=dp[i-1][j]+dp[i][j-1];
				}
			}
		}
		cout<<dp[a-1][b-1]<<endl;
	}
}

Measured memory_bytes: 3032
#include <iostream>

using namespace std;

int main(){
    int n,a,b,c,d;
    char op1,op2,op3;
    cin >> n;
    a = n/1000;
    b = (n%1000)/100;
    c = (n%100)/10;
    d = n%10;

    for(int i=0; i<8; i++){
        int ans = a;
        if(i&1){
            ans += b;
            op1='+';
        }else{
            ans -= b;
            op1='-';
        }
        if(i&2){
            ans += c;
            op2='+';
        }else{
            ans -= c;
            op2='-';
        }
        if(i&4){
            ans += d;
            op3='+';
        }else{
            ans -= d;
            op3='-';
        }

        if(ans == 7){
            cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
            break;
        }
    }
    return 0;
}

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



int main() {
    
    string s;
    cin>>s;
    vector<char> v;
    for(ll i=0;s[i];i++){
        if(s[i]=='0'){
            v.push_back(s[i]);
        }
        else if(s[i]=='1'){
            v.push_back('1');
        }
        else{
            if(v.size()==0){
                continue;
            }
            v.erase(v.begin()+v.size()-1);
        }
    }
    for(char i: v){
        cout<<i;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000000000LL
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n;
ll a[MN];
ll tot;

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

    cin >> n;
    F0R(i, n){
        cin >> a[i];
        tot += a[i];
    }
    ll mn = INF;
    ll sm = 0;
    F0R(i, n){
        sm += a[i];
        ll ot = tot-sm;
        ll dif = sm-ot;
        if(dif < 0) dif = -dif;
        mn = min(mn, dif);
    }

    cout << mn << "\n";

    return 0;
}


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

int main(void)
{
	int n;
	scanf("%d", &n);
	int A[n], cnt = 0;
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &A[i]);
		if(A[i]%2)
		{
			cnt++;
		}
	}
	if(cnt%2) printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 1148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer time = Integer.parseInt(br.readLine());
		Integer hour = time / (60 * 60);
		Integer minute = (time - (hour * 60 * 60)) / 60;
		Integer ss = (time - (hour * 60 * 60)) % 60;
		System.out.println(hour + ":" + minute + ":" + ss);
	}

}

Measured memory_bytes: 17032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int n, minn, ans=0, check, startt;
    cin >> n;
    vector<int> data(n);
    rep(i,n) cin >> data.at(i);
    while (true) {
        minn = 101;
        check = 0;
        startt = 0;
        rep(i,n) {
            if (data.at(i) == 0 || i == n-1) {
                minn = (data.at(i) != 0 ? min(minn, data.at(i)) : minn);
                for (int j=startt; i+1>j; j++) {
                    data.at(j) = ((data.at(j)-minn < 1) ? 0 : data.at(j)-minn);
                }
                ans += (minn == 101 ? 0 : minn);
                startt = i;
                minn = 101;
                check += data.at(i);
                continue;
            }
            check += data.at(i);
            minn = min(minn, data.at(i));
        }
        if (check == 0) break;
    }
    ct(ans);
}

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

#define rep(i,st,en) for(int i=st;i<=en;i++)
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

typedef long long LL;
const LL MOD=1000000007;
const int N=1e5+10;
int x[N],h[N];

int main(){
    FAST_IO;
    int n;
    cin>>n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n[50050],f[100050],zs,a,lefts,rights;
//n[]为辅助空间，里面处理完全是质数；f[]用来前缀和，zs代表质数个数（欧拉线筛需要）
bool b[100050];
int main(){
    b[0]=1,b[1]=1;//初始值
    for(int s=2;s<=100005;s++){//欧拉线筛
        if(!b[s]){n[zs++]=s;}//一个质数
        for(int v=0;v<zs;v++){//处理
            if(s*n[v]>100005)break;//超过了所求的质数范围
            b[n[v]*s]=true;//筛质数
            if(s%n[v]==0)break;}}//压成到O(n)的关键
    cin>>a;
    for(int s=2;s<=100005;s++){//前缀和
        if(s%2==1&&b[s]==0&&b[(s+1)/2]==0)
        f[s]=1;f[s]+=f[s-1];}
    while(a--){
        cin>>lefts>>rights;
        cout<<f[rights]-f[lefts-1]<<endl;}//前缀和的大法
    return 0;
}

Measured memory_bytes: 1536
import Control.Monad
import Data.List

main = do
  [n,k,q] <- map read.words<$>getLine
  as <- replicateM q readLn
  mapM_ putStrLn $ solve n k q as

solve n k q as = zipWith f (scanl(+)0cs) (tail$scanr(+)0cs) where
  f a b = if a+b < k then "Yes" else "No"
  cs = map (pred.length) $ group $ sort $ [1..n] ++ as

Measured memory_bytes: 44412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int i, j;
	int n, a, b;
	cin >> n >> a >> b;
	if (b > a * n) {
		cout << a * n << endl;
	} else {
		cout << b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $H, $W);
$field = array();
for($i=0;$i<$H;$i++){
    $field[] = str_split(trim(fgets(STDIN)));
}
$dx = [1,0,-1,0];
$dy = [0,1,0,-1];

$ans = "Yes";
for($i=0;$i<$H;$i++){
    for($j=0;$j<$W;$j++){
        if($field[$i][$j] == ".") continue;
        $cnt = 0;
        for($d=0;$d<4;$d++){
            $ni = $i+$dy[$d];
            $nj = $j+$dx[$d];
            if($ni < 0 || $H <= $ni) continue;
            if($nj < 0 || $W <= $nj) continue;
            if($field[$ni][$nj] == '.') continue;
            $cnt++;
        }
        if($cnt == 0){
            $ans = "No";
            break 2;
        }
    }
}

echo $ans;

Measured memory_bytes: 4856
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N , M ;
    cin >> N >> M ;
    
    map<ll, vector<ll> > G;
    
    rep(i, M){
        ll a, b; cin >> a >> b ;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    vector<ll> ans(N + 1, -1);
    
    queue<ll> chk;
    chk.push(1);

    while(!chk.empty()){
        ll now = chk.front();
        chk.pop();
        
        rep(i, G[now].size()){
            ll nxt = G[now][i];
            if(ans[nxt] == -1){
                ans[nxt] = now;
                chk.push(nxt);
            }
        }
    }
    
    
    rep(i, N + 1){
        if(i <= 1) continue;
        if(ans[i] == -1){
            cout <<"No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    rep(i, N + 1){
        if(i <= 1) continue;
        cout << ans[i] << endl;
    }
    
        


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 19512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	final static int ICE_TEA_COUNT = 4;
	final static double SHORT_TEA = 0.25;

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String [] input = br.readLine().split(" ");
		String  input2 = br.readLine();
		long [] iceTeaList = new long[4];
		for(int i = 0;i<ICE_TEA_COUNT ;i++) {
			iceTeaList[i] = Integer.parseInt(input[i]);
		}

		int max = Integer.parseInt(input2);
		long [] resultTea = new long[4];
		int multiple = 2;
		long beforeResult = 1;
		boolean continueFlag = false;
		int point = 0;
		resultTea[0] = (long)( max / SHORT_TEA);
		for(int i = 0;i<ICE_TEA_COUNT-1 ;i++) {
			if(beforeResult == 0) {
				continueFlag = true;
			}else if(iceTeaList[i+point]*multiple > iceTeaList[i+1]) {
				resultTea[i+1] = resultTea[i+point]/multiple;
				resultTea[i+point] = resultTea[i+point]%multiple;
				continueFlag = false;
				point = 0;
				multiple = 2;
			}
			if(continueFlag) {
				point -= 1;
				multiple *=2;
				if(i+point >= 0) {
					beforeResult = (long)resultTea[i+point];
					i -= 1;
				}else {
					beforeResult = 1;
				}

				continue;
			}
			beforeResult = resultTea[i+1];
		}
		System.out.println(resultTea[0] * iceTeaList[0] + resultTea[1] *  iceTeaList[1] + resultTea[2] *  iceTeaList[2] + resultTea[3] * iceTeaList[3]);
	}
}

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

int main()
{
	int n,max,ans,i,temp;
	cin >> n;
	max = -1;
	ans = 0;
	for(i=0; i<n; i++)
	{
		cin >> temp;
		if(temp >= max)
		{
			max = temp;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int all[1000002];

    for (int i = 0; i <= 1000001; i++)
    {
        all[i] = 0;
        if (i % 3 == 0)
            all[i] = 1;
        else if(i%5==0)
            all[i] = 1;
    }

    int x;
    if(scanf("%d", &x)==1){}
    long z=0;

    for (int i = 1; i <= x; i++)
    {
        if (all[i] == 0)
            z =(long) z + (long)i;
    }

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

Measured memory_bytes: 6056
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

ll mod26(ll x){
    if(x%26==0)return 26;
    return x%26;
}

int main(){
    ll N;
    cin>>N;
    string ans;
    ans.clear();
    char c;
    while(N){
        c='a'+mod26(N)-1;
        N-=mod26(N);
        N/=26;
        ans.push_back(c);
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n;
double a[100], s;
int main(){
    cin >> n;
    for(int i = 1 ; i <=  n ; i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    int p = 2 , pos = n;
    while( p < 1e9 && pos > 1){
        s += (double)a[pos]/p;
        pos--;
        p*=2;
    }
    if(p < 1e9){
        s += 2*(double)a[1]/p;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    char c;
    cin >> c;
    cout << static_cast<char>(c+1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

bool check(string s, vector<char> &res, char c1, char c2) {
    res[0] = c1, res[1] = c2;
    int n = s.size();
    for(int i = 1; i < s.size() - 1; i++) {
        if(s[i] == 'o' && res[i] == 'S')
            res[i + 1] = res[i - 1];
        else if(s[i] == 'o' && res[i] == 'W')
            res[i + 1] = (res[i - 1] == 'W' ? 'S' : 'W');
        else if(s[i] == 'x' && res[i] == 'S')
            res[i + 1] = (res[i - 1] == 'W' ? 'S' : 'W');
        else if(s[i] == 'x' && res[i] == 'W')
            res[i + 1] = res[i - 1];
    }
    bool ret = false;
    if((res[0] == 'W' && s[0] == 'o') || (res[0] == 'S' && s[0] == 'x')) {
        ret = !(res[1] == res[s.size() - 1]);
        if((res[n - 1] == 'W' && s[n - 1] == 'o') ||
           (res[n - 1] == 'S' && s[n - 1] == 'x')) {
            ret &= !(res[0] == res[n - 2]);
        } else {
            ret &= (res[0] == res[n - 2]);
        }
        return ret;
    } else {
        ret = (res[1] == res[s.size() - 1]);
        if((res[n - 1] == 'W' && s[n - 1] == 'o') ||
           (res[n - 1] == 'S' && s[n - 1] == 'x')) {
            ret &= !(res[0] == res[n - 2]);
        } else {
            ret &= (res[0] == res[n - 2]);
        }
        return ret;
    }
}

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    vector<char> res(N);
    if(check(s, res, 'S', 'S')) {
        rep(i, N) cout << res[i];
        cout << endl;
        return 0;
    }
    if(check(s, res, 'S', 'W')) {
        rep(i, N) cout << res[i];
        cout << endl;
        return 0;
    }
    if(check(s, res, 'W', 'S')) {
        rep(i, N) cout << res[i];
        cout << endl;
        return 0;
    }
    if(check(s, res, 'W', 'W')) {
        rep(i, N) cout << res[i];
        cout << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

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

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

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;

}
Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;

}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);
  y=x->parent;
   while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }

  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }

  if(y!=z){
    z->key=y->key;
  }
  free(y);
}

void insert(int k){
  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;
    }
  }
}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


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

const int N = 1e5 + 5;
const int inf = 2e9;

int n, k;
vector<int> G[N];
int a[N], lev[N];
int low[N], high[N];

void dfs(int u,int p) {
	for (int v : G[u]) if (v != p) {
		lev[v] = lev[u] + 1;
		dfs(v, u);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n - 1; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v), G[v].push_back(u);
	}
	dfs(1, 1);
	for (int i = 1; i <= n; ++i) low[i] = -inf, high[i] = inf;
	
	queue<int> q;
	cin >> k; int form = -1;
	while (k--) {
		int v, p; cin >> v >> p;
		int cur = (lev[v] + p) & 1;
		if (form == -1) form = cur;
		if (cur != form) {
			return cout << "No\n",0;
		}
		low[v] = p, high[v] = p;
		q.push(v);
	} 
	
	while (!q.empty()) {
		int u = q.front(); q.pop();
		int lu = low[u], hu = high[u];
		if (low[u] > high[u]) return cout << "No\n",0;
		for (int v : G[u]) {
			if (low[v] < lu - 1 || high[v] > hu + 1) {
				low[v] = max(low[v], lu - 1);
				high[v] = min(high[v], hu + 1);
				q.push(v);
			}
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		if (low[i] == high[i]) q.push(i);
		a[i] = low[i];
	}
	
	while (!q.empty()) {
		int u = q.front(); q.pop();
		a[u] = low[u];
		for (int v : G[u]) if (!a[v]) {
			low[v] = max(low[v], a[u] - 1);
			high[v] = min(high[v], a[u] + 1);
			q.push(v);
		}
	}
	
	cout << "Yes\n";
	for (int i = 1; i <= n; ++i) cout << a[i] << '\n';
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

int h, w, k;

int f(int yy, int xx, vector<string> t) {
  int cnt = 0;
  rep(y, h) {
    if ((yy >> y) & 1) {
      rep(x, w) {
        if ((xx >> x) & 1) {
          if (t[y][x] == '#') {
            cnt += 1;
          }
        }
      }
    }
  }

  return cnt;
}

int main() {
  cin >> h >> w >> k;

  vector<string> tab(h);
  rep(i, h) {
    cin >> tab[i];
  }

  int res = 0;
  rep(yy, 1 << h) {
    rep(xx, 1 << w) {
      int t = f(yy, xx, tab);
      if (t == k) {
        res += 1;
      }
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
import bisect

n, q = map(int, input().split())
s=input()
sng=len(s)
aclist=[]
for i in range(sng-1):
    if s[i]=='A' and s[i+1]=='C':
        aclist.append(i+1)

#print(aclist)
for i in range(q):
    l, r = map(int, input().split())
    ll=bisect.bisect_left(aclist, l)
    rr=bisect.bisect_right(aclist, r-1)
    print(rr-ll)

Measured memory_bytes: 55896
# -*- coding: utf-8 -*-
from collections import deque
N, M = map(int, input().split(' '))
graph = [[] for _ in range(N)]
for i in range(M):
    l, r, d = map(int, input().split(' '))
    l -= 1
    r -= 1
    graph[l].append((r, d))
    graph[r].append((l, -d))

dsts = [float('inf') for _ in range(N)]

for n in range(N):
    if dsts[n] != float('inf'):
        continue

    buf = deque()
    buf.append(n)
    dsts[n] = 0
    while buf:
        src = buf.popleft()
        for dst, d, in graph[src]:
            next_d = dsts[src] + d

            if dsts[dst] == float('inf'):
                dsts[dst] = next_d
                buf.append(dst)

            elif dsts[dst]  != next_d:
                # print(dsts)
                # print(dst, src, dsts[dst], dsts[src], d, next_d)
                print("No")
                exit()

print("Yes")




Measured memory_bytes: 84512
#include<bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<=(e);i++)
#define FORD(i,s,e) for(int i=(s);i>=(e);i--)
#define eb emplace_back
#define MAXN 1000009
#define MOD 1000000007
#define mp(x, y) make_pair(x,y)
#define all(v) (v).begin(),(v).end()
#define pb(x) push_back(x)
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
const bool print=false;
typedef long long ll;

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

int n,x;
vector<pair<PII,PII>>p;
int a[MAXN];
int main()
{
    scanf("%d%d", &n,&x);
    for(int i = 0; i < n; i ++) scanf("%d",a+i);
    a[n++] = x;
    sort(a,a+n);
    x = 0;
    for(int i = 1; i < n; i ++)
    	if(a[i] != a[i-1]) x = __gcd(x,a[i] - a[i-1]);
    printf("%d", x);
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;


#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
const int maxn = 1e5 + 20;
LL a[maxn];
LL b[maxn];
int n;
void work() {
    cin >> n;
//    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
    }
    LL ans = 0;
    LL add = 0;
    int tocalc = n;
    while (tocalc >= 1) {
        LL now = a[tocalc] + add;
        LL need = b[tocalc] - now % b[tocalc];
        if (now % b[tocalc] == 0) need = 0;
        ans += need;
        add += need;
        tocalc--;
//        cout << ans << endl;
//        cout << tocalc << endl;
    }
    cout << ans << endl;
}


int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    IOS;
    work();
    return 0;
}


Measured memory_bytes: 1792
--https://www.lua.org/pil/11.4.html
local List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

----------

local h,w=io.read("n","n","l")
local maze={}
local shounter=0
for i=1,h do
    local s=io.read()
    maze[i]={}
    for j=1,w do
        local sub=s:sub(j,j)
        if sub=="#" then
            shounter=shounter+1
        end
        maze[i][j]=sub
    end
end

local dx={1,0,-1,0}
local dy={0,1,0,-1}

local function bfs(x,y)
    local dist={}
    for i=1,h do
        dist[i]={}
        for j=1,w do
            dist[i][j]=-1
        end
    end
    local que=List.new()
    
    List.pushright(que,{x,y})
    dist[x][y]=1

    while x~=h and y~=w do
        local q=List.popleft(que)
        if not q then break end
        local x,y=q[1],q[2]
        for i=1,4 do
            local nx,ny=x+dx[i],y+dy[i]
            local checker=(nx<1 or nx>h or ny<1 or ny>w)
            if not checker and maze[nx][ny]~="#" and dist[nx][ny]==-1 then
                dist[nx][ny]=dist[x][y]+1
                List.pushright(que,{nx,ny})
            end
        end
    end
    
    return dist[h][w]
end

local mindist=bfs(1,1)
if mindist>-1 then
    print(h*w-(mindist+shounter))
else
    print(mindist)
end

Measured memory_bytes: 2832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
ll INF=1e18+5;

int main(){
  ll N;
  cin >> N;
  VL a(5);
  rep(i,0,5) cin >> a[i];
  VL t(5);

  t[0] = (N+a[0]-1)/a[0];
  ll ans = t[0];
  ll mov = INF;
  // t[i] i個目の交通機関が全員送り届け終わるまでの時刻（0-何分後か）
  rep(i,1,5){
    mov = min(mov, min(a[i], a[i-1]));
    t[i] = (N+mov-1)/mov + i;
  }
  cout << t[4] << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int lli;

const lli max_val = 5L * 100000 * 100001;

pair< lli, lli > get_left_right(const vector<lli> &xs, lli x) {
  auto it = lower_bound(xs.begin(), xs.end(), x);
  lli l = max_val;
  lli r = max_val;
  if (it != xs.end()) {
    r = *it;
  }

  if (it != xs.begin()) {
    l = *(it - 1);
  }
  return make_pair(l, r);
}


int main() {
  lli a, b, q;
  cin >> a >> b >> q;
  vector<lli> ss(a), ts(b);
  for (int i = 0; i < a; i++) cin >> ss[i];
  for (int i = 0; i < b; i++) cin >> ts[i];
  sort(ss.begin(), ss.end());
  sort(ts.begin(), ts.end());

  for (int i = 0; i < q; i++) {
    lli x; cin >> x;
    lli ans = max_val;
    // 神社から
    auto lr = get_left_right(ss, x);
    // 右側
    if (lr.second != max_val) {
      auto result = get_left_right(ts, lr.second);
      lli tmp = min(abs(lr.second - result.first), abs(lr.second - result.second));
      ans = min(tmp + abs(lr.second - x), ans);
    } 
    if (lr.first != max_val) {
      // 左側
      auto result = get_left_right(ts, lr.first);
      lli tmp = min(abs(lr.first - result.first), abs(lr.first - result.second));
      ans = min(tmp + abs(lr.first - x), ans);
    }

    // 寺から
    lr = get_left_right(ts, x);
    // 右側
    if (lr.second != max_val) {
      auto result = get_left_right(ss, lr.second);
      lli tmp = min(abs(lr.second - result.first), abs(lr.second - result.second));
      ans = min(tmp + abs(lr.second - x), ans);
    } 
    if (lr.first != max_val) {
      // 左側
      auto result = get_left_right(ss, lr.first);
      lli tmp = min(abs(lr.first - result.first), abs(lr.first - result.second));
      ans = min(tmp + abs(lr.first - x), ans);
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);

    for(int i=0;i<n;i++) cin>>v[i];

    sort(v.begin(),v.end());

    int ans=INT_MAX;
    for(int i=0,j=n-1;i<j;i++,j--){
        ans=min(ans,v[j]-v[i]);
    }
    cout <<ans <<endl;

    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,p;
	cin>>n>>p;
	map<ll,ll> m;
	for(ll i=2;i*i<=p;i++)
	if(p%i==0){
		while(p%i==0){
			p/=i;
			m[i]++;
		}
	}
	if(p)
	m[p]++;
	ll res=1;
	for(auto it=m.begin();it!=m.end();it++)
	res*=pow(it->first,it->second/n);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();		
}


Measured memory_bytes: 3948
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		String codefes = "CODEFESTIVAL2016";
		String s = sc.next();
		
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (codefes.charAt(i) != s.charAt(i)) {
				count++;
			}
		}
		
		out.println(count);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}


Measured memory_bytes: 8276
N, W = map(int, input().split())
value, wight = [0] * N, [0] * N
for i in range(N):
    value[i], wight[i] = map(int, input().split())

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(N):
    for w in range(W + 1):
        if w >= wight[i]:
            dp[i + 1][w] = max(dp[i][w - wight[i]] + value[i], dp[i][w])
        else:
            dp[i + 1][w] = dp[i][w]
print(dp[N][W])


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

using namespace std;


void solve() {
    int n; cin >> n;
    map<int, int> cnt;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        cnt[x]++;
    }
    if (cnt.size() == 1) {
        if (cnt[0] == n) cout << "Yes";
        else cout << "No";
    } else if (cnt.size() == 2) {
        if (cnt[0]*3 == n && cnt.rbegin()->second * 3 == 2*n) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else if (cnt.size() == 3) {
        int sum = 0;
        for (auto& p: cnt) {
            if (p.second * 3 != n) {
                cout << "No"; return;
            }
            sum ^= p.first;
        }
        if (sum == 0) cout << "Yes";
        else cout << "No";
    } else {
        cout << "No";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 3840
import collections
n = int(input())
balls = []
for _ in range(n):
    x, y = map(int, input().split())
    balls.append([x, y])
# print(balls)
delta = []
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        dx = balls[j][0] - balls[i][0]
        dy = balls[j][1] - balls[i][1]
        delta.append((dx, dy))

c_delta = collections.Counter(delta)
# print(c_delta)
if len(c_delta):
    print(n-c_delta.most_common()[0][1])
else:
    print(1)

Measured memory_bytes: 9888
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	if( (N/10==9) || (N%10==9) ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;

	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (auto & P : p)
    cin >> P;
  int max = 0;
  for (int i = 0; i < K; ++i)
    max += p[i];
  int idx = 0;
  int sum = max;
  for (int i = 0; i < N - K; ++i)
  {
    sum += -p[i] + p[i + K];
    if (max < sum)
    {
      idx = i + 1;
      max = sum;
    }
  }
  double exp = 0.0;
  for (int i = idx; i < idx + K; ++i)
    exp += 0.5*(1 + p[i]);
  cout << fixed << exp;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string n; cin >> n;
  rep(i,n.size()){
    if(n[i]=='1') n[i] = '9';
    else n[i] = '1';
  }

  cout << n << endl;
  
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 5228;
ll f[N][N];
int p[N];

const ll INF = (1ll << 60);

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif  
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    ll a, b;
    cin >> n >> a >> b;

    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }

    p[n] = n;

    for (int i = 0; i <= n + 1; ++i) {
        fill(f[i], f[i] + n + 1, INF);
    }

    f[0][0] = 0;
   
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            ll cf = f[i][j];
            if (p[i] >= j) {
                f[i + 1][p[i]] = min(f[i + 1][p[i]], cf);
                f[i + 1][j] = min(f[i + 1][j], cf + a);
            } else {
                f[i + 1][j] = min(f[i + 1][j], cf + b);
            }
        }
    }

    cout << f[n + 1][n] << "\n";
}

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

int main()
{
    int n; cin>>n;
    vector<long> a(n); for(auto& e: a) cin>>e;
    sort(begin(a), end(a));

    auto func=[&]() {
        deque<long> b={a[0]};
        int k=n-1;
        for(int i=1, j=n-1; i<=j; i+=2, j-=2) {
            b.push_back(a[j]); if (!--k) break;
            b.push_front(a[j-1]); if (!--k) break;
            b.push_back(a[i]); if (!--k) break;
            b.push_front(a[i+1]); if (!--k) break;
        }

        long res=0;
        for(int i=1; i<n; ++i) res+=abs(b[i-1]-b[i]);
        swap(b[0], b[n-1]);
        long res2=0;
        for(int i=1; i<n; ++i) res2+=abs(b[i-1]-b[i]);

        return max(res, res2);
    };

    auto func2=[&]() {
        deque<long> b={a[n-1]};
        int k=n-1;
        for(int i=0, j=n-2; i<=j; i+=2, j-=2) {
            b.push_back(a[i]); if (!--k) break;
            b.push_front(a[i+1]); if (!--k) break;
            b.push_back(a[j]); if (!--k) break;
            b.push_front(a[j-1]); if (!--k) break;
        }

        long res=0;
        for(int i=1; i<n; ++i) res+=abs(b[i-1]-b[i]);
        swap(b[0], b[n-1]);
        long res2=0;
        for(int i=1; i<n; ++i) res2+=abs(b[i-1]-b[i]);

        return max(res, res2);
    };

    cout<<max(func(), func2())<<endl;
}


Measured memory_bytes: 1860
// 0228.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	ios::sync_with_stdio(false);
	string a[10];
	a[0] = "0111111";
	a[1] = "0000110";
	a[2] = "1011011";
	a[3] = "1001111";
	a[4] = "1100110";
	a[5] = "1101101";
	a[7] = "0100111";
	a[6] = "1111101";
	a[8] = "1111111";
	a[9] = "1101111";
	while (true) {

		ll n;
		cin >> n;
		if (n == -1) { break; }
		string s = "0000000";
		for (int i = 0; i < n; i++) {
			int d;
			cin >> d;
			for (int j = 0; j < 7; j++) {
				if (a[d][j] == s[j]) { cout << 0; }
				else { cout << 1; }
			}
			cout << endl;
			s = a[d];
		}
	
	}
	
	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main(){
    int a, b; cin >> a >> b;
    int x;
    if (b==100) x = 1000*a + b;
    else if (b>=10&&b<100) x = 100*a + b;
    else x = 10*a + b;

    bool ans=false;
    for (int i=1;i<x/2;i++){
        if (i*i==x) {
            ans=true;
            break;
        }
    }
    cout << ((ans) ? "Yes" : "No")<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
#define ll long long
int mul(int p){
  int ans = 1;
  for(int i = 0;i < p;i ++){
    ans = ans * 10;
  }
  return ans;
}

int dig(int a){
  int ans = 1;
  double p = 9.9999999;
  while(p<a){
    p = p*10;
    ans++;
  }
  return ans;
}

int main(void){
  int n;
  cin >> n;
  int p = dig(n);
  int ans;
  if(p == 1){
    ans = n;
  }else if(p % 2 == 0){
    ans = 0;
    p = p/2;
    for(int i = 0;i < p;i ++){
      ans = ans*100+9;
    }
  }else{
    int q = (p-1)/2;
    ans = 9;
    for(int i = 0;i < q;i ++){
      ans = ans*100+9;
    }
    ans = ans + n -mul(p) + 1;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
   int n;

   scanf("%d", &n);

   if(n % 10 == 3) {
      printf("bon\n");
   } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
      printf("pon\n");
   } else {
      printf("hon\n");
   }

   return 0;
}


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

int main(void){
    long int i, n;
    scanf("%ld", &n);
    long int ans = n;
    for(i = 1; i <= (long int)sqrt(n); ++i){
        if(n % i == 0){
            if(ans > i + n/i - 2 ){ ans = i + n/i - 2; }
        }
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 128
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll cnt = 0;
	string s, t; cin >> s >> t;
	for (ll i = 0; i < 3; i++) {
		cnt += (s[i] == t[i]);
	}	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int MOD=1e9+7;

ll powm(ll x,ll k){
    ll res=1;
    while(k){
        if(k&1) res=res*x%MOD;
        k>>=1;
        x=x*x%MOD;
    }
    return res;
}
ll inv(ll x){
    return powm(x,MOD-2);
}
int main(){
    int n;
    cin>>n;

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

    map<int,int> mp;
    for(int i=0;i<n;i++){
        int x=a[i];
        map<int,int> mpX;
        for(int j=2;j*j<=x;j++){
            while(x%j==0) x/=j,mpX[j]++;
        }
        if(x>1) mpX[x]++;
        for(auto& e:mpX){
            if(mp[e.first]<e.second){
                mp[e.first]=e.second;
            }
        }
    }

    ll res=0;
    ll piyo=1;
    for(auto &x:mp){
        for(int i=0;i<x.second;i++) piyo=piyo*x.first%MOD;
    }
    // cerr<<piyo<<endl;
    for(int i=0;i<n;i++){
        int x=a[i];
        map<int,int> mpX;
        for(int j=2;j*j<=x;j++){
            while(x%j==0) x/=j,mpX[j]++;
        }
        if(x>1) mpX[x]++;
        ll v=piyo;
        for(auto &e:mpX){
            for(int i=0;i<e.second;i++) v=v*inv(e.first)%MOD;
        }
        res=(res+v)%MOD;
    }

    cout<<res<<endl;
    
    
    return 0;
}


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

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
queue<tuple<int, int, int>> keep;
int H, W;

int bfs(int i, int j, vector<vector<bool>> &seen, vector<vector<char>> &maze) {
  int ans = 0;
  seen.at(i).at(j) = true;
  keep.push(make_tuple(i, j, 0));
  while(!keep.empty()) {
    int a, b, c;
    tie(a, b, c) = keep.front();
    ans = c;
    keep.pop();
    for(int k = 0; k < 4; k++) {
      if(a + dx.at(k) < 0 || a + dx.at(k) >= H || b + dy.at(k) < 0 || b + dy.at(k) >= W) {
        continue;
      }
      else if(seen.at(a + dx.at(k)).at(b + dy.at(k))) {
        continue;
      }
      else if(maze.at(a + dx.at(k)).at(b + dy.at(k)) == '#') {
        seen.at(a + dx.at(k)).at(b + dy.at(k)) = true;
        continue;
      }
      else {
        seen.at(a + dx.at(k)).at(b + dy.at(k)) = true;
        keep.push(make_tuple(a + dx.at(k), b + dy.at(k), c + 1));
      }
    }
  }
  return ans;
}
                  

int main() { 
  cin >> H >> W;
  vector<vector<char>> maze(H, vector<char> (W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> maze.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(maze.at(i).at(j) == '.') {
        vector<vector<bool>> seen(H, vector<bool> (W, false));
        int l = bfs(i, j, seen, maze);
        if(l > ans) {
          ans = l;
        }
      }
    }
  }
  cout << ans << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi a(3), b(3);
  rep(i,3) cin >> a[i];
  rep(i,3) cin >> b[i];
  rep(_,2){
    int m = n;
    vi c, d;
    rep(i,3) if(a[i] < b[i]){
      c.push_back(a[i]);
      d.push_back(b[i]);
    }
    if(c.size() == 3){
      rep(i,n+1) rep(j,n-i+1){
	int k = n - i - j;
	// 金にi,銀にj,銅にk個使う
	int x = i/c[0], y = j/c[1], z = k/c[2];
	int tmpn = n - x*c[0] - y*c[1] - z*c[2];
	tmpn += x*d[0] + y*d[1] + z*d[2];
	m = max(m, tmpn);
      }
    }else if(c.size() == 2){
      rep(i,n+1){
	int j = n - i;
	// 金にi,銀にj個使う
	int x = i/c[0], y = j/c[1];
	int tmpn = n - x*c[0] - y*c[1];
	tmpn += x*d[0] + y*d[1];
	m = max(m, tmpn);
      }
    }else if(c.size() == 1){
      int i = n;
      // 金にi個使う
      int x = i/c[0];
      int tmpn = n - x*c[0];
      tmpn += x*d[0];
      m = max(m, tmpn);
    }
    swap(a,b);
    n = m;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
l = input().split()
n = int(l[0])
m = int(l[1])
x = int(l[2])
a = input().split()
i = 0
while(1):
    if int(a[i]) > x:
        break
    i = i + 1
if i < m - i:
    print(i)
else:
    print(m - i)


Measured memory_bytes: 3060
s = input()

ans = "No"
if s == "hi":
    ans = "Yes"
elif s == "hihi":
    ans = "Yes"
elif s == "hihihi":
    ans = "Yes"
elif s == "hihihihi":
    ans = "Yes"
elif s == "hihihihihi":
    ans = "Yes"

print(ans)

Measured memory_bytes: 2940
import re
Sd = input()
T = input()

Sdr = Sd[::-1].replace('?', '.')
Tr = T[::-1]

for i in range(len(Sdr)-len(Tr)+1):
    pattern = Sdr[i:i+len(Tr)]
    if re.match(pattern, Tr):
        print(Sdr.replace(pattern, Tr, 1).replace('.', 'a')[::-1])
        break
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v)  cin >> e;
    vector<int>ans;
    rep(_,300){
        for(int i = (int)v.size() - 1; i >= 0; --i){
            if(i + 1 == v[i]){
                ans.push_back(i + 1);
                v.erase(v.begin() + i);
                break;
            }
        }
    }
    reverse(all(ans));
    if(v.size() != 0) return puts("-1") * 0;
    for(auto e : ans)
        cout << e << endl;
}






Measured memory_bytes: 256
require 'prime'
S = gets.chomp.to_i
sqrt = Math.sqrt(S).to_i
rt = (sqrt ** 2 == S) ? sqrt : (sqrt + 1)
diff = rt ** 2 - S
x1 = 0
y1 = 0
# s == (x2 * y3 - x3 * y2).abs
x2 = rt
y3 = rt
x3 = diff.zero? ? 0 : 1
y2 = diff
puts [x1, y1, x2, y2, x3, y3].join(" ")

Measured memory_bytes: 2044