akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N;
    ll S=0;
    cin>>N;
    vll A(N);
    map<ll,ll> cnt; //cnt[i] := 配列Aのなかにiが何個あるか
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
        S += A[i];
        cnt[A[i]]++;
    }

    ll Q;
    cin>>Q;
    ll B,C;
    for (size_t i = 0; i < Q; i++)
    {
        cin>>B>>C;
        S += (C-B)*cnt[B];
        cnt[C]+=cnt[B];
        cnt[B]=0;
        cout<<S<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 10040
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int i,n,c=1;
	cin>>n;
	vi h(n);
	for0(i,n) cin>>h[i];
	int m = h[0];
	for(i=1 ; i<n ; i++){
		if(h[i]>=m){
			m = h[i];
			c++;
			}
		}
	cout<<c<<nw;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint num[100100];
int a[100100];
int main()
{
	int n;cin>>n;
	memset(num,0,sizeof(num));
	rep(i,n){
		cin>>a[i];num[a[i]]++;
	}
	if(a[0]>0){
		cout<<0<<endl;return 0;
	}
	lint out=1,mo=998244353;
	REP(i,1,n){
		out*=num[a[i]-1];out%=mo;
	}
	cout<<out<<endl;
}


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

using namespace std;

const int N = 100;
const int C = (int) 1e9;
const int V = (int) 1e3;
int n_items;
int cap;
int64_t dp[N * V + 1];
const int64_t INF = (int64_t) N * C + 1;

// dp[sumv]: minimum weight that has the total value of sumv

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

    cin >> n_items >> cap;

    fill(dp, dp + N * V + 1, INF);
    dp[0] = 0;

    for (int i = 1; i <= n_items; i++) {
        int w, v;
        cin >> w >> v;

        for (int sumv = N * V; sumv >= v; sumv--) {
            dp[sumv] = min(dp[sumv], dp[sumv - v] + w);
        }
    }

    for (int sumv = N * V; sumv > 0; sumv--) {
        if (dp[sumv] <= cap) {
            cout << sumv << '\n';
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int D = sc.nextInt();

		int[] x = new int[H * W + 1];
		int[] y = new int[H * W + 1];

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int a = sc.nextInt();
				x[a] = i;
				y[a] = j;
			}
		}

		int[] d = new int[H * W + 1];
		for (int i = D + 1; i <= H * W; i++) {
			d[i] = d[i - D] + Math.abs(x[i] - x[i - D]) + Math.abs(y[i] - y[i - D]);
		}

		int Q = sc.nextInt();
		for (int i = 0; i < Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(d[r] - d[l]);
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 56916
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)

vector<int> makeFactor(int x) {
	vector<int> factors;
	factors.push_back(2);
	for (size_t i = 3; i <= sqrt(x); i+=2)
	{
		bool flag = false;
		Foreach(item, factors) if (i%item == 0) { flag = true; break; }
		if (!flag) factors.push_back(i);
	}
	return factors;
}

vector<int> graph[10];
ll ans = 0;

int dfs(int current, vector<bool> used) {
	if (used[current]) return 0;
	used[current] = true;
	bool all = true;
	Foreach(item, used) if (!item) all = false;
	if (all)return 1;
	Foreach(item, graph[current]) {
		ans += dfs(item, used);
	}
	return 0;
}

int main(){
	int N, M;
	cin >> N >> M;
	Rep(i, M) {
		int a, b;
		cin >> a >> b;
		graph[a-1].push_back(b-1);
		graph[b-1].push_back(a-1);
	}
	vector<bool> used(N, false);
	dfs(0, used);
	out(ans);
}



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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abt = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = abt[0];
        var b = abt[1];
        var t = abt[2];

        var k = (t * 10 + 5) / (a * 10) * b;
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13268
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

vector<ll> search(vector<ll> & u, ll x) {
	auto it = lower_bound(u.begin(), u.end(), x);
	vector<ll> ret;
	if (it != u.end()) {
		ret.push_back(*it);		
	}
	if (it != u.begin()) {
		it--;
		ret.push_back(*it);
	}
	return ret;

}


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

	vector<ll> s(a);
	vector<ll> t(b);

	rep(i, a) {
		cin >> s[i];
	}
	rep(i, b) {
		cin >> t[i];
	}
	rep(i, q) {
		ll x;
		cin >> x;

		ll ans = 1e12;

		// s -> t
		vector<ll> ret_s = 	search(s, x);
		for(ll x_s : ret_s) {
			vector<ll> ret_t = search(t, x_s);
			for(ll x_t : ret_t) {
				ll cur = abs(x - x_s) + abs(x_s - x_t);
				if (cur < ans) {
					ans = cur;
				}
			} 
		} 	


		// t -> s
		vector<ll> ret_t = 	search(t, x);
		for(ll x_t : ret_t) {
			vector<ll> ret_s = search(s, x_t); 
			for(ll x_s : ret_s) {
				ll cur = abs(x - x_t) + abs(x_t - x_s);
				if (cur < ans) {
					ans = cur;
				}
			} 
		} 
		cout << ans << endl;	
	}

	return 0;
}


Measured memory_bytes: 4400
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    X = int(input())
    if X >= 30:
        print("Yes")
    else:
        print("No")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9880
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    while(1){
        int N,M;
        scanf("%d %d",&M,&N);
        if(N==0&&M==0)break;
        int MAX=7368791;
        bool flag[7368792];
        rep(i,MAX+1){flag[i]=false;}
        for(int i=M;i<=MAX;i++){
            if(flag[i]){
            }else{
                if(N==0){
                    printf("%d\n",i);break;
                }
                N--;
                for(int j=i;j<=MAX;j+=i){
                    flag[j]=true;
                }
            }
        }
    }
}



Measured memory_bytes: 9804
#include<string>
#include<iostream>
using namespace std;
int a[50];
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(a[s[i]]){
			cout<<"no"<<endl;
			return 0;
		}
		a[s[i]]=1;
	}
	cout<<"yes"<<endl;
	return 0;
} 

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

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

Measured memory_bytes: 512
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

INF = float('inf')
ans_l, ans_r = -INF, INF
for l, r in lr:
    ans_l = max(ans_l, l)
    ans_r = min(ans_r, r)
print(max(0, ans_r-ans_l+1))

Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(int i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,d,a,ans=0;
    cin>>n>>k;
    vector<vector<int>> v(n+1);
    fori(i,1,k){
    	cin>>d;
    	fori(j,1,d){
    		cin>>a;
    		v[a].pb(i);
    	}
    }
    fori(i,1,n){
    	if(v[i].empty())
    		ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int m, k;
    cin>>m>>k;
    if(m == 0){
        if(k != 0){
            cout<<"-1\n";
        }
        else cout<<"0 0";
        return 0;
    }
    int terms = power(2, m);
    if(k == 0){
        for(int i = 0; i < terms; i++) cout<<i<<' '<<i<<' ';
        return 0;
    }
    if(k > terms - 1 || m == 1){
        cout<<-1;
        return 0;
    }
    cout<<0<<' '<<k<<" 0 ";
    for(int i = 1; i <= terms - 1; i++) {
        if(i == k) continue;
        cout<<i<<' ';
    }
    cout<<k<<' ';
    for(int i = terms - 1; i > 0; i--) {
        if(i == k) continue;
        cout<<i<<' ';
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
	int i,n,num[10000];
	long long int sum,min,max;
	scanf("%d",&n);
	min=1000000;
	max=-1000000;
	sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		if(num[i]<min)
			min=num[i];
		if(num[i]>max)
			max=num[i];
		sum=sum+num[i];
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int  main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	int AB=A-B;
	printf("%d\n",AB<C?C-AB:0);
}

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

check = A[0]
A = A[1:]
while True:
  if check == "a":
    if len(A) == 0:
      print("A")
      exit()
    check = A[0]
    A = A[1:]
  elif check == "b":
    if len(B) == 0:
      print("B")
      exit()
    check = B[0]
    B = B[1:]
  elif check == "c":
    if len(C) == 0:
      print("C")
      exit()
    check = C[0]
    C = C[1:]

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sum[3][n+1];
    rep(i,3)sum[i][0]=0;
    /*
    int Rs[n+1],Bs[n+1],Gs[n+1];
    Rs[0]=0;
    Bs[0]=0;
    Gs[0]=0;
    */
    //cout<<s<<endl;
    char color[3]={'R','G','B'};
    rep(i,n){
        rep(l,3){
            sum[l][i+1]=sum[l][i];
            if(s[i]==color[l]){
                sum[l][i+1]+=1;
            }
        }
    }
    /*
    rep(k,3){
        rep(i,n+1)cout<<sum[k][i]<<" ";
        cout<<endl;
    }
    */
    

    long long ans=0;
    
    int num[3]={1,2,4};
    for(int i=0;i<n;i++){
        int now=0;
        char start=s[i];

        rep(l,3)if(s[i]==color[l])now=l;

        for(int k=i+1;k<n;k++){
            //cout<<s[k]<<" "<<start<<endl;
            if(s[k]==start)continue;

            int diff=k-i;
            int tmp=0;
            int second_color;
            //long long nowcolor;
            rep(l,3)if(s[k]==color[l])second_color=l;
            //cout<<start<<" "<<s[k]<<" "<<endl;
            rep(l,3){
                if(l==now||l==second_color)continue;

                tmp+=sum[l][min(k+diff,n)]-sum[l][k];
                //cout<<tmp<<" ";
                tmp+=sum[l][n]-sum[l][min(k+diff+1,n)];
                //cout<<tmp<<" ";
            }
            
            //cout<<tmp<<endl;
            ans+=tmp;
        
        }
    }
    cout<<ans<<endl;
    /*
        rep(l,3){
            if(s[k]==color[l] && num[l]^now!=0){
                //未だにとっていない色だとわかる=とる
                
            }
        }
        */
    return 0;

}
/*


*/


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

int main() {	

	ll n; cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 1;
	bool zeroExist = false;
	for (ll i = 0; i < n; i++) {
		if (a[i] == 0) {
			zeroExist = true;
			break;
		}
		if (ans > 1000000000000000000LL / a[i]) {
			ans = -1;
			break;
		}
		else {
			ans *= a[i];
		}
	}
	if (zeroExist) cout << 0 << endl;
	else cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////
#define MAX_V 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
//辺を表す構造体{行き先、容量、逆辺}
struct edge{int to,cap,rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];//dfsですでに調べたかのフラグ
//fromからtoへの流量capの辺をグラフに追加
void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,static_cast<int>(G[to].size())});
    G[to].push_back((edge){from,0,static_cast<int>(G[from].size()-1)});
}
//増加パスをdfsで探す
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,inf);
        if(f==0)return flow;
        flow+=f;
    }
}
/////////////////////////////////////////////
int main(){
    int v,e;cin>>v>>e;
    while(e--){
        int u,v,c;cin>>u>>v>>c;
        add_edge(u,v,c);
    }
    cout<<max_flow(0,v-1)<<endl;
    
    return 0;
}



Measured memory_bytes: 27624
s = input()
if s == "SSS":
    print(0)
if s == 'SSR' or s == 'SRS' or s == 'RSS'or s == 'RSR':
    print(1)
if s == 'RRS'or s == 'SRR':
    print(2)
if s == 'RRR':
    print(3)


Measured memory_bytes: 61812
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s1 = iterator.next().unwrap().to_uppercase().chars().next().unwrap();
    let s2 = iterator.next().unwrap().to_uppercase().chars().next().unwrap();
    let s3 = iterator.next().unwrap().to_uppercase().chars().next().unwrap();

    return format!("{}{}{}", s1, s2, s3);
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, D, X; cin >> N >> D >> X;
  vi A(N); rep(i,N) cin >> A.at(i);
  
  int choco =0;
  rep(i,N) {
    for (int j = 0; 1+j*A.at(i) <= D; j++) {
      choco++;
    }
  }
  
  choco += X;
  cout << choco << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,a[100005],g1[100005],g2[100005],ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    g1[0]=a[0];
    g2[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        g1[i]=gcd(a[i],g1[i-1]);
    }
    for(int i=n-2;i>=0;i--){
        g2[i]=gcd(a[i],g2[i+1]);
    }
    for(int i=0;i<n;i++){
        ans=max(ans,gcd(g2[i+1],g1[i-1]));
    }
    cout<<ans<<endl;
    return(0);
}

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

#define NIL -1
#define MAX 25

class Node{
public:
  int key;
  Node* parent;
  Node* left;
  Node* right;

  Node(){
    parent = NULL;
    left = NULL;
    right = NULL;
  }
};

Node* root = NULL;

void preOrder(Node* n){
  printf(" %d",n->key);
  if(n->left != NULL) preOrder(n->left);
  if(n->right != NULL) preOrder(n->right);
};

void inOrder(Node* n){
  if(n->left != NULL) inOrder(n->left);
  printf(" %d",n->key);
  if(n->right != NULL) inOrder(n->right);
}

void insert(int k){
  Node* n = root;
  Node* new_node = new Node;
  new_node->key = k;

  if(root == NULL){
    root = new_node;
    return;
  }

  while(true){
    if(k < n->key){
      if(n->left != NULL) n = n->left;
      else{
        n->left = new_node;
        new_node->parent = n;
        return;
      }
    }
    else{
      if(n->right != NULL) n = n->right;
      else{
        n->right = new_node;
        new_node->parent = n;
        return;
      }
    }
  }
}

Node* find(int key){
  Node* n = root;

  while(n != NULL){
    if(n->key == key) break;
    n = (key < n->key) ? n->left : n->right;
  }

  return n;
}

int main(){

  int n;
  scanf("%d", &n);

  char c[10];
  int key;
  for(int i=0; i<n; i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(c[0] == 'p'){
      inOrder(root); printf("\n");
      preOrder(root);printf("\n");
    }
    else{
      scanf("%d",&key);
      if(find(key) != NULL) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 21924
import sys
from heapq import heappush, heappop
T = int(input())
for _ in range(T):
	n, a, b, c, d = map(int, input().split())
	dp = dict()
	dp[n] = 0
	q = [(0, n)]
	def add(x, v):
		if x not in dp:
			dp[x] = v
			return True
		elif dp[x] > v:
			dp[x] = v
			return True
		else:
			return False

	while True:
		l = heappop(q)
		if l[1] == 0:
			break
		x = l[1]
		if x%2 == 0:
			v = min(a, d*(x//2)) + dp[x]
			if add(x//2, v):
				heappush(q, (v, x//2))
		else:
			v = min(a+d, d + d*(x//2)) + dp[x]
			if add(x//2, v):
				heappush(q, (v, x//2))
			v = min(a+d, d + d*(x//2+1)) + dp[x]
			if add(x//2+1, v):
				heappush(q, (v, x//2+1))

		if x%3 == 0:
			v = min(b, d*2*(x//3)) + dp[x]
			if add(x//3, v):
				heappush(q, (v, x//3))
		else:
			m = x%3
			v = min(b+d*m, d*m + d*2*(x//3)) + dp[x]
			if add(x//3, v):
				heappush(q, (v, x//3))
			v = min(b+d*(3-m), d*(3-m) + d*2*(x//3 + 1)) + dp[x]
			if add(x//3+1, v):
				heappush(q, (v, x//3+1))

		if x%5 == 0:
			v = min(c, d*4*(x//5)) + dp[x]
			if add(x//5, v):
				heappush(q, (v, x//5))
		else:
			m = x%5
			v = min(c+d*m, d*m + d*4*(x//5)) + dp[x]
			if add(x//5, v):
				heappush(q, (v, x//5))
			v = min(c+d*(5-m), d*(5-m) + d*4*(x//5 + 1)) + dp[x]
			if add(x//5+1, v):
				heappush(q, (v, x//5+1))

	print(dp[0])

Measured memory_bytes: 96120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };




int main()
{
	int n, limit, w[222];
	cin >> n >> limit;
	rep (i, n)
		cin >> w[i];
	sort(w, w + n, greater<int>());
	w[n] = 0;

	const int mod = 1000000007;
	static int dp[222][12345];
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= limit; ++j)
		{
			dp[i + 1][j] = dp[i][j];
			if (j >= w[i])
				(dp[i + 1][j] += dp[i][j - w[i]]) %= mod;
		}
	}

	int res = 0;
	int use = 0;
	for (int i = n - 1; i >= 0 && use < limit; --i)
	{
		for (int j = limit - w[i] - use + 1; j <= limit - w[i + 1] - use; ++j)
			(res += dp[i + 1][j]) %= mod;
		use += w[i];
	}


	printf("%d\n", res);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int amount,cardValue;
  char cardType; 
  int sbox[13] = {};
  int hbox[13] = {};
  int cbox[13] = {};
  int dbox[13] = {};
  
  scanf("%d", &amount);

  int i=0;
  while(i<amount*2){
    scanf("%c %d",&cardType,&cardValue);
    switch(cardType){
      case 'S':
       sbox[cardValue-1] = 1;
       break;
      case 'H':
	hbox[cardValue-1] = 1;
	break;
      case 'C':
	cbox[cardValue-1] = 1;
	break;
      case 'D':
	dbox[cardValue-1] = 1;
	break;
    }
    i++;
  }

  for(int i=0; i<13; i++){
    if(sbox[i] == 0) printf("S %d\n", i+1);
  }
  for(int i=0; i<13; i++){
    if(hbox[i] == 0) printf("H %d\n", i+1);
  }
    for(int i=0; i<13; i++){
    if(cbox[i] == 0) printf("C %d\n", i+1);
  }
  for(int i=0; i<13; i++){
    if(dbox[i] == 0) printf("D %d\n", i+1);
  }
  return 0;
}



Measured memory_bytes: 2592
#[allow(dead_code)]
fn main() {
    let kk= i::i();
    let ss= i::i();
    let mut count=0;
    for xx in 0..(kk+1) {
        count+=max(0,min(2*kk-ss+xx+1,ss-xx+1));
    }
    println!("{}", count);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i32() -> i32 {
        read()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

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

using namespace std;

int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double a = A * A;
	double b = B * B;

	cout << fixed << setprecision(10);

	double da = 30. * H + 1. * M / 2.;
	double db = 6. * M; 

	double deg = abs(da - db);

	deg = min(deg, 360. - deg);

	cout << sqrt(a + b - 2. * A * B * cos(deg / 180. * acos(-1))) << '\n';

	return 0;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

pair<long long,long long> get(long long Lx,long long Rx,int x,long long d){
	long long lx,rx;
	if(x==0){
		if((Lx>>d)&1LL)return {-1,-1};
		else lx = Lx;
		if((Rx>>d)&1LL)rx = (1LL<<d)-1LL;
		else rx=Rx;
	}
	else{
		if((Lx>>d)&1LL)lx=Lx^(1LL<<d);
		else lx=0LL;
		if((Rx>>d)&1LL)rx=Rx^(1LL<<d);
		else return {-1,-1};
	}
	return {lx,rx};
}

int Get(long long Lx,long long Rx,long long Ly,long long Ry,long long d,int f){
	if(d<0){
		if(Lx==0&&Rx==0&&Ly==0&&Ry==0)return 1;
		else return 0;
	}
	
	static map<vector<long long>,int> mp;
	vector<long long> args = {Lx,Rx,Ly,Ry,d,f};
	if(mp.count(args))return mp[args];
	
	int ret = 0;	
	for(int y=0;y<2;y++){
		for(int x=0;x<2;x++){
			if(y==0&&x==1)continue;
			if((f==0)&&x!=y)continue;
			auto [lx,rx] = get(Lx,Rx,x,d);
			auto [ly,ry] = get(Ly,Ry,y,d);
			if(lx==-1||rx==-1)continue;
			if(x==1&&y==1)ret = mod(ret +Get(lx,rx,ly,ry,d-1,1));
			else ret = mod(ret + Get(lx,rx,ly,ry,d-1,f));
					
		}
	}
	mp[args] = ret;
	return ret;
}

int main(){
	
	long long L,R;
	cin>>L>>R;
	int ans = Get(L,R,L,R,60,0);
	cout<<ans<<endl;
	
	return 0;
}


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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int ans;
    ans=0;
    rep(i,3){
        if(s[i]==t[i]){
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n,i;
    char s[100];
  
    scanf("%d",&n);
    
    int flag=0;
  
    for(i=0;i<n;i++){
        scanf("%c",&s[i]);
        if(s[i]=='Y') {
           flag=1;
           break;
        }
    }
  
    if(flag==1) printf("Four\n");
    else        printf("Three\n");
      
    return 0;
}     

Measured memory_bytes: 128
while True:
  x, y, s = map(int,input().split())
  lst=[]
  if x==0 and y==0 and s==0:
    break
  for i in range(1, s):
    for j in range(1, s):
      if (i*(100+x)//100) + (j*(100+x)//100) == s:
        lst.append((i*(100+y)//100) + (j*(100+y)//100))
  print(max(lst))
  


Measured memory_bytes: 5608
//-----------------------
// author : xyqkoala
// time : 2020-07-12
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int l,r,n;
	cin>>l>>r>>n;
	cout<<(r/n)-(l-1)/n<<endl;
}


Measured memory_bytes: 3512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24916
#include<iostream>
#include<list>

using namespace std;
int n,u,k;

class points{
    public:
    int flag=0;
    list<int> l;
    int d=0;
    int f=0;
}pt[110];
int tem;

int times=0;

void dfa(int cur){
    times+=1;
    pt[cur].d=times;
    pt[cur].flag=1;
    while(!pt[cur].l.empty()){
        int dst=pt[cur].l.front();
            if(pt[dst].flag==0){
                dfa(dst);
            }
        pt[cur].l.pop_front();
    }
    times+=1;
    pt[cur].f=times;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>tem;
            pt[u].l.push_back(tem);
        }
    }
    for(int i=1;i<=n;i++){
        if(pt[i].flag==0){
            dfa(i);
        }
    }
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<pt[i].d<<" "<<pt[i].f<<endl;
    }
    
}



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

using namespace std;

int main(){
    int h1,h2;
    cin>>h1>>h2;
    int k1,k2;
    cin>>k1>>k2;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int sa=0,sb=0;
    sa+=h1*a;
    sa+=h2*b;
    sa+=h1/10*c;
    sa+=h2/20*d;
    sb+=k1*a;
    sb+=k2*b;
    sb+=k1/10*c;
    sb+=k2/20*d;
    if(sa>sb)cout<<"hiroshi"<<endl;
    else if(sb>sa)cout<<"kenjiro"<<endl;
    else cout<<"even"<<endl;
    return 0;
}


Measured memory_bytes: 3100
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var A=0;
var B=0;
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(",").map(Number);
var a=arr[0];
var b=arr[1];
var c=arr[2];
if(a*a+b*b==c*c)A++;
if(a==b)B++;

}
console.log(A+"\n"+B);

Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> lst(n,vector<int>(m+1));
    rep(i,n) rep(j,m+1) {
        cin >> lst[i][j];
    }
    int ans = 1000000000000000000;
    for (int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        vector<int> sc(m);
        rep(i,n) {
            if ((bit >> i) & 1) {
                sum += lst[i][0];
                rep(j,m) {
                    sc[j] += lst[i][j+1];
                }
            }
        }
        bool ok = true;
        rep(i,m) {
            if (sc[i] < x) {
                ok = false;
                break;
            }
        }
        if (ok) {
          ans = min(ans, sum);
        }
    }
    if (ans == 1000000000000000000) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

const int INF = 1e9;

int main() {
  int  n, x;
  cin>>n>>x;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];

  long long cnt = 0;
  if (a[0] > x) {
    cnt += a[0] - x;
    a[0] = x;
  }
  for (int i=1; i<n; i++) {
    if (a[i-1] + a[i] > x) {
      cnt += a[i] + a[i-1] - x;
      a[i] = x - a[i-1];
    }
  }
  cout<<cnt<<endl;
}

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

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                int[] x=int_arr();
                int n=x[0],m=x[1];
                List<Integer>[] g=new ArrayList[n+1];
                for(int i=0;i<=n;i++) g[i]=new ArrayList<>();
                for(int i=0;i<m;i++){
                    int[] e=int_arr();
                    g[e[0]].add(e[1]);
                    g[e[1]].add(e[0]);
                }
                int[] r=new int[n+1];
                Queue<Integer> q=new LinkedList<>();
                boolean[] b=new boolean[n+1];b[1]=true;
                q.add(1);
                while(!q.isEmpty()){
                    int p=q.poll();
                    for(int c:g[p]){
                        if(!b[c]){
                            r[c]=p;
                            q.add(c);
                            b[c]=true;
                        }
                    }
                }
                for(int i=2;i<=n;i++){
                    if(r[i]==0){
                        out.write("No");
                        out.flush();return;
                    }
                }
                out.write("Yes\n");
                for(int i=2;i<=n;i++){
                    out.write(r[i]+"\n");
                }
                out.flush();

    }
}


Measured memory_bytes: 66092
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    string T;
    cin >> T;

    ll ans = 0;
    rep(i, 3){
        if(S[i] == T[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}
int main(){
  int n;
  cin >> n;
  ll ans=1ll;
  rep(i,n){
    ll t;
    cin >> t;
    ans=lcm(ans,t);
  }

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


Measured memory_bytes: 256
# include <cstdio>

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

bool a[NR];
int w[NR], n, m;

bool calc_top () {
	int p = 0;

	//REP (i, n) printf ("%d ", a[i]); puts (" Beg");
	
	FOR (i, 2, n) {
		if (a[i] == a[i - 1]) {
			int l = p + 1, r = i - 2;
			if (l <= r) {
				int len = r - l + 1;
				if (len % 2 == 0) {
					REP_0 (j, len) {
						if (j < len / 2) a[l + j] = a[l - 1];
						else a[l + j] = a[r + 1];
					}
				} else FOR (j, l, r) a[j] = a[r + 1];
			}
			p = i;
		}
	}
	
	if (p == 0) return a[1];

	int l = p + 1, r = n;

	if (l <= r) {
		int len = r - l + 1;
		if (len % 2 == 0) {
			REP_0 (j, len) {
				if (j < len / 2) a[l + j] = a[l - 1];
				else a[l + j] = a[r + 1];
			}
		} else FOR (j, l, r) a[j] = a[l - 1];
	}
	
	//REP (i, n) printf ("%d ", a[i]); puts (" End");

	return a[m];
}

int main () {
	scanf ("%d", &m);
	n = 2 * m - 1;
	REP (i, n) {
		scanf ("%d", &w[i]);
	}

	int l = 1, r = n;

	for (; l < r; ) {
		int mid = (l + r + 1) / 2;
		REP (i, n) a[i] = (w[i] >= mid);
		//printf ("!%d\n", mid);
		if (calc_top ()) l = mid;
		else r = mid - 1;
	}

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


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

void dfs(int curr, vector<int> adj[], vector<int> &dp, vector<bool> &vis){
    vis[curr] = true;
    for(int i = 0; i < adj[curr].size();i++){
        if(!vis[adj[curr][i]])
            dfs(adj[curr][i], adj, dp, vis);
            
        dp[curr] = max(dp[curr], 1+dp[adj[curr][i]] );
    }
    return;
}

void addEdge(vector<int> adj[], int u, int v){
    adj[u].push_back(v);
    return;
}

int solution(){
    int n,m; cin>>n>>m;
    vector<int> adj[n+1];
    for(int i = 0;i < m;i++){
        int u,v; cin>>u>>v;
        addEdge(adj, u , v);
    }
    
    vector<bool> vis(n+1, false);
    vector<int> dp(n+1, 0);
    for(int i = 1;i <= n;i++){
        if(!vis[i])
            dfs(i, adj, dp, vis);
    }
    
    int ans = INT_MIN;
    for(int i = 1;i <= n;i++)
        ans = max(ans, dp[i]);
    
    cout<<ans<<"\n";
    return 0;
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 12368
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 2e5;

LL n, t;
pair<LL, LL> a[MaxN];

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 0 ; i < n ; ++i) cin >> a[i].second >> a[i].first;
    sort(a, a + n);
    for(int i = 0 ; i < n ; ++i){
        t += a[i].second;
        if(t > a[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(1145141919)

N,M=map(int, input().split())

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def walk(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not walk(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not walk(i, 0):
		ans = "No"
		break

print(ans)


Measured memory_bytes: 129092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}
			
			int d = Integer.parseInt(tmp);
			
			int result = 0;
			for(int i = 0; i < 600; i += d){
				result += d*i*i;
			}
			
			System.out.println(result);
		}
	}

}

Measured memory_bytes: 24148
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      if(s.equals("AC")) {
        ac++;
      } else if(s.equals("WA")) {
        wa++;
      } else if(s.equals("TLE")) {
        tle++;
      } else {
        re++;
      }
    }
    System.out.println("AC x " + ac);
    System.out.println("WA x " + wa);
    System.out.println("TLE x " + tle);
    System.out.println("RE x " + re);
  }
}

Measured memory_bytes: 58528
#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM : https://atcoder.jp/contests/abc111/submissions/4032175

N = int(input())
targets = [ list(map(int, input().split())) for _ in range(N)]

mod_1st = sum(targets[0]) % 2 
if not all( sum(t) %2 == mod_1st for t in targets[1:]):
    print(-1)
    exit(0)

# if mod == 1, m = 31, di = 2^(i-1), 
# if mod == 0, m = 32, di = 2^(i-1), d32 = 1

# num of arms

mod = mod_1st
print(33 - mod)  # 33 or 32 
D = [2**i for i in range(31, -1, -1)] # 32
if mod == 0:
    D.append(1)
print(' '.join(map(str, D)))
# ----
for (x,y) in targets:
    temp = []
    u = x+y
    v = x-y
    for d in D:
        if u >= 0:
            if v >= 0:
                temp.append("R")
                u -= d
                v -= d
            elif v <  0:
                temp.append("U")
                u -= d
                v += d
        elif u < 0:
            if v >= 0:
                temp.append("D")
                u += d
                v -= d
            elif v < 0 :
                temp.append("L")
                u += d
                v += d

    # for d in D:
    #     if x >= y and x+y >= 0:
    #         temp.append("R")
    #         x -= d
    #     elif x < y and x + y >= 0:
    #         temp.append("U")
    #         y -= d
    #     elif x >= y and x + y  <0 :
    #         temp.append("D")
    #         y += d
    #     else:
    #         temp.append("L")
    #         x += d
    print(''.join(temp))
            
    



Measured memory_bytes: 43504
#include<stdio.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}
void bubble_sort (int array[], int array_size) {
  int i, j;

  for (i = 0; i < array_size - 1; i++){
    for (j = array_size - 1; j >= i + 1; j--){   //　右から左に操作
      if (array[j] < array[j-1]) { swap(&array[j], &array[j-1]); }
    }
  }
}
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int kakaku[n];
    for(int c=0;c<n;c++){
        scanf("%d ",&kakaku[c]);
    }
    bubble_sort(kakaku,n);
    int result=0;
    for(int c=0;c<k;c++){
        result=result+kakaku[c];
    }
    printf("%d\n",result);
    return 0;

}

Measured memory_bytes: 1732
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int N, T;
        N = int.Parse(words[0]);
        T = int.Parse(words[1]);
        int cost_min = 10000;
        int c_n, t_n;
        for (int i = 0; i < N; i++)
        {
            line = Console.ReadLine();
            words = line.Split(' ');
            c_n = int.Parse(words[0]);
            t_n = int.Parse(words[1]);
            if (T >= t_n)
            {
                if (cost_min > c_n)
                {
                    cost_min = c_n;
                }
            }
        }
        if (cost_min != 10000)
            Console.WriteLine(cost_min);
        else
            Console.WriteLine("TLE");
    }
}

Measured memory_bytes: 11092