akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative

type Dice
    = [Int]

type Problem
    = (Dice, Dice)

type Result
    = Bool

roll :: Dice -> String -> Dice

roll dice []
    = dice

roll [s1, s2, s3, s4, s5, s6] (x:xs)
    = case x of
        'N' -> roll [s2, s6, s3, s4, s1, s5] xs
        'S' -> roll [s5, s1, s3, s4, s6, s2] xs
        'E' -> roll [s4, s2, s1, s6, s5, s3] xs
        'W' -> roll [s3, s2, s6, s1, s5, s4] xs
        'C' -> roll [s1, s3, s5, s2, s4, s6] xs
        
rollTo :: Int -> Dice -> [Dice]

rollTo top dice@[s1, s2, s3, s4, s5, s6]
    = [rolled | (cond, rolled) <- [c1, c2, c3, c4, c5, c6], top == cond] where
        c1 = (s1, dice)
        c2 = (s2, roll dice "N")
        c3 = (s3, roll dice "W")
        c4 = (s4, roll dice "E")
        c5 = (s5, roll dice "S")
        c6 = (s6, roll dice "NN")
        
spinTo :: Int -> Dice -> [Dice]

spinTo front dice@[_, s2, s3, s4, s5, _]
    = [spun | (cond, spun) <- [c2, c3, c4, c5], front == cond] where
        c2 = (s2, dice)
        c3 = (s3, roll dice "C")
        c4 = (s4, roll dice "CCC")
        c5 = (s5, roll dice "CC")

solve :: Problem -> Result

solve (dice1@(top:front:_), dice2)
    = elem dice1 $ concatMap (spinTo front) $ rollTo top dice2

output :: Result -> String

output bool
    = if bool then "Yes" else "No"
    
input :: IO Problem

input
    = do
        dice1 <- map read <$> words <$> getLine
        dice2 <- map read <$> words <$> getLine
        return (dice1, dice2)

main :: IO ()

main
    = putStrLn <$> output =<< solve <$> input

Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
	int a;
	while(~scanf("%d",&a))
	{
		if(a==1||a==2||a==3||a==5||a==7||a==9||a==4||a==6||a==8||a==10||a==12||a==14||a==16||a==18||a==9||a==12||a==15||a==18||a==21||a==24||a==27||a==20||a==28||a==32||a==36||a==10||a==25||a==30||a==35||a==40||a==45||a==36||a==42||a==48||a==54||a==21||a==42||a==49||a==56||a==63||a==64||a==72||a==81)
		printf("Yes\n");
		else
		printf("No\n");
	}
}

Measured memory_bytes: 128
N=int(input())
num=0
flag=0
for _ in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        num+=1
    else:
        num=0
    if num==3:
        flag=1
if flag==0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 62340
#include<iostream>
using namespace std;
 
int main() {
  string S; cin >> S;
  int A = (S[0] - '0') * 10 + (S[1] - '0');
  int B = (S[2] - '0') * 10 + (S[3] - '0');
  int am = 0, bm = 0;
  if (A >= 1 && A <= 12) am = 1;
  if (B >= 1 && B <= 12) bm = 1;
  
  if (am && bm) cout << "AMBIGUOUS" << endl;
  else if (am) cout << "MMYY" << endl;
  else if (bm) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int x,y,r;
int main() {
  scanf("%d%d",&x,&y);
  if (x<=y) r=y-x; else r=x-y+2;
  x=-x;
  if (x<=y) r=min(r,y-x+1); else r=min(r,x-y+3);
  y=-y;
  if (x<=y) r=min(r,y-x+2); else r=min(r,x-y+4);
  x=-x;
  if (x<=y) r=min(r,y-x+1); else r=min(r,x-y+3);
  printf("%d\n",r);
  return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i < X + K - 1; ++i)
        cout << i << ' ';

    cout << X + K - 1 << endl;

    return 0;
}


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

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

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

    sort(A.begin(), A.end(), greater<int>());

    int AL = 0;
    int BO = 0;

    for (int j = 0; j < N; j++){
        if (j % 2 == 0){
            AL += A.at(j);
        } else {
            BO += A.at(j);
        }
    }
    
    cout << AL-BO << endl;
    
}

Measured memory_bytes: 256
n = int(input())

l = list(map(int,input().split()))

acc = []

s = 0
for c in l:
    s += c
    acc.append(s)

#find the left part best bars

left = [-1]*(n-1)
# left[i] is the best bar when middle bar is between i and i+1

L = 0
M = 1

for M in range(1,n-2):
    if M == 1:
        left[M] = 0
    else:
        #judge left bar go forward or not?!
        pre_bar = left[M-1]
        pre_gap = abs(acc[pre_bar] - (acc[M]-acc[pre_bar]))
        next_bar = M-1
        for nxt_bar in range(pre_bar+1,M):
            nxt_gap = abs(acc[nxt_bar]-(acc[M]-acc[nxt_bar]))
            if nxt_gap > pre_gap:
                next_bar = nxt_bar - 1
                break
            else:
                pre_gap = nxt_gap
        left[M] = next_bar
#print(left)



#find the right part best bars
right = [-1]*(n-1)
# right[i] is the best bar when middle bar is between i and i+1

for M in range(1,n-2)[::-1]:
    if M == n-3:
        right[M] = n - 2
    else:
        #judge right bar go backward or not?!
        pre_bar = right[M+1]
        pre_gap = abs(acc[n-1]-acc[pre_bar] - (acc[pre_bar] - acc[M]))
        next_bar = M+1
        for nxt_bar in range(M+1,pre_bar)[::-1]:
            nxt_gap = abs(acc[n-1]-acc[nxt_bar] - (acc[nxt_bar]-acc[M]))
            if nxt_gap > pre_gap:
                next_bar = nxt_bar + 1
                break
            else:
                pre_gap = nxt_gap
        right[M] = next_bar
#print(right)

res = acc[n-1] + 1
for M in range(1,n-2):
    L = left[M]
    R = right[M]
    a,b,c,d = acc[L],acc[M]-acc[L],acc[R]-acc[M],acc[n-1]-acc[R]
    gap = max(a,b,c,d)-min(a,b,c,d)
    res = min(res,gap)

print(res)


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

using namespace std;

int main() {
	long long int n;
	cin >> n;

	long long int ans = 0;

	vector<long long int> V;

	for (long long int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		ans += a;
		V.push_back(a);
	}
	
	sort(V.begin(), V.end());

	cout << V[0] << " " << V[n - 1] <<  " " << ans << endl;

	return 0;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=1e3+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-7;
using namespace std;
int main()
{
	int jc[10]={1};
	int n,i,x,a=1,b=1;
	for(i=1;i<=8;i++)jc[i]=jc[i-1]*i;
	vector<int>v1,v2;
	scanf("%d",&n);
	for(i=1;i<=n;i++)v1.push_back(i),v2.push_back(i);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		int g=lower_bound(v1.begin(),v1.end(),x)-v1.begin();
		v1.erase(v1.begin()+g);
		a=a+g*jc[n-i];
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		int g=lower_bound(v2.begin(),v2.end(),x)-v2.begin();
		v2.erase(v2.begin()+g);
		b=b+g*jc[n-i];
	}
	printf("%d\n",abs(a-b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  int N, K;
  cin >> N >> K;
  //vector<double> p(N);
  vector<double> e(N);
  rep(i, N){
    double a;
    cin >> a;
    e[i] = (a+1)/2;
  }
  vector<double> s(N+1);
  s[0] = 0.0;
  for(int i = 1; i <= N; i++){
    s[i] += s[i-1] + e[i-1];
  }
  double ans = 0.0;
  for(int i = 0; i + K <= N; i++){
    if(ans < s[i+K] - s[i]){
      ans = s[i+K] - s[i];
    }
  }
  cout <<setprecision(18)<< ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
typedef struct { long x, y; } pt;

void solve() {

}

int main() {
    int k; string s;
    cin >> k >> s;
    for (int i = 0; i < s.length() && i < k; i++) {
        cout << s[i];
    }
    if (k < s.length())
        cout << "...";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
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); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll n, m; cin >> n >> m;
    vector<ll> p(m, 0);

    vector<bool> isco(n, false);
    vector<ll> cntwa(n, 0);

    rep(i, m){
        cin >> p[i]; --p[i];
        string s; cin >> s;

        if(isco[p[i]] == false){
            s == "AC" ? isco[p[i]] = true
                      : ++cntwa[p[i]];
        }
    }

    ll sumco = 0, sumwa = 0;
    rep(i, n){
        if(isco[i]){
            ++sumco;
            sumwa += cntwa[i];
        }
    }

    cout << sumco << " " << sumwa << endl;

return 0;
}

Measured memory_bytes: 4764
// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University
 
#include <bits/stdc++.h>
using namespace std;
 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)
 
#define pb push_back 
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
 
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number
 
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
 
typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);
 
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }
 
//inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
//ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
//ll add(ll a,ll b,ll M)  { return mod(( mod(a,M ) + mod(b,M )),M);     }
//ll sub(ll a, ll b,ll M) { return mod((mod(a,M ) + M - mod(b,M )),M);   }
//ll mult(ll a,ll b,ll M) { return  mod(( mod(a,M)*mod(b,M) ),M) ; }
//bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 
 
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
 
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; }
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;
 
/* For counting number of digits, directly do floor(log10(n)+1)*/
               /* -------------------------------Main Code------------------------------- */

int main(){
    int ans = 0;
    int n;cin>>n;
    if(n%2) cout<<n/2<<"\n";
    else cout<<n/2 -1 <<"\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  int div = min(A, B);
  int cnt = 0;
  while (true) {
    if (A % div == 0 && B % div == 0) cnt++;
    if (cnt == K) {
      cout << div << endl;
      return 0;
    }
    div--;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & (-x)) 
    
using namespace std;

const int MAXN = 200;

char edge[MAXN + 1][MAXN + 1];
   
int main() {
#if 0
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
		
	cin >> n;
	for(i = 1; i <= n; i++) {
		cin >> edge[i] + 1;
	}

	auto bfs = [&](int x) -> int {
		queue <int> Q;
		vector <int> dst(n + 1);
		Q.push(x);
		dst[x] = 1;

		while(Q.size()) {
			int nod = Q.front();
			Q.pop();
			for(int i = 1; i <= n; i++) {
				if(dst[i] == 0 && edge[nod][i] == '1') {
					Q.push(i);
					dst[i] = dst[nod] + 1;
				}
			}
		}

		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				if(edge[i][j] == '1' && (dst[i] + dst[j]) % 2 == 0) {
					return -2;
				}
			}
		}

		return *max_element(dst.begin(), dst.end());
	};

	int ans = -1;
	for(i = 1; i <= n; i++) {
		ans = max(ans, bfs(i));
	}

	cout << ans;
            
	return 0;
}       

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <iomanip>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define D 1.0000000000001
 
int main(){
	double n, m, d;
	cin >> n >> m >> d;

	if(d==0){
		cout << setprecision(8) << fixed << (m-1)/n << endl;
		return 0;
	}

	double a = 1.0;
	a *= ( n - d ) * 2.0/ n;
	a *= ( m - 1.0 ) / n;
	
	cout << setprecision(8) << fixed << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> ans;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		ans[a]++;
		ans[b]++;
	}
	loop(i, 1, n+1) cout << ans[i] << endl;
	return 0;
}

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

cnt=0
first_flg = True
for i in a:
    if not first_flg:
        if i-1 == before_num:
            cnt += c[i-2]
    first_flg = False
    before_num = i
print(sum(b)+cnt)    

Measured memory_bytes: 9192
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc067/tasks/arc067_a
# C - Factors of Factorial
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
A = [0] * N
pl = [0] * N
p0 = 0
for i in range(N):
    A[i] = gi()
    if (i % 2):
        p0 -= A[i]
    else:
        p0 += A[i]

pl[0] = p0

for i in range(1, N):
    pl[i] = A[i - 1] - pl[i - 1] // 2
    pl[i] *= 2
for i in range(N):
    print(pl[i], end=" ")


Measured memory_bytes: 29156
#include <iostream>
#include <cstdio>
#include <vector>
#define N 200005
using namespace std;

int n, q, s[N], v[N];
vector<int> g[N];

void f(int p, int q) {
	if(v[p]) return;
	v[p] = true;
	s[p] += q;
	for(int i=0; i<g[p].size(); i++) {
		f(g[p][i], s[p]);
	}
}

int main() {
	int i, a, b;
	cin >> n >> q;
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(q--) {
		scanf("%d%d", &a, &b);
		s[a] += b;
	}
	f(1, 0);
	for(i=1; i<=n; i++) printf("%d ", s[i]);
	return 0;
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(void){
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB")
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }
    
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> h(n);
    cin >> h;
    const int N = 1e5 + 5;
    lli dp[N];
    const lli inf = 1LL << 60;
    fill(dp, dp + N, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
      if (i + 1 < n) setmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
      if (i + 2 < n) setmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n - 1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>

#define ll long long

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

    bool flag = false;
    for(int i=A; i <= B; i++) {
        if(i % K == 0) {
            std::cout << "OK" << std::endl;
            flag = true;
            break;
        }
    }
    if(flag == false) {
        std::cout << "NG" << std::endl;
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
    
while(a > 0 || c > 0){
    c -= b;
    if(c <= 0) break;
    a -= d; 
}
if(a <= 0){
 cout << "No" << endl;
}else {
 cout << "Yes" << endl;
}

return 0;

}


Measured memory_bytes: 3624
#include <stdio.h>

int main(int argc, char *argv[])
{
    long long N, M, c = 0;
    scanf("%lld %lld", &N, &M);

    if ( N <= M/2 ){
        c = N;
        M-=N*2;
        c += M/4;
    } else {
        c = M/2;
    }
    printf("%lld\n", c);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
 
using namespace std;

typedef long long LL;

const int N = 1e6 + 10;
 
int main()
{
    LL n, a, b;
    cin >> n >> a >> b;
    
    LL res = n / (a + b) * a + min(a, n % (a + b));
    
    cout << res << endl;
    
    return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_paie
#define F first
#define S second
#define an size()


using namespace std;
vector<ll> q1,q2,q3,q4;
vector<ll> z1,z2,z3,z4;
int main()
{
    ll n,WW,fiestw,v,d;
    cin>>n>>WW>>fiestw>>v;
    q1.pb(v);
    for (ll i=1; i<n; i++)
    {
        cin>>d>>v;
        if (d==fiestw)
        {
            q1.pb(v);
        }
        if (d==fiestw+1)
        {
            q2.pb(v);
        }
        if (d==fiestw+2)
        {
            q3.pb(v);
        }
        if (d==fiestw+3)
        {
            q4.pb(v);
        }
    }

    sort(&q1[0],&q1[q1.an]);
    sort(&q2[0],&q2[q2.an]);
    sort(&q3[0],&q3[q3.an]);
    sort(&q4[0],&q4[q4.an]);
    reverse(&q1[0],&q1[q1.an]);
    reverse(&q2[0],&q2[q2.an]);
    reverse(&q3[0],&q3[q3.an]);
    reverse(&q4[0],&q4[q4.an]);
    z1.pb(0);
    z2.pb(0);
    z3.pb(0);
    z4.pb(0);
    for (ll i=0; i<q1.an; i++)
    {
        z1.pb(z1[z1.an-1]+q1[i]);
    }
    for (ll i=0; i<q2.an; i++)
    {
        z2.pb(z2[z2.an-1]+q2[i]);
    }
    for (ll i=0; i<q3.an; i++)
    {
        z3.pb(z3[z3.an-1]+q3[i]);
    }
    for (ll i=0; i<q4.an; i++)
    {
        z4.pb(z4[z4.an-1]+q4[i]);
    }
    ll ans=0;
    for (ll i1=0; i1<z1.size()              &&fiestw*i1<=WW                              ; i1++)
    {
        for (ll i2=0; i2<z2.size()          &&fiestw*i1+(fiestw+1)*i2<=WW                ; i2++)
        {
            for (ll i3=0; i3<z3.size()      && fiestw*i1+(fiestw+1)*i2+(fiestw+2)*i3<=WW ; i3++)
            {
                for (ll i4=0; i4<z4.size()      && fiestw*i1+(fiestw+1)*i2+(fiestw+2)*i3+(fiestw+3)*i4<=WW ; i4++)
                {
                    ans=max(ans,z1[i1]+z2[i2]+z3[i3]+z4[i4]);
                }
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
N, M, C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    total = 0
    for j in range(M):
        total += B[j]*A[i][j]
    total += C
    if total > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string s[105];
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(s[i]>s[j])
			{
				swap(s[i],s[j]);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<s[i];
	}
	return 0;
} 

Measured memory_bytes: 256
//----------------------------------------------------------------------
// ITP1_2_A:   Small, Large, or Equal
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <iostream>

//----------------------------------------------------------------------
// Definitions
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Entry point
//----------------------------------------------------------------------
int main()
{
    int a = 0, b = 0;

    std::cin >> a >> b;

    if( a < b )
    {
        std::cout << "a < b" << std::endl;
    }
    else if( a > b )
    {
        std::cout << "a > b" << std::endl;
    }
    else
    {
        std::cout << "a == b" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3080
/*input
475254
*/

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

int main() {
  ll n;
  cin >> n;
  string s;
  while (n > 0) {
    n--;
    s += 'a'+n%26;
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

Measured memory_bytes: 3632
N = int(input())
S = []
for i in range(N):
    S.append(input())

c0, c1, c2, c3 = [0, 0, 0, 0]

for s in S:
    if s == 'AC':
        c0 += 1
    elif s == 'WA':
        c1 += 1
    elif s == 'TLE':
        c2 += 1
    elif s == 'RE':
        c3 += 1

print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)

Measured memory_bytes: 16124
#include <cstdio>
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	char s[109];
	scanf("%s",&s);
	int len = strlen(s);
	printf("%c%d%c",s[0],len-2,s[len-1]);
		}

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s]
	sss=ss.copy()
	for i, c in enumerate(s[1:],1):
		if s[i-1]=='A' and s[i]=='C':
			ss[i]=1
		sss[i] = ss[i] + sss[i-1]
	
	for i in range(q):
		r, l=map(int, io().split())
		#rr=sum(ss[r-1:l])-ss[l-1]
		rr=sss[l-1]-sss[r-1]
		#ret.append(str(rr))
		print(rr)
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

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


int main() {

int N;
  
  cin >> N;
  vector<long long int>X(N);
  vector<long long int>Y(N);
  vector<long long int>Wa(N);
  vector<long long int>Sa(N);
    
  for(int i=0;i<N;i++){
    cin >> X.at(i) >> Y.at(i);
  }
  
  for(int i=0;i<N;i++){
    Wa.at(i)=X.at(i)+Y.at(i);
    Sa.at(i)=X.at(i)-Y.at(i);
  }
  sort(Wa.begin(), Wa.end());
  sort(Sa.begin(), Sa.end());
  
cout << max(Wa.at(N-1)-Wa.at(0),Sa.at(N-1)-Sa.at(0));

}


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

using namespace std;

using ll = long long;

ll h, w, n;
int cs = 1;

template <typename T>
using matrix = std::vector<std::vector<T>>;

constexpr long long mod = 1e9+9;

template <typename T>
matrix<T> modmul(const matrix<T> &l, const matrix<T> &r)
{
    matrix<T> ret(l.size(), std::vector<T>(r[0].size()));
    for (int i = 0; i < (int)l.size(); i++)
    {
        for (int k = 0; k < (int)r.size(); k++)
        {
            for (int j = 0; j < (int)r[0].size(); j++)
            {
                ret[i][j] += l[i][k] * r[k][j] % mod;
                ret[i][j] %= mod;
            }
        }
    }
    return ret;
}

template <typename T>
std::vector<T> modmul(const matrix<T> &a, const std::vector<T> &x)
{
    const int n = a.size();
    const int m = x.size();
    std::vector<T> ret(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            ret[i] += a[i][j] * x[j] % mod;
            ret[i] %= mod;
        }
    }
    return ret;
}

template <typename T>
matrix<T> eye(const int n)
{
    matrix<T> ret(n, std::vector<T>(n));
    for (int i = 0; i < n; i++)
        ret[i][i] = 1;
    return ret;
}

template <typename T>
matrix<T> modpow(matrix<T> x, long long n)
{
    auto ret = eye<T>(x.size());
    while (n)
    {
        if (n & 1)
            ret = modmul(ret, x);
        x = modmul(x, x);
        n /= 2;
    }
    return ret;
}


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

    while (cin >> w >> h >> n, h || w || n)
    {
        cout << "Case " << cs << ": ";
        cs++;
        bool f = false;
        set<ll> st = {h};
        map<ll, vector<ll>> mp;
        for (int i = 0; i < n; i++)
        {
            ll x, y;
            cin >> y >> x;
            if (x == 1)
                continue;
            st.insert(x);
            y--;
            mp[x].push_back(y);
            if (x == h && y == w)
            {
                f = true;
            }
        }
        if (f)
        {
            cout << 0 << endl;
            continue;
        }
        vector<vector<ll>> id(w, vector<ll>(w, 0));
        for (int i = 0; i < w; i++)
        {
            id[i][i] = 1;
            if (i)
                id[i][i - 1] = 1;
            if (i + 1 < w)
                id[i][i + 1] = 1;
        }
        vector<ll> x(w, 0);
        x[0] = 1;
        ll pre = 1;
        for (auto v : st)
        {
            x = modmul(modpow(id, v - pre), x);
            for (auto y : mp[v])
                x[y] = 0;
            pre = v;
        }
        cout << x[w - 1] << endl;
    }
}



Measured memory_bytes: 3360
def myAnswer(N:int,M:int,X:int,A:list) -> int:
   masu =[]
   for i in range(N+1):
      if(i in A):
         masu.append(1)
      else:
         masu.append(0)
   return min(sum(masu[:X]),sum(masu[X+1:]))


def modelAnswer():
   tmp=1
def main():
   N,M,X =map(int,input().split())
   A =list(map(int,input().split()))
   print(myAnswer(N,M,X,A[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
std::vector<int> V[200010];
int check[200010];

int func(int k)
{
	check[k] = 1;
	int ans = 1;
	for(int i=0;i<V[k].size();i++) if(check[V[k][i]]==0) ans+=func(V[k][i]);
	return ans;
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(d);
		V[d].push_back(c);
	}
	
	int ans = 0;
	for(int i=1;i<=a;i++)
	{
		if(check[i]==0)
		{
			int S = func(i);
			ans = ans>S?ans:S;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 24236
A = input()
B = input()
C = input()

cnt = {'a': 0, 'b': 0, 'c': 0}
S = {'a': A, 'b': B, 'c': C}
turn = 'a'

while True:
	if cnt[turn] >= len(S[turn]):
		break	
	pop = S[turn][cnt[turn]]
	cnt[turn] += 1	
	turn = pop

print(turn.upper())



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll MOD = 998244353;

ll modpow(ll a, ll b, ll m) {
  if (b == 0) return 1;
  ll ret;
  if (b % 2 == 0) {
    ll t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    ll t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> cnt(n, 0);
  REP(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll m = *max_element(ALL(a));
  if (a[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  FOR(i, 1, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  FOR(i, 1, m) {
    if (cnt[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    (ans *= modpow(cnt[i], cnt[i + 1], MOD)) %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
a = []
b = []
for i in range(N):
    a.append(list(map(int, input().split())))
for i in range(N):
    b.append(list(map(int, input().split())))
a_sorted = sorted(a, key = lambda x:-x[1])
b_sorted = sorted(b)

ans = 0
for i in range(len(b_sorted)):
    for j in range(len(a_sorted)):
        if(b_sorted[i][0] > a_sorted[j][0] and b_sorted[i][1] > a_sorted[j][1]):
            ans += 1
            a_sorted.pop(j)
            break
print(ans)

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

int main(){
	int a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	c=max(c,d);
	c=max(c,e);
	cout<<c<<'\n';
	return 0;
}


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

#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	vector<int>	vi;

int main(){
	const int Ne=1200;
	static bool er[Ne]; er[0]=er[1]=true;
	for(int i=2;i*i<Ne;i++) if(!er[i]) for(int j=i*i;j<Ne;j+=i) er[j]=true;
	vi p; rep(i,Ne) if(!er[i]) p.pb(i);

	int dp[15][1121]={};	dp[0][0]=1;
	rep(i,p.size()){
		for(int k=min(i+1,14);k>=1;k--){
			for(int j=p[i];j<=1120;j++){
				dp[k][j]+=dp[k-1][j-p[i]];
			}
		}
	}

	for(int n,k;scanf("%d%d",&n,&k),n;)	printf("%d\n",dp[k][n]);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){
    int cards[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++)
        cards[i][j] = 0;
    }

    int n;
    cin >> n;

    char c;
    int num;
    for(int i = 0; i < n; i++){
        cin >> c >> num;
        if(c == 'S')
            cards[0][num - 1] = 1;
        if(c == 'H')
            cards[1][num - 1] = 1;
        if(c == 'C')
            cards[2][num - 1] = 1;
        if(c == 'D')
            cards[3][num - 1] = 1;
    }

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(cards[i][j] == 0 && i == 0)
                cout << "S" << " " << j + 1 << endl;
            if(cards[i][j] == 0 && i == 1) 
                cout << "H" << " " << j + 1 << endl;
            if(cards[i][j] == 0 && i == 2)
                cout << "C" << " " << j + 1 << endl;
            if(cards[i][j] == 0 && i == 3)
                cout << "D" << " " << j + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
  } else {
    ll a = 1LL, b = 2LL, c;
    for (int i = 0; i < n - 1; i++) {
      c = a;
      a += b;
      b = c;
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll a,b,c,d,e,f;

int main(){
    cin>>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }if(b==c){
        cout<<a<<endl;
    }if(a==c){
        cout<<b<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  system("python3 -c \"h,w=map(int,input().split())\na=[list(map(int,input().split()))for _ in range(h)]\nans=[]\nfor i in range(h):\n  for j in range(w-1):\n    if a[i][j]%2:\n      a[i][j+1]+=1\n      ans.append([i+1,j+1,i+1,j+2])\n  if i<h-1 and a[i][w-1]%2:\n    a[i+1][w-1]+=1\n    ans.append([i+1,w,i+2,w])\nprint(len(ans))\nfor t in ans:\n  print(*t)\n\"");
  return 0;
}

Measured memory_bytes: 30972
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let mut ans = 0;
    for &c in s {
    	if c == b'1' {
        	ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
s = input().strip()
import re
r = 0
for mch in re.findall("((<+)(>+)|^>+|<+$)", s):
    n, m = sorted([len(mch[1]),len(mch[2])])
    if m == 0:
        x = len(mch[0])
        r += x*(x+1)//2
    else:
        r += m*(m+1)//2 + n*(n-1)//2
print(r)

#m = False
#cd = 0
#for c in s:
#    for b != c:
#        print(cd)


Measured memory_bytes: 28188
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

vector<ll> adj[2002],final(2002,0);

void answer(){
    ll n,m,ans1=0,k,x;
    cin>>n>>m>>k;
    for(int i=0;i<n-1;i++){
        adj[i+2].pb(i+1);
        adj[i+1].pb(i+2);
    }
    adj[m].pb(k);
    adj[k].pb(m);
    
    
    for(int i=1;i<=n;i++){
        std::queue<int> q;
        std::vector<int> vis(2002,0),dis(2002,0);
        q.push(i);
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(int j=0;j<adj[v].size();j++){
                if(vis[adj[v][j]]==0){
                    dis[adj[v][j]]=dis[v]+1;
                    q.push(adj[v][j]);
                    vis[adj[v][j]]=1;
                }
            }
        }
        for(int i=1;i<=n;i++){
            final[dis[i]]++;
        }
    }
    final[2]-=n;
    for(int i=1;i<n;i++) cout<<final[i]/2<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,j,i,p=0,k,l;
    cin>>n;p=p;
    for(i=1;i<=n;i++){p=p+n/i;
        if(n%i==0){
            p=p-1;
        }
    }
        cout<<p;
    
    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int size(int);

int main()
{
	
	int a, b,anser;
	bool judge = false;

	scanf("%d %d", &a, &b);

	anser = (size(b)*a) + b;

	for (int i = 1; i <= 400; i++) {
		if ((i*i) == anser) {
			judge = true;
		}
	}

	if (judge == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

int size(int suuti)
{
	if (suuti == 100) {
		return 1000;
	}
	else if (suuti >= 10 && suuti < 100) {
		return 100;
	}else {
		return 10;
	}
}

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

int main(){
    char s[3];
    int a = 0, b = 0;

    scanf("%s",s);

    for(int i = 0 ; i < 3;++i){
        if(s[i] == 'A')
            ++a;
        else 
            ++b;
    }
    if( a == 2 || b == 2)
        puts("Yes");
    else
        puts("No");


    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    string s,t; cin >> s >> t;

    int ans = 0;
    rep(i, s.size()) {
        if(s[i] == t[i]) ans ++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num, p;
    
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
        p.assign(N, 0);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        int ret = root(par[x]);
        p[x] += p[par[x]];
        return par[x] = ret;
    }

    int weight(int x){
        root(x);
        return p[x];
    }
    
    bool unite(int x, int y, int w){
        w += weight(x), w -= weight(y);
        x = root(x), y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]){
            par[x] = y, num[y] += num[x];
            p[x] = -w;
        }
        else{
            par[y] = x, num[x] += num[y];
            p[y] = w;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void clear(){
        fill(all(par), -1);
        fill(all(rank), 0);
        fill(all(num), 1);
        fill(all(num), 0);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    Union_Find_Tree uf(N);
    bool ans = true;
    rep(i, M){
        int u, v, d; cin >> u >> v >> d; u--, v--;
        if(!uf.unite(u, v, d)){
            ans &= (uf.weight(v)-uf.weight(u) == d);
        }
    }
    cout << (ans? "Yes" : "No") << endl;
}

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

int main() {
  int n;
  vector<string> s;

  cin >> n;

  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    s.push_back(tmp);
  }

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

  int ans = 1;
  string tmp = s.at(0);

  for (int i = 1; i < n; i++) {
    if (s.at(i) != tmp) {
      ans++;
      tmp = s.at(i);
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 11660
package main

import (
	"fmt"
)

func main() {
	var H, W, K int

	fmt.Scan(&H, &W, &K)

	c := make([][]string, H)
	for i := 0; i < H; i++ {
		c[i] = make([]string, W)
	}

	var line string
	for i := 0; i < H; i++ {
		fmt.Scan(&line)
		for j := 0; j < W; j++ {
			c[i][j] = line[j : j+1]
		}
	}

	var count int
	var Gcount int

	for i := 0; i < pow(2, H)-1; i++ {
		for j := 0; j < pow(2, W)-1; j++ {
			count = 0

			for h := 0; h < H; h++ {
				for w := 0; w < W; w++ {

					if refbit(i, h) == 0 && refbit(j, w) == 0 {
						if c[h][w] == "#" {
							count++
						}
					}

				}
			}
			if count == K {
				Gcount++
			}
		}
	}

	fmt.Println(Gcount)
}

func refbit(i int, b int) int {
	return (i >> uint(b)) & 1
}

func pow(x, y int) int {
	z := x
	for i := 0; i < y-1; i++ {
		z = z * x
	}
	return z
}


Measured memory_bytes: 1832
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    long long m,n,ans=0;
    cin>>m>>n;
    if((m==1)and(n==1))
    {
        puts("1");
        WAIT;
        rt0;
    }
    if(m==1)
    {
        cout<<n-2;
        WAIT;
        rt0;
    }
    if(n==1)
    {
        cout<<m-2;
        WAIT;
        rt0;
    }
    if((m>=2)and(n>=2)) ans+=(m-2)*(n-2);
    cout<<ans;
    WAIT;
    rt0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	int N;
	cin >> N;
	vector<pair<string, pint>> V(N);
	string s;
	int a;
	for(int i = 0; i < N; i ++){
		cin >> s >> a;
		V[i] = mp(s, mp(-a, i + 1));
	}
	sort(all(V));
	for(int i = 0; i < N; i ++){
		cout << V[i].sps << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int x = 0, ans = 0;
    for(int i = 0; i < n; i++) {
        x += (s[i] == 'I' ? 1 : -1);
        chmax(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  long long N;
  cin >> N;
  
  vector<long long>man(5,0);
  for(int i=0;i<5;i++){
    cin >> man[i];
  }
  
  long long min_man = 1000000000000001;
  for(int i=0;i<5;i++){
    if(min_man > man[i])
      min_man = man[i];
  }
  
  cout << (N + min_man - 1) / min_man + 4 << endl;
  
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int a,p;
  cin >> a >> p;
  cout << (3*a+p)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
     
    using namespace std;
     
    int n;
    int dp[100001]={0};
     
    int func(int *a){
        dp[n-1]= 0;
        dp[n-2]=a[n-1]-a[n-2];

            if(dp[n-2]<0)
                dp[n-2]=-dp[n-2];
   
      for(int i=n-3;i>=0;i--){
      	    int b=a[i]-a[i+1];
            int c=a[i]-a[i+2];
            if(b<0)
                b=-b;
            if(c<0)
                c=-c;
            dp[i]=min(dp[i+1]+b,dp[i+2]+c);
      }return dp[0];
    }
     
    int main()
    {
       cin>>n;
       int a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];
        cout<<func(a);
    }

Measured memory_bytes: 1024