akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;;

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vector<int> r(n,INF);
  for(int i=0; i<m; i++) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    r[a] = min(r[a], b);
  }
  int x = INF, ans = 0;
  for(int i=0; i<n; i++){
    if (x == i) x = INF, ans++;
    x = min(x, r[i]);
  }

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






















Measured memory_bytes: 3788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#define ll long long
#define fi first
#define se second
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
const int INF=0x7fffffff;
const double EPS=1e-6;
const int MAX_N=1000000+5;
string s;
int main (void)
{
   ll n,a,b;
   cin>>n>>a>>b;
   ll ans=0;
   ans=n/(a+b)*a;
   ll m=n%(a+b);
   if(m<=a)
    ans+=m;
   else
    ans+=a;
   cout<<ans<<endl;
}

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

long p[55][55];

void p_init(){
  p[0][0]=1;
  p[1][0]=1,p[1][1]=1;
  for(int n=2;n<=50;n++){
    for(int r=0;r<=n;r++){
      if(r==0||r==n) p[n][r]=1;
      else{
        p[n][r]=p[n-1][r-1]+p[n-1][r];
      }
    }
  }
}

long com(long n,long r){
  return p[n][r];
}

int main() {
  long N,P;
  cin>>N>>P;
  long ans=0;
  long o=0,e=0;
  for(int i=0;i<N;i++){
    long a;
    cin>>a;
    if(a%2==0) e++;
    else o++;
  }
  p_init();
  if(P==0){
    for(int i=0;i<=o;i+=2){
      ans+=long(pow(2,e))*com(o,i);
    }
  }
  else{
    for(int i=1;i<=o;i+=2){
      ans+=long(pow(2,e))*com(o,i);
    }
  }
cout<<ans<<endl;
}


Measured memory_bytes: 3964
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

AB.sort()
S1=[]
i=0
while AB[i][0]==1:
    S1.append(AB[i][1])
    i+=1
    if i>M-1:
        break

AB.sort(key=lambda x:x[1],reverse=True)
SN=[]
i=0
while AB[i][1]==N:
    SN.append(AB[i][0])
    i+=1
    if i>M-1:
        break

print(['IMPOSSIBLE','POSSIBLE'][len(set(S1)&set(SN))>=1])

Measured memory_bytes: 61068
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Data.Char

solve :: VU.Vector Int -> Int -> Int -> Int
solve hs n k =
  runST $ do
    dp <- VUM.replicate (n+1) (10^5)
    VUM.write dp 0 0
    forM_ [1..n-1] $ \now -> do
      xs <- forM [now-k,now-k+1..now-1] $ \prev ->
              if prev >= 0 then do
                n <- VUM.read dp prev
                let diff = abs $ (hs VU.! now) - (hs VU.! prev) 
                return $ n + diff
              else
                return $ 10^9
      let x = minimum xs 
      VUM.write dp now x          
    VUM.read dp (n-1)


main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve hs n k 


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll w,a,b; cin >>w>>a>>b;

    if (a+w < b) {
        cout << b - (a + w) << endl;
    } else if (b+w < a) {
        cout << a - (b + w) << endl;
    } else {
        cout << 0 << endl;
    } 
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 1000003, mod = 1e9 + 7;
int n, m;
bool col[N], row[N];
int main(){
	scanf("%d%d", &n, &m);
	for(Rint i = 1;i <= n;i ++){
		int x;
		scanf("%d", &x);
		if(col[x]){puts("0"); return 0;}
		col[x] = true;
	}
	for(Rint i = 1;i <= m;i ++){
		int x;
		scanf("%d", &x);
		if(row[x]){puts("0"); return 0;}
		row[x] = true;
	}
	int ans = 1, c = 0, r = 0;
	for(Rint i = n * m;i;i --){
		int tc = c, tr = r;
		if(col[i]){tc = 1; ++ c;}
		if(row[i]){tr = 1; ++ r;}
		if(col[i] || row[i]) ans = (LL) ans * tc % mod * tr % mod;
		else ans = (LL) ans * (tc * tr - n * m + i) % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>
 
#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;
 
vector<int> z[2];
 
bool search(int x, vector<int> &v) {
  std::bitset<8000> b;
  b.set(0);
 
  for (int i : v) {
    b = (b << i) | (b >> i);
  }
 
  return b[abs(x)];
}
 
void solve() {
  string s;
  cin >> s;
 
  int x, y;
  cin >> x >> y;
 
  int way = 0;
  int n = 0;
 
  int i = 0;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      x--;
    } else {
      break;
    }
  }
 
  for (; i < s.size(); i++) {
    char c = s[i];
    if (c == 'F') {
      n++;
    } else {
      if (n != 0) {
        z[way].push_back(n);
        n = 0;
      }
      way = (way + 1) % 2;
    }
  }
  if (n) {
    z[way].push_back(n);
  }
 
  if (search(x, z[0]) && search(y, z[1])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
 
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {

    int n; cin >>n;
    vector<ll> l(100);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i < 100; i++) {
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;

    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def main():
    W, H, x, y = map(int, input().split())

    x_c = W/2
    y_c = H/2

    S = W*H/2

    if x == x_c and y == y_c:
        print("{} {}".format(S, 1))
    elif x == x_c or y == y_c:
        print("{} {}".format(S, 0))
    else:
        print("{} {}".format(S, 0))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>

int n;
int A[20];

int adding(int m, int i){
	if( i >= n ){ return 0; }
	if( m < 0 ){ return 0; }
	if( m == A[i] ){
		return 1;
	}
	if( adding(m-A[i], i+1) ){ return 1; }
	if( adding(m, i+1) ){ return 1; }
	return 0;
}

int main(){
	int q, m;
	int i;
	char *ans[2] = {"no", "yes"};
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){ scanf("%d", &A[i]); }
	scanf("%d", &q);
	for( i = 0; i < q; i++ ){
		scanf("%d", &m);
		printf("%s\n", ans[adding(m,0)]);
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
int N; cin >> N;
int ans = 0;
rep(i,N+1){
	if(int(i * 1.08) == N){
		ans = i;
	}
	
}
	if(ans != 0){
		cout << ans << endl;
	}
	else{
		cout << ":(" << endl;
	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

struct Point
{
    double x,y,z;
    double norm2(){ return x*x+y*y+z*z; }
};
typedef Point Vector;

struct Object
{
    Point c;
    int r;
    ll cost;
};

double dist(Point p, Point q)
{
    return sqrt((p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y)+(p.z-q.z)*(p.z-q.z));
}

const double eps=1e-8;

int main()
{
    int n,Q;
    scanf(" %d %d", &n, &Q);
    vector<Object> a(n);
    rep(i,n)
    {
        double x,y,z;
        int r;
        ll l;
        scanf(" %lf %lf %lf %d %lld",&x,&y,&z,&r,&l);
        a[i]=Object{Point{x,y,z},r,l};
    }
    while(Q--)
    {
        double sx,sy,sz,dx,dy,dz;
        scanf(" %lf %lf %lf %lf %lf %lf",&sx,&sy,&sz,&dx,&dy,&dz);

        Vector v=Vector{dx-sx,dy-sy,dz-sz};
        ll ans=0;
        rep(i,n)
        {
            double t=(double)(v.x*(a[i].c.x-sx)+v.y*(a[i].c.y-sy)+v.z*(a[i].c.z-sz))/(v.norm2());

            if(-eps<t && t<1+eps)
            {
                Point h=Point{sx+t*v.x,sy+t*v.y,sz+t*v.z};
                if(dist(a[i].c,h)<a[i].r+eps) ans+=a[i].cost;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3240
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

typedef long long lint;

int main() {

    lint N, A, B;
    cin >> N >> A >> B;
    lint ans = 1ll << 60;
    if(A > B) swap(A, B);
    if(A % 2 == B % 2) {
        chmin(ans, (B - A) / 2);
    } else {
        {
            lint step = A;
            lint a = 1, b = B - step;
            chmin(ans, step + (b - a) / 2);
        }
        {
            lint step = N - B + 1;
            lint b = N, a = A + step;
            chmin(ans, step + (b - a) / 2);
        }
    }
    cout << ans << '\n';

}


Measured memory_bytes: 256
import Prelude hiding (abs)
import Control.Monad
import Control.Arrow ((&&&))
import Data.List (nub, sort, group, find)
import Data.Maybe (fromMaybe, fromJust)
import qualified Data.IntMap as M

type Counter = M.IntMap Int

main :: IO ()
main = do
    [n, k] <- (map read . words) <$> getLine
    abs <- map readLine2 <$> replicateM n getLine
    print $ solve abs k

-- |
--
-- >>> solve [(1,1),(2,2),(3,3)] 4
-- 3
solve :: [(Int,Int)] -> Int -> Int
solve abs k = fst y
  where
    c = foldl update M.empty abs
    y = head . dropWhile (\(_,b) -> b < k) $ scanl f (0,0) (sort $ M.assocs c)
    f (a1,b1) (a2,b2) = (a2, b1 + b2)

update :: Counter -> (Int,Int) -> Counter
update c (a,b) = M.insertWith (+) a b c

readLine2 :: String -> (Int,Int)
readLine2 = tuplify2 . map read . words
    where
      tuplify2 [] = (0, 0)
      tuplify2 [x] = (x, 0)
      tuplify2 (x:y:_) = (x, y)


Measured memory_bytes: 102780
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    Int A,B,C,X,Y;
    cin >> X >> Y >> A >> B >> C;
    vector<Int>p(A),q(B),r(C);
    for(auto& e : p) cin >> e;
    for(auto& e : q) cin >> e;
    for(auto& e : r) cin >> e;
    sort(p.begin(),p.end(),greater<>());
    sort(q.begin(), q.end(),greater<>());
    sort(r.begin(), r.end(),greater<>());
    using pii = pair<int,int>;
    vector<Int>data;
    for(int i = 0; i < X; ++i)
        data.emplace_back(p[i]);
    for(int j = 0; j < Y; ++j)
        data.emplace_back(q[j]);
    priority_queue<Int,vector<Int>,greater<>>que;
    priority_queue<Int,vector<Int>>rque;
    for(auto e : data)que.push(e);
    for(auto e : r)rque.push(e);
    while(not que.empty() and not rque.empty() and que.top() <= rque.top()){
        que.pop();que.push(rque.top());
        rque.pop();
    }
    Int ans = 0;
    while(not que.empty())ans += que.top(), que.pop();
    cout << ans << endl;
}


Measured memory_bytes: 7280
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n%2==1)return mul(exp(a,n-1),a);
	V b=exp(a,n/2);
	return mul(b,b);
}
V z(){
	V x(N*N);
	int i;
	if(T){
		for(i=0;i<N;i++){
			if(i>0)x[i*N+i-1]=A;
			x[i*N+i]=B;
			if(i<N-1)x[i*N+i+1]=C;
		}
		return exp(x,T);
	}else{
		for(i=0;i<N;i++)x[i*N+i]=1;
		return x;
	}
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		V s(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
		const V r=z();
		for(i=0;i<N;i++){
			printf(i<N-1?"%d ":"%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
		}
	}
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;cin>>s1>>s2;
	string ans;
	for(int i=1;i<=(int)s1.length()+(int)s2.length();i++) if(i%2==1) ans+=s1[i/2];else ans+=s2[i/2-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int h, w;
int a[4][2]= {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};//????????????????§???¨
char map[105][105];
int ans;
bool judge(int i, int j){
	if(i >= 0 && i < h && j >= 0 && j < w)
		return true;
	return false;
}
void dfs(int x, int y,char c){

		map[x][y] = 'x';
	int tempx, tempy;
	for(int i = 0; i < 4; i++){  //???????????????????´¢ 
		tempx = x + a[i][0];
		tempy = y + a[i][1];
		if(judge(tempx, tempy) && map[tempx][tempy] == c)
			dfs(tempx, tempy, c); 
	}

	return ;
}

int main(){
	while(scanf("%d %d", &h, &w) && h != 0 && w != 0){
		ans = 0;
		for(int i = 0; i < h; i++)
			scanf("%s", map[i]);
		for(int i = 0; i < h; i++)
			for(int j = 0; j < w; j++){
				if(map[i][j]=='@'||map[i][j]=='#'||map[i][j]=='*'){									
					dfs(i, j, map[i][j]);
					ans++;
				}
			}
		printf("%d\n", ans);
	}
	
	
	return 0;
} 

Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int n,t;
int main(){
    cin >> n >> t;
    int c[n],z[n];
    for(int i=0; i<n; i++){
        cin >> c[i] >> z[i];
    }
    int res=1e9;
    int root = -1;
    for(int i=0; i<n; i++){
        if(z[i]<=t){
            if(res>c[i]){
                root = z[i];
                res = c[i];
            }
        }
    }
    if(root>0){
        cout << res << endl;
    }else{
        cout << "TLE" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int N = sc.nextInt();
			long D = sc.nextLong();
			int count = 0;
			for(int i = 0; i< N; i++){
				long x = sc.nextLong();
				long y = sc.nextLong();
				if(x*x + y*y <= D*D){
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M, K;
  cin >> N >> M >> K;

  bool ans = false;
  if(K % N == 0 || K % M == 0)
	ans = true;
  for(int x=0;x<=N;++x)
	for(int y=0;y<=M;++y)
	  if(K == y*x + (M-y) * (N-x))
		ans = true;
  cout << (ans? "Yes": "No") << endl;
	

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b;
  cin >> a >> b;
  for(int i=1;i<=1250;i++){
    if(a==floor(i*0.08)&&b==floor(i*0.1)){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll X;
	scan(X);
	ll now=100;
	rep1(i,INF){
		now+=now/100;
		if(now>=X){
			prin(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	
	static int mod = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int l = Math.abs(m - n);
		
		if(l > 1) {
			System.out.println(0);
		}
		long ans = 0;
		
		if(l == 1) {
			ans = (long)(fact(n)* fact(m))%mod;
			System.out.println(ans);
		}
		
		if(l == 0) {
			ans = (long)(2 * (fact(n) * fact(m))%mod)%mod;
			System.out.println(ans);
		}

	}
	
	private static long fact(int n){
		long p = 1;
		for(int i = 1; i <= n ; i++) {
			p = (p*i)%mod;
		}
		return p;
	}

}


Measured memory_bytes: 21844
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.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			if(N < 1000) {
				out.println("ABC");
			}else {
				out.println("ABD");
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}


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

using namespace std;
typedef pair<int, int> ii;


const int MOD = (int)1e9 + 7;

#define N 16
int arr[N][N];

long long subSeg[(1<<N)];

long long dp[(1<<N)];
int n;

long long getans(int mask) {
    if(mask == 0) {
        return 0;
    }

    if(dp[mask] != -1) {
        return dp[mask];
    }

    long long cur = 0;
    for(int i = mask; i > 0; i = (i-1)&mask) {
        
        cur = max(cur, subSeg[i] + getans(mask^i) );
        
    }
    dp[mask] = cur;
    return cur;

}


void print(int num) {

    while(num) {
        cout << num%2;
        num>>= 1;
    }
    cout << "\n";
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> arr[i][j];
        }
    }    

    for(int i = 0; i < (1<<n); ++i) {
        long long cur = 0;
        for(int j = 0; j < n; ++j) {
            for(int k = j+1; k < n; ++k) {
                if( (i&(1<<j)) and (i&(1<<k))) {
                    cur += arr[j][k];
                }
            }
        }
        subSeg[i] = cur;
    }

    long long ans = getans((1<<n)- 1);

    cout << ans;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

typedef class Status {
	public:
		int l, r, cl, cr;

		Status() {	}
		Status(int l, int r, int cl, int cr) : l(l), r(r), cl(cl), cr(cr) {	}

		boolean operator < (Status b) const {
			if (l ^ b.l)
				return l < b.l;
			if (r ^ b.r)
				return r < b.r;
			if (cl ^ b.cl)
				return cl < b.cl;
			return cr < b.cr;
		}
} Status;

#define ll long long

int n;
int a[20];
map<Status, ll> F;

ll dp(int l, int r, int cl, int cr) {
	if (l > r)
		return 0;
	if (l == r)
		return 1ll * a[l] * (cl + cr);
	Status scur (l, r, cl, cr);
	if (F.count(scur))
		return F[scur];
	ll rt = 1e18;
	for (int k = l; k <= r; k++) {
		ll cost = a[k] * 1ll * (cl + cr);
		cost += dp(l, k - 1, cl, cl + cr);
		cost += dp(k + 1, r, cl + cr, cr);
		rt = min(rt, cost);
	}
	return F[scur] = rt;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	if (n == 2) {
		printf("%d", a[1] + a[2]);
		return 0;
	}
	ll ans = dp(2, n - 1, 1, 1) + a[1] + a[n];
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<vector<int>> count(19, vector<int>(19, 0));
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        string A;
        cin >> A;
        int p = -1;
        long long num = 0;
        for (int j = 0, L = A.length(); j < L; ++j) {
            if (A[j] != '.') {
                num *= 10;
                num += (A[j] - '0');
            } else {
                p = j;
            }
        }
        int f = 0;
        if (p != -1) {
            f = A.length() - p - 1;
        }
        // power of 2, 5 : -9 ~ 9
        int power2 = -f, power5 = -f;
        while (power2 < 9 && num % 2 == 0) {
            ++power2;
            num /= 2;
        }
        while (power5 < 9 && num % 5 == 0) {
            ++power5;
            num /= 5;
        }
        ++count[power2 + 9][power5 + 9];
        if (power2 >= 0 && power5 >= 0) {
            --ans;
        }
    }
    for (int i = 0; i <= 18; ++i) {
        for (int j = 0; j <= 18; ++j) {
            for (int k = 18 - i; k <= 18; ++k) {
                for (int t = 18 - j; t <= 18; ++t) {
                    if (count[i][j] != 0 && count[k][t] != 0) {
                        ans += (long long)count[i][j] * count[k][t];
                    }
                }
            }
        }
    }
    cout << ans / 2 << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
if you have any question about any part of my code,
please don't shy to ask anytime :)
*/

ll mx = 1e18;

void solve()
{
    ll n;
    cin>>n;
    vector<ll>x(n);
    bool f = false;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==0)
        {
            f = true;
        }
    }

    if(f)
    {
        cout<<"0"<<endl;
        return;
    }

    ll ans=1;
    sort(x.begin(), x.end());
    for(int i=0;i<n;i++)
    {
        if(x[i]>mx/ans)
        {
            ans = -1;
            break;
        }
        ans*=x[i];
    }
    cout<<ans<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3972
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=0,p=0;
    cin>>a>>p;
    cout<<((a*3)+p)/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        // 配列の要素数は先に入れさせる
        int N = sc.nextInt();
        int []A = new int[N];
        //各配列の数を入れる
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
		for (int i = 1; i < N; i++) {
	        out_put(A);
			int j;
			int tmp = A[i];
			for(j = i;j > 0 && A[j - 1] > tmp; j--)
				A[j] = A[j-1];
			A[j] = tmp;
		}
        out_put(A);
    }

	private static void out_put(int array[]){

        System.out.printf("%d", array[0]);

        for(int i = 1; i < array.length; i++){
            System.out.printf(" %d", array[i]);
        }
        System.out.printf("\n");
    }
}



Measured memory_bytes: 45012
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

import collections

N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

ans = 0
for a in A:
    tmp = c[a-1] + c[a] + c[a+1]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 14500
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> d(n);
		REP(i, n) cin >> d[i];
		int ans = 0;
		REP(i, n) REP(j, i) {
			ans += d[i] * d[j];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 44

int F[MAX];
int makeFibonacci(int);


int main(){
  int a,i,answer;
  scanf("%d",&a);
  for(i = 0; i <= a; i++){
    F[i] = -1;
  }
  
  
  answer = makeFibonacci(a);

  printf("%d\n",answer);
  return 0;
}

int makeFibonacci(int n){
  int i;
  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  if(F[n] != -1){
    return F[n];
  }
     
  return F[n] = makeFibonacci(n-2) + makeFibonacci(n-1);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main (void){
    int a, b, k;
    int cnt = 0;
    cin >> k >> a >> b;
    
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cnt++;
            break;
        } 
    }

    if (0 < cnt) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import numpy as np

N, M, C=map(int, input().split())
B=np.array(list(map(int, input().split())))
A=np.array([list(map(int, input().split())) for i in range(N)])

counter=0
for i in range(N):
  if np.dot(A[i, :], B)+C>0:
    counter+=1
    
print(counter)

Measured memory_bytes: 12508
s = input()
ans = 0
for i in range(len(s)):
    if i % 2 ==0 :
        if s[i] == "L":
            ans += 1
    else:
        if s[i] == "R":
            ans += 1
if ans == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<"@"<<__LINE__<<": "<<x<<endl
using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k;
    cin>>n>>m>>k;
    vector<string> grid(n);
    rep(i,0,n) cin >> grid[i];
    vector<vi> ans(n,vi(m,-1));
    int r = 0;
    rep(i,0,n) {
        bool any = false;
        int c = -1;
        rep(j,0,m+1) if(j==m || grid[i][j]=='#') {
            if(j<m) {
                any = true;
                if(c==-1) {
                    c = 0;
                    continue;
                }
            }
            if(j==m && !any) continue;
            rep(jj,c,j) rep(ii,r,i+1) {
                ans[ii][jj] = k;
            }
            --k;
            c = j;
        }
        if(any) r = i+1;
    }
    rep(i,0,n) {
        rep(j,0,m) {
            if(ans[i][j]==-1) ans[i][j]=ans[i-1][j];
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 1280
N,M = map(int,input().split())
p=[]
S=[]
d={"WA":-1,"AC":1}
for _ in range(M):
    i,j= input().split()
    p.append(int(i)-1)
    S.append(d[j])
    
status = [False for _ in range(N)]

wa = [0 for _ in range(N)]
ac = 0
for i in range(M):
    if not status[p[i]]:
        if S[i]==-1:
            wa[p[i]] += 1
        else:
            ac += 1
            status[p[i]] = True
    else:
        pass
wa2 = 0 
for i in range(N):
    if status[i]:
        wa2 += wa[i]
print(ac,wa2)

Measured memory_bytes: 63200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void print(char str[1024], int a, int b);
void reverse(char str[1024], int a, int b);
void replace(char str[1024], int a, int b, char p[1024]);

int main(void){
	char str[1024]={0};
	char p[1024]={0};
	char ch[24]={0};
	int q,i;
	int a,b;

	scanf("%s", str);
	scanf("%d", &q);
	for(i=0; i<q; i++){
		scanf("%s %d %d", ch, &a, &b);
		if(!strcmp(ch,"print"))
			print(str,a,b);
		else if(!strcmp(ch,"reverse"))
			reverse(str,a,b);
		else if(!strcmp(ch,"replace")){
			scanf("%s",p);
			replace(str,a,b,p);
		}
		
	}
	return 0;
}
void print(char str[1024], int a, int b){
	int i;
	for(i=a; i<=b; i++){
		printf("%c",str[i]);
	}
	printf("\n");
}
void reverse(char str[1024], int a, int b){
	int i,j;
	char str2[1024];

	strcpy(str2,str);
	for(i=a,j=b; i<=b && j>=a; i++, j--){
		str[i] = str2[j];
	}
}
void replace(char str[1024], int a, int b, char p[1024]){
	int i,j;
	for(i=a; i<=b; i++){
		str[i] = p[i-a];
	}
}

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

int main() {
    int n, k; cin >> n >> k;
    int tmp;

    if (n % 2 == 0)
        tmp = n/2;
    else
        tmp = n/2 + 1;
    cout << ((k <= tmp) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2005;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	queue<char>a, b, c;
	string s, s1, s2; cin >> s >> s1 >> s2;
	_for(i, 0, s.size())a.push(s[i]);
	_for(i, 0, s1.size())b.push(s1[i]);
	_for(i, 0, s2.size())c.push(s2[i]);
	char ch = a.front(); a.pop();
	while (1) {
		if (ch == 'a'&&!a.empty()) { ch = a.front(); a.pop(); }
		else if (ch == 'b'&& !b.empty()) { ch = b.front(); b.pop(); }
		else if (ch == 'c'&& !c.empty()) { ch = c.front(); c.pop(); }
		if (ch == 'a' && a.empty())break;
		else if (ch == 'b' && b.empty())break;
		else if (ch == 'c' && c.empty())break;
	}
	if (ch=='a'&&a.empty())cout << "A\n";
	else if (ch=='b'&&b.empty())cout << "B\n";
	else if (ch=='c'&&c.empty())cout << "C\n";
	return 0;
}

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

/*int main(void)
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<int>> p(n, vector<int>(2));
    int a[n] = {0};
    for (int i = 0; i < n; i++)
    {
        cin >> p[i][0] >> p[i][1] >> a[i];
    }

    //vector<vector<bool>> nu(h, vector<bool>(w, false));
    for (int i = 0; i < n; i++)
    {
        switch (a[i])
        {
        case 1:
            if (w > w - p[i][0]) { w -= p[i][0]; }
            break;
        case 2:
            if (w = p[i][0];
            break;
        case 3:
            h -= p[i][1];
            break;
        case 4:
            h = p[i][1];
            break;
        default:
            break;
        }
    }
    int ans = h*w;
    cout << ans << endl;
}*/

int main(void)
{
    int w_max, h_max, n;
    cin >> w_max >> h_max >> n;
    int x[n], y[n], a[n];
    int w_min = 0, h_min = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> a[i];
        
        switch(a[i])
        {
            case 1:
                w_min = max(w_min, x[i]);
                break;
            case 2:
                w_max = min(w_max, x[i]);
                break;
            case 3:
                h_min = max(h_min, y[i]);
                break;
            case 4:
                h_max = min(h_max, y[i]);
                break;
        }
    }

    if (w_max-w_min > 0 && h_max-h_min > 0)
    {
        cout << (w_max - w_min)*(h_max - h_min) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Tenki(void) {

	string S, T; cin >> S >> T;

	int counter = 0;
	rep(index, 3) if (S[index] == T[index]) counter++;
	
	cout << counter << flush;
	return;
}

int main(void) {

	A_Tenki();
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x, y, z;
    cin >> x >> y >> z;

    int K;
    cin >> K;
    vector<long long> A(x);
    vector<long long> B(y);
    vector<long long> C(z);
    for (int i = 0; i < x; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < y; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < z; ++i) {
        cin >> C[i];
    }

    if (A.size() > B.size()) {
        swap(A, B);
    }
    if (A.size() > C.size()) {
        swap(A, C);
    }
    if (B.size() > C.size()) {
        swap(B, C);
    }
    int n = A.size();
    int m = B.size();
    int l = C.size();

    vector<long long> sums;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            sums.push_back(A[i] + B[j]);
        }
    }
    sort(sums.begin(), sums.end(), greater<long long>());
    if (sums.size() > K) {
        sums.resize(K);
    }
    sort(C.begin(), C.end());

    auto count = [&](long long S) {
        int n = C.size();
        int m = sums.size();

        long long res = 0;
        for (int i = 0, j = 0; i < n; ++i) {
            while (j < m && C[i] + sums[j] >= S) {
                ++j;
            }
            res += j;
        }
        // cout << S << " " << res << endl;
        return res;
    };

    auto find = [&](long long K, long long L, long long R) -> long long {
        long long lo = L, hi = R;
        while (lo < hi) {
            auto mi = (lo + hi + 1) >> 1;
            if (count(mi) >= K) {
                lo = mi;
            } else {
                hi = mi - 1;
            }
        }
        return lo;
    };

    long long ans = 1LL << 40;
    // long long MX = 1LL << 32;
    for (int i = 1; i <= K; ++i) {
        ans = find(i, 0, ans);
        cout << ans << '\n';
    }


    return 0;
}

Measured memory_bytes: 10608
#include <iostream>
#include <map>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::map<uint32_t, uint32_t> dict;
  for (size_t i = 0; i < N; i++) {
    uint32_t a = 0;
    std::cin >> a;
    dict[a - 1]++;
    dict[a]++;
    dict[a + 1]++;
  }

  uint32_t max = 0;
  for (auto &&d : dict) max = (d.second > max) ? d.second : max;

  std::cout << max << std::endl;

  return 0;
}

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

int main() {
    uint64_t N;
    std::cin >> N;

    uint64_t cnt[N] = {0};
    uint64_t A[N];
    for (size_t i = 0; i < N; ++i) {
        std::cin >> A[i];
        cnt[A[i]] += 1;
        if (cnt[A[i]] > 2) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    if (N % 2 != 0 && cnt[0] != 1) {
        std::cout << 0 << std::endl;
        return 0;
    } 

    for (size_t i = 1; i < N; ++i) {
        if ((cnt[i] == 2 || cnt[i] == 0) == false) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    uint64_t ans = 1;
    for (size_t i = 0; i < N / 2; ++i) {
        ans *= 2;
        ans %= 1000000007;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cstdio>
#include <string>
#include <utility>
#include <iomanip>
#include <numeric>
#include <functional>
#include <list>
#include <regex>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <climits>
using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

#define pb(c,num) c.push_back(num)

// loops
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define tr(c, it) \
for(auto it = c.begin(); it != c.end(); ++it)


#define all(c) c.begin(), c.end()

// set,map
#define present(c, element) (c.find(element) != c.end())
//vectors
#define cpresent(c, element) (find(all(c), element) != c.end())




int main(){
    std::ios_base::sync_with_stdio(false);

//    ifstream input;
//    ofstream output;
//    input.open("input.in");
//    output.open("output.out");
    

    int n, k;
    cin >> n >> k;

    int in, counter = 0;
    rep(i,n){
        cin >> in;
        if(in >= k) counter++;
    }

    cout << counter;

//    input.close();
//    output.close();
//
    
    return 0;
}
    


Measured memory_bytes: 256
#include<stdio.h>

int MAX = 101, FUGE = (1<<30);//2の30乗

int main(){

  int i, j, A[MAX][MAX],n, k, c, u, v, min ,d[MAX], number[MAX];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    {
      for ( j = 0; j < n; j++ )
	{
	  A[i][j] = FUGE;
	}
    }

  for ( i = 0; i < n; i++ )
    {
      scanf("%d %d", &u, &k);

      for ( j = 0; j < k; j++ )
	{
	  scanf("%d %d", &v, &c);
	  A[u][v] = c;
	}
    }

  for ( i = 0; i < n; i++ ) 
    {
      d[i] = FUGE;//minを探すため、大きい値をいれておく。
      number[i] = 0;
    }

  d[0] = 0;

  while(1)
    {
      min = FUGE;
      u = -1;
      for ( i = 0; i < n; i++ )
	{
	  if ( number[i] != 1 && d[i] < min )
	    {
	      min = d[i];
	      u = i;
	    } 
	}

      if ( min == FUGE ) 
	{
	  break;
	}

      number[u] = 1;

      for ( v = 0; v < n; v++ )
	{
	  if (number[v] != 1)
	    {
	      if ( d[v] > d[u] + A[u][v] )
		{
		  d[v] = d[u] + A[u][v];
		}
	    }
	}
    }

  for ( i = 0; i < n; i++ )
    {
      printf("%d %d\n", i, d[i]);
    }

  return 0;
}

Measured memory_bytes: 636
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

k = 0
okb = [0 for i in range(n)]
for i in range(n):
    if k < n:
        while a[k] < b[i]:
            k += 1
            if k == n: break

    okb[i] = k

ans = 0
okc = 0

k = 0
for i in range(n):
    if k < n:
        while b[k] < c[i]:
            okc += okb[k]
            k += 1
            if k == n: break

    ans += okc
print(ans)

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

int main(){
    string S,T;
    cin >> S >> T;
    map<char, char> m;
    bool possible=true;
    for(int i=0; i<S.size(); i++){
        char s=S.at(i);
        char t=T.at(i);
        if(m.count(s)){
            if(m[s] != t) possible=false;
        }
        m[s] = t;
    }
    set<char> change;
    for(auto p: m){
        char c=p.second;
        if(change.count(c)) possible=false;
        change.insert(c);
    }
    if(possible){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3928