akhauriyash/Code-Regression huggingface dataset:
// atcoder/abc082/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> v(n);
    cin >> v;
    map<int, lli> m;
    each (i, v) ++m[i];
    lli sum = 0;
    each (i, m) {
      if (i.second >= i.first) {
        sum += i.second - i.first;
      } else {
        sum += i.second;
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 6656
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, P = ILI()
    A = ILI()
    return N, P, A


def nCr(n, r):
    if r == 0:
        return 1

    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))


def solve(N, P, A):
    n_even = 0
    n_odd = 0
    for a in A:
        if a % 2 == 1:
            n_odd += 1
        else:
            n_even += 1

    ans = 0
    if P == 0:
        sum_even = 2 ** n_even
        n_odd_div = n_odd // 2
        sum_odd = 0
        for i in range(0, n_odd_div + 1):
            sum_odd += nCr(n_odd, i * 2)
        ans = sum_even * sum_odd

    elif P == 1:
        if n_odd == 0:
            ans = 0
        else:
            sum_even = 2 ** n_even
            n_odd_div = n_odd // 2
            sum_odd = 0
            for i in range(n_odd_div):
                sum_odd += nCr(n_odd, i * 2 + 1)
            ans = sum_even * sum_odd

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i,N) cin >> X[i];
    ll ans = 0;
    rep(i,N-1) ans += min((X[i+1]-X[i])*A,B);
    pr(ans);
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int r,d,x;
    scanf("%d%d%d",&r,&d,&x);
    vector<ll>v;
    ll temp = (ll)(r*x-d);
    v.push_back(temp);
    for(int i=1;i<10;i++){
        temp = temp*r-d;
        v.push_back(temp);
    }
    for(int i=0;i<v.size();i++){
        printf("%lld\n",v[i]);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  cout << (n + k - 3) / (k - 1) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuffer buf = new StringBuffer();
		int[] p = {2,11,31,41,61,71,101,131,151,181,191,211,251,271,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1361,1381,1451,1571,1831,2311,2711,2851,2791};
		int N =sc.nextInt();
		String ans="";
		if(N%2==0) {
			for(int i = 0;i<N;i++) {
				buf.append(p[i]);
				buf.append(" ");
			}
		}else {
			for(int i = 1;i<N+1;i++) {
				buf.append(p[i]);
				buf.append(" ");
			}
		}
		ans = buf.toString();
		System.out.println(ans);
		sc.close();
	}
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'
#define double long double

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  double b;
  cin >> b;

  cout << (int)floor(n * b) << endl;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;

#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3748
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String[] s = sc.next().split("");
        int ans = 0;
        for(String n : s) {
          if ("+".equals(n)) {
            ans++;
          } else {
            ans--;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21588
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader re =
         new BufferedReader(new InputStreamReader(System.in));       
        String line = re.readLine();       
         
        int cnt=0;
 
        String st[] = line.split(" ",0);
        int a = Integer.parseInt(st[0]);
        int b = Integer.parseInt(st[1]);
       
        
        int d= a / b;
        int r = a % b;
        double f=(double)a/(double)b;
          System.out.print(d +" "+ r +" ");
          System.out.printf("%.5f\n",f);
        re.close();
    }
}

Measured memory_bytes: 24804
#include<iostream>
using namespace std;
int m[101][101];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,u,k,v;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>u>>k;
    u--; //頂点番号をあわせてる
    for(int j=0;j<k;++j){
      cin>>v;
      v--;
      m[u][v]=1;
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(j) cout<<" ";
      cout<<m[i][j];
    }
    cout<<endl;
  }
  return 0;
}



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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int s[4];
int t[4];

int main(){
	ios::sync_with_stdio(false);
	do{
		REP(i,4){
			if (!(cin>>s[i])){
				return 0;
			}
		}
		REP(i,4){
			cin>>t[i];
		}
		int h=0,b=0;
		REP(i,4){
			REP(j,4){
				if (s[i]==t[j]){
					if (i==j){
						h++;
					}
					else{
						b++;
					}
				}
			}
		}
		cout<<h<<" "<<b<<endl;
	}while (1);
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
	int a,x,t;
	cin>>a>>x>>t;

	if(a%x!=0){
		int val=(a+x)/x;
		cout<<val*t<<endl;
	}
	else
	{
		int val=(a)/x;
		cout<<val*t<<endl;
	}
	return 0;
}

Measured memory_bytes: 3592
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let[a,b]=nrin(2)
  out(a*b%2==0?'Even':'Odd')
}
main()


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

wa=[0]*N
ac=[False]*N
for i in range(M):
	p, S = input().split()
	p=int(p)-1
	
	if S=="AC":
		ac[p]=True

	else:#一度ACしたらWAをカウントしない
		if not ac[p]:
			wa[p]+=1

a=0
b=0

for i in range(N):
	if ac[i]:
		a+=1
		b+=wa[i]
print(*[a,b])


Measured memory_bytes: 80140
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int n, a, arr[200000];
    cin >> n;

    for(int i=0; i<n; i++){
        scanf("%d", &a);
        if(i%2) arr[n/2-i/2-1] = a;
        else arr[n/2+i/2] = a;
    }

    if(n%2) reverse(arr, arr+n);

    for(int i=0; i<n; i++){
        printf("%d ", arr[i]);
    }

    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<queue>
#define maxn 500000
using namespace std;
int dir[4][2]={0,-1,0,1,1,0,-1,0};
char map[100][100];
bool vis[100][100];
int n,m;
struct DT
{
	int x;
	int y;
	int step;
};

int bfs(int a,int b)
{
	memset(vis,false,sizeof(vis));
	
	queue<DT>q;
	DT star ,now,next;
	star.x=a;
	star.y=b;
	star.step=1;
	vis[star.x][star.y]=true;
	q.push(star);
	while(!q.empty())
	{
		now=q.front();
		q.pop();
		if(now.x==n-1&&now.y==m-1)
		  {
		  	return now.step;
		  }
		for(int i=0;i<4;i++)
		{
			next.x=now.x+dir[i][0];
			next.y=now.y+dir[i][1];
			if(map[next.x][next.y]=='#'||next.x<0||next.y<0||next.x>=n||next.y>=m||vis[next.x][next.y])
			continue;
			next.step=now.step+1;
			q.push(next);
			vis[next.x][next.y]=true;
			
		}
		
		
	}
	return -1;
}
int main()
{
	int x;
	int num;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		
		num=0;
		for(int i=0;i<n;i++)
		scanf("%s",map[i]);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(map[i][j]=='.')
				num++;
			}
		}
		 x=bfs(0,0);
	   if(x==-1)
	   printf("-1\n");
	   else
	   printf("%d\n",num-x);	 
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> fac;
long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

long long int g(long long int r, long long int c) {
    long long int res = 0;
    for (long long int i = 0; i <= r; i++) {
        res += myc(i + 1 + c, c);
        res %= mod;
    }
    return res;
}

int main() { 
    long long int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fac.push_back(1);
    for (long long int i = 1; i <= c2 + r2 + 2; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    long long int res = g(r2, c2) - g(r1 - 1, c2) - g(r2, c1 - 1) + g(r1 - 1, c1 - 1);
    res %= mod;
    res += mod;
    res %= mod;
    cout << res << endl;
}




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

bool findstr(int num){
	int div=100;
	int cnt=0;
	for (int i = 0; i < in.length(); ++i)
	{
		if (in[i]-'0'==num/div)
		{
			// printf("in[%d]=%c %d/%d==%d\n",i,in[i],num,div,num/div );

			cnt++;
			num-=(num/div)*div;
			div/=10;
		}

		if (cnt==3)
		{
			return true;
		}
	}
	return false;
}

int main(int argc, char const *argv[])
{
	int n;
	while(~scanf("%d",&n)){
		
		cin>>in;
		int ans=0;
		for (int i = 0; i < 1000; ++i)
		{
			if (findstr(i))
			{
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
void solve(int X) {
    double x = 0, y = 0;
    int ans = 0, deg = 0;
    double PI = acos(-1);
    while (true) {
        ans++;
        double deg2 = deg * PI / 180;
        x = x + sin(deg2);
        y = y + cos(deg2);
        if (abs(x) < 1e-7 and abs(y) < 1e-7) {
            break;
        }
        deg += X;
        deg %= 360;
    }
    cout << ans << endl;
}
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int x;cin>>x;solve(x);
    // for (int i = 1; i <= 179; i++)
    //     solve(i);
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n,0);
  for(int i=0;i<n;i++) cin >> d[i];
  sort(d.begin(),d.end());
  int count=0;
  for(int i=1;i<n;i++){
    if(d[i-1]!=d[i]) count++;
  }
  cout << count+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;

    int x, y, z;
    x = Y / 10000;
    y = (Y - 10000*x) / 5000;
    z = (Y - 10000*x - 5000*y) / 1000;
    // printf("%d %d %d\n", x, y, z);

    if(Y<(x+y+z)) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    int i, j, k;
    for(i=x; i>=0; i--) {
        k = z;
        for(j=y; j>=0; j--) {
            if(N==(i+j+k)) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
            k += 5;
        }
        y += 2;
    }

    printf("-1 -1 -1\n");
    
    return 0;
    
}

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

using namespace std;

int main() {
	constexpr Int MOD = 998244353;
	Int A, B, C, D;
	cin >> A >> B >> C >> D;

	vector<vector<Int>> dp(C + 10, vector<Int>(D + 10, 0));
	dp[A][B] = 1;
	for (Int a = A; a <= C; ++a) {
		for (Int b = B; b <= D; ++b) {
			(dp[a + 1][b] += b * dp[a][b]) %= MOD;
			(dp[a][b + 1] += a * dp[a][b]) %= MOD;
			
			Int X = dp[a][b] * a % MOD * b % MOD;
			(dp[a + 1][b + 1] += MOD - X) %= MOD;
		}
	}
	cout << dp[C][D] % MOD << endl;

	return 0;
}


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

using namespace std;

int a, b, c;

int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b;
    c = a+b;
    if (c%2)
        cout << c/2 + 1;
    else
        cout << c/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
vector<int>g[maxn],dp(maxn);
int n;
void dfs(int u,int p=-1){
	int cnt = 0;
	for(auto v:g[u]){
		if( v != p ){
			dfs(v,u);
			dp[u]+=dp[v];
			if(!dp[v]){
				cnt +=1;
			}
		}
	}
	dp[u]+=max(0,cnt-1);
}
int32_t main(){
	IOS
	cin >> n;
	for(int i=0;i+1<n;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int rt = 0;
	for(int i=0;i<n;i++){
		if( g[rt].size() < g[i].size() ){
			rt = i;
		}
	}
	if( g[rt].size() < 3 ){
		cout << 1;return 0;
	}
	dfs(rt);
	cout << dp[rt];
	

	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 15080
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int N,L,i;
  scanf("%d %d",&N,&L);
  int aji[N],saisyou=1000,syouhi;
  int total=0;

  for(i=0;i<N;i++){
    aji[i] = L + i;
    if(saisyou>abs(aji[i])){
      saisyou = abs(aji[i]);
      syouhi = aji[i];
    }
  }
  for(i=0;i<N;i++){
    total = total + aji[i];
  }
  printf("%d",total-syouhi);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int a[100];
  int i,n;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  
  for(i = n-1; i >= 0; i--){
    if(i != n-1) printf(" "); 
    printf("%d", a[i]);
  }
  printf("\n");
}

Measured memory_bytes: 1028
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.6lf\n",a);
#define SIZE

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define N (int)(1e5+10)


using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;

int main() {
    ll n ,k ;
    cin >>n>>k;
   ll res = 0;
    while  ( n > 0){
       n/=k;
       res++;
   }
    cout << res;
    return 0;

}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述
    int A, B = 0;
    cin >> A >> B;

    int plg = 1;
    int count = 0;

    if(B==1){
        cout << count << "\n";
        return 0;
    }

    while(true){
        plg += (A - 1);
        count++;
        if(plg >= B){
            cout << count << "\n";
            return 0;
        }
    }

return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	set<int> s[2];
	s[0] = { 1, 3, 5, 7, 8, 10, 12 };
	s[1] = { 4, 6, 9, 11 };
	for (int i = 0; i < 2; i++) {
		if (s[i].find(a) != s[i].end()) {
			if (s[i].find(b) != s[i].end()) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
const double PI = acos(-1.0);
int dx[] = { 1,-1,0,0 };
int dy[] = { 0,0,1,-1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);  
#endif
}
bool check_prime(ll a)
{
	bool flag = true;
	if (a <= 1)
		return false;
	else
	{
		for (ll i = 2; i <= sqrt(a); i++)
		{
			if (a % i == 0)
			{
				flag = false;
				break;
			}
		}
	}
	if (flag)
		return true;
	else
	{
		return false;
	}
}

int main()
{
	//file();
	Fast;
	string a;
	cin >> a;
	string b;
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] != 'B')
		{
			b.push_back(a[i]);
		}
		else
		{
			if (b.size() != 0)
			{
				b.pop_back();
			}
		}
	}
	cout << b;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    n = II()
    s = IS()
    cnt_b = 0
    cnt_w = s.count('.')
    cnt = cnt_w
    for si in s:
        if si == '#':
            cnt_b += 1
        else:
            cnt_w -= 1
        c = cnt_b+cnt_w
        if c < cnt:
            cnt = c
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        arc088_a solver = new arc088_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class arc088_a {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long a = in.scanLong();
            long b = in.scanLong();
            int max = 0;
            while (b - a >= 0) {
                a += a;
                max++;
            }
            out.println(max);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

    }
}



Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
const LL MOD = 1000000007;

int main(){
    int W,H,w,h,x,y;
    cin >> W>>H>>w>>h>>x>>y;
    double x1 = (min(W/2, x+w/2) + max(-W/2, x-w/2)) / 2.;
    double y1 = (min(H/2, y+h/2) + max(-H/2, y-h/2)) / 2.;
    //cout << x1 << " " << y1 << endl;
    cout << setprecision(15) << (y1*1.)/(x1*1.) << endl;
    return 0;
}



Measured memory_bytes: 3284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        Arrays.sort(str);
        System.out.println(String.join(" ", str));

    }
}

Measured memory_bytes: 24180
#include <iostream>
using namespace std;
int main() {
  int a[100] = {}, m, i, n;
  while (cin >> n) {
    a[n - 1]++;
  }
  for (i = m = 0; i < 100; i++) {
    if (a[i] > m) {
      m = a[i];
    }
  }
  for (i = 0; i < 100; i++) {
    if (a[i] == m) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		if(a%3==0||b%3==0||(a+b)%3==0)
			printf("Possible\n");
		else 
			printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=5005;
int n,k,P;
int w[N];
long long dp[N][N];
int main()
{
	scanf("%d%d",&n,&P);
	k=(n-1)/2;
	for(int i=1,j=1;i<=k+1;i++,j--)
		w[i]=j;
	for(int i=n,j=-1,cnt=1;cnt<=k;cnt++,i--,j--)
	{
		w[i]=j;
		if(n%2==0&&cnt==k) w[i-1]=j;
	}
	dp[1][0]=1;
	for(int i=2;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-(1-w[i])>=0) dp[i][j]=(dp[i][j]+dp[i][j-(1-w[i])])%P;
		}
	long long ans=0;
	for(int j=0;j<=n;j++)
		ans=(ans+dp[n][j]*(n-j)%P)%P;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 199220
import sys
import re
import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N,K=(int(x) for x in input().split())

for i in range(1,K+1):
    if i < min(K+1,N-K+2):
        print((combinations_count(N-K+1, i)*combinations_count(K-1, i-1))%1000000007)
    else:
        print(0)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s,t;
    cin >> s>>t;
    if(s==t.substr(0,t.size()-1)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  int a;
  cin>>a;
  if(a%10==a/100)puts("Yes");
  else puts("No");
	   
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k,x,y;
  
  cin >>k >>x ;
  

  for(int i=x-(k-1);i<x;i++){
    cout << i << ' ';
  }
  cout << x << ' ';
   for(int i=x+1;i<x+k;i++){
    cout << i << ' ';
  }
  cout << endl;
 
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(string, a, N);
    ll ans = INF;
    REP(i, N)
    {
        bool ok = false;
        ll c = 0;
        REP(j, N)
        {
            ok |= a[j][i] == '#';
        }
        if (not ok)
        {
            ++c;
        }
        REP(j, N)
        {
            c += a[i][j] == '.';
        }
        CH(min, ans, c);
    }
    if (ans == N + 1)
    {
        OUT(-1);
        return 0;
    }
    REP(j, N)
    {
        bool ok = true;
        REP(i, N)
        {
            ok &= a[i][j] == '#';
        }
        if (not ok)
        {
            ++ans;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 4076
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);
    static boolean[][] r;
    public static void main(String[] args){
        int N = in.nextInt(), M  = in.nextInt();
        r = new boolean[N][N];

        for(int i = 0; i < N; i++){
            Arrays.fill(r[i], false);
        }

        for(int i = 0; i < M; i++){
            int a = in.nextInt() - 1, b = in.nextInt() - 1;
            r[a][b] = true;
            r[b][a] = true;
        }

        boolean[] v = new boolean[N];
        v[0] = true;
        Deque<P> q = new ArrayDeque<>();
        q.push(new P(1, v));
        
        int sum = 0;
        while(q.size() > 0){
            P p = q.pop();
            boolean all = true;
            for(int i = 0; i < N; i++){
                if(!p.v[i]) all = false;
            }
            if(all){
                sum++;
                continue;
            }
            for(int i = 0; i < N; i++){
                if(!p.v[i] && r[p.pos - 1][i]){
                    boolean[] nv = new boolean[N];
                    nv = Arrays.copyOf(p.v, p.v.length);
                    nv[i] = true;
                    q.push(new P(i + 1, nv));
                }
            }
        }
        System.out.println(sum);
    }
}

class P{
    int pos;
    boolean[] v;
    public P(int p, boolean[] v){
        pos = p;
        this.v = v;
    }
}

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

l = input().split(" ")
int_l = list(map(int, l))

avg_l = sum(int_l) / N

diff_l =[]
for i in range(N):
  diff_l.append(abs(avg_l - int_l[i]))

answer = diff_l.index(min(diff_l))
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {

  int N;
  cin >> N;

  long long sum = 0,m;
  for(int i = 1;sum < N;i++) {
    sum += i;
    m = i;
  }

  int num = sum - N;
  for(int i = 1;i <= m;i++) {
    if(i == num) continue;
    cout << i << endl;
  }

}



Measured memory_bytes: 256
N=int(input())
T=0
A=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append([a,b])
A.sort(key=lambda x: x[1])

for i in range(N):
    T+=A[i][0]
    if A[i][1]<T:
        ans="No"
        break
    else:
        ans="Yes"
print(ans)

Measured memory_bytes: 38044
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 2e5+5;

void robin(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;
    bool ok = 1;

    if(d > c){
        for(int i=b; i<d; i++){
            if(s[i] == '#' and s[i+1] == '#') ok = 0;
        }
        for(int i=a; i<c; i++){
            if(s[i] == '#' and s[i+1] == '#') ok = 0;
        }
        if(ok) cout << "Yes";
        else cout << "No";
    }
    else{
        for(int i=b; i<d; i++){
            if(s[i] == '#' and s[i+1] == '#') ok = 0;
        }
        for(int i=a; i<c; i++){
            if(s[i] == '#' and s[i+1] == '#') ok = 0;
        }
        bool can = 0;
        for(int i = b; i <= d; i++){
            if(s[i-1] == '.' and s[i] == '.' and s[i+1] == '.') can = 1;
        }
        if(! ok || ! can) cout << "No";
        else cout << "Yes";
    }
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        robin();
    }
    return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc162_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var S = CIn.Read().ToCharArray();

      var r = new int[N + 1];
      var g = new int[N + 1];
      var b = new int[N + 1];

      for (int i = N - 1; i >= 0; i--)
      {
        r[i] = r[i + 1];
        g[i] = g[i + 1];
        b[i] = b[i + 1];

        if (S[i] == 'R') r[i]++;
        if (S[i] == 'G') g[i]++;
        if (S[i] == 'B') b[i]++;
      }

      var ans = 0L;

      for (int i = 0; i < N - 2; i++)
      {
        for (int j = i + 1; j < N - 1; j++)
        {
          if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G'))
          {
            ans += r[j + 1];
            if (j + j - i < N && S[j + j - i] == 'R') ans--;
          }
          if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R'))
          {
            ans += g[j + 1];
            if (j + j - i < N && S[j + j - i] == 'G') ans--;
          }
          if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R'))
          {
            ans += b[j + 1];
            if (j + j - i < N && S[j + j - i] == 'B') ans--;
          }
        }
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;++i){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  
  int ans=0;
  for(int i=0;i<n-2;++i){
    for(int j=i+1;j<n-1;++j){
      for(int k=j+1;k<n;++k){
        if(l[i]+l[j]>l[k]){
          ++ans;
        }else{
          break;
        }
      }
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
 
void solve(){
	int n, k;
	cin >> n >> k;
	int h[n];
	int ans = 0;
	rep(i, n) {
		cin >> h[i];
		if (h[i] >= k) ans++;
	}
	cout << ans;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    int a,b,c,n,x,y,m=0,k,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> a >> b >> c;
    if(a+b+c>=22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }
    val common = c * d / euclid(c,d)
    println(b - b/c - b/d + b / common - (a-1) + (a-1)/c + (a-1)/d - (a-1) / common)
}

fun euclid(a: Long, b: Long):Long {
    var divisor = b
    var dividend = a
    var remainder = b % a
    while (remainder != 0L) {
        divisor = dividend
        dividend = remainder
        remainder = divisor % dividend
    }
    return dividend
}

Measured memory_bytes: 37868
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(N);
	vector<pair<int, int>>P(M);
	vector<int>li;
	rep(i, 0, N)cin >> A[i];
	rep(i, 0, M) {
		int B, C;
		cin >> B >> C;
		P[i] = {C,B};
	}
	sort(all(A));
	sort(all(P));
	reverse(all(P));

	int cnt = 0;
	fore(x, P) {
		int C = x.first;
		int B = x.second;
		rep(i, 0, B) {
			li.pb(C);
		}
		cnt += B;
		if (cnt > N)break;
	}

	ll ans = 0;
	rep(i, 0, N) {
		if (i < li.size()) {
			ans += max(li[i], A[i]);
		}
		else {
			ans += A[i];
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2552