akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

A,B,K = II()

if A-K>=0:
    print(A-K,B)
else:
    print(0,max(A+B-K,0))

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
#define ll long long

int main(){
	
	int n,m;
	cin>>n>>m;
	double arr[n];
	double sum = 0;
	
	for(int i = 0 ; i < n ; i++){
		cin>>arr[i];
		sum += arr[i];
	}
	
	int cnt = 0;
	sum /=  ( 4 * m );
	
	for(int i = 0 ; i < n ; i ++){
		if( arr[i] >= ( sum ) ){
			cnt++;
		}
	}
	if(cnt >= m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);
const int MAX = 1000020;
LL N;
LL a[MAX],b[MAX],c[MAX];

void Cin(LL a[])
{
    for(int i = 1;i<=N;i++)
        scanf("%lld",&a[i]);
}

int Find2(LL a[], LL n, LL x)
{
    int ans = std::upper_bound(a + 1, a + 1 + n, x) - a;
    ans = (ans == n+1) ? -1 : ans;
    return ans;
}

int Find1(LL a[], LL n, LL x)
{
    int ans = std::lower_bound(a + 1, a +1 + n, x) - a;
    ans = (ans == 0) ? -1 : ans - 1;
    return ans;
}


int main()
{
    cin>>N;
    Cin(a),Cin(b),Cin(c);
    sort(a+1,a+1+N),sort(b+1,b+1+N),sort(c+1,c+1+N);
    LL sum = 0;
    LL ai=0,ci = 0;
    for(int i = 1;i<=N;i++)
    {
        ai = Find1(a,N,b[i]);
        ci = Find2(c,N,b[i]);
       // cout<<ai<<" "<<ci<<endl;
        if(ai==-1||ci==-1)continue;
        sum += ai*(N - ci+1);
    }

    cout<<sum<<endl;


    return 0;
}


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

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

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

  cout << abs(A.back() - A.front()) << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

int n,x=0,y=0,z=0;
int cnt;
int main() {
	cin >> n;
	int k = n;
	x = 800 * n;
	for (int i = 0; i < n; i++) {
		if (k >= 15) {
			k = k - 15;
			cnt++;
		}
	}
	y = 200 * cnt;
	z = x - y;
	cout << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>

using namespace std;

int main(){

	string W, T;
	//x??¨y?????????????????????????°??????????????????????????????????????????????????????????
	int x,y, count, count_num = 0;
	getline(cin, W);

	for (;;){
		getline(cin, T);
		if (T == "END_OF_TEXT"){ break; }
		//string??????????????°????¶????????????????
		for (int i = 0; i < T.length(); i++){
			count = 0;
			//????????§??????????????°??????
		for (int j = 0; (T[i + j] != ' ') &&( W[j] && T[i + j]); j++){

				if (isupper(T[i + j]))
					T[i + j] = tolower(T[i + j]);
				if (isupper(W[j]))
					W[j] = tolower(W[j]);

				//W??¨T????????´??????????????????
				if (W[j] == T[i + j]) count++;

				x = i;//???????????????
				y = i + j;//???????????????
		}

			if (count == (W.length()) && (!islower(T[y + 1]))){//?????????????????????????°????????????????????????????

				if (x == 0){//T[0]?????????????????????-1????????§?????\????????????
					count_num++;
				}
				else if (!islower(T[x - 1])){//!T[0]????????§???????????????????°???????????????\
					count_num++;
				}

			}
		
		}
	}//??°??????????????????

	cout << count_num << endl;



	return 0;
}

Measured memory_bytes: 1196
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int k = sc.nextInt();
        String s = sc.next();
        if (s.length() <= k) {
            System.out.println(s);
            return;
        }

        System.out.println(s.substring(0, k) + "...");
    }
}



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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

# (鍵の購入コスト, 開けられる宝箱)
keys = [None] * M
for i in range(M):
    c, _ = MAP()
    # どの宝箱を開けられるのかをbitで持っておく
    s = 0
    for a in [a-1 for a in LIST()]:
        s += 1 << a
    keys[i] = (c, s)

# dp[i][j] := i個目の鍵まで見て、集合jの宝箱を開けるための最小コスト
dp = list2d(2, 1<<N, INF)
dp[0][0] = 0
for i in range(M):
    # 今回の鍵で開けられる宝箱の集合s
    s = keys[i][1]
    c = keys[i][0]
    cur = i % 2
    nxt = (i+1) % 2
    # 今回の鍵を買わない遷移
    dp[nxt] = dp[cur][:]
    for j in range(1<<N):
        if dp[cur][j] != INF:
            m = j | s
            # 買う遷移：遷移元の開けられる宝箱の集合j | 今回の鍵で開けられる宝箱の集合s
            dp[nxt][m] = min(dp[nxt][m], dp[cur][j]+c)
ans = dp[M%2][-1]

if ans != INF:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 46044
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var r = parseInt( input,10 );

	console.log('%d', r*r);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 0 && s.substr(0, n/2) == s.substr(n/2, n/2))
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll nxt[35][100000], val[35][100000];

int main() {
    ll N, X, M;
    cin >> N >> X >> M;
    rep(i, M) nxt[0][i] = i * i % M, val[0][i] = i * i % M;
    
    ll ans = X;
    N--;

    rep(b, 34){
        rep(i, M){
            nxt[b + 1][i] = nxt[b][nxt[b][i]];
            val[b + 1][i] = val[b][i] + val[b][nxt[b][i]];
        }
    }

    repr(i, 35){
        ll bit = 1ll << i;
        if(bit <= N){
            ans += val[i][X];
            X = nxt[i][X];
            N -= bit;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 58288
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int n, l;
	cin >> n >> l;

	vector<pair<int, int>> s(n);
	rep(i, n) {
		cin >> s[i].first >> s[i].second;
		s[i].second *= -1;
	}
	sort(all(s));
	for (auto& p : s) p.second *= -1;

	int cur = 0;
	int ans = 0;
	int idx = 0;
	while (idx < n and cur < l) {
		ans++;
		int nxt = 0;
		while (idx < n and s[idx].first <= cur) {
			// show(s[idx].first)
			// show(cur)
			nxt = max(nxt, s[idx].second);
			idx++;
		}
		// show(idx)
		cur = nxt;
	}
	cout << ans << ' ';

	map<int,int> m;
	for(auto p : s){
		m[p.first]++;
		m[p.second]--;
	}
	int sum = 0;
	ans = 1e9;
	int i = 0;
	for(auto p : m){
		sum += p.second;
		i++;
		if(i == m.size()) break;
		ans = min(ans, sum);
		//cout << p.first << ' ' << p.second << endl;
	}
	cout << n - ans + 1 << endl;
	return 0;


	ans = 1e9;
	cur = 0;
	idx = 0;
	priority_queue<int, vector<int>, greater<int>> q;
	while (idx < n and cur < l) {
		while (idx < n and s[idx].first <= cur) { q.emplace(s[idx++].second); }
		int d = 0;
		int id = idx - 1;
		while(id >= 0 and s[id].second == cur){
			id--;
			d++;
		}
		show(d)
		ans = min<int>(ans, q.size() - d);
		cur = q.top();
		q.pop();
	}
	cout << n - ans + 1 << endl;
}



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

void show(int nums[], int n) {
    for (int k = 0; k < n; ++k) {
        if( k == n - 1) {
            cout << nums[k];
        } else {
            cout << nums[k] << " ";
        }
    }
    cout << endl;
}

void select_sort(int nums[], int n) {
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int min = i;
        for (int j = i; j < n; ++j) {
            if(nums[j] < nums[min]) {
                min = j;
            }
        }
        if(i != min) {
            int temp = nums[i];
            nums[i] = nums[min];
            nums[min] = temp;
            count++;
        }
    }
    show(nums, n);
    cout << count << endl;
}

int main()
{
    int n;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    select_sort(nums, n);
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
int main(void)
{
  int N;
  int person[26];
  while(cin >> N && N)
    {
      memset(person,0,sizeof(person));
      int rest;
      char top,second,ans;
      int topn=0,secondn=0,turn=-1;
      for(int i=1;i<=N;i++)
	{
	  rest=N-i;
	  char getter;
	  cin >> getter;
	  person[int(getter-'A')]++;
	  for(int k=0;k<2;k++)
	    {
	      int mx=-1;
	      for(int j=0;j<26;j++)
		{
		  if(k==0 && person[j]>mx)
		    {
		      mx=person[j];
		      top=char(int('A')+j);
		      topn=mx;
		    }
		  else
		    {
		      if(person[j]>mx && j!=int(top-'A'))
			{
			  mx=person[j];
			  second=char(int('A')+j);
			  secondn=mx;
			}
		    }
		}
	    }
	  if(topn-secondn>rest)
	    {
	      //cout << rest << ' ' << "Decide" << endl;
	      if(turn==-1)
		{
		  ans=top;
		  turn=i;
		}
	    }
	  //cout << top << ' ' << topn << ' ' << second << ' ' << secondn << endl;
	}
      if(turn!=-1 && topn!=second)
	{
	  cout << ans << ' ' << turn << endl;;
	}
      else
	{
	  cout << "TIE" << endl;
	}
    }
  return 0;
}



Measured memory_bytes: 3068
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype=np.int64).T

matr = csr_matrix(([1 for _ in range(M)], (edge[:2] - 1)), (N, N))
print(connected_components(matr, return_labels=False))


Measured memory_bytes: 57016
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define LL long long
#define MXN 10000
#define MOD 10000007

ifstream f("data.in");
ofstream g("data.out");

void solve(){
    LL a,b,c,k;
    cin>>a>>b>>c>>k;
    LL s =0;
    
    LL x = a+b;
    if(x>=k){
      if(a>=k) s+=k;
      else s+=a;
    }
    else{
        s+=a;
        k-=x;
        if(k) s-=k;
    }
    cout<<s<<"\n";
} 

int main() {
    solve();

    return 0;
}

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


typedef long long ll;
using namespace std;




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

    #ifdef FUN
        freopen("input.txt", "r",stdin);
        freopen("output.txt", "w",stdout);
    #else
        #define endl '\n'
    #endif // FUN

    ll a, b, c, d, e, f, g;
    cin>>a>>b>>c>>d>>e>>f>>g;

//    ll ans = 0;
//    vector<int> arr(3);
//    arr[0] = a; arr[1] = e; arr[2] = d;
//    sort(arr.begin(), arr.end());
//    ans += arr[0];
//    if(arr[0]&1) {
//        --arr[1]; --arr[2];
//        ans += 2;
//    }
//    ans += 2ll*(arr[1]/2ll);
//    ans += 2ll*(arr[2]/2ll);
//    ans += b;
//
//    ll ans2 = 0;
//    arr[0] = a; arr[1] = e; arr[2] = d;
//    sort(arr.begin(), arr.end());
//    ans2 += 2ll*(arr[0]/2ll);
//    ans2 += 2ll*(arr[1]/2ll);
//    ans2 += 2ll*(arr[2]/2ll);
//    ans2 += b;
//
//
//    ll sum = 0;
//    sum += b;
//    sum += 2ll*(d/2ll);
//    sum += 2ll*(e/2ll);
//    sum += 2ll*(a/2ll);
//    if ( (d%2) + (e%2) + (a%2) == 3 ) sum += 3ll;
//
//    ll minV = min(min(d, e), a);
//    ll sum2 = min(min(d, e), a)*3;
//    d -= minV;
//    e -= minV;
//    a -= minV;
//    sum2 += b;
//    sum2 += 2ll*(d/2ll);
//    sum2 += 2ll*(e/2ll);
//    sum2 += 2ll*(a/2ll);
//
//
//    cout << max(max(ans, sum), max(sum2, ans2)) << endl;
//
//    --a; d -= 2; e -= 2;
//    int mn = min(a, min(d, e));
//    if (mn > 0) a -= mn, d -= mn, e -= mn;
//    else mn = 0;
//
//    ++a; d += 2; e += 2;
//    int ans = 3 * mn;
//    if (a == 1) ans += d / 2 * 2 + e / 2 * 2 + ((d%2) + (e%2) + (a%2) == 3) * 3;
//    else {
//        mn = min(a, min(d, e));
//        a -= mn, d -= mn, e -= mn;
//        ans += 3 * mn + a / 2 * 2 + d / 2 * 2 + e / 2 * 2 + ((d%2) + (e%2) + (a%2) == 3) * 3;
//    }

    int cc = 0;
    if ( a % 2 == 1) cc++;
    if ( e % 2 == 1) cc++;
    if ( d % 2 == 1) cc++;
    ll ans = a+e+d+b;
    if ( cc == 1 ) ans--;
    if ( cc == 2 ) {
        ans--;
        ll mx = min(min(a, e), d);
        if ( mx == 0ll ) ans--;
    }
    //
    //if ( cc == 1 || cc == 2 ) ans--;
    //if (a % 2 == 1 && d % 2 + e % 2 == 1) --ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
void dfs(vector<vector<int> > &adj, vector<bool> &ok, int i) {
    ok[i] = true;
    for (int j : adj[i]) if (!ok[j]) dfs(adj, ok, j);
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > a(m);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int L; cin >> L;
            a[L-1].push_back(i);
        }
    }
    vector<vector<int> > adj(n);
    for (int l = 0; l < m; l++) {
        for (int j = 1; j < a[l].size(); j++) {
            adj[a[l][0]].push_back(a[l][j]);
            adj[a[l][j]].push_back(a[l][0]);
        }
    }
    vector<bool> ok(n, false);
    dfs(adj, ok, 0);
    cout << (find(ok.begin(), ok.end(), false) == ok.end() ? "YES\n" : "NO\n");
}


Measured memory_bytes: 8824
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] >= b[i]:
        cnt += b[i]
    else:
        cnt += a[i]
        b[i] -= a[i]
        cnt += min(b[i],a[i+1])
        a[i+1] -= min(b[i],a[i+1])
print(cnt)

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

const int N = 1010;
const int INF = 0x7f7f7f7f;

char s[N][N];
int dis[N][N];
int h, w, k;
std::queue <std::pair <int, int>> q;

bool check(int x, int y){
	return x >= 0 && x < h && y >= 0 && y < w && s[x][y] != '#';
}

void bfs(std::pair <int, int> p){
	dis[p.first][p.second] = 0;
	q.push(p);
	while (!q.empty()){
		std::pair <int, int> pair = q.front();
		q.pop();
		int x = dis[pair.first][pair.second];
		if (x == k){
			return;
		}
		if (check(pair.first + 1, pair.second) && dis[pair.first + 1][pair.second] == INF){
			dis[pair.first + 1][pair.second] = x + 1;
			q.push({pair.first + 1, pair.second});
		}
		if (check(pair.first - 1, pair.second) && dis[pair.first - 1][pair.second] == INF){
			dis[pair.first - 1][pair.second] = x + 1;
			q.push({pair.first - 1, pair.second});
		}
		if (check(pair.first, pair.second + 1) && dis[pair.first][pair.second + 1] == INF){
			dis[pair.first][pair.second + 1] = x + 1;
			q.push({pair.first, pair.second + 1});
		}
		if (check(pair.first, pair.second - 1) && dis[pair.first][pair.second - 1] == INF){
			dis[pair.first][pair.second - 1] = x + 1;
			q.push({pair.first, pair.second - 1});
		}
	}
}

int main(){
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; ++ i){
		scanf("%s", s[i]);
	}
	std::pair <int, int> now;
	for (int i = 0; i < h; ++ i){
		for (int j = 0; j < w; ++ j){
			if (s[i][j] == 'S'){
				now = {i, j};
			}
		}
	}
	memset(dis, 0x7f, sizeof(dis));
	bfs(now);
	int ans = INF;
	for (int i = 0; i < h; ++ i){
		for (int j = 0; j < w; ++ j){
			if (dis[i][j] != INF){
				ans = std::min(ans, 1 + (std::min(std::min(i, j), std::min(h - i - 1, w - j - 1)) + k - 1) / k);
			}
		}
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 4992
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[15][100010];
int main()
{
    int w;
    scanf("%d",&w);

    vector<int> weight;
    for(int i = 1; i <= w; i *= 6)
    weight.push_back(i);
    for(int i = 9; i <= w; i *= 9)
    weight.push_back(i);
    int n = (int)weight.size();

    for(int i = 0; i < 15; i++){
        for(int j = 0; j < 100010; j++){
            dp[i][j] = 1145141919810;
        }
    }
    for(int i = 0; i <= n; i++)
    dp[i][0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            dp[i + 1][j] = min(dp[i + 1][j],dp[i][j]);
            if(j >= weight[i]) dp[i + 1][j] = min(dp[i + 1][j],dp[i + 1][j - weight[i]] + 1);
        }
    }
    printf("%lld\n",dp[n][w]);
}

Measured memory_bytes: 12028
#include <iostream>
#include <string>
const int ALPH = 26;
std::string S, T;
int N;

char advance(char c) {
    return ((c - 'A') + N) % ALPH + 'A';
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> N >> S;
    for (char c: S) {
        T.push_back(advance(c));
    }
    std::cout << T << std::endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
g = []
ans = 0
for j in range(60):
    d = 0
    for i in range(n):
        d += a[i]&1
        a[i] >>= 1
    g.append(d)
for i in range(60):
    ans += g[i]*(n-g[i])*(pow(2,i,1000000007))
    ans = ans % (1000000007)
print(ans%(1000000007))

Measured memory_bytes: 122808
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	string s,t;
	cin >> s >> t;
	vector<char>s2, t2;
	for (int i = 0; i < s.length(); i++) {
		s2.push_back(s[i]);
		t2.push_back(t[i]);
	}
	for (int i = 0; i < s.length(); i++) {
		s2.insert(s2.begin(),s2[s.size()-1]);
		s2.pop_back();
		if (true == equal(s2.cbegin(), s2.cend(), t2.cbegin()))return cout << "Yes" << endl,0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
#include <array>
#include <cmath>

using namespace std;

int A, N;

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

	if(N % 500 <= A)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

class Main{

    static class Edge{
        int to,dis;
        Edge(int to,int dis){
            this.to = to;
            this.dis = dis;
        }
    }
    static int used[];
    static List<Edge> edgeList[];

    static boolean dfs(int v,int pos){
        if(used[v] > Integer.MIN_VALUE)return used[v] == pos;
        used[v] = pos;
        for(Edge e : edgeList[v]){
            if(!dfs(e.to,pos+e.dis))return false;
        }
        return true;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        edgeList = new ArrayList[N+1];
        for(int i=1;i<=N;++i)edgeList[i]=new ArrayList<>();
        used = new int[N+1];
        Arrays.fill(used,Integer.MIN_VALUE);
        for(int i=0;i<M;++i){
            int L = scan.nextInt();
            int R = scan.nextInt();
            int D = scan.nextInt();
            edgeList[L].add(new Edge(R,D));
            edgeList[R].add(new Edge(L,-D));
        }

        for(int i=1;i<=N;++i){
            if(used[i] > Integer.MIN_VALUE)continue;
            if(!dfs(i,0)){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");


    }
}

Measured memory_bytes: 173688
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int d=sc.nextInt();
    int x=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int total=x;
    for(int i=0;i<n;i++){
      for(int s=0;;s++){
        if(a[i]*s+1>d){
          break;
        }else{
          total++;
        }
      }
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 22612
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ


int n;
vector<int> h, mem;

int dp(int p){
  if (p == 0){
    mem[p]=0;
    return(mem[p]);
  }
  if (p == 1){
    mem[p] = abs(h[p]-h[p-1]);
    return (mem[p]);
  }
  if (mem[p] != INT_MAX){
    return (mem[p]);
  }
  mem[p] = min(dp(p-1)+abs(h[p]-h[p-1]),dp(p-2)+abs(h[p]-h[p-2]));
  return (mem[p]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  h.resize(n);
  mem.resize(n,INT_MAX);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  cout << dp(n-1) << '\n';
  return 0;
}

Measured memory_bytes: 6288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+9;
ll arr[maxn];
ll sum[maxn];
ll sz[maxn];
ll n,k;
int main(){
        ll a,b,c,d,e,f,g,h;
        ios::sync_with_stdio(0);
        cin>>n>>k;
        for(int i=1;i<=n;i++){
                cin>>arr[i];
                sum[i]=sum[i-1]+arr[i];
                sz[i]=sz[i-1];
                if(arr[i]>0)sz[i]+=arr[i];
        }
        g=0;
        h=0;
        for(int i=k;i<=n;i++){
                g=max(g,sz[i-k]+sz[n]-sz[i]);
                g=max(g,sz[i-k]+sz[n]-sz[i]+sum[i]-sum[i-k]);
               // if(g==20)cout<<i<<endl;
        }
        cout<<g<<endl;
        return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    ll n,a,b;
    cin>>n>>a>>b;
    ll m=a*(n-1)+b;
    ll M=b*(n-1)+a;
    fin(max(M-m+1,0LL));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>

using namespace std;

const int maxN = 1e5 + 10, modP = 1e9 + 7;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < ll, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

int x[maxN], a, b, n;
LL res;

int main() {
    cin >> n >> a >> b;
    FORU(i, 1, n) cin >> x[i];
    FORU(i, 2, n)
        if (1ll * a * (x[i] - x[i - 1]) > b)
            res += b;
        else
            res += 1ll * a * (x[i] - x[i - 1]);
    cout << res;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))


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

	if (s == "SUN") {
		cout << 7;
	}
	else if (s == "MON") {
		cout << 6;
	}
	else if (s == "TUE") {
		cout << 5;
	}
	else if (s == "WED") {
		cout << 4;
	}
	else if (s == "THU") {
		cout << 3;
	}
	else if (s == "FRI") {
		cout << 2;
	}
	else if (s == "SAT") {
		cout << 1;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		NavigableSet<Long> hs = new TreeSet<>();
		hs.add(1L);
		for (int i = 0; i < n; i++) {
			NavigableSet<Long> tmp = new TreeSet<>();

			for (long e : hs) {
				tmp.add(e * 2);
				tmp.add(e + k);
			}

			hs = tmp;
		}

		pr.println(hs.first());
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a-1;
  }

  for (int i = 1; i < N; i++){
    ans = max(ans, vec.at(i));
    if(vec.at(i-1) > vec.at(i)){
      // cout << "a" << endl;
      // cout << "ans " << ans << endl;
      if(ans - vec.at(i) > 1){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3784
import sys
S = sys.stdin.readline().rstrip()

if S == 'SUN':
    print(7)
if S == 'MON':
    print(6)
if S == 'TUE':
    print(5)
if S == 'WED':
    print(4)
if S == 'THU':
    print(3)
if S == 'FRI':
    print(2)
if S == 'SAT':
    print(1)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main()
{
  long long N,A,B;
  cin >> N >> A >> B;

  if (A > N){
    cout << N;
    return 0;
  }

  if (A + B > N){
    cout << A;
    return 0;
  }

  long long perN = N / (A + B);
  long long subN = N % (A + B) ;
  if (subN > A){
    cout << (A*perN + A);
  } else {
    cout << (A*perN + subN);
  }
  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 int long long
signed main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))cout<<"B"<<endl;
	else puts("A");
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
y=x.copy()
y.sort()
cr=y[n//2]
cl=y[n//2-1]

for i in range(n):
    if x[i]<=cl:
        print(cr)
    elif x[i]>=cr:
        print(cl)


Measured memory_bytes: 25228
from collections import defaultdict
from math import factorial

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

number = defaultdict(int)
for a in A:
    number[a] += 1

def combination(n, r):
    denominator = 1
    for i in range(n, n - r, -1):
        denominator *= i
    numerator = factorial(r)
    return denominator // numerator

combi = {}
combi2 = {}
for k, v in number.items():
    combi[k] = combination(v, 2)
    combi2[k] = combination(v - 1, 2)
combination_all = sum(combi.values())
# print(f"number:{number} combi:{combi} combi2:{combi2} combination_all:{combination_all}", file=sys.stderr)

for a in A:
    print(combination_all - (combi[a] - combi2[a]))

Measured memory_bytes: 38972
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

ll a[N], b[N], p[N];
void solve() {
    int n,m,k;
    cin>>n>>m>>k;
    REP(i,1,n) {
        cin>>a[i];
    }
    REP(i,1,m) {
        cin>>b[i];
        p[i] = p[i-1] + b[i];
    }
    int lo=0, hi = n+m, mi;
    while(lo<hi) {
        mi = 1 + (lo+hi)/2;
        bool ch = false;
        ll sum = 0;
        REP(i,0,min(mi,n)) {
            sum += a[i];
            if(mi-i<=m && sum+p[mi-i]<=k) {
                ch = true;
                break;
            }
        }
        if(ch) lo = mi;
        else hi = mi-1;
    }
    cout<<lo;
}
int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 8316
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    """
    解説聞いたらそりゃそうなんだが、どうやったらスラスラ思いつくんだ。。。
    """
    ans1 = [['.'] * 100 for _ in range(50)]
    for i in range(b // 49):
        for j in range(49):
            ans1[i * 2 + 1][j * 2 + 1] = '#'
    for j in range(b % 49):
        ans1[b // 49 * 2 + 1][j * 2 + 1] = '#'

    ans2 = [['#'] * 100 for _ in range(50)]
    for i in range(a // 49):
        for j in range(49):
            ans2[i * 2 + 1][j * 2 + 1] = '.'
    for j in range(a % 49):
        ans2[a // 49 * 2 + 1][j * 2 + 1] = '.'

    ans = ans1 + ans2
    print(100, 100)
    for i in range(100):
        print("".join(ans[i]))


if __name__ == "__main__":
    main()


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

int N;
int A[2005],Deg[2005];
bool G[2005][2005],Vis[2005];

vector<int> To[2005];
priority_queue<pair<int,int>> Q;

void DFS(int u){
	int i;
	Vis[u]=true;
	for(i=1;i<=N;i++)
		if(G[u][i]&&!Vis[i]){
			Deg[i]++;
			To[u].push_back(i);
			DFS(i);
		}
}

int main(){
	int i,j,u,v;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		scanf("%d",&A[i]);
	sort(A+1,A+N+1);
	for(i=1;i<N;i++)
		for(j=i+1;j<=N;j++)
			if(__gcd(A[i],A[j])>1)
				G[i][j]=G[j][i]=true;
	for(i=1;i<=N;i++)
		if(!Vis[i])
			DFS(i);
	for(i=1;i<=N;i++)
		if(!Deg[i])
			Q.push({A[i],i});
	while(Q.size()){
		u=Q.top().second;
		printf("%d ",Q.top().first);
		Q.pop();
		for(auto v:To[u])
			if(!--Deg[v])
				Q.push({A[v],v});
	}
	return 0;
}

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

using namespace std;
int n;
long long a[200001];
long long ok(long long x){
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        sum += abs(a[i] - (x + i));
    }
    return sum;
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    long long l = -1e10, r = 1e10;
    while(r - l > 1){
        long long mid = (l + r) / 2;
        if(ok(mid) <= ok(mid + 1)){
            r = mid;
        }
        else{
            l = mid;
        }
    }
    cout << min(ok(r), ok(l));
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

char F(int a, int b, char c){
	return (char)((a*(c-'a')+b)%26+'a');
}

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;i++){
		int alpha = 1;
		int beta = 0;
		string str;
		getline(cin, str);
		string tmp = str;

		while(str.find("this")==string::npos && str.find("that")==string::npos){
			str = tmp;
			beta++;
			if(beta>30){
				alpha++;
				beta=0;
			}
			for(int j=0;j<str.size();j++){
				if(str[j]>='a' && str[j]<='z'){
					str[j]=F(alpha, beta, str[j]);
				}
			}
			//cin >> str;
			//cout << alpha <<" "<<beta<<" "<<str <<endl;
		}
		cout << str <<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
// ツ堕スツ倍ツ陳キツ可可算
#include <stdio.h>
#include <string.h>

#define MAX_LEN	(80)

int main(void)
{
	int no;
	
	scanf("%d", &no);
	
	while (no--){
		char num_str[MAX_LEN + 2];
		char add_str[MAX_LEN + 2];
		int num_len, add_len;
		int i;
		int tmp;
		
		scanf("%81s", num_str);
		scanf("%81s", add_str);
		num_len = strlen(num_str);
		add_len = strlen(add_str);
		
		memmove(&num_str[MAX_LEN - num_len + 1], num_str, num_len);
		for (i = 0; i < MAX_LEN - num_len + 1; i++) num_str[i] = '0';
		num_str[MAX_LEN + 1] = '\0';
		
		memmove(&add_str[MAX_LEN - add_len + 1], add_str, add_len);
		for (i = 0; i < MAX_LEN - add_len + 1; i++) add_str[i] = '0';
		add_str[MAX_LEN + 1] = '\0';
		
		tmp = 0;
		for (i = MAX_LEN; i + 1; i--){
			num_str[i] = num_str[i] + (add_str[i] - '0') + tmp;
			if (num_str[i] > '9'){
				num_str[i] = num_str[i] - 10;
				tmp = 1;
			}
			else tmp = 0;
		}
		
		if (num_str[0] != '0') puts("overflow");
		else {
			for (i = 1; num_str[i] == '0'; i++);
			if (i == MAX_LEN + 1) puts("0");
			else puts(&num_str[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  rep(i, 3) {
    if (S[i] == T[i]) {
      ans++;
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
 ll a,b=100,c=0;
 cin>>a;
 while (b < a)
 {
     b=b+(b/100);
     c++;
 }

 cout<<c;

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int H, W, K;
	std::cin >> H >> W >> K;
	boost::multi_array<bool, 2> field(boost::extents[H][W]);
	int max = 0;
	for (auto i : boost::irange(H))
	{
		for (auto j : boost::irange(W))
		{
			char c;
			std::cin >> c;
			if (field[i][j] = c == '#')
			{
				++max;
			}
		}
	}
	int result = 0;
	for (auto x : boost::irange(1 << H))
	{
		for (auto y : boost::irange(1 << W))
		{
			int count = 0;
			for (auto i : boost::irange(H))
			{
				for (auto j : boost::irange(W))
				{
					auto a = 1 << i;
					auto b = 1 << j;
					if (((a & x) != 0 || (b & y) != 0) && field[i][j])
					{
						++count;
					}
				}
			}
			if (max - count == K)
			{
				++result;
			}
		}
	}
	std::cout << result << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3648
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    vector<ll> a(N + 1, 0);
    for(ll x = 1; x <= 200; x++){
        for(ll y = 1; y <= 200; y++){
            for (ll z = 1; z <= 200; z++){
                ll p = x * x + y * y + z * z + x * y + y * z + z * x;
                if (p <= N) a[p]++;
            }
        }
    }
    rep(i, N) pt(a[i + 1]);
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  queue<int> q;
  rep(i,n) {
    rep(j,a[i]) {
      q.push(i+1);
    }
  }
  
  vvi c(h,vi(w));
  rep(i,h) {
    if (i%2 == 0) {
      rep(j,w) {
        c[i][j] = q.front(); q.pop();
      }
    }
    else {
      for (int j = w-1; j >= 0; --j) {
        c[i][j] = q.front(); q.pop();
      }
    }
  }

  showv2(c);
  return 0;
}

Measured memory_bytes: 384