akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {

	int h, w;
	cin >> h >> w;
	vector<string> c(h);
	FOR(i, h)cin >> c[i];
	pair<int, int> s, g;
	FOR(i, h)FOR(j, w) {
		if (c[i][j] == 's')s = { i,j };
		else if (c[i][j] == 'g')g = { i,j };
	}
	queue<pair<int, int>> q;
	q.push({0,0});
	int ans[50][50];
	FOR(i, h)FOR(j, w)ans[i][j] = INF;
	bool vis[50][50] = {};
	ans[0][0] = 1; vis[0][0] = 1;
	int dy[4] = { 0,-1,0,1 }, dx[4] = { -1,0,1,0 };
	while (!q.empty()) {
		int Y = q.front().F;
		int X = q.front().S;
		q.pop();
		FOR(i, 4) {
			int y = Y + dy[i];
			int x = X + dx[i];
			if (!(y < 0 || y >= h || x < 0 || x >= w)) {
				if (!(vis[y][x] || c[y][x] == '#')) {
					q.push({ y,x });
					vis[y][x] = 1;
					ans[y][x] = ans[Y][X] + 1;
				}
			}
		}
	}
	int cnt = 0;
	FOR(i, h)FOR(j, w) {
		if (c[i][j] == '.')cnt++;
	}
	cout << max(cnt - ans[h - 1][w - 1], -1) << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 * 2440.cc: Kagisys
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef map<string,int> msi;

/* global variables */

msi us;

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    string ui;
    cin >> ui;
    us[ui] = i;
  }

  int m;
  cin >> m;

  bool dr = false;

  while (m--) {
    string ti;
    cin >> ti;

    msi::iterator mit = us.find(ti);
    if (mit == us.end()) cout << "Unknown " << ti << endl;
    else {
      dr = ! dr;
      string stat = dr ? "Opened" : "Closed";
      cout << stat << " by " << ti << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for (v = 0; v < n; v++) {
		if (M[u][v] == 0)continue;
		if (color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
	int u;
	for (u = 0; u < n; u++) {
		color[u] = WHITE;
	}
	tt = 0;

	for (u = 0; u < n; u++) {
		if (color[u] == WHITE)dfs_visit(u);
	}
	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}

int main(void) {
	int u, v, k, i, j;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			M[i][j] == 0;
		}
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		u--;
		for (j = 0; j < k; j++) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}
	
	dfs();

	return 0;
}


Measured memory_bytes: 3256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int N,M,a[100],b[100],tmp[10]={2,3,4,5,6,7,8,9},res=0;
bool edge[10][10]={};
int main() {
	cout << fixed << setprecision(18);
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
        edge[a[i]][b[i]]=true;
        edge[b[i]][a[i]]=true;
    }
    do{
        for(int i=0;i<=N-2;i++){
            //cout<<tmp[i]<<" ";
            //if(!edge[tmp[i]][tmp[i+1]]&&!edge[tmp[i+1]][tmp[i]]){continue;}
        }
        //cout<<endl;
        if(!edge[1][tmp[0]]&&!edge[tmp[0]][1]){continue;}
        for(int i=0;i<=N-3;i++){
            
            if(!edge[tmp[i]][tmp[i+1]]&&!edge[tmp[i+1]][tmp[i]]){res--;break;}
        }
        res++;
    }while(next_permutation(tmp,tmp+N-1));
    cout<<res<<endl;
} 


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

#define NAME_SIZE 10
#define POOL_SIZE 100000

int main(void){
	char* name[POOL_SIZE];
	int time[POOL_SIZE];
	
	char n_tmp[NAME_SIZE]={};
	char n_tmp2[NAME_SIZE];
	int t_tmp;
	
	int n,q;
	
	scanf("%d",&n);
	scanf("%d",&q);
	
	scanf("%s",n_tmp);
	for(int i=0;i<n;i++){
		scanf("%d",&t_tmp);
		
		scanf("%s",n_tmp2);
		if(strcmp(n_tmp,n_tmp2)!=0){
			name[i]=(char*)malloc(sizeof(char)*strlen(n_tmp));
			strcpy(name[i],n_tmp);
			strcpy(n_tmp,n_tmp2);
			
			time[i]=t_tmp;
		}else{
			name[i]=(char*)malloc(sizeof(char)*strlen(n_tmp));
			strcpy(name[i],n_tmp);
			time[i]=t_tmp;
			break;
		}
	}
	int count=0;
	for(int total_time=0;total_time<1000000;){
		for(int i=0;i<n;i++){
			if(time[i]==0){
			}
			else if(time[i]<=q){
				count++;
				total_time+=time[i];
				time[i]=0;
				printf("%s %d\n",name[i],total_time);
			}
			else{
				total_time+=q;
				time[i]-=q;
			}
		}
		if(count>=n){
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

LL x, y;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> x >> y;

    if(abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    double a, b, x; cin >> a >> b >> x;
    double lim = a * a * b;

    double ans = -1;
    if (x <= lim / 2) {
        double ok = 0, ng = a;
        FOR(i, 0, 100000) {
            double mid = (ok + ng) / 2;
            if (a * b * mid / 2 <= x)ok = mid;
            else ng = mid;
        }
        ans = pi / 2 - atan(ok / b);
    }
    else {
        double ok = 0, ng = b;
        FOR(i, 0, 100000) {
            double mid = (ok + ng) / 2;
            if (a * a * mid / 2 <= lim - x)ok = mid;
            else ng = mid;
        }
        ans = atan(ok / a);
    }
    cout << ans / pi * 180 << "\n";
}


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

int arr[3005][3005];
//char arr2[1000000];
int main()
{
    int test;
    scanf("%d",&test);
    //for(int xx=1;xx<=test;xx++)
    //{
        string a,b;
        cin>>a>>b;
        int len1=a.size();
        int len2=b.size();

        for(int i=0;i<=len1;i++)
        {
            arr[i][0]=0;
        }
        for(int i=0;i<=len2;i++)
        {
            arr[0][i]=0;
        }

        for(int i=1;i<=len1;i++)
        {
            for(int j=1;j<=len2;j++)
            {
                if(a[i-1]==b[j-1])
                {
                    arr[i][j]=arr[i-1][j-1]+1;
                }
                else
                {
                    arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
                }
            }
        }
        int res=arr[len1][len2];
        string cc;
        while(len1>=0 && len2>=0)
        {
            if(len1==0 || len2==0)
            {
                break;
            }
            if(arr[len1-1][len2]==arr[len1][len2])
            {
                len1--;
            }
            else if(arr[len1][len2-1]==arr[len1][len2])
            {
                len2--;
            }
            else
            {
                cc+=a[len1-1];
                //arr2[p++]=a[len1-1];
                len1--;
                len2--;
            }
        }
        reverse(cc.begin(),cc.end());
        //cout<<cc<<endl;
        cout<<cc<<endl;
        memset(arr,0,sizeof(arr));
    //}
}


Measured memory_bytes: 35584
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

ll dp[105][100005]; // dp[i][j] = max value that can be obtained using the first i + 1 items and weight limit j.

ll weight[101];
ll val[101];

ll knap (ll ni, ll wt){

    if(ni <= 0 || wt <= 0) {
        //LOG(0);
        return 0;
    }
    if(dp[ni][wt] != 0) {
        //cout << ni << " " << wt << " "<< (dp[ni][wt]) << '\n';
        return dp[ni][wt];
    }

    dp[ni][wt] = max(knap(ni-1, wt), (wt >= weight[ni]) ? (knap(ni-1, wt - weight[ni]) + val[ni]) : 0);

    //cout << ni << " " << wt << " "<< (dp[ni][wt]) << '\n';
    return dp[ni][wt];
}


int main(){

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

    ll N, W;
    cin>>N>>W;

    memset(dp, 0, sizeof(dp[0][0]) * 105 * 100005);

    REP(i,0,N){
        cin>>weight[i+1]>>val[i+1];
        //cout<<weight[i+1]<< " " << val[i+1] << '\n';
    }


    
    cout << knap(N, W) << endl;
    



    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

void solve(){
   int n, k, ans; cin >> n >> k;

   if(k == 1) cout << 0 << endl;
   else{
        ans = n % k;
        cout << min(ans, k - ans);
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s=scan.next();
        if(s.equals("hi")||s.equals("hihi")||s.equals("hihihi")||s.equals("hihihihi")||s.equals("hihihihihi")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main(void){
  int a, i;
  int b[4] = {0};
  scanf("%d",&a);
  for(i=0;i<4;i++){
    b[i] = a % 10;
    a /= 10;
  }
  for(i=0;i<3;i++){
    if(b[i] == b[i+1] && b[i] == b[i+2]){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    int h=n-m-k-k;
    int s=0;
    if(h>0) s=h/(m+k);
    int l=0;
    if(h>=0) l=1;
    printf("%d\n",l+s);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if(c*a <= b) {
			System.out.println(c);
		}else {
			System.out.println(b/a);
		}
	}

}


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

using namespace std;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;

const int N = 111;

char s[N][N];

int main()
{
  	ios_base::sync_with_stdio(false);
   	cin.tie(0);
    
    int n , m;
    cin >> n >> m;
    
    vector<vector<int>> dp(n + 1 , vector<int>(m + 1, 1e9));
    dp[1][0] = dp[0][1] = 0;

    for(int i = 0; i <= n; i++){
      s[i][0] = s[0][i] = '.';
    }

    for(int i = 1; i <= n; i++){
      cin >> (s[i] + 1);
      
    }

    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
        if(s[i][j] == '.'){
          dp[i][j] = min(dp[i-1][j] , dp[i][j-1]);
        }else{
          dp[i][j] = min(dp[i][j] , dp[i][j-1] + (s[i][j-1] == '.'));
          dp[i][j] = min(dp[i][j] , dp[i-1][j] + (s[i-1][j] == '.'));          
        }
      }
    }

    cout << dp[n][m] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int n,i,j=0,ans=0,sum=0;
  for(;;){
    scanf("%d",&n);
    if(n==0){
      break;
    }
  for(i=1;i<n;i++){
    for(j=i;j<n;j++){
      sum+=j;
      
      if(sum==n){
	ans++;
	break;
	}
      
      if(sum>n){
	sum=0;
	break;
      }
      
    }
  }
    printf("%d\n",ans);
    ans=0;
    sum=0;
  }
  return 0;
}

Measured memory_bytes: 1028
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 998244353; //1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;
ll cnt[maxn];
ll n, p;
string s;

ll go() {
	fill_n(cnt, maxn, 0);
	cnt[0]++;
	ll cur = 0;
	ll ten = 10;
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		(cur += ten * (ll)(s[i] - '0')) %= p;
		ans += cnt[cur];
		cnt[cur]++;
		(ten *= 10) %= p;
	}
	return ans;
}

ll naive() {
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll kek = s[i] - '0';
		if (kek % p == 0) {
			ans += i + 1;
		}
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> p;
	cin >> s;
	
	if (p == 2 or p == 5)
		cout << naive() << endl;
	else
		cout << go() << endl;
	return 0;

	vector<ll>primes = { 2,5,7,11,13,17,19,23,29 };

	while (true) {
		ll kek = gen() % 1000000000;
		s = to_string(kek);
		n = s.size();
		p = primes[gen() % (ll)(primes.size())];
		if (go() != naive()) {
			cout << kek << endl;
			return 0;
		}
	}

	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 2964
N = int(input())
S = [input().strip() for _ in range(N)]

hd = 0
tl = 0
bt = 0
ans = 0
for s in S:
    for i in range(len(S)-1):
        if s[i:i+2] == 'AB':
            ans += 1
    if s[0] == 'B' and s[-1] == 'A':
        bt += 1
    elif s[0] == 'B':
        hd += 1
    elif s[-1] == 'A':
        tl += 1

if bt == 0:
    ans += min(hd, tl)
else:
    ans += bt - 1
    if hd > 0 and tl > 0:
        ans += 2 + min(hd-1, tl-1)
    elif hd > 0 or tl > 0:
        ans += 1

print(ans)


Measured memory_bytes: 47704
W, H, N = gets.split.map(&:to_i)
left, right, bottom, top = [0, W, 0, H]

while gets
  x, y, a = $_.split.map(&:to_i)

  if a == 1
    left = [left, x].max
  elsif a == 2
    right = [right, x].min
  elsif a == 3
    bottom = [bottom, y].max
  elsif a == 4
    top = [top, y].min
  end
end

p [right - left, 0].max * [top - bottom, 0].max


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

int main()
{
	int n, less_min{1 << 30};
	scanf("%d", &n);
	std::vector<int> a(n), b(n);
	long long sum{};
	for (int i{}; i < n; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
		sum += a[i];
		if (b[i] < a[i] && b[i] < less_min)
			less_min = b[i];
	}
	if (less_min == 1 << 30)
		printf("0\n");
	else
		printf("%lld\n", sum - less_min);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define MX 100000
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll arr[3005];
ll n;
ll dp[3005][3005];
ll solve(ll i,ll j)
{

    if(i>j)
        return 0;
    if(i==j)
    {
        return arr[i];
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ret=0;
    ret=max(arr[i]-solve(i+1,j),arr[j]-solve(i,j-1));
    return dp[i][j]=ret;
}
int main()
{
    sc1(n);
    for(ll i=1;i<=n;i++)
    {
        sc1(arr[i]);
    }
    memset(dp,-1,sizeof dp);
    ll ans=solve(1,n);
    printf("%lld\n",ans);
    return 0;
}


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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long

const int N = 1e2 + 5, W = 1e5 + 5;
int dp[N][W], a[N], b[N], n;

int rec(int s, int w){
	if(s == n)
		return 0;
	if(dp[s][w] != -1)
		return dp[s][w];
	int temp = rec(s + 1, w);
	if(w - a[s] >= 0)
		temp = max(temp, b[s] + rec(s + 1, w - a[s]));
	return dp[s][w] = temp;
}
	
void solve(){
	int w;
	cin >> n >> w;
	memset(dp, -1, sizeof dp);
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] >> b[i];
	}	
	cout << rec(0, w);
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

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

vector<pair<int, int> > v;

int main()
{
  int h, w;
  cin >> h >> w;

  for(int i = 0; i < h; i++){
    string a;
    cin >> a;
    
    for(int j = 0; j < w; j++){
      if(a[j] == '#'){
        v.push_back(make_pair(i, j));
      }
    }
  }

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

  for(int i = 1; i < v.size(); i++){
    if(v[i-1].second > v[i].second){
      cout << "Impossible" << endl;
      return 0;
    }
  }

  cout << "Possible" << endl;

  return 0;
}



Measured memory_bytes: 256
"""
NTC here
"""
 
 
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

profile = 0
pypy = 1
 
 
def iin(): return int(input())


def lin(): return list(map(int, input().split()))


def main():
    n = iin()
    a = lin()
    q = iin()
    dc = {}
    for i in a:
        try:
            dc[i] += 1
        except:
            dc[i] = 1
    sm = sum(a)
    for i in range(q):
        b, c= lin()
        if b in dc:
            sm += c*dc[b] -b*dc[b]
            try:
                dc[c] += dc[b]
            except:
                dc[c] = dc[b]
            dc.pop(b)
        print(sm)






    




                

        

 
 
 
 
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
if pypy:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
    input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    if profile:
        import cProfile
        cProfile.run('main()')
    else:
        main()

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

int main()
{
    long long int D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int R = sc.nextInt();
  
  	if(N>=10){
      System.out.println(R);
    }else{
	  System.out.println(R+100*(10-N));
    }
}

}

Measured memory_bytes: 22996
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i, j=0;
	scanf("%d %d %d", &a, &b, &c);
	for(i=0; i<b-a+1; i++) {
		if(c%(a+i)==0) j++;
	}
	printf("%d\n", j);
		
	return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int getkey(char []);
int h1(int);
int h2(int);
int Getc(char);
#define M 1046527
#define L 14
typedef struct a{
  char H[L];
  bool X;
}has;
has hash[M];
void insert(char []);
bool find(char []);
int main(){
  int n,i;
  char X[L],command[7];
  for(i=0;i<M;i++){
    hash[i].X=false;
    hash[i].H[0]='\0';
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",command,X);
    if(command[0]=='i'){
      insert(X);
    }
    else{
      if(find(X))printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}
int Getc(char str){
  if(str=='A')return 1;
  else if(str=='C')return 2;
  else if(str=='G')return 3;
  else if(str=='T')return 4;
  else return 0;
}
int h1(int x){
  return x%M;
}
int h2(int x){
  return 1+(x%(M-1));
}
int getkey(char str[]){
  int sum=0,i,p=1;
  for(i=0;i<strlen(str);i++){
    sum+=p*Getc(str[i]);
    p*=3;
  }
  return sum;
}
void insert(char str[]){
  
  int num,i,h;
  num=getkey(str);
  for(i=0;;i++){
    h=(h1(num)+i*h2(num))%M;
    if(!hash[h].X){
      strcpy(hash[h].H,str);
      hash[h].X=true;
      return;
    }
  }
}
bool find(char str[])
{
  int i,num,h;
  num=getkey(str);
  for(i=0;;i++){
     h=(h1(num)+i*h2(num))%M;
     if(!strcmp(hash[h].H,str))return true;
     else if(strlen(hash[h].H)==0)return false;
  }
  return false;
}




Measured memory_bytes: 17088
/*Smile Please!*/
//hp1999
#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast() 	     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
 int p,q,r;
 
 cin>>p>>q>>r;
 
 cout<<min({p+q,q+r,r+p});
}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}


Measured memory_bytes: 256
module ABC126

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A
  private :: lowercase

  ! constants for this <module>
  integer(INT32), parameter, private :: len_string_max = 50_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1), private :: given_string
  integer(INT32),                        private :: index
  integer(INT32),                        private :: len_string

  ! contained <subroutine>s and <function>s are below
  contains

  function lowercase (upper) result(lower)

    ! arguments for this <function>
    character(len=1, kind=1), intent(in) :: upper

    ! return value of this <function>
    character(len=1, kind=1) :: lower

    lower(1:1) = char( ichar(upper(1:1)) + 32 )
    return

  end function

  subroutine task_A

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*    ) len_string, index
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! lowercasing the target string
    given_string(index:index) = lowercase( given_string(index:index) )

    ! STEP.03
    ! calculate & output the summation
    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') trim(given_string)

    ! STEP.END
    return

  end subroutine task_A

end module ABC126


program main

  ! <module>s to import
  use, non_intrinsic :: ABC126

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define maxn 100009
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
//const int LL_INF = 0x7fffffffffffffff,INF = 0x3f3f3f3f;

//LL init(LL a, LL b)
//{
//    LL res = 1;
//    while(b)
//    {
//        if(b & 1) res = res * a % MOD;
//        a = a * a % MOD;
//        b >>= 1;
//    }
//    return res;
//}
//
//void init2()
//{
//    int ans = 0;
//    for(int i=2; i<maxn; i++)
//        if(!vis[i])
//        {
//            primes[ans++] = i;
//            for(LL j= i*i; j<maxn; j+=i)
//                vis[j] = 1;
//        }
//}
//
//int gcd(int a,int b)
//{
//    return b==0?a:gcd(b,a%b);
//}
//





int main()
{
    int A, B;
    cin>>A >> B;
//    if(A > B)
//        swap(A,B);
//    if(A == B) cout<< "Yay!"<<endl;
//    else if( ((B-A)&1) && (16-B + A - 1) % 2 == 0) cout<< "Yay!"<<endl;
//    else cout<< ":(" <<endl;
    if(A <= 8 && B <= 8)
        cout<< "Yay!"<<endl;
    else
       cout<< ":(" <<endl;





	return 0;
}


Measured memory_bytes: 256
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


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

  if(s==u){
    a -= 1;
  }
  else{
    b -= 1;
  }
  cout << a << " " << b;
 
 
}

Measured memory_bytes: 3644
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

h,w = map(int,readline().split())


def f(h,w):
    ans = h*w
    for i in range(1,h):
        v1 = i*w
        if (h-i)%2==0 or w%2 == 0:
            v2 = (h-i)*w//2
        else:
            v2 = max((h-i)//2*w,w//2*(h-i))
        v3 = (h-i)*w - v2
        
        ans = min(ans,max(v1,v2,v3)-min(v1,v2,v3))
        #print(i,h,w,v1,v2,v3,ans)
    return ans

print(min(f(h,w),f(w,h)))






Measured memory_bytes: 9144
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  double n,m;
  long d;
  in(n,m,d);
  if(d==0)printf("%.10f\n",(m-1)/n);
  else printf("%.10f\n",2*(n-d)*(m-1)/(n*n));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    rep(i, n) cin >> x[i] >> y[i] >> a[i];

    int xmi = 0, ymi = 0, xma = w, yma = h;
    rep(i, n)
    {
        if (a[i] == 1)
        {
            xmi = max(xmi, x[i]);
        }
        else if (a[i] == 2)
        {
            xma = min(xma, x[i]);
        }
        else if (a[i] == 3)
        {
            ymi = max(ymi, y[i]);
        }
        else
        {
            yma = min(yma, y[i]);
        }
    }
    int ans=0;
    if ( xma>xmi && yma > ymi)
    {
        ans = (xma - xmi) * (yma - ymi);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
long long int powermod(long long int x, unsigned long long int y, long long int p){long long int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}

#define mod 1000000007
using namespace std;
#define inf 1e18
const ll INF = 1e18L + 5;
const ll maxn = 1e5 + 5;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };


int main()
{

    ll n;
    cin >> n;
    vector <ll> a(n + 1);
    rep(i, 1, n + 1)
    {
        cin >> a[i];
    }
    vector<ll> dp(n + 1, 0);
    dp[1] = 0;
    vector<ll> prefix(n + 1);
    prefix[1] = a[1];
    for (ll i = 3; i <= n; i += 2)
    {
        prefix[i] = prefix[i - 2] + a[i];
    }
    for (ll i = 2; i <= n; i++)
    {
        if (i & 1)
        {
            dp[i] = max(dp[i - 1], dp[i - 2] + a[i]);
        }
        else
        {
            dp[i] = a[i] + dp[i - 2];
            dp[i] = max(dp[i], prefix[i - 1]);
        }
    }
    cout << dp[n];
return 0;
}


Measured memory_bytes: 8012
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int n, v[50], c[50];
	cin >> n;
	int i,ans=0;
	for (i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}

	for (i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) {
			ans += (v[i] - c[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
result = []
count = 1
n = gets.chomp.to_i
while(count <= n) do
    if(count % 3 == 0)
        result << count
    elsif(count.to_s.match(/.+3|3.+/))
        result << count
    end
    count += 1
end
puts " " + result.join(" ")


Measured memory_bytes: 7320
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    char a,b;
    cin >> a >> b;
    bool abit = a == 'H',bbit = b == 'H';
    cout << (!(abit^bbit)? "H":"D") << endl;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[200000], sum[200001];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) { a[i] -= i; }
	sort(a, a + n);
	inc(i, n) { sum[i + 1] = sum[i] + a[i]; }
	
	LL ans = 1e15;
	inc(i, n) {
		setmin(ans, sum[n] - 2 * sum[i] + a[i] * (2 * i - n));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int n;
    cin >> n;
    map<string, int>mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC " <<"x " <<  mp["AC"] << endl;
    cout << "WA " <<"x " <<  mp["WA"] << endl;
    cout << "TLE " <<"x " <<  mp["TLE"] << endl;
    cout << "RE " <<"x " <<  mp["RE"] << endl;

}
    




Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();

		double x = Math.abs(x1 - x2);
		double y = Math.abs(y1 - y2);

		double distance = Math.sqrt(x * x + y * y);

System.out.printf("%.5f", distance);


	}
}


Measured memory_bytes: 28148
n = int(input())
a = list(map(int,input().split()))
asum = [0]*(n+1)

for i in range(n):
    asum[i+1] = asum[i] + a[i]

ans = 10**12
for i in range(1,n):
    snu = asum[i]
    arai = asum[-1] - asum[i]
    ans_ = abs(snu - arai)
    if ans >ans_:
        ans = ans_
        
print(ans)

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

int main() {
	int n,m;
	int max_x=-101, min_y=101;
	cin>>n>>m>>max_x>>min_y;
	if (max_x>=min_y) {
		cout<<"War"<<endl;
		return 0;
	}
	for (int i=0; i<n; i++) {
		int a; cin>>a;
		max_x = max(max_x, a);
	}
	for (int i=0; i<m; i++) {
		int a; cin>>a;
		min_y = min(min_y, a);
	}
	if (max_x < min_y)
		cout<<"No War"<<endl;
	else
		cout<<"War"<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$i = trim(fgets(STDIN));
$val = explode(" ",$i);

$a = $val[0] - ($val[2] + $val[4]) >= 0 && $val[2]-$val[4] >=0;
$b = $val[1] - ($val[3] + $val[4]) >= 0 && $val[3]-$val[4] >=0;

$r = $a && $b;

echo $r ?"Yes" :"No" ;

?>

Measured memory_bytes: 15380
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Queue;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		char[] s = ns(3);
		char[] t = ns(3);
		int ct = 0;
		for(int i = 0; i < 3; i++) {
			if(s[i] == t[i]) ct++;
		}
		out.println(ct);
	}
		
		
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 22484
import math
import sys


sys.setrecursionlimit(1000000)

X, Y = map(int, input().split())

# いけない
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2*Y < X:
    print(0)
    exit()
if Y > 2*X:
    print(0)
    exit()

# 何段目
dan = (X + Y) // 3

# 端から
x = X + Y
y = 0
while True:
    x -= 1
    y += 1
    if x - 2*y == 0:
        break


def comb(n, r):
    return (math.factorial(n)) // (math.factorial(n - r) * math.factorial(r))


dic = {}


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

# print(comb(dan, x - X) % 1000000007)
print(cmb(dan, x - X, mod))


Measured memory_bytes: 130748
#include <bits/stdc++.h>
using namespace std;
const int N=300005;
int n, q, v[N], ans[N];
vector<int> g[N];
void dfs(int x, int p, int val) {
	val+=v[x];
	ans[x]=val;
	for (auto y:g[x]) if (y!=p)
		dfs(y, x, val);
}
int main() {
	cin>>n >>q;
	for (int i=1, x, y;i<n;i++) {
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	while (q--) {
		int x, y;
		cin>>x>>y;
		v[x]+=y;
	}
	dfs(1, 0, 0);
	for (int i=1; i<=n; i++) cout<<ans[i]<<" \n"[i==n];
	return 0;
}

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

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int tmp = 0;
  int x;
  for(int i=0;i<N;i++){
    cin>>x;
  	if(x>=abs(K-x))
      tmp += abs(x-K);
     else
       tmp += x;
  }
  cout << tmp*2 << endl;
}

Measured memory_bytes: 256
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

P nyaxt[4] = {{1,-1},{1,1},{-1,1},{-1,-1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	long long l,n;cin>>l>>n;
	string s;cin>>s;
	vector<int> A;
	int t = 0;
	for(int i = 0; s.size() > i; i++){
		if(s[i]=='o'){
			t++;
		}else{
			if(t>1){
				A.push_back(t);
			}
			t=0;
		}
	}
	if(t>1){
		A.push_back(t);
	}
	long long ans = s.size();
	for(int i = 0; A.size() > i; i++){
		long long z = (A[i]-1)*3;
		for(int i = 0; n > i; i++){
			ans+=z;
			z*=2;
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 3248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int cur[MAXN+5], fa[2][MAXN+5], in[2][MAXN+5], c[MAXN+5], n, tot;
struct Edge{int to,nex,w; Edge(){} Edge(int _to, int _nex, int _w):to(_to),nex(_nex),w(_w){}}e[(MAXN<<2)+5]; bool book[(MAXN<<2)+5];
inline void Add(int a, int b, int w){e[tot] = Edge(b,cur[a],w), cur[a] = tot++, e[tot] = Edge(a,cur[b],w), cur[b] = tot++;}
void DFS(int p){for(rint u = cur[p]; ~u; u = cur[p]) if(cur[p]=e[u].nex, !book[u] && !book[u^1]) !e[u].w ? ++c[e[u].to], --c[e[u^1].to] : 0, book[u] = true, DFS(e[u].to);}
int main()
{
	n = read(), memset(cur,-1,-~n<<2); for(rint k = 0, i; k < 2; k++) for(i = 1; i <= n; ++in[k][fa[k][i++]=max(read(),0)]);
	for(rint i = 1; i <= n; i++) if((in[0][i]+in[1][i])&1){puts("IMPOSSIBLE"); return 0;} puts("POSSIBLE");
	for(rint i = 1; i <= n; Add(i,fa[0][i],0), Add(i,fa[1][i],1), i++); DFS(1); for(rint i = 1; i <= n; printf("%d ",c[i]), i++); putchar('\n'); return 0;
}

Measured memory_bytes: 11136
N, M = map(int, input().split())
s = []
c = []
check = [-1 for _ in range(N)]
muri = False
for _ in range(M):
    tmp = list(map(int, input().split()))
    s.append(tmp[0])
    c.append(tmp[1])
 
result = [0 for _ in range(N)]
 
for idx, S in enumerate(s):
    if check[S-1] < 0:
        result[S-1] = str(c[idx])
        check[S-1] = c[idx]
        if (S == 1) and c[idx] == 0:
            if N != 1:
                muri = True
                break
    else:
        if check[S-1] != c[idx]:
            muri = True
            break
if result[0] == 0:
    result[0] = 1
a = ''
reigai = False
if N==1 and M==0:
    reigai = True
for i in result:
    a += str(i)
if muri:
    print(-1)
else:
    if reigai:
        print(0)
    else:
        print(int(a))

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

int main(int argc, char const *argv[])
{
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if (a[0]==a[2])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256