akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<sstream>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
map<int,int> mp;
int n;
int ans;
vector<string> st;
void sec(int pos,vector<bool> used,int cnt){
  if(used[pos])
    return;
  used[pos]=true;
  if(pos==n){
    ans=min(ans,cnt);
  }else if(st[pos].substr(0,5)=="goto "){

    sec(mp[pos],used,cnt);

    sec(pos+1,used,cnt+1);
  }else{
    sec(pos+1,used,cnt);
  }
}
int main(){
  while(cin>>n){
    cin.ignore();
    st.resize(n);
    rep(i,n){
      getline(cin,st[i]);
      
    }
    rep(i,n){
      if(st[i].substr(0,5)=="goto "){
	string to=st[i].substr(5,(int)st[i].size()-6);
	rep(j,n){
	  if(to==st[j].substr(0,st[j].size()-1)){
	    mp[i]=j;
	    //cout<<i<<" "<<j<<endl;
	  }
	}
      }
    }
        
    ans=1000;
    vector<bool> used(n+1,false);
    sec(0,used,0);
    cout<<ans<<endl;
    

  }
  return 0;
}

Measured memory_bytes: 1292
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort()

    if n == 2:
        print(a[1]-a[0])
        print(a[1],a[0])
    else:
        if a[1] > 0:
            ans = a[0]-a[-1]
            op = [(a[0],a[-1])]
        else:
            ans = a[-1]-a[0]
            op = [(a[-1],a[0])]
        f = True
        for i in range(1,n-2):
            if f and a[i+1] > 0:
                f = False
            if f:
                op.append((max(ans,a[i]),min(ans,a[i])))
                ans = max(ans,a[i])-min(ans,a[i])
            else:
                op.append((min(ans,a[i]),max(ans,a[i])))
                ans = min(ans,a[i])-max(ans,a[i])
        op.append((max(ans,a[n-2]),min(ans,a[n-2])))
        ans = max(ans,a[n-2])-min(ans,a[n-2])
        print(ans)
        for x,y in op:
            print(x,y)


if __name__ == '__main__':
    main()


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

int main() {
    int n, k;
    cin >> n;
    
    vector<vector<int> > arr(n, vector<int>(3)), dp(n, vector<int>(3, 0));
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
            cin >> arr[i][j];
            
    int ans = 0;
    
    dp[0] = arr[0];
    
    for(int row = 1; row < n; row++){
        for(int col = 0; col < 3; col++){
            for(int k = 0; k < 3; k++){
                if(k == col)
                    continue;
                dp[row][col] = max(dp[row][col], arr[row][col] + dp[row-1][k]);
            }
        }
    }
    
    cout << *max_element(dp[n-1].begin(), dp[n-1].end());
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {

	int N; cin >> N;
	int cnt = 0; int first;
	cin >> first;
	int max = 0;
	forn(i, N-1) {
        int input; cin >> input;
		if(input <= first)
			cnt++;
		else 
			cnt = 0;
		first = input;
		
		uax(max, cnt);
	}
	cout << max << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
 
        int cou = 0;
        for(int i=0; i<S.length()/2; i++){
            if(ss[i]!=ss[S.length()-1-i]){
                cou++;
            }       
}
            System.out.println(cou);
        }
}


Measured memory_bytes: 35684
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];
string str;

int main()
{
	ll n,a,b,c,d,i,flag=-1,inde=-1,cnt=0;
	cin>>n>>a>>b>>c>>d;
	cin>>str;
	for(i=a-1;i<max(c,d);i++)
	{
		if(str[i]=='#'&&str[i+1]=='#')
		{
			flag=i;
			break;
		}
	}
	if(flag!=-1)
	{
		cout<<"No";
		return 0;
	}
	for(i=b-1;i<=d-1;i++)
	{
		if(str[i-1]=='.'&&str[i]=='.'&&str[i+1]=='.')
		{
			inde=i;
			break;
		}
	}
	if(c>d)
	{
		if(inde!=-1)
			cout<<"Yes";
		else
			cout<<"No";
	}
	else
		cout<<"Yes";
	return 0;
}


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

int main(void){
    int n;
    cin>>n;
    vector<ll> l(n+1),r(n+1);
    rep(i,n) cin>>l[i]>>r[i];
    sort(all(l));
    sort(all(r));
    ll sum = 0;
    rep(i,n) sum += max(l[n-i] - r[i],0LL);
    cout<<sum*2<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int n,q;
int A[2000];
int M;

int BF(int cnt,int sum){
  if(sum==M)return 1;
  if(cnt==n||sum>M)return 0;
  if( BF(cnt+1,sum+A[cnt]) ) return 1;
  if( BF(cnt+1,sum) ) return 1;
  return 0;
}

int main(){
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(BF(0,0))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<size_t> factors(size_t n) {
  vector<size_t> result;
  for (size_t d = 1; d * d <= n; d++) {
    if (n % d == 0) {
      result.push_back(d);
      if (n / d != d) {
        result.push_back(n / d);
      }
    }
  }
  return result;
}

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

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

  const int MAX = 1'000'001;
  vector<bool> ex(MAX, false);
  int result = 0;
  rep(i, N) {
    vector<size_t> fs = factors(a[i]);
    bool c = true;
    for (size_t f : fs) {
      c = c && !ex[f];
    }
    if (c && (upper_bound(a.begin(), a.end(), a[i]) -
                  lower_bound(a.begin(), a.end(), a[i]) ==
              1)) {
      result++;
    };
    ex[a[i]] = true;
  }
  cout << result << endl;
  return 0;
}

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

int main() {
  int N; 
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    count += r-l+1;
  }
  cout << count << endl;
}

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int d, t, s; cin >> d >> t >> s;
	if(d/s < t || (d/s == t && d%s == 0)) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define pb push_back
#define all(v) v.begin(),v.end()
const ll mod=1000000007;
ll cnt[200005];
 
 
using namespace std;
 
 
ll fib(ll n) { 
  double phi = (1 + sqrt(5)) / 2; 
  return round(pow(phi, n) / sqrt(5)); 
} 
 
int main() {
		 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
	ld N;
	
	cin >> N;
	ld k;
	
	k = (ceil(N/2))/N;
	
	printf("%0.10llf",k);
	
}


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

typedef long long ll;
ll A[200010],B[200010];
ll N;

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		B[A[i]] = i;
	}
	set<ll> s,t;
	ll ans = 0;
	s.insert(0);
	t.insert(N+1);
	for(int i=1;i<=N;i++){
		s.insert(-B[i]);
		t.insert(B[i]);
		set<ll>::iterator it = s.upper_bound(-B[i]); 
		set<ll>::iterator it2 = t.upper_bound(B[i]);
		ll l = -*it;
		ll r = *it2;
		ans += i*(B[i]-l)*(r-B[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define INF 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> G[100000];
int n, m;
int v[100000], d[100000], c[100000];
int dp[100000][11];

void dfs(int cur, int dist, int cnt) {
  dp[cur][dist] = cnt;
  if (dist == 0) return;
  if (dp[cur][dist - 1] == -1) {
    dfs(cur, dist - 1, cnt);
  }
  REP(i, G[cur].size()) {
    int nxt = G[cur][i];
    if (dp[nxt][dist - 1] == -1) {
      dfs(nxt, dist - 1, cnt);
    }
  }
}

int main() {
  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int q;
  cin >> q;
  REP(i, q) {
    cin >> v[i] >> d[i] >> c[i];
    v[i]--;
  }
  REP(i, n) REP(j, 11) dp[i][j] = -1;
  RREP(i, q) {
    if (dp[v[i]][d[i]] == -1) dfs(v[i], d[i], i);
  }
  REP(i, n) cout << (dp[i][0] == -1 ? 0 : c[dp[i][0]]) << endl;
  return 0;
}

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif
typedef unsigned long long ULL;

const LL BASE = 37;
const LL MOD = 1000000009;

LL modpow(LL a, LL b){
    if(b == 0) return 1;
    LL k = modpow(a, b/2);
    k = k*k%MOD;
    if(b%2) k = k*a%MOD;
    return k;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<LL> a(n+1,0), b(n+1,0);
    map<LL,LL> cnt;
    LL ans = 0;
    cnt[0] = 1;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        b[i] = b[i-1] + a[i];
        //~ cerr << b[i] << endl;
        ans += cnt[b[i]];
        cnt[b[i]]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 15872
n = int(input())
flag = 0
c = 0
for i in range(n):
    d1,d2=map(int,input().split())
    if d1 == d2:
        c += 1
        if c == 3:
            flag = 1
    else:
        c = 0
if flag == 1:
    print("Yes")
else:
    print("No")

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

using namespace std;

using ll = long long;

const int N = 3e5;

map<ll, int> id;
ll fw[N], a[N];

void add(int p) {
    p += 10;
    for (int i = p; i < N; i += i & -i) {
        ++fw[i];
    }
}

ll sum(int p) {
    p += 10;
    ll res = 0;
    for (int i = p; i; i -= i & -i) {
        res += fw[i];
    }
    return res;
}

int main() {
    #if __APPLE__
        freopen("in", "r", stdin);
        freopen("out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie();
    int n, k;
    cin >> n >> k;
    vector<ll> all(n);
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= k;
        if (i) a[i] += a[i - 1];
        all[i] = a[i];
    }
    sort(all.begin(), all.end());
    for (int i = 0; i < n; ++i) {
        id[a[i]] = 1 + lower_bound(all.begin(), all.end(), a[i]) - all.begin();
    }
    for (int i = 0; i < n; ++i) {
        res += sum(id[a[i]]);
        if (a[i] >= 0) ++res;
        add(id[a[i]]);
    }
    cout << res << '\n';
}


Measured memory_bytes: 17920
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const [D, X] = input[1].map(Number);

  let answer = X;

  for (let i = 2; i < N + 2; i++) {
    const A = Number(input[i][0]);

    let count = 0;

    for (let j = 0; A * j + 1 <= D; j++) {
      count += 1;
    }

    answer += count;
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 29592
N = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for i in range(N,N+10**5):
    if(is_prime(i)):
        print(i)
        exit()

Measured memory_bytes: 3060
using AtCoderBeginnerContest119.Questions;
using AtCoderBeginnerContest119.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest119.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var datetime = DateTime.Parse(inputStream.ReadLine());
            if (datetime < new DateTime(2019, 5, 1))
            {
                yield return "Heisei";
            }
            else
            {
                yield return "TBD";
            }
        }
    }
}


namespace AtCoderBeginnerContest119
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest119.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest119.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13664
mod = 10**9+7
from math import gcd
from collections import defaultdict

n = int(input())

ab = [list(map(int, input().split())) for i in range(n)]

ans = 0
d = defaultdict(int)
s = set()
for a,b in ab:
    if a == 0 and b == 0:
        ans += 1
        continue
    if a == 0:
        b = 1
        x = 1
        y = 0
    elif b == 0:
        a = 1
        x = 0
        y = 1
    else:
        g = gcd(abs(a), abs(b))
        a //= g
        b //= g
        if a < 0:
            a = -a
            b = -b
        x = b
        y = -a
        if x < 0:
            x = -x
            y = -y
    d[(a,b)] += 1
    k = tuple(sorted([(a,b), (x,y)]))
    s.add(k)

s = list(s)
n = len(s)
if n == 0:
    print(ans)
    exit()
DP = [0]*(n+1)
DP[0] = 1
for i in range(n):
    l,r = s[i]
    DP[i+1] = DP[i]*(1 + pow(2,d[l], mod)-1 + pow(2, d[r], mod)-1)
    DP[i+1] %= mod

ans += DP[-1]-1
ans %= mod
print(ans)


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    for(int i = 0; i < m+2; i++)
    {
        cout << '#';
    }
    cout << endl;
    for(int i = 0; i < n; i++)
    {   
        cout << '#';
        for(int j = 0; j < m; j++)
        {
            cout << a[i][j];
        }
        cout << '#' << endl;
    }
    for(int i = 0; i < m+2; i++)
    {
        cout << '#';
    }
    cout << endl;
    
    
    return 0;
}

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

int main()
{
   int n,a[200];
   double ans=0;
   cin>>n;
   for(int i=0;i<n;i++){ 
       cin>>a[i];
   }
   sort(a,a+n);
   ans+=(a[0]+a[1])/2.0;
   for(int i=2;i<n;i++){ 
     ans=(ans+a[i])/2.0;
   }
   cout<<ans<<endl; 

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int H = 0;
  int W = 0;
  int i, j;

  do{
    scanf("%d %d", &H, &W);

    if(H == 0 && W == 0)
      break;

    for(i = 0; i < H; i++){
      if(i == 0 || i == H - 1) 
	for(j = 0; j < W; j++)
	  putchar('#');
      else{
	putchar('#');
	for(j = 0; j < W - 2; j++)
	  putchar('.');
	putchar('#');
      }
      
      putchar('\n');
    }
    putchar('\n');
    
  }while (1);
  
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

bool AC[101010];
int WA[101010];

void solve() {
    int n, m;
    cin >> n >> m;
    int pen = 0, ac = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if (AC[p]) continue;
        if (s == "AC") {
            ac++;
            pen += WA[p];
            AC[p] = 1;
        } else {
            WA[p]++;
        }
    }
    cout << ac << " " << pen << endl;
}

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


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

int main()
{
    int n,m;
    const int INF = 1001001001;
    cin>>n>>m;
    vector<int> to[100004];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> dist(n,INF);
    vector<int> pre(n,0);
    queue<int> q;
    dist[0] = 0;
    q.push(0);
    while(!q.empty())
    {
        int v = q.front();q.pop();
        for(int u : to[v])
        {
            if(dist[u] != INF)continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)
    {
        if(i==0)continue;
        int ans = pre[i];
        cout<<++ans<<endl;
    }
}

Measured memory_bytes: 10748
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    
    int ans =0;
    for(int i= A ; i<=B ; i++){
        if ((int)(i/10000) == i%10 && (int)((i%10000)%1000%100/10) == (int)(i%10000)/1000)ans += 1;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){
  int i,j;
  char s1,s2;
  cin>>s1>>s2;
  if(s1=='A')i=1;
  if(s1=='B')i=2;
  if(s1=='C')i=3;
  if(s1=='D')i=4;
  if(s1=='E')i=5;
  if(s1=='F')i=6;

  if(s2=='A')j=1;
  if(s2=='B')j=2;
  if(s2=='C')j=3;
  if(s2=='D')j=4;
  if(s2=='E')j=5;
  if(s2=='F')j=6;
  
  if(i>j)cout<<'>'<<endl;
  if(i<j)cout<<'<'<<endl;
  if(i==j)cout<<'='<<endl;
}


Measured memory_bytes: 256
program string_transformation
  implicit none
  character(200000) :: s, t
  integer :: n, i, j, a, b
  logical :: x(26,26) = .false.
  read(*,*) s
  read(*,*) t
  n = len_trim(s)
  do i = 1, n
    x(ord(s(i:i)),ord(t(i:i))) = .true.
  end do
  do i = 1, 26
    a = 0
    b = 0
    do j = 1, 26
      if (x(i,j)) a = a+1
      if (x(j,i)) b = b+1
    end do
    if (a > 1 .or. b > 1) then
      write(*,'(a)') "No"
      stop
    end if
  end do
  write(*,'(a)') "Yes"
contains
  integer function ord(s)
    character(1), intent(in) :: s
    ord = ichar(s)-96
  end
end program string_transformation

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();

  bool flag1 = false;
  bool flag = false;
  int ind = 0;
  for(int i = 0;i < n - m + 1; i ++){
    flag = false;
    for(int j = 0; j < m; j ++){
      if(!(s[i + j] == t[j] || s[i + j] == '?')){
	// cout << j << endl;
	flag = false;
	break;
      }else{flag = true;}
    }
    // cout << s.substr(i,m) <<" " << flag<< endl;
    if(flag){
      flag1 = true;
      ind = i;
    }
  }
  if(!flag1){
    cout <<"UNRESTORABLE" << endl;
    return 0;
  }
  for(int i = ind;i < ind + m;i ++){
    s[i] = t[i - ind];
  }

  REP(i,n){
    if(s[i] == '?'){
      s[i] = 'a';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, b[1003] = {}, z = 0, c[10] = {}, d[10] = {}, e[10] = {};
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) c[s[i] - '0']++;
    for (int i = 0; i < n; i++) {
        d[s[i] - '0']++;
        for (int j = 0; j < 10; j++) if (e[j]) {
            for (int k = 0; k < 10; k++) if (c[k] != d[k]) {
                //cout << i << ' ' << j << ' ' << k << '\n';
                b[j * 100 + k * 10 + s[i] - '0'] = 1;
            }
        }
        e[s[i] - '0'] = 1;
    }
    for (int i = 0; i < 1000; i++) z += b[i];
    cout << z;
}


Measured memory_bytes: 384
A, B, Q = gets.split.map(&:to_i)

s = []
A.times do
  s << gets.to_i
end
t = []
B.times do
  t << gets.to_i
end
Q.times do
  x = gets.to_i
  sr = s.bsearch_index { |d| d >= x }
  tr = t.bsearch_index { |d| d >= x }

  sl = nil
  if sr.nil?
    sl = s.size - 1
  elsif sr > 0
    sl = sr - 1
  end

  tl = nil
  if tr.nil?
    tl = t.size - 1
  elsif tr > 0
    tl = tr - 1
  end

  result = []
  [sl, sr].each do |si|
    [tl, tr].each do |ti|
      next if si.nil? || ti.nil?

      result << (s[si] - x).abs + (t[ti] - s[si]).abs
      result << (t[ti] - x).abs + (s[si] - t[ti]).abs
    end
  end
  puts result.min
end



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

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

    double res;
    if(a * a * b < 2 * x){
        res = atan(2 * (b - 1.0 * x / (a * a)) / a);
        printf("%.20f\n", res * 180 / (atan(1) * 4));
    } else {
        res = atan(2.0 * x / (a * b * b));
        printf("%.20f\n", 90 - res * 180 / (atan(1) * 4));
    }

    return 0;
}


Measured memory_bytes: 128
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int W,H;cin >> W >> H;
    double X,Y;cin >> X >> Y;
    double w = W,h = H;
    cout << fixed << setprecision(10) << (w*h)/2.0 << endl;
    if(X != w/2 || Y != h/2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, K) = Read2Longs();
            var A = ReadLongs();

            var dicCount = new Dictionary<long, long>();
            foreach (var item in A)
            {
                if (!dicCount.ContainsKey(item))
                {
                    dicCount.Add(item, 0);
                }
                dicCount[item]++;
            }

            var takeCount = dicCount.Count - K;
            return dicCount.Select(x => x.Value).OrderBy(x => x).Take((int)takeCount).Sum();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 57460
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i=0; i<n; i++) cin >> nums[i];
    int m;
    cin >> m;
    vector<vector<int>> dr(m, vector<int>(2));
    for (int i=0; i<m; i++) cin >> dr[i][0] >> dr[i][1];
    int sum = 0;
    for (int i=0; i<n; i++)
        sum += nums[i];
    for (int i=0; i<m; i++) {
        cout << sum - nums[dr[i][0]-1] + dr[i][1] << endl;
    }
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}  

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int,int> P;

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

    vector<int> e_out[n];
    vector<int> deg(n,0);
    for(int i=0; i<m; ++i) {
        int a,b;
        cin >> a >> b;
        e_out[a-1].push_back(b-1);
        ++deg[b-1];
    }

    queue<int> q;
    for(int i=0; i<n; ++i) {
        if(deg[i]==0) q.push(i);
    }

    bool flag=false;
    vector<int> ans;

    while(!q.empty()) {
        if(q.size()!=1) flag=true;
        int p=q.front(); q.pop();
        ans.push_back(p);
        for(auto x : e_out[p]) {
            --deg[x];
            if(deg[x]==0) q.push(x);
        }
    }

    for(int i=0; i<n; ++i) cout << ans[i]+1 <<  endl;
    cout << (flag?1:0) << endl;

    return 0;
}

Measured memory_bytes: 3788
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string s;
const int maxN = 1e5 + 10;
bool can[maxN];
string f[4] = {"dream", "dreamer", "erase", "eraser"};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> s;
    can[0] = true;
    for (int i = 0; i < s.size(); i++) {
        if (!can[i]) continue;
        for (int j = 0; j < 4; j++) {
            if (i + j <= s.size() && s.substr(i, f[j].size()) == f[j]) {
                can[i + f[j].size()] = true;
            }
        }
    }
    cout << (can[s.size()] ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<utility>
#include<vector>

#define MOD   998244353
#define F_MAX 333333

// numer/denom、もしくはそれと合同(MODを法として)なものを返す
long long devide_mod(long long numer, long long denom)
{
	// 割り切れる場合は普通に返す
	if (numer % denom == 0)
	{
		return numer / denom;
	}
	/* フェルマーの小定理
	* p is prime,(b,p)=1 ⇒   b^(p-1)≡1   (mod p)
	*                    ⇒ a*b^(p-1)≡a   (mod p)
	*                    ⇒ a*b^(p-2)≡a/b (mod p) ← これを畳み込み累乗を使って計算して返す
	*/
	long long index = MOD - 2, power = 1;
	while (index > 0)
	{
		if (index & 1)
		{
			power *= denom;
			power %= MOD;
		}
		denom *= denom;
		denom %= MOD;
		index >>= 1;
	}
	return numer * power % MOD;
}
// nCrをMODで割ったあまりを返す
long long combination_mod(long long n, long long r)
{
	//　例外処理
	/*if (n < r || n < 0 || r < 0)
	{
		throw - 1;
	}*/
	//　階乗(をMODで割ったあまり)を計算する
	static std::vector<long long>factorial_mod(F_MAX);
	if (factorial_mod[0] != 1)
	{
		factorial_mod[0] = 1;
		for (long long i = 1; i < F_MAX; i++)
		{
			factorial_mod[i] = (factorial_mod[i - 1] * i) % MOD;
		}
	}

	long long numerator = factorial_mod[n];
	long long denominator = (factorial_mod[r] * factorial_mod[n - r]) % MOD;
	return devide_mod(numerator, denominator);
}

signed main()
{
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for (long long x = 0; x <= n; x++)
	{
		if ((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if (0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for (auto i : pairs)
	{
		ans += combination_mod(n, i.first) * combination_mod(n, i.second) % MOD;
		ans %= MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7552
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,m;
int a[maxn];
int b[maxn];

int main()
{
	scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	scanf("%d",&m); for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(a+1,a+n+1); sort(b+1,b+m+1);
	
	int pos=1;
	for(int i=1;i<=m;i++)
	{
		while(pos<=n&&a[pos]<b[i]) pos++;
		if(pos>n||a[pos]!=b[i]) { puts("NO");return 0; }
		pos++;
	}
	puts("YES");
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> s = a;
  
  sort(s.rbegin(),s.rend());
  
  rep(i,n){
    if(a[i]==s[0]){
      cout << s[1] <<endl;
    }else cout << s[0] <<endl;
  }
}


Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>


using namespace std;

bool char_find (vector<char>& arr, char& str){
    for (int i = 0; i < arr.size(); i++){
        if (arr[i] == str)
            return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    int count = 0; int M = 0;
    vector<char> acgt{'A', 'C', 'G', 'T'};
    for (int i = 0; i < s.size(); i++){
        if (char_find(acgt, s[i])){
            count++;
            M = max(M, count);
        }
        else
            count = 0;
    }
    cout << M << endl;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> v(3); rep(i, 0, 3) {
		cin >> v[i];
	}
	cout << (char)(max_element(all(v)) - v.begin() + 'A') << endl;
	return 0;
}


Measured memory_bytes: 3092
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int cnt = 1;
       
        for(int i = 0;i < n-1;i++){
            if(s[i] != s[i+1])
            cnt++;
        }
        System.out.println(cnt);
    }
}

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

int x[101];
int S[101][101];

int solve(int n){
  for(int i = 2; i <= n; i++){
    for ( int l = 1; l <= n - i + 1 ; l++){
      // l は 始まりの数
      int j = l + i - 1; // 終わりの数
      S[l][j] = 100000;
      for ( int k = l; k <= j-1; k++){
        S[l][j] = min(S[l][j], S[l][k] + S[k+1][j] + x[l-1]*x[k]*x[j]);
      }
    }
  }

 return S[1][n];
}

int main(){
  int n;
  cin >> n;
  int r, c;
  for ( int i = 0; i < n; i++){
    cin >> r >> c;
    if(i == 0){
      x[0] = r;
      x[1] = c;
   } else {
     x[i+1] = c;
   }
  }

  // init
  for ( int i = 0; i <= n; i++){
    S[i][i] = 0;
  }

  cout << solve(n) << endl;

  return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N;
  cin >> N;
  P p[MAX*2];
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> p[i].sc >> p[i].ft;
  }
  sort(p, p+N);
  
  ll ti=0;
  for(i=0; i<N; i++) {
    ti+=p[i].sc;
    if(ti>p[i].ft) {
      pt("No");
      return 0;
    }
    
  }
  pt("Yes");
  
}












Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    List<Character> list1 = new ArrayList<>();

    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();

    for(int i = 0; i < n ; i++){
        list1.add(s.charAt(i));
        list1.add(t.charAt(i));
    }

    List<String> change = list1.stream().map(e -> String.valueOf(e)).collect(Collectors.toList());
    //System.out.println(list1);
    //System.out.println(String.join("",change));
    System.out.println(String.join("", change));


        
    
	}
}

Measured memory_bytes: 28624
k, x = map(int, input().split())
res = []
N = 1000000
if x - k + 1 < -N:
	res = list(range(-N, -N + k))
elif x + k - 1 > N:
	res = list(range(N - k + 1, N + 1))
else:
	res = list(range(x - k + 1, x + k))
print(" ".join([str(x) for x in res]))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> G[100000];
ll dist[100000][3];
int main() {
	int N,M;
	cin>>N>>M;
	for(int i=0;i<M;i++) {
		int u,v;
		cin>>u>>v;u--;v--;
		G[u].push_back(v);
	}
	int S,T;
	cin>>S>>T;S--;T--;
	fill((ll*)dist,(ll*)(dist+N),1LL<<60);
	dist[S][0]=0;
	deque<P> Q;
	Q.emplace_back(S,0);
	while(!Q.empty()) {
		P now=Q.front();Q.pop_front();
		for(int to:G[now.first]) {
			ll cost = dist[now.first][now.second] + (now.second == 0);
			if(dist[to][(now.second+1)%3] > cost) {
				dist[to][(now.second+1)%3] = cost;
				if(now.second == 0) Q.emplace_back(to,1);
				else Q.emplace_front(to,(now.second+1)%3);
			}
		}
	}
	if(dist[T][0] == 1LL<<60) cout<<-1<<endl;
	else cout<<dist[T][0]<<endl;
}

Measured memory_bytes: 8064
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	auto S = IN<string>();
	auto T = IN<string>();
	int ans = 0;
	REP(i, 3)
	{
		if (S[i] == T[i])
			ans++;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main() {
    int a;
    int b;
    int max;

    cin >> a >> b;

    if ((a + b) >= (a - b)) {
        max = a + b;
    } else {
        max = a - b;
    }

    if ((a * b) >= max) {
        max = a * b;
    }

    cout << max;
}

Measured memory_bytes: 256
N, M, K = list(map(int,input().split()))
m = 998244353

# コンビネーション _{N} C_n (n=1,...,N)をmod mで計算する
# フェルマーの小定理を利用する
# 計算量はO(max(N,m))
class combination_mod: # mod mのもとでのN C nを計算するクラス，計算量はO(N)
    def __init__(self,N,m):
        self.N = N
        self.m = m
        self.N_factorials = [1 for _ in range(N)] # 1!からN!までをmod mで計算したリスト
        for n in range(1,N):
            self.N_factorials[n] = (self.N_factorials[n-1] * (n+1)) % m
        N_factorial_inv = pow(self.N_factorials[N-1], m-2, m) # N!^{-1} = N!^{m-2} (mod m)を計算する，高速
        self.N_factorials_inv = [1 for _ in range(N)] # N!^{-1}から1!^{-1}までをmod mで計算したリスト
        self.N_factorials_inv[0] = N_factorial_inv
        for n in range(1,N): # nは1からN-1まで走る
            self.N_factorials_inv[n] = (self.N_factorials_inv[n-1] * (N-n+1)) % m
    def calc(self,n): # N C n (mod m)を計算する，計算量はO(1)
        if n == 0 or n == self.N:
            return 1
        else:
            c = (self.N_factorials[self.N-1] * self.N_factorials_inv[self.N-n]) % self.m # ここが N! * n!^{-1}
            c = (c * self.N_factorials_inv[n]) % self.m # ここが * (N-n)!^{-1}
            return c
if N == 1:
    print(M%m)
    exit()
elif M == 1:
    if N > K+1:
        print(0)
    else:
        print(1)
    exit()
else:
    func = combination_mod(N-1,m)
    ans = 0
    for k in range(K+1):
        ans_temp = M
        ans_temp = (ans_temp * func.calc(k)) % m
        ans_temp = (ans_temp * pow(M-1,N-1-k,m)) % m
        ans += ans_temp
        ans = ans % m
    print(ans)


Measured memory_bytes: 24852
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
A.insert(0,"#"*(W+2))
for i in range(1,H+1):
    A[i] = "#"+A[i]+"#"
A.append("#"*(W+2))
for i in range(H+2):
    print(A[i])

Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int h = ni();
        int w = ni();
        String[][] s = new String[h][w];

        for (int i = 0; i < h; i++) {
            s[i] = nsa(w);
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j].equals("snuke")) {
                    out.println("" + (char)(j + 'A') + (i + 1));
                }
            }
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8532