akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;

int main() {
  map<int, int> count_word_num;
  int words[3];
  cin >> words[0] >> words[1] >> words[2];
  for (int i = 0; i < 3; i++) {
    count_word_num[words[i]]++;
  }
  cout << (count_word_num[5] == 2 && count_word_num[7] == 1 ? "YES" : "NO") << endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
}

Node treeMaximum(Node x){
}

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

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

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

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

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

  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;

}

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

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


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

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

  return 0;
}

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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
vv_ll A;
int main(){
  cin >> N;
  A.assign(N+10,v_ll(N+10,0));
  for (ll i=1;i<=N;i++){
    for (ll j=i+1;j<=N;j++){
      ll x=i,y=j,z=1;
      while (1){
        if ((x%2)!=(y%2)){A[i][j]=z;break;}
        else{x/=2;y/=2;z++;}
      }
    }
  }
  for (ll i=1;i<=N-1;i++){
    for (ll j=i+1;j<=N;j++){
      cout << A[i][j];
      if (i<N)cout << " ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b;
    cin >> a >> b;
    int res = a + b;
    if(res < 10)
        cout << res << endl;
    else
        cout << "error" << endl;
}


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

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
  LL n, k;
  cin >> n >> k;
  LL pom = n / k;
  n -= pom * k;
  LL res = n;
  res = min(res, k - n);
  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   int k=0,k1=0;
   for(int i=1;i<=n;i++)
   for(int j=i+1;j<=n;j++)
   {
       k=min(min(j-i,abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
	   a[k]++;	
   } 	
   for(int i=1;i<n;i++)
   cout<<a[i]<<endl;
}

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

using namespace std;
vector<vector<bool> > graph;

const long long INF = 1LL << 61;


int main(){
    int H, W, K;
    cin >> H >> W >> K;

    graph.assign(H, vector<bool>());


    for(int h=0; h<H; ++h){
        string s;
        cin >> s;
        for(int w=0; w<W; ++w){
            int flag = s[w] - '0';
            graph[h].push_back(flag);
        }
    }

    //答え
    long long ans = INF;

    //横の切り方はbit全探索2^H通り
    for(int bit=0; bit< (1 << (H-1)); ++bit){
        int group = 0;
        vector<int> id(H);
        //どのグループに属するかを決める
        for(int h=0; h<H; ++h){
            id[h] = group;
            if(bit >> h & 1){
                group++;
            }
        }
        group++;

        //各グループに今何個入っているか
        vector<vector<int>> group_nums(group, vector<int>(W));
        for(int h=0; h<H; ++h){
            for(int w=0; w<W; ++w){
                int group = id[h];
                if(graph[h][w] == true){
                    group_nums[group][w]++;
                }
            }
        }

        //縦に何回切るかを貪欲に計算
        bool skip = false;
        vector<vector<int>> group_cumsum(group, vector<int>(W));
        //縦の累積を初期化
        for(int i=0; i<group; ++i){
            group_cumsum[i][0] = group_nums[i][0];
        }

        //もし事前にグループがそもそも閾値を超えてたらそのbitの横の切り方はできないので、
        //調べない。
        for(int i=0; i<group; ++i){
            for(int w=0; w<W; ++w){
                if(group_nums[i][w] > K){
                    skip = true;
                }
            }
        }


        if(!skip){
            long long tate = 0;
            int w=1;
            //一個ずつ切るか見ていく
            for(w=0; w< W; ++w){
                bool is_cut = false;
                for(int i=0; i<group; ++i){
                    long long next_num = group_cumsum[i][w-1] + group_nums[i][w];
                    if(next_num > K){
                        is_cut = true;
                    }
                }

                if(is_cut == true){
                    //カットする
                    tate++;
                    //そうすると次の累積和はgraph[g][w]に初期化される.
                    for(int i=0; i<group; ++i){
                        group_cumsum[i][w] = group_nums[i][w];
                        
                    }                    
                }else{
                    //カットしない場合は累積和を増やす
                    for(int i=0; i<group; ++i){
                        group_cumsum[i][w] = group_cumsum[i][w-1] + group_nums[i][w];
                        
                    }
                }
            }
            //グループの分ける切り方はgroup-1,
            long long cut_num = tate + (group-1);
            ans = min(ans, cut_num);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3724
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
  string a,b;
  cin>>a>>b;
  bool jud=true;
  for (int i = 0; i < 3; i++) {
    if(a[i]!=b[2-i])jud=false;
  }
  if(jud)cout<<"YES\n";
  else cout<<"NO\n";

  return 0;
}


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


int main(){
    int n, T;
    int ans = 1001;
    cin >> n >> T;

    for(int i=0; i<n; ++i){
        int c, t;
        cin >> c >> t;
        if(t<=T){
            ans = min(ans, c);
        }
    }
    if(ans==1001){
        cout << "TLE" << endl;
    }else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = sqrt(n); i >= 0; i--) {
		if (sqrt(i * i) == i) {
			cout << i * i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N;
  int a[3];

  cin >> N;
  for(int i = N; i <= 999; i++){
    a[0] = i%10;
    a[1] = (i/10)%10;
    a[2] = i/100;
    if(a[0] == a[1] && a[1] == a[2]){
      cout << i << endl;
      return 0;
    }
  }
}

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

#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define FORD(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define Debug(x) cerr << #x << " = " << x << '\n';
#define HERE cerr << "HERE\n\n";
#define X first
#define Y second
#define pb push_back
#define FASTER { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

using namespace std;

typedef pair <int, int> ii;
typedef vector <int> vi;



int main(){
    FASTER
//    freopen("x.INP", "r", stdin);
//    freopen("x.OUT", "w", stdout);
    int64_t n;
    cin >> n;
    if (n%2) cout << 0;
    else{
        n /= 2;
        int64_t ans = 0;
        for (int64_t i = 5; i <= n; i *= 5){
            ans += n / i;
        }
        cout << ans;
    }
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG//空配列へのアクセスでエラー表示
using namespace std;
 
int main() {

  string S;
  bool hi = false;

  cin >> S;

  
  if(S=="hi"){
      hi = true;
  }

  if(S=="hihi"){
      hi = true;
  }

  if(S=="hihihi"){
      hi = true;
  }

  if(S=="hihihihi"){
      hi = true;
  }
  
  if(S=="hihihihihi"){
      hi = true;
  }
  
  if(hi){

     cout << "Yes" << endl;

  }
  
  else{

     cout << "No" << endl;

  }
 
   
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            if (B%A==0)
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(B - A);
            }
        }
    }
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  str s; cin >> s;
  if(c < d)
  {
    for(ll i = a;i < d;i++)
    {
      if(s[i - 1] == '#' && s[i] == '#') fin("No");
    }
    fin("Yes");
  }
  else
  {
    for(ll i = a;i < c;i++)
    {
      if(s[i - 1] == '#' && s[i] == '#') fin("No");
    }
    for(ll i = b - 1;i < d;i++)
    {
      if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') fin("Yes");
    }
    fin("No");
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var ymd = s.Split(' ').Select(i => int.Parse(i)).ToArray();
				var ymdi = int.Parse(string.Join("", ymd.Select((w, i) => w.ToString().PadLeft(i == 0 ? 4 : 2, '0')).ToArray()));
				if (ymdi < 18680908)
				{
					Console.WriteLine("pre-meiji");
				}
				else if (18680908 <= ymdi && ymdi <= 19120729)
				{
					Console.WriteLine("meiji {0} {1} {2}", (ymd[0] - 1867), ymd[1], ymd[2]);
				}
				else if (19120730 <= ymdi && ymdi <= 19261224)
				{
					Console.WriteLine("taisho {0} {1} {2}", (ymd[0] - 1911), ymd[1], ymd[2]);
				}
				else if (19261225 <= ymdi && ymdi <= 19890107)
				{
					Console.WriteLine("showa {0} {1} {2}", (ymd[0] - 1925), ymd[1], ymd[2]);
				}
				else if (19890108 <= ymdi)
				{
					Console.WriteLine("heisei {0} {1} {2}", (ymd[0] - 1988), ymd[1], ymd[2]);
				}
			}
		}
	}
}

Measured memory_bytes: 6012
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

count = 0
for i in range(len(A)):
    if (x >= 0):
        x = x - A[i]
        count += 1
    else:
        break

if (x > 0):
    print(count - 1)
elif(x == 0):
    print(count)
elif(x < 0):
    print(count - 1)


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

int main(int argc, char const *argv[])
{
	ll a, b; cin >> a >> b;
	cout << a * b / __gcd(a, b) << endl;
	return 0;
}


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

#define ll long long

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

  int x;
  cin >> x;
  int res = (2199 - x) / 200;
  cout << res << endl;
  
  return 0;
}


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

int main(){
        int n, c, w, v;
        cin >> n >> c;
        int a[n + 1][c + 1];
        vector<pair<int, int>> p(n);
        for(int i = 0; i < n; i++){
                cin >> v >> w;
                p[i] = make_pair(v, w);
        }
        for(int j = 0; j <= c; j++){
                for(int i = 0; i <= n; i++){
                        if(i == 0 || j == 0) a[i][j] = 0;
                        else if(j - p[i - 1].second < 0) a[i][j] = a[i - 1][j];
                        else a[i][j] = max(p[i -1].first + a[i - 1][j - p[i - 1].second], a[i - 1][j]);
                }
        }
        cout << a[n][c] << endl;
        return 0;
}



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

struct circle{
  int x, y, r;
  circle(int a, int b, int c){ x=a, y=b, r=c; }
  bool operator<(const circle right)const{
    return r<right.r;
  }
};

double get_dis_PP(int x1, int y1, int x2, int y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int n, dp[1005], xs, ys, xt, yt;
vector<circle> c;

signed main(){

  while(1){
  
    cin>>n;
    if(!n) break;
    cin>>xs>>ys>>xt>>yt;

    c.clear();
  
    for(int i=0;i<n;i++){
      int x, y, r;
      cin>>x>>y>>r;
      int flag=0;
      if(get_dis_PP(xs,ys,x,y)<r) flag^=1;
      if(get_dis_PP(xt,yt,x,y)<r) flag^=1;
      if(flag) c.push_back(circle(x,y,r));
    }
  
    sort(c.begin(),c.end());
  
    for(int i=0;i<c.size();i++) dp[i]=1;
        
    for(int i=0;i<c.size();i++)
      for(int j=i+1;j<c.size();j++){
	circle A=c[j], B=c[i];
	double d=get_dis_PP(A.x,A.y,B.x,B.y);
	if(d+B.r<A.r) dp[j]=max(dp[j],dp[i]+1);
      }
    
    int ans=0;
    
    for(int i=0;i<c.size();i++){
      ans=max(ans,dp[i]);
      for(int j=i+1;j<c.size();j++){
	circle A=c[j], B=c[i];
	double d=get_dis_PP(A.x,A.y,B.x,B.y);
	if(d>A.r+B.r) ans=max(ans,dp[i]+dp[j]);
      }
    }
    
    cout<<ans<<endl;
  
  }
  
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string S;
    ll N;
    cin >> S >> N;

    for(ll i = 0; i < S.length(); i++){
        if('a' == S[i]) continue;
        //cout << 'z' - S[i] + 1 << " " << N << endl;
        if('z' - S[i] + 1 <= N){
            N -= 'z' - S[i] + 1;
            S[i] = 'a';
        }
    }

    if(N > 0){
        S[S.length()-1] += N % 26;
    }

    cout << S << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
using namespace std;
#define MAX 200000
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

int main(){
    int n,a[100000],j,sum;
    bool b[100000]={};
    scanf("%d",&n);
    REP(i,n)scanf("%d",&a[i]);
    j=sum=0;
    while(1){        
        j=a[j];
        sum++;
        if(j==2){
            printf("%d",sum);
            return 0;
        }
        else if(b[--j]==1){
            printf("-1\n");
            return 0;
        }     
        b[j]=1;   
    }
    return 0;
}

Measured memory_bytes: 768
// -------- START : snippet -------- //

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

// -------- START : macro -------- //

#define ll long long
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define len(c) (ll)c.size()
#define all(v) (v).begin(),(v).end()
#define lb(v,x) (lower_bound(all(v),x)-v.begin())
#define ub(v,x) (upper_bound(all(v),x)-v.begin())
#define has(c,x) (c.find(x) != c.end())
#define uniq(v) v.erase(unique(all(v)),v.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// -------- END : macro -------- //

// -------- START : debug macro -------- //

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

// -------- END : debug macro -------- //

// -------- END : snippet -------- //

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    double l = 0, r = 1e9;
    rep(loop, 200) {
        double m = (l+r)/2.0;
        auto check = [&](){
            int cnt = 0;
            rep(i,n) {
                int cut = a[i]/m;
                if (cut * m == a[i]) cut--;
                cnt += cut;
            }
            return cnt <= k;
        };
        if (check()) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << (int)ceil(l) << endl;
    return 0;
}


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

// int INF = 1000001;

int main() {
    int N, M;
    string s[110], t[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> s[i];
    cin >> M;
    for (int i = 0; i < M; i++) cin >> t[i];
    
    int score = 0;
    
    for (int i = 0; i < N; i++) {
        int res = 0;
        string currentString = s[i];
        for (int j = 0; j < N; j++) if (currentString == s[j]) res++;
        for (int k = 0; k < M; k++) if (currentString == t[k]) res--;
        
        if (res > score) score = res;
    }
    cout << score << endl;
    return 0;
}


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

int main() {
	long n,m,i,j,k,ans,cur,res,q,query,v;
	cin >> n >> k;
	
	vector<long> a(n),b(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	
	vector<long> l(0),r(0);
	long jud=1,ok,ng,mid;
	for(q=0; q<k; q++){
		jud=1;
		for(i=0; i<n; i++){
			if(a[i]!=n){
				jud=0;
			}
		}
		if(jud==1){
			for(i=0; i<n; i++){
				cout << n << ' ';
			}
			cout << endl; return 0;
		}
		
		for(i=0; i<n; i++){
			l.push_back(i-a[i]);
			r.push_back(i+a[i]);
		}
		
		l.push_back(-100);
		l.push_back(1000000);
		r.push_back(-100);
		r.push_back(1000000);
		sort(l.begin(), l.end());
		sort(r.begin(), r.end());
		reverse(r.begin(),r.end());
		
		for(i=0; i<n; i++){
			ok=0; ng=l.size()-1;
			while(abs(ok-ng)>1){
				mid=(ok+ng)/2;
				if(l[mid]>i){
					ng=mid;
				}else{
					ok=mid;
				}
			}
			res=ng;
			
			ok=0; ng=r.size()-1;
			while(abs(ok-ng)>1){
				mid=(ok+ng)/2;
				if(r[mid]<i){
					ng=mid;
				}else{
					ok=mid;
				}
			}
			res=n-((n+1)-res)-(n+1-ng);
			
			b[i]=res;
			
		}
		while(l.size()>0){
			l.pop_back();
		}
		while(r.size()>0){
			r.pop_back();
		}
		a=b;
	}
	for(i=0; i<n; i++){
		cout << a[i] << ' ';
	}
	return 0;
}

Measured memory_bytes: 9768
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    
ans = 0
for i in range(N):
    ans = max(uf.size(i), ans)
    
print(ans)

Measured memory_bytes: 14400
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String O = sc.next();
        String E = sc.next();
        String password="";
        
        int df = O.length() - E.length();
        
        for(int i=0;i<E.length();i++){
            password += (O.substring(i, i+1) + E.substring(i, i+1));
        }
        
        if(df != 0){
            password += O.substring(O.length()-1, O.length());
        }
        System.out.println(password);
    }
    
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main() {
  int M1, M2, D1, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  vector<vector<int> > vec = {
    {1,31,2,1},
    {2,28,3,1},
    {3,31,4,1},
    {4,30,5,1},
    {5,31,6,1},
    {6,30,7,1},
    {7,31,8,1},
    {8,31,9,1},
    {9,30,10,1},
    {10,31,11,1},
    {11,30,12,1},
    {12,31,1,1}
  };
  int cnt = 0;
  for (int i = 0; i<12; i++) {
    if(M1 == vec.at(i).at(0) && D1 == vec.at(i).at(1)){
      cnt++;
    }  
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class Test{
  public static void Main(){
    var NM = Console.ReadLine().Split(" ").Select(a => int.Parse(a)).ToList();
    var N = NM[0];
    var M = NM[1];
    var nums = Console.ReadLine().Split(" ").Select(b => int.Parse(b)).ToList();
    for(int i = 0; i<M; i++){
      N -= nums[i];
    }
    if(N<0){
      Console.Write(-1);
    }else{
      Console.Write(N);
    }
  }
}

Measured memory_bytes: 29120
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

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

    if(x==0) cout << 1 << endl;
    else cout <<  0 << endl;
    return 0;
}

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

int main(){
	int m,f,r;
	
	while(1){
		cin >> m >> f >>r;
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1) cout << "F" << endl;
		else if(m+f>=80) cout << "A" << endl;
		else if(m+f>=65) cout << "B" << endl;
		else if(m+f>=50) cout << "C" << endl;
		else if(m+f>=30 && r>=50) cout <<"C" <<endl;
		else if(m+f>=30) cout <<"D" << endl;
		else cout << "F" << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	string s;
	cin>>s;
	int a=(s[0]-'0')*10+(s[1]-'0');
	int b=(s[2]-'0')*10+(s[3]-'0');
	if(a>0&&a<=12){
		if(b>0&&b<=12)cout<<"AMBIGUOUS";
		else cout<<"MMYY";
	}
	else if(b>0&&b<=12)cout<<"YYMM";
	else cout<<"NA";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N-1):
    ans += A[i] // 2
    if A[i] % 2 != 0:
        if 0 < A[i+1]:
            ans += 1
            A[i+1] -= 1
ans += A[N-1] // 2
print(ans)

Measured memory_bytes: 7072
#include <cstdio>

int main() {
	int n;
	long long x = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		long long y;
		scanf("%lld", &y);
		x += y;
	}
	if (x & 1)puts("NO");
	else puts("YES");
}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    n -= a;
  }
  if (n >= 0)
    cout << n << endl;
  else 
    cout << -1 << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(void){
  int n,i,j,c;
  while(scanf("%d",&n)!=EOF){
    int a[n+1];
    c=0;
    for(i=2;i<=n;i++)
      a[i]=i;
    for(i=2;i<=n;i++){
      if(a[i]){
	for(j=2*i;j<=n;j+=i){
	  if(a[j]%a[i]==0)
	    a[j]=0;
	}
      }
    }
    for(i=2;i<=n;i++){
      if(a[i])
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;

	std::set<int> values;
	values.insert(A);
	values.insert(B);
	values.insert(C);

	if (values.size() == 2) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, k; cin >> n >> k;
  
  lint ans = 0;
  for (lint l = k; l <= n + 1; l++) {

    lint left = (0 + l - 1) * l / 2;
    lint right = (n - l + 1 + n) * l / 2;

    lint sum = right - left + 1;
    ans += sum;
    ans %= MOD;

  }

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string S;
    cin >> S;
    S[3] = '8';

    cout << S;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main() {
  int N;
  cin >> N;
  map<pair<int, int>, int> MA;
  long ans = 0;
  for (double A; cin >> A;) {
    long a = round(A * 1e9);
    int x = 0, y = 0;
    while (a % 2 == 0) a /= 2, x++;
    while (a % 5 == 0) a /= 5, y++;
    for (auto [xy, cnt] : MA) {
      if (x + xy.first >= 18 && y + xy.second >= 18) ans += cnt;
    }
    MA[{x, y}]++;
  }
  cout << ans << "\n";
}

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

int main()
{
    int a, b, c, x, y, z;
    string A, B, C;
    cin >> A >> B >> C;
    a = 0;
    b = 0;
    c = 0;
    char F;
    F = 'a';
    x = A.size();
    y = B.size();
    z = C.size();
    for (int i = 0; i < x + y + z; i++)
    {
        if ((a == x && F == 'a') || (y == b && F == 'b') || (z == c && F == 'c'))
        {
            break;
        }
        if (F == 'a')
        {
            F = A[a];
            a++;
        }
        else if (F == 'b')
        {
            F = B[b];
            b++;
        }
        else
        {
            F = C[c];
            c++;
        }
    }
    if (F == 'a')
    {
        cout << 'A' << endl;
    }
    else if (F == 'b')
    {
        cout << 'B' << endl;
    }
    else
    {
        cout << 'C' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int num_to = (int)Math.pow(2, n)-1;
			int[] a = in.nextIntArray(n);
			HashSet<Integer> list = new HashSet<>();

			for (int i = num_to; i > 0; i--) {
				int sum = 0;
				char bin[] = String.format("%"+n+"s",Integer.toBinaryString(i))
						.replace(' ', '0')
						.toCharArray();
				for (int j = bin.length-1; j >= 0 ; j--) {
					if (bin[j] == '1') {
						sum += a[j];
					}
				}
				list.add(sum);
			}

			int q = in.nextInt();
			int[] m = in.nextIntArray(q);
			for (int mi : m) {
				if (list.contains(mi)) {
					out.println("yes");
				} else {
					out.println("no");
				}
			}
		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 437540
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A')return 1;
  else if(ch=='C')return 2;
  else if(ch=='G')return 3;
  else if(ch=='T')return 4;
  else return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int find(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];

  for(i=0;i<M;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i')insert(str);
    else{
      if(find(str))printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 16056
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int n = int.Parse(Console.ReadLine());
	    int a = int.Parse(Console.ReadLine());
	    int b = int.Parse(Console.ReadLine());
	    Console.WriteLine((n-a)%b);
	} 
}

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

int main(){
  int a, b, c, count;
  count = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++){
    if (c % i == 0){
      count += 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3108
#include<stdio.h>

int main(){

  int i,j,k;
  int N;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d ",&A[i]);
  }
  int tmp,Bob=0,Alice=0;
  for (i=0; i<N; ++i) {
    for (j=i+1; j<N; ++j) {
      if (A[i] < A[j]) {
        tmp =  A[i];
        A[i] = A[j];
        A[j] = tmp;
      }
    }
  }
  
  for(i=0;i<N;i++){
    if(i==0||i%2==0)
      Alice += A[i];
    else 
      Bob += A[i];
  }
  
  printf("%d\n",Alice-Bob);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

template<class Monoid> struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    using G = function<Monoid(int, Monoid)>;
    int n;
    Monoid id;
    vector<Monoid> data;
    F op;
    G ud;
    
    SegmentTree(int sz, F f, G g, Monoid def) : op(f), ud(g) {
        n = 1; id = def;
        while (n < sz) n *= 2;
        data = vector<Monoid>(2*n-1, id);
    }
    
    void update (int i, Monoid x) {
        i += n - 1;
        data[i] = ud(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }
    
    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return data[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return op(vl, vr);
    }
};


int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<pair<int, int>, long long>> C;
    for (int i = 0; i < M; i++) {
        int l, r; long long c;
        cin >> l >> r >> c;
        C.emplace_back(make_pair(l, r), c);
    }
    sort(C.begin(), C.end());
    
    auto f = [](long long a, long long b) { return min(a, b); };
    auto g = [](int i, long long x) { return x; };
    SegmentTree<long long> sg(N+1, f, g, INF);
    sg.update(1, 0);
    ///*
    for (int i = 0; i < M; i++) {
        int l, r; long long c = C[i].second;
        tie(l, r) = C[i].first;
        long long res = sg.query(l, r+1) + c;
        long long now = sg.query(r, r+1);
        if (res < now) sg.update(r, res);
    }
    //*/
    long long ans = sg.query(N, N+1);
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
    
}

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

int main(){
    string s;
    string t;
    int r=0;
    cin >> s >> t;
    for (int i = 0;i < s.size();i++){
        if(s[i]==t[i])r++;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)

ans = 0
for i in range(n):
    if n < i+m:
        continue
    x = s[i:i+m]
    cnt = 0
    for a, b in zip(x, t):
        if a == b:
            cnt += 1
    if ans < cnt:
        ans = cnt
print(m-ans)


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

#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 ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n+1);
    for1(i,n) cin>>a[i];
    unordered_map<int,int> cnt;
    ll ans=0;
    for1(i,n){
        ans+=cnt[-(a[i]-i)];
        cnt[a[i]+i]++;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 19244
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define STR_MAX 10
#define BUF_SIZE (STR_MAX+10)

int main(void) {
    int num = get_int();
    int i;
    static int map[26];
    for(i = 0; i < num; i++) {
        char str[BUF_SIZE];
        get_str(str, BUF_SIZE);
        map[str[0]-'A']++;
    }
    int64_t ans = 0;
    static char keyword[] = "MARCH";
    int pat, bit;
    for(pat = 0; pat < (1<<5); pat++) {
        if(__builtin_popcount(pat)!=3) continue;
        int64_t res = 1;
        for(bit = 0; bit < 5; bit++) {
            if(!(pat & (1<<bit))) continue;
            res *= map[keyword[bit]-'A'];
        }
#ifdef DEBUG
        printf("%lld\n", res);
#endif
        ans += res;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
import math

N = int(input())
dp= [0] * (N+1)

dp[0] = 0

for i in range(1,N+1):
    A = dp[i-1] + 1
    
    k = int(round(math.log(i, 6), 10))
    B = dp[i - 6 ** k] + 1
    
    k = int(round(math.log(i, 9), 10))
    C = dp[i - 9 ** k] + 1

    dp[i] = min(A,B,C)

print(dp[N])

Measured memory_bytes: 9528
# C
N,M = map(int, input().split())
graph = [[False]*N for _ in range(N)]
visited = [False]*N

def dfs(cur):
    global visited
    visited[cur] = True
    for nxt in range(N):
        if graph[cur][nxt]==False: continue
        if visited[nxt]==True: continue
        dfs(nxt)


a = [-1]*M
b = [-1]*M
for i in range(M):
    ai,bi = map(int, input().split())
    a[i],b[i] = ai-1, bi-1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

ans = 0
for i in range(M):
    graph[a[i]][b[i]] = False # 辺を消す
    graph[b[i]][a[i]] = False
    # print("graph: "+"\n".join(map(str, graph)))
    visited = [False]*N
    dfs(0)
    if not all(visited):
        ans += 1
    graph[a[i]][b[i]] = True # 辺を戻す
    graph[b[i]][a[i]] = True
    
print(ans)

Measured memory_bytes: 3064
/*input
a
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    char a;
    cin>>a;
    if(isupper(a)) cout<<'A';
    else cout<<'a';
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int a[3][3];
    rep(i, 3) rep(j, 3) cin >> a[i][j];

    int n;
    cin >> n;

    rep(_, n){
        int b;
        cin >> b;

        rep(i, 3) rep(j, 3){
            if(a[i][j] == b) a[i][j] = 0;
        }
    }

    if(a[0][0]+a[0][1]+a[0][2]==0 || a[1][0]+a[1][1]+a[1][2]==0 || a[2][0]+a[2][1]+a[2][2]==0 || a[0][0]+a[1][0]+a[2][0]==0 || a[0][1]+a[1][1]+a[2][1]==0 || a[0][2]+a[1][2]+a[2][2]==0 || a[0][0]+a[1][1]+a[2][2]==0 || a[0][2]+a[1][1]+a[2][0]==0){
        puts("Yes");
    }
    else puts("No");

    return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    bool all_zero = true;
    for (int i=0; i<n; ++i) cin >> a[i];
    for (int i=0; i<k; ++i) {
        vector<int> diff(n+1);
        for (int j=0; j<n; ++j) {
            int left = max(0, j - a[j]);
            int right = min(n, j + a[j] + 1);
            diff[left]++; diff[right]--;
        }
        a[0] = diff[0];
        bool all_n = (a[0] == n);
        for (int j=1; j<n; ++j) {
            a[j] = a[j-1] + diff[j];
            if (a[j] != n) all_n = false;
        }
        if (all_n) {
            break;
        }
    }
    for (int i=0; i<n; ++i) cout << a[i] << (i == n-1 ? "\n" : " ");
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  bool ans = false;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k-i;j++){
      if(a<b*pow(2,i)&&b*pow(2,i)<c*pow(2,j)) ans = true;
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4092
#include<iostream>
using namespace std;
int n,a[20],q,m,h[2222]={};

void s(int i=0,int sum=0){
  if(i==n){
    h[sum]=1;
    return;
  }
  s(i+1,sum+a[i]),s(i+1,sum);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  cin>>q,s();
  for(int i=0;i<q;i++){
    cin>>m;
    cout<<(h[m]?"yes\n":"no\n");
  }
  return 0;
}

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


Measured memory_bytes: 3576