akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

static ll dp[200010];
static vector<int> numwhere[200010];
static int c[200010];
int n;



ll search(int x){
	if(x==n-1){
		dp[x]=1;
		return 1;
	}
	if(dp[x]!=0) return dp[x];

	ll ret;
	int temp;
	int ng,ok;

	ng=numwhere[c[x]].size();
	ok=0;

	while(ng-ok>1){
		temp=(ok+ng)/2;
		if(numwhere[c[x]][temp]<=x){
			ok=temp;
		}else{
			ng=temp;
		}
	}

	if(numwhere[c[x]].size()>ok+1){
		ret=(search(x+1)+search(numwhere[c[x]][ok+1]))%MOD;
	}else{
		ret=search(x+1);
	}

	dp[x]=ret;

	return ret;
}

int main(void)
{
	//変数の宣言
//	int n;
//	static int c[200010];
//	static vector<int> numwhere[200010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;
	int r;
	


	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&c[i]);
//		scanf_s("%d",&c[i]);
	}
	
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	temp=0;
	for(i=1;i<n;i++){
		if(c[i-1]!=c[i]){
			c[i-temp]=c[i];
		}else{
			temp++;
		}
	}

	n=n-temp;

	for(i=0;i<n;i++){
		numwhere[c[i]].push_back(i);
	}

	search(0);

	//	printf("計算部分終了\n");

	//出力

/*	for(i=0;i<n;i++){
		printf("dp[%d]=%lld\n",i,dp[i]);
	}*/

	printf("%lld",dp[0]);


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 19712
#include<cstdio>
#include<stdlib.h>
#include<iostream>

using namespace std;

const int maxn = 105;
int M[maxn][maxn];
int d[maxn];
int p[maxn];
bool visit[maxn];

int main(){
	int n;
	int u,k,v,c;
	cin >> n;
	for(int i = 0;i < n;i++){
		visit[i] = false;
		d[i] = 0x3f3f3f;
		for(int j = 0;j < n;j++){
			M[i][j] = -1;
		}
	}
	
	for(int i = 0;i < n;i++){
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	
	d[0] = 0;
	int result = 0;
	while(true){
		int u;
		int min_distance = 0x3f3f3f;
		for(int i = 0;i < n;i++){
			if(visit[i])continue;
			if(d[i] < min_distance){
				min_distance = d[i];
				u = i;
			}
		}
		if(min_distance == 0x3f3f3f)break;
		visit[u] = true;
		result += min_distance;
		for(int i = 0;i < n;i++){
			if(visit[i])continue;
			if(M[u][i] == -1)continue;
			if(d[u] + M[u][i] < d[i]){
				d[i] = d[u] + M[u][i];
				p[i] = u;
			}
		}
	}
	for(int i = 0;i < n;i++)cout << i << " " << d[i] << endl;
//	cout << result << endl;
	
}


Measured memory_bytes: 3120
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
        //console.log('%s',input);
	input = input.split("\n");
	tmp = input[1].split(" ");
	var max = 0;
	var min = 1000;
	for(var i=0;i < tmp.length ;i++){
		var a = parseInt(tmp[i], 10);
		if(a > max)max = a;
		if(a < min)min = a;
	}
	//出力
	console.log('%d',max-min);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;



int main(){
    int n,q;
    string s;
    cin>>n>>q>>s;
    vector<int>l(q),r(q),a(n+1);
    a[0]=0;a[1]=0;
    for(int i=2; i<=n; i++){
        if(s.substr(i-2,2)=="AC")a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    for(int i=0; i<q; i++)cin>>l[i]>>r[i];
    for(int i=0; i<q; i++){
        if(l[i]>1&&s[l[i]-2]=='A'&&s[l[i]-1]=='C')cout<<a[r[i]]-a[l[i]-1]-1<<endl;
        else cout<<a[r[i]]-a[l[i]-1]<<endl;
    }
    //for(int i=0; i<n+1; i++)cout<<a[i];
    return 0;
}

Measured memory_bytes: 2176
hoge = list(map(int,input().split()))
X, Y, A, B, C = hoge[0], hoge[1], hoge[2], hoge[3], hoge[4]
r_apple = sorted(list(map(int,input().split())),reverse=True)
g_apple = sorted(list(map(int,input().split())),reverse=True)
b_apple = sorted(list(map(int,input().split())),reverse=True)

eat_list = []
for i in range(X):
  eat_list.append(r_apple[i])
for i in range(Y):
  eat_list.append(g_apple[i])

sort_eat_list = sorted(eat_list)

for i in range(len(sort_eat_list)):
  if sort_eat_list[i] < b_apple[0]:
    sort_eat_list[i] = b_apple.pop(0)
    if len(b_apple) == 0:
      break

print(sum(sort_eat_list))

Measured memory_bytes: 23200
n, y = gets.split.map(&:to_i)
0.upto(n) do |i|
    0.upto(n - i) do |j|
        if i * 10000 + 5000 * j + 1000 * (n - i - j) == y
            puts "#{i} #{j} #{n - i - j}"
            exit
        end
    end
end
puts "-1 -1 -1"

Measured memory_bytes: 3836
/*
ID: siva.ja1
TASK: (insert task name)
LANG: C++
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string n;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	reverse(n.begin(), n.end());
	if(n[0] == '3') cout << "bon\n";
	else if(n[0] == '0' || n[0] == '1' || n[0] == '6' || n[0] == '8') cout << "pon\n"; 
	else cout << "hon\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF (1LL<<60)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[5005];
ll a2[5005];
vector<int> G[5005];
vector<int> G2[5005];
int cmp[5005];
ll dp[5005][5005][2];
int sz[5005];
int cnt2[5005];

void dfs(int v,int c){
    cmp[v]=c;
    if(a[v]<0LL)return;
    for(int i=0;i<G[v].size();i++){
        int nv=G[v][i];
        if(a[nv]>0LL && cmp[nv]==-1){
            dfs(nv,c);
        }
    }
}

int dfs2(int v,int p){
    sz[v]=1;
    for(int i=0;i<G[v].size();i++){
        int nv=G[v][i];
        if(nv!=p){
            sz[v]+=dfs2(nv,v);
        }
    }
    return sz[v];
}

ll tmp[5005][2];

void dfs3(int v,int p){
    int szc=1;
    if(a[v]<0LL)dp[v][0][1]=a[v];
    else dp[v][0][0]=a[v];
    cnt2[v]++;
    assert(cnt2[v]==1);
    for(int i=0;i<G[v].size();i++){
        int nv=G[v][i];
        if(nv==p)continue;
        dfs3(nv,v);
        for(int j=0;j<=szc+sz[nv];j++){
            tmp[j][0]=INF;
            tmp[j][1]=INF;
        }
        for(int j=0;j<szc;j++){
            for(int k=0;k<sz[nv];k++){
                tmp[j+k][0]=min(tmp[j+k][0],dp[v][j][0]+dp[nv][k][0]);
                tmp[j+k][1]=min(tmp[j+k][1],dp[v][j][1]+dp[nv][k][0]);
                tmp[j+k][1]=min(tmp[j+k][1],dp[v][j][0]+dp[nv][k][1]);
                tmp[j+k][1]=min(tmp[j+k][1],dp[v][j][1]+dp[nv][k][1]);
                if(dp[nv][k][1]<0LL || dp[nv][k][0]!=INF)tmp[j+k+1][1]=min(tmp[j+k+1][1],dp[v][j][1]);
                if(dp[nv][k][1]<0LL || dp[nv][k][0]!=INF)tmp[j+k+1][0]=min(tmp[j+k+1][0],dp[v][j][0]);
            }
        }
        for(int j=0;j<=szc+sz[nv];j++){
            dp[v][j][0]=tmp[j][0];
            dp[v][j][1]=tmp[j][1];
        }
        szc+=sz[nv];
    }
    /*
    printf("%d\n",v);
    for(int i=0;i<=szc;i++){
        printf("%lld %lld\n",dp[v][i][0],dp[v][i][1]);
    }
     */
}

int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(cmp,-1,sizeof(cmp));
    int sz=0;
    for(int i=0;i<n;i++){
        if(cmp[i]==-1){
            dfs(i,sz++);
        }
        //printf("%d ",cmp[i]);
    }
    //printf("\n");
    for(int i=0;i<n;i++){
        a2[cmp[i]]+=a[i];
        for(int j=0;j<G[i].size();j++){
            int nv=cmp[G[i][j]];
            if(nv!=cmp[i]){
                G2[cmp[i]].push_back(nv);
                G2[nv].push_back(cmp[i]);
            }
        }
    }
    for(int i=0;i<sz;i++){
        sort(G2[i].begin(),G2[i].end());
        G2[i].erase(unique(G2[i].begin(),G2[i].end()),G2[i].end());
    }
    dfs2(0,-1);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k]=1LL<<60;
            }
        }
    }
    dfs3(0,-1);
    int ans=n-1;
    for(int i=0;i<n;i++){
        if(dp[0][i][0]<0LL || dp[0][i][1]<0LL)ans=min(ans,i);
        if(dp[0][i][0]!=INF)ans=min(ans,i);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 392576
import numpy as np
import numpy.linalg as linalg 

X, Y = map(int, input().split())

if Y%2 == 1:
  print('No')
else:
  A = np.array([[1, 1],
                [2, 4]])
  A_inv = linalg.inv(A)

  B = np.array([X , Y])

  C = np.dot(A_inv, B)
  if C[0] >= 0 and C[1] >= 0 :
    print('Yes')
  else:
    print('No')



Measured memory_bytes: 27512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin >> s;

    const int slen = s.length();
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < slen; i++)
    {
        if (s[i] == '0') cnt1++;
        else cnt2++;
    }

    cout << min(cnt1, cnt2)*2 << endl;
    return 0;
}

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

// IGNORE THE #pragma, just to suppress annoying warnings on IDE

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wuninitialized"
using namespace std;


typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int dcmp(double x, double y)
{ return fabs(x - y) <= eps ? 0 : x < y ? -1 : 1; }

int valid(ll n, vector<int> const &a)
{
    rep(i,0,sz(a))
    {
        if (n < 2)
            return -1;
        n = n - n%a[i];
    }
    if (n == 2)
        return 0;
    return 1;
}

ll bsMin(ll st, ll end, vector<int> const &a)
{
    while (st < end)
    {
        ll mid = st + (end - st) / 2;
        if (valid(mid, a) == 0)
            end = mid;
        else if (valid(mid, a) == 1)
            end = mid - 1;
        else if (valid(mid, a) == -1)
            st = mid + 1;
    }
    return st;
}

ll bsMax(ll st, ll end, vector<int> const &a)
{
    while (st < end)
    {
        ll mid = st + (end - st + 1) / 2;
        if (valid(mid, a) == 0)
            st = mid;
        else if (valid(mid, a) == 1)
            end = mid - 1;
        else if (valid(mid, a) == -1)
            st = mid + 1;
    }
    return st;
}

int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
    int k;
    cin >> k;
    vector<int> a(k);
    rep(i, 0, k)
    {
        cin >> a[i];
    }
    ll st = 0, end = 1e18;
    ll nMin = bsMin(st, end, a);
    ll nMax = bsMax(st, end, a);
    if (valid(nMin, a) == 0 && valid(nMax, a) == 0)
        cout << nMin << " " << nMax << endl;
    else
        cout << -1 << endl;
    return 0;
}

#pragma clang diagnostic pop

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str,ans=")]";
    while(getline(cin,str)&&str!="."){
        stack<int> sta;
        for(int i=0;i<str.size();i++){
            if(str[i]=='(')sta.push(0);
            if(str[i]=='[')sta.push(1);
            if((str[i]==')'||str[i]==']')&&!sta.empty()&&str[i]==ans[sta.top()])sta.pop();
            else if(str[i]==')'||str[i]==']'){
                sta.push(0);
                break;
            }
        }
        if(sta.empty())cout<<"yes\n";
        else cout<<"no\n";
    }
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <stack>
#define int long long
using namespace std;
int limit = 10e10+5;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,h;
    cin >> h >> n;
    vector<pair<int,int>>p;
    vector<int>d(h+5,limit);
    for(int i= 0;i < n;++i){
        int t,t1;
        cin >> t >> t1;
        p.push_back(make_pair(t,t1));
    }
    d[0]=0;
    for(int i = 0; i <= h;i++){
        if(d[i]!=limit){
            for(int j = 0; j < n; j++){
                d[min(i+p[j].first,h)]=min(d[i]+p[j].second,d[min(i+p[j].first,h)]);
            }
        }
    }
    cout << d[h] << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

const long long MOD = 1000000007;
long long finv[200001], inv[200001];

void COMinit() {
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= 200001; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long modpow(long long a, long long n) {
  long long res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  COMinit();
  long long n, a, b;
  cin >> n >> a >> b;
  long long func[200001];
  long long ans = modpow(2, n) - 1;
  long long M = max(a, b);
  func[0] = 1;
  rep(i, M) {
    func[i+1] = func[i] * (n-i) % MOD;
  }

  ans -= func[a] * finv[a] % MOD;
  if(ans < 0) ans += MOD;

  ans -= func[b] * finv[b] % MOD;
  if(ans < 0) ans += MOD;

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

Measured memory_bytes: 8284
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	char n;
	cin>>n;
	if(n<95){
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3564
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,1,10){
        rep(j,1,10){
            if(i*j == N){
                print("Yes");
                return 0;
            }
        }
    }
    print("No");
    

}

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

string S; int N, K;
int dp[2][300][300];

int main() {
  cin >> S >> K; int N = S.size();
  for(int k = 0; k <= K; ++k) {
    int cur = k % 2, prev = (k + 1) % 2;
    for(int i = 1; i <= N - 1; ++i) for(int j = 1; j <= N - i; ++j) {
      if(S[i - 1] == S[N - j]) {
        dp[cur][i][j] = dp[cur][i - 1][j - 1] + 1;
      } else {
        dp[cur][i][j] = max(dp[cur][i][j - 1], dp[cur][i - 1][j]);
        if(k > 0) dp[cur][i][j] = max(dp[cur][i][j], dp[prev][i - 1][j - 1] + 1);
      }
    }
  }
  int res = 0;
  for(int i = 0; i < N; ++i) res = max(res, 2 * dp[K % 2][i][N - 1 - i] + 1);
  for(int i = 0; i < N; ++i) res = max(res, 2 * dp[K % 2][i][N - i]);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S_1 = sc.next();
        String S_2 = sc.next();
        String S_3 = sc.next();
        System.out.println(String.valueOf(S_1.charAt(0)).toUpperCase()
                + String.valueOf(S_2.charAt(0)).toUpperCase()
                + String.valueOf(S_3.charAt(0)).toUpperCase() );

    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A00 = A[:]

A0 = []
A1 = []

F = [0,0,0]
for i in range(n):
    if A[i] > 0:
        F[0] += 1
        A0.append(A[i])
    elif A[i] == 0:
        F[1] += 1
    else:
        F[2] += 1
        A1.append(A[i])
G = [F[2]*(F[2]-1)//2 + F[0]*(F[0]-1)//2,
 (F[0]+F[2]) * F[1] + F[1]*(F[1]-1)//2,
  F[2] * F[0]]
# print("G",G)
g = 2
if G[2] < k and G[2]+G[1] >= k:
    k -= G[2]
    g = 1
if G[2]+G[1] < k:
    k -= G[2]+G[1]
    g = 0
if g==2:
    k = n*(n-1)//2 + 1 - k  # 上からk番目
    k -= G[0]+G[1]  # 負になるペアの中で上からk番目
    
k -= 1 # これで「それより絶対値が下の数がk個」になる
# print("k",k)

# print("g",g)

if g==1:
    print(0)
elif g==0:
    A = A0[:]
    B = [-i for i in A1]
    B.sort()
    le = -1
    ri = 10**18+2
    m = (le+ri) // 2
    while ri-le > 1:
        ans = 0
        if len(A) > 0:
            j0 = len(A)-1
            for i in range(len(A)):
                while j0 > i and A[i]*A[j0] >= m:
                    j0 -= 1
                ans += j0-i
                j0 = max(i+1,j0)
        if len(B) > 0:
            j1 = len(B)-1
            for i in range(len(B)):
                while j1 > i and B[i]*B[j1] >= m:
                    j1 -= 1
                ans += j1-i
                j1 = max(i+1,j1)
        # print(le,ri,m,ans) # ansはm未満の数の個数
        if ans > k:
            ri = m
        else:
            le = m
        m = (le+ri)//2
    print(le)
else:
    # print("k",k)
    A = A0[:]
    B = [-i for i in A1]
    B.sort()
    # print(A,B)

    le = -1
    ri = 10**18+2
    m = (le+ri) // 2
    while ri-le > 1:
        ans = 0
        if len(A) > 0:
            j0 = len(B)-1
            for i in range(len(A)):
                # print("seki",A[i]*B[j0])
                while j0 >= 0 and A[i]*B[j0] >= m:
                    
                    j0 -= 1
                ans += j0+1
                # print("plus",j0)
        # print(le,ri,m,ans) # ansはm未満の数の個数
        if ans > k:
            ri = m
        else:
            le = m
        m = (le+ri)//2
    print(-le)



# CC = []
# A = A00[:]
# for i in range(n):
#     for j in range(i+1,n):
#         CC.append(A[i]*A[j])
# CC.sort()
# print("lenCC", len(CC))
# print(CC)
# print(CC[400:420])

Measured memory_bytes: 92116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  int si,sj;
  vector<vector<char>> A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A.at(i).at(j);
      if(A.at(i).at(j)=='S'){
        si=i;
        sj=j;
      }
    }
  }

  vector<vector<int>> dist(H,vector<int>(W,-1));
  dist.at(si).at(sj)=0;
  queue<pair<int,int>> q;
  q.push(make_pair(si,sj));
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    q.pop();
    for(int k=0;k<4;k++){
      int ni=i+dx[k];
      int nj=j+dy[k];
      if(ni<0||nj<0||ni>=H||nj>=W){
        continue;
      }
      if(A.at(ni).at(nj)=='#'){
        continue;
      }
      if(dist.at(ni).at(nj)==-1){
        dist.at(ni).at(nj)=dist.at(i).at(j)+1;
        q.push(make_pair(ni,nj));
      }
    }
  }

  int ans=10000;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(dist.at(i).at(j)==-1){
        continue;
      }
      if(dist.at(i).at(j)>K){
        continue;
      }
      int sub=1;
      if(i==0||j==0||i==H-1||j==W-1){
        ans=min(ans,sub);
        continue;
      }
      sub+=(min(i,min(j,min(H-1-i,W-1-j)))-1)/K+1;
      ans=min(ans,sub);
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

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

int main() {
  int N;
  
  cin >> N;
  
  if (N == 2) {
    long long in1, in2;
    
    cin >> in1 >> in2;
    
    cout << max(in1, in2) << endl;
    return 0;
  }
  
  vector<ll> a;
  // L_n = gcd(a[0], ... , a[n - 1]), R_n = gcd(a[N - 1], ... , a[n + 1]);
  vector<ll> L(N, 0), R(N, 0);
  
  for (int i = 0; i < N; i++) {
    int in1;
    
    cin >> in1;
    
    a.push_back(in1);
  }
  
  L[0]     = 0;
  R[N - 1] = 0;
  
  for (int i = 1; i < N; i++) {
    L[i] = gcd(L[i - 1], a[i - 1]);
  }
  
  for (int i = N - 2; i >= 0; i--) {
    R[i] = gcd(R[i + 1], a[i + 1]);
  }
  
  ll _gcd = 0;
  
  for (int i = 0; i < N; i++) {
  	_gcd = max(_gcd, gcd(L[i], R[i]));
  }
  
  cout << _gcd << endl;
  
  return 0;
}

Measured memory_bytes: 2936
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

void print_vec(vector<int> A, int n) {
	Rep(i, n) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	Rep(i, n) cin >> A[i];
	vector<int> B = A;
	if(prev_permutation(All(B))) print_vec(B, n);
	print_vec(A, n);
	B = A;
	if(Next_permutation(B)) print_vec(B, n);
	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(s,n) for(int i=s;i<n;i++)
#define inf 10000000000 //1e10
#define M 1000000007
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int n,m;
char tab[1010][1010];
bool vis[1010][1010][2];
int gx[] = {0,1};
int gy[] = {1,0};
int rx[] = {0,-1};
int ry[] = {-1,0};
void dfs(int i,int j,vector<pair<int,int> > &s,bool d){
    if(vis[i][j][d] || tab[i][j]!='.'){return;}
    vis[i][j][d]=true;
    for(int k=0;k<2;k++)
        dfs(i+gx[k],j+gy[k],s,k);
    if(!vis[i][j][(d+1)%2])
    s.pb(mp(i,j));
}
int solve(){
    vector<pair<int,int> > tsorted;
    dfs(1,1,tsorted,0);
    reverse(tsorted.begin(),tsorted.end());
    int dp[1010][1010];
    memset(dp,0,sizeof dp);
    dp[1][1]=1;
    for(int i=1;i<tsorted.size();i++){
        int x = tsorted[i].ff;
        int y = tsorted[i].ss;
        if(vis[x][y][0])
            dp[x][y]= (dp[x][y]+dp[x+rx[0]][y+ry[0]])%M;
        if(vis[x][y][1])
            dp[x][y]= (dp[x][y]+dp[x+rx[1]][y+ry[1]])%M;
    }
    
    return dp[n][m];
}

int32_t main(){
    fastio;
    memset(tab,'#',sizeof tab);
    memset(vis,0,sizeof(vis));
    cin >> n >> m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin >> tab[i][j];
    cout << solve() << endl;

}

Measured memory_bytes: 27492
<?php
fscanf(STDIN, "%d", $N);

$prime = eratosthenes5(1000000);
if($N === 1){
    echo 0;
    exit;
}
foreach($prime as $i){
    while($N%$i === 0){
        $N/=$i;
        if(!isset($list[$i])){
            $list[$i]=1;
        }else{
            $list[$i]++;
        }
    }
    if($N===1){
        break;
    }
}
if($N > 1){
    $list[$N] = 1;
}
$ans = 0;
foreach($list as $key=>$value){
    $i = 1;
    while(true){
        if($value>=$i){
            $value -= $i;
            $i++;
            $ans++;
        }else{
            break;
        }
    }
}
echo $ans;
function eratosthenes5($max) {

    // maxの平方根
    $sqrt = floor(sqrt($max));

    // keyで配列を一気に作る
    $lists = array_fill(2, $max-1, true);

    // もっと単純に倍数を取り除くだけ
    for ($i=2; $i<=$sqrt; $i++) {
        if (isset($lists[$i])) {
            for ($j=$i*2; $j<=$max; $j+=$i) {
                unset($lists[$j]);
            }
        }
    }

    return array_keys($lists);
}

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

int a[100100], dp[100100];
const int mx = 1e9 + 1000;

int min(int a, int b){
    return (a < b ? a : b);
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    for(int i = 0; i < n; i++) dp[i] = mx;
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = i - 1; j >= i - k && j >= 0; j--){
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
string  N;
int main(){
  cin >> N;
  
  if (N.at(0)  >= N.at(1) && N.at(0)  >= N.at(2)){
    cout << N.at(0)  << N.at(0)  << N.at(0)  << endl;
    return 0;
  }
  if (N.at(0)  < N.at(1)){
    N.at(0)++;
    cout << N.at(0)  << N.at(0)  << N.at(0)  << endl;
    return 0;
  }
  if (N.at(0)  >= N.at(1) && N.at(0)  < N.at(2)){
    N.at(0)++;
    cout << N.at(0)  << N.at(0)  << N.at(0)  << endl;
    return 0;
  }
  return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#define LL long long
#define Int register int
using namespace std;
LL aa[55], bb[55], cc[55], dd[55];
LL Ans, AA[15];
LL n, m, q;
void Dfs(LL x,LL F)
{
	if (x == n + 1)
	{
		LL Summ = 0;
		for (Int i = 1; i <= q; ++ i)
			if (AA[bb[i]] - AA[aa[i]] == cc[i])
				Summ += dd[i];
		if (Summ > Ans)
			Ans = Summ;
		return ;
	}
	for (Int i = F; i <= m; ++ i)
	{
		AA[x] = i;
		Dfs(x + 1, i);
	}
}
int main()
{
	scanf("%lld %lld %lld", &n, &m, &q);
	for (Int i = 1; i <= q; ++ i)
		scanf("%lld %lld %lld %lld", &aa[i], &bb[i], &cc[i], &dd[i]);
	Dfs(1, 1);
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

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

using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep (i, n) cin >> p[i];
  rep (i, n) cin >> q[i];

  vector<int> v(n);
  iota(v.begin(), v.end(), 1);

  int index = 0, p_index, q_index;
  do {
    if (p == v) p_index = index;
    if (q == v) q_index = index;
    ++index;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(p_index - q_index) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b,d,r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = ((double)a)  / ((double)b);
	printf("%d %d %.5lf\n", d, r, f);
	return 0;
}


Measured memory_bytes: 2748
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
  int A, B, K;
  cin >> A >> B >> K;

  int p = 1;
  for( int i=min(A,B);i>0; i-- )
    {
      if( A%i==0 && B%i==0 )
	{
	  if( p == K )
	    {
	      cout << i << endl;
	      break;
	    }
	  else
	    p++;
	}
    }
  return 0;
}


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

#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));

int main(){
	int n;
	while(cin >> n){
		string s;
		cin >>s;
		int k;
		cin>>k;
		for(int i=0;i<n;i++){
			if(s[i]!=s[k-1]){
				s[i]='*';
			}
		}
		cout<<s<<endl;
	}

}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int N=sc.nextInt();
        if(N==1)out.println("Hello World");
        if(N==2)out.println(sc.nextInt()+sc.nextInt());
    }
}

Measured memory_bytes: 23252
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const LL MOD = 1e9 + 7;

const int K = 1e5;
const int N = 100;
LL dp[N + 5][K + 5];
LL pref[K + 5];
LL npref[K + 5];

void hora(int tc) {
	int n,k;
	cin>>n>>k;
	dp[0][0] = 1;
	for(int i = 0;i <= k;i++) pref[i] = 1;
	for(int i = 1;i <= n;i++) {
		int x;
		cin>>x;
		for(int j = 0;j <= k;j++) {
			dp[i][j] = pref[j];
			if(j - x > 0) dp[i][j] = (dp[i][j] + MOD - pref[j - x - 1]) % MOD;
			npref[j] = dp[i][j];
			if(j != 0) npref[j] = (npref[j] + npref[j - 1]) % MOD;
		}
		for(int j = 0;j <= k;j++) pref[j] = npref[j];
	}
	cout<<dp[n][k]<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 81664
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> P(n);
  vector<unsigned short> F(n);
  REP(i,n){
    int f = 0; //(5,2),(5,1),(4,2) ... (1,2),(1,1)　bit flags
    REP(j,10){
      int in;
      cin >> in;
      if(in == 1){
	f += 1 << (9-j);
      }
    }
    F[i] = (unsigned short)f;
  }

  REP(i,n){
    REP(j,11){
      int in;
      cin >> in;
      P[i].push_back(in);
    }
  }

  
  int ans = INT_MIN;
  for(unsigned short i = 1; i < 1024;i++){//joisinoの開店パターンのビット
    int score = 0;
    REP(j,n){//他店の開店パターンのビット=>F[i]
      int result = 0;
      unsigned short ands = i & F[j];
      REP(k,10){
	result += ands % 2;
	ands /= 2;
      }
      score += P[j][result];
      DUMP(P[j][result]);
      DUMP(score);
    }
    ans = max(ans,score);
  }
  cout << ans << endl;
  return 0;
}



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

ll f(ll n) {
    ll ans = 0;
    ll p;
    n /= 2;
    while (n >= 5) {
        p = n / 5;
        ans += p;
        n = p;
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << f(n) << endl;
}


Measured memory_bytes: 256
def init_state():
    return 0, 0, 0


def main():
    n = int(input())

    point, hit, out = init_state()

    while True:
        if n == 0:
            break

        event = input()

        if event == 'HIT':
            if hit >= 3:
                point += 1
            else:
                hit += 1
        elif event == 'OUT':
            out += 1
        elif event == 'HOMERUN':
            point += hit + 1
            hit = 0

        if out == 3:
            print(point)
            point, hit, out = init_state()
            n -= 1


if __name__ == '__main__':
    main()

Measured memory_bytes: 7660
// ALPC-B.cpp

#include <iostream>
#include <atcoder/fenwicktree.hpp>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
int main()
{
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    ll a;
    rep(i, n) {
        cin >> a;
        fw.add(i, a); // fwに値をセット
    }
    ll q0, q1, q2;
    rep(i, q) {
        cin >> q0 >> q1 >> q2;
        if (q0 == 0) {
            fw.add(q1, q2); // fwの値を更新
        }
        if (q0 == 1) {
            cout << fw.sum(q1, q2) << endl; // fwで区間和を求める
        }
    }
}


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

int main(){
	const int n = 4280;
	int w;
	while( cin >> w , ~w ){
		int sum = 1150;
		if( w <= 10 ){
		}else if( w <= 20 ){
			sum += (w-10)*125;
		}else if( w <= 30 ){
			sum += 1250 + (w-20)*140;
		}else{
			sum += 1250 + 1400 + (w-30)*160;
		}
		cout << n - sum << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    ll K, ans = 0;
    cin >> S >> K;
    vector<ll> alpha;

    ll cnt = 1;
    repd(i, 1, S.size()) {
        if (S[i] == S[i - 1]) cnt++;
        else {
            alpha.push_back(cnt);
            cnt = 1;
        }
    }
    if (cnt) alpha.push_back(cnt);

    rep(i, alpha.size()) {
        ans += alpha[i] / 2;
    }

    ans *= K;
    int len = (int)alpha.size() - 1;
    if (alpha[0] % 2 == 1 && alpha[len] % 2 == 1 && S[0] == S[(int)S.size() - 1]) {
        ans += K - 1;
    }

    if (len == 0) ans = (alpha[len] * K) / 2;

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

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n : usize,
        m : usize,
        a : [i64; m],
    }
    let mut avail = n as i64;
    for (_i, v) in a.iter().enumerate() {
        avail -= v;
    }
    avail = std::cmp::max(avail, -1);

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


Measured memory_bytes: 2252
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int n = in.size();
    
    rep(i, n){
        if(i % 2 == 0){
            cout << in[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

#define MAX 300005

struct BIT{
	int bit[MAX];
	void init(){
		memset(bit, 0, sizeof(bit));
	}
	void add(int i,int x){
		i++;
		while(i<MAX){
			bit[i]+=x;
			i+=i&-i;
		}
		
	}
	int get(int i){
		i++;
		int ret=0;
		while(i>0){
			ret+=bit[i];
			i-=i&-i;
		}
		return ret;
	}
};

BIT bit;
int n,m;

signed main(){
	cin>>n>>m;
	vector<int> kaz[MAX];
	for(int i=0; i<n; i++){
		int a,b; cin>>a>>b;
		b++;
		kaz[b-a].push_back(a);
	}
	int kazuto=n;
	for(int i=1; i<=m; i++){
		int ans=kazuto;
		for(int j=i; j<=m; j+=i){
			ans+=bit.get(j);
		}	
		kazuto-=kaz[i].size();
		for(int j=0; j<kaz[i].size(); j++){
			int l=kaz[i][j];
			int r=l+i;
			bit.add(l, 1);
			bit.add(r, -1);
		}
		printf("%lld\n",ans);
	}
}



Measured memory_bytes: 13056
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int n[4];

void dfs(int i, int j, string op) {
    if (i == 4 && j == 7) {
        op += "=";
        rep(i, 0, 4) cout << n[i] << op[i];
        cout << "7" << endl;
        exit(0);
    }
    if (i == 4 && j != 7) {
        return;
    }
    dfs(i + 1, j + n[i], op + "+");
    dfs(i + 1, j - n[i], op + "-");
}

int main() {
    int s;
    cin >> s;
    rrep(i, 3, 0) {
        n[i] = s % 10;
        s /= 10;
    }
    dfs(1, n[0], "");
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 079
	// https://atcoder.jp/contests/abc079/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String str = sc.next();
		
		if ((str.charAt(0) == str.charAt(1) && str.charAt(1) == str.charAt(2)) || (str.charAt(1) == str.charAt(2) && str.charAt(2) == str.charAt(3))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
  
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
const int MOD = 1e9+7;

int main() {
  int n,ans=1; cin>>n;
  vector<ll> cnt(n+1, 0);
  for(int i=1; i<=n; i++){
    int b=i;
    for(int j=2; j<=n; j++) {
      while(b%j==0) {
        b/=j;
        cnt[j]++;
      }
    }
  }
  REP(i,n+1) ans = ans*(cnt[i]+1)%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// Union-Find木 //////////

struct UnionFind{
  vector<int> par,siz;						//par[i]:iの親の番号
  UnionFind(int N):par(N),siz(N,1ll){		//最初は全てが根であるとして初期化
    for(int i=0; i<N; i++) par[i]=i;
  }
  
  int root(int x){						//データxが属する木の根
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  
  void unite(int x,int y){				//xとyの木を併合
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    if(siz[rx]<siz[ry]) swap(rx,ry);
    siz[rx]+=siz[ry];
    par[ry]=rx;
  }
  
  bool same(int x,int y){				//x,yが属する木が同じならtrueを返す
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
  
  int size(int x){
    return siz[root(x)];
  }
};

//////////////////////////////////////////////////

int main(){
  int N,M;
  cin>>N>>M;
  
  UnionFind U(N);
  REP(i,M){
    int A,B;
    cin>>A>>B;
    A--,B--;
    U.unite(A,B);
  }
  
  int ans=0;
  REP(i,N) chmax(ans,U.size(i));
  co(ans);
  return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n, m;
    cin >> n;
    cin >> m;

    vector<vector<string>> tes(n);
    vector<int> ac(n), pena(n);
    REP(i, m)
    {
        int p;
        string s;
        cin >> p;
        p--;
        cin >> s;
        if (ac[p])
            continue;
        if (s == "AC")
        {
            ac[p] = 1;
        }
        else
        {
            pena[p]++;
        }
    }

    int AC = 0, PENA = 0;
    REP(i, n)
    {
        AC += ac[i];
        if (ac[i])
            PENA += pena[i];
    }
    printf("%d %d\n", AC, PENA);

    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);

	if (abs(a - b) >0) {
		if (a > b) {
			printf("%d", a * 2 - 1);
		}
		else {
			printf("%d", b * 2 - 1);
		}
	}
	else {
		printf("%d", a + b);
	}


	return 0;
}

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

int main() {
  int n;
  cin >> n;
  pair<int,int> a[100010] = {}, b[100010] = {};
  for (int i = 1; i <= 100000; i++) {
    a[i].second = i;
    b[i].second = i;
  }
  int aa = 0, bb = 0;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (i & 1) {
      b[v].first++;
      bb++;
    } else {
      a[v].first++;
      aa++;
    }
  }
  sort(a, a + 100010);
  sort(b, b + 100010);
  reverse(a, a + 100010);
  reverse(b, b + 100010);
  if (a[0].second == b[0].second) {
    if (a[1].first > b[1].first) {
      cout << n - b[0].first - a[1].first << endl;
    } else {
      cout << n - a[0].first - b[1].first << endl;
    }
  } else {
    cout << n - a[0].first - b[0].first << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
def read():
    N, A, B = list(map(int, input().strip().split()))
    return N, A, B


def solve(N, A, B):
    if N * A < B:
        return N * A
    else:
        return B


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 38384
n = int(input())
li = list(map(int,input().split()))

dp = [0,abs(li[1]-li[0])]

for i in range(2,n):
    dp += [min(dp[-2]+abs(li[i]-li[i-2]),dp[-1]+abs(li[i]-li[i-1]))]

print(dp[-1])

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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    string s;
    cin >> s;
    if( s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 3628
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    N =  int(input())

    def fn(n):
        ans = 0
        a, b = divmod(n, 6)
        if b == 0:
            if int(a**.5)**2 == a:
                ans += 1

        n2 = n//2
        for i in range(n2):
            x = 3 * i**2

    ans = dp = [0] * (N+1)
    r1 = range(1, N)

    for i in r1:
        x = 6 * i**2
        if x > N: break
        dp[x] += 1

    for i in r1:
        x = 3* i**2

        if x > N: break

        for j in r1:
            if i == j: continue
            y = x + j * (j+2*i)
            if y > N: break
            dp[y] += 3

    for i in r1:
        x = i**2

        if x > N: break

        for j in range(i+1, N):
            y = x + j**2 + i * j

            if y > N: break

            for k in range(j+1, N):
                z = y + k*(k + i + j)

                if z > N: break

                dp[z] += 6

    print(*dp[1:], sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 68432
N = int(input())
P = list(map(int,input().split()))

a = []
for i in range (N-1):
    a.append(P[i+1] - P[i])

ans = 0
for i in range (N-2):
    if a[i+1]/a[i] > 0:
        ans = ans + 1
print(ans)

Measured memory_bytes: 3060