akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApp1
{
    class ABC178C
    {
        // https://atcoder.jp/contests/abc178/tasks/abc178_c
        static void Main(string[] args)
        {
            const long m = 1000000007;

            uint N = uint.Parse(Console.ReadLine());

            long result = 0;
            long r10 = 10;
            long r9 = 9;
            long r8 = 8;

            if (N > 1)
            {
                // 10^N - 9^N * 2 + 8^N

                for (int i = 1; i < N; i++)
                {
                    r10 = (r10 * 10) % m;
                    r9 = (r9 * 9) % m;
                    r8 = (r8 * 8) % m;
                }

                result = (r10 - r9 - r9 + r8 + m + m) % m;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27536
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

#define INF (1 << 28)
#define MAX_V 1000

using namespace std;

int d[MAX_V][MAX_V];

void warshall_floyd(int n){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
	
	int N = 10;
	
	int H, W;
	cin >> H >> W;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> d[i][j];
		}
	}
	
	warshall_floyd(N);
	
	int ans = 0;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			int num;
			cin >> num;
			if(num != -1){
				ans += d[num][1];
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())

A=list(map(int,input().split()))

# まず、Nが3以下のときはAの最大値を返して終了
if N<=3:
  print(max(A))
  exit(0)

# 通常は1つ先まで進むが、
# Nが奇数の場合は2マス
# Nが偶数の場合は1マス
# どこかで余計に進むことができる。この余計に進んだマス数を保持してDP

if N&1:
  # Nが奇数の場合は最大2マス飛ばす権利がある
  dp=[[-((10**9) * (10**5))-1]*3 for i in range(N)]

  dp[0][0] = A[0] # 最初のマス
  dp[1][1] = A[1] # 1マス使う権利を行使
  dp[2][2] = A[2] # 2マス使う権利を行使
  for i in range(N):
    if i+2<N:
      # 通常の2マス進み
      for j in range(3):
        if dp[i+2][j] < dp[i][j] + A[i+2]:
          dp[i+2][j] = dp[i][j] + A[i+2]
    if i+3<N:
      # 1マス飛ばしパターン
      for j in range(2):
        if dp[i+3][j+1] < dp[i][j] + A[i+3]:
          dp[i+3][j+1] = dp[i][j] + A[i+3]
    if i+4<N:
      # 2マス飛ばしパターン
      if dp[i+4][2] < dp[i][0] + A[i+4]:
        dp[i+4][2] = dp[i][0] + A[i+4]
  
  # 以下の3パターンを比較する
  # 2マスの権利を使わずに最後2マス残す
  # 1マスの権利を残して最後1マス残す
  # 権利なしで最後のマス
  ans = max(dp[N-3][0],dp[N-2][1],dp[N-1][2])
  print(ans)
  
else:
  # Nが偶数の場合は最大1マス飛ばす権利がある
  # Nが奇数の場合は最大2マス飛ばす権利がある
  dp=[[-((10**9) * (10**5))-1]*2 for i in range(N)]

  dp[0][0] = A[0] # 最初のマス
  dp[1][1] = A[1] # 1マス使う権利を行使
  for i in range(N):
    if i+2<N:
      # 通常の2マス進み
      for j in range(2):
        if dp[i+2][j] < dp[i][j] + A[i+2]:
          dp[i+2][j] = dp[i][j] + A[i+2]
    if i+3<N:
      # 1マス飛ばしパターン
      if dp[i+3][1] < dp[i][0] + A[i+3]:
        dp[i+3][1] = dp[i][0] + A[i+3]
  
  # 以下の2パターンを比較する
  # 1マスの権利を残して最後1マス残す
  # 権利なしで最後のマス
  ans = max(dp[N-2][0],dp[N-1][1])
  print(ans)


Measured memory_bytes: 61640
import os

def main():
	s = input()
	num = 0
	if len(s)%2 == 0:	
		num = check(s[:len(s)//2], s[len(s)//2:])
	else:
		num = check(s[:len(s)//2], s[len(s)//2+1:])
	print(num)


def check(str_list1, str_list2):
	s1,s2 = str_list1, str_list2[::-1]
	count = 0
	for i in range(len(s1)):
		if s1[i] == s2[i]:
			pass
		else:
			count += 1
	return count


if __name__ == "__main__":
	main()


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

ans = 0

for n in range(1, N-1):
    if P[n-1] < P[n] & P[n] < P[n+1]:
        ans += 1
    elif P[n-1] > P[n] & P[n] > P[n+1]:
        ans +=1

print(ans)

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

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a < b) cout << "a < b" << endl;
  if(a > b) cout << "a > b" << endl;
  if(a == b) cout << "a == b" << endl;
  
  return 0;
}


Measured memory_bytes: 3092
N, A, B, C = [int(i) for i in input().split()]
l = [int(input()) for _ in range(N)]
INF = 10**9


def dfs(depth, a, b, c):
    if depth == N:
        # A, B, C いずれも竹は1本以上必ず使っていないとだめ
        if min(a, b, c) > 0:
            # 合体が終わったあとで差を計算してそれがコストになる
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return INF

    # 今ある竹を採用しない場合
    ret0 = dfs(depth + 1, a, b, c)

    # A, B, C を使う場合
    # 先にまとめて合体してあとで -30 することによって調整
    ret1 = dfs(depth + 1, a + l[depth], b, c) + 10
    ret2 = dfs(depth + 1, a, b + l[depth], c) + 10
    ret3 = dfs(depth + 1, a, b, c + l[depth]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n ;
    cin>>n;
      vector<int>a(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        long long c1=0,s1=0;
        long long  c2=0,s2=0;
        for(int i=0;i<n;i++)
        {
            s1+=a[i];
            s2+=a[i];
          if(i%2==0)
            {
                if(s1<=0)
                {
                    c1+=1-s1;
                    s1=1;
                }
                if(s2>=0)
                {
                    c2+=s2+1;
                    s2=-1;
                }

            }
            else
            {
                if(s1>=0)
                {
                    c1+=s1+1;
                    s1=-1;
                }
                if(s2<=0)
                {
                    c2+=1-s2;
                    s2=1;
                }

            }
        }

       cout<<min(c1,c2);

}


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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int>> A(N, vector<int>(M));
    vector <int> B(M);
    rep(i, M)
        cin >> B[i];

    rep(i, N)
        rep(j, M)
            cin >> A[i][j];
    int count = 0;
    rep(i, N)
    {
        int point = 0;
        rep(j, M)
            point += A[i][j] * B[j];
        point += C;
        if(point > 0) count++;
    }
    cout << count << endl;
    return 0;  
}

Measured memory_bytes: 256
s = input()
k=0
rei=['a','b','c']
def counter(v):
	a=0
	for i in list(s):
		if i == v:
			a+=1
	return a
result=0
for i in rei:
	if counter(i) == 1:
		result+=1
if result == 3:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] C = new int[N];
		int[][] A = new int[N][M];
		for(int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for(int j = 0; j < M; j++)
				A[i][j] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < 1<<N; i++) {
			int temp = 0;
			boolean ok = true;
			int[] u = new int[M];
		    for(int j = 0; j < N; j++) {
		        if ((1 & i >> j) == 1) {
		        	temp += C[j];
		        	for(int k = 0; k < M; k++)
		        		u[k] += A[j][k];
		        }
		    }
		    for(int j = 0; j < M; j++) {
		    	if(u[j] < X) {
		    		ok = false;
		    		break;
		    	}
		    }
		    if(ok)
		    	ans = Math.min(ans, temp);
		}
		System.out.println(ans == Integer.MAX_VALUE ? -1 : ans);
	}

}

Measured memory_bytes: 37648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll n,k,q;
cin>>n>>k>>q;
vector<int> v(n+1,0);
std::vector<int> Ans(n+1,0);
for(int i=0;i<q;i++)
{int temp;
 cin>>temp;
 v[temp]+=1;
}
for(int i=1;i<=n;i++)
{
  if(k-q+v[i]>0){cout<<"Yes\n";}
  else cout<<"No\n";
}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
void chmin(long long &a, long long b)
{
    if (a > b)
        a = b;
}
const long long INF = 1LL << 58;

int main()
{
    long long s;
    cin >> s;
    if (s <= 1e9)
        cout << 0 << " " << 0 << " " << 1 << " " << 0 << " " << 0 << " " << s << endl;
    else if (s == 1e18)
    {
        long long a = 1e9;
        cout << 0 << " " << 0 << " " << a << " " << 0 << " " << 0 << " " << a << endl;
    }
    else
    {
        long long a = 1e9;
        cout << 0 << " " << 0 << " " << a << " " << 1 << " " << a - (s % a) << " " << s / a + 1 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;

ll N,M;
vector<vector<ll>> G;
ll INF = 1e18;

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
    }
    ll ans = INF;
    vector<ll> ans_vec;
    for(int i=0;i<N;i++){
        queue<Q> q;
        vector<P> dist(N,{INF,-1});
        for(auto &e : G[i]) q.push({e,{0,-1}});
        while(!q.empty() && dist[i].first == INF){
            auto e = q.front();
            q.pop();
            ll n = e.first;
            if(dist[n].first != INF) continue;
            dist[n] = e.second;
            for(auto &f : G[n]){
                if(dist[f].first != INF) continue;
                q.push({f,{e.second.second+1,n}});
            }
        }
        if(dist[i].first == INF) continue;
        vector<ll> tmp;
        ll p = i;
        while(p != -1){
            tmp.push_back(p);
            p = dist[p].second;
        }
        if(ans > tmp.size()){
            ans_vec = tmp;
            ans = tmp.size();
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
        for(int i=ans-1;i>=0;i--) cout << ans_vec[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] xy = str.split(" ");
		int x = Integer.parseInt(xy[0]);
		int y = Integer.parseInt(xy[1]);
		int answer = 0;

		if(x<y){
			if(0<=x){
				answer = y - x;
			}else if(0<y){
				answer = Math.abs(Math.abs(y) - Math.abs(x)) + 1;
			}else{
				answer = y - x;
			}
		}else{
			if(0<y){
				answer = x - y + 2;
			}else if(0<=x){
				answer = Math.abs(Math.abs(x) - Math.abs(y)) + 1;
			}else{
				answer = x - y + 2;
			}
		}

		System.out.println(answer);

	}
}


Measured memory_bytes: 21204
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118

#include <iostream>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int, int> point;
int H, W;

bool isvalid(int i, int j) {
  return 0 <= i && i < H && 0 <= j && j < W;
}

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

int main() {
  while (cin >> H >> W && H) {
    char L[110][110];
    for (auto i=0; i<H; i++) {
      for (auto j=0; j<W; j++) {
	scanf(" %c", &L[i][j]);
      }
    }
    bool visited[110][110];
    fill(&visited[0][0], &visited[0][0]+110*110, false);
    int res = 0;
    for (auto i=0; i<H; i++) {
      for (auto j=0; j<W; j++) {
	if (!visited[i][j]) {
	  res++;
	  stack<point> S;
	  S.push(make_pair(i, j));
	  while (!S.empty()) {
	    int x = S.top().first;
	    int y = S.top().second;
	    S.pop();
	    if (!visited[x][y]) {
	      visited[x][y] = true;
	      for (auto k=0; k<4; k++) {
		int nx = x + dx[k];
		int ny = y + dy[k];
		if (isvalid(nx, ny) && !visited[nx][ny] 
		    && L[nx][ny] == L[i][j]) {
		  S.push(make_pair(nx, ny));
		}
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n", res);
  }
}

Measured memory_bytes: 1320
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b";
    }else if(a<b){
        cout<<"a < b";
    }else if(a==b){
        cout<<"a == b";
    }
    cout<<endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    long long n;
    cin>>n;
    long long a[n], b[n];
    for(int i=0;i<n;i++){    
        cin>>a[i];
        b[i] = a[i];
    }
    sort(b, b+n);
    long long first, second;
    if(b[n-1]==b[n-2]){
        for(int i=0;i<n;i++)    cout<<b[n-1]<<endl;
        return;
    }
    first = b[n-1];
    second = b[n-2];
    for(int i=0;i<n;i++){
        if(a[i]==first)     cout<<second<<endl;
        else                cout<<first<<endl;
    }
}
int main(){
    solve();
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[n],b[n];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	a[0]=b[n-1]=0;
	for(int i=1;i<n;i++)
	{
		if(s[i-1]=='W') a[i]=a[i-1]+1;
		else a[i]=a[i-1];
	}
	for(int i=n-2;i>=0;i--)
	{
		if(s[i+1]=='E') b[i]=b[i+1]+1;
		else b[i]=b[i+1];
	}
	int mi=2147483637;
	for(int i=0;i<n;i++)
	{
		int c=a[i]+b[i];
		if(c<mi) mi=c;
	}
	cout<<mi<<'\n';
	return 0;
}

Measured memory_bytes: 2948
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int d = sc.nextInt();
            if(d==0)break;
            for (int i = 1; i < 10; i++) {
                d -= sc.nextInt();
            }
            System.out.println(d);
        }
    }
}


Measured memory_bytes: 26160
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; ++i) cin>>A[i];
	sort(A.begin(), A.end());
	int n = A[N-1], r = 0;
	int mindiff = INT_MAX;
	for(int i=N-2; i>=0; --i){
		// int diff = abs(n/2 - A[i]);// |⌊n/2⌋ - ai|
		// if(mindiff > diff){ mindiff = diff; r = A[i]; }
		int diff = abs((n+2-1)/2 - A[i]);// |⌊n/2⌋ - ai|
		if(mindiff > diff){ mindiff = diff; r = A[i]; }
	}
	cout<< n <<" "<< r <<endl;
}


Measured memory_bytes: 640
using System;
namespace q1
{
    class q2
    {
        static void Main()
        {
          	string S = Console.ReadLine();	
			if(S[2]==S[3]&&S[4]==S[5])
            {
              Console.WriteLine("Yes");
            }
            else
            {
              Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 25820
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    long ans = 0;

    long x;
    scanf("%ld", &x);

    //printf("%ld ", x / 500);

    long tmp = (x / 500);
    ans += tmp * 1000;
    x -= tmp * 500;
    ans += (x / 5) * 5;

    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#define rep(i, n) for(i; i < n; i++)
using namespace std;

int main(void) {
  string s;
  cin >> s;
  string ans = "No";
  int i = 0;
  rep(i, s.size()) {
    if (s[i] == 'C') break;
  }
  rep(i, s.size()) {
    if (s[i] == 'F') {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pdd;

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
        a[i]%=k;
    }
    rept(i,1,n){
        a[i]+=a[i-1];
        a[i]%=k;
    }
    
    ll ans=0;
    map<ll,vector<ll>> mp;
    rep(i,n){
        ll s=a[i];
        ans+=mp[s].end()-upper_bound(mp[s].begin(),mp[s].end(),i-k);
        mp[s].push_back(i);

    }
    rep(i,mp[0].size()){
        if(mp[0][i]<k-1) ans++;
    }

    
    cout<<ans;

    return 0;
}

Measured memory_bytes: 23680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<numeric>

using namespace std;

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

    int sum = accumulate(vec.begin(), vec.end(), 0);

    if(sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define MAXN 2010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    ll a,  b, x, ans=0;
    cin >> a >> b >> x;

    ans = (b/x) - (a/x);
    a%x == 0? ans++ : ans;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n , m , c , counter = 0 , temp ;
	cin >> n >> m >> c ;
	int b[m];
	for(int i = 0 ; i < m ; i++)
		cin >> b[i] ;
	while(n-->0)
	{
		int lol = 0;
		for(int i = 0 ; i < m ; i++)
		{
			cin >> temp ;
			lol+=temp*b[i];
		}
		lol+=c;
		if(lol>0)
			counter++;
	}
	cout << counter ;
	return 0;
}

Measured memory_bytes: 256
#coding: UTF-8

a = int(input())
N = list(map(int, input().split()))

c = 0

for i in range(a - 1):
    for j in range(a-1, i,-1):
        if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp

for i in range(a - 1):
    print(N[i],end=' ')
print(N[a-1]);
print(c);

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


int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int counter = 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){
					counter++;
				}
			}
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int r;
	cin >> r;
	cout << r*r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a[100];
int main()
{
	int b,c;
	cin>>b>>c;
	for(int i=0;i<b;i++){
		cin>>a[i];
	}
	for(int j=0;j<b;j++){
		cout<<a[j]<<endl;
		cout<<a[j]<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NMAX 50

int compare(const void *a, const void *b);
int main(void)
{
  int t, i, x, y, z, n, k, sz = 0, cpe[6], cps[3] = {0};
  int fp[6][NMAX], cp[3][2*NMAX+1];
  long long res = 0;
  char map[2*NMAX][2*NMAX][2*NMAX] = {0};
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    for (t = 0; t < 6; t++) {
      scanf("%d", &fp[t][i]);
      cp[t%3][sz+t/3] = fp[t][i];
    }
    sz += 2;
  }
  cp[0][sz] = cp[1][sz] = cp[2][sz] = -1;
  for (t = 0; t < 3; t++) {
    qsort(cp[t], sz, sizeof(int), compare);
    for (i = 0; i < sz; i++) {
      cp[t][cps[t]++] = cp[t][i];
      while (cp[t][cps[t]-1] == cp[t][i+1]) i++;
    }
  }
  for (i = 0; i < n; i++) {
    for (t = 0; t < 6; t++) {
      int mid, dir = t % 3, lo = 0, hi = cps[dir] - 1;
      while (hi >= lo) {
        mid = (lo + hi) / 2;
        if (cp[dir][mid] > fp[t][i]) hi = mid - 1;
        else if (cp[dir][mid] < fp[t][i]) lo = mid + 1;
        else break;
      }
      cpe[t] = mid;
    }
    for (x = cpe[0]; x < cpe[3]; x++) {
      for (y = cpe[1]; y < cpe[4]; y++) {
        for (z = cpe[2]; z < cpe[5]; z++) {
          map[x][y][z]++;
        }
      }
    }
  }
  for (x = 0; x < cps[0]; x++) {
    for (y = 0; y < cps[1]; y++) {
      for (z = 0; z < cps[2]; z++) {
        if (map[x][y][z] >= k) {
          res += (long long)(cp[0][x+1] - cp[0][x]) * (cp[1][y+1] - cp[1][y]) *(cp[2][z+1] - cp[2][z]);
        }
      }
    }
  }
  printf("%lld\n", res);
}

int compare(const void *a, const void *b) {
  int ta = *(int*)a, tb = *(int*)b;
  return ta - tb;
}



Measured memory_bytes: 2704
#include<iostream>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  long long n, k; cin >> n >> k;
  vector<double> vec(n), expval(n);
  double ans = 0, comp = 0;;
  for(int i=0; i<n; i++)  {
    cin >> vec[i];
    expval[i] = (vec[i]+1)/2;
  }
  for(int i=0; i<k; i++)  comp += expval[i];
  ans = comp;
  for(int i=k; i<n; i++){
    comp -= expval[i-k];
    comp += expval[i];
    ans = max(ans, comp);
  }

  printf("%.6lf\n", ans);
}

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int k=0,l=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')k++;
        else
        {
            if(k>0)
             l=k;
            k=0;
        }
    }
    if(k>0) l=k;
    cout<<l;
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String s = sc.next();

        if (s.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }



    }
}


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

using namespace std;

int main(void)
{
	int n, t;
	cin >> n >> t;
	vector<int> a(n), b(n);
	vector<int> arev(n), brev(n);
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) {
		arev[i] = a[n-1-i];
		brev[i] = b[n-1-i];
	}

	long long dp1[n-1][t]; // 0 ~ n-2
	long long dp2[n-1][t]; // n-1 ~ 1
	for (int j = 0; j < t; j++) {
		if (j < a[0])
			dp1[0][j] = 0;
		else
			dp1[0][j] = b[0];
	}
	for (int i = 1; i < n-1; i++) {
		for (int j = 0; j < t; j++) {
			if (j-a[i] < 0) {
				dp1[i][j] = dp1[i-1][j];
				continue;
			}
			dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-a[i]]+b[i]);
		}
	}

	for (int j = 0; j < t; j++) {
		if (j < arev[0])
			dp2[0][j] = 0;
		else
			dp2[0][j] = brev[0];
	}
	for (int i = 1; i < n-1; i++) {
		for (int j = 0; j < t; j++) {
			if (j-arev[i] < 0) {
				dp2[i][j] = dp2[i-1][j];
				continue;
			}
			dp2[i][j] = max(dp2[i-1][j], dp2[i-1][j-arev[i]]+brev[i]);
		}
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long max = 0;
		for (int j = 0; j < t; j++) {
			long long tmp = 0;
			if ((i-1) >= 0)
				tmp += dp1[i-1][j];
			if ((n-2-i) >= 0 && (t-1-j)>=0)
				tmp += dp2[n-2-i][t-1-j];
			tmp += b[i];

			if (tmp > max)
				max = tmp;
		}
		if (ans < max)
			ans = max;
	}
	cout << ans << endl;

	return 0;
}

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

            #define FOR(i,a,b) for (int i = (a); i < (b); i++)
            #define rep(i,n) FOR(i,0,n)
            #define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
            #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
            #define FILL(a,value) memset(a, value, sizeof(a))

            #define SZ(a) (int)a.size()
            #define ALL(a) a.begin(), a.end()
            #define PB push_back
            #define MP make_pair
            #define SC second
            #define FS first

            typedef long long LL;
            typedef vector<int> VI;
            typedef vector<LL>VL;
            typedef vector <bool >VB;
            typedef vector<vector<int>>WI;
            typedef vector<vector<LL>>WL;
            typedef pair<int, int> PII;
            typedef pair<double, double> PDD;

            const double PI = acos(-1.0);
            const int INF = 1000 * 1000 * 1000 + 7;
            const LL LINF = LL(1e12);
            const int MAS = int(1e5 * 3 + 1);
            const double EPS = 1e-7;
            const LL MAX = 4294967296;
            const LL MOD =LL(1e9+7);
           int a[MAS];
            int main()
            {

             int n ;
             cin >> n;
             string s;
             cin >> s;
             LL sum = 1;
             rep(i,n-1)
             {
                 if(s[i]!=s[i+1])sum++;
             }
             cout << sum ;

            }


Measured memory_bytes: 512
int main() {

    int a, i;
    char s[101];

    scanf("%d", &a);
    scanf("%s", s);

    for (i = 1; s[i] != '\0'; ++i);

    if (a >= i) {
        printf("%s", s);

    }
    else {
        printf("%.*s", a, s);
        printf("...");
    }
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    long long x{};
    std::cin >> x;

    long long result{};
    result += (x / 500) * 1000;
    x %= 500;
    result += (x / 5) * 5;
    std::cout << result << std::endl;
    return 0;
}


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

#define INF (INT64_MAX/4)
#define MOD (1000000000+7)
#define MAX 100000

long long H, W, A, B;

long long fac[MAX + MAX + 1];
long long ifac[MAX + MAX + 1];

long long mpow( long long x, long long n )
{
	long long ans = 1;
	while( n != 0 ) {
		if(n&1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

long long comb( long long a, long long b )
{
    if( a == 0 && b == 0 ) {
		return 1;
	}
    if( a < b || a < 0 ) {
		return 0;
	}
	long long tmp = ifac[a - b] * ifac[b] % MOD;
	return tmp * fac[a] % MOD;
}

int main() {
	cin >> H >> W >> A >> B;

	fac[0] = 1;
	ifac[0] = 1;
	for( long long i = 0; i < H + W; i++ ) {
        fac[i + 1] = fac[i] * ( i + 1 ) % MOD;
        ifac[i + 1] = ifac[i] * mpow( i + 1, MOD - 2 ) % MOD;
    }

	long long ans = 0;
	for( long long i = B + 1; i <= W; i++ ) {
		int ii = i - B - 1;
		int x1 = i - 1;
		int y1 = H - A - ii - 1;
		int x2 = W - i;
		int y2 = A + ii;
		ans += ( comb( x1 + y1, x1 ) * comb( x2 + y2, x2 ) ) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    vector<int>v;
    int n;
    cin>>n;
    int counter=1;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        if(temp==counter)
            counter++;
        else
            ans++;
    }
    if(ans!=n)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int H, W, Sx, Sy, Gx, Gy;
  cin >> H >> W >> Sx >> Sy >> Gx >> Gy;
  vector<vector<int>> num(1010,vector<int>(1010, -2));//そのマスにワープ何回で辿り着けるか記録する
  
  
  char s;
  rep(i,H){
    rep(j,W){
      cin >> s;
      if(s == '.'){
        num[i+1][j+1] = -1;
      }
    }
  }
  
  //BFSの準備
  queue<pair<int,int>> que0;  
  queue<pair<int,int>> que;
  
  que.push(make_pair(Sx,Sy));
  que0.push(make_pair(Sx,Sy));
  num[Sx][Sy] = 0;
  int p = 0;
  
  while(!que.empty()){
  
  while(!que.empty()){
    pair<int,int> v = que.front();
    que.pop();
    
    int x,y;
    tie(x,y) = v;
    
    if(num[x+1][y]==-1){
      num[x+1][y]=p;
      que0.push(make_pair(x+1,y));
      que.push(make_pair(x+1,y));
    }
    if(num[x-1][y]==-1){
      num[x-1][y]=p;
      que0.push(make_pair(x-1,y));
      que.push(make_pair(x-1,y));
    }
    if(num[x][y+1]==-1){
      num[x][y+1]=p;
      que0.push(make_pair(x,y+1));
      que.push(make_pair(x,y+1));
    }
    if(num[x][y-1]==-1){
      num[x][y-1]=p;
      que0.push(make_pair(x,y-1));
      que.push(make_pair(x,y-1));
    } 
  }
    
  p++;
  int t = que0.size();
  for(int i = 0; i<t;i++){
    pair<int,int> v = que0.front();
    que0.pop();
    int x,y;
    tie(x,y) = v;
    for(int i = max(0,x-2); i<=min(1010, x+2); i++){
      for(int j = max(0,y-2); j<=min(1010, y+2); j++){
        if(num[i][j]==-1){
          num[i][j]=p;
          que.push(make_pair(i,j));
          que0.push(make_pair(i,j));
        }
      }
    }
  }
    
  }
 
  cout << num[Gx][Gy] << endl;
}

      
      
       






Measured memory_bytes: 7556
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

int n,l,ans=12345678;
int dist[2005],used[2005];
vector<int> nei[2005];
queue<int> q;

void BFS(){
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=0;i<nei[x].size();i++){
			if(used[nei[x][i]]) continue;
			used[nei[x][i]]=1;
			q.push(nei[x][i]);
			if(dist[nei[x][i]]>dist[x]+2) dist[nei[x][i]]=dist[x]+2;
		}
	}
}

int main(){
	cin>>n>>l;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			used[j]=0;
			dist[j]=12345678;
		}
		dist[i]=0;
		used[i]=1;
		q.push(i);
		BFS();
		int res=0;
		for(int j=1;j<=n;j++) if(dist[j]>l){
			res++;
		}
		ans=min(ans,res);
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<nei[i].size();j++){
			for(int k=1;k<=n;k++){
				used[k]=0;
				dist[k]=12345678;
			}
			dist[i]=1;
			dist[nei[i][j]]=1;
			used[i]=1;
			used[nei[i][j]]=1;
			q.push(i);
			q.push(nei[i][j]);
			BFS();
			int res=0;
			for(int j=1;j<=n;j++) if(dist[j]>l) res++;
			ans=min(ans,res);
		}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vi v(n);
    ll ans = 0;
    loop(i, n) {
        cin >> v[i];
        if (i & 1)ans -= v[i] * 2;
        else ans += v[i] * 2;
    }

    ans >>= 1;
    cout << ans;
    loop(i, n - 1) {
        v[i] -= ans / 2;
        ans = v[i] * 2;
        cout << " " << ans;
    }

    cout << endl;

    return 0;
}

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

int main() {
    string W;
    cin >> W;

    int counter = 0;
    while(true){
        string S; cin >> S;
        if(S == "END_OF_TEXT")break;
        rep(i, S.size()){
            S[i] = tolower(S[i]);
        }
        if(S == W)counter++;
    }

    cout << counter << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll f[N];
void solve(){
    ll n, m;
    cin >> n  >> m;
    if(abs(n - m) > 1){
        cout << 0;
        return;
    }
    if(n == m) {
        // 2 * n! * m!
        cout << (2 * f[n] * f[m]) % MOD;
    }
    else {
        cout << (f[n] * f[m]) % MOD; 
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    f[0] = 1;
    for(int i = 1; i < N; ++i)
        f[i] = (f[i - 1] * i) % MOD;
    while(t--)solve();
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import collections


def solve(N: int, M: int, A: "List[int]"):
    a = [i % M for i in A]
    b = [0]
    nums = collections.defaultdict(int)
    for i in range(len(a)):
        n = (b[i] + a[i]) % M
        b.append(n)
    for i in b:
        nums[i] += 1
    sum = 0
    for k in nums:
        c = nums[k]
        if c > 1:
            sum += c * (c - 1) // 2
    # print(nums)
    print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23592
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


int n, k, s;
int ans;


void calc(int sum, int b, int e){
	if(sum > s){
		return;
	}
	if(e == k){
		if(sum == s) ans++;
		return;
	}
	for(int i = b + 1; i + sum <= s && i <= n; i++){
		calc(sum + i, i, e + 1);
	}
}

int main(){
	while(cin>>n>>k>>s){
		if(n == 0 && k == 0 && s == 0) break;
		ans = 0;
		calc(0, 0, 0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
while True:
    n,x = map(int,input().split())
    if n==x==0:
        exit()
    count = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if i+1+j+1+k+1 == x:
                    count += 1
    print(count)


Measured memory_bytes: 5596
#include <stdio.h>
int main()
{
  int max,min,N,a[100],i,j;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&a[i]);
    }
  max=a[0];
  min=a[0];
  for(i=0;i<N;i++)
    {
      if(max<a[i])max=a[i];
      if(min>a[i])min=a[i];
    }
  printf("%d\n",max-min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    string s;cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int test;
	//cin>>test;
	test=1;
	while(test--){
		int k;
		cin>>k;
		string s;
		cin>>s;
		string ans="";
		if(s.size()<=k){ans=s;}
		else{
			for(int i=0;i<k;i++){ans+=s[i];}
			ans+="...";
		}
		cout<<ans<<endl;
		
	}
		
}
	



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;

  vector<int> v;

  double ans=0;

  rep(i,N){
    int vv;
    cin>>vv;
    v.push_back(vv);
  }

  SORT(v);

  ans=v[0];

  reps(i,1,N){
    ans+=v[i];
    ans=ans/2;
  }

  std::cout << std::fixed;
  std::cout << std::setprecision(8) << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(input())
a =0
if n%2 == 0:
  m = int(n/2)
  for i in range(m):
    if l[i] != l[i+m]:
      a = 1
else:
  a = 1

if a == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
function main(input) {
  var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));

  var count = 0;
  while(nums.every((n) => (n % 2) === 0)) {
      count++;
      nums = nums.map((n) => n / 2);
  }

  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define rep(i,n) for (int i=0; i<(n);++i)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main() {
	int n, m;
	ll x;
	int a[12][12];

	cin >> n >> m>>x;
	vector<ll> c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			cin >>  a[i][j];
		}
	}
	ll ans = INF;
	rep(s, 1 << n) {
		ll cost = 0;
		vector<int>d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m) d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j, m)if (d[j] < x) ok = false;
		if (ok) ans = min(ans, cost);
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

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

using namespace std;

const int N = 100100;
int arr[N];
int prfs[N];

int main() {
    arr[0]=arr[1]=1;
    int cnt = 0;
    for (int i=2; i<N; ++i) {
        if (arr[i] == 0) {
            if (arr[(i+1)/2] == 0) cnt++;
            for (int d=i+i; d<N; d+=i) {
                arr[d] = 1;
            }
        }
        prfs[i] = cnt;
    }

    // for (int i=0;i<20;++i) {
    //     cout << prfs[i] << " ";
    // } cout << endl;
    // for (int i=0;i<20;++i) {
    //     cout << arr[i] << " ";
    // } cout << endl;

    int q; cin >> q;
    for (int i=0; i<q; ++i) {
        int l, r; cin >> l >> r;
        cout << prfs[r]-prfs[l-1] << endl;
    }

    return {};
}


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

#define int long long
#define pii pair<int,int>
#define pqi priority_queue<int>
#define pb push_back()
#define INF 1000000000000000000

#define float long double
#define pi acos(-1)

const int modu= (1e9)+7;

void testCase(int ti){
    cout<<"Case "<<ti<<": ";
}

int bigmod(int n,int p){
    if(p==0) return 1;
    int x=bigmod(n,p/2)%modu;
    x=(x*x)%modu;
    if(p%2) return (x*n)%modu;
    return x;
}

int modInverse(int a){
    return bigmod(a,modu-2)%modu;
}

void debug(string pr,vector<int> var,bool out=true){
    #ifdef OFFLINE
        ofstream fl;
        fl.open("debug.txt");
        fl<<pr;
        for(int i=0;i<var.size();i++) fl<<" "<<var[i];
        fl<<endl;
        fl.close();
    if(out){
        cout<<pr;
        for(int i=0;i<var.size();i++) cout<<" "<<var[i];
        cout<<endl;
    }
    #endif
}

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
}

void defInit(){
    faster();
    #ifdef OFFLINE
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
    #endif
}

int add(int x,int y){
    int z =(x%modu + y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}

int mul(int x,int y){
    int z = (x%modu * y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}

//starts here
const int MaxSize=1;

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 


int32_t main(){
    defInit();
    //Now I will start writing codes and start preparation to get errors
    string a,b;
    cin>>a>>b;
    lcs(a,b,a.size(),b.size());
    return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()
{
    int n, h, w;
    cin >> n >> h >> w;
    cout << ((n - h) + 1) * ((n - w) + 1) << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        string s;
        cin>>s;
        if (s.size()<6||s.size()%2!=0){
            cout<<"NA"<<endl;
        } else {
            if (s.at(0)=='>'&&s.at(1)=='\''&&s.at(s.size()-1)=='~') {
                string tmp=s.substr(2,s.size()-3);
                string front=tmp.substr(0,(tmp.size()-1)/2);
                string back=tmp.substr((tmp.size()+2)/2,(tmp.size()-1)/2);
                if (front==back) {
                    cout<<"A"<<endl;
                } else {
                    cout<<"NA"<<endl;
                }
            } else if (s.at(0)=='>'&&s.at(1)=='^'&&s.at(s.size()-1)=='~'&&s.at(s.size()-2)=='~') {
                string center=s.substr(2,s.size()-4);
                for (int j=0;j<center.size();j+=2) {
                    if (center.at(j)!='Q'||center.at(j+1)!='=') {
                        cout<<"NA"<<endl;
                        break;
                    }
                    if (j==center.size()-2) {
                        cout<<"B"<<endl;
                    }
                }
            } else {
                cout<<"NA"<<endl;
            }
        }
    }
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL p;

signed main() {
    cin >> N;
    REP(i, N) p.emplace_back(IN());
    ll ans = 0;
    REP(i, N) {
        if(p[i] == i + 1) {
            ans++;
            swap(p[i], p[i + 1]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1400
c = []
for i in range(3):
    c.append(list(map(int, input().split())))

x = [0] * 3
y = [0] * 3

for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]

for i in range(3):
    for j in range(3):
        if x[i] + y[j] != c[i][j]:
            print('No')
            exit()

print('Yes')


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

int main(){
    string S, T;  cin >> S >> T;
    int N = S.length();
    map<char, char> mp;
    for(int i=0; i<N; i++){
        mp[S[i]] = T[i];
    }
    vector<int> cnt(26, 0);
    for(auto p : mp){
        if(cnt[p.second - 'a'] > 0){
            cout << "No" << endl;
            return 0;
        }
        cnt[p.second - 'a']++;
    }
    for(int i=0; i<N; i++){
        if(mp[S[i]] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 904
package main

import "fmt"

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		h -= a
		if h <= 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}


Measured memory_bytes: 5504