akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
const int MOD = 998244353;

int N;
int a[310];
int dp1[310][90010];
int dp2[310][90010];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> a[i];
    int S = 0;
    rep(i, N) S += a[i];
    
    dp1[0][0] = 1;
    rep(i, N) {
        rep(j, N*300+1) {
            dp1[i+1][j] += 2*dp1[i][j];
            dp1[i+1][j] %= MOD;
            if (j+a[i]<=N*300) {
                dp1[i+1][j+a[i]] += dp1[i][j];
                dp1[i+1][j+a[i]] %= MOD;
            }
        }
    }
    
    int ans = 1;
    rep(i, N) {
        ans *= 3;
        ans %= MOD;
    }
    int sub = 0;
    for (int i=(S+1)/2; i<=N*300; i++) {
        sub += dp1[N][i];
        sub %= MOD;
    }
    ans = (ans-3*sub%MOD+MOD)%MOD;
    
    if (S%2==0) {
        dp2[0][0] = 1;
        rep(i, N) {
            rep(j, N*300+1) {
                dp2[i+1][j] += dp2[i][j];
                dp2[i+1][j] %= MOD;
                if (j+a[i]<=N*300) {
                    dp2[i+1][j+a[i]] += dp2[i][j];
                    dp2[i+1][j+a[i]] %= MOD;
                }
            }
        }
        ans += 3*dp2[N][S/2];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 425600
n,m,x = map(int, input().split())

c = []
a = []

for i in range(n):
    ai = list(map(int,input().split()))
    ci = ai.pop(0)
    a.append(ai)
    c.append(ci)

for j in range(m):
    tmp = 0
    for i in range(n):
        tmp += a[i][j]
    if tmp<x:
        print(-1)
        exit()

def dps(lis, num):
    if num == n:
        res = 0
        for j in range(m):
            tmp = 0
            for i in lis:
                tmp += a[i][j]
            if tmp < x:
                return 10000000
        for i in lis:
            res += c[i]
        return res
    else:
        lisnext = lis + [num]
        return min(dps(lisnext,num+1),dps(lis,num+1))

print(dps([],0))

Measured memory_bytes: 69600
#include<bits/stdc++.h>
using namespace std;
const int maxn=110000;
const int maxm=210000;
const int inf=1e9+7;
struct edge
{
	int to,nxt;
}e[maxm];
int h[maxn],E;
int n,m;
int d[maxn];
int w[maxm];
int use[maxn];
int col[maxn];
int root[maxn];
int fa[maxn];
int find(int x)
{
	if(fa[x]==x) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}
void add(int u,int v)
{
	E++;
	e[E].to=v;
	e[E].nxt=h[u];
	h[u]=E;
	return;
}
void mer(int u,int v)
{
	u=find(u);
	v=find(v);
	if(u==v) return;
	fa[u]=v;
}
void dfs(int u,int fa)
{
	col[u]=col[fa]^1;
	for(int i=h[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u);
	}
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++) scanf("%d",&d[i]);
	for(int i=1;i<=n;i++) root[i]=-1;
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(find(u)==find(v)) continue;
		if(d[u]>d[v]) swap(u,v);
		if(d[u]==d[v]&&use[u]&&use[v]) continue;
		if(use[v]&&d[u]!=d[v]) continue;
		if(d[u]==d[v]) use[u]=use[v]=1;
		else use[v]=1;
		w[i]=max(d[u],d[v]);
		mer(u,v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++) 
	{
		if(!use[i])
		{
			printf("-1\n");
			return 0;			
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(root[find(i)]==-1||d[root[find(i)]]>d[i]) root[find(i)]=i;
	}
	for(int i=1;i<=n;i++)
	{
		if(fa[i]==i)
		{
			dfs(root[i],0);
		}
	}
	for(int i=1;i<=n;i++) 
	{
		if(col[i]) printf("W");
		else printf("B");
	}
	printf("\n");
	for(int i=1;i<=m;i++)
	{
		if(w[i]==0) printf("1000000000\n");
		else printf("%d\n",w[i]);
	}
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.mss", "r", stdin);
	string str = "";
	int n;

	while (1){
		getline (cin, str );
		stringstream ssn(str);
		ssn >> n;
		if (n == 0){
			break;
		} // end if
		vector <int> a(n + 1, 0);
		int i,j;

		vector <int> sum (n + 1, 0);

		for (i = 1; i <= n; ++i){
			getline (cin, str );
			stringstream ss(str);
			ss >> a[i];
		} // end for
		for (i = 1; i <= n; ++i){
			sum[i] = accumulate (a.begin(), a.begin() + i + 1, 0 );
//			cout << "sum[" << i << "]:" << sum[i] << endl;
		} // end for

		int maxn = INT_MIN;
		for (i = 1; i <= n; ++i){
			for (j = i; j <= n; ++j){
//				cout << " sum[" << j << "]:" << sum[j];
//				cout << " sum[" << (i-1) << "]:" << sum[i-1];
//				cout << " sub: " << (sum[j] - sum[i-1]) << endl;
				 maxn = max (maxn , sum[j] - sum[i - 1]);
			} // end for
		} // end for
		cout << maxn << endl;			

	} // end while

	return 0;
}

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

int main() {
	std::string const ALPHABET = "abcdefghijklmnopqrstuvwxyz";
	long long n = 0;
	std::cin >> n;

	std::string name;

	while (n > 0)
	{
		--n;
		name = ALPHABET.at(n % 26) + name;
		n /= 26;
	}
	std::cout << name << std::endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

struct Runner{
  double p, t, v;
  Runner(double p, double t, double v) : p(p), t(t), v(v){}  
};

int main(){
  int N, M, L;
  cin >> N >> M >> L;
  
  vector<Runner> r;
  
  for(int i = 0 ; i < N ; i++){
    double p, t, v;
    cin >> p >> t >> v;
    r.push_back(Runner(p/100.0, t, v));
  }
  
  double dp[55][110][55]; // iテァツ閉ェテァツ崢ョテ」ツ?ァ j テ」ツ??kテ・ツ崢?テ、ツシツ妥」ツつ?ァツ「ツコテァツ篠?
  memset(dp, 0, sizeof(dp));
  for(int i = 0 ; i < N ; i++) dp[0][i][0] = 1;
  
  for(int i = 1 ; i <= M ; i++){
    for(int j = 0 ; j < N ; j++){
      for(int k = 0 ; k <= M ; k++){
	dp[i][j][k] = (r[j].p * dp[i-1][j][k-1]) + ((1.0-r[j].p) * dp[i-1][j][k]);
      }
    }
  }
  
  double sum[110][55];
  for(int i = 0 ; i < N ; i++){
    sum[i][0] = (double)(L / r[i].v);
    for(int j = 1 ; j <= M ; j++){
      sum[i][j] = sum[i][j-1] + r[i].t;
    }
  }
  
  double sum2[110][55];
  for(int i = 0 ; i < N ; i++){
    sum2[i][0] = dp[M][i][0];
    for(int j = 1 ; j <= M ; j++){
      sum2[i][j] = sum2[i][j-1] + dp[M][i][j];
    }
  }
  
  for(int i = 0 ; i < N ; i++){
    double ans = 0.0;

    for(int j = 0 ; j <= M ; j++){
      double p = dp[M][i][j];
      for(int ii = 0 ; ii < N ; ii++){
	if(i == ii) continue;

	int index = upper_bound(sum[ii], sum[ii]+M+1, sum[i][j]) - sum[ii];

	double s = sum2[ii][M] - sum2[ii][index-1];
	p *= s;	
      }
      ans += p;
    }
    printf("%.8f\n", ans);
  }
  return 0;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < 3; i++)
        if(s[i] == 'A')
            cnt++;
    if(cnt > 0 && cnt < 3)
        cout << "Yes";
    else
        cout << "No";   
}

Measured memory_bytes: 256
n,m=map(int,input().split())
che=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    che[a-1] += 1
    che[b-1] += 1
    
error=0
for i in range(n):
    if che[i]%2!=0:
        error += 1

if error==0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3828
import math

A, B = input().split()
A = int(A)
B = float(B)

# 小数を各数字にまとめる
# B_sho, B_sei = math.modf(B)
# print(B_sei, B_sho)
# B_sei = int(B_sei)
# B_sho = int(B_sho*100)
# B_sho1, B_sho2 = divmod(B_sho,10)

B_fix = int(round(B*100))
B_sei, B_sho = divmod(B_fix,100)
B_sho1, B_sho2 = divmod(B_sho, 10)

# print(B_sei, B_sho1,B_sho2)

ans = 100 * A * B_sei + 10 * A * B_sho1 + 1 * A * B_sho2

ans = ans // 100

print(ans)

Measured memory_bytes: 9188
#include <stdio.h>
int main(){
    int n,k,i,j;
    while (1) {
        scanf("%d %d",&n,&k);
        if (n==0&&k==0) {
            return 0;
        }
        int c[100000],blank=0,flag=0,max=0;
        for (i=0; i<100000; i++) {
            c[i]=0;
        }
        for (i=0; i<k; i++) {
            scanf("%d",&j);
            if (j==0) {
                blank=1;
            }
            c[j-1]=1;
        }
        for (i=0; i<n; i++) {
            int count=0;
            flag=blank;
            for (j=i; j<n; j++) {
                if (c[j]==0) {
                    if (flag==0) {
                        break;
                    }
                    flag--;
                }
                count++;
            }
            if (max<count) {
                max=count;
            }
        }
        printf("%d\n",max);
    }
}

Measured memory_bytes: 992
#include<iostream>
#include<cstring>
#define ll long long


using namespace std;

int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll c;
	if(b > n) c = n ;
	else c = b-1;
	cout<<a * c / b - a * (c / b);
	return 0;
}

Measured memory_bytes: 3192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	n := len(s)
	k := getNextInt(scanner)
	for i := 0; i < n-1; i++ {
		if s[i] == 'a' {
			fmt.Fprint(writer, "a")
			continue
		}
		inc := 26 - int(s[i]-'a')
		if inc > k {
			fmt.Fprintf(writer, "%c", s[i])
			continue
		}
		k -= inc
		fmt.Fprint(writer, "a")
	}
	fmt.Fprintln(writer, fmt.Sprintf("%c", 'a'+(int(s[n-1]-'a')+k)%26))
}


Measured memory_bytes: 2560
#include"stdio.h"
int main(){
  long long  n;
  scanf("%lld",&n);
  long long sum=0,num;
  for(long long i=1;i*i<n;i++){
       if(n%i==0){
       num=n/i-1;
       if(num>i)
         sum+=num;
       }
  }
  
  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll a,v,b,w,t; cin >> a >> v >> b >> w >> t;
  
  if(v > w and abs(a-b) <= t*(v-w)) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    For(i,0,n) cin>>p[i];
    sort(ALL(p));
    For(i,0,k) ans+=p[i];
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main() {
  int N,t4,t3,t2,t1;
  cin >> N;
  t4 = N / 1000;
  t3 = (N%1000)/100;
  t2 = (N%100)/10;
  t1 = N%10;
  if (t4 == t3){
    if(t3 == t2){
      cout << "Yes";
      return 0;
    }
    else
      cout << "No";
  }
  else{
    if(t3==t2){
      if(t2==t1){
        cout <<"Yes";
      	return 0;
      }
      else{
        cout << "No";
        return 0;
      }
    }
    else
      cout <<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
}

void solveA() {
    int x, y, z; cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}

void solveB() {
    int n, m; cin >> n >> m;
    int S = 0, arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        S += arr[i];
    }
    int t = m;
    for (int i = 0; i < n; i++) {
        if (4 * m * arr[i] >= S) t--;
    }
    if (t > 0) cout << "No";
    else cout << "Yes";
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

void solveC() {
    long long n, k; cin >> n >> k;
    if (n % k == 0) {
        cout << 0;
        return;
    }
    while (true) {
        long long tmp = fabs(n - n / k * k - k);
        if (tmp >= n) break;
        else n = tmp;
    }
    cout << n;
}

void solveF() {
    long long n; cin >> n;
    long long res = 0;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            long long tmp = n;
            while (tmp % i == 0) tmp /= i;
            if (tmp % i == 1) res++;
            long long x = n / i;
            if (x == i) continue;
            tmp = n;
            while (tmp % x == 0) tmp /= x;
            if (tmp % x == 1) res++;
        }
    }
    n--;
    vector<int> primes;
    int maxN = 1e6 + 4;
    int check[maxN];
    memset(check, 0, sizeof(check));
    for (int i = 2; i < maxN; i++) {
        if (check[i] == 0) {
            primes.push_back(i);
            for (int j = i; j < maxN; j += i) check[j] = 1;
        }
    }
    long long ext = 1;
    for (int i : primes) {
        if (n % i == 0) {
            int c = 0;
            while (n % i == 0) {
                n /= i;
                c++;
            }
            ext *= c + 1;
        }
    }
    if (n != 1) ext *= 2;
    res += ext;
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // rwFile();
    solveF();
}


Measured memory_bytes: 4988
<?php
list($n,$m,$l)=explode(' ',trim(fgets(STDIN)),3);

$a=[];
for($i=0;$i<$n;$i++) $a[$i]=explode(' ',trim(fgets(STDIN)),$m);

$b=[];
for($k=0;$k<$m;$k++) $b[$k]=explode(' ',trim(fgets(STDIN)),$l);

for($i=0;$i<$n;$i++){
  $C=[];
  for($j=0;$j<$l;$j++){
    $c=0;
    for($k=0;$k<$m;$k++) $c+=$a[$i][$k]*$b[$k][$j];
    $C[]=$c;
  }
  echo implode(' ',$C),PHP_EOL;
}

Measured memory_bytes: 18784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int ans = 0;
    vector<int> p(3,0);
    string S;
    cin >> N >> S;
    for (int i = 0; i < 1000; i++) {
        vector<int> c = {i/100, i/10%10, i%10};
        int counter = 0;
        for (int j = 0; j < N; j++) {
            if (S.at(j) == '0' + c.at(counter)) {
                counter++;
                // cout << i << endl;
            }
            if (counter == 3) {
                break;
            }
        }
        if (counter == 3) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
A,B,C = map(int,input().split())
ans =[]
flag =False
for i in range(1,A*B):
    temp =  (A*i)%B
    ans.append(temp)
for j in ans:
    if j == C:
        flag = True
        break
    else:
        flag = False
if flag ==True:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    double n, k;
    scanf("%lf%lf", &n, &k);
    double ans = 0;
    for (int i = 1; i <= n; i++) {
        double count = 0;
        int tmp = i;
        while (tmp < k) {
            tmp *= 2;
            count++;
        }
        ans += pow(0.5, count);
    }
    printf("%.10lf", ans / n);
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

ll n,m,q,ans = 0;
vector<ll> a(51),b(51),c(51),d(51);


void calc(vector<int> A, ll index) {
	if (index==n) {
		// check  update ans
		ll tmp = 0;
		for(int i=0;i<q;i++) {
			if (A[b[i]]-A[a[i]]==c[i]) tmp += d[i];
		}
		ans = max(ans , tmp);
		return;
	}

	for(int i=A[index]; i<=m; i++) {
	//for(int i=A[index]; i<=m-(n-index-1); i++) {
		A[index+1] = i;
		calc(A , index+1);
	}
}
int main() {
	ll		i,j,k,x,y;

	cin >> n >> m >> q;
	vector<int> A(n+1);

	for(i=0;i<q;i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	//for(i=1;i<=m-(n-1);i++) {
	for(i=1;i<=m;i++) {
		A[1] = i;
		calc(A , 1);
	}

	cout << ans << endl;

}


Measured memory_bytes: 3600
<?php
$input = (int)trim(fgets(STDIN));

list($start, $finish) = explode(' ', trim(fgets(STDIN)));

$count = 0;
for ($i = (int)$start; $i <= (int)$finish; $i++) {
    if ($i % $input === 0) {
        $count++;
        break;
    }
}

if ($count === 1) {
    echo 'OK';
} else {
    echo 'NG';
}

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

using namespace std;
#define BUF (1000)
#define ll long long 

int a,b,c,x,y;
int ans;

int main(void){
	cin >> a >> b >> c >> x >> y;

	if( 2*c < a+b){
		int tmp = min(x,y);
		x-=tmp;
		y-=tmp;
		ans = 2*c*tmp;
	}else{
		cout << a*x + b*y << endl;
		return 0;
	}

	if(2*c < a){
		ans += 2*c*x;
	}else{
		ans += a*x;
	}

	if(2*c < b){
		ans += 2*c*y;
	}else{
		ans += b*y;
	}
	
	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 < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(ALL(a));
    int max_c = 0;
    rep(i, n) {
        int cnt = upper_bound(ALL(a), a[i] + 1) - lower_bound(ALL(a), a[i] - 1);
        max_c = max(max_c, cnt);
    }
    cout << max_c << endl;
}

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
inline bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

string f[8];
int solve(int y, int x, int d, bool p, int now){
  if(!is_in_field(y, x, 8, 8) || f[y][x] == '.') return 0;
  char my_c = (!p)? 'o' : 'x';
  if(f[y][x] == my_c) return now;
  else return solve(y+e_dir[0][d], x+e_dir[1][d], d, p, ++now);
}

bool color(int y, int x, int d, int p){
  char my_c = (!p)? 'o' : 'x';
  if(!is_in_field(y, x, 8, 8) || f[y][x] == '.') return false;
  else if(f[y][x] == my_c) return true;
  if(!color(y+e_dir[0][d], x+e_dir[1][d], d, p)) return false;
  f[y][x] = my_c;
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  for(int i  = 0; i < 8; i++){
    cin >> f[i];
  }
  pair<pair<int, int> , int> nowa, nowb;
  do{
    bool p = 0;
    nowa = {{0, 0}, 0};
    for(int i = 0; i < 8; i++){
      for(int j = 0; j < 8; j++){
        if(f[i][j] == '.'){
          int t = 0;
          for(int k = 0; k < 8; k++){
            t += solve(i+e_dir[0][k], j+e_dir[1][k], k, p, 0);
          }
          if(nowa.second < t) nowa = {{i, j}, t};
        }
      }
    }
    if(nowa.second){
      for(int i = 0; i < 8; i++) color(nowa.first.first+e_dir[0][i], nowa.first.second+e_dir[1][i], i, p);
      f[nowa.first.first][nowa.first.second] = 'o';
    }

    p = !p;
    nowb = {{0, 0}, 0};
    for(int i = 7; i >= 0; i--){
      for(int j = 7; j >= 0; j--){
        if(f[i][j] == '.'){
          int t = 0;
          for(int k = 0; k < 8; k++){
            t += solve(i+e_dir[0][k], j+e_dir[1][k], k, p, 0);
          }
          if(nowb.second < t) nowb = {{i, j}, t};
        }
      }
    }
    if(nowb.second){
      for(int i = 0; i < 8; i++) color(nowb.first.first+e_dir[0][i], nowb.first.second+e_dir[1][i], i, p);
      f[nowb.first.first][nowb.first.second] = 'x';
    }
  }while(nowa.second || nowb.second);

  for(int i = 0; i < 8; i++){
    cout << f[i] << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] tokens = in.readLine().split(" ");
		double d = Double.parseDouble(tokens[0]);
		int t = Integer.parseInt(tokens[1]);
		int s = Integer.parseInt(tokens[2]);
		if (d/s <= t)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 25452
n = int(input())
lis  =[0]+ list(map(int, input().split())) + [0]

s = 0
for i in range(n+1):
    tmp= abs(lis[i]-lis[i+1])
    s += tmp

for i in range(1,n+1):
    ans = s+abs(lis[i-1] - lis[i+1]) - (abs(lis[i-1]-lis[i]) +abs(lis[i] - lis[i+1]))
    print(ans)

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

vector<int> l;
vector<vector<int>> edges;
vector<bool> used;

void dfs(int i) {
    for (int j = 0;j < edges[i].size();++j) if (!used[edges[i][j]]) {
        used[edges[i][j]] = true;
        dfs(edges[i][j]);
    }
    l.push_back(i);
}

int main() {
    int n,m;
    cin >> n >> m;
    edges = vector<vector<int>>(n);
    for (int i = 0;i < m;++i) {
        int x,y;
        cin >> x >> y;
        edges[x-1].push_back(y-1);
    }

    used = vector<bool>(n,false);
    vector<int> dp(n,0);
    for (int i = 0;i < n;++i) if (!used[i]) {
        used[i] = true;
        dfs(i);
    }
    reverse(l.begin(),l.end());

    for (int i = 0;i < n;++i) for (int j = 0;j < edges[l[i]].size();++j) dp[edges[l[i]][j]] = max(dp[edges[l[i]][j]],dp[l[i]]+1);

    cout << *max_element(dp.begin(),dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 8828
def resolve():
    X, Y, A, B, C = map(int, input().split())
    P = sorted(list(map(int, input().split())), reverse=True)
    P = P[:X]
    Q = sorted(list(map(int, input().split())), reverse=True)
    Q = Q[:Y]
    R = sorted(list(map(int, input().split())))
    l = sorted(list(P + Q + R), reverse=True)
    print(sum(l[:X + Y]))


resolve()

Measured memory_bytes: 111980
P = [1 for _ in range(10**5)]
P[0]=0
P[1]=0
for i in range(2,int((10**5)**0.5)+1):
    for j in range(i*i,10**5,i):
        P[j]=0
Q = []
for i in range(3,10**5,2):
    if P[i]==1 and P[(i+1)//2]==1:
        Q.append(i)
A = [0 for _ in range(10**5+1)]
for q in Q:
    A[q] = 1
for i in range(1,10**5+1):
    A[i] += A[i-1]
Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    print(A[r]-A[l-1])

Measured memory_bytes: 86412
N, K, Q = map(int, input().split())

la = list()
for i in range(Q):
    la.append(int(input()))

lcount = [0] * N
for i in range(Q):
    lcount[la[i]-1] += 1

for i in range(N):
    if K+lcount[i]-Q > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8636
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100010;
int t[MAXN], a[MAXN], mint[MAXN], maxt[MAXN], mina[MAXN], maxa[MAXN];

int n;

LL mul(LL x, LL y) {
    return (x * y) % MOD;
}

int overlap(int l1, int r1, int l2, int r2) {
//    DEBUG(l1); DEBUG(r1); DEBUG(l2); DEBUG(r2);
    if (l1 > r2 || l2 > r1) return 0;
    return min(r1, r2) - max(l1, l2) + 1;
}

int main() {
    GI(n);

    memset(t, 0, sizeof t);
    memset(a, 0, sizeof a);

    FOR1(i, n) {
        GI(t[i]);

        if (t[i] != t[i-1]) {
            mint[i] = maxt[i] = t[i];
        }
        else {
            mint[i] = 1;
            maxt[i] = t[i];
        }

        if (t[i] < t[i-1]) {
            printf("0\n");
            return 0;
        }
    }

    FOR1(i, n) {
        GI(a[i]);
    }

    LL res = 1;

    for (int i = n; i >= 1; i--) {
        if (a[i] != a[i+1]) {
            mina[i] = maxa[i] = a[i];
        }
        else {
            mina[i] = 1;
            maxa[i] = a[i];
        }

        res = mul(res, overlap(mina[i], maxa[i], mint[i], maxt[i]));

        if (a[i] < a[i+1]) {
            printf("0\n");
            return 0;
        }
    }

    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;
    REP(i,dx) cout<<'R';
    REP(i,dy) cout<<'U';
    REP(i,dx) cout<<'L';
    REP(i,dy) cout<<'D';
    cout<<'D';
    REP(i,dx+1) cout<<'R';
    REP(i,dy+1) cout<<'U';
    cout<<'L'<<'U';
    REP(i,dx+1) cout<<'L';
    REP(i,dy+1) cout<<'D';
    cout<<'R';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
ll modInverse(ll A,ll M=MOD)
{
    return modularExponentiation(A,M-2,M);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll ans=0;
	for(int i=1;i<n-1;i++)
	{
		if(arr[i]>arr[i-1] && arr[i]<arr[i+1])
		{
			ans++;
			continue;
		}
		else if(arr[i]<arr[i-1] && arr[i]>arr[i+1])
		{
			ans++;
			continue;
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b % 2) {
            res *= a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int N = 5e6 + 5;
int n, k, p;

bool ispalin(string &s) {
    int b = true;
    int i=0, j=s.length()-1;
    for(; i<j; i++, j--) {
        if(s[i] != s[j]) return false;
    }
    return true;
}
signed main() {
    int t;
    // cin >> t;
    t = 1;
    for(int _=1; _<=t; _++) {
        // string s;
        // cin >> s;
        // if(ispalin(s)) {
        //     int len = (s.length()-1)/2;
        //     string str = s.substr(0, len);
        //     if(ispalin(str)) {
        //         int l = (s.length()+3)/2;
        //         l--;
        //         string ss = s.substr(l);
        //         if(ispalin(ss)) {
        //             cout << "Yes\n";
        //         }
        //         else cout << "No\n";
        //     }
        //     else {
        //         cout << "No\n";
        //     }
        // }
        // else {
        //     cout << "No\n";
        // }
        int l;
        cin >> l;
        cout <<fixed << setprecision(20)<< (double)l*l*l/27 << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    REP(i,1,10) {
        if (n % i != 0) continue;
        if (n / i <= 9) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }
    let patterns = ["eraser", "erase", "dreamer", "dream"];
    let s = patterns.iter().fold(s, |s, pattern| s.replace(pattern, ""));
    println!("{}", if s.is_empty() { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
a, b, c, d = list(map(int, input()))
flag = False
als = a + b + c + d
ret = ""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if als - (2 * i * b + 2 * j * c + 2 * k * d) == 7:
                ret += str(a)
                if i:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(b)
                if j:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(c)
                if k:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(d)
                ret += "=7"
                flag = True
                break
        if flag:
            break
    if flag:
        break
print(ret)


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

int main(){
  int n;
  cin >> n;
  long long ni[87];
  ni[0]=2;
  ni[1]=1;
  for(int i=2; i<87; ++i){
    ni[i] = ni[i-1] + ni[i-2];
  }
  cout << ni[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//小数点以下　cout << fixed << setprecision(10) << num << endl;

int main(){
    int k,s; cin >> k >> s;
    int ans = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(0<=s-i-j && s-i-j<=k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
using Graph=vector<vector<int>>;

void dfs(Graph &G,int v,vector<bool> &can_reach,vector<int> &A){
  can_reach.at(v)=true;
  for(auto e:G.at(v)){
    int nv=A.at(e);
    if(can_reach.at(nv)){
      continue;
    }
    dfs(G,nv,can_reach,A);
  }
}

int main(){
  int N,M;
  ll P;
  cin>>N>>M>>P;
  vector<int> A(M),B(M);
  vector<ll> C(M);
  Graph Gf(N),Gb(N);
  for(int i=0;i<M;i++){
    cin>>A.at(i)>>B.at(i)>>C.at(i);
    A.at(i)--;
    B.at(i)--;
    C.at(i)-=P;
    Gf.at(A.at(i)).push_back(i);
    Gb.at(B.at(i)).push_back(i);
  }

  vector<ll> coin(N,-INF);
  coin.at(0)=0;
  for(int i=0;i<M+1;i++){
    for(int v=0;v<N;v++){
      if(coin.at(v)==-INF){
        continue;
      }
      for(auto e:Gf.at(v)){
        int nv=B.at(e);
        coin.at(nv)=max<ll>(coin.at(nv),coin.at(v)+C.at(e));
      }
    }
  }

  bool loop=false;
  vector<int> s;
  for(int v=0;v<N;v++){
    if(coin.at(v)==-INF){
      continue;
    }
    for(auto e:Gf.at(v)){
      int nv=B.at(e);
      if(coin.at(nv)<coin.at(v)+C.at(e)){
        s.push_back(nv);
        loop=true;
      }
    }
  }

  if(loop){
    vector<bool> can_reach(N,false);
    dfs(Gb,N-1,can_reach,A);

    bool flag=false;
    int n=s.size();
    for(int i=0;i<n;i++){
      flag=flag|can_reach.at(s.at(i));
    }
    if(flag){
      cout<<-1<<endl;
    }else{
      cout<<max<ll>(coin.at(N-1),0)<<endl;
    }
  }else{
    cout<<max<ll>(coin.at(N-1),0)<<endl;
  }
}


Measured memory_bytes: 768
/**
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>
 
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define LOCAL 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  long long cntr = 0, cntg = 0, cntb = 0;
  for (char c : s) {
    cntr += (c == 'R');
    cntg += (c == 'G');
    cntb += (c == 'B');
  }
  long long total = cntr * cntg * cntb;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i + j + j < n) {
        if (s[i] != s[i + j] && s[i] != s[i + j + j] && s[i + j] != s[i + j + j]) {
          ++cnt;
        }
      }
    }
  }
  cout << total - cnt << '\n';
  return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

ll nC2(ll n) { return n * (n - 1) / 2; }

int main() {
    int N;
    cin >> N;
    map<ll, ll> ma;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        ma[A[i]]++;
    }

    ll sum = 0;
    for (auto p : ma) {
        sum += nC2(p.second);
    }

    rep(i, N) {
        ll n = ma[A[i]];
        ll bef = nC2(n);
        ll aft = nC2(n - 1);
        cout << sum - bef + aft << endl;
    }
}

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

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)
#define sz(x) (int)(x).size()
#define pvec(v) copy(all(v), ostream_iterator<decltype(v)::value_type>(cout, " "))

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)


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

void emit(int a, int b) {
	cout << a << ' ' << b << '\n';
}

int lsb(int x) {
	return x & (-x);
}

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

	int n;
	cin >> n;

	if (__builtin_popcount(n) == 1) {
		cout << "No\n";
		return 0;
	}

	cout << "Yes\n";
	/*forb(i, 2) {
		emit(i, i + 1);
		emit(i + n, i + 1 + n);
	}*/
	/*emit(1, n + 3);*/
	int start = 2;
	if (n % 2 == 0) {
		start = lsb(n);
	}
	emit(1, start + 1);
	emit(start + 1, start);
	emit(1 + n, start + 1 + n);
	emit(start + 1 + n, start + n);
	emit(1 + n, start);

	for (int i = 2; i < n; i += 2) {
		if (i == start) continue;
		emit(i, i + 1);
		emit(i + n, i + n + 1);
		emit(i, 1);
		emit(i + n + 1, 1 + n);
	}
	if (n % 2 == 0) {
		emit(n, start + 1);
		emit(n + n, n ^ start);
	}
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll a, b, x;

	cin >> a >> b >> x;

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

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m;
  cin >> n >> m;

  ll min_l = 0;
  ll max_l = n;

  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    chmax(min_l, a);
    chmin(max_l, b);
  }

  if (min_l > max_l) {
    cout << 0 << endl;
  } else {
    cout << (max_l - min_l + 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;



int main(void){
	int n;
	cin >> n;
	ll a[n];
	rep(i,n)cin >> a[i];

	int left = 0,right = 1;
	ll sum = a[0];
	ll ans = 0;
	while(left != n){
		if(right == n){
			ans += right-left;
			left++;
		}
		else if((sum+a[right]) == (sum^a[right])){
			sum += a[right];
			right++;
		}
		else{	

			ans += right-left;
			sum -= a[left];
			left++;
		}
	}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define int32 int32_t
#define PI 2 * acos(0)

using namespace std;

int32 main() {
    ios_base::sync_with_stdio(false);
    int a, b, c, k, res = 0;
    cin >> a >> b >> c >> k;
    res = min(a,k);
    if(res == a) {
        k -= a;
        a = 0;
    } else  {
        k = 0;
    }
    if(k > 0) {
        min(b,k) == b ? k -=b, b = 0 : k = 0;
    }
    if(k > 0) {
        res -= k;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	bool yes = true;
	if( n % 2 == 1 ) yes = false;
	
	else {
		for(int i = 0; i < n / 2; ++i) {
			if( s[i] != s[i + n / 2] )  { 
				yes = false;
				break;
			}
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
private static int[][]daoyu;
private static int count;
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int x = input.nextInt();
            int y = input.nextInt();
            if (x == 0 && y == 0) {
            	break;
            	}
            daoyu = new int [y+2][x+2];
            for(int i = 1;i<=y;i++) {
            	for(int j = 1;j<=x;j++) {
            		daoyu[i][j]=input.nextInt();
            		}
            }
            for (int i=0; i<y+2; i++){
            	daoyu[i][0] = daoyu[i][x+1] = 0;
         
            for (int j=0; j<x+2; j++){
            	daoyu[0][j] = daoyu[y+1][j] = 0;
 
            count = 0;
            }
        }
        for (int i = 1; i <= y; i++) {
            for (int j = 1; j <=x; j++) {
                if (daoyu[i][j] == 1) {
                    count++;
                    lj(i, j);
                }
            }
        } 
        System.out.println(count);
        daoyu=null;
    }
    }
    private static void lj(int i, int j) {
    	 daoyu[i][j] = 2;
         if (i - 1 >= 0 && daoyu[i - 1][j] == 1)
             lj(i - 1, j);//上
         if (i + 1 < daoyu.length && daoyu[i + 1][j] == 1)
             lj(i + 1, j);//下
         if (j - 1 >= 0 && daoyu[i][j - 1] == 1)
             lj(i, j - 1);//左
         if (j + 1 < daoyu[i].length && daoyu[i][j + 1] == 1)
             lj(i, j + 1);//右
         if (i - 1 >= 0 && j-1>=0 && daoyu[i - 1][j-1] == 1)
             lj(i - 1, j-1);//左上
         if (i - 1 >= 0 && j+1<daoyu[i-1].length && daoyu[i - 1][j+1] == 1)
             lj(i - 1, j+1);//右上错误
         if (i + 1 < daoyu.length && j-1>=0 && daoyu[i + 1][j-1] == 1)
             lj(i + 1, j-1);//左下
         if (i + 1 < daoyu.length && j+1<daoyu[i+1].length &&daoyu[i + 1][j+1] == 1)
             lj(i+1, j+1);//右下
     }
 
}


Measured memory_bytes: 44820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << endl;
}


Measured memory_bytes: 256