akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int a, b;

    cin >> a >> b;

    if (a + b < 10) cout << a + b << endl;
    else cout << "error" << endl;

    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}



Measured memory_bytes: 20492
#include <iostream>

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

    size_t l = s.length();
    char* out = new char[l+1];
    for (int i = 0; i < l; ++i) {
        out[i] = 'x';
    }
    out[l] = 0;

    std::cout << out << std::endl;

    delete[] out;

    return 0;
}


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

vector<string> split_naive(string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
    string s;
    getline(cin, s);
    char delim = ' ';
    vector<string> vec = split_naive(s, delim);
    vector<int> stack(200);
    int top = 0;
    for (int i=0; i < vec.size(); i++) {
        string val = vec[i];
        if (val == "+") {
            int num1 = stack[--top];
            int num2 = stack[--top];
            stack[top++] = num1 + num2;
        } else if (val == "-") {
            int num1 = stack[--top];
            int num2 = stack[--top];
            stack[top++] = num2 - num1;
        } else if (val == "*") {
            int num1 = stack[--top];
            int num2 = stack[--top];
            stack[top++] = num2 * num1;
        } else {
            int num = stoi(val);
            stack[top++] = num;
        }
    }
    cout << stack[--top] << endl;

    return 0;
}


Measured memory_bytes: 3160
/*author - Ashutosh Chitranshi*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string str;
    cin >> str;
    cout << str.substr(0,3) << nl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
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; }

int main()
{
	string s, t;
	ll pos = 0;
	ll pre = -1;
	ll ite = 0;
	bool flag = true;
	vector<vector<int>> alpha(26);

	cin >> s >> t;

	rep(i, s.size())
		alpha[s[i] - 'a'].push_back(i + 1);

	rep(i, t.size())
	{
		if (alpha[t[i] - 'a'].empty())
		{
			flag = false;
			break;
		}
		auto it = upper_bound(alpha[t[i] - 'a'].begin(), alpha[t[i] - 'a'].end(), pre);
		if(it != alpha[t[i] - 'a'].end())
		{
			pos = ite * s.size() + *it;
			pre = *it;
		}
		else 
		{
			ite++;
			pos = ite * s.size() + alpha[t[i] - 'a'][0];
			pre = alpha[t[i] - 'a'][0];
		}
	}

	if (!flag)
		cout << "-1" << endl;
	else if (pos > s.size() * pow(10, 100))
		cout << "-1" << endl;
	else
		cout << pos << endl;

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || a + c == b || b + c == a)
        OP("Yes");
    else
        OP("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();

        System.out.println(solve(a, b, h));

        sc.close();
    }

    static int solve(int a, int b, int h) {
        return (a + b) * h / 2;
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
long p[111111],a[111111],b[111111];
int compare(const void *c, const void *d) {
    return a[*(long*)c] - a[*(long*)d];
}
int main() {
    long a, b,i, ans;
    scanf("%ld%ld", &a, &b);
    if (a%2==0) {
        if ((b - a) % 4 == 0)
            ans = b;
        if ((b - a) % 4 == 1)
            ans = 1;
        if ((b - a) % 4 == 2)
            ans = b + 1;
        if ((b - a) % 4 == 3)
            ans = 0;
    }
    else {
        if ((b - a) % 4 == 0)
            ans = a;
        if ((b - a) % 4 == 1)
          ans=a^b;
        if ((b - a) % 4 == 2)
            ans = a-1;
        if ((b - a) % 4 == 3)
          ans=(a^b)-1;
    }
        printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int findSumOfDigits(int n){
    int sum = 0;
    while(n > 0) {
       sum += n%10;
       n /= 10;
    }
    return sum;
}
int main() {
    int N,A,B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 1; i <= N; ++i) {
        int sum = 0;
        sum = findSumOfDigits(i);
        if(sum>=A && sum <=B){
            total += i;
        }
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut scan = Scanner::new(cin);

    let mut e = scan.readn::<i32>(3);
    e.sort();
    println!("{}", if e[0]==e[1] && e[1]==e[2] {"Yes"} else {"No"});
}

// region template
#[allow(dead_code)]
fn uz(i: i32) -> usize { i as usize }

#[allow(dead_code)]
fn chmax<T: PartialOrd>(a: &mut T, b: T) -> bool {
    if *a < b {
        *a = b;
        true
    } else { false }
}

#[allow(dead_code)]
fn chmin<T: PartialOrd>(a: &mut T, b: T) -> bool {
    if *a > b {
        *a = b;
        true
    } else { false }
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: i32) -> Vec<T> {
        let mut ret = vec![];
        for _ in 0..n { ret.push(self.read::<T>()) }
        ret
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int count = 0;
	sort(arr, arr + n);
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (arr[i] != arr[j] && arr[j] != arr[k]) {
					if (arr[i] + arr[j] > arr[k])
						count++;
				}
			}
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  char c;
  cin>>c;
  if(c>='a')cout<<'a'<<"\n";
  else cout<<'A'<<"\n";
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
int n,a[MAXN],b[MAXN];
int L[MAXN],R[MAXN];
vector<pii> vec;
LL pres[MAXN];
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		vec.emplace_back(mp(a[i],i));
		vec.emplace_back(mp(b[i],i));
	}sort(vec.begin(),vec.end());
	LL ans=1e18,sum=0;
	for(int i=1;i<=n;i++)sum+=a[i];chkmin(ans,sum);sum=0;
	for(int i=1;i<=n;i++)sum+=b[i];chkmin(ans,sum);sum=0;
	int t=0;
	for(auto p:vec)
	{
		if(L[p.second])R[p.second]=++t;
		else L[p.second]=++t;
		pres[t]=pres[t-1]+p.first;
	}
	for(int i=1;i<=n;i++)
	{
		if(L[i]>n-2)chkmin(ans,a[i]+b[i]+pres[n-2]);
		else if(R[i]>n-1)chkmin(ans,pres[n-1]+pres[R[i]]-pres[R[i]-1]);
		else chkmin(ans,pres[n]);
	}pr2(ans);
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


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

int main()
{	
	int n; std::cin >> n;
	int k; std::cin >> k;
	int* T = new int[k];
	for (int i=0; i<k; i++) std::cin >> T[i];
	std::sort(T, T+k);

	for (long long int i=0; i<(1<<k); i++) {
		long long index = 0;
		std::vector<int> output;
		long long d = i;
		for (int j=0; j<k; j++) {
			if ( (d&1) == 1 ) {
				index += 1<<T[j];
				output.push_back(T[j]);
			}
			d >>= 1;
		}
		std::cout << index << ":";
		for (std::vector<int>::iterator it = output.begin(); it != output.end(); ++it) std::cout << " " << *it;
		std::cout << std::endl;
	}
	
	delete[] T;
	
	return 0;
}



Measured memory_bytes: 3160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int ans = 0;
        int l = 0, r = s.length-1;
        while(0 < r - l){
            int fx = 0, bx = 0;
            while(l < r && s[l] == 'x'){
                fx++; l++;
            }
            while(l < r && s[r] == 'x'){
                bx++; r--;
            }
            if(s[l] != s[r]){
                ans = -1; break;
            }
            if(s[l] == 'x')break;
            ans += Math.abs(fx - bx);
            l++; r--;
            if(s.length-1 < l || r < 0)break;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 28324
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

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

    if (N==100) {
        ll ans = 101*pow(100,D);
        cout << ans << endl;
   }
    else {
        ll ans = N*pow(100,D);
        cout << ans << endl;
    }

}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

constexpr ll INF = 1e18;
 
struct edge{
    int from, to, cost;
};
 
using edges = vector<edge>;

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

  ll n, m;
  cin >> n >> m;
  edges es(m);
  REP(i, m){
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].from--;
    es[i].to--;
    es[i].cost *= -1;
  }

  ll res = INF;

  vector<ll> d(n, INF); //頂点0からの距離
  d[0] = 0;

  
  REP(i, 2 * n){
    for(auto& e : es){
      if(d[e.to] > d[e.from] + e.cost){
        //負閉路検出
        if(e.to == n - 1 && i >= n){
          cout << "inf" << endl;
          return 0;
        }
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }

  cout << -d[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			String strArr[] = br.readLine().split(" ");

			int n = Integer.parseInt(strArr[0]);
			int a = Integer.parseInt(strArr[1]);
			int b = Integer.parseInt(strArr[2]);
			int answer = 0;

			for (int i = 1; i < n + 1; i++) {
				int num = i;
				int sum = 0;

				while (num != 0) {
					sum += num % 10;
					num /= 10;
				}

				if (sum >= a && sum <= b ) {
					answer = answer + i;
				}
			}
			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}


Measured memory_bytes: 32828
S = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, c in enumerate(S):
    if c == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif c == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif c == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)



Measured memory_bytes: 8280
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m;
    if(max(n,m)==n)
        c = n+ max(n-1,m);
      else 
        c =  m + max(m-1,n);
  cout<<c;
}

signed main(){
     
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

const int mod = 100000;
//dp[ pos&1 ][ is nice ][ is prv 'J' ][ bit ] 
int dp[2][2][2][1<<20];

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> g(h);
  rep(i,h)cin >> g[i];
  dp[0][0][0][0] = 1;

  rep(y,h)rep(x,w){
    int cur = (y*w+x)&1, nxt = 1-cur;
    rep(ok,2)rep(J,2)rep(bit,1<<(w-1))dp[nxt][ok][J][bit] = 0;

    rep(ok,2)rep(J,2){
      rep(bit,1<<(w-1)){
	if(dp[cur][ok][J][bit]==0)continue;
	
	int nxtbit = bit & (~(1<<x));
	if(g[y][x] == 'J' || g[y][x] == '?'){
	  if(x!=w-1){
	    (dp[nxt][ok][1][nxtbit] += dp[cur][ok][J][bit]) %= mod;
	  }else{
	    (dp[nxt][ok][0][nxtbit] += dp[cur][ok][J][bit]) %= mod;
	  }
	}
	
	if(g[y][x] == 'O' || g[y][x] == '?'){
	  if(x!=0 && J){
	    (dp[nxt][ok][0][nxtbit | 1<<(x-1)] += dp[cur][ok][J][bit]) %= mod;
	  }else{
	    (dp[nxt][ok][0][nxtbit] += dp[cur][ok][J][bit]) %= mod;
	  }
	}
	
	if(g[y][x] == 'I' || g[y][x] == '?'){
	  if( (bit>>x)&1 ){
	    (dp[nxt][1][0][nxtbit] += dp[cur][ok][J][bit]) %= mod;
	  }else{
	    (dp[nxt][ok][0][nxtbit] += dp[cur][ok][J][bit]) %= mod;
	  }
	}
      }
    }
  }

  int ans = 0;
  rep(J,2)rep(bit,1<<(w-1)){
    (ans += dp[(h*w)&1][1][J][bit]) %= mod;
  }
  cout << ans << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin >> n;

    while(10 < n && n%10 == 0) n /= 10;
    
    ll minn = 0;
    if(n == 10) minn = 10;
    else{
        ll x = n;
        while(0 < x){
            minn += x%10;
            x /= 10;
        }
    }

    cout << minn << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;
  int d = a - b;

  cout << max(0, c - d) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

int main() {
  int N, C;
  while (cin >> N >> C) {
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
      cin >> B[i];
    }
    vector<vector<ll>> tbl(N, vector<ll>(C + 1));
    for (int i = 0; i < N; i++) {
      for (int a = 0; a <= C; a++) {
        ll sum = 0;
        for (int x = A[i]; x <= B[i]; x++) {
          (sum += mod_pow(x, a)) %= MOD;
        }
        tbl[i][a] = sum;
      }
    }
    vector<vector<ll>> dp(N, vector<ll>(C + 1, -1));
    function<ll(int, int)> solve = [&](int k, int C) {
      ll &res = dp[k][C];
      if (res != -1) {
        return res;
      }
      if (k == N - 1) {
        return res = tbl[k][C];
      }
      res = 0;
      for (int a = 0; a <= C; a++) {
        (res += tbl[k][a] * solve(k + 1, C - a) % MOD) %= MOD;
      }
      return res;
    };
    cout << solve(0, C) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL solve(){
	string s;
	cin >> s;
	cout << s.substr(0,3) << endl;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 15408
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
num = 0
p = 0
for i in range(N):
    a = A[i]
    if a <= p:
        num += a
        p = B[i]
        continue
    a -= p
    num += p
    if a <= B[i]:
        num += a
        p = B[i] - a
        continue
    num += B[i]
    p = 0
else:
    num += min(p, A[-1])
print(num)


Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){

long long s;
cin>>s;
long long x1=0,y1=0;
    
long long x2,y2,x3,y3;

long long t=1000000000;
x2=t;
y2=1;

x3=(t-s%t)%t;
y3=(s+x3)/t;



cout<<x1<<" "<<y1<<" "
<<x2<<" "<<y2
<<" "<<x3<<" "<<y3<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

typedef pair<ll,ll> PLL;

const int MAXN=100050;
const int MAXQ=100050;
vector<ll> q;

ll ans[MAXN];

int main() {
	int N, Q; scanf("%d%d",&N,&Q);
	q.PB(N);
	for(int i=0;i<Q;i++) {
		debug("i=%d\n",i);
		ll in;
		scanf("%lld",&in);
		while(SZ(q)>0 && q.back()>=in) q.pop_back();
		q.PB(in);
	}
	priority_queue<PLL> pq;
	pq.push(MP(q.back(), 1));
	for(int i=SZ(q)-1;i>=0;i--) {
		debug("q[%d]=%lld\n",i,q[i]);
		ll cnt=0;
		while(SZ(pq)>0 && pq.top().F>q[i]) {
			auto p=pq.top(); pq.pop();
			debug("SZ:%d [%lld, %lld]\n",SZ(pq),p.F,p.S);
			cnt+=(p.F/q[i])*p.S;
			if(ll t=p.F%q[i]) {
				debug("push: %lld,%lld\n",t,p.S);
				pq.push( MP(t, 1*p.S) );
			}
		}
		if(cnt) pq.push( MP(q[i], cnt) );
	}
	while(!pq.empty()) {
		auto p=pq.top(); pq.pop();
		debug("-- [%lld, %lld]\n",p.F,p.S);
		ans[1]+=p.S;
		ans[p.F+1]-=p.S;
	}
	for(int i=1;i<=N;i++) ans[i]+=ans[i-1];
	for(int i=1;i<=N;i++) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4976
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

sum = 0
pre = -1

for A in A_list:
    sum += B_list[A - 1]

    if pre + 1 == A:
        sum += C_list[A - 2]

    pre = A

print(sum)

Measured memory_bytes: 3064
N = int(input())
C = list(input())

def solve(N, C):
    R = 'R'
    W = 'W'
    if C.count('W') == 0:
        return 0
    if C.count('R') == 0:
        return 0

    w = 0
    r = len(C)-1
    count  = 0

    while w < r:
        while w < r and C[w] != W:
            w+=1
        while w < r and C[r] != R:
            r-=1
        if r <= w:
            return count
        else:
            #print(C, w, r)
            C[w], C[r] = 'R', 'W'
            count+= 1
    return min(count, C.count("R"))

print(solve(N, C))


Measured memory_bytes: 10800
#!/usr/bin/env python

def main():
    N, Z, W = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))

    if N == 1:
        print(abs(a[N - 1] - W))
    else:
        print(max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])))

if __name__ == '__main__':
    main()


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

using namespace std;

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

    vector<int> sums(N+1, 0);
    rep (i, N) {
        sums[i+1] = sums[i] + d[i];
    }

    int ans = 0;
    rep (i, N) {
        ans += d[i]*(sums[N] - sums[i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int k,s;
    cin >> k >> s;
    int ans = 0;
    rep(x,k+1){
        rep(y,k+1){
            int z = s - y - x;
            if(z <= k && z >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3508
//01, 07, 2018, 08:33:55 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

const ll INF = 1000000;
const int N = 200010;
ll a[N];
ll pref[N];
ll suf[N];

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

    cin >> n;

    ll mn = INF;
    ll sum = 0LL;
    
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];

        a[i] -= i;
        
        mn = min(mn, a[i]);

        sum += abs(a[i]);
    }
    
    sort(a + 1, a + 1 + n, greater<ll>());

    ll tmp = 0LL;
    for(int i = n ; i >= 1 ; i--){
        suf[i] = a[i] + suf[i + 1];
    }
    
    ll best = sum;
    
    for(int i = 1 ; i <= n ; i++){
        if(a[i] > 0LL){
            ll rg = n - i;
            ll lf = i;

            best = min(best, abs(suf[i + 1] - a[i] * rg) + abs((tmp + a[i]) - a[i] * lf));
        }else{
            ll rg = n - i + 1;
            ll lf = i - 1;

            best = min(best, abs(suf[i] - a[i] * rg) + abs(tmp - a[i] * lf));
        }

        tmp += a[i];
    }

    cout << best << endl;
    
    return 0;
}

Measured memory_bytes: 4480
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n = 0;
    ll k;
    fi>>k;
    const string STR = "$FESTIVAL";
    static ll dp[1 << 20][99];
    dp[0][0] = 1;
    for (int i = 1;i <= 5000;++i)
    {
        for (int j = 0;j <= 7;++j)
            dp[i][j] = dp[i - 1][j];
        const int cur = (i - 1) % 7 + 1;
        dp[i][cur] += dp[i][cur - 1];
    }
    string ans = "";
    for (int i = 4600;i;--i)
    {
        if (k >= dp[i][7])
            ans = "L" + ans,k -= dp[i][7];
        ans = STR[(i - 1) % 7 + 1] + ans;
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




Measured memory_bytes: 4224
//============================================================================
// Name        : ITP_1_2_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

int main() {
	vector<int> v(3);
	int temp;
	cin >> v[0] >> v[1] >> v[2];
	for(int i=0;i<2;++i) {
		for(int j=0;j<2-i;++j) {
			if ( v[j]>v[j+1] ) {
				temp = v[j];
				v[j]=v[j+1];
				v[j+1]=temp;
			}
		}
	}
	cout << v[0] << " " << v[1] << " " << v[2] << endl;
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct disjoint_set{
    vector<int> p;
    disjoint_set(int n){
        p.resize(n);
        for(int i = 0; i < n; i += 1) p[i] = i;
    }
    int fp(int u){
        return u == p[u] ? u : p[u] = fp(p[u]); 
    }
    void unite(int u, int v){
        p[fp(u)] = fp(v);
    }
    bool same(int u, int v){
        return fp(u) == fp(v);
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, q;
    cin >> n >> q;
    disjoint_set ds(n);
    for(int i = 0; i < q; i += 1){
        int com, u, v;
        cin >> com >> u >> v;
        if(com) cout << ds.same(u, v) << "\n";
        else ds.unite(u, v);
    }
    return 0;
}


Measured memory_bytes: 3276
n = int(input());

v = [int(i) for i in input().split()];

f = True;

for x in v:
    if x % 2 == 0:
        f = f and (x % 3 == 0 or x % 5 == 0);

if f == True:
    print('APPROVED');
else:
    print('DENIED');


Measured memory_bytes: 2940
//DFSテンプレート
fun main(args: Array<String>) {
    var (A, B, K) = listOfLong()
    val a = A - Math.min(A, K)
    val b = B - Math.min(B, K - (Math.min(K, A - a)))
    println("${a} ${b}")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }

Measured memory_bytes: 37908
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] b = new int[n];
		int[] f = new int [n];
		int[] r = new int [n];
		int[] v = new int [n];
		for(int a = 0;a<n;a++){
			b[a] = scan.nextInt();
			f[a] = scan.nextInt();
			r[a] = scan.nextInt();
			v[a] = scan.nextInt();
		}
		int V[] = new int[120];
		int ka = 0;
		for(int g = 0;g<n;g++){
			for(int h = 1;h<=4;h++){
				for(int i = 1;i<=3;i++){
					for(int j = 1;j<=10;j++){
						if(b[g] == h && f[g] == i && r[g] == j){
							V[ka*10+j-1] = V[ka*10+j-1] + v[g];
						}
					}
					ka++;
				}
			}
			ka = 0;
		}
		int kb =0;
		for(int e =1;e<=4;e++){
			for(int c =1;c<=3;c++){
				for(int d = 1;d<=10;d++){
					System.out.print(" "+V[kb*10+d-1]);
				}
				System.out.println("");
				kb++;
			}
			if(e != 4){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 21128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
  int s = h1 * 60 + m1, t = h2 * 60 + m2;
  cout << t - s - k << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005,mod=1000000000;
int n,b[N],c[N],s[100][100],xb[N],xc[N],a[N],ans;
signed main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string r;
		cin>>r;
		int k=0,zh=0;
		int fl=0;
		for(auto c:r)
		{
			if(c=='.')
			{
				fl=1;
				continue;
			}
			k=k*10+c-'0';
			zh+=fl;
		}
		while(zh<9)
		{
			zh++;
			k*=10;
		}
		int y;
		y=k;
		while(y%2==0)
		{
			xb[i]++;
			y/=2;
		}
		y=k;
		while(y%5==0)
		{
			xc[i]++;
			y/=5;
		}
		s[xb[i]][xc[i]]++;
		if(k%mod==0)
			ans--;
	}
	for(int i=1;i<=n;i++)
		for(int j=max(18-xb[i],0LL);j<=70;j++)
			for(int k=max(18-xc[i],0LL);k<=70;k++)
				ans+=s[j][k];
	cout<<ans/2<<endl;
	return 0;
}


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

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

int main(){
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for(int i=0;i<N;i++)  cin >> x.at(i) >> u.at(i);

  double ans=0;
  for(int i=0;i<N;i++){
    if(u.at(i)=="JPY")  ans+=x.at(i);
    else if(u.at(i)=="BTC") ans+=380000.0*x.at(i);
  }
  printf("%.8f\n",ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	
	int receive = 1000 - (n % 1000);
	if(n % 1000 == 0){
		printf("0\n");
	}
	else {
		printf("%d\n", receive);
	}
	return 0;
}

Measured memory_bytes: 3232
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/


int main(){
  string S, T;
  cin >> S >> T;
  ll cnt = 0;
  rep(i, 3) if(S[i] == T[i]) cnt++;
  cout << cnt << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
using namespace std;
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (max({ a,b,c }) == a + b + c - max({ a,b,c }))cout << "Yes" << endl;
	else cout << "No" << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> ans = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << ans.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

typedef array<LL,3> A;
const int L=1e5+1;
A D[L];
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		LL a,b;
		cin >> a >> b;
		D[i]={a+b,a,b};
	}
	sort(D,D+N);
	int p=0;
	LL ret=0;
	for(int i=N-1;i>=0;i--){
		if(p==0){
			ret+=D[i][1];
		}
		else{
			ret-=D[i][2];
		}
		p^=1;
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            var x1 = a.Count(x => x % 2 != 0);
            var x4 = a.Count(x => x % 4 == 0);
            var x2 = a.Count(x => x % 2 == 0) - x4;

            if (x2 > 0)
            {
                return x4 >= x1 ? "Yes" : "No";
            }
            else
            {
                return x4 + 1 >= x1 ? "Yes" : "No";
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    string str; cin >> str;
    int n; cin >> n;
    set<string> st;
    if(str.size() == 1){
        cout << str << endl;
        return 0;
    }
    for(int i = 0; i < str.size(); i++){
        for(int j = 1; j <= n; j++){
            string sub = str.substr(i, j);
            if(st.find(sub) == st.end()){
                st.insert(sub);
            }
        }
    }
    auto itr = st.begin();
    for(int i = 0; i < n-1; i++){
        ++itr;
    }

    cout << *itr << endl;

    return 0;
}



Measured memory_bytes: 1664
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 2020-08-22 19:01
**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << argc;
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int ts;
int x,n,t;

void solve() {
	cin >> x >>n >> t;
	int ans = x/n*t + (x%n?t:0);
	cout << ans;
}

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

	//cin >> ts;
	//while(ts--)
		solve();
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;


int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=0;
	if(n%(a+b)==0) ans=(ll)a*(n/(a+b));
	ll tmp=n-(a+b)*(n/(a+b));
	ans=a*(n/(a+b))+min(a,tmp);
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int main(){
    int n,q; cin >> n >> q;
    priority_queue<int> pq[n];
    for(int i = 0; i < q; i++){
        int m; cin >> m;
        if (m == 0){
            int t,x; cin >> t >> x;
            pq[t].push(x);
        } else if (m == 1){
            int t; cin >> t;
            if (pq[t].size()){
                cout << pq[t].top() << endl;
            }
        } else {
            int t; cin >> t;
            if (pq[t].size()){
                pq[t].pop();
            }
        }
    }
}
  




Measured memory_bytes: 4156
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(){
	ll l, r; cin >> l >> r;
	ll m = 2019;
	vector<ll> a;
	a.push_back(l%m);
	int cnt = 0;
	for(int i=l+1; i<=r; i++){
		if(cnt==2*m) break;
		ll add = i%m;
		cnt++;
		a.push_back(add);
	}
	ll ans = INF;
	reps(i,a.size()-1){
		rep(j,i){
			ans = min(ans, (a[i]*a[j])%m);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!/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():
    N, K = map(int, input().split())
    H = list(sorted(list(map(int, input().split())), reverse=True))

    ans = 0
    for i in range(N):
        if i < K:
            continue
        else:
            ans += H[i]
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 32876