akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 924844033;
const int MAXN =(int) 2e3+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N,K;
LL g[MAXN*2],dp[MAXN*2][MAXN*2][2];
int id[MAXN*2];


void work(){
    scanf("%d%d",&N,&K);
    g[0]=1;
    for(int i=1;i<=N;i++) g[i]=g[i-1]*i%MOD;
    int curid=0;
    for(int i=1;i<=K;i++){
        for(int j=i;j<=N;j+=K){
            id[++curid]=j;
        }
    }
    for(int i=1;i<=K;i++){
        for(int j=i;j<=N;j+=K){
            id[++curid]=j;
        }
    }
//    for(int i=1;i<=curid;i++){
//        printf("%d ",id[i]);
//    }
//    printf("\n");
//    printf("curid = %d\n",curid);
    dp[0][0][0]=1;
    for(int i=1;i<=N*2;i++){
        for(int j=0;j<=i;j++){
            if(id[i]<=K){
                dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%MOD;
                dp[i][j][1]=0;
            }
            else{
                dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%MOD;
                if(j>0) dp[i][j][1]=dp[i-1][j-1][0];
            }
        }
    }
    LL ans=0;
    int tmp=1;
    for(int i=0;i<=N;i++){
        if(tmp==1){
            ans+=(dp[N*2][i][0]+dp[N*2][i][1])*g[N-i]%MOD;
        }
        else{
            ans+=MOD-(dp[N*2][i][0]+dp[N*2][i][1])*g[N-i]%MOD;
        }
        tmp*=-1;
    }
    printf("%lld\n",ans%MOD);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 250240
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
const double pi=3.141592653589793238;
int main(){
    long long mod=1000000007,n;
    cin >> n;
    if(n==1) cout << 0 << endl;
    else{
        long long x=1,y=1,z=2;
        for(int i=0; i<n; i++){
            x=(x*10)%mod;
            y=(y*8)%mod;
            z=(z*9)%mod;
        }
        long long ans=x+y-z;
        if(ans<0) cout << mod+ans << endl;
        else cout << ans << endl;
    }
}



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

namespace D

{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long kon = (long)Math.Sqrt(N);
            long ans = 0;
            for (long i = 1; i <= kon; i++)
            {

                if(N%i!=0)
                { continue; }
                long k = N / i - 1;
                if (k <= i) { continue; }
                ans += N / i - 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#9
S = input()[::-1]
for i in range(0, len(S)//5+1):
    if S[0:5] == 'maerd' or S[0:5] == 'esare':
        S = S[5:]
    elif S[0:6] == 'resare':
        S = S[6:]
    elif S[0:7] == 'remaerd':
        S = S[7:]
    else:
        break
print('YES' if len(S)==0 else 'NO')


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            IO io = new IO();

            //ここから
            int n = io.ReadLineToInt();
            int[] a = io.ReadLineToIntArray();

            int min = 0;

            for(int i = 0; i < n - 1; i++)
            {
                if (a[i] == a[i + 1])
                {
                    min++;
                    a[i + 1] = 0;
                }
            }

            //ここまで
            Console.Write(min);
            Console.ReadKey();
        }
    }

    //関数
    public class Func
    {
        public void Swap<T>(ref T a,ref T b)
        {
            T temp;
            temp = a;
            a = b;
            b = temp;
        }
    }

    //IOを担う関数群
    public class IO
    {
        //stringの入力
        public string ReadLineToString()
        {
            return Console.ReadLine();
        }

        //intの入力
        public int ReadLineToInt()
        {
            return int.Parse(Console.ReadLine());
        }

        //空白区切りの複数の文字列の入力をstring[]にして返す
        public string[] ReadLineToStringArray()
        {
            return Console.ReadLine().Split(' ').ToArray();
        }


        //空白区切りの複数の整数の入力をint[]にして返す
        public int[] ReadLineToIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        //空白区切りの複数の文字列の入力をList<string>で受け取る
        public List<string> ReadLineToStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        //空白区切りの複数の整数の入力をList<int>で受け取る
        public List<int> ReadLineToIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }

}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
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 ret=0;
struct SCC{
	//
	int V;
	vector<int> G[10000];
	vector<int> rG[10000];
	vector<int> vs,used,cmp;
	//
	SCC(int n){
		V=n;
		used.resize(V);
		cmp.resize(V);
	}
	//
	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	//
	void DFS(int v){
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			if(used[G[v][i]]==0){
				DFS(G[v][i]);
			}
		}
		vs.push_back(v);
	}
	//
	void rDFS(int v,int k){
		used[v]=1;
		cmp[v]=k;
		for(int i=0;i<rG[v].size();i++){
			if(used[rG[v][i]]==0){
				rDFS(rG[v][i],k);
			}
		}
	}
	//
	vector<int> scc(){
		fill(used.begin(),used.end(),0);
		for(int i=0;i<V;i++){
			if(used[i]==0){
				DFS(i);
			}
		}
		ret=0;
		fill(used.begin(),used.end(),0);
		for(int i=vs.size()-1;i>=0;i--){
			if(used[vs[i]]==0){
				rDFS(vs[i],ret++);
			}
		}
		return cmp;
	}
	//
};
int main(){
	int N,M;
	cin>>N>>M;
	SCC sc(N);
	vector<pair<int,int> > V;
	FOR(i,0,M){
		int s,t;
		cin>>s>>t;
		V.push_back(make_pair(s,t));
		sc.add_edge(s,t);
	}
	vector<int> ans=sc.scc();
	if(ret==1){
		cout<<0<<endl;
		return 0;
	}
	set<int> in[10000],out[10000];
	FOR(i,0,M){
		int ns=ans[V[i].first],nt=ans[V[i].second];
		if(ns==nt){
			continue;
		}
		out[ns].insert(nt);
		in[nt].insert(ns);
	}
	int ini=0,ouo=0;
	FOR(i,0,ret){
		if(in[i].empty()){
			ini++;
		}
		if(out[i].empty()){
			ouo++;
		}
	}
	cout<<max(ini,ouo)<<endl;
	return 0;
}


Measured memory_bytes: 16076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = longinf;
    ll sumFrontTo[N];
    sumFrontTo[0] = A[0];
    for(int i = 1; i < N; i++)
        sumFrontTo[i] = sumFrontTo[i-1] + A[i];
    ll sum = sumFrontTo[N-1];
    
    for(int i = 0; i < N - 1; i++){
        ans = min(ans, abs(sum - 2*sumFrontTo[i]));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int x=in,s=x,i;
    for (i=1;s%360!=0;i++){
        s+=x;
    }
    out(i);
}


Measured memory_bytes: 3632
n = int(input())
R = [int(input()) for l in range(n)]

max_profit = -(10**10)
R_min = R[0]

for j in range(1, n):
    if R[j] - R_min > max_profit:
        max_profit = R[j] - R_min
    if R[j] < R_min:
        R_min = R[j]

print(max_profit)



Measured memory_bytes: 13592
N = gets.to_i
A1 = gets.split.map(&:to_i)
A2 = gets.split.map(&:to_i)
sum1 =0
sum2 =0
A1.each{|i| sum1 += i }
A2.each{|i| sum2 += i }
sum1 -= A1[0]
sum2 -= A2[N-1]
i =0
max =sum1
while i < N-1 do
  max=sum1 if max < sum1
  max=sum2 if max < sum2
  sum1 -= A1[i+1]
  sum2 += A1[i+1]
  sum2 -= A2[i]
  i+=1
end
p max+A1[0]+A2[N-1]

Measured memory_bytes: 1788
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut v: Vec<i32> = parse_line().unwrap();
    let mut k: usize = 0;
    let mut t: usize = 0;

    while t < n {
        if v[t] % 2 == 0{
            v[t] = v[t] / 2;
            k = k + 1;
        } else {
            t = t + 1;
        }
    }

    println!("{}", k);
}


Measured memory_bytes: 2256
s = input()
n = len(s)-1
ans = 0
for bit in range(1<<n):
    tmp = s
    cnt = 0
    for i in range(n):
        if 1<<i & bit:
            tmp = tmp[:i+1+cnt] + '+' + tmp[i+1+cnt:]
            cnt += 1
    ans += eval(tmp)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if(x+y>=x-y && x+y>x*y)
    printf("%d\n",x+y);
    else if(x-y>=x+y && x-y>x*y)
    printf("%d\n",x-y);
    else
    printf("%d\n",x*y);
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(n) fori(somethingStupid,1,(n))


using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;

void solve(){
    int a, b; cin >> a >> b;
    cout << a*b << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    rep(t) solve();
    return 0;
}


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

using namespace std;

int main() {
  string s, c = "abc";
  cin >> s;
  sort(s.begin(), s.end());
  for (int i = 0; i < 3; i++) {
    if (s[i] != c[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


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

std::string S;
std::string T;

int main()
{
	int i, j;

	std::cin >> S;
	std::cin >> T;

	j = 0;
	for (i = 0; i < 3; i++) {
		if (T[i] == S[i]) {
			j++;
		}
	}

    std::cout << j;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    ATYN(S.substr(0,4) == "YAKI")

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    int n = 200000 , ans = 0;
    string s , t;
    cin >> s;
    cin >> t;
    for(int i =0 ; i<s.length(); i++){
        if(s[i] !=t[i])
            ans ++;
    }
    cout << ans;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (1000 == n ||
      2000 == n ||
      3000 == n ||
      4000 == n ||
      5000 == n ||
      6000 == n ||
      7000 == n ||
      8000 == n ||
      9000 == n ||
      1110 <= n && n <= 1119 ||
      2220 <= n && n <= 2229 ||
      3330 <= n && n <= 3339 ||
      4440 <= n && n <= 4449 ||
      5550 <= n && n <= 5559 ||
      6660 <= n && n <= 6669 ||
      7770 <= n && n <= 7779 ||
      8880 <= n && n <= 8889 ||
      9990 <= n && n <= 9999) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
}

Measured memory_bytes: 256
A,B=(int(x) for x in input().split())
a = int(A) % 2
b = int(B) % 2
if int(A) == 1 or int(B) == 1:
    print("1")

elif int(a) != 0 and int(b) != 0:
    mod = (int(A)*int(B)) % 2
    n = ((int(A) * int(B)) // 2) + int(mod)

    print(n)
else :
    n = (int(A) * int(B)) //2
    print(n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = numeric_limits<int>::max();

struct edge {
    int to;
    int len;
};

struct Graph {
    enum Color {WHITE, BLACK, RED};
    vector<vector<edge>> adj;
    vector<Color> color;
    Graph(int n) {
        adj.assign(n, vector<edge>());
        color.assign(n, WHITE);
    }
};

bool dfs(Graph& g, int u, Graph::Color color)
{
    g.color[u] = color;
    for (auto e : g.adj[u]) {
        Graph::Color next_color = color;
        if (e.len % 2 == 1) {
            next_color = color == Graph::BLACK ? Graph::RED : Graph::BLACK;
        }
        if (g.color[e.to] == Graph::WHITE) {
            if (!dfs(g, e.to, next_color)) {
                return false;
            }
        } else if (g.color[e.to] != next_color) {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    rep(i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        g.adj[u - 1].push_back({v - 1, w});
        g.adj[v - 1].push_back({u - 1, w});
    }

    rep(i, n) {
        if (g.color[i] == Graph::WHITE) {
            if (!dfs(g, i, Graph::BLACK)) {
                cout << "Error" << endl;
            }
        }
    }
    rep(i, n) {
        cout << (g.color[i] == Graph::BLACK ? 0 : 1) << endl;
    }
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, K, res;
int A[2000];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		ll c = 0;
		for (int j = 0; j < i; ++j) {
			if (A[i] > A[j]) {
				++c;
			}
		}
		res += (K*(K - 1) / 2) % mod*c;
		res %= mod;
		c = 0;
		for (int j = i + 1; j < N; ++j) {
			if (A[i] > A[j]) {
				++c;
			}
		}
		res += (K*(K + 1) / 2) % mod*c;
		res %= mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())
s = input()
start_pattern = ['SS', 'SW', 'WS', 'WW']
s2 = s+s[0]
for start in start_pattern:
    ans = start
    before = s[0]

    for i, now in enumerate(s2[1:]):
        if i == N-1:
            break
        before_state = ans[i]
        now_state = ans[i+1]
        if now_state == 'S':
            yes = 'o'
            no = 'x'
        else:
            yes = 'x'
            no = 'o'

        if now == yes:
            ans += before_state
        else:
            if before_state == 'S':
                ans += 'W'
            else:
                ans += 'S'
    if ans[0] == ans[-1]:
        ok = False
        if ans[0] == 'S':
            yes = 'o'
        else:
            yes = 'x'
        if s[0] == yes:
            if ans[1] == ans[-2]:
                ok = True
        else:
            if ans[1] != ans[-2]:
                ok = True
        if ok:
            print(ans[:-1])
            exit()
print('-1')


Measured memory_bytes: 3700
import sys


TEST_INPUT = [
    """
    1 1 2 2
    """,
    """
    314 159 2653 589
    """
]
ANSWER = [
    "14",
    "602215194"
]


class InputHandler:

    def __init__(self, text_lines="", is_test=False):
        self.data = list(text_lines.split("\n"))
        self.index = 0
        self.is_test = is_test

    def input(self):
        if self.is_test:
            self.index += 1
            return self.data[self.index].strip()
        else:
            return sys.stdin.readline().rstrip()


LARGE = 10 ** 9 + 7


def solve(r1, c1, r2, c2):

    fact = [0] * (r2 + c2 + 3)
    fact[0] = 1
    for i in range(1, r2 + c2 + 3):
        fact[i] = fact[i - 1] * i % LARGE

    fact_inv = [0] * (r2 + c2 + 3)
    fact_inv[-1] = pow(fact[-1], LARGE - 2, LARGE)
    for i in range(r2 + c2 + 1, -1, -1):
        fact_inv[i] = fact_inv[i + 1] * (i + 1) % LARGE

    def solve_special(r, c):
        return (fact[r + c + 2] * fact_inv[r + 1] * fact_inv[c + 1] - 1) % LARGE

    res = solve_special(r2, c2) - solve_special(r1 - 1, c2) - solve_special(r2, c1 - 1) + solve_special(r1 - 1, c1 - 1)

    return res % LARGE


def input_and_solve(ih):
    r1, c1, r2, c2 = map(int, ih.input().split())
    res = solve(r1, c1, r2, c2)
    return res


def main():
    ih = InputHandler()
    res = input_and_solve(ih)
    print(res)


def test():
    for test_input, ans in zip(TEST_INPUT, ANSWER):
        ih = InputHandler(test_input, True)
        res = input_and_solve(ih)
        # print(res, ans)
        assert str(res) == str(ans)


if __name__ == "__main__":
    # test()
    main()


Measured memory_bytes: 161268
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int L,R,d;	cin>>L>>R>>d;
	int ans=0;
	rep(i,L,R+1){
		if(i%d==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===

//=== xorshift
uint32_t xorshift32() {
    static uint32_t s = 1710;
    s = s ^ (s << 13);
    s = s ^ (s >> 17);
    s = s ^ ( s << 5);
    return s;
}
//===
template<typename T, typename Compare = less<T> >
struct MeldableHeap {
    struct Node {
        T dat;
        Node *l, *r;

        Node (T dat): dat(dat), l(nullptr), r(nullptr) {};
    };

    Node *root;
    Compare cmp;

    MeldableHeap (Compare cmp = Compare()): root(nullptr), cmp(cmp) {};

    Node *meld(Node *h1, Node *h2) {
        if (h1 == nullptr) return h2;
        else if (h2 == nullptr) return h1;

        if (cmp(h2->dat, h1->dat)) swap(h1, h2);
        
        if (xorshift32() & 1) h1->l = meld(h1->l, h2);
        else h1->r = meld(h1->r, h2);

        return h1;
    };

    void push(T dat) {
        Node *u = new Node(dat);
        root = meld(root, u);
    };

    T top() { return root->dat; };
    
    T pop() {
        T ret = top();
        Node *rm = root;
        root = meld(root->l, root->r);
        delete rm;
        
        return ret;
    };

    void merge_with(MeldableHeap &h) {
        root = meld(root, h);
        h.root = nullptr;
    };

    bool empty() { return root == nullptr; };
};
// MinHeap<T> = MeldableHeap<T, less<T>>
// MaxHeap<T> = MeldableHeap<T, greater<T>>
//===

int ABC141D() {
    llong n, m;
    llong a;
    MeldableHeap<llong, greater<llong> > h;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a;
        h.push(a);
    }

    for (int i = 0; i < m; i++) {
        a = h.pop() / 2;
        h.push(a);
    }

    llong sum = 0;
    while (!h.empty()) {
        sum += h.pop();
    }

    cout << sum << endl;
    
    return 0;
}

int main() {
    return ABC141D();
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(), (a).rend()

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    if((x - ans * 11 / 2) == 0) cout << ans << endl;
    else if((x - ans * 11 / 2) <= 6) cout << ans + 1 << endl;
    else cout << ans + 2 << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  vector<vector<int>> cand;
  vector<int> idx(N, 0);
  iota(idx.begin(), idx.end(), 1);
  do {
    cand.emplace_back(idx);
  } while (next_permutation(idx.begin(), idx.end()));
  sort(idx.begin(), idx.end());
  int a = 0, b = 0;
  for (int i = 0; i < (int)cand.size(); i++) {
    if (equal(cand[i].begin(), cand[i].end(), P.begin())) a = i;
    if (equal(cand[i].begin(), cand[i].end(), Q.begin())) b = i;
  }
  cout << abs(a - b) << '\n';
  return 0;
}


Measured memory_bytes: 3384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define SQ(A)   ((A)*(A))
using namespace std;
typedef long long ll;

int main(){
    int role[12];
    char *li;
    string str;
    while(getline(cin,str)){
        li=(char *)str.c_str();
        int len;
        char sp[]=" ";
        char *res=NULL;
        sscanf(strtok(li,sp),"%d",&len);
        int n=0;
        for(;;){
            res=strtok(NULL,sp);
            if(res==NULL) break;
            sscanf(res,"%d",&role[n]);
            n++;
        }
        double path[13][13];
        for(int i=0;i<n;i++){
            path[0][i]=path[i][0]=role[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                path[i][j]=sqrt(SQ(role[i]+role[j])-SQ(role[i]-role[j]));
            }
        }
        double dp[1<<n][n];
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                dp[i][j]=10000;
            }
        }
        for(int i=0;i<n;i++){
            dp[1<<i][i]=role[i];
        }
        for(int i=1;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                if(i&(1<<j)){
                    int bef=i-(i&(1<<j));
                    for(int k=0;k<n;k++){
                        if(bef&(1<<k)){
                            dp[i][j]=min(dp[i][j],dp[bef][k]+path[k][j]);
                        }
                    }
                }
            }
        }
        double ret=10000;
        for(int i=0;i<n;i++){
            ret=min(ret,dp[(1<<n)-1][i]+role[i]);
        }
        if(ret<=len) printf("OK\n");
        else printf("NA\n");
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

vector<vector<ll>> matmul(vector<vector<ll>>& A, vector<vector<ll>>& B, ll mod) {
    ll n = A.size();
    vector<vector<ll>> ans(n, vector<ll>(n));
    for(ll i=0; i<n; i++)
        for(ll j=0; j<n; j++)
            for(ll k=0; k<n; k++)
                (ans[i][j] += A[i][k] * B[k][j]) %= mod;
    return ans;
}

vector<vector<ll>> matpow(vector<vector<ll>> A, ll n, ll mod) {
    vector<vector<ll>> ans(A.size(), vector<ll>(A.size(), 0));
    for(ll i=0; i<A.size(); i++)
        ans[i][i] = 1;

    while(n>0) {
        if(n%2==1) ans = matmul(ans, A, mod);
        A = matmul(A, A, mod);
        n >>=1;
    }
    return ans;
}

int main() {
    ll N, K, mod = 1e9+7;
    cin >> N >> K;
    vector<vector<ll>> a(N, vector<ll>(N));
    for(ll i=0; i<N; ++i) for(ll j=0; j<N; j++) cin >> a[i][j];

    vector<vector<ll>> result = matpow(a, K, mod);
    ll ans =0;
    for(ll i=0; i<N; i++) for(ll j=0; j<N; j++) (ans += result[i][j]) %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define _GLIBCXX_DEBUG // ArrayOutofBounds
#define rep(i, N) for (int i = 0; i < N; i++) //制御変数iを用いてN回転
using namespace std;
using ll = long long;

int main() {
    ll sum = 0;
    string N;
    cin >> N;
    rep(i, N.size()) {
        if (!isdigit(N[i])) break;
        sum += N[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define all(A) (A).begin(), (A).end()
#define sz(A) int((A).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <ll> b(n - 1);
  for (ll& elem: b) cin >> elem;
  ll sum = b[0];
  ll prev = b[0];
  for (int i = 1; i < sz(b); i++) {
    // cur <= prev
    // cur <= b[i]
    sum += min(prev, b[i]);
    prev = b[i];
  }
  cout << sum + b.back() << '\n';
  return (0);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    int N = S.length();

    ll ans = N;
    for(int c = 0; c < 26; c++){
        char x = c + 'a';
        ll cnt = 0;
        ll tmp = 0;
        for(int i = N-1; i >= 0; i--){
            char s = S[i];
            if(s == x){
                chmax(tmp, cnt);
                cnt = 0;
            }
            else{
                cnt++;
            }
        }
        chmax(tmp, cnt);
        chmin(ans, tmp);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,i;
int dp[200001],h[200001];
int main(){
    cin>>n;
    for(i=1;i<=n;i++)cin>>h[i];
    for(i=2;i<=n;i++){
        if(i == 2){dp[i]=abs(h[i]-h[i-1]);continue;}
        dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	int c=0;
	vector<int> buf;
	while(cin>>n){
		c++;
		buf.push_back(n);
		if(c==5){
			sort(buf.begin(),buf.end());
			reverse(buf.begin(),buf.end());
			for(int i=0; i<buf.size(); i++){
				if(i!=0) cout<<" ";
				cout<<buf[i];
			}
			cout<<endl;
			buf.clear();
			c = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int A, B;
  cin >> A >> B;
  cout << max({A + A - 1, B + B - 1, A + B}) << endl;
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8

MAX = 10 ** 9

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split(" ")))
    max,min=(1,MAX)
    for i in range(n):
        if a[i] < min:
            min = a[i]
        if a[i] > max:
            max = a[i]
    
    print(max - min)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        long sum = 0;
        for(int i = 0; i < n.length; i++) {
            sum += (int)n[i] - 48;
        }
        if(sum % 9 == 0)
        System.out.println("Yes");
        else
        System.out.println("No");
	}
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	int ans;
	if(A>=13) ans=B;
	else if(A>=6) ans=B/2;
	else ans=0;
	cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
mod = 2019
count = [0] * 2019
count[0] = 1
tmp = 0
d = 1

for s in S[::-1]:
    tmp += int(s) * d
    count[tmp % mod] += 1
    d *= 10
    d %= mod

ans = 0

for c in count:
    ans += c * (c - 1) // 2
        
print(ans)

Measured memory_bytes: 74184
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    H = int(input())

    ans = 0
    n = 1
    for i in range(10**12):
        if H == 1:
            ans += n
            print(ans)
            exit()
        ans += n
        n *= 2
        H = int(H/2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

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

int main(){
	int a[100000],N,ans=0;
	cin>>N;
	REP(i,N){
		cin>>a[i];
	}
	map<int,int>mp;
	REP(i,N)mp[a[i]]++;
	for(auto p:mp){
		int x=p.first,n=p.second;
		if(x<=n)ans+=n-x;
		else ans+=n;
	}
	cout<<ans;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code
	string s, t;
	cin >> s >> t;
	int res=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			res += 1;
		}
	}
	cout << res;
	
}


Measured memory_bytes: 3712
#include<stdio.h>
int main(void){
    int L,A,B,C,D,cnt = 0;
    scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
    while(1){
        A = A - C;
        B = B - D;
        cnt++;
        if(C > A && D > B)break;
    }
    if(A > 0){
        cnt++;
    }
    if(B > 0){
        cnt++;
    }
    if(A > 0 && B > 0){
        cnt--;
    }
    L = L - cnt;
    printf("%d\n",L);
    return 0;
}

Measured memory_bytes: 596
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	a, b, k := scanInt(), scanInt(), scanInt()
	aa, ab := a, b
	if (k - a) > 0 {
		aa = 0
		k = k - a
	} else {
		aa -= k
		fmt.Println(aa, ab)
		return
	}
	if (k - b) > 0 {
		ab = 0
	} else {
		ab -= k
	}

	fmt.Println(aa, ab)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


class KMP:
    def __init__(self, needle):
        """
        https://ja.wikipedia.org/wiki/クヌース–モリス–プラット法
        :param typing.Sequence needle: 何を検索するか
        """
        self._needle = needle
        kmp = [0] * (len(needle) + 2)
        kmp[0] = -1
        kmp[1] = 0
        i = 2
        j = 0
        while i < len(needle):
            if needle[i - 1] == needle[j]:
                kmp[i] = j + 1
                i += 1
                j += 1
            elif j > 0:
                j = kmp[j]
            else:
                kmp[i] = 0
                i += 1
        self._kmp = kmp

    def index_of(self, haystack, m=0, i=0):
        """
        haystack の何番目に needle があるか。見つからなければ -1
        :param typing.Sequence haystack: 何から検索するか
        :param int m: The position of the current character in haystack
        :param int i: The position of the current character in needle
        :rtype: int
        """
        while m + i < len(haystack):
            if self._needle[i] == haystack[m + i]:
                i += 1
                if i == len(self._needle):
                    return m
            else:
                m += i - self._kmp[i]
                if i > 0:
                    i = self._kmp[i]
        return -1

    def search(self, haystack):
        """
        ret[i]: haystack[i:i+len(needle)] == needle
        :param typing.Sequence haystack: 何から検索するか
        :rtype: list of bool
        """
        ret = [False] * len(haystack)
        m = 0
        i = 0
        while m + i < len(haystack):
            m = self.index_of(haystack, m=m, i=i)
            if m < 0:
                break
            ret[m] = True
            m += len(self._needle) - self._kmp[len(self._needle) - 1] - 1
            i = max(0, self._kmp[len(self._needle) - 1])
        return ret


def test(t, s):
    ret = []
    for i in range(len(s)):
        ret.append(s[i:i + len(t)] == t)
    return ret


S = sys.stdin.buffer.readline().decode().rstrip()
T = sys.stdin.buffer.readline().decode().rstrip()

# kmp = KMP(T)
# print(kmp.search(S))

S *= 4
while len(S) < len(T) * 4:
    S *= 2

kmp = KMP(T)
idx = kmp.search(S)
ans = 0
for k in range(len(T)):
    i = k
    cnt = 0
    while i < len(idx):
        if idx[i]:
            cnt += 1
        else:
            ans = max(cnt, ans)
            cnt = 0
        i += len(T)
    ans = max(cnt, ans)
if len(T) * ans >= len(S) // 4 * 3:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 97784
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a,b,c,d = map(int,input().split())
ans = b-a+1
dim = 0
ca = a % c
if not ca:
    dim +=1
da = a % d
if not da:
    dim +=1
cd = lcm(c,d)
cda = a%cd
if not cda:
    ans+=1
dim+= (b-a+ca)//c
dim+= (b-a+da)//d
ans += (b-a+cda)//cd
print(ans-dim)

Measured memory_bytes: 5044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
map<string,int> M;
string s;
int main(){
	n=read();
	int ans=0;
	for(register int i=1;i<=n;i++){
		cin>>s;
		if(M[s])continue;
		M[s]=1;ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19316
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    mx = S.count('R') * S.count('G') * S.count('B')
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k < N:
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    mx -= 1

    print(mx)


if __name__ == '__main__':
    main()


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

int dp[5005][5005];

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  for(int i=n-1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(s[i]==s[j]) dp[i][j] = dp[i+1][j+1] + 1;
    }
  }

  int ans = 0;
  int p = 0;
  rep(i,n){
    rep(j,n){
      if(i>=j) continue;
      p = min(dp[i][j],j-i);
      ans = max(ans,p);
    }
  }
  cout << ans << endl;
}
  

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

int main() {
	IOS
	ll a,b;
	cin>>a>>b;
	ll res=1;
	for(ll p = 2; p*p <= max(a,b); p++) {
		bool c1,c2;
		c1=c2=0;
		while(a%p==0) {
			c1=1;
			a/=p;
		}
		while(b%p==0) {
			b/=p;
			c2=1;
		}
		if(c1 and c2) res++;
	}
	if(a==b and a>1) res++;
//	debug(a)
//	debug(b)
	cout<<res<<endl;
}


Measured memory_bytes: 3640
package main

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

func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	values := map[rune]int{}
	for _, s := range S {
		values[s]++
	}
	for _, s := range "abc" {
		_, ok := values[s]
		if !ok {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n;
    cin >> n;
    
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    int ma = a[n / 2], mb = b[n / 2];
    if (n % 2 == 0) {
        ma += a[n / 2 - 1];
        mb += b[n / 2 - 1];
    }
    cout << (mb - ma + 1) << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}



Measured memory_bytes: 4808