akhauriyash/Code-Regression huggingface dataset:
print('Yes')

from collections import deque  

n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

ans = [-1] * (n+1)
ans[0] = 0
ans[1] = 0

d = deque()
d.append(1)

while d:
    v = d.popleft()
    for i in graph[v]:
        if ans[i] != -1:
            continue
        ans[i] = v
        d.append(i)

print(*ans[2:], sep="\n")

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

int main(){
    int n, u, k, tmp;
    scanf("%d", &n);
    int graph[n][n];
    for(int i = 0;i < n;i++){
        for(int j = 0; j < n; j++) graph[i][j] = 0;
    }
    
    for(int i = 0; i < n; i++){
        scanf("%d %d", &u, &k);
        for(int j = 0; j < k; j++){
            scanf("%d", &tmp);
            graph[u - 1][tmp - 1] = 1;
        }
    }
    
    for(int i = 0;i < n;i++){
        for(int j = 0; j < n - 1; j++){
            printf("%d ", graph[i][j]);
        }
        printf("%d\n", graph[i][n - 1]);
    }
}


Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,m,i,src,dest,count=0;
	scanf("%d %d",&n,&m);
	int arrh[n+1];
	int arr[n+1];
	for(i=0;i<=n;++i)
	{
		arr[i]=0;
	}
	for(i=1;i<=n;++i)
	{
		scanf("%d",&arrh[i]);
	}
	for(i=0;i<m;++i)
	{
		scanf("%d %d",&src,&dest);
		if(arr[src]==0 || arr[src]<arrh[dest])
			arr[src]=arrh[dest];
		if(arr[dest]==0 || arr[dest]<arrh[src])
			arr[dest]=arrh[src];
	}
	for(i=1;i<=n;++i)
	{
		if(arrh[i]>arr[i])
			count++;
	}
	printf("%d\n",count);
	return 0;
}
	
	


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

int main(){
  int n, a[2000];
  long long b=0, c=0, k, sumk=0, sumkk=0, ans=0, bb=1000000007;
  cin >> n >> k;
  REP(i,n) cin>>a[i];
  sumk = (((k+1)%bb)*(k%bb)/2)%bb;
  sumkk = ((k%bb)*((k-1)%bb)/2)%bb;
  
  REP(i,n) REP(j,n){
    if(i>j && a[i]>a[j]) b++;
    if(i<j && a[i]>a[j]) c++;
  }
  
  ans = ((c*sumk)%bb + (b*sumkk)%bb)%bb;
  cout << ans <<endl;  
}

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



int main() {
    vector<char> c1(3),c2(3),c3(3);
    rep(i,3) cin >> c1[i] >> c2[i] >>c3[i];
    cout << c1[0] << c2[1] <<c3[2] << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b; cin>>a>>b;
  string s; cin>>s;
  bool ans=true;
  if(s.length()!=a+b+1) ans=false;
  if(ans){
    string sb=s.substr(0,a);
    for(char c:sb){
      if('0'>c||c>'9'){
        ans=false; break;
      }
    }
  }
  if(ans){
    if(s.substr(a,1)!="-") ans=false;      
  }
  if(ans){
    string sb=s.substr(a+1,b);
    for(char c:sb){
      if('0'>c||c>'9'){
        ans=false; break;
      }
    }
  }
  cout<<(ans?"Yes":"No");
}

Measured memory_bytes: 256
s = input()
a1 = a2 = 0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='1':a1+=1
        else:a2+=1
    else:
        if s[i]=='0':a1+=1
        else:a2+=1
print(min(a1,a2))

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

int main()
{	
	int n;
	bool f = 0;

	while (cin >> n) {
		int a[5];
		string s[8];

		if (!f)
			f = 1;
		else
			cout << endl;

		for (int i = 0; i < 5; i++) {
			a[4 - i] = n % 10;
			n /= 10;
		}

		for (int i = 0; i < 5; i++) {
			if (a[i] > 4) {
				s[0] += " ";
				s[1] += "*";
			}
			else {
				s[0] += "*";
				s[1] += " ";
			}
				
			s[2] += "=";

			if (a[i] % 5 == 0)
				s[3] += " ";
			else
				s[3] += "*";

			if (a[i] % 5 == 1)
				s[4] += " ";
			else
				s[4] += "*";

			if (a[i] % 5 == 2)
				s[5] += " ";
			else
				s[5] += "*";

			if (a[i] % 5 == 3)
				s[6] += " ";
			else
				s[6] += "*";

			if (a[i] % 5 == 4)
				s[7] += " ";
			else
				s[7] += "*";
		}
		
		for (int i = 0; i < 8; i++)
			cout << s[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.nextLine();
			StringBuilder sb = new StringBuilder(s);

			int index = sb.indexOf("B");
			while (true) {
				if (index == -1) {
					break;
				}

				sb = sb.deleteCharAt(index);
				if (index != 0) {
					sb = sb.deleteCharAt(index - 1);
				}

				index = sb.indexOf("B");
			}

			System.out.println(sb.toString());

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 21844
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = (1 << 21) + 5;
int dp[25][N] ;

void solve(int test) {
	int n; cin >> n ;
	int a[n][n]; rep(i,0,n) rep(j,0,n) cin >> a[i][j] ;

	dp[0][0] = 1 ;

	for(int i = 1 ; i <= n ;++i ){
		for(int mask = 1 ; mask < (1 << n) ; ++mask) {
			if(__builtin_popcount(mask) == i) {
				for(int j = 0 ; j < n ; ++j ) {
					if(a[i-1][j] and mask&(1 << j)) dp[i][mask] = (dp[i][mask] + dp[i-1][mask-(1 << j)])%mod ;
				}
			}
		}
	}

	cout << dp[n][(1<<n)-1] ; 
}

int32_t main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif   

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 167360
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int half = (n-1)/2;
    int halfp = (n+3)/2;
    bool ans = true;
    for(int i=0; i<half ;i++)
    {
        if (s[i] != s[n-1-i]) ans = false;
    }

    for(int i=0; i<half ;i++)
    {
        if(s[i] != s[half-1-i]) ans = false;
    }
    
    for(int i=0; i<half; i++)
    {
        if(s[half+1+i] != s[n-1-i]) ans = false;
    }

    if(ans) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int x,y,z;
		scanf("%d %d %d", &x, &y, &z);
	
	if (( x==y && x==z && y==z) || (x!=y && x!=z && y!=z)){
			printf("No");
	}
	else {
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main(void) {

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if( a[2] == a[0] + a[1] ) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,r,d,count=0;
  cin>>l>>r>>d;
  
  for(int i=l;i<=r;i++)
  {
    if(i%d==0) count++;
  }
  
  cout<<count<<endl;
  
 return 0; 
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int memo[100];
int fibonacci(int n){
    for(int i = 2; i <= n; i++){
        memo[i] = memo[i -1] + memo[i - 2];
    }
    return memo[n];
}

int main(){
    int n;
    cin >> n;
    memo[0] = 1;
    memo[1] = 1;
    int res = fibonacci(n);
    cout << res << endl;
}


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

int main() {

    int N ;

    cin >> N ;

    string S , T ;

    cin >> S >> T ;

    for(int i = 0 ; i < N ; i++){

        cout << S.at(i) << T.at(i) ;

    }

    cout << endl;
        

}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int a, b, c;
int main() {
	cin >> a >> b >> c;
	cout << max({ a + b * 10 + c, a * 10 + b + c ,a + b + c * 10 }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<char> v( N );
	rep( i, N ) cin >> v[i];

	rep( i, N )
	{
		if ( v[i] == 'Y' )
		{
			cout << "Four" << endl;
			return ( 0 );
		}
	}

	cout << "Three" << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  int q; 
  cin>>q;
  string str;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1)
      swap(str,s);
    else{
      int f; char c;
      cin>>f>>c;
      if(f==1)
        str+=c;
      else
        s+=c;
    }
  }
  reverse(all(str));
  str+=s;
  cout<<str<<endl;
}

Measured memory_bytes: 1128
#include<cstdio>

int main(void){
int n,i;

scanf("%d",&n);
int a[n];
for(i=1;i<=n;i++){
scanf("%d",&a[i-1]);
};
//printf("%d",a[0]);
//printf("%d",a[1]);
//printf("%d",a[2]);
//printf("%d",a[3]);
//printf("%d",a[4]);
for(i=n;i>=2;i--){
printf("%d ",a[i-1]);
};
printf("%d\n",a[0]);

return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b,c,d;
    string s;cin>>s;
    a=s[0]-'0'; b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
    if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    else cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}


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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll mx;
  if (a >= k) {
    mx = k;
    cout << mx << endl;
    return 0;
  } else {
    k -= a;
  }

  if (b >= k) {
    cout << a << endl;
    return 0;
  } else {
    k -= b;
  }

  if (c >= k) {
    cout << a - k << endl;
    return 0;
  } else {
    cout << a - c << endl;
    return 0;
  }
  return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){ 
      a=b; 
      b=r; 
      r=a%b; 
    }
    return b;
}
int main(){
  ll n,x;cin>>n>>x;
  ll g;
  for(int i=0;i<n;i++){
    ll num;cin>>num;
    if(i==0){
      g = abs(num-x);
    }else{
      g = gcd(abs(num-x),g);
    }
  }
  cout<<g<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}
ll mp[Max+10];

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


    cin>>n;

    ll ara[n+1];



    for(i=0; i<n; i++)
    {
        cin>>ara[i];

        sum+=ara[i];

        mp[ara[i]]++;
    }

    cin>>t;
    while(t--)
    {
      cin>>a>>b;

      sum-=(mp[a]*a);

      sum+=(mp[a]*b);

      mp[b]+=mp[a];

      mp[a]=0;

      cout<<sum<<endl;


    }















}


Measured memory_bytes: 5176
import sys

INF = 1000000007

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def nal(): return list(map(int, stdin.readline().split()))
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

N = ni()
x = nal()
x.insert(0, 0)

n = 1
c = 0
a = 1

for i in range(N):
    t = x[i+1] - x[i] - 1
    c = c+1
    if(t > 1):
        n = n+t-1
    elif(t == 0):
        n = n-1
        if(n == -1):
            n = 1
            a = a*c
            c = c-1

for i in range(1, c+1):
    a = a*i%INF

print(a % INF)

Measured memory_bytes: 14468
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    while (s.size() >= 5) {
        string last5 = s.substr(s.size() - 5, 5);
        if (last5 == "dream" || last5 == "erase") {
            s.erase(s.size() - 5, 5);
        } else if (s.size() >= 6) {
            string last6 = s.substr(s.size() - 6, 6);
            if (last6 == "eraser") {
                s.erase(s.size() - 6, 6);
            } else if (s.size() >= 7) {
                string last7 = s.substr(s.size() - 7, 7);
                if (last7 == "dreamer") {
                    s.erase(s.size() - 7, 7);
                } else
                    break;
            } else
                break;
        } else {
            break;
        }
    }
    if (s.size() == 0)
        cout << "YES"
             << "\n";
    else
        cout << "NO"
             << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int ans = N;
    int x = N / 9;
    rep(i, x+1){
        int total = 0;
        int x = i;
        int y = (N - i * 9) / 6;
        int z = (N - i * 9) % 6;
        while(x != 0){
            total += x % 9;
            x /= 9;
        }
        while(y != 0){
            total += y % 6;
            y /= 6;
        }
        total += z;
        if (total < ans) {
            ans = total;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void)
{
	int A,B;
	cin >> A>>B;
	if (A <= 8 && B <= 8)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int n,k,a,b,vis[N];
vector<int> g[N];

int mul(int x, int y) {

    return (1LL*x*y)%mod;

}

int dfs(int u, int par) {

    vis[u] = 1;

    int ret = 1, l = k - 1 - par;

    for(auto v:g[u]) {

        if(!vis[v]) {
            ret = mul(mul(ret,l--),dfs(v,1));
        }

    }

    return ret;

}

int main() {

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

    cin >> n >> k;

    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }

    cout << mul(k,dfs(1,0)) << '\n';

    return 0;
}

Measured memory_bytes: 9600
S = input()
x, y = map(int, input().split(' '))

F = [len(s) for s in S.split('T')]

memo_x = [set((F[0], ))]
memo_y = [set((0, ))]

for i, f in enumerate(F[2::2]):
    next_memo_x = set()
    for prev_x in memo_x[i]:
        next_memo_x.add(prev_x + f)
        next_memo_x.add(prev_x - f)
    memo_x.append(next_memo_x)

for i, f in enumerate(F[1::2]):
    next_memo_y = set()
    for prev_y in memo_y[i]:
        next_memo_y.add(prev_y + f)
        next_memo_y.add(prev_y - f)
    memo_y.append(next_memo_y)

if x in memo_x[-1] and y in memo_y[-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 359944
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            long[] T = new long[N];
            for (int i = 0; i < N; i++) {
                T[i] = in.nextLong();
            }

            long lcm = T[0];
            for (int i = 0; i < N; i++) {
                lcm = lcm(lcm, T[i]);
            }
            System.out.println(lcm);
        }
    }

    public static final long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static final long lcm(long a, long b) {
        return a * (b / gcd(a, b));
    }

}


Measured memory_bytes: 23892
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 200010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
static const ll max_d = 10000000000;


vector<vector<ll>> edge_list(max_n);
vector<pair<ll, ll>> distance_table;

template<typename T>
map<T, T> prime_factor(T N){
    map<T, T> res;
    ll i = 2;
    for(i=2;i*i<=N;i++){
        while(N%i==0){
            ++res[i];
            N /= i;
        }
    }
    if(N!=1){
        res[N] = 1;
    }
    return res;
}

void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N;
    sll(N);
    auto primes = prime_factor(N);

    ll ans = 0;
    for(auto prime_p: primes){
        ll prime = prime_p.first;
        ll power = prime_p.second;
        ll k;
        for(k=1;k*(k+1)<= 2*power;k++){
            continue;
        }
        // printf("prime = %lld, poewr = %lld\n", prime, k);
        ans += k - 1;
    }
    cout << ans <<endl;
    // cout << junkan<<endl;

    // ll index = (K % junkan.size());
    // printf("%lld\n", junkan[index]+1);
    

    // printf("%lld\n", ans);


    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 7396
#include<stdio.h>

int main(){
  int n,b,f,r,v;
  int NoP[4][3][10];
  int i,j,k;

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	NoP[i][j][k] = 0;
      }
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    NoP[b-1][f-1][r-1] += v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        printf("%2d",NoP[i][j][k]);
      }
      printf("\n");
    }
    if(i==3) return 0;
    printf("####################\n");
  }

}

  
  

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;

  int answer = 0;
  int tmp = 0;
  for (int i = 0; i < 3; i++) {
    if(s[i] == 'R') tmp++;
    else tmp = 0;
    answer = max(answer, tmp);
  }
  cout << answer << '\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[2][200][200],z[1000];
typedef pair<int,int> P;
 
int main(){
 
 
    while(scanf("%d %d",&n,&m),n){
	    
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
	    
	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
	    
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
				d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
			 }
		  }
	   }
	    
	   scanf("%d",&r);
	   for(int i=0;i<r;i++){
		  scanf("%d",&z[i]);
		  z[i]--;
	   }
	    
	   vector<vector<int> > dp(1000,vector<int>(200,INF));
	   dp[0][z[0]]=0;
 
	   //int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
						    
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
 
	   printf("%d\n",*min_element(dp[r-1].begin(),dp[r-1].end()));
	    
    }
}

Measured memory_bytes: 4108
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

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

  cout << N*M << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  int count=1;
  for(int i = 1; i < N; i++){
    if(S[i] != S[i-1]) count ++;
  }
  cout <<N+min(-1,-count+2*K)<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
map<ll,ll>mp;
int main()
{
    ll x,n,pos,con=1000,non=1000;
    cin>>x>>n;
    if(n==0)
    {
        cout << x << endl;
        return 0;
    }
    com(i,n)
    {
        ll a;
        cin>>a;
        mp[a]=1;
    }
    for(int i=x; i<=101; i++)
    {
        if(mp[i]==0)
        {
            con=i-x;
            pos=i;
            break;
        }
    }
    for(int i=x-1; i>=0; i--)
    {
        if(mp[i]==0)
        {
            non=x-i;
            if(non<=con)
                pos=i;
            break;
        }
    }
    cout << pos << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << setw(4); cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll n, x=0, m=0, y=0, d=1, k=mod;
		cin >> n >> m;
		ll a[n + 1][m + 1] = {};
		char c;
		a[1][1] = 1;
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				cin >> c;
				if(c == '.')
					a[i][j] += a[i - 1][j] + a[i][j - 1];

				a[i][j] %= mod;
			}
		}
		cout << a[n][m];
	}
}

Measured memory_bytes: 8064
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int h=sc.nextInt();
		System.out.println((a+b)*h/2);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> s;
    string brank = "";
    for(int i = 0; i < W+2; i++)brank+="-";
    s.push_back(brank);
    for(int i = 0; i < H; i++){
        string tmp;
        cin >> tmp;
        tmp = "|" + tmp + "|";
        s.push_back(tmp);
    }
    s.push_back(brank);

    for(int i = 1; i < s.size() - 1; i++){
        for(int j = 1; j < s[i].size()-1; j++){
            if(s[i][j] == '#'){
                if(s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

const int MAXN = 100000;

int h[MAXN];
int cost[MAXN];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &h[i]);
    cost[0] = 0;
    cost[1] = std::abs(h[1] - h[0]);

    for (int i = 2; i < n; ++i)
        cost[i] = std::min(std::abs(h[i] - h[i - 1]) + cost[i - 1], std::abs(h[i] - h[i - 2]) + cost[i - 2]);

    printf("%d\n", cost[n - 1]);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], B[MAXN], C[MAXN*2];

inline void change(int x, int y){
	x+=MAXN;
	if (MAXN<x) ans-=(C[x]==0);
	C[x]+=y;
	if (MAXN<x) ans+=(C[x]==0);
}

inline void add(int x){
	change(x-B[x], +1);
	B[x]++;
}

inline void rem(int x){
	B[x]--;
	change(x-B[x], -1);	
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	ans=n;
	for (int i=1; i<=n; i++) cin>>A[i], add(A[i]);
	while (m--){
		cin>>x>>y;
		rem(A[x]);
		A[x]=y;
		add(A[x]);
		cout<<ans<<"\n";
	}
	
	return 0;
}
/*
4 1
1 4 4 4
2 1

4 0
1 1 4 4

*/

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

using namespace std;

class dic {

public:
	dic()
		: vctc_(26, 0)
	{
	};

	int getnum(char cs){

		int i = 0;
		for (auto& elem : vctc_){
			if (elem == 0){
				elem = cs;
				return i;
			}
			else if (elem == cs){
				return i;
			}
			++i;
		}
		return 0; //あり得ないが。
	}

private:
	std::vector<char> vctc_;
};

int main()
{
	std::string S;
	std::string T;

	cin >> S;
	cin >> T;

	std::string::const_iterator t = T.begin();
	std::string::const_iterator s = S.begin();
	dic ds;
	dic dt;
	for (int i = 0; i < S.size(); ++i){
		if (ds.getnum(*s) != dt.getnum(*t)) {
			cout << "No";
			return 0;
		}
		++t;
		++s;
	}
	cout << "Yes";

	return 0;
}

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

using namespace std;

vector<int> G[100000];

bool flag;
bool visited[100000];
bool fennec[100000];
bool sunuke[100000];
int cnt;

int dist_s[100000];
int dist_f[100000];

void dfs(int s, int t, int d, int dist[], bool p[]){
    //cout << s << endl;
    visited[s] = true;
    dist[s] = d;
    if(s == t) flag = true;
    if(flag){
        cnt++;
        p[s] = true;
        //cout << s << endl;
    }
    for(int i = 0; i < G[s].size();i++){
        if(!visited[G[s][i]]) dfs(G[s][i], t, d+1, dist, p);
    }
    if(s == t) flag = false;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N-1 ;i++){
        visited[i] = false;
        sunuke[i] = false;
        fennec[i] = false;
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    flag = false;
    dfs(0, N-1, 0, dist_f, sunuke);
    //int s = cnt;
    
    cnt = 0;
    for(int i = 0; i < N ;i++){
        visited[i] = false;
    }
    flag = false;
    dfs(N-1, 0, 0, dist_s, fennec);
    //int f = cnt;
    int s = 0;
    int f = 0;
    for(int i = 0; i < N; i++){
        //cout << dist_f[i] << ' ' << dist_s[i] << endl;
        if(sunuke[i]) s++;
        else if(fennec[i]) f++;
        else{
            if(dist_f[i] <= dist_s[i]) f++;
            else s++;
        }
    }
    //cout << f << ' ' << s << endl;
    if(f > s) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 14720
#include <algorithm>
#include <cmath>
#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--)

int inva[200'000];

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        int j;
        cin >> j;
        inva[j - 1] = i + 1;
    }

    int64_t result = 0;
    set<int> s;
    s.insert(0);
    s.insert(n + 1);

    rep(i, n)
    {
        auto ub = s.upper_bound(inva[i]);
        int R = *ub;
        ub--;
        int L = *ub;
        result += (int64_t)(i + 1) * (inva[i] - L) * (R - inva[i]);
        s.insert(inva[i]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> a(N);
    deque<long long> b;

    for(int i = 0;i < N;i++){
        cin >> a[i];
    }

    for(int i = 0;i < N;i++){
        if(i % 2 == 0){
            b.push_front(a[i]);
        }else{
            b.push_back(a[i]);
        }
    }
    if (N % 2 == 0){
        for(int i = b.size() - 1;i >= 0;i--){
            cout << b[i] << " ";
        }
    }else {
        for(int i = 0; i < b.size(); i++){
            cout << b[i] << " ";
        }
    }

    return 0;
}


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

int main()
{
  int n;
  scanf("%d",&n);
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    scanf("%lld",&(a[i]));
  }
  map<long long,int> M;
  long long ans=0ll;
  M[0]=1;
  long long S=0ll;
  for(int i=0;i<n;i++){
    S+=a[i];
    if(M.find(S)!=M.end()){
      ans+=M[S];
      M[S]++;
    }
    else{
      M[S]=1;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A.at(i);

    set<int> AC;
    for(int i:A) AC.insert(i);

    if(A.size()==AC.size()) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 10368
x, n = map(int, input().split())

ret = 0
diff = 10 ** 9

if n == 0:
    s = input()
    print(x)
    exit()
else:
    p = set(list(map(int, input().split())))
    for i in range(102):
        if i in p:
            continue
        else:
            tmp_d = abs(x - i)
            if diff > tmp_d:
                ret = i
                diff = tmp_d

print(ret)


Measured memory_bytes: 61892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		int cnt = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)==t.charAt(i))
				cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string S;
	cin >> S;
	S[5] =  S[13] = ' ';
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if N>0:
  p = [int(i) for i in input().split()]
else:
  p = [-1]
  
p = sorted(p)
#print(p)
 
try:
  idx=p.index(X)
  flag=False
  for i in range(X+1):
    for o in [-1,+1]:
      if idx+(i*o) < 0 or idx + (i*o) >= N:
        print(X+(i*o))
        flag=True
        break
      elif X+(i*o)!=p[idx+(i*o)]:
        print(X+(i*o))
        flag=True
        break
    if flag:
      break
except:
  print(X)

Measured memory_bytes: 9216
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64_t
#endif

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int n;
int a[MAXN];

int f(int x) {
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += abs(i[a] - x);	
	}             
	return sum;
}
int b[MAXN];

 main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
     n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = (b[i] = readInt()) - i;
    }
    sort(a + 1, a + 1 + n);
	cout << f(a[(n+1)/2]);
    return 0;
}

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

vector<vector<int>> left(int x, vector<vector<int>> square){
  int W = square[0].size();
  int H = square.size();
  for (int i=0; i<H; i++){
    for (int j=0; j<x; j++){
      square.at(i).at(j)=9;
    }
  }
  return square;
}

vector<vector<int>> right(int x, vector<vector<int>> square){
  int W = square[0].size();
  int H = square.size();
  for (int i=0; i<H; i++){
    for (int j=x; j<W; j++){
      square.at(i).at(j)=9;
    }
  }
  return square;
}

vector<vector<int>> down(int y, vector<vector<int>> square){
  int W = square[0].size();
  int H = square.size();
  for (int i=0; i<y; i++){
    for (int j=0; j<W; j++){
      square.at(i).at(j)=9;
    }
  }
  return square;
}

vector<vector<int>> up(int y, vector<vector<int>> square){
  int W = square[0].size();
  int H = square.size();
  for (int i=y; i<H; i++){
    for (int j=0; j<W; j++){
      square.at(i).at(j)=9;
    }
  }
  return square;
}

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> square (h, vector<int>(w,0));
  for (int N=1; N<=n; N++){
    int x,y,a;
    cin >> x >> y >> a;
    if (a==1) square = left(x,square);
    else if (a==2) square = right(x,square);
    else if (a==3) square = down(y,square);
    else square = up(y,square);
  }
  int area;
  for (auto raw:square){
    for(int p:raw){
      if(p == 0) area++;
    }
  }
  cout << area << endl;
}

Measured memory_bytes: 384
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    string S;
    cin >> S;

    int result = 0;

    int at = 0;
    for (; at < S.size(); ) {
        result++;

        auto j = at;

        while (j + 1 < S.size() && S[j + 1] == S[at])
            j++;

        at = j + 1;
    }

    cout << result - 1 << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> D(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++)
    {
        int d; cin >> d;
        mp[d]++;
    }
    int m; cin >> m;
    bool ok = true;
    for(int i = 0; i < m; i++)
    {
        int t; cin >> t;
        if(mp[t] == 0) ok = false;
        mp[t]--;
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int INF = 1e9;
constexpr long double eps = 1e-8;

int main() {
    int N;
    cin >> N;
    vector<int> cnt(100001);
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        for(int j = -1; j <= 1; ++j) {
            if(a + j < 0 || 100000 < a + j) {
                continue;
            }
            cnt[a + j]++;
        }
    }
    int res = 0;
    for(int i = 0; i < 100001; ++i) {
        if(cnt[res] < cnt[i]) {
            res = i;
        }
    }
    cout << cnt[res] << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
using namespace std;
int main() {
	string S;	cin >> S;
	int Cnum = 0;
	int Cpos = 0;
	bool isAllSmall = true;

	if (S[0] == 'A') {
		for (int i = 2; i < S.size() - 1; ++i) {
			if (S[i] == 'C') {
				Cnum++;
				Cpos = i;
			}
		}

		if (Cnum == 1) {
			for (int i = 1; i < S.size(); ++i) {
				if (i != Cpos) {
					if ((S[i] >= 'A') && (S[i] <= 'Z')) {
						isAllSmall = false;
					}
				}
			}
			if (isAllSmall) {
				cout << "AC" << endl;
				cin >> S;
				return 0;
			}
		}
	}
	cout << "WA" << endl;
	cin >> S;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int V[101][10001];
int v[101],w[101];
int main()
{
    int N,W;
    cin>>N>>W;
    
    for(int i=1;i<N+1;i++)
    {
        cin>>v[i]>>w[i];
    }
    
    for(int i=0;i<101;i++)
        V[i][0]=0;
    for(int i=0;i<10001;i++)
        V[0][i]=0;
    
    for(int i=1;i<N+1;i++)
    {
        for(int j=1;j<W+1;j++)
        {
            if(w[i]>j)
                V[i][j]=V[i-1][j];
            else
            {
                //V[i][j]=max(v[i]+V[i-1][j-w[i]],V[i-1][j]);
                V[i][j]=max(max(v[i]+V[i-1][j-w[i]],V[i-1][j]),v[i]+V[i][j-w[i]]);
            }

        }
    }
    cout<<V[N][W]<<endl;
}

Measured memory_bytes: 7008