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

#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define P1(XX) cout<<"db1: "<<XX<<endl
#define P2(XX,YY) cout<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cout<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007LL
#define MX 200005


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll m, n;
ll a[MX],b[MX];
ll dp[MX][2];

using namespace std;
ll f (ll k)
{
    int l = 0;
    int r = m - 1;

    // Stores the index of the left most element
    // from the array which is greater than k
    ll leftGreater = m;

    // Finds number of elements greater than k
    while (l <= r) {
        ll mid = l + (r - l) / 2;

        // If mid element is greater than
        // k update leftGreater and r
        if (b[mid] > k) {
            leftGreater = mid;
            r = mid - 1;
        }

        // If mid element is less than
        // or equal to k update l
        else
            l = mid + 1;
    }
    return leftGreater;
}

int main()
{
    int test, tc=0, i, j;
    //scanf("%d", &test);
    test=1;
    while(test--)
    {
        MS(dp,-1);
        ll mm, k, res=0,ans=0;
        cin>>n>>m>>k;
        mm=m+n;
        for(i=0;i<n;i++)
        {
            scanf("%lld", &a[i]);
            if(i>0)a[i]+=a[i-1];
        }
        for(i=0;i<m;i++)
        {
            scanf("%lld", &b[i]);
            if(i>0)b[i]+=b[i-1];
        }
        ans=f(k);
        for(i=0;i<n;i++)
        {
            if(a[i]>k)break;
            ans=max(ans, i+1+f(k-a[i]));
        }
       cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 9904
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
int a[N], b[4];

bool ok(int i,int j,int k){
    b[1]=a[i], b[2]=a[j], b[3]=a[k];
    if(b[1]==b[2]||b[1]==b[3]||b[2]==b[3]) return 0;
    sort(b+1,b+4);
    if(b[1]+b[2]>b[3]) return 1;
    return 0;
}

int main(){
    ios;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    int ans=0;
    rep(i,1,n) rep(j,i+1,n) rep(k,j+1,n){
        if(ok(i,j,k)) ++ans;
    }
    cout<<ans;
    return 0;
}
/*
0 1
0 1 1 2
0 1 1 2

0 1 1 2
1 2 2 3
1 2 2 3
2 3 3 4
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 3612
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,a,b,c;
    string s,yr,dd,mm;
    cin>>s;
    yr=s.substr(0,4);
    mm=s.substr(5,2);
    dd=s.substr(8,2);
    a=stoi(yr);
    b=stoi(mm);
    c=stoi(dd);
    if(a<=2019&&b<=4)
    cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;



    return 0;
}





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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;






ll solve(ll cap, vector<vector<ll>> a) {
    vector<ll> dp(cap+1, 0);

    for (int i=1; i<=cap; i++) {
	dp[i]=dp[i-1];
	for (auto item: a) {
	    ll weight = item[0];
	    ll reward = item[1];
	    if (i-weight>=0) {
		dp[i] = max(dp[i], reward+dp[i-weight]);
	    }
	}
    }

    return dp[cap];
}


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


    ll n;
    ll ga,sa,ba;
    ll gb,sb,bb;

    cin>>n;
    cin>>ga>>sa>>ba;
    cin>>gb>>sb>>bb;

    vector<vector<ll>> a = {{ga,gb},{sa,sb},{ba,bb}};
    vector<vector<ll>> v;
    for (auto p: a) {
	v.push_back({p[0],p[1]-p[0]});
    }
    n += solve(n, v);
	
    
    a = {{gb,ga},{sb,sa},{bb,ba}};
    v.clear();
    for (auto p: a) {
	v.push_back({p[0],p[1]-p[0]});
    }
    n += solve(n, v);
    cout<<n<<endl;

    
    return 0;
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.end()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  while(cin >> n, n) {
    int ans = 0;
    rep(i, 1, n) {
      int sum = i;
      int j = i + 1;
      while(sum < n) {
        sum += j;
        ++j;
      }
      if(sum == n) ans++;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int x[100];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  ll res = 0x3f3f3f3f3f3f3f3f;
  for (int p = -100; p <= 100; p++) {
    ll sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (x[i] - p) * (x[i] - p);
    }
    res = min(sum, res);
  }
  cout << res << endl;
}



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

int main(){
    int n;
    cin>>n;
    vector<int>a(n),l(n),r(n);
    rep(i,n)cin>>a[i];
    l[0]=a[0];
    r[n-1]=a[n-1];
    for(int i=1; i<n; ++i){
        l[i]=__gcd(l[i-1],a[i]);
    }
    for(int i=n-2; i>=0; --i){
        r[i]=__gcd(r[i+1],a[i]);
    }
    int ans=max(l[n-2],r[1]);
    for(int i=1; i<n-1; ++i){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,a,b,c;
    while(~scanf("%d",&n))
    {
        if(n==2)
        {
            scanf("%d",&a);
            scanf("%d",&b);
            printf("%d\n",a+b);
        }
        else if(n==1)
            printf("Hello World\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 500000
#define M 2000000000


int L[N/2+2],R[N/2+2];
int count=0;


void merge(int A[],int l,int m,int r){
  int i,j,k;
  int n1;
  int n2;
  n1 = m - l;
  n2 = r - m;
  for(i=0;i<n1;i++){
    L[i] = A[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[m+i];
  }
  L[n1] = R[n2]=M;
  i = j = 0;
  for(k=l;k<r;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
      else {
	A[k] = R[j];
	j++;
      }
  }
}


void mergesort(int A[],int l,int r){
  int m;
  if(l+1<r){
    m = (l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}


int main(){
  int i,a,b[N];
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  mergesort(b,0,a);
  for(i=0;i<a-1;i++){
    //if(i>=1) printf(" ");
    printf("%d ",b[i]);
  }
  printf("%d\n",b[a-1]);
  printf("%d",count);
  printf("\n");
  return 0;
}

Measured memory_bytes: 4508
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,a,b,c,d[100];
	int i,j,cal,dol,mx,c2;
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&c);
	for(i=0;i<n;i++)	scanf("%d",&d[i]);
	sort(d,d+n);
	cal=c;	dol=a;
	mx=c/a;
	for(i=n-1;i>=0;i--)	{
		cal+=d[i];
		dol+=b;
		mx=max(mx,cal/dol);
	}
	printf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 1040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().run();
	}
	
	int filed[][]=new int[12][12];
	void run(){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int count=0;
			
			for(int i=0;i<12;i++){
				char ch[]=sc.next().toCharArray();
				for(int j=0;j<12;j++){
					filed[i][j]=ch[j]-'0';
				}
			}
			
			for(int i=0;i<12;i++){
				for(int j=0;j<12;j++){
					if(filed[i][j]==1){
						count++;
						dfs(j,i,12,12);
					}
				}
			}
			System.out.println(count);
		}
	}
	
    int mx[]={-1,0,1,0};
    int my[]={0,-1,0,1};
	void dfs(int x,int y,int w,int h){
        int i,nx,ny;
        for(i=0;i<4;i++){
            nx=x+mx[i];
            ny=y+my[i];
            if(0<=nx && nx<w && 0<=ny && ny<h && filed[ny][nx]!=0){
                filed[ny][nx]=0;
                dfs(nx,ny,w,h);
            }
        }
    }

}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,sum;
    cin>>N;
    int a[N];
    for(int i=0; i<N; i++){
        cin>>a[i];
    }
    sort(a,a+N);
    sum=a[N-1]/2;
    for(int i=0; i<N-1; i++)
        sum+=a[i];
    cout<<sum<<endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    if(n%2==0){
        int m2=m/2,m1=m-m2;
        for1(i,m1) write(i,m1*2+1-i);
        int d=m1*2;
        for1(i,m2) write(d+i,d+m2*2+2-i);
    }else{
        for1(i,m) write(i,m*2+1-i);
    }
    return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    int s = 0;
    int n = stoi(N);
    for (int i = 0; i < (int)N.size(); i++) {
        s += (int)(N[i] - '0');
    }
    if (n % s == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	string a, b, c;
	cin >> a >> b >> c;
	cout << char(a[0] + 'A' - 'a') << char(b[0] + 'A' - 'a') << char(c[0] + 'A' - 'a') << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
string a;

int main(){
  cin >> a;
  cout << "ABC" << a << endl;
  return 0;
}


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

using namespace std;

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

struct edge {
	int to;
	int flow;
	int cost;
	int rev;
	edge(int a, int b, int c, int d) : to(a), flow(b), cost(c), rev(d) {}
};

int N;
vector<vector<edge>> e;
const int INF = 1e9;

void add_edge(int from, int to, int flow, int cost)
{
	e[from].emplace_back(to, flow, cost, e[to].size());
	e[to].emplace_back(from, 0,  -cost, e[from].size()-1);
}

bool init()
{
	cin >> N;
	if (N == 0) return false;	
	e.clear();
	e.resize(N * 2 + 2);
	const int S = N * 2;
	const int G = N * 2 + 1;
	vector<tuple<int, int,int>> s;
	rep(i, N) {
//		e[S].emplace_back(i, 1, 0, e[i].size());
//		e[i].emplace_back(S, 0, 0, e[S].size()-1);
		add_edge(S, i, 1, 0);
		int t = i + N;
//		e[t].emplace_back(G, 1, 0, e[G].size());
//		e[G].emplace_back(t, 0, 0, e[t].size()-1);
		add_edge(t, G, 1, 0);
	}
	rep(i, N) {
		int a, b, c;
		cin >> a >> b >> c;
		vector<int> t{a, b, c};
		sort(t.begin(), t.end());
		s.emplace_back(t[0], t[1], t[2]);
	}
	sort(s.begin(), s.end());
	rep(i, N) {
		int cost = get<0>(s[i]) * get<1>(s[i]) * get<2>(s[i]);
//		e[i].emplace_back(G, 1, cost, e[G].size());
//		e[G].emplace_back(i, 1, -cost, e[i].size()-1);
		add_edge(i, G, 1, cost);
		reps(j, i+1, N) {
			if (get<0>(s[i]) < get<0>(s[j]) &&
				get<1>(s[i]) < get<1>(s[j]) &&
				get<2>(s[i]) < get<2>(s[j])) {
//				e[i].emplace_back(j, 1, 0, e[i].size());
//				e[j].emplace_back(i, 0, 0, e[i].size()-1);
				add_edge(i, j + N, 1, 0);
			}
		}
	}
	return true;
}


int min_cost_flow(int s, int t, int f, int V)
{
	int res = 0;
	vector<int> dist(V, INF);
	vector<int> prevv(V);
	vector<int> preve(V);
	while (f > 0) {
		fill(dist.begin(), dist.end(), INF);
		dist[s] = 0;
		bool update = true;
		while (update) {
			update = false;
			rep(v, V) {
				if (dist[v] == INF) continue;
				rep(i, e[v].size()) {
					edge& E = e[v][i];
					if (E.flow > 0 && dist[v] + E.cost < dist[E.to]) {
						dist[E.to] = dist[v] + E.cost;
						prevv[E.to] = v;
						preve[E.to] = i;
						update = true;
					}
				}
			}
		}
		if (dist[t] == INF) return -1;
		int d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, e[prevv[v]][preve[v]].flow);
		}
		f -= d;
		res += d * dist[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge& E = e[prevv[v]][preve[v]];
			E.flow -= d;
			e[v][E.rev].flow += d;
		}
	}
	return res;
}

int solve()
{
	return min_cost_flow(N * 2, N * 2 + 1, N, N * 2 + 2);
}

int main()
{
	while (init()) {
		cout << solve() << endl;
	}
}




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

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

#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int maxn = 2e3 + 10;
const int oo = 0x7fffffff;

template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m, q;
char st[maxn][maxn];
int s[maxn][maxn], s1[maxn][maxn], s2[maxn][maxn];

int X1, X2, Y1, Y2;
int qsum() { return s[X2][Y2] - s[X1-1][Y2] - s[X2][Y1-1] + s[X1-1][Y1-1]; }
int qsum1() { return s1[X2][Y2] - s1[X1-1][Y2] - s1[X2][Y1] + s1[X1-1][Y1]; }
int qsum2() { return s2[X2][Y2] - s2[X1][Y2] - s2[X2][Y1-1] + s2[X1][Y1-1]; }

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%d%d%d", &n, &m, &q);
    for(int i = 1; i <= n; i++) scanf("%s", st[i] + 1);

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) s[i][j] = s[i][j-1] + (st[i][j] == '1');
        for(int j = 1; j <= m; j++) s[i][j] += s[i-1][j];
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 2; j <= m; j++) s1[i][j] = s1[i][j-1] + (st[i][j] == '1' && st[i][j-1] == '1');
        for(int j = 2; j <= m; j++) s1[i][j] += s1[i-1][j];
    }
    
    for(int j = 1; j <= m; j++) {
        for(int i = 2; i <= n; i++) s2[i][j] = s2[i-1][j] + (st[i][j] == '1' && st[i-1][j] == '1');
        for(int i = 2; i <= n; i++) s2[i][j] += s2[i][j-1];
    }

    while(q--) {
        cin >> X1 >> Y1 >> X2 >> Y2;
        printf("%d\n", qsum() - qsum1() - qsum2());
    }
    return 0;
}


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

int main() {
   int N,K;
   cin >> N >> K;
   long long a[N];
   for (int i=0; i<N; i++) cin >> a[i];
   long long total=1000000000000000;
   for (int tmp=0; tmp<(1<<15); tmp++) {
       bitset<15> s(tmp);
       int k=0;
       long long count=0;
       long long b=a[0];
       for (int i=0; i<N; i++) {
           if (i==0) {
               k++;continue;
           }
           if (s[i]) {
               k++;
               if (b<a[i]) {
                   b=a[i];continue;
               }
               b++;
               count+=(b-a[i]);
           }
           b=max(b,a[i]);
       }
       if (K==k) total=min(total,count);
   }
   cout << total << endl;
}

Measured memory_bytes: 3600
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 * What a trick prob!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n % 1000 == 0){
                out.println(0);
            }
            else{
                out.println(1000 - (n % 1000));
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 33064
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string n;
	cin>>n;
	if(string::npos==n.find("7")){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int h,w;
           cin>>h>>w;
           vst s(h);
           rep(i,0,h)cin>>s[i];
           vst ans(2*h);
           rep(i,0,2*h){
             rep(j,0,w)
            ans[i]+=s[(i)/2][j];
           }
           rep(i,0,2*h)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K; cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];
	SORT(A);
	int ans = 0;
	REP(i, K)ans += A[i];
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3624
A, B, C = map(int, input().split(' '))

M = max(A, B ,C)

# 偶数奇数が同一の場合
if (A + B + C) % 2 == (3 * M) % 2:
    print(int((3 * M - (A + B + C)) / 2))
else:
    print(int((3 * (M + 1) - (A + B + C)) / 2))

Measured memory_bytes: 3060
use std::env;
use std::io::*;
use std::str::*;

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

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let rate = read::<i32>();
    if rate < 1200 {
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A == B && A!=C)
    cout << "Yes";
  
  else if(A == C && A != B)
    cout << "Yes";
  
  else if(B == C && B != A)
    cout << "Yes";
  
  else 
    cout << "No";
}

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

using namespace std;

const int N = 100000 + 77 , Mod = 1000000007;
int n , dp[N][2];
vector < int > a[N];
void dfs(int v , int prev = - 1){
   dp[v][1] = dp[v][0] = 1;
   for(int u : a[v]){
      if(u == prev)
         continue ;
      dfs(u , v);
      dp[v][0] = dp[v][0] * 1ll * dp[u][1] % Mod;
      dp[v][1] = (dp[v][1] * 1ll * (dp[u][0] + dp[u][1])) % Mod;
   }
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int v , u , i = 1;i < n;++ i){
      cin >> v >> u;
      a[v].push_back(u);
      a[u].push_back(v);
   }
   dfs(1);
   cout << (dp[1][0] + dp[1][1]) % Mod;
   return 0;
}


Measured memory_bytes: 13440
#include<cstdio>
#include<cstring>
using namespace std;

char s[200002];
int z[200001];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='A')z[++z[0]]=1;
		else if(i<n&&s[i]=='B'&&s[i+1]=='C')
			z[++z[0]]=2,i++;
		else z[++z[0]]=3;
	long long ans=0;
	for(int i=1;i<=z[0];i++){
		if(z[i]==3)continue;
		int j=i;
		while(j<=z[0]&&z[j]!=3)j++;
		int w=0;
		for(int k=i;k<=j;k++)
			if(z[k]==2)ans+=k-i-w,w++;
		i=j;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == 1 && b == 2){
    cout << 3 << endl;
  }

  if (a == 1 && b == 3){
    cout << 2 << endl;
  }

  if (a == 2 && b == 3){
    cout << 1 << endl;
  }

  if (a == 2 && b == 1){
    cout << 3 << endl;
  }

  if (a == 3 && b == 1){
    cout << 2 << endl;
  }

  if (a == 3 && b == 2){
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll sum[n + 1] = {};
    rep(i, 1, n + 1) sum[i] = sum[i - 1] + i;
    set<int> ans;
    rep(i, 0, n + 1) {
        if (n <= sum[i]) {
            rep(j, 1, i + 1) {
                if (sum[i] - j != n) ans.insert(j);
            }
            break;
        }
    }

    for (auto i : ans) cout << i << endl;
    return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    int n = s.length();
    int p; cin>>p;

    ll dp[111][2][4];
    memset(dp,0,sizeof(dp));

    dp[0][0][0] = 1;

    rep(i,n) {
        const int D = s[i]-'0';
        rep(j,2) {
            rep(k,4) {
                for (int d = 0; d <= (j?9:D); ++d) {
                    int z = 0;
                    if (d!=0) {
                        z = k+1;
                        if (z>3) {
                            continue;
                        }
                    }
                    else {
                        z = k;
                    }
                    dp[i+1][j||(d<D)][z] += dp[i][j][k];
                }
            }
        }
    }

    cout << dp[n][0][p]+dp[n][1][p] << '\n';
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define iter(name) decltype(name)::iterator
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

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

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}



int N;
intvec A;
int res=0;
intpv p;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	sort(all(A));
	int ok=N-1, ng=0;
	while(ok-ng>1) {
		int mid=(ok+ng)/2;
		if(A[mid]>=0) ok=mid;
		else ng=mid;
	}

	for(int i=ok+1; i<N; i++) {
		p.pushb({A[0],A[i]});
		A[0]-=A[i];
	}
	for(int i=ok-1; i>=0; i--) {
		p.pushb({A[ok],A[i]});
		A[ok]-=A[i];
	}

	cout<<A[ok]<<endl;
	for(int i=0; i<N-1; i++) cout<<p[i].fi<<" "<<p[i].se<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 3188
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
 #include <bits/stdc++.h>
 #define mod 1000000007
 #define endl '\n'
 typedef long long int ll;
using namespace std;
vector<ll> a,b;
ll k;
typedef long long int  ll;
bool check(ll n)
{
    ll ans=0;
    for(int i=0;i<b.size();i++){
        if(a[i]*b[i]>n){
            ll val= n/b[i];
            ans+=a[i]-val;
        }
    }
    if(ans>k) return false;
    else return true;
}
int main()
{
    ll n; cin>>n>>k;
    for(int i=0;i<n;i++) {
        ll val; cin>>val;
        a.push_back(val);
    }
    for(int i=0;i<n;i++) {
        ll val; cin>>val;
        b.push_back(val);
    }
    sort(b.begin(),b.end());
    sort(a.rbegin(),a.rend());
    ll start=0; ll end=10000000000000;
    while(true)
    {
        ll mid=(start+end)/2;
        if(check(mid)) end=mid;
        else start=mid;
        if(end-start<=1) break;
    }
    if(check(start)) cout<<start<<endl;
    else cout<<end<<endl;
    
    
}

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

using namespace std;

#ifndef ONLINE_JUDGE
#define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
#define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
__attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
#define pr_debug(...) do { } while(0)
#define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
                                                for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
                                                    if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll n, m; cin >> n >> m;
    if (n == 1 && m == 1) { cout << 1 << endl; exit(0); }
    // corners
    ll s = 1; if (n > 1) s++; if (m > 1) s++; if (n > 1 && m > 1) s++;
    if (s % 2 == 1) { if (n > 1) res += 2; if (m > 1) res += 2; }
    // top row
    ll num = m - 2;
    if (num > 0) {
        s = 1; s += 2; if (n > 1) s += 3;
        if (s % 2 == 1)
        {
            res += num;
            // bottom row
            if (n > 1) res += num;
        }
    }
    // left column
    num = n - 2;
    if (num > 0) {
        s = 1; s += 2; if (m > 1) s += 3;
        if (s % 2 == 1) {
            res += num;
            // right
            if (m > 1) res += num;
        }
    }
    // center
    n -= 2; m -= 2;
    if (n > 0 && m > 0) res += n * m;

    cout << res << endl;

    //    ll res = 0;
    //    ll n, k; cin >> n >> k;
    //    for (ll i = 1; i <= n; i++) {
    //        res += 0;
    //    }
    return 0;
}


Measured memory_bytes: 256
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

import itertools
import bisect
n = int(input())
if n == 1:
    print(0)
    exit()
arr = list(range(1, 50))
arr_sum = list(itertools.accumulate(arr))
ans = 0
for i in factorization(n):
    if i[1] in arr_sum:
        ans += (bisect.bisect_left(arr_sum, i[1])+1)
    else:
        ans += bisect.bisect_left(arr_sum, i[1])
print(ans)

Measured memory_bytes: 63844
n = int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=B[int(A[0])-1]

for i in range(1,n):
    if A[i-1]+1==A[i]:
        ans += B[int(A[i])-1]+C[int(A[i-1])-1]
    else:
        ans += B[int(A[i])-1]
       
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
int main(){
	string S, T;
	cin >> S >> T;
	ll ans = 0;
	REP(i, 3){
		if(S.substr(i,1) == T.substr(i,1)){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  rep(i, N) {
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four" ;
      break;
    }
    if (i + 1 == N){
      cout << "Three";
    }
      
  }
}

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

using namespace std;

//Data types macros
typedef long long  ll;
typedef vector<int> vec;
typedef unsigned long long ull;
typedef unsigned int ui;

//loop macros
#define f(i,s,e) for(long long i=s;i<e;i++)
#define fe(i,s,e)  for(long long i=s;i<=e;i++)
#define fr(i,s,e) for(long long i=e;i>s;i--)
#define fre(i,s,e) for(long long i=e;i>=s;i--)

//Input macros
#define get1(n) cin>>n;
#define get2(n,m) cin>>n>>m;
#define get3(t,n,m) cin>>t>>n>>m;
#define wez(n) ll (n); cin>>(n);
#define wez2(n,m) ll (n),(m); cin>>(n)>>(m);
#define wez3(n,m,k) ll (n),(m),(k); cin>>(t)>>(n)>>(m);

//Action macro
#define allv(c) (c).begin(),(c).end()
#define setmax(a,b) (a)=max((a),(b))
#define setmin(a,b) (a)=min((a),(b))
#define pb push_back

//Specific values macros
#define min -
#define mod 100000000
#define max 1e9

//output macros
#define outa(a,s,e) f(i,s,e) cout << a[i] << (i==e-1?'\n':' ')
#define oute(n) cout<<n<<"\n"
#define outc(n) cout<<n<<" "
#define out2e(n,m) cout<<n<<" "<<m<<"\n"
#define out3e(n,m,o) cout<<n<<" "<<m<<" "<<o<<"\n"

//your work

//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,l;
    cin>>n>>l;
    ll a[n],sum=0,psum=0,tmp,val,diff=1e9;
    for(int i=0;i<n;i++){
        a[i]=l+i;
        sum+=a[i];
    }
    if(sum<0)psum=-sum;
    else psum=sum;

    for(int i=0;i<n;i++){
       tmp=psum;
       if(a[i]>0)tmp=tmp-a[i];
       else tmp=tmp+a[i];
       if(psum-tmp==0){
        val=a[i];
        break;
       }else if(psum-tmp<diff){
        diff=psum-tmp;
        val=a[i];
       }
    }
    cout<<sum-val<<endl;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(u==s) a--;
  if(u==t) b--;
  cout<<a<<' '<<b;
  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, A, B;
long long t[1005];

int main(){
	cin >> N >> A >> B;
	for(int i = 0; i < N; i++){
		cin >> t[i];
	}
	long long ans = N;

	for(int i = 0; i < N; i++){
		if(A <= t[i] && t[i] < B){
			ans--;
		}
	}
	cout << ans << endl;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int L,R,d;
    cin >> L >> R >> d;
    int cnt = 0;
    FOR(i,L,R+1) if(i%d == 0) cnt++;
    cout << cnt << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3632
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias TV = Tuple!(int, "t", int, "v");

int[200*100*2+2] GP;

void main()
{
    auto N = readln.chomp.to!int;
    auto ts = readln.split.to!(int[]).map!"a * 2".array;
    auto vs = readln.split.to!(int[]).map!"a * 2".array;

    foreach (i; 0..N-1) ts[i+1] += ts[i];

    foreach (ref gp; GP) gp = int.max;

    int i = 1;
    foreach (j, t; ts) {
        --i;
        while (i <= t) {
            GP[i] = min(GP[i], vs[j]);
            ++i;
        }
    }

    foreach (j, t; ts) {
        auto x = j == N-1 ? 1 : vs[j+1]+1;
        foreach_reverse (k; 0..t) {
            if (GP[k] <= x) break;
            GP[k] = x++;
        }
    }

    i = 0;
    double r = 0;
    foreach (j; 0..ts[$-1]) {
        i = min(GP[j], i);
        r += i++;
    }

    writefln("%.12f", r / 4.0);
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  ll ans = inf;
  for (ll i = 1; i < n; i++) {
    ll a = i, b = n - i;
    string s = to_string(a), t = to_string(b);
    ll sum = 0;
    for (ll j = 0; j < s.size(); j++) {
      sum += s[j] - '0';
    }
    for (ll j = 0; j < t.size(); j++) {
      sum += t[j] - '0';
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
'''
1 ~ N の倍数の箱を見ていくがN ~ 1の順で決めていく
'''
ans = [-1 for i in range(N)]
opt = []
for i in range(N,0,-1):
    p = N // i
    if p >= 2 :
        m = 0
        for x in range(2,p+1,1):
            m += ans[x*i-1]
        m = m % 2
        if m == A[i-1]:
            ans[i-1] = 0
        else :
            ans[i-1] = 1
            opt.append(i)
    else :
        if A[i-1] == 0 :
            ans[i-1] = 0
        else:
            ans[i-1] = 1
            opt.append(i)
print(sum(ans))
print(*opt)

Measured memory_bytes: 14120
s = gets.chomp.split('')
odd = []
even = []
s.count.times do |i|
  if (i % 2) === 0
    odd << s[i]
  else
    even << s[i]
  end
end

unless odd.include?("L") || even.include?("R")
  puts 'Yes'
else
  puts 'No'
end

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  int res = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    if(v[i] > c[i]){
      res += v[i] - c[i];
    }
  }

  cout << res << endl;

}


Measured memory_bytes: 256
N, W = map(int, input().split())
w = []
for i in range(N):
    w.append(int(input()))
w.sort()
summ = 0
ans = 0
for num, wi in enumerate(w):
    if num == N - 1:
        if sum(w) - w[-1] <= W and W - sum(w) - w[-1] < w[-1]:
            ans += 1
        break
    dp = [[0] * (W + 1) for i in range(N - num)]
    dp[0][0] = 1
    for n in range(N - num - 1):
        dpn1 = dp[n + 1]
        dpn = dp[n]
        for k in range(W + 1):
            if k - w[num + n + 1] >= 0:
                dpn1[k] = dpn[k] + dpn[k - w[num + n + 1]]
            else:
                dpn1[k] = dpn[k]
    for i in range(max(W - summ - wi + 1,0), W - summ + 1):
        ans += dp[-1][i]
        ans %= 10 ** 9 + 7
    summ += wi
    if W < summ:
        break
print(ans%(10**9+7))


Measured memory_bytes: 52448