akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;
long long const LL_INF = 5000000000000000000LL;

long long bg[MAX_N], en[MAX_N], x[MAX_N];

struct pp {
	long long A, tp, x;
	pp() {}
	pp(long long A, long long tp, long long x) :A(A), tp(tp), x(x) {}
};
vector<pp> blk;

bool operator < (const pp& e, const pp& f) {
	return e.A < f.A || (e.A == f.A && e.tp < f.tp);
}

multiset<long long> ms;
long long ANS[MAX_N];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, q;
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++)
		scanf("%lld%lld%lld", &bg[i], &en[i], &x[i]);
	

	for (int i = 0; i < n; i++) {
		int A = bg[i] - x[i];
		int B = en[i] - x[i] - 1;
		if (B < 0) continue;
		if (A > B) continue;
		A = max(A, 0);
		B = max(B, 0);
		blk.push_back(pp(A, +1, x[i]));
		blk.push_back(pp(B+1, -1, x[i]));
	}

	for (int i = 0; i < q; i++) {
		long long xx;
		scanf("%lld", &xx);
		blk.push_back(pp(xx, +5, i));
	}

	sort(blk.begin(), blk.end());
	//close, open

	int kk = 0;
	while (kk < (int)blk.size()) {
		int coord = blk[kk].A;
		while (kk < (int)blk.size() && blk[kk].tp < 0 && blk[kk].A == coord) {
			ms.erase(ms.find(blk[kk].x));
			kk++;
		}
		while (kk < (int)blk.size() && blk[kk].tp == +1 && blk[kk].A == coord) {
			ms.insert(blk[kk].x);
			kk++;
		}
		multiset<long long>::iterator iter = ms.begin();
		while (kk < (int)blk.size() && blk[kk].tp == +5 && blk[kk].A == coord) {
			if (iter == ms.end()) ANS[blk[kk].x] = -1;
			else ANS[blk[kk].x] = *iter;
			kk++;
		}
	}

	for (int i = 0; i < q; i++) printf("%lld\n", ANS[i]);
	return 0;
}


Measured memory_bytes: 33636
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[200001];
int E[400001], ne[400001], he[200001];
vector<int> V;

void dfs(int p, int mae) {

	int itr = lower_bound(V.begin(), V.end(), A[p]) - V.begin();
	if (itr == V.size()) {
		V.pb(A[p]);
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = V.size();
		V.pop_back();
	}
	else {
		swap(V[itr], A[p]);
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = V.size();
		V[itr] = A[p];
	}
}

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V.pb(2000000000);
	dfs(1, -1);

	rep1(i, N) putint(he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 25884
#include<stdio.h>
int main(void){
    char a[1000];
    int i,j;

    gets(a);
    for(i=0;a[i]!='\0';i++){
        if(a[i]==32 || a[i]==46)continue;
        a[i]-=32;
    }
    printf("%s\n",a);


    return 0;

}

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

int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if (c-a-b > 0 and 4*a*b < powl(c-a-b,2)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

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

    lli ans=0;

    for(int i=1;i<=n;i++){
        int t=0,z;
        z=i;
        while(z){
            t++;
            z/=10;
        }
        if(t%2)ans++;
    }
    cout<<ans<<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,m;
    cin>>n>>m;
    ll ans=0;
    priority_queue<pair<int,int>>q;
    rep(i,n){
        int a; cin>>a;
        q.push(make_pair(a,1));
    }
    rep(i,m){
        int b,c;
        cin>>b>>c;
        q.push(make_pair(c,b));
    }
    while(n>0){
        int qf=q.top().first;
        int qs=q.top().second;
        ans+=qf;
        n--;
        if(qs>1){
            pair<int,int>x=make_pair(qf,qs-1);
            q.pop();
            q.push(x);
        }
        else q.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2420
def main():
    K = int(input())  # 文字列または整数(一変数)
    A, B = map(int, input().split())

    for i in range(1,1001):
        num = K*i
        if num >= A and num <= B:
            print("OK")
            return
        if num > B:
            print("NG")
            return

    print("NG")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <utility>

using namespace std;

int main()
{
    int n, x, m[101];
    cin>>n>>x;
    for (int i=0; i<n; i++) cin>>m[i];
    for (int i=0; i<n; i++) x-=m[i];
    sort(m ,m+n);
    cout<<n+x/m[0]<<endl;
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; ++i) cout << s << ' ';
    int magic;
    if (s == int(1e9)) magic = int(1e9) - 1;
    else magic = s + 1;
    for (int i = 0; i < n - k; ++i) cout << magic << ' ';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1280
h,w = map(int,input().split())
lis = [list(input()) for _ in range(h)]
dx = [1,0,-1,0,1,1,-1,-1]
dy = [0,1,0,-1,1,-1,1,-1]

for i in range(h):
  for j in range(w):
    if lis[i][j] == "#":
      continue
    else:
      lis[i][j] = 0
    for d in range(8):
      if i + dx[d] < 0 or i + dx[d] >= h:
        continue
      elif j + dy[d] < 0 or j + dy[d] >= w:
        continue
      if lis[i+dx[d]][j+dy[d]] == "#":
        lis[i][j] += 1
for i in range(h):
  lis[i] = list(map(str,lis[i]))
  print("".join(lis[i]))

Measured memory_bytes: 3188
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int to, cost; };
int n, a, b, c;
int main() {
	while (cin >> n, n) {
		vector<vector<edge> > G(n);
		for (int i = 0; i < n - 1; i++) {
			cin >> a >> b >> c; a--, b--;
			G[a].push_back(edge{ b, c });
			G[b].push_back(edge{ a, c });
		}
		vector<bool> lv(n, false);
		for (int i = 1; i < n; i++) {
			if (G[i].size() == 1) lv[i] = true;
		}
		vector<int> v(n, 999999999); v[0] = 0;
		queue<int> que; que.push(0);
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (edge e : G[u]) {
				if (v[e.to] > v[u] + e.cost) {
					v[e.to] = v[u] + e.cost;
					que.push(e.to);
				}
			}
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (lv[i]) continue;
			for (edge j : G[i]) {
				if (!lv[j.to]) sum += j.cost;
			}
		}
		int res = 0;
		for (int i = 0; i < n; i++) {
			if (!lv[i]) res = max(res, v[i]);
		}
		cout << sum - res << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        String ans = "YES";
        if(X<A||X>(A+B)) ans = "NO";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll a,b,c,ans1,ans2;
	cin>>a>>b>>c;
	ans1=c-a-b;
	bool f=true;
	if(ans1<0) f=false;
	ans1=(c-a-b)*(c-a-b);
	ans2=4*a*b;
	if(ans1>ans2&&f) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
/******************************************
* AUTHOR : DHRUV GUPTA *
* NICK : COSMOGOD *
* INSTITUTION : LNMIIT *
******************************************/

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000007

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

	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];

	int dp[n+1][k+1];
	int prefix[n+1][k+1];
	dp[0][0] = 1;
	prefix[0][0] = 1;
	for(int i=1;i<=n;i++){
		dp[i][0] = 1;
		prefix[i][0] = 1;
	}
	for(int j=1;j<=k;j++){
		dp[0][j] = 0;
		prefix[0][j] = 1;
	}

	for(int i=1;i<=n;i++){
		for (int j=1;j<=k;j++)
		{
			
				if(j-a[i-1]-1 >= 0)
					dp[i][j] = (prefix[i-1][j]%inf - prefix[i-1][j-a[i-1]-1]%inf + inf)%inf;
				else
					dp[i][j] = prefix[i-1][j];

				if(dp[i][j]<0)
					dp[i][j] += inf;

				prefix[i][j] = (prefix[i][j-1] + dp[i][j])%inf;
			
		}
	}	

	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=k;j++){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	cout << dp[n][k];

	return 0;
}

Measured memory_bytes: 79232
n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    for j in range(0,n,i):
        k=n-1-j
        if k<i or k%i<1 and k<=j:break
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

Measured memory_bytes: 70520
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    if(f[0]==e[0])*(f[5]==e[5]):
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


Measured memory_bytes: 5608
N = int(input())
#key:いる位置, value:右手の位置
range_dct = {}
for i in range(N):
    x, l = map(int, input().split())
    range_dct[x] = x + l

range_dct_sorted = sorted(range_dct.items(), key=lambda x:x[1])

counter = 0
right = -100000000000

for key, value in range_dct_sorted:
    if right <= key * 2 - value:
        right = value
        counter += 1

print(counter)

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

int main() {

	int N;
	string S; // .->白 #->黒

	cin >> N;
	cin >> S;

	int w = 0, b = 0, ans = 0;
	for (char c : S) {
		if (c == '.') {
			w++;
		}
	}
	ans = w;
	for (char c : S) {
		if (c == '#') {
			b++;
		}
		else {
			w--;
		}
		if (b + w < ans) {
			ans = b + w;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    int ans = 0;
    int CurMin = 1e9;
    for(int i = 0; i < n; i++){
        CurMin = min(CurMin, p[i]);
        if(CurMin == p[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#define LL long long
LL N, A, B, C, D;
std::string S;
int K;
int main() {
	std::cin >> S >> K;
	for (auto &u : S) {
		if (u != 'a') {
			if ('z' - u + 1 <= K) {
				K -= 'z' - u + 1;
				u = 'a';
			}
		}
	}
	K %= 26;
	S[S.size() - 1] += K;
	std::cout << S << std::endl;
	return 0;
}

Measured memory_bytes: 512
N,M=map(int,input().split())

C=[-1]*N

for i in range(M):
    s,c=map(int,input().split())
    if C[s-1]==-1:
        C[s-1]=c
    elif C[s-1]!=-1:
        if C[s-1]!=c:
            print(-1)
            exit()

if N==1 and C[0]==0:
    print(0)
    exit()

if N==1 and C[0]==-1:
    print(0)
    exit()

ans=""
for i in range(N):
    if i == 0 and C[i] == 0:
        print(-1)
        exit()
    if C[i]==-1:
        if i==0:
            ans+="1"
        else:
            ans+="0"
    else:
        ans+=str(C[i])
print(ans)




Measured memory_bytes: 3316
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    
    for(int i = 0; i <= a; ++i){
        for(int j = 0; j<= b; ++j){
            for(int k = 0; k<= c; ++k){
                if(500*i+100*j+50*k==x) ans+=1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n%2!=0) { cout << "No\n"; return 0; }
	string s2,s3;
	s2=s.substr(0,n/2);
	s3=s.substr(n/2,n/2); 
	if(s2==s3) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}                 

Measured memory_bytes: 256
import std.stdio;
import std.numeric;

void main(){
	ulong x;
	ulong[3] a, m, ans;
	while (readf("%d %d %d %d %d %d\n", &a[0], &m[0], &a[1], &m[1], &a[2], &m[2])) {
		if(a[0] == 0 && a[1] == 0 && a[2] == 0 && m[0] == 0 && m[1] == 0 && m[2] == 0) break;
		for (int i = 0; i < 3; i++) {
			x =  1;
			ulong j = 0;
			do {
				x = a[i]*x % m[i];
				j++;
			} while (x != 1);
			ans[i] = j;
		}
		writeln(LCM(ans));
	}
}

ulong LCM(ulong[] n){
	ulong result = n[0];
	for (int i = 1; i < n.length; i++) {
		result = result / gcd(result, n[i]) * n[i];
	}
	return result;
}

Measured memory_bytes: 988
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b){
  return a * b / gcd(a, b);
}
int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = A[0];
    for(int i = 1; i < N; i++){
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4000
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
    public function nextString() {
        return (string)$this->next();
    }
}

$sc = new Scanner();
$s = $sc->nextString();

$target = '2019/04/30';

if(strtotime($s) <= strtotime($target)){
  echo 'Heisei';
} else {
  echo 'TBD';
}


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

int main(){
	vector<ll> N(3);
	int K;
	for(int i = 0; i < 3; ++i) cin >> N[i]; cin >> K;
	vector<vector<ll>> v(3);
	for(int iter = 0; iter < 3; ++iter){
		v[iter].resize(N[iter]);
		for(int i = 0; i < N[iter]; ++i) cin >> v[iter][i];
		sort(v[iter].begin(), v[iter].end(), greater<ll>());
	}
	priority_queue<Data> que;
	set<Data> se;
	que.push(Data(v[0][0] + v[1][0] + v[2][0], vector<int>({0,0,0})));
	for(int k = 0; k < K; ++k){
		auto c = que.top();que.pop();
		cout << c.first << endl;

		for(int iter = 0; iter < 3; ++iter){
			if(c.second[iter] + 1 < N[iter]){
				ll sum = c.first - v[iter][c.second[iter]] + v[iter][c.second[iter] + 1];
				auto num = c.second; num[iter]++;
				auto d = Data(sum, num);

				if(!se.count(d)) se.insert(d), que.push(d);
			}
		}
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

long long a[10005];

int calLog2(int n)
{
	if(n == 1) return 0;
	int ans = 0;
	if(n % 2 == 1) return 0;
	while(n % 2 == 0)
	{
		n /= 2;
		ans++;
	}
	return ans;
}

int main() 
{
	int n;
	scanf("%d", &n);
	int ma = 0;
	for(int i = 1; i <= n; i++) 
	{
		scanf("%d", &a[i]);
		ma += calLog2(a[i]);
	}
	printf("%d\n", ma);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int kazu,siz[100]={0},i,j,buff,G=0;
	scanf("%d",&kazu);
	for(i=0;i<kazu;i++){
		scanf("%d",&siz[i]);
	}
	for(i=0;i<kazu;i++){
		for(j=i;j<kazu;j++){
			if(siz[i]<siz[j]){
				buff=siz[i];
				siz[i]=siz[j];
				siz[j]=buff;
			}
		}
	}
	for(i=0;i<kazu;i++){
		if(siz[i]!=siz[i+1]){
			G++;
		}
	}
	printf("%d\n",G);
	return 0;
}

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

using ll=long long;
const ll mod=998244353;

ll pow2(ll x, ll y) {
    ll a=1;
    for(ll i=0; i<y; i++) {
        a *= x;
        a %= mod;
    }
    return a;    
}

int main() {
    ll N,i,m=0,r=1;
    cin >> N;
    vector<ll> D(N),c(N,0);
    for(i=0; i<N; i++)
        cin >> D.at(i);
    for(ll x : D) {
        c.at(x)++;
        m = max(x,m);
    }

    if(!(D.at(0)==0 && c.at(0)==1)) {
        cout << 0 << endl;
        return 0;
    }

    for(i=1; i<=m; i++) {
        if(c.at(i) == 0) {
            r = 0;
            break;
        }
        r *= pow2(c.at(i-1), c.at(i));
        r %= mod;
    }

    cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int d[100];
    for (int x = 0; x < n; x++) {
        cin >> d[x];
    }
    int i = 1,j ,counta,count=1;
    for (i; i < n; i++) {
        counta = 0;
        for (j = 0; j < i; j++) {
            if (d[i] == d[j]) {
                counta++;
                break;
            }
        }
        if (counta == 0) {
            count++;
        }
    }
    cout<< count << endl;
    return 0;
}

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

const long long c = 1e9+7;
int N;
long long dp[2001][2001];

void nCr(){
  for(int cnt0=2; cnt0<2001; cnt0++){
    for(int cnt1=0; cnt1<=cnt0; cnt1++){
      if(cnt1==0) {dp[cnt0][cnt1] = 1; continue;}
      if(cnt1==cnt0) {dp[cnt0][cnt1] = 1; continue;}
      dp[cnt0][cnt1] = (dp[cnt0-1][cnt1-1] + dp[cnt0-1][cnt1])%c;
    }
  }
}

int main(int argc, char** argv){
  int K;
  cin >> N >> K;

  for(int cnt0=0; cnt0<2001; cnt0++) for(int cnt1=0; cnt1<2001; cnt1++) dp[cnt0][cnt1] = 0;
  dp[0][0] = 1;
  dp[1][0] = 1;
  dp[1][1] = 1;
  nCr();
  for(int i = 1; i <= K; i++){
    /* calculate nCk */
    if(N-K+1 < i){
      printf("0\n");      
    }else{
      printf("%lld\n", (dp[K-1][i-1]*dp[N-K+1][i])%c);
    }
  }
  return 0;
  
}


Measured memory_bytes: 31488
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    println!("{}",if a=="AKIHABARA"||a=="AKIHABAR"||a=="AKIHABRA"||a=="AKIHABR"||a=="AKIHBARA"||a=="AKIHBAR"||a=="AKIHBRA"||a=="AKIHBR"||a=="KIHABARA"||a=="KIHABAR"||a=="KIHABRA"||a=="KIHABR"||a=="KIHBARA"||a=="KIHBAR"||a=="KIHBRA"||a=="KIHBR"{"YES"}else{"NO"})
}

Measured memory_bytes: 2152
use proconio::{
    input,
    marker::Chars,
};

fn main() {
    input! {
        n: usize,
        m: usize,
        aa: [Chars; n],
        bb: [Chars; m]
    }

    for i in 0..=n-m {
        for j in 0..=n-m {
            let mut ok = true;
            'next: for k in 0..m {
                for l in 0..m {
                    if aa[i+k][j+l] != bb[k][l] {
                        ok = false;
                        break 'next;
                    }
                }
            }
            if ok {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

struct Problem {
public:

	void Solve() {
		UL N; scanf("%d", &N);
		rep(i, 1 << N) {
			printf("%d:", i);
			rep(j, N) {
				if ((i >> j) & 1) printf(" %d", j);
			}
			printf("\n");
		}
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}



Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	sc.close();
    	int ans = 1;
    	for(int i = 0; i < N; i++){
    		if(ans < K) ans = ans * 2;
    		else ans = ans + K;
    	}
    	System.out.println(ans);
    }
}

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

int main() {
  int n, A;
  cin >> n >> A;
  vector<ll> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<vector<vector<ll>>> dp(n + 1,
                                vector<vector<ll>>(n + 1, vector<ll>(5555)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      for (int s = 0; s <= 5000; s++) {
        dp[i + 1][k][s] += dp[i][k][s];
        if (s >= x[i]) { dp[i + 1][k + 1][s] += dp[i][k][s - x[i]]; }
      }
    }
  }
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += dp[n][i][i * A];
  }

  cout << sum << endl;
}

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

int main() {
  int n;

  int num[8] = {0, 1, 2, 3, 5, 7, 8, 9};
  while (cin >> n, n) {
    vector<int> ans;
    while (n) {
      ans.push_back(n % 8);
      n /= 8;
    }

    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
      cout << num[ans[i]];
    }

    cout << endl;
  }
}

Measured memory_bytes: 3048
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(n);
        bool f = n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9;
        Console.WriteLine(f ? "YES" : "NO");
    }
}

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


#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define print(x) cout << x << endl;
typedef long long ll;

constexpr ll INF = 1'010'000'000'000'000'017LL;\
constexpr ll MOD = 1'000'000'007LL;\
constexpr double EPS = 1e-12;\
constexpr double PI = 3.14159265358979323846;

int main()
{
    ll A, B;
    cin >> A >> B;
    REP(i, 1000) {
        ll tmp1 = floor((i+1) * 0.08);
        ll tmp2 = floor((i+1) * 0.1);
        if (A == tmp1 && B == tmp2) {
            print((i+1));
            return 0;
        }
    }
    print(-1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,q; cin >>n>>q;
    string s; cin >> s;
    vector<int> l(q);
    vector<int> r(q);
    REP (i,q) cin >> l[i] >> r[i]; 

    vector<int> sc(n+1);
    for (int i = 2; i <= n; i++) {
        if (s[i-1] == 'C' && s[i-2] == 'A') {
            sc[i] = sc[i-1] + 1;
        } else {
            sc[i] = sc[i-1];
        } 
    }

    for (int i = 0; i < q; i++) {
        cout << sc[r[i]] - sc[l[i]] << endl;
    }

    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char> > pic(H,vector<char>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> pic.at(i).at(j);
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cout << pic.at(i).at(j);
        }
        cout << endl;
        for(int j = 0; j < W; j++) {
            cout << pic.at(i).at(j);
        }
        cout << endl;
    }
    


    return 0;
}

Measured memory_bytes: 3624
from collections import defaultdict
import sys
input = sys.stdin.readline


T = defaultdict(list)

N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

for _ in range(M):
    A, B = list(map(int, input().split()))
    A -= 1
    B -= 1
    T[A].append(H[B])
    T[B].append(H[A])

ans = 0

for n in range(N):
    if len(T[n]) == 0 or H[n] > max(T[n]):
        ans += 1

print(ans)


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

int main() {
    int h, w;
    
    while(1) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;

        for(int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if ((i % 2 == 1 && j % 2 == 1) || (i % 2 == 0 && j % 2 == 0)) {
                  cout << '#';
                } else {
                  cout << '.';
                }
            }
        	cout << endl;
        }
        cout << endl;
    }
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    vint ca(n,0),cb(n,0);
    for(auto e:a) ca[e-1]++;
    for(auto e:b) cb[e-1]++;

    rep(i,n){
        if(ca[i] + cb[i] > n){
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    vint ruica,ruicb;
    ruica.push_back(0);
    ruicb.push_back(0);
    rep(i,n){
        ruica.push_back(ruica.back() + ca[i]);
        ruicb.push_back(ruicb.back() + cb[i]);
    }

    ll maxval = 0;
    rep(i,n){
        chmax(maxval, ruica[i+1] - ruicb[i]);
    }

    rep(i,n){
        cout<<b[(i-maxval+n)%n]<<" ";
    }
    cout<<endl;




    return 0;

}

Measured memory_bytes: 12808
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >>b >> c;
	if (a == b&&b == c) {
		cout << '1';
	}
	else if (a != b&&b != c&&a != c) {
		cout << '3';
	}
	else {
		cout << '2';
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;const ll N=2*1e5+5;
int main()
{
	fast;
	ll n;cin>>n;
	if(n>=30)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

		int n = sc.nextInt();

		String s = sc.next();

		char before = '0';
		int count = 0;

		for (int i = 0; i < s.length(); i++) {

			char c = s.charAt(i);
			if (c != before) {
				before = c;
				count++;
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 24268
#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define pr(x) cout<<x
#define prs cout<<" "
#define prn cout<<"\n"
#define sc(x) cin>>x
#define ll long long int


int main()
{
    ios :: sync_with_stdio(false); cin.tie(0);
    int t=1;
    //cin >> t;
    for(int i9 = 1; i9 <= t; i9++)
    {
        ll r, c;
        cin>>r>>c;
        //cout<<r<<c<<endl;
        char grid[r][c];
        ll dp[r][c];
        memset(dp, 0, sizeof(dp));
        for(ll i=0; i<r; i++)
        {
            for(ll j=0; j<c; j++)
            {
                cin>>grid[i][j];
                if(grid[i][j] == '#')
                   dp[i][j] = -1;
                //cout<<dp[i][j]<<" ";
            }
            //cout<<endl;
        }
        for(ll i=0; i<r; i++)
        {
            if(dp[i][0] == -1)
             break;
            else
             dp[i][0] = 1;
            //cout<<dp[i][0]<<endl;
        }
        for(ll i=0; i<c; i++)
        {
            //cout<<i<<endl;
            if(dp[0][i] == -1)
             break;
            else
             dp[0][i] = 1;
            //cout<<dp[0][i]<<endl;
        }
        for(ll i=1; i<r; i++)
        {
            for(ll j=1; j<c; j++)
            {
                //cout<<dp[i][j]<<" ";
                if(dp[i][j] == -1)
                  continue;
                if(dp[i-1][j] > 0)
                  dp[i][j] = dp[i][j]%1000000007 + dp[i-1][j]%1000000007;
                if(dp[i][j-1] > 0)
                  dp[i][j] = dp[i][j]%1000000007 + dp[i][j-1]%1000000007;
            }
            //cout<<endl;
        }
        ll res = dp[r-1][c-1]%1000000007;
        cout<<res<<endl;
    }
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
string a[100005];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    string c;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sort(a[i].begin(),a[i].end());
    }
    sort(a,a+n);
    long long s=0,sum=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1])
            s++;
        else s=0;
        sum+=s;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
 
void selectionSort(int array[],int n,int& change_count)
{
    int min;
    for(int i = 0; i < n-1; i++){
        min = i;    //?????????
        for(int j = i+1; j < n; j++){
            if(array[j] < array[min]){
                min = j;
            }
        }
        if(i != min){
            swap(array[i],array[min]);
            change_count++;
        }
    }
 
}
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
    int array[ARRAY_SIZE];
    int change_count = 0;
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    selectionSort(array,n,change_count);
 
    for(int i = 0; i < n; i++){
        if(i != n-1){
            printf("%d ",array[i]);
        }else{
            printf("%d\n",array[i]);
        }
    }
    printf("%d\n",change_count);
}


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

int a, b, c, n;
int l[200005];

int funk(int ind, int x, int y, int z){
    if(ind == n){
        if(x == 0 || y == 0 || z == 0){
            return 987654321;
        }else{
            return abs(a - x) + abs(b - y) + abs(c - z);
        }
    }

    int res = funk(ind + 1, x + l[ind], y, z) + (x ? 10 : 0);
    res = min(res, funk(ind + 1, x, y + l[ind], z) + (y ? 10 : 0));
    res = min(res, funk(ind + 1, x, y, z + l[ind]) + (z ? 10 : 0));
    res = min(res, funk(ind + 1, x, y, z));

    return res;
}

int main()
{
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; ++i){
        cin >> l[i];
    }

    int res = funk(0, 0, 0, 0);
    cout << res << "\n";
    return 0;
}


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

int main(){
    int N;
    vector<int> p(4),t(4);
    cin >> N;
    for(int i=0;i<4;i++) cin >> p[i];
    for(int i=0;i<4;i++) cin >> t[i];
    int ans = 1e9;
    for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) for(int k=0;k<=N;k++){
        int res = N-i*t[0]-j*t[1]-k*t[2];
        int l = 0;
        if(res>0) l = (res+t[3]-1)/t[3];
        ans = min(ans,i*p[0]+j*p[1]+k*p[2]+l*p[3]);
//        cerr << i*p[0]+j*p[1]+k*p[2]+l*p[3] << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(90);
double r,pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
cin>>r;
r*=pi;
cout<<r*2<<endl;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

llint cnt = 0;

int main()
{
    int n;
    int h;
    int mx = 0;
    
    ci >> n;
    rep(i, n) {
	ci >> h;
	mx = max(mx, h);
	if(mx <= h) cnt++;
    }

    co << cnt << en;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long n,m,i,ans,c;
  string s;
  int a[4];
  for(i=0;i<4;i++)
    a[i] = 0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    if (equal(s.begin(), s.end(), "AC"))
        a[0]++;
    else if (equal(s.begin(), s.end(), "WA"))
        a[1]++;
    else if (equal(s.begin(), s.end(), "TLE"))
        a[2]++;
    else if (equal(s.begin(), s.end(), "RE"))
        a[3]++;
  }
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
			// 整数配列の入力
			var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			var A = inputLongArray[0];
			var B = inputLongArray[1];
			var K = inputLongArray[2];

			for(int i = 0; i<K; ++i) {
				var target = A + i;
				if(target > B) {
					break;
				}
				Console.WriteLine(target);
			}

			for(int j = (int)(B - K + 1); j <= B; ++j) {
				if(j >= A + K) {
					Console.WriteLine(j);
				}
			}
		}
	}
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int f(int n){
    ll s=0;
    while(n>0){
        s += n % 10;
        n /= 10;
    }
    return s;
}


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

    if(n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def telepo_test(start, goal, delta, board):
    route = [start + delta * i for i in range(abs(goal - start) // abs(delta) + 1)]
    route = [board[r] for r in route]

    mp = 0
    for s, t in zip(route[:-1], route[1:]):
        print(s,t)
        mp += abs(t[0] - s[0]) + abs(t[1] - s[1])
    return mp


H, W, D = tuple(map(int, input().split()))
board = dict()
for h in range(H):
    row = tuple(map(int, input().split()))
    for w in range(W):
        board[row[w]] = (h, w)
delta = dict([(i, 0) for i in range(1, D+1)])
for d in range(D+1, H*W+1):
    delta[d] = delta[d-D] + abs(board[d][0] - board[d-D][0]) + abs(board[d][1] - board[d-D][1])

Q = int(input())

LRs = [tuple(map(int, input().split())) for _ in range(Q)]
result = [delta[LR[1]] - delta[LR[0]] for LR in LRs]

for r in result:
    print(r)


Measured memory_bytes: 48248
MOD = 10**9 + 7

class Combination:
    def __init__(self, size, MOD):
        self.size = size + 2

        f = 1
        self.fact = fact = [f]
        for i in range(1, size+1):
            f = f * i % MOD
            fact.append(f)
        f = pow(f, MOD-2, MOD)
        self.factInv = factInv = [f]
        for i in range(size, 0, -1):
            f = f * i % MOD
            factInv.append(f)
        factInv.reverse()

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

def sol():
    K = int(input())
    S = input()
    N = len(S)

    comb = Combination(N + K + 100, MOD)

    ans = 0
    L = 1
    R = pow(26, K, MOD)
    inv26 = pow(26, MOD - 2, MOD)
    for l in range(K + 1):
        ans += L * comb.nhr(N, l) * R
        ans %= MOD

        L = L * 25 % MOD
        R = R * inv26 % MOD

    print(ans)
sol()

Measured memory_bytes: 169812
from collections import Counter

N,*A = map(int, open(0).read().split())
As = sorted(A)
Ac = Counter(A)
m = max(A)
dp = [True] * (m+1)
ans = 0
for x in As:
    if dp[x] == True:
        for i in range(1,m//x+1):
            dp[x*i] = False
        if Ac[x] == 1:
            ans += 1
    else:
        continue
print(ans)

Measured memory_bytes: 40024
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
y=0
a1=0
a2=0
for a3 in a:
  s = max(a1+a2-x,a2+a3-x,0)
  y += s
  a1 = a2 
  a2 = a3 - s
print(y)

Measured memory_bytes: 14252
<?php
    fscanf(STDIN,"%d", $a);
    fscanf(STDIN,"%d", $b);
    fscanf(STDIN,"%d", $c);
    fscanf(STDIN,"%d", $d);

    $arrayTrain = [$a, $b];
    $train = min($arrayTrain);
    $arrayBus = [$c, $d];
    $bus = min($arrayBus);
    echo $train + $bus;
    
    
  ?>

Measured memory_bytes: 4604
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, vector<ll> a) {
  vector<int> cnt(100100);
  for (ll i: a) {
    cnt[i]++;
    if (i > 0) cnt[i-1]++;
    cnt[i+1]++;
  }
  cout << *max_element(ALL(cnt)) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 2176
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k[] = new int[n];
        int c = 0;
        for (int i = 0;i < n;++i){
            k[i] = sc.nextInt();
            c += k[i] - 1;
        }
        System.out.println(c);
    }
}


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

int main() {

  int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
  
  if (b - a > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (c - a > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (d - a > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (e - a > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (c - b > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (d - b > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (e - b > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (d - c > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (e - c > k) {
    cout << ":(" << endl;
    return 0;
  }
  if (e - d > k) {
    cout << ":(" << endl;
    return 0;
  }
  cout << "Yay!" << endl;
}



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

using namespace std;

constexpr int MAX_N = 100000;
vector<int> pre_order(MAX_N, -1);
vector<int> post_order(MAX_N, -1);
vector<int> parent(MAX_N, -1);
vector<bool> visited(MAX_N, false);

vector<vector<int>> G(MAX_N);

void add_edge(int s, int t) {
	G[s].emplace_back(t);
	G[t].emplace_back(s);
}

void dfs(const vector<vector<int>>& G, int u = 0, int prev_u = -1, int timer = 1) {
	pre_order[u] = timer;
	post_order[u] = timer;
	++timer;

	visited[u] = true;

	for (auto&& v:G[u]) {
		if (!visited[v]) {
			parent[v] = u;
			dfs(G, v, u, timer);
			post_order[u] = min(post_order[u], post_order[v]);
		}
		else if (v != prev_u) {
			post_order[u] = min(post_order[u], pre_order[v]);
		}
	}
}

vector<int> articulation_points(const vector<vector<int>>& G, int G_sz, int root = 0) {
	dfs(G, root);
	vector<int> ans;
	vector<bool> used(G_sz, false);
	int root_child = 0;
	for (int j = 0; j < G_sz; ++j) {
		if (parent[j] == root)++root_child;
		if (root_child == 2) {
			ans.emplace_back(root);
			break;
		}
	}
	for (int i = 1; i < G_sz; ++i) {
		if (parent[i] != root
			&&pre_order[parent[i]] <= post_order[i]
			&& !used[parent[i]]) {
		        ans.emplace_back(parent[i]);
			used[parent[i]] = true;
		}
	}
	sort(ans.begin(), ans.end());
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, E;cin >> N >> E;
	int s, t;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t;
		add_edge(s, t);
	}
	vector<int>ans = articulation_points(G, N);
	for (auto&& v : ans) {
		cout << v << endl;
	}
}

Measured memory_bytes: 6136
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string S;

int charCounter(string a, char c) {
    int counter = 0;
    for(int i =0;i<a.size();i++){
        if (a[i]==c) {
            counter++;
        }
    }
    return counter;
}

int main() {
    cin >> S;
    
    set<char> m;
    for(int i = 0;i<S.size();i++) {
        m.insert(S[i]);
    }
    
    bool flag = false;

    if(m.size()==2) {
        auto itr = m.begin();
        auto a = itr;
        itr++;
        auto b = itr;
        if(charCounter(S, *a)==2&&charCounter(S, *b)==2) {
            flag = true;
        } 
    }
    auto ans = flag ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256