akhauriyash/Code-Regression huggingface dataset:
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;


#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int



bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }



int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

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

	vl v(n);

	ll lcm = 1;

	forn(i,0,n)
	{
		cin>>v[i];
		lcm = LCM(lcm,(v[i]/2));
	}
        
    bool val = true;    
        
	forn(i,0,n)
	{
		if(((2*lcm)/v[i])%2 == 0)
		{
			val = false;
		}
	}

	if(!val)
	{
		cout<<0;
		return 0;
	}	


	m -= (m%lcm);

	ll total = 0;
	if(lcm <= m)
	{
		total = (m-lcm)/(2*lcm) + 1;
		cout<<total;
 	}
	else
	{
		cout<<0;
	}

    return 0;
}		

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

int main(void) {

	vector<ll> sumCounterList;
	for (int i = 1; i <= 100; ++i) {
		sumCounterList.push_back(i * (i + 1) / 2);
	}



	ll a;
	cin >> a;

	auto answers = GetPrimeFactorize(a);

	ll ansCount = 0;
	for (auto n : answers) {
		if (n.second == 0)	continue;
		int index = 0;
		for (int i = 0; i < sumCounterList.size(); ++i) {
			if (n.second < sumCounterList[i])	break;
			index = i;
		}
		//cout << n.first << ":" << n.second << "->" << index+1 << endl;
		ansCount += index+ 1;
	}
	cout << ansCount << endl;

	return 0;
}


Measured memory_bytes: 3640
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,K;

signed main(){

    in(N,K);
    out(K*(int)pow(K-1,N-1));

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(len(a)):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
ans = alice - bob
print(ans)

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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef long double ldb;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
#define putc(x) *nowps ++ = (x)
	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;
	inline void flush(){fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<class T>inline void read(T &_) {
		_ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		_ *= ___;
	}
	template<class T>inline void write(T _, char __ = '\n') {
		if(!_) putc('0');
		if(_ < 0) putc('-'), _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; putc(sta[tp --] ^ 48)); putc(__);
	}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;

char S[N]; int n;

int main() {
#ifdef ylsakioi
	file("e");
#endif
	scanf("%s", S + 1), n = strlen(S + 1);
	if(S[1] == '0' || S[n] == '1') return puts("-1"), 0;
	For(i, 1, n - 1) if(S[i] ^ S[n - i]) return puts("-1"), 0;
	int now = 1;
	For(i, 2, n) if(S[i] == '1') {
		For(k, now, i - 1) cout << k << ' ' << i << endl; now = i;
	}
	For(i, now, n - 1) cout << now << ' ' << n << endl;
	return flush(), 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    if (n >= k * 2 - 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()

	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int size = s.size();
    for(int i = 0;i < size;i++){
        s[i] = (s[i]+n-'A')%26 + 'A';
    }
    cout << s << endl;
    return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			if (n <= 2) {
				Console.WriteLine(0);
				return;
			}

			var dic = new Dictionary<int, int>();
			for (int i = 2; i <= n; i++) {
				var temp = Prime(i);
				foreach (var key in temp.Keys) {
					if (dic.ContainsKey(key) == false) {
						dic[key] = temp[key];
					} else {
						dic[key] += temp[key];
					}
				}
			}

			int up2 = dic.Where(x => x.Value >= 2).Count();
			int up4 = dic.Where(x => x.Value >= 4).Count();
			int up14 = dic.Where(x => x.Value >= 14).Count();
			int up24 = dic.Where(x => x.Value >= 24).Count();
			int up74 = dic.Where(x => x.Value >= 74).Count();

			long ans = 0;
			ans += up74;
			ans += up24 * (up2 - 1);
			ans += up14 * (up4 - 1);
			ans += (up4 * (up4 - 1)) / 2 * (up2 - 2);

			Console.WriteLine(ans);
		}

		public static Dictionary<int, int> Prime(int n)
		{
			var dic = new Dictionary<int, int>();
			for (int i = 2; i <= 100; i++) {
				while (n % i == 0) {
					if (dic.ContainsKey(i) == false) {
						dic[i] = 1;
					} else {
						dic[i]++;
					}

					n /= i;
				}
			}

			return dic;
		}
	}
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0, cnt = 0;
	rep(i, s.size()){
		if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T'){
			cnt++;
		}else{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    N = input().rstrip().split(' ')
    N = int(N[0])
    line = input().rstrip().split(' ')
    count = 0
    skip_flag = False
    for i in range(len(line)-1):
        if skip_flag:
            skip_flag = False
            continue
        if line[i] == line[i+1]:
            count += 1
            skip_flag = True
    print(count)

Measured memory_bytes: 3064
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
    exit()
elif a == 0 or b == 0 or (a < 0 and 0 < b):
    print("Zero")
    exit()
else:
    diff = abs(a-b)+1
    if diff%2 == 0:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 3060
#include<stdio.h>
int main()
  {
    int arr[3];
    int i,sum=0;
    for(i=0;i<3;i++)
      { 
        scanf("%d",&arr[i]);
      }
  for(i=0;i<3;i++)
    { 
     sum=sum+arr[i];
    }
  if(sum>=22)
  printf("bust");
  else
    printf("win");
  return 0;
  }


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

void solve() {
  int n; scanf("%d", &n);
  long long cur = 0;
  for (int i = 0; i < n; ++i) {
    cur += 7;
    cur %= n;
    if (cur == 0) {
      printf("%d", i+1);
      return;
    }
    cur *= 10;
  }
  printf("-1");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3856
#include<stdio.h>
#include<string.h>

long gcd(int n, int m);
int main(void)
{
	long n, m;
	scanf("%ld%ld", &n, &m);
	printf("%ld", m*n/gcd(n, m));

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


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

int N;
LL a[100001];
int ans[100001];
int x = 0;
LL L;

int main(){
	scanf("%d%lld%lld" , &N , &L , a + 1);
	for(int i = 2 ; i <= N ; ++i){
		scanf("%lld" , a + i);
	}
	for(int i = 1 ; i < N ; ++i){
		if(a[i] + a[i + 1] >= L){
			x = i;
			break;
		}
	}
	if(x > 0){
		printf("Possible\n");
		for(int i = 1 ; i < x ; ++i){
			printf("%d\n" , i);
		}
		for(int i = N - 1 ; i >= x ; --i){
			printf("%d\n" , i);
		}
	} else {
		printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 1536
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    o = list(map(int, input().split()))
    l = [0]*n
    for i in range(n):
        l[o[i]-1] = i+1
    print(" ".join(map(str,l)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 17740
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

def facto(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt +=1
                temp //= i
            arr.append([cnt, i])
    if temp != 1:
        arr.append([1, temp])
    
    if arr == []:
        arr.append([1, n])
    
    return arr

k, p=I()

for i in facto(p):
    if i[0] >= k:
        ans *= i[1]**(i[0]//k)

if k == 1:
    print(p)
elif p == 1:
    print(1)
else:
    print(ans)


Measured memory_bytes: 10264
import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner sc=new Scanner(System.in);        int ca=0,cb=0,co=0,cab=0;        while(sc.hasNext()){            String str[]=sc.next().split(",");            if(str[1].equals("A")){                ca++;            }            if(str[1].equals("B")){                cb++;            }            if(str[1].equals("O")){                co++;            }            if(str[1].equals("AB")){                cab++;            }        }        System.out.printf("%d\n%d\n%d\n%d\n",ca,cb,cab,co);    } }

Measured memory_bytes: 17172
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect


def main():
    A = int(input())
    B = int(input())
    if A > B:
        A, B = B, A
    # A <= B
    if A == 1 and B == 2:
        print(3)
    elif A == 1 and B == 3:
        print(2)
    elif A == 2 and B == 3:
        print(1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21400
x = int(input())
if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)


Measured memory_bytes: 61652
/**
 *    author:  tootal    
 *    created: 2020/03/28 15:43:11
**/
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<char> d(k);
    for(int i=0;i<k;i++){
        cin>>d[i];
    }
    while(true){
        bool flag=false;
        string s=to_string(n);
        for(int i=0;i<k;i++){
            if(s.find(d[i]) != -1){
                flag=true;
                break;
            }
        }
        if(!flag)break;
        else ++n;
    }
    cout<<n<<endl;
    return 0;
}

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

int main() {
    string s;
    
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '9') {
            printf("Yes");
            return 0;
        }
    }
    
    printf("No");
    
    return 0;
}


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

using namespace std;

char s[1234561];

void init()
{
	scanf("%s", s);
	int k;
	scanf("%d", &k);
	for (int i = 0; s[i]; ++i)
		{
			if(s[i] != 'a')
			{
				int chk = 'z' - s[i] + 1;
				if(chk <= k) {
					s[i] = 'a'; k -= chk;
				}
			}
		}
		int l = strlen(s);
		while(k--) 
			{
				s[l - 1]++;
				if(s[l - 1] > 'z') {
					s[l - 1] = 'a';
				}

			}
			puts(s);	
			//printf("%s\n", s);
}

int main()
{

	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif

	init();

	return 0;
}

Measured memory_bytes: 384
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


struct comp
{
	bool operator()(P p, P q)
	{
		return q.first*(p.second+1)<p.first*(q.second+1);
	}
};

const LL inf=1e9+1;
int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
	vector<P> ps;
	vector<LL> bs;
    for(int i = 0 ; i < N ; i++){
		LL a,b;
        scanf("%lld",&a);
        scanf("%lld",&b);
		if(a==0)
		{
			bs.push_back(b);
		}
		else{
			ps.push_back(P(a,b));
		}
    }
	sort(bs.begin(),bs.end());
	int ret=0;
	for(int i=0;i<bs.size();i++){
		if(i>0){
			bs[i]+=bs[i-1];
		}
		bs[i]++;
		if(bs[i]<=T)
		{
			ret=i+1;
		}
	}
	sort(ps.begin(),ps.end(),comp());
	vector<LL> dp;
	for(auto p:ps){
		dp.push_back(min(inf,p.first+p.second+1));
		//cerr << dp.back() << endl;
	}

	for(int k=1;;k++){
		LL m=inf;
		for(int i=0;i<ps.size();i++){
			if(dp[i]<=T){
				LL r=T-dp[i];
				int c=upper_bound(bs.begin(),bs.end(),r)-bs.begin();
				ret=max(ret,k+c);
			}
			LL m2=min(m,dp[i]);
			dp[i]=min(inf,ps[i].first*(m+1)+ps[i].second+m+1);
			m=m2;
		}

		if(m==inf)
		{
			break;
		}
	}

	printf("%d\n",ret);


    return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a[100010][3];
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>

typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  ll ans=0;
  for(int i=0;i<n;i++){
  	cin >> a[i];
  	ans+=a[i];
  }
  cout << ans-n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N, D;
    cin >> N >> D;
    vector<long long> X(N), Y(N);
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(X[i] * X[i] + Y[i] * Y[i] <= D * D) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = n % 1000;
        if (ans == 0) ans = 1000;
        System.out.println(1000 - ans);
    }
}

Measured memory_bytes: 35888
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

ll gcd(ll a, ll b) {
	while (b > 0) {
		ll tb = b, ta = a;
		a = tb; b = ta % tb;
	}
	return a;
}

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

int main(void) {
	ll A, B, C, D;

	cin >> A >> B >> C >> D;
	A--;
	ll lc = lcm(min(C, D), max(C, D));
	ll cntB = B - (B / C + B / D - B / lc);
	ll cntA = A - (A / C + A / D - A / lc);
	ll ans = cntB - cntA;
	cout << ans << endl;

	return 0;
}



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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

void solve() {
    int n;
    cin >> n;
    vt<pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(rall(a));

    vt<vt<ll>> dp(n + 1, vt<ll>(n + 1));
    for (int i = 0; i < n; i++) {
        for (int l = 0; l <= i + 1; l++) {
            int r = i - l + 1;
            if (l) dp[l][r] = max(
                    dp[l][r],
                    dp[l - 1][r] + (ll)a[i].fi * abs(a[i].se - l + 1)
                );
            if (r) dp[l][r] = max(
                    dp[l][r],
                    dp[l][r - 1] + (ll)a[i].fi * abs(a[i].se - n + r)
                );
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[n - i][i]);
    }
    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 34564
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    char ch;
    while( 1 ){
        scanf("%c", &ch);
        if( islower(ch) ) printf("%c", toupper(ch));
        else printf("%c", tolower(ch));
        if( ch == '\n' ) break;
    }
}

Measured memory_bytes: 1104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };

    int allroot();

    inline bool isroot(int x) { return (par.at(x) == -1); };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
}

bool UnionFind::same(int x, int y) {
    return root(x) == root(y);
}

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}

int UnionFind::allroot() {
    int cnt = 0;
    for (const auto it : par) {
        if (it == -1) cnt++;
    }
    return cnt;
}

struct UF {
    vector<int> par;

    UF(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        else {
            par[rx] = ry;
            return;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


//約数の数を数える
int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        if (yakusu(i) == 8) {
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<"1";
  if(b==0)
    cout<<"2";
  if(c==0)
    cout<<"3";
  if(d==0)
    cout<<"4";
  if(e==0)
    cout<<"5";
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define rg register
using namespace std;
const int MAXN1=2e5+50,MAXN2=2100,MOD=1e9+7,S=2050;
typedef long long LL;
LL N,a[MAXN1],b[MAXN1],mul[MAXN2<<2],invv[MAXN2<<2],f[MAXN2<<1][MAXN2<<1],ans=0;
inline LL qpow(LL a,LL b){//快速幂 
	LL res=1;
	while(b){
		if(b&1) res=(res*a)%MOD;
		b>>=1;
		a=(a*a)%MOD;
	}
	return res;
}
inline LL inv(LL x){return qpow(x,MOD-2)%MOD;}//求逆元 
inline LL C(LL n,LL m){return mul[n]*invv[n-m]%MOD*invv[m]%MOD;}//求组合数 
int main()
{
	memset(f,0,sizeof(f));
	scanf("%lld",&N);
	for(rg LL i=1;i<=N;i++) scanf("%lld%lld",&a[i],&b[i]),f[S-a[i]][S-b[i]]++;//将所有的起点的dp值都加一 
	mul[0]=1,invv[0]=inv(mul[0]);//预处理阶乘及阶乘逆元 
	for(rg LL i=1;i<=8000;i++) mul[i]=mul[i-1]*i%MOD,invv[i]=inv(mul[i]);
	for(rg LL i=1;i<=S*2;i++)//dp 
		for(rg LL j=1;j<=S*2;j++)
			f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%MOD)%MOD;
	for(rg LL i=1;i<=N;i++){
		ans=(ans+f[S+a[i]][S+b[i]])%MOD;//累加答案 
		ans=(ans-C(2*a[i]+2*b[i],2*a[i]))%MOD;//减去重复计算的 
		ans=(ans+MOD)%MOD;//防止ans为负数 
	}
	ans=(ans*500000004)%MOD;//除以二，也就是乘2的逆元 
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int p,q,r;
cin>>p>>q>>r;
int s=p+q,s1=p+r,s2=r+q;
cout<<min(min(s,s1),s2) <<"\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<ll> s(a), t(b);
    ll MIN = 0;
    ll MINS = LINF;
    rep(i, a) {
        cin >> s[i];
        chmin(MINS, s[i]);
    }
    ll MINT = LINF;
    rep(i, b) {
        cin >> t[i];
        chmin(MINT, t[i]);
    }
    MIN = MINS + MINT;
    vector<int> x(m), y(m);
    vector<ll> c(m);
    rep(i, m) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
        chmin(MIN, s[x[i]] + t[y[i]] - c[i]);
    }
    cout << MIN << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
string solve(string s)
{
  if(s.back()=='s')
  {
    return s+"es";
  }
  else
  {
    return s+'s';
  }
}

int main()
{
  string s;
  cin>>s;
  
	cout<<solve(s)<<"\n";
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;

	vector<int> prices({a, b, c});
	sort(prices.begin(), prices.end());

	cout << (prices[0] + prices[1]) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        int n = in.intNext();
        int k = in.intNext();
        HashSet<Integer> seen = new HashSet<>();
        for (int i = 0; i < k; i++) {
            int d = in.intNext();
            for (int j = 0; j < d; j++) seen.add(in.intNext());
        }
        int count = 0;
        for (int i = 1; i < n + 1; i++) if (!seen.contains(i)) count++;
        out.println(count);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 34664
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n, m;
vector<bool> f(100001, false);

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n >> m;
	int ca = 0, cw=0;
	vector<int> vcw(n+1,0);
	REP(i, m) {
		int p;
		string s;
		cin >> p >> s;
		if (f[p])continue;
		if (s == "AC") {
			ca++;
			cw += vcw[p];
			f[p] = true;
		}
		else {
			vcw[p]++;
		}
	}
	cout << ca << " " << cw << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll X,Y;
	scan(X);scan(Y);
	int count=1;
	while(1){
		if((X<<1) >Y) break;
		else{
			X<<=1;
			count++;
		}
	}
	prin(count);
	return 0;
}


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

#define F first
#define S second
#define ll long long
#define int long long
#define pb push_back
#define ld long double

using namespace std ; 

const int N = 1001 * 1001  , MOD = 1e9 + 7 ; 

int par[N] ; 

int val[N] ; 

vector<int> v[N] ; 

int root(int x)
{
	return (par[x]==x?x:par[x]=root(par[x])) ; 
}

bool mrg(int x , int y)
{
	x = root(x) , y = root(y) ; 
	if(x==y) return 0;
	if(v[x].size()<v[y].size()) swap(x,y) ; 
	for(auto u : v[y]) v[x].pb(u) ; 
	par[y] = x ; 
	return 1 ;
}

int32_t main()
{
	ios::sync_with_stdio(0) ;cin.tie(0) ; 
	int n , m ; 
	cin >> n >> m ; 
	for(int i = 0 ; i < n ; i ++ ) par[i] = i , cin >> val[i] , v[i].pb(val[i]) ; 
	while(m--)
	{
		int x , y ;
		cin >> x >> y ; 
		mrg(x,y) ; 
	}

	multiset<int> s ; 
	for(int i = 0 ; i < n ; i ++ ) s.insert(val[i]) ; 
	
	int ans = 0 , need = -2 ; 

	for(int i = 0 ; i < n ; i ++ ) 
	{
		if(par[i]!=i) continue ; 
		need ++ ; 
		sort(v[i].begin(),v[i].end()) ; 
		ans += v[i][0] ; 
		s.erase(s.find(v[i][0])) ; 
	}
	if(need==-1) return cout << 0 << endl , 0  ;
	if(s.size()<need) return cout << "Impossible" << endl , 0 ; 
	while(need--)
	{
		ans += *s.begin() ; 
		s.erase(s.find(*s.begin())) ; 
	}
	cout << ans << endl ; 
}	

Measured memory_bytes: 36724
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  vector<ll> r, g, b;
  REP(i, n){
    if(s[i] == 'R') r.emplace_back(i);
    if(s[i] == 'G') g.emplace_back(i);
    if(s[i] == 'B') b.emplace_back(i);
  }
  ll ans = r.size() * g.size() * b.size();
  REP(i, n){
    FOR(j, i+1, n){
      ll d = j-i;
      if(j+d >= n) continue;
      if(s[i] != s[j] && s[i] != s[j+d] && s[j] != s[j+d]) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <queue>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template<class T>
void chmin(T& a, T b) {
    if (a > b) a = b;
}

signed main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        v[i] = a;
    }

    ll sum_cost = INF;
    for (int base = -100; base <= 100; base++) {
        ll cost = 0;
        for (int i = 0; i < n; i++) {
            cost += pow(base - v[i], 2);
        }
        chmin<ll>(sum_cost, cost);
    }
    cout << sum_cost << endl;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr const char* YES = "Yes";
static constexpr const char* NO = "No";

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);

  if (N == M) {
    put(YES);
    return 0;
  }

  put(NO);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = intList()
    var lMax = 0
    var rMin = Int.MAX_VALUE
    repeat(m) {
        val (l, r) = intList()
        lMax = Math.max(lMax, l)
        rMin = Math.min(rMin, r)
    }
    val result = Math.max(0, (rMin - lMax + 1))
    println(result.toString())
}


Measured memory_bytes: 53928
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s[3];
    for(int i = 0;i < 3;i++)
    {
        cin >> s[i];
    }
    int i = 0,j = 0,k = 0;
    int next = s[0][i] - 'a';
    i++;
    while(true)
    {
        if(next == 0)
        {
            next = s[next][i] - 'a';
            if(i == s[0].size())
            {
                cout << "A\n";
                break;
            }
            else
            {
                i++;
            }
        }
        else if(next == 1)
        {
            next = s[next][j] - 'a';
            if(j == s[1].size())
            {
                cout << "B\n";
                break;
            }
            else
            {
                j++;
            }
        }
        else
        {
            next = s[next][k] - 'a';
            if(k == s[2].size())
            {
                cout << "C\n";
                break;
            }
            else
            {
                k++;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
#[allow(dead_code)]
fn tansaku_fn(iti: usize, n: usize, kyori: &mut Vec<i32>, map: &Vec<Vec<bool>>, ans: &mut Vec<usize>) {
    let mut tansaku1: Vec<usize> = Vec::new();
    for j in 0..n {
        if map[iti][j] == true {
            tansaku1.push(j);
        }
    }
    let mut tansaku2: Vec<usize> = Vec::new();
    for j in tansaku1 {
        if kyori[j] > kyori[iti] + 1 {
            kyori[j] = kyori[iti] + 1;
            ans[j] = iti;
            tansaku2.push(j);
        }
    }
    for iti1 in tansaku2{
        tansaku_fn(iti1, n, kyori, map, ans);
    }
}

fn is_prime(i: i64) -> bool {
    for j in 2..i/2 {
        if i % j == 0 {
            return false
        }
    }
    return true
}
fn main() {
    let n = read::<i64>();
    for i in n..2*n {
        if is_prime(i) {
            println!("{}", i);
            return
        }
    }

}

Measured memory_bytes: 2128