akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;   
}

int dist(int x, int y, int z, int w){
    return (abs(x-z) + abs(y-w));
}

bool solve(){
    int last_t = 0;
    int last_x = 0;
    int last_y = 0;
    for (int i = 0; i < N; i++)
    {
        int t,x,y; cin >> t >> x >> y;
        int diff_t = t-last_t;
        if(dist(x,y,last_x,last_y)>diff_t) return false;
        if(dist(x,y,last_x,last_y)%2!=diff_t%2) return false;
        last_t = t;
        last_x = x;
        last_y = y;
    }
    return true;
}   

int main()
{
    input();
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
p,q= input().split()
a,b =(int(p), int(q))
key_num = 0
azi_list = []
for i in range(a):
    azi_list.append(b + i)
if key_num in azi_list:
    print(sum(azi_list))
elif key_num not in azi_list and azi_list[0] > 0:
    print(sum(azi_list[1:]))
else:
    print(sum(azi_list[:-1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b / a;
  ans = min(ans, c);
  print(ans);
  return 0;
}

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

using namespace std;

int main()

{
    long long int x,k,d,m,n,y,p,ans;

    cin>>x>>k>>d;
    if(x<0){
        x=-x;
    }

   if(x%d==0){
    m=x/d;

   }
   else{
    m=(x/d)+1;
   }
      y=2*x;
    if(y%d==0){
    n=y/d;

   }
   else{
    n=(y/d)+1;
   }

   if(m>=k){
    ans=x-(k*d);
   }




   else if(y<=d){
    if(k%2){
            if(y!=0){
        ans=x+(d%y);
    }
    else{
        ans=x+d;;
    }
    }
    else{
        ans=x;
    }
   }

   else{
    p=x/d;
    p=k-p;
    if(p%2){
        ans=d-(x%d);
    }
    else{
        ans=x%d;
    }
   }
   if(ans<0){
    ans=-ans;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;


int main()
{
	int N;
	cin >> N;
	rep(ii,N)
	{
	string s,t;
	cin >> s >> t;
	int n=s.size(),m=t.size();
	vector<vector<int>> dp(n+1,vector<int>(m+1,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i]==t[j])
			{
				dp[i+1][j+1] = dp[i][j]+1;

			}
			else
			{
				dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
			}
		}
	}
	cout<<dp[n][m]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6860
#include <stdio.h>
#include <math.h>

int main(void)
{
    int i,n;
        double x,mean,poi[1010]={0};
    
    while(scanf("%d",&n)==1){
        x=0;
        if(n!=0){
        for(i=0;i<n;i++){
            scanf("%lf",&poi[i]);
            x+=poi[i];
        }
        mean=x/n;
        x=0;
        
        for(i=0;i<n;i++){
            x+=pow(poi[i]-mean,2);
        }
        
        mean=sqrt(x/n);
        printf("%f\n",mean);
        }else break;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  int a; cin >> a;
  cout << a+a*a+a*a*a << endl;

  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3648
#include<stdio.h>
//#include<algorithm>
//#include<functional>
#include<deque>		//1
using namespace std;
int main(void)
{
	deque<int> dq;		//1
	int q,x,d,p,i,n;
	scanf("%d",&q);
	for(i=0;i<q;i++)	{
		scanf("%d",&n);
		if(n==0)	{
			scanf("%d %d",&d,&x);
			if(d==0)	dq.push_front(x);
			else dq.push_back(x);
		}
		else if(n==1)	{
			scanf("%d",&p);
			printf("%d\n",dq[p]);
		}
		else {
			scanf("%d",&d);
			if(d==0)	dq.pop_front();
			else dq.pop_back();
		}
	}
	return 0;
}



Measured memory_bytes: 4100
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
} 
int  days(int month, int year)
{
	if( month == 2)
	{
		if((year%400==0) || (year%4==0 && year%100!=0))	
			return 29;
		else	
			return 28;
	}
	else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8
	||month == 10 || month==12)	
		return 31;
	else 		
		return 30;
} 
int dayofweek(int d, int m, int y)  
{  
    static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };  
    y -= m < 3;  
    return ( y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7;  
}  
int main()
{
	FAST
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 1024
n,m = map(int,input().split())
h = list(map(int,input().split()))
r = []
g = [1]*n
for i in range(m):
    ps = [int(i)-1 for i in input().split()]
    x,y = ps[0],ps[1]
    if h[x] >= h[y]:
        g[y] = 0
    if h[y] >= h[x]:
        g[x] = 0
print(sum(g))

Measured memory_bytes: 20112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const ll INF=(1ll<<31)-1;
int a[100001];
int b[1005];
int main(){
    int n,q;
    cin>>n>>q;
    int qn=sqrt(n);
    int br=(n+qn-1)/qn;
    rep(i,n) a[i]=INF;
    rep(i,br) b[i]=INF;
    int com;
    rep(i,q){
        cin>>com;
        if(com==0){
            int k,x;
            cin>>k>>x;
            a[k]=x;
            int mn=INF;
            FOR(j,k/qn*qn,(k/qn+1)*qn) mn=min(mn,a[j]); 
            b[k/qn]=mn;
        }
        if(com==1){
            int s,t;
            cin>>s>>t;
            ++t;
            int ans=INF;
            rep(j,br+1){
                int l=j*qn,r=(j+1)*qn;
                if(r<=s||t<=l) continue;
                if(s<=l&&r<=t) ans=min(ans,b[j]);
                else{
                    FOR(k,max(s,l),min(t,r)){
                        ans=min(ans,a[k]);
                    }
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

vector<vector<int> > DP(2000,vector<int>(2001));

void init(){
    rep(i,2000){
        rep(j,2001)DP[i][j]=-1;
    }
}

int combi_makable(vector<int> A,int m,int i){
    if(m<0)return false;
    if(DP[i][m]!=-1)return DP[i][m];
    if(i==0){
        if(A[0]==m||m==0)DP[i][m]=1;
        else DP[i][m]=0;
        return DP[i][m];
    }
    if(combi_makable(A,m,i-1)||combi_makable(A,m-A[i],i-1))DP[i][m]=1;
    else DP[i][m]=0;
    return DP[i][m];
}

int main(){
    init();
    int n,q,m;
    cin>>n;
    vector<int> A(n);
    rep(i,n)scanf("%d",&A[i]);
    cin>>q;
    rep(i,q){
        scanf("%d",&m);
        if(combi_makable(A,m,n-1))printf("yes\n");
        else printf("no\n");
    }
}


Measured memory_bytes: 18720
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let p: i32 = input();
    let q: i32 = input();
    let r: i32 = input();
    println!("{}", std::cmp::min(p + q, std::cmp::min(q + r, r + p)));
}


Measured memory_bytes: 4352
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
d = [tuple(MI()) for _ in range(N)]
d.sort(reverse=True, key=lambda x: x[0] + x[1])

T = 0
A = 0
for i, (a, b) in enumerate(d):
    if i % 2 == 0:
        T += a
    else:
        A += b
print(T - A)

Measured memory_bytes: 58588
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;long long k;cin>>s>>k;k--;
	bool have=0;
	long long havep=-1;
	for(int i=0;i<s.length();i++){
		if(s[i]!='1'){
			have=1;havep=(long long)i;break;
		}
	}
	if(have==0){
		cout<<1<<endl;return 0;
	}else{
		if(k<havep){
			cout<<1<<endl;
		}else{
			cout<<s[havep]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
using namespace std;
const int mod = 1e9+7;

int n, m, sumr[2020][2020], sumc[2020][2020];
int main(){
	// map <pair<int, int>, int> sumr, sumc;
	string s[2020];
	cin >> n >> m;

	for (int i=0; i<n; i++){
		cin >> s[i];
	}
	int col = 0 ,row =0, maximo = 0;;

	for (int i=0; i<n; i++){
		for (int j=0; j<m; j++){
			if (s[i][j] == '.') row++;
			if (s[i][j] == '#') row = 0;
			sumr[i][j] = row;
		}
		row = 0;
	}
	for (int i=0; i<m; i++){
		for (int j=0; j<n; j++){
			if (s[j][i] == '.') col++;
			if (s[j][i] == '#') col = 0;
			sumc[j][i] = col;
		}
		col = 0;
	}
	row = col = 0;
	for (int i=n-1; i >= 0; i--){
		for (int j=m-1; j>=0; j--){
			if (s[i][j] == '.') row = max(row, sumr[i][j]);
			if (s[i][j] == '#') row = 0;
			sumr[i][j] = row;
		}
		row = 0;
	}
	for (int i=m-1; i >= 0; i--){
		for (int j=n-1; j >= 0; j--){
			if (s[j][i] == '.') col = max(col, sumc[j][i]);
			if (s[j][i] == '#') col = 0;
			sumc[j][i] = col;
			maximo  = max(maximo, sumc[j][i] + sumr[j][i]);
		}
		col = 0;
	}


	cout << maximo -1<< endl;

    return 0;
}

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

int main()
{
    int N,i,j,d,M;
    cin >> N;
    int a[N],b[N];
    for(i=0;i<N;i++)
    {
        cin >> a[i];
        b[i]=0;
    }
    for(i=N;i>0;i--)
    {
        d=0;
        for(j=i;j<=N;j+=i)
        {
            d^=b[j-1];
        }
        if(a[i-1]!=d)b[i-1]=1;
    }
    M=0;
    for(i=0;i<N;i++)M+=b[i];
    cout << M << endl;
    for(i=0;i<N;i++)
    {
        if(b[i]==1)cout << i+1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int A, B, C;
  cin>>A>>B>>C;
  Int K;
  cin>>K;

  Int ans = 0;
  for(Int i=0;i<=K;i++)
    for(Int j=0;j<=K;j++)
      for(Int k=0;k<=K;k++){
        if(i + k + j > K) continue;
        Int a = A;
        for(Int t=0;t<i;t++) a *= 2;
        Int b = B;
        for(Int t=0;t<j;t++) b *= 2;
        Int c = C;
        for(Int t=0;t<k;t++) c *= 2;
        if(b > a && c > b) ans = 1;
      }

  cout<<(ans? "Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define PI acos(-1.0)
#define LL long long
#define MAX 0x3fffffff
using namespace std;

int n;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	cout << (n / 2.0 == (int)n / 2 ? n / 2 : n / 2 + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = []
n.times { arr << gets.chomp.split(' ').map(&:to_i) }
count = 0
(n - 1).downto(0) do |i|
  a, b = arr[i]
  mod = (a + count) % b
  if mod != 0
    count += b - mod
  end
end
puts count

Measured memory_bytes: 9468
a,b,c,x,y=map(int,input().split())
price=0
z=min(x,y)
w=max(x,y)
if a+b>c*2:
    d=w*2*c
    e=z*c*2+(x-z)*a+(y-z)*b
    print(min(e,d))

else:
    print(a*x+b*y)


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

#define MAX 10001

int cnt = 0;

void countingSort(int *A, int *B, int k, int n)
{
    int C[k];

    for (int i = 0; i < k; i++)
    {
        C[i] = 0;
    }

    /* C[i]にiの出現数を記録する */
    for (int j = 0; j < n; j++)
    {
        C[A[j]] += 1;
    }
    /* C[i]にi以下の数の出現数を記録する */
    for (int i = 1; i < k; i++)
    {
        C[i] += C[i - 1];
    }

    for (int j = n - 1; j >= 0; j--)
    {
        C[A[j]] -= 1;
        B[C[A[j]]] = A[j];
    }
}


int main(void)
{
    int n;
    int A[2000000];
    int B[2000000];
    int k = MAX;

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

    countingSort(A, B, k, n);

    printf("%d", B[0]);
    for (int i = 1; i < n; i++)
    {
        printf("% d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 17404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n],s[m][n+1],t=1<<m,inf=1<<25;
  for(int i=0;i<m;i++) s[i][0]=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    for(int j=0;j<m;j++){
      s[j][i+1]=s[j][i]+(a[i]-1==j);
    }
  }
  int dp[1<<20];
  for(int i=0;i<t;i++) dp[i]=inf;
  dp[0]=0;
  for(int i=0;i<t;i++){
    for(int j=0;j<m;j++){
      if((i>>j)&1) continue;
      int p=0;
      for(int k=0;k<m;k++) if((i>>k)&1) p+=s[k][n];
      dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+s[j][n]-(s[j][p+s[j][n]]-s[j][p]));
    }
  }
  cout<<dp[t-1]<<endl;
  return 0;
}

Measured memory_bytes: 15384
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
 
hiroshi = h1 * a + (h1//10) * c + h2 * b + (h2//20) * d
kenjiro = k1 * a + (k1//10) * c + k2 * b + (k2//20) * d
 
if hiroshi > kenjiro:
  print("hiroshi")
elif hiroshi < kenjiro:
  print("kenjiro")
else:
  print("even")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>

using namespace std;

const long long int p = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> broken(M);
    for(int i = 0; i < M; i++)
        cin >> broken[i];

    vector<long long int> dp(N+1);
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 0; i < M; i++) {
        dp[broken[i]] = -1;
    }

    for(int i = 2; i < N+1; i++) {
        if(dp[i] != -1) {
            if(dp[i-1] != -1) {
                if(dp[i-2] != -1)
                    dp[i] = (dp[i-1] + dp[i-2]) % p;
                else
                    dp[i] = dp[i-1];
            }
            else if(dp[i-2] != -1)
                dp[i] = dp[i-2];
        }
    }
    
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int a, b;
  cin>>a>>b;
  if(a==1) a = 14;
  if(b==1) b = 14;
  if(a>b) cout<<"Alice"<<endl;
  else if(a<b) cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s;
  std::cin>>s;
  ll n=s.size(),count=0;
  rep(i,0,n)if(s[i]=='p')count++;
  std::cout<<n/2-count;
  return 0;
}

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

if n == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = factorization(n)
s= 0
for i in range(len(ans)):
    now = 1
    while(ans[i][1] >= 0):
        ans[i][1] -= now
        #print(ans[i][0],now)
        s += 1
        now += 1
    s -= 1
print(s)


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

    int a, b; cin >> a >> b;

    int now = 1;
    int ans = 0;
    while(now < b){
        now += a-1;
        ++ans;
    }

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

Measured memory_bytes: 256
main=do
 getLine
 ss<-lines<$>getContents
 let x=last ss
 let st=map((\[s,t]->(s==x,read t)).words)$init ss
 print$f False st
f x[]=0
f True((s,t):st)=t+f True st
f False((s,t):st)=f s st

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

int main(void){
  int N;
  int oturi;
  cin >> N;
  for(int i = 1; i <= 10; i++){
    if(i * 1000 >= N){
      oturi = i * 1000 - N;
      break;
    }
  }
  cout << oturi << endl;
}

Measured memory_bytes: 3612
// https://atcoder.jp/contests/abc118/tasks/abc118_c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

//ユークリッドの互除法
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  int n, buf, ans = 1000000001;
  scanf("%d", &n);
  int hp[n];

  // 初期化
  for (int i = 0; i < n; i++) {
    scanf("%d", &buf);
    hp[i] = buf;
  }

  // コンビネーションで剰余を取る
  ans = gcd(hp[0], hp[1]);
  for (int i = 2; i < n - 1; i++) {
    ans = gcd(ans, hp[i]);
  }
  printf("%d", ans);

  return 0;
}


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

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

  vector<int> L(N);
  rep(i, N) cin >> L[i];

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

  int sum = 0;
  rep(i, N) sum += L[i];

  if (sum - L[N - 1] > L[N - 1])
    puts("Yes");
  else
    puts("No");
}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } 
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,x;
	cin >>n >>x;
	VI m(n);
	rep(i,n) cin >>m[i];
	sort(all(m));
	rep(i,n) x -= m[i];
	int ans = x / m[0] + n;
	cout << ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 



void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


const int Mxn = 6e5+1;
vector<int>a,seg;


void update(int l,int r,int i,int c,int vl)
{

   if(l>r || l>c || r< c)
   {
    return ;
   }
   if(l==r)
   {
      // cout<<i<<" "<<l<<" "<<vl<<"\n";
      seg[i] = vl;
      return ;
   }
   int md = (l+r)/2;
   update(l,md,2*i+1,c,vl);
   update(md+1,r,2*i+2,c,vl);
   seg[i] = max(seg[2*i+1],seg[2*i+2]);
}


int qr(int l,int r,int sl,int sr,int i)
{
  if( r < sl || sr < l) return 0;

  if(sl<=l && sr>=r)
  {
    //cout<<l<<" "<<r<<" "<<seg[i]<<"\n";
    return seg[i];
  }
  int md = (l+r)/2;
  return  max(qr(l,md,sl,sr,2*i+1),qr(md+1,r,sl,sr,2*i+2));
}

int vls[Mxn];
void solve()
{
  int n,k;
  cin >> n >> k;
  
  a.assign(Mxn,0);
  seg.assign(4*Mxn+4,0);

  forf(i,0,n)
  {
    cin >> a[i];
  }
  
  int an =0;
  forf(i,0,n)
  {
     int cur = qr(0 , Mxn ,max(a[i]-k,(int)0) , a[i]+k,0); 
     
     an = max(an,cur+1);
     // cout<<cur+1<<"\n";
     update(0,Mxn,0,a[i],cur+1);
    
  }

  // forf(i,0,11)
  // {
  //   cout<<vls[i]<<"\n";
  // }
  
  // forf(i,0,30) cout<<seg[i]<<" ";
  cout<<an;


}

int32_t main()
{
  pr_init();
  //fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 26756
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	char a,b;
	cin >> a >> b;
	if(a == 'H'){
		cout << b << endl;
	}
	else{
		if(b == 'H'){
			cout << 'D' << endl;
		}
		else{
			cout << 'H' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<int> v(n,0);
    rep(i,n) cin >> v[i];
    int tmp;
    rep(i,n){
        cin >> tmp;
        v[i] -= tmp;
    }
    int sum = 0;
    rep(i,n){
        if(v[i]>0) sum += v[i];
    }
    cout<< sum;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	string s;
	cin >> s;
	if ('A' <= s[0] && s[0] <= 'Z')
		s = "A";
	else
		s = "a";
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(int(x) for x in input().split())
found = True

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            found = False
            break

if found:
    print('APPROVED')
else:
    print('DENIED')


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  int mx=0,mn=1000*1000*1000+5;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    mx=max(a,mx);
    mn=min(a,mn);
  }
  cout<<mx-mn<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define alphanso                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if ((abs(a - b) + 1) % 2 == 0)
        cout << "Borys";
    else
        cout << "Alice";
    return 0;
}

Measured memory_bytes: 3612
fun main(){
  val (N,M) = readInts()
  val A = readInts()

  var sm = 0
  for(l in A){
    sm += l
  }

  val ans = N-sm
  if (ans>-1){
    println(ans)
  }
  else println(-1)
}


fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints

Measured memory_bytes: 39408
#include <iostream>

using namespace std;

int main()
{
	int n;
	int dd[101];
	for (int i = 1; i <= 100; ++i)
	{
		dd[i] = 0;
	}
	cin >> n;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		dd[a]++;
	}
	int count = 0;
	for (int i = 1; i <= 100; ++i)
	{
		if (dd[i] > 0)
			count++;
	}
	cout << count;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

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

	void solve() {
		String s = ns(), t = ns();
		out.println(s.equals(t.substring(0, t.length() - 1)) ? "Yes" : "No");
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 32540
n = int(input())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n%2==0:
    A_med=(A[int(n/2)-1]+A[int(n/2)])/2
    B_med=(B[int(n/2)-1]+B[int(n/2)])/2
    print(int((B_med-A_med)*2+1))
else:
    A_med=A[int((n+1)/2)-1]
    B_med=B[int((n+1)/2)-1]
    print(int(B_med-A_med+1))

Measured memory_bytes: 25392
N = int(input())
a = list(map(int, input().split()))

minus_cnt=0
zero_flag=False
mn = 10**10
sm = 0

for i in range(N):
    if a[i] == 0:
        zero_flag=True
    if a[i] < 0:
        minus_cnt+=1
    if mn > abs(a[i]):
        mn = abs(a[i])
    sm+=abs(a[i])

if zero_flag or minus_cnt%2==0:
    print(sm)
else:
    print(sm-2*mn)

Measured memory_bytes: 64880
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  string str;cin>>str;
  string ref;cin>>ref;
  int cnt = 0;
  for (int i = 0; i < 3; i++)
  {
    if(str[i] == ref[i])cnt++;
  }
  cout<<cnt<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int k,n;
    string S;
    cin >> S >> k;
    vector<string> s;
    for (int i = 0; i < (int)S.size(); i++){
        for (int k = 1; k < 6; k++){
            s.push_back(S.substr(i,k));
        }
    }
    sort(all(s));
    s.erase(unique(all(s)), s.end());

    cout << s[k-1] << endl;




    return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll tyo=(ll)1e12*2;
using namespace std;

int main(){
  ll N,M,ans=0,a=0;
  cin>>N>>M;
  ll A[N];
  vector<pair<ll,ll>> p(M);
  for(ll i=0;i<N;i++) cin>>A[i];
  for(ll i=0;i<M;i++){
    cin>>p[i].second>>p[i].first;
  }
  sort(A,A+N);
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  for(ll i=0;i<N;i++){
    if(A[i]<p[a].first&&a<M){
      ans+=p[a].first;
      p[a].second--;
      if(p[a].second==0) a++;
    }else ans+=A[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

int main() {
    int t;
    cin >> t;
    rep(i, t) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int K[N+1];
  int A[N+1][31];
  for(int i=1; i<=N; ++i){
    cin >> K[i];
    for(int j=1; j<=K[i]; ++j){
      cin >> A[i][j];
    }
  }
  int count[M+1];
  for(int i=1; i<=M+1; ++i) count[i]=0;
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=K[i]; ++j){
      count[A[i][j]] +=1;
    }
  }
  int ans=0;
  for(int i=1; i<=M; ++i){
    if(count[i]==N) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

struct edge{int from, to, cost;};
int V, E, r;
vector<edge> g;
int d[100005];  
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> V >> E >> r;
    rep(i, 0, E) {
        int s, t, u;
        cin >> s >> t >> u;
        edge tmp;
        tmp.from = s, tmp.to = t, tmp.cost = u;
        g.pb(tmp);
    }

    fill(d, d+V, INF);
    d[r] = 0;
    rep(k, 0, V) {
        rep(i, 0, E) {
            edge e = g[i];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                if (k == V - 1) {
                    cout << "NEGATIVE CYCLE" << endl;
                    return 0;
                }
            }
        }
    }
    rep(i, 0, V) {
        if (d[i] != INF) cout << d[i] << endl;
        else cout << "INF" << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);

        int n = Reader.nextInt();

        int case_1 = (n/500)*1000;
        int case_2 = (n/5)*5;
        int case_3 = ((( (n-((n/500)*500))/5)*5)+case_1);

        System.out.println(Math.max(case_1,Math.max(case_2,case_3)));
    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

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

vector<int> xw = {-1,  0,  1, -1,  1, -1,  0,  1 };
vector<int> yh = {-1, -1, -1,  0,  0,  1,  1,  1 };
void dfs( vector<vector<int>> &vec, int X, int Y, int &w, int &h, vector<vector<bool>> &ck ){
  if ( ck.at(Y).at(X) ) return;
  
  ck.at(Y).at(X) = true;
  for (int i=0; i<8; i++) {
    int x = X + xw.at(i);
    int y = Y + yh.at(i);
    if( x < 0 || w <= x ) continue;
    if( y < 0 || h <= y ) continue;
    if ( vec.at(y).at(x) ) dfs( vec, x, y, w, h, ck);
  }
}

int main() {
  
  while (true) {
  int W,H;
  cin >> W >> H;
  if( W == 0 || H == 0) break;
    
  vector<vector<int>> P(H, vector<int>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> P.at(i).at(j);  
    }
  }
  
  vector<vector<bool>> checked(H, vector<bool>(W, false));
  int res = 0;
  for (int h=0; h<H; h++) {
    for (int w=0; w<W; w++) {
      if( !checked.at(h).at(w) && P.at(h).at(w) ) {
         res++; dfs( P, w, h, W, H, checked);
      }
    }
  }
  
  cout << res << endl;
    
  }
  return 0;
}


Measured memory_bytes: 3256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string A[3]={"Sunny","Cloudy","Rainy"};
	string S;
	scan(S);
	rep(i,3){
		if(S==A[i]){
			prin(A[(i+1)%3]);
			return 0;
		}
	}
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	while(cin>>n,n){
		vector<string> field(n,string(n,' '));
		vector< vector<int> > dp(n,vector<int>(n));
		for(int i=0;i<n;i++)	cin>>field[i];

		for(int i=0;i<n;i++)	dp[i][0]=field[i][0]=='.'?1:0;
		for(int i=0;i<n;i++)	dp[0][i]=field[0][i]=='.'?1:0;
		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				if(field[i][j]=='*')	dp[i][j]=0;
				else	dp[i][j]=min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
			}
		}

		int ans=0;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans=max(ans,dp[i][j]);
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3984