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

#define ll long long
#define inf 0x3f3f3f3f
const int maxn=1e5+5;
#define mod 1000000007
/*int head[maxn],ver[maxn],nxt[maxn],tot,edge[maxn];
bool vis[maxn];
int d[maxn],ans;
void add(int x,int y)
{
    ver[++tot]=y;
    edge[tot]=1;
    nxt[tot]=head[x];
    head[x]=tot;
}
void dp(int x)
{
    vis[x]=1;
    for(int i=head[x];i;i=nxt[i])
    {
        int y=ver[i];
        if(vis[y])continue;
        dp(y);
        ans=max(ans,d[x]+d[y]+edge[i]);
        d[x]=max(d[x],d[y]+edge[i]);
    }
}*/
int main()
{
   int h,a;
   cin>>h>>a;
   if(h%a==0) cout<<h/a<<endl;
   else cout<<(h/a+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        if(n==0 || n==k){
            System.out.println(0);
            return;
        }

        long min = n;
        if(n > k){
            n = Math.abs(n - (n/k - 1)*k);
        }
        else if(n<k){
            n = Math.abs(n - (k/n - 1)*n);
        }
        n = Math.min(n, min);
        min = n;
        while(true){
            long tmp = Math.abs(n-k);
            if(tmp < min){
                min = tmp;
                n = tmp;
            }
            else{
                break;
            }
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 23636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
using namespace std;


int main() {
    int n, l, r;
    int ans = 0;
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>l>>r;
        ans += r - l + 1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
struct E{
	int to;
	int clr;
	int len;
	
};
vector<E> g[100005];
int anc[18][100005],d[100005];
void dfs(int u,int fa){
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		anc[0][v.to]=u;
		d[v.to]=d[u]+1;
		dfs(v.to,u);
	}
}
int LCA(int x,int y){
	if(d[x]>d[y]){
		swap(x,y);
	}
	for(int ind=0;d[x]<d[y];++ind){
		if((d[y]-d[x])>>ind&1){
			y=anc[ind][y];
		}
	}
	if(x==y){
		return x;
	}
	for(int ind=18;ind--;){
		if(anc[ind][x]!=anc[ind][y]){
			x=anc[ind][x],y=anc[ind][y];
		}
	}
	return anc[0][x];
}
struct info{
	int ind;
	char typ;
	int clr;
	int cnt;
	info(){}
	info(int in,char ty,int cl,int cn){
		ind=in,typ=ty,clr=cl,cnt=cn;
	}
}; 
vector<info> q[100005];
ll sum[100005];
ll cnt[100005];
ll ans[100005];
void DFS(int u,int fa,ll len){
	for(auto now:q[u]){
		if(now.typ=='d'){
			ans[now.ind]+=len*now.cnt;
		}
		else if(now.typ=='s'){
			ans[now.ind]+=sum[now.clr]*now.cnt;
		}
		else{
			ans[now.ind]+=cnt[now.clr]*now.cnt;
		}
	}
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		sum[v.clr]+=v.len;
		cnt[v.clr]++;
		DFS(v.to,u,len+v.len);
		sum[v.clr]-=v.len;
		cnt[v.clr]--;
	}
}
int main(){
	int n,Q;
	cin>>n>>Q;
	for(int i=1;i<n;++i){
		int u,v,clr,leng;
		cin>>u>>v>>clr>>leng; 
		u--,v--,clr--;
		E a;
		a.to=v,a.len=leng,a.clr=clr;
		E b;
		b.to=u,b.len=leng,b.clr=clr;
		g[u].push_back(a),g[v].push_back(b);
	}
	dfs(0,0);
	for(int ind=0;ind<17;++ind){
		for(int u=0;u<n;++u){
			anc[ind+1][u]=anc[ind][anc[ind][u]];
		}
	}
	for(int i=0;i<Q;++i){
		int clr,leng,u,v;
		cin>>clr>>leng>>u>>v;
		clr--;
		u--;
		v--;
		int lca=LCA(u,v);
		q[u].emplace_back(i,'d',0,1);
		q[u].emplace_back(i,'s',clr,-1);
		q[u].emplace_back(i,'c',clr,leng);
		
		q[v].emplace_back(i,'d',0,1);
		q[v].emplace_back(i,'s',clr,-1);
		q[v].emplace_back(i,'c',clr,leng);
		
		q[lca].emplace_back(i,'d',0,-2);
		q[lca].emplace_back(i,'s',clr,2);
		q[lca].emplace_back(i,'c',clr,-2*leng);
	}
	DFS(0,0,0);
	for(int i=0;i<Q;++i){
		cout<<ans[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 45552
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;
int MOD = 1000000007;

int MAX = 20000000;

long long fac[20000000], finv[20000000], inv[20000000];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
int x,y;
cin >> x >> y;

long long ans =1;
int same=0;
while(x >=3 and y>=3 and x <(2*y) and y <(2*x)){

  same+=2;
  x-=3;
  y-=3;
  //printf("%d %d\n",x,y);
}
int side=0;
while(x >=1 and y>=1){
  if(x>y){
    x-=2;
    y-=1;
    
  }else{
    x-=1;
    y-=2;
  }
  side++;
  //printf("%d %d\n", x, y);
}
if(x!=0 or y!=0){
  ans=0;
  }
      //cout << same <<'\n'<<side<<endl;
/*
//find   (same+side)C(same/2)

*/
if(ans){

  COMinit();
cout << COM(same+side,same/2) << endl;
}else{
  cout <<0<<endl;
}
}

Measured memory_bytes: 468992
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            p.add(i, scanner.nextInt());
        }
        List<Integer> q = p.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
        int count = 0;
        for (int i = 0; i < N; i++) {
            if(p.get(i) != q.get(i)){
                count++;
            }
        }
        if(count == 2 || count == 0) {
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}

Measured memory_bytes: 28748
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

int n;
double x[100000], r[100000];

bool check(double y) {
    double lm = -1000000, rm = 2000000;
    for(int i = 0; i < n; i++) {
        if(r[i] < y) return false;
        double left = x[i] - sqrt(r[i] * r[i] - y * y);
        double right = x[i] + sqrt(r[i] * r[i] - y * y);
        lm = max(lm, left);
        rm = min(rm, right);
    }
    return lm <= rm;
}

int main() {

    cin >> n;
    double left = 0, right = 1000000000;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> r[i];
        right = min(right, r[i]);
    }

    int cnt = 0;
    while(cnt++ < 200) {
        double mid = (left + right) / 2;

        if(check(mid)) {
            left = mid;
        } else {
            right = mid;
        }
    }
    cout << fixed << left << endl;
}

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

/*==========type============*/
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::pair<std::string,ll> psl;

/*==========constant============*/
#define INF INT_MAX
#define INF_L LONG_MAX
#define INF_LL LLONG_MAX
#define MOD 1000000007

/*==========function============*/
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

using namespace std;

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

    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    REP(i,0,n)cin >> h[i];

    vector<ll> dp(n,INF);

    dp[0] = 0;
    REP(i,0,n){
        REP(j,1,k+1){
            if(j + i >= n)break;
            ll cost = abs(h[i] - h[i+j]) + dp[i];
            dp[i + j] = dp[i + j] > cost ? cost : dp[i+j];
        }
        // cout << "i:" << i << " dp:" << dp[i] << endl;
    }

    ll ans = dp[n - 1];

    cout << ans << endl;

    return 0;
}    

Measured memory_bytes: 4732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        long gcd = gcd(a, b);
        
        System.out.println(prime(gcd));
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
    
	public static long prime(long n) {
		int count = 1;
		
		long d = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (d % i == 0) {
				count++;
				while (d % i == 0) {
					d = d / i;
				}
			}
		}
		
		if (d != 1)
			count++;
		return count;
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    int p[n], q[n];

    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        cin >> q[i];
    }

    int pp=0, qq=0;
    int nn = 1;
    rep(i, n-1){
        nn *= i+1;
    }

    rep(i, n){
        
        int tmpp = 0;
        int tmpq = 0;
        rep(j, n){
            if(i<j){
                if(p[i]<p[j]){
                    tmpp++;
                }
                if(q[i]<q[j]){
                    tmpq++;
                }  
                
            }
        }
        // printf("%d\n", i);
        pp += nn * tmpp;
        qq += nn * tmpq;
        if(i!=n-1) nn /= (n-1-i);
    }

    cout << abs(pp-qq) << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 10000000000000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
vector<P> G[100000];
int Q, K;

ll d[100000];
void solve(){
	rep(i, N)
		d[i] = INF;
	K--;
	d[K] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, K));
	while(!q.empty()){
		P p = q.top(); q.pop();
		int n = p.second;
		int cost = p.first;
		if(d[n] < cost) continue;
		rep(i, G[n].size()){
			int to = G[n][i].first;
			int co = G[n][i].second;
			if(d[to] > d[n] + co){
				d[to] = d[n] + co;
				q.push(P(d[to], to));
			}
		}
	}
	rep(i, Q){
		int x, y;
		cin >> x >> y;
		x--; y--; 
		cout << d[x] + d[y] << endl;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N - 1){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].pub(P(b, c));
		G[b].pub(P(a, c));
	}
	cin >> Q >> K;
		solve();
	return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
int64_t l[100005],n,r[100005],ans;
int main(){
	cin>>n;
	for(int i=0;i<n;++i) cin>>l[i]>>r[i];
	sort(l,l+n+1,greater<long long>());sort(r,r+n+1);
	for(int64_t i=0,sum=0;i<=n;++i){
		sum += 2*(l[i]-r[i]);
		ans = max(ans,sum);
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	string ans = "No";
	rep(i, 0, n / 4 + 1) {
		if ((n - 4 * i) % 7 == 0) ans = "Yes";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
//using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    std::string s;
    std::cin >> s;
    int n = s.size() - 1;

    ll sum = 0;
    std::vector<std::string> a;
    for (int bit = 0; bit < (1 << n); bit++) {
        std::string t = s;
        int count = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                t.insert(i + count + 1, "+");
                count++;
            }
        }
        a.push_back(t);
    }
    int m = a.size();
    for (int i = 0; i < m; ++i) {
        while (a[i].size() != 0){
            if(all_of(a[i].cbegin(),a[i].cend(),isdigit)){
                sum += stoll(a[i]);
                break;
            }else{
                std::string sub_t = a[i].substr(0, a[i].find('+'));
                int num = stoll(sub_t);
                sum += num;
                a[i].erase(0, a[i].find('+') + 1);
            }
        }
    }
    print(sum);
}

Measured memory_bytes: 256
while True:
    A, op, B = input().split()
    A = int(A)
    B = int(B)

    if op == "+":
        print(int(A + B))
    elif op == "-":
        print(int(A - B))
    elif op == "*":
        print(int(A * B))
    elif op == "/":
        print(int(A / B))
    elif op == "?":
        break


Measured memory_bytes: 5596
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, a, b = LI()
print(n // (a + b) * a + min(n % (a + b), a))

Measured memory_bytes: 39664
#include<iostream>
using namespace std;
typedef long long ll;

// 解説を見た
int main(){
    ll n, x;
    cin >> n >> x;
    
    // 最初の2回分の反射
    ll ans = x + n-x; // virtually n

    /// a, bからなる平行四辺形が出来る
    ll a = max(n-x, x), b = min(n-x, x);
    
    while(b != 0){
        // 図示するとわかるが(x > n/2とするとわかりやすい)、
        // 平行四辺形内を光が反射しまくって
        // 新しい平行四辺形を作り上げるとき、長辺aの長さを短辺b
        // の長さで割ったときの商(切り捨て)の2倍だけ長さbの軌跡が残る
        // 新しく出来る平行四辺形の長さはb, a%b(euclidそのもの)
        ans += a/b*2*b;
        ll tmp = a;
        a = b;
        b = tmp%b;
    }

    // 最後(平行四辺形でなくなってしまう)とき、bを1回余計に足している
    // これは、最後の平行四辺形内の軌跡を構成する線分群のうち、
    // 1辺だけ既にもっと長い線分の一部として計算済であることからわかる
    // そのときのbはaに格納されているので、ansからaを引く
    cout << ans-a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	int n,m;
	cin >> n >> m;
	vector<ll> x(n);
	vector<ll> y(n);
	vector<ll> z(n);

	for(int i = 0;i < n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}

	vector<ll> a[8];
	for(int i = 0;i < n;i++){
		a[0].push_back(x[i]+y[i]+z[i]);
	}

	for(int i = 0;i < n;i++){
		a[1].push_back(x[i]+y[i]-z[i]);
	}

	for(int i = 0;i < n;i++){
		a[2].push_back(x[i]-y[i]+z[i]);
	}

	for(int i = 0;i < n;i++){
		a[3].push_back(-x[i]+y[i]+z[i]);
	}

	for(int i = 0;i < n;i++){
		a[4].push_back(-x[i]-y[i]+z[i]);
	}

	for(int i = 0;i < n;i++){
		a[5].push_back(-x[i]+y[i]-z[i]);
	}

	for(int i = 0;i < n;i++){
		a[6].push_back(x[i]-y[i]-z[i]);
	}

	for(int i = 0;i < n;i++){
		a[7].push_back(-x[i]-y[i]-z[i]);
	}

	for(int i = 0;i < 8;i++)sort(a[i].begin(),a[i].end(),greater<ll>());

	ll sum[8] = {};
	for(int i = 0;i < m;i++){
		for(int k = 0;k < 8;k++)sum[k] += a[k][i];
	}

	ll ans = 0;
	for(int i = 0;i < 8;i++)ans = max(ans,sum[i]);
	cout << ans << endl;
}


Measured memory_bytes: 384
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


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


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


n, k = invr()
res = 0
for i in range(1, n+1):
    if i > (k-1):
        res += 1/n
    else:
        x = ceil(log2((k)/i))
        res += (1/n) * (1/2)**x
print(res)


Measured memory_bytes: 5460
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll inf = 1e9;

string s;

int main(void) {
    fastio;
    cin >> s;
    bool yes = false;
    for(auto c : s) if(c == '7') yes = true;
    cout << (yes ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3648
/*************************************************************************
  > File Name: e.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Sun Mar 22 20:21:36 2020
*************************************************************************/

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

int h, w, k;
int in[11][1010];
int sum[11][1010];
int ans;
void check(int x) {
    vector<int> v;
    v.emplace_back(0);
    int cnt = 0;
    for (int j = 1; j < h; j++) {
        int a = (x >> (j - 1)) & 1;
        if (a)
            v.emplace_back(j);
        cnt += a;
    }
    v.emplace_back(h);
    int last = 0;
    for (int i = 1; i <= w; i++) {
        bool to_cut = 0;
        for (int j = 1; j < (int)v.size(); j++) {
            int s = sum[v[j]][i] - sum[v[j - 1]][i] - sum[v[j]][last] + sum[v[j - 1]][last];
            int s2 = sum[v[j]][i] - sum[v[j]][i - 1] - sum[v[j - 1]][i] + sum[v[j - 1]][i - 1];
            if (s2 > k)
                return;
            //cout << v[j] << ' ' << v[j - 1] << ' ' << i << ' ' << last << ' '<< s << '\n';
            to_cut |= s > k;
        }
        if (to_cut) {
            last = i - 1;
            cnt++;
        }
    }
    ans = min(ans, cnt);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> k;
    ans = 1e9;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) {
            char a;
            cin >> a;
            in[i][j] = a == '1';
            sum[i][j] = in[i][j] - sum[i - 1][j - 1] + sum[i - 1][j] + sum[i][j - 1];
        }
    int mx = 1 << (h - 1);
    for (int i = 0; i < mx; i++) {
        check(i);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s1[105],s2[105],s3[105];
	int n;
	scanf("%d",&n);
	scanf("%s%s%s",s1,s2,s3);
	int cot=0;
	for(int i=0;i<n;i++)
	{
		if(s1[i]!=s2[i]&&s1[i]!=s3[i]&&s3[i]!=s2[i])	cot+=2;
		else	if(s1[i]==s2[i]&&s1[i]!=s3[i])	cot++;
		else	if(s1[i]==s3[i]&&s1[i]!=s2[i])	cot++;
		else	if(s2[i]==s3[i]&&s2[i]!=s1[i])	cot++;
	}
	printf("%d\n",cot);
	return 0;
 } 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const int maxn = 1e5;
const long long maxw = 1e10;

int n;
long long a[maxn];
int cnt_prime, prime[5000];

inline long long Sqr(int n) {
  return (long long)n * n;
}

inline long long Cube(int n) {
  return (long long)n * n * n;
}

long long GetRest(long long a) {
  long long b = 1;
  for (int i = 0; i < cnt_prime; ++i) {
    if (a % Sqr(prime[i]) == 0) {
      b *= prime[i];
      a /= Sqr(prime[i]);
    } else if (a % prime[i] == 0) {
      b *= Sqr(prime[i]);
      a /= prime[i];
    }
  }
  long long sqrt_a = floor(sqrt(a + (long double)0.5));
  if (sqrt_a * sqrt_a == a) {
    b *= sqrt_a;
  } else {
    b *= a * a;
  }
  return b;
}

int main(void) {
  cnt_prime = 0;
  for (int n = 2; Cube(n) <= maxw; ++n) {
    bool is_prime = true;
    for (int i = 2; i * i <= n; ++i) {
      if (n % i == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime) {
      prime[cnt_prime++] = n;
    }
  }

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    for (int j = 0; j < cnt_prime; ++j) {
      while (a[i] % Cube(prime[j]) == 0) {
        a[i] /= Cube(prime[j]);
      }
    }
  }
  sort(a, a + n);

  int ans = a[0] == 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) continue;
    int j = i + 1;
    while (j < n && a[j] == a[i]) {
      ++j;
    }
    long long b = GetRest(a[i]);
    pair<long long*, long long*> res = equal_range(a, a + n, b);
    if (res.second == res.first || b > a[i]) {
      ans += max(j - i, (int)(res.second - res.first));
    }
    i = j - 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1152
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    if A[i-1]+A[i] <= x:
        continue
    eat = A[i-1]+A[i] - x
    ans += eat
    A[i] = max(0, A[i]-eat)

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll s, k;
	cin >> k >> s;
	ll ans = 0;
	for(ll i=0; i<=k; i++){
		for(ll j=0; j<=k; j++){
			if(s - (i+j) <= k and s - (i+j) >= 0)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def __move_next(self, x, y):
        temp = y.pop(0)
        y.append(temp)
        x[0] = y[0]
        x[2] = y[2]
 
    def __move_prev(self, x, y):
        temp = y.pop(3)
        y.insert(0, temp)
        x[0] = y[0]
        x[2] = y[2]
 
    def execute(self, c):
        for i in c:
            self.__move(i, self.rows, self.cols)
 
    def __move(self, com, x, y):
        if com == "N":
            self.__move_prev(y, x)
        elif com == "S":
            self.__move_next(y, x)
        elif com == "E":
            self.__move_prev(x, y)
        elif com == "W":
            self.__move_next(x, y)
 
    def print_top(self):
        print(self.rows[0])
    
    def execute2(self, a, b):
        self.__rot(a)
        if a == self.rows[0] or a == self.rows[2]:
            self.__move_prev(self.cols, self.rows)    
        
        self.__rot(b)
        
        while a != self.rows[0]:
            self.__move_prev(self.cols, self.rows)    
        
        if b == self.rows[1]:
            print(self.cols[3])
        elif b == self.rows[3]:
            print(self.cols[1])
        
    def __rot(self, z):
        i = 0
        while z not in self.rows:
            self.__move_next(self.rows, self.cols)
            if i > 3:
                self.__move_next(self.cols, self.rows)
                i = 0
            i+=1

d = list(map(int, input().split(" ")))
c = int(input()) 
dice = Dice(d)

for i in range(c):
    a, b = map(int, input().split(" "))
    dice.execute2(a,b)



Measured memory_bytes: 5612
import java.util.Scanner;

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

        if ((A + B) % 2 == 0) {
            System.out.println((A + B) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int GCD(int x, int y){
	if(y == 0) return x;
	return GCD(y, x % y);
}

int main(){
	int N, X;
	cin >> N >> X;
	vector<long int> x(N);
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	vector<long int> zahyo;
	zahyo.push_back(X);
	for(int i=0;i<N;i++){
		zahyo.push_back(x[i]);
	}
	sort(zahyo.begin(), zahyo.end());
	vector<long int> v;
	for(int i=0;i<N;i++){
		v.push_back(zahyo[i+1] - zahyo[i]);
	}
	int ans =  GCD(v[0], v[1]);
	for(int i=2;i<N;i++){
		ans = GCD(ans, v[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3316
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 3 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int a , b, t;
    cin>>a>>b>>t;
    int x=a , counter = 0;

    while(x<=t){
        counter +=b;
        x+=a;
    }

    cout<<counter<<endl;




    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("ain","r",stdin);
    freopen("aout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int x;
  cin >> x;
  int ans = (x/500)*1000;
  x %= 500;
  ans += (x/5)*5;
  cout << ans << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define free  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second

bool vowel(char che)
{
    if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' || che == 'Y')
        return true;
    else
        return false;
}

const int N = 1e6+5;
const int mod = 1e9+7;
ll a[N], b[N], c[N], d, dp, dis, tree[N];
pair <int, int> p;
char o;
bool mark[N], h;
string s, s1;
stack <int> st;
set <ll> st1, st2;
deque <int> dq;
vector <int> vt, vs, vm;
//int a1[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};


int main()
{
    Fast
    ll t, n, m, k = 0, f = 0, sum = 0, ans = 0, n1 = 0;
    cin  >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n-2; i++){
        if (a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2])
            h = true;
    }
    if (h)
        cout << "Yes";
    else
        cout << "No";
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<int> A;
    int sum = 0;
    rep(i, N){int a; cin >> a; A.push_back(a); sum += a;}
    sort(A.begin(), A.end(), greater<int>());
    // cout << sum << " " << A.at(M - 1) << " " << (sum / (4 * M)) << endl;
    double res = (double)sum / (4 * M);
    if (A.at(M - 1) < res){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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


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

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; ++i) {
        cout << S[i] << T[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;
    if(B>=A*C){
        cout << C << endl;
    }else{
        cout << (int)B/A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
mod = int(1e9+7)

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = []
for i in range(len(s)+1):
  dp.append([0] * (len(t)+1))

for i in range(1, len(s)+1):
  for j in range(1, len(t)+1):
    if s[i-1] == t[j-1]:
      dp[i][j] = (1 + dp[i-1][j] + dp[i][j-1]) % mod
    else:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
ans = dp[-1][-1] + 1 % mod
print(ans)


Measured memory_bytes: 72284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,w=0;
  std::cin >> x;
  std::vector<std::vector<int>> v(2,std::vector<int> (x));
  rep(i,2)Rep(j,x)std::cin >> v[i][j];
  rep(i,x){
    Rep(j,x){
      if(i<j){
        y+=v[1][j];
      }else if(i==j){
        y+=v[1][j]+v[0][j];
      }
      else{
        y+=v[0][j];
      }
    }
    if(n<y)n=y;
    y=0;
  }
  std::cout << n << '\n';
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  int W, H, x, y, r;
 
  cin >> W >> H >> x >> y >> r;
  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
 
  return 0;
}

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

int parent[100000];
int degree[100000];
int *children[100000];

int depth(int node){
    if(parent[node] == -1)
        return 0;
    else
        return depth(parent[node]) + 1;
}

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        parent[i] = -1;
    for(int j=0; j<n; j++){
        int id, k;
        scanf("%d%d", &id, &k);
        degree[id] = k;
        children[id] = (int*)malloc(sizeof(int)*k);
        for(int i=0; i<k; i++){
            scanf("%d", &children[id][i]);
            parent[children[id][i]] = id;
        }
    }
    for(int i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth(i));
        if(parent[i] == -1)
            printf("root, ");
        else if(degree[i] == 0)
            printf("leaf, ");
        else
            printf("internal node, ");
        printf("[");
        for(int j=0; j<degree[i]; j++){
            printf("%d", children[i][j]);
            if(j < degree[i] - 1)
                printf(", ");
        }
        printf("]\n");
    }
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

struct edge{
  int from,to,cost;
};

vector<vector<int>> G;

int calc(vector<int>& dist, vector<edge>& edges){
  int n = dist.size(), m = edges.size();
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      int from = edges[j].from, to = edges[j].to, cost = edges[j].cost;
      if(dist[from] != INF && dist[to] > dist[from]+cost){
        dist[to] = dist[from] + cost;
        if(i == n-1) {
          return -1;
        }
      }
    }
  }
  return 0;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,p,a,b,c;
  cin >> n >> m >> p;
  vector<int> dist(n,INF);
  dist[0] = 0;
  G = vector<vector<int>>(n);
  vector<edge> edges;

  for(int i=0; i<m; i++){
    cin >> a >> b >> c;
    a--; b--;
    edge t;
    t.from = a; t.to = b; t.cost = -c+p;
    edges.push_back(t);
    G[a].push_back(b);
  }


  if(calc(dist,edges) == -1){
    int tmp = dist[n-1];
    calc(dist,edges);
    if(tmp==dist[n-1]){
      cout << max(0,-dist[n-1]) << endl;
    }else{
      cout << -1 << endl;
    }
  }else{
    cout << max(0,-dist[n-1]) << endl;
  }
  //cout << arrive << endl;
  //cout << dist << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937


int main()
{
	
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif*/
    
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]==t[i])
    	{
    		count++;
		}
	}
	
	cout<<count;
	
	return 0;
}


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

int main(){
  long long int a,b,k;
  cin >> a >> b >> k;
  long long int tk,ao;
  if(a>k){
    tk = a-k;
    ao = b;
  }
  else if(a+b>k){
    tk = 0;
    ao = a+b-k;
  }
  else
    tk = ao = 0;
  cout << tk << " " << ao << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(btoe(l));
    ll ans=0;
    rep(i,n-1){
        rep(j,i){
            for(int k=i+1; k<n; ++k){
                if(l[i]+l[j]<=l[k]) break;
                ans++;
            } 
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね

int main(){
    int a,b,c;
    cin >> a>>b>>c;
    if(c-(a-b)>0){
        cout<<c-(a-b)<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

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

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int main(){
	//HelloWorld();
	XCubic();
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

std::string s;
ll dp[100005][13];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> s;

    int end = (int)s.size();
    dp[0][0] = 1;
    for (int i = 0; i < end; ++i) {
        int num = -1;

        if (s[i] != '?')
            num = s[i] - '0';

        for (int j = 0; j < 13; ++j) {
            for (int k = 0; k < 10; ++k) {
                if (num != -1 && k != num)
                    continue;
                auto idx = (10 * j + k) % 13;
                dp[i + 1][idx] = (dp[i + 1][idx] + dp[i][j]) % mod;
            }
        }
    }

    std::cout << dp[end][5] << std::endl;

    return 0;
}


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

using namespace std;

int main(void)
{
	string input;
	cin >> input;

	int result = 0;
	for(auto i = 0U; i < (input.size() + 1) / 2; ++i) {
		if(input[i] != input[input.size() - 1 - i]) {
			++result;
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 256
// abc129d.cpp : Lamp
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))

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

	vector<string> s(h);
	vvi U(h,vi(w));
	vvi L(h,vi(w));

	up(i,0,h,1){
		cin>>s[i];
		up(j,0,w,1){
			if(i>0 && s[i][j]=='.' && s[i-1][j]=='.'){ // U
				U[i][j] = U[i-1][j] + 1;
			}
			if(j>0 && s[i][j]=='.' && s[i][j-1]=='.'){ // L
				L[i][j] = L[i][j-1] + 1;
			}
		}
	}

	dw(i,h-1,-1,1){
		dw(j,w-1,-1,1){
			if(i<h-1 && s[i][j]=='.' && s[i+1][j]=='.'){ // D
				U[i][j] = U[i+1][j];
			}
			if(j<w-1 && s[i][j]=='.' && s[i][j+1]=='.'){ // R
				L[i][j] = L[i][j+1];
			}
		}

	}

	int ans = 0;
	up(i,0,h,1){
		up(j,0,w,1){
			if(s[i][j]=='.'){
				int s = U[i][j] + L[i][j] + 1;
				if(ans<s) ans = s;
			}
		}
	}

	cout<< ans <<endl;
}

Measured memory_bytes: 35712
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
A = [0]*N
ans = 0
bag = [i for i in range(1, M+1)]
for v in itertools.combinations_with_replacement(bag, N):
  an = 0
  for a, b, c, d in abcd:
    a -= 1
    b -= 1
    if v[b] - v[a] == c:
      an += d

  ans = max(ans, an)
print(ans) 

Measured memory_bytes: 73588
#include<stdio.h>
#define Max 500000
#define term 2000000000

int Left[(Max/2)+2], Right[(Max/2)+2];
int c=0;


void merge(int e[], int n, int left, int mid, int right){
  int i,j,k;

  int x = (mid-left);
  int y = (right-mid);

  for ( i=0; i<x; i++ )
   Left[i] = e[left+i];
  for ( i=0; i<y; i++ )
   Right[i] = e[mid+i];

  Left[x]= Right[y] = term;
  i = j = 0;
  for ( k=left; k<right; k++){
    c++;
    if ( Left[i]<=Right[j] ){
      e[k] = Left[i++];
    } else {
      e[k] = Right[j++];
    }
  }
}

void mergeSort(int e[], int n, int left, int right ){
  int mid;
  if ( left+1<right ){
    mid=(left + right)/2;
    mergeSort(e, n, left, mid);
    mergeSort(e, n, mid, right);
    merge(e, n, left, mid, right);
  }
}

int main(){
  int e[Max], n, i;
  scanf("%d", &n);
  for ( i=0; i<n; i++) {
    scanf("%d", &e[i]);
    if (e[i]>=term ){
      return 1;
    }
  }
  mergeSort(e,n,0,n);

  for ( i=0; i<n; i++) {
    if ( i !=0 ) 
    printf(" ");

    printf("%d", e[i]);
    }
  printf("\n");

  printf("%d\n", c);


  return 0;
}




Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

map<string, int> memo;
int main() {
	//sort(a.begin(),a.end());
	int h, a;
	cin >> h >> a;
	int ans = 0;
	if (h % a != 0) {
		ans = h / a + 1;
	}
	else {
		ans = h / a;
	}
	cout << ans;
	return 0;
}









Measured memory_bytes: 256