akhauriyash/Code-Regression huggingface dataset:
import scala.annotation.tailrec
import scala.collection.{immutable, mutable}


object Main extends App {

  import scala.io.StdIn._

  val idx = readLong()
  var min = 1L
  var max = idx
  while (min < max) {
    val mid = (min + max) / 2
    if (calDigitUnder(mid) < idx) min = mid + 1
    else max = mid
  }
  val rest = idx - calDigitUnder(min - 1) - 1
  println(toSequence(min, min + 20).substring(rest.toInt, rest.toInt + 20))
  def toSequence(from: Long, until: Long): String = {
    (from until until).map{
      case n if n % 15 == 0 ⇒ "FizzBuzz"
      case n if n % 3 == 0 ⇒ "Fizz"
      case n if n % 5 == 0 ⇒ "Buzz"
      case n ⇒ n.toString
    }.mkString("")
  }

  def calDigitJustDigit(digit: Int): Long = {
    val value = power(10, digit) - 1
    val nonStr = value - value / 3 - value / 5 + value / 15
    val underValue = value / 10
    val underNonStr = underValue - underValue / 3 - underValue / 5 + underValue / 15
    (nonStr - underNonStr) * digit + (value / 3 - underValue / 3) * 4 + (value / 5 - underValue / 5) * 4
  }

  def calDigitUnder(number: Long): Long = {
    val digit = calDigit(number)
    val under = power(10, digit - 1) - 1
    val underDigit = (1 until digit).map(calDigitJustDigit).sum
    val underStr = under / 3 + under / 5 - under / 15
    val str = number / 3 + number / 5 - number / 15 - underStr
    val nonStr = number - under - str
    underDigit + nonStr * digit + (number / 3 - under / 3 + number / 5 - under / 5) * 4
  }

  def calDigit(number: Long): Int = {
    if (number < 10) 1 else 1 + calDigit(number / 10)
  }

  def power(base: Long, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ power(base * base, exp / 2) * power(base, exp % 2)
    }
  }
}


Measured memory_bytes: 44664
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

const int N(1e5 + 10);
std::set<std::pair<int, int> > P[10];
std::set<std::pair<int, int> > B;
int n, H, W, a[N], b[N];
long long ans[10];

int main()
{
	scanf("%d%d%d", &H, &W, &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", a + i, b + i);
	for (int i = 1; i <= n; i++) B.insert(std::make_pair(a[i], b[i]));
	for (int t = 1; t <= n; t++)
	{
		int dx = std::max(a[t] - 2, 1), dy = std::max(b[t] - 2, 1);
		for (int x = dx; x <= a[t] && x + 2 <= H; x++)
			for (int y = dy; y <= b[t] && y + 2 <= W; y++)
			{
				int cnt = 0;
				for (int i = x; i < x + 3; i++)
					for (int j = y; j < y + 3; j++)
						cnt += (B.find(std::make_pair(i, j)) != B.end());
				P[cnt].insert(std::make_pair(x, y));
			}
	}
	ans[0] = 1ll * (H - 2) * (W - 2);
	for (int i = 1; i <= 9; i++) ans[i] = P[i].size(), ans[0] -= ans[i];
	for (int i = 0; i <= 9; i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 47872
#include<stdio.h>

int main(){
	int a, b, temp, digit;
	while(scanf("%d %d", &a, &b) == 2)
	{
		temp = a + b;
		digit = 1;
		while(temp >= 10)
		{
			digit++;
			temp /= 10;
		}
		printf("%d\n", digit);
	}
	
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) {
		cout << "Left" << endl;
	}
	if (A + B < C + D) {
		cout << "Right" << endl;
	}
	else if (A + B == C + D) {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int i;
	int asumikana = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int a;
		if (scanf("%d", &a) != 1) return 1;
		while (a % 2 == 0) {
			asumikana++;
			a /= 2;
		}
	}
	printf("%d\n", asumikana);
	return 0;
}


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

using ll = long long;
using P = pair<int, int>;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, b;
  cin >> a >> b;

  if (a == b) cout << a + b << endl;
  else cout << max(a, b) + max(a, b) - 1 << endl;
  return 0;
}


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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]+=1;
    }

    int najveci = 0;

    for(auto x:m)
    {
        najveci = max(najveci, x.se);
    }

    for(map<string, int>::iterator it = m.begin(); it != m.end(); ++it)
    {
        if(it->se == najveci)
        {
            cout << it->fi << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 25216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            int n = ReadAndParseInt();
            var t = ReadAndParseIntArr();
            int m = ReadAndParseInt();
            var p = new int[m];
            var x = new int[m];
            for(int i=0;i<m;++i)
            {
                var o = ReadAndParseIntArr();
                p[i] = o[0];
                x[i] = o[1];
            }
            int sum = t.Sum();
            for(int i=0;i<m;++i)
            {
                int idx = p[i] - 1;
                int ans = sum + x[i] - t[idx];
                Console.WriteLine(ans);
            }
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main(){
	int numData;
	int a[100];
	cin >> numData;
	for ( int i = 0; i < numData; i ++){
		cin >> a[i];
	}
	for ( int i = 0; i < numData-1; i++){
		cout << a[i] << " ";
	}
	cout << a[numData - 1] << endl;
	for ( int i = 1; i < numData; i++ ){
		int v = a[i];
		int j = i-1;
		while ( a[j+1] < a[j] && j >= 0){
			a[j+1] = a[j];
			a[j] = v;
			j--;
		}
		for ( int i = 0; i < numData-1; i++){
			cout << a[i] << " ";
		}
		cout << a[numData - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
while n = gets.chomp.to_i
break if n == 0

ary = Array.new(n).map{Array.new(n,0)}

x = n / 2
y = (n + 1) / 2
k = 1
ary[y][x] = k

while k  < n * n
x += 1
x = 0 if x >= n
y += 1
y = 0 if y >= n

while ary[y][x] > 0
x -= 1
x = n - 1 if x < 0 
y += 1
y = 0 if y >= n 
end
k += 1
ary[y][x] = k
end
puts ary.map{|i| i.map{|j| sprintf("%4d",j)}.join}
end



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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> u, d;
    long check_s{0};
    for(unsigned long i{0}; i < N; ++i){
        string S;
        cin >> S;
        long t{0}, p{0};
        for(const auto& c : S)if(c & 1)p = min(p, --t);
        else++t;
        if(t >= 0)u.emplace_back(p, t);
        else d.emplace_back(p - t, -t);
        check_s += t;
    }
    if(check_s)return 0 & puts("No");
    sort(u.begin(), u.end(), greater<>());
    sort(d.begin(), d.end(), greater<>());
    {
        priority_queue<unsigned long> pq;
        long now{0}, cnt{0};
        auto it = u.begin();
        while(cnt < u.size()){
            while(it != u.end() && now + it -> first >= 0){
                pq.emplace(it -> second);
                ++it;
            }
            if(pq.empty())return 0 & puts("No");
            now += pq.top();
            pq.pop();
            ++cnt;
        }
    }
    {
        priority_queue<unsigned long> pq;
        long now{0}, cnt{0};
        auto it = d.begin();
        while(cnt < d.size()){
            while(it != d.end() && now + it -> first >= 0){
                pq.emplace(it -> second);
                ++it;
            }
            if(pq.empty())return 0 & puts("No");
            now += pq.top();
            pq.pop();
            ++cnt;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 26960
s=input()
t=input()

dic={}
for i in range(len(s)):
    if s[i] not in dic:
        dic.setdefault(s[i],t[i])
    else:
        if t[i]!=dic[s[i]]:
            print("No")
            exit()

dic={}
for i in range(len(t)):
    if t[i] not in dic:
        dic.setdefault(t[i],s[i])
    else:
        if s[i]!=dic[t[i]]:
            print("No")
            exit()
            
print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
int a,b,c,d,e;
  cin >>a>>b>>c>>d>>e;
  int iti = 10;
  if(a%10 != 0) iti = min(a%10,iti);
  if(b%10 != 0) iti = min(b%10,iti);
  if(c%10 != 0) iti = min(c%10,iti);
  if(d%10 != 0) iti = min(d%10,iti);
  if(e%10 != 0) iti = min(e%10,iti);
  int ans =0;
  if(a%10 == 0) ans += a;
  else ans += ((a/10)+1)*10;
  if(b%10 == 0) ans += b;
  else ans += ((b/10)+1)*10;
  if(c%10 == 0) ans += c;
  else ans += ((c/10)+1)*10;
  if(d%10 == 0) ans += d;
  else ans += ((d/10)+1)*10;
  if(e%10 == 0) ans +=e;
  else ans += ((e/10)+1)*10;
  ans = ans - 10 + iti;
  cout << ans <<endl;
}
  


Measured memory_bytes: 256
n = int(input())
count = 0
ans = 0
for i in range(n):
  a, b = map(int,input().split())
  if (a == b):
    count = count + 1
    if (count == 3):
      ans = 1
  else:
    count = 0
if (ans == 1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 10) write(b);
    else write(b + 100 * (10 - a));
}

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


using namespace std;


int main()
{
	int N, M, a,c, b[60] = {};
	cin >> N >> M;
	for (int i = 1; i <=  M; i++) {
		cin >> a >> c;
		b[a] ++;
		b[c] ++;
	}
	for (int i = 1; i <= N; i++) {
		cout << b[i] << endl;
	}
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s,t;
string res;

int main(){
	cin>>s>>t;
	int n=s.size();
	res=s;
	for (int i=0;i<n;i++){
		for (int j=n-1;j>=0;j--){
			if (res==t){
				cout<<"Yes"<<endl;
				return 0;
			}else{
				string x=res;
				res[0]=s[j];
				for (int k=1;k<n;k++){
					res[k]=x[k-1];
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int x,a,b; 
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)){ cout << "A" << endl; } else { cout << "B" << endl; }
  return 0;
}


Measured memory_bytes: 256
n,a,b=[int(i) for i in input().split()]
mod=10**9+7
ans=pow(2,n,mod)-1
ans=ans%mod

def inv(x):
    return(pow(x,mod-2,mod))
x=1
k=1
while x<max(a,b)+1:
    k=(k*(n-x+1))*inv(x)
    k=k%mod
    if x==a or x==b:
        ans-=k
    x+=1
print(ans%mod)


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

// A - We Love Golf
int main() {
    int K, A, B;
    cin >> K >> A >> B;

    int min = (A + K - 1) / K;
    int result = K * min;
    if (A <= result && result <= B) {
        cout << "OK";
    } else {
        cout << "NG";
    }

}


Measured memory_bytes: 3608
def main():
    n = int(input())
    a = list(map(int, input().split()))

    ret = 0
    for i in range(n):
        if i % 2 == 0 and a[i] % 2 == 1:
            ret += 1
    print(ret)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
n=int(input())
x=[10000]*(n+2)
x[0]=0
a=[6**i for i in range(1,7)]
b=[9**i for i in range(1,6)]
c=[1]
c=a+b+c
c.sort()
for i in range(1,n+2):
    for j in c:
        if i-j>=0:
            x[i]=min(x[i],x[i-j]+1)
        else:
            break
print(x[n])

Measured memory_bytes: 73952
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

int main()
{
	string s;
	cin>>s;
	int k=(s.size()+1)/2;
	while(s[k]==s[k-1] && s[k]==s[s.size()-k-1])k++;
	cout<<k<<endl;
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define bit(x) (x & 1)
#define inv(x) (1 - (x & 1))
using namespace std;

int dpn[2][3010]; /// normal
int dps[2][3010]; /// final
int n, m;

void add(int & a, int b)
{
    a = a + b;
    if (a > mod)
        a -= mod;
    if (a < 0)
        a += mod;
}

int main()
{
    cin >> n >> m;
    for (int i(0); i <= n; i++)
        dpn[0][i] = 1;

    for (int i(1); i <= m; i++) {
        for (int j(0); j <= n; j++) {
            /// nr o ways made i turns, j balls 0 left
            dpn[bit(i)][j] = dps[bit(i)][j] = 0;

            add(dpn[bit(i)][j], dpn[inv(i)][j + 1]); /// 00
            add(dps[bit(i)][j], dps[inv(i)][j + 1]);
            if (j == 0) {
                add(dps[bit(i)][j], dpn[inv(i)][j + 1]);
                add(dpn[bit(i)][j], -dpn[inv(i)][j + 1]);
            }

            if (j) {
                add(dpn[bit(i)][j], dpn[inv(i)][j - 1]); /// 11
                add(dps[bit(i)][j], dps[inv(i)][j - 1]);
                if (j == 1) {
                    add(dps[bit(i)][j], dpn[inv(i)][j - 1]);
                    add(dpn[bit(i)][j], -dpn[inv(i)][j - 1]);
                }

            }

            if (j < n) { /// 10
                add(dpn[bit(i)][j], dpn[inv(i)][j]);
                add(dps[bit(i)][j], dps[inv(i)][j]);
                if (j == 0) {
                    add(dps[bit(i)][j], dpn[inv(i)][j]);
                    add(dpn[bit(i)][j], -dpn[inv(i)][j]);
                }
            }

            if (j) { /// 01
                add(dpn[bit(i)][j], dpn[inv(i)][j]);
                add(dps[bit(i)][j], dps[inv(i)][j]);
                if (j == 1) {
                    add(dps[bit(i)][j], dpn[inv(i)][j]);
                    add(dpn[bit(i)][j], -dpn[inv(i)][j]);
                }
            }
        }
    }

    int ans(0);

    for (int i(0); i <= n; i++)
        add(ans, dps[bit(m)][i]);

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,C;

signed main(){
	cin>>A>>B>>C;
	if(A+B+C>=22){
		cout<<"bust"<<endl;
	}
	else{
		cout<<"win"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    int r, c;
    int h, w;
    cin >> r >> c >> h >> w;
    int ans = r * c;
    ans -= h * c;
    r -= h;
    ans -= w * r;
    cout << ans, nl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int square_a_line, square_b_line, i, j, k, l, flag;
  scanf("%d %d", &square_a_line, &square_b_line);
  char array[square_a_line];
  int square_a[square_a_line][square_a_line], square_b[square_b_line][square_b_line];
  for(i = 0; i < square_a_line; i++) {
    scanf("%s", array);
    for(j = 0; j < square_a_line; j++) {
      square_a[i][j] = (array[j] == '#')? 0 : 1;
    }
  }
  for(i = 0; i < square_b_line; i++) {
    scanf("%s", array);
    for(j = 0; j < square_b_line; j++) {
      square_b[i][j] = (array[j] == '#')? 0 : 1;
    }
  }
  for(i = 0; i <= square_a_line - square_b_line; i++) {
    if(flag == square_b_line * square_b_line) {
      break;
    }
    for(j = 0; j <= square_a_line - square_b_line; j++) {
      if(flag == square_b_line * square_b_line) {
        break;
      }
      flag = 0;
      for(k = 0; k < square_b_line; k++) {
        for(l = 0; l < square_b_line; l++) {
          if(square_a[i+k][j+l] == square_b[k][l]) {
            flag++;
          } else {
            break;
          }
        }
      }
    }
  }
  if(flag == square_b_line * square_b_line) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, a, total int
	fmt.Scanf("%d\n", &n)
	bucket := make([]int, 100000)

	for i := 0; i < n; i++ {
		if i != n-1 {
			fmt.Scanf("%d", &a)
		} else {
			fmt.Scanf("%d\n", &a)
		}
		bucket[a-1]++
		total += a
	}

	var q, b, c int
	fmt.Scanf("%d\n", &q)
	out := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scanf("%d %d\n", &b, &c)
		total += (c - b) * bucket[b-1]
		out[i] = total
		bucket[c-1] += bucket[b-1]
		bucket[b-1] = 0
	}

	for _, j := range out {
		fmt.Println(j)
	}

}


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

 
int main(){
  int N;
  string str;
  cin >> N;
  cin >> str;

  string tmp;
  int cnt = 0;
  string s1,s2,s3;
  for(int i = 0; i < N-2; i++){
    s1 = str[i];
    s2 = str[i+1];
    s3 = str[i+2];
    tmp = s1.append(s2).append(s3);
    if(tmp == "ABC") cnt++;
  }

  cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
typedef vector<ll> vl;
set <int> st;
vector<int> videos(105);
double now=0;
queue<int> num;
ll n,k,ans=-1;
ll s[200005];
ll ss[200005];
ll x[200005];
ll a[200005];
ll b[200005];
ll bmin=2e18;
int main(int argc,char const* argv[])
{
  cin >> n; 
  for(int i=0;i<n;i++)
    {
      if(i!=0) ss[i]+=ss[i-1];
      cin >> x[i] >> s[i];
      ss[i]+=s[i];
      a[i]=-x[i];
      b[i]=-x[i];
    }
  for(int i=0;i<n;i++)
    {
      if(i!=0) 
	{
	  a[i]+=ss[i-1];
	}
      b[i]=a[i];
      a[i]+=s[i];
    }
  for(int i=0;i<n;i++)
    {
      if(b[i]<bmin) bmin=b[i];
      if(a[i]-bmin>ans) ans=a[i]-bmin;
    }

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


Measured memory_bytes: 8064
#include <cstdio>
#define rep(i,n) for(int(i)=0; (i)<(n); (i)++)

int main(){
    int A, B, C, D;
    scanf("%1d%1d%1d%1d", &A, &B, &C, &D);

    rep(i,2) rep(j,2) rep(k,2)
        if( A + (i?-B:B) + (j?-C:C) + (k?-D:D) == 7 ){
            char ope[2] = {'+', '-'};
            printf("%d%c%d%c%d%c%d=7\n", A, ope[i], B, ope[j], C, ope[k], D);
            return 0;
        }
}


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

int n, k;
bool d[10];

bool flag(int a) {
	int digit = 10;
	while (true) {
		if (a < digit / 10)break;
		int digitnum = (a - a / digit*digit) / (digit / 10);
		if (d[digitnum])return false;
		digit *= 10;
	}

	return true;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		d[a] = true;
	}

	while (true) {
		if (flag(n))break;
		n++;
	}

	cout << n << endl;
}

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

int i = 0, add;
string s[3];
bool f() {
	if (s[0].size() == 0 || s[1].size() == 0 || s[2].size() == 0) return false;
	else return true;
}
int main() {
	cin >> s[0] >> s[1] >> s[2];
	riv(s[0]);
	riv(s[1]);
	riv(s[2]);
	i = add = s[0][s[0].size() - 1] - 'a';
	s[0].pop_back();
	while (1) {
		if (s[i].size() != 0) {
			add = s[i][s[i].size() - 1] - 'a';
			s[i].pop_back();
			i = add;
		}
		else {
			cout << char('A' + i) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    rep(i,n-1){
        cin>>v[i];
    }
  
    ll ans=0;
    
    rep(i,n){
        if(i==0)ans+=v[i];
        else if(i==n-1)ans+=v[n-2];
        else ans+=min(v[i],v[i-1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()-1) {
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
}


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005

//int memo[105][1000005] = {0};
#define inf 				1e9+1

int main()
{
	
	int n,w;
	cin>>n>>w;
	int wt[n+1], p[n+1];

	f(i,1,n+1)
		cin>>wt[i]>>p[i];

	int max_val = n*1000;
	ll dp[n+1][max_val +1];

	f(j,0,max_val+1)
		dp[1][j] = inf;

	dp[1][0] = 0;
	dp[1][p[1]] = wt[1];

	f(i,2,n+1)
		f(j,0,max_val+1)
		{
			dp[i][j] = dp[i-1][j];
			if(j >= p[i])
				dp[i][j] = min(dp[i][j], wt[i]+dp[i-1][j-p[i]]);
		}
ll ans;
f(j,0,max_val+1)
	{
		if(dp[n][j] <= w)
			ans = j;
	}

	cout<<ans;

	return 0;
}

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

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

	vector<int> ans;
    for (int i = x; i < k + x; i++) {
    	ans.push_back(i);
    }

    for (int i = x - 1; i > x - k; i--) {
    	ans.push_back(i);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
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<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 (a>b) { a=b; return 1; } return 0; }

int ksum(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  
  int ans = inf;
  FOR(i, 1, n) {
    chmin(ans, ksum(i) + ksum(n - i));
  }
  cout << ans << '\n';

  

  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
 
    int sum=0;
    if(a>k) sum=k,k=0;
    else sum=a, k-=a;
    if(b>k) k=0;
    else k-=b;
    sum-=k;
    cout<<sum<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
typedef long long ll;
 
 
int main(){
    int N;
    int A[3][3];
    int b[10];
    bool appear[3][3];
    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }
    cin >> N;
    rep(i,N) cin >> b[i];
    rep(i,N){
        rep(j,N){
            appear[i][j]  =false;
            rep(k,N){
                if(A[i][j] == b[k]) appear[i][j] = true;
            }            
        }
    }
    string ans = "No";

    rep(i,3){
        if(appear[i][0] and appear[i][1] and appear[i][2])  ans = "Yes";
    }
    rep(i,3){
        if(appear[0][i] and appear[1][i] and appear[2][i])  ans = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2])  ans = "Yes";
    if(appear[2][0] and appear[1][1] and appear[0][2])  ans = "Yes";

    cout << ans << endl; 
}

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

int main(){
  int N,K;
  int j=1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(2*j <j+K) j *= 2;
    else j += K;
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
double a,b,x;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>a>>b>>x;
		double b2=2.0*x/(a*b);
		if(b2>a) {
			double x2=x-0.5*a*a*b;
			double base=x2*2.0/(a*a);
//			double x3=x-a*base;
			cout<<setprecision(20)<<atan((b-base)/a)*(180.0/3.14159265359);
			return 0;
		}
		cout<<setprecision(20)<<atan(b/b2)*(180.0/3.14159265359);
		return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
string S;
int Q;
ll Crui[2000100];
ll pre[2000100]; // previous M
ll preC[2000100]; // previous M only at M
void print(ll *a){
	for(int i=0;i<=N;i++)printf("%lld ",a[i]);
	printf("\n");
}
int main(){
	cin >> N;
	cin >> S;
	for(int i=0;i<S.size();i++){
		if(S[i]=='C'){
			Crui[i+1]=1;
		}
		if(S[i]=='M'){
			pre[i+1]=1;
		}
	}
	for(int i=1;i<=2*N;i++){
		pre[i+1]+=pre[i];
		Crui[i+1]+=Crui[i];
	}
	for(int i=0;i<N;i++){
		if(S[i]=='C'){
			preC[i+1]=pre[i+1];
		}
	}
	for(int i=1;i<=2*N;i++){
		preC[i+1]+=preC[i];
	}
	/*printf("\n");
	for(int i=0;i<=2*N;i++)printf("%d ",i);
	printf("\n");
	print(pre);
	print(Crui);
	print(preC);*/
	cin >> Q;
	for(int i=0;i<Q;i++){
		int k;
		cin >> k;
		ll ans = 0ll;
		for(int j=0;j<N;j++){
			if(S[j]=='D'){
				ans += (preC[j+k]-preC[j])-pre[j+1]*(Crui[j+k]-Crui[j]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 48260
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define nw	 endl
#define mod 1000000007
 
 
int main(void)
{
	CIN;
	ll  tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	cout<<(n?'0':'1');
}

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

int N, Q;

vector<unordered_map<int, int>> edge;
vector<int> counters;
vector<int> ans;

void tree(int root){
    for (auto itr = edge[root].begin(); itr != edge[root].end(); ++itr){
        int child = itr->first;
        edge[child].erase(root);
        tree(child);
    }
    return;
}

void scoring(int root){
    ans[root] += counters[root];
    for (auto itr = edge[root].begin(); itr != edge[root].end(); ++itr){
        int child = itr->first;
        ans[child] += ans[root];
        scoring(child);
    }
    return;
}

int main() {
    cin >> N >> Q;
    edge.resize(N);
    counters.resize(N);
    ans.resize(N);

    for (int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        counters[p] += x;
    }

    tree(0);
    scoring(0);

    for (int i = 0; i < N - 1; ++i) cout << ans[i] << " ";
    cout << ans[N-1] << endl;

    return 0;
}

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

int main(){
	int num_coins, money_input;
	cin >> num_coins >> money_input;
	
	if(500*num_coins >= money_input){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

r_cnt = C.count('R')
w_cnt = 0
ans = 200000

if w_cnt <= r_cnt:
    ans = min(ans, r_cnt)
else:
    ans = min(ans, w_cnt)

for i in range(N):
    if C[i] == 'R':
        r_cnt -= 1
    else:
        w_cnt += 1

    if w_cnt <= r_cnt:
        ans = min(ans, r_cnt)
    else:
        ans = min(ans, w_cnt)
print(ans)


Measured memory_bytes: 10720
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N + 1];
    for (int i = 1; i <= N; i++) a[i] = scanner.nextInt();

    boolean[][] dp1 = new boolean[N + 1][K + 1];
    for (int i = 0; i <= N; i++) dp1[i][0] = true;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= K; j++) {
        dp1[i][j] = dp1[i - 1][j] || (j >= a[i] && dp1[i - 1][j - a[i]]);
      }
    }

    boolean[][] dp2 = new boolean[N + 1][K + 1];
    for (int i = 0; i <= N; i++) dp2[i][0] = true;
    for (int i = N - 1; i >= 0; i--) {
      for (int j = 1; j <= K; j++) {
        dp2[i][j] = dp2[i + 1][j] || (j >= a[i + 1] && dp2[i + 1][j - a[i + 1]]);
      }
    }

    int count = 0;
    loop:
    for (int i = 1; i <= N; i++) {
      int min = Math.max(0, K - a[i]);
      for (int k = min; k < K; k++) {
        for (int j = 0; j <= k; j++) {
          if (dp1[i - 1][j] && dp2[i][k - j]) {
            count++;
            continue loop;
          }
        }
      }
    }
    System.out.println(N - count);
  }
}


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

int main() {
    int N, k=1;
    cin >> N;
    vector<int> A(N, 0);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    vector<int> mountain(N, 0);

    for(int i=0; i<N; i++) {
        mountain[0] += k * A[i];
        k *= (-1);
    }
    mountain[0] /= 2;
    
    for(int i=1; i<N; i++) {
        mountain[i] = A[i-1] - mountain[i-1];
    }

    for(int i=0; i<N; i++) {
        mountain[i] *= 2;
    }
    
    for(int i=0; i<N-1; i++) {
        cout << mountain[i] << " ";
    }
    cout << mountain[N-1] << endl;

    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N,M,X,Y;
  cin >>N>>M>>X>>Y;
  int maxx=X;
  int miny=Y;
  int x,y;

  for(int i=0;i<N;i++){
    cin >>x;
    if(maxx<x) maxx=x;
  }

  for(int i=0;i<M;i++){
    cin >>y;
    if(miny>y) miny=y;
  }
  if(maxx<miny) cout << "No War"<<endl;
  else cout <<"War"<<endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,k;
  cin >> n >> k;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  vll s(n+1, 0);
  REP(i, n)
    s[i+1] = s[i]+a[i];

  map<ll, ll> m;
  ll ans = 0;
  REP(i, s.size()){
    ll t = (s[i]-i)%k;
    if(t<0)
      t += k;

    if(i<k){
      ans += m[t];
      m[t] += 1;
    }
    else{
      ll r = (s[i-k]-(i-k))%k;
      if(r<0)
        r += k;
      m[r] -= 1;
      ans += m[t];
      m[t] += 1;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 15872
import math

n = int(input())
count_lis = [0]*n
for i in range(1, math.floor(n**(1/2))):
    for j in range(1, math.floor(n**(1/2))):
        for k in range(1, math.floor(n**(1/2))):
            if i**2 + j**2 + k**2 + i*j + j*k + k*i <= n:
                count_lis[i**2 + j**2 + k**2 + i*j + j*k + k*i-1] += 1
for i in range(n):
    print(count_lis[i])

Measured memory_bytes: 9420
/**
 * @param {String} input
 */
function Main(input){
    const inputs = input.split(' ');
    const num = Number(inputs[0]) + Number(inputs[1]);
    if(num >= 10) return "error";
    return num; 
}
console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

ll n,k;
string s;

int main(){
    cin >> n >> k;
    cin >> s;
    vector<ll> vec;
    if(s[0]=='0') vec.push_back(0);
    for(ll i=0;i<n;){
        ll j=i;
        while(j<n&&s[j]==s[i]) j++;
        vec.push_back(j-i);
        i=j;
    }
    if(s[n-1]=='0') vec.push_back(0);

    vector<ll> cal(vec.size()+1,0);
    for(ll i=0;i<vec.size();i++){
        cal[i+1]=cal[i]+vec[i];
    }

    ll res=0;
    for(ll i=0;i<cal.size();i+=2){
        ll j=i+k*2+1;
        if(j>=cal.size()) j=cal.size()-1;
        res=max(res,cal[j]-cal[i]);
    }
    cout << res << endl;
    return 0;
}  


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

using namespace std;

long long inf=1000000007;

int main(){
	int h,w;
	cin>>h>>w;
	vector<string> maze(h);
	for(int i=0;i<h;i++) cin>>maze.at(i);

	vector<vector<int>> NumOfBlack(h,vector<int>(w,inf));
	if(maze.at(0).at(0)=='.') NumOfBlack.at(0).at(0)=0;
	else NumOfBlack.at(0).at(0)=1;

	queue<pair<int,int>> que;
	que.push(make_pair(0,0));

	while(!que.empty()){
		int x=que.front().first;
		int y=que.front().second;
		que.pop();

		vector<int> dx={0,1};
		vector<int> dy={1,0};

		for(int i=0;i<2;i++){
			int px=x+dx.at(i);
			int py=y+dy.at(i);
			if(px>=w || py>=h) continue;

			int add=0;
			if(maze.at(y).at(x)=='.' && maze.at(py).at(px)=='#') add=1;

			if(NumOfBlack.at(py).at(px)!=inf || px==0 || py==0) que.push(make_pair(px,py));

			NumOfBlack.at(py).at(px)=min(NumOfBlack.at(py).at(px),NumOfBlack.at(y).at(x)+add);
		}
	}

	cout<<NumOfBlack.at(h-1).at(w-1)<<endl;

	return 0;
}


Measured memory_bytes: 256
W, H, x, y, r = map(int, input().split())
rx1 = x + r
rx2 = x - r
ry1 = y + r
ry2 = y - r

if rx1 <= W and rx1 >= 0:
    if rx2 <= W and rx2 >= 0:
        if ry1 <= H and ry1 >= 0:
            if ry2 <= H and ry2 >= 0:
                print("Yes")
                exit()
print("No")



Measured memory_bytes: 5596
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0


 int main()
 {
 	int a,b,N;
 	cin >>a>>b>>N;
 	int m=N/2;
 	for (int i = 0; i < m; i++){
 		if(a%2==1){
 			a=a-1;
 			
 		}
 		a=a/2;
 		b=b+a;
 		if(b%2==1){
 			b=b-1;
 		}
 		b=b/2;
 		a=a+b;
 	}
 	if(N%2==1){
 		if(a%2==1){
 			a=a-1;
 			
 		}
 		a=a/2;
 		b=b+a;
 	}
 	cout << a<<' '<<b << endl;
 }

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

string s;
long long k;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s >> k;
	for (long long i = 0; i < min(k, (long long)s.size()); ++i) {
		if (s[i] != '1') return cout << s[i] << '\n',0;
	}
	cout << 1;
}

Measured memory_bytes: 256
N=int(input())
S=list(input())
X=[]
Y=[]
max_len=0
for i in range(N-1):
  X=S[:i+1]
  Y=S[i+1:]
  #print(set(X),set(Y))
  same_ele_num = len(set(X) & set(Y))
  #print('X and Y:', same_ele_num)
  if(same_ele_num > max_len):
    max_len = same_ele_num
print(max_len)

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

int main() {
  ll N;
  cin >> N;
  vector<ll> tk(N);
  for (ll i = 0; i < N; i++) cin >> tk[i];

  ll s = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      s += tk[i] * tk[j];
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
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 (a>b) { a=b; return 1; } return 0; }

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint H(int n, int k) { return (*this)(n+k-1, k);}
};

int main() {
    int n, k;
    cin >> n >> k;
    
    combination C(n+k);
    rep (i, 1, k+1)
        cout << C(k-1, i-1) * C.H(i+1, n-k-(i-1)) << endl;
    
    return 0;
}


Measured memory_bytes: 3660
import java.io.*
import java.util.*

fun solve(N: Int, H: IntArray){
    val steps = ArrayDeque<Int>()
    var i = 0
    var step = 0
    while(i < N - 1){
        if(H[i] < H[i+1]){
            steps.addLast(step)
            step = 0
        }else{
            step++
        }
        i++
    }
    steps.addLast(step)
    println(steps.max()!!)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val H = IntArray(N)
    for (i in 0 until N) {
        H[i] = sc.next().toInt()
    }
    solve(N, H)
}



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int c = Integer.parseInt(strArr[2]);
		if (b - a == c - b)
			System.out.println("YES");
		else
			System.out.println("NO");
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21076