akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  queue<int> q;
  int rs = INT32_MAX;
  F0R(i, N) {
    int x;
    cin >> x;
    q.push(x);
    if (q.size() == K) {
      int l = q.front(), r = q.back();
      int score;
      if (l < 0) {
        if (r > 0) {
          score = min(abs(l), abs(r)) + r - l;
        }
        else {
          score = abs(l);
        }
      }
      else {
        score = abs(r);
      }
      chmin(rs, score);
      q.pop();
    }
  }
  cout << rs;
}
#endif


Measured memory_bytes: 3816
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K = map(int, input().split())
D = list(map(int, input().split()))


def ok(X):
    for d in D:
        if str(d) in str(X):
            return False
    return True

while not ok(N):
    N += 1

print(N)

Measured memory_bytes: 3572
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long A, long long B, long long C, long long D){
    if (A * B >= C * D) cout << A * B << '\n';
    else cout << C * D << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int dp[64][100+1];

int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N; 
    cin >> N;
    int fc = 0;
    ll abssum = 0;
    ll maxf = 1000000;
    for (int i = 0; i < N; ++i) {
        ll t;
        cin >> t;
        abssum += abs(t);
        if (t < 0) {
            ++fc;
        }
        maxf = min(maxf, abs(t));
    }

    if (fc % 2 == 0) {
        cout << abssum << std::endl;
    }
    else cout << (abssum - 2 * maxf) << std::endl;

    return 0;
}

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

#define mid(l,r) ((l+r)/2)

using namespace std;

const int N = 1e5 + 7;
const int inf = 1e9 + 7;

int main() {
	//freopen("t.gir", "r", stdin);
	//freopen("t.cik", "w", stdout);

	string s;

	cin >> s;

	int n = s.size();

	int cnt = 0;

	for(int i = 0; i < n/2; i++){
		if(s[i] != s[n - i - 1])
			cnt ++;
	}	

	cout << cnt;
}

Measured memory_bytes: 256
function main(lines) {
  const [X, Y] = splitN(lines[0]);
  
  let res = 'No';
  for (let a = 0, b = X; a <= X; a++, b--) {
    if (2*a + 4*b == Y) {
      res = 'Yes';
      break;
    }
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 29628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int cnt;
void insertionSort(VI& A, int n, int g){
  for(int i=g;i<n;++i){
	int v = A[i];
	int j = i - g;
	while(j >= 0 && A[j] > v){
	  A[j+g] = A[j];
	  j -= g;
	  ++cnt;
	}
	A[j+g] = v;
  }
}

void shellSort(VI& A, int n){
  cnt = 0;
  VI G;
  G.PB(1);

  while(G.back()*3+1 <= n)
	G.PB(G.back()*3+1);

  reverse(ALL(G));

  cout << SZ(G) << endl;
  cout << G[0];
  REP(i,SZ(G)-1) cout << " " << G[i+1];
  cout << endl;
  
  for(int i=0;i<SZ(G);++i)
	insertionSort(A, n, G[i]);
}

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

  int n; cin >> n;
  VI A(n);
  REP(i,n) cin >> A[i];
  shellSort(A, n);

  cout << cnt << endl;
  REP(i,n) cout << A[i] << endl;
  
  return 0;
}

Measured memory_bytes: 4956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 500000
#define SENTINEL 2000000000
constexpr int inf = 100000000;

int l[MAX/2+2],r[MAX/2+2];
int cnt;

void merge(int a[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++){
        l[i]=a[left+i];
    }
     for(int i=0;i<n2;i++){
        r[i]=a[mid+i];
    }
    l[n1]=SENTINEL;
    r[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        cnt++;
        if(l[i]<=r[j]){
            a[k]=l[i++];
        }else{
            a[k]=r[j++];
        }
    }
}

void mergesort(int a[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(a,left,mid);
        mergesort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){
    int a[MAX];
    int n;
    cnt=0;
    cin>>n;
    rep(i,n)cin>>a[i];
    mergesort(a,0,n);
    rep(i,n){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}












Measured memory_bytes: 6900
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	int x;
	cin >> x;

	if (x >= 1200) {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int a,b
    ;
  cin
    >>
    a  >>
    b
    ;
  ;;;;;;;
    ;
    if (
	a
	-
	b
	*
	2
	<=
	0
	)




      {

	puts(
	     "0"








	     );;




	;;

      } else



      {




	cout << a - 2 * b << endl;


      }



    
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define pll pair<ll,ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define ff first
#define ss second

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll a,b;
    cin >> a >> b;
    ll rozetki = 1;
    ll cnt = 0;
    while(rozetki < b){
        rozetki += a;
        rozetki--;
        cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
def p_d():
    class UnionFind:
        def __init__(self, n):
            self.par = list(range(n))
            self.rank = [0] * n
            self.size = [1] * n

        def find(self, x):
            if self.par[x] == x:
                return x
            self.par[x] = self.find(self.par[x])
            return self.par[x]

        def unite(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                x, y = y, x
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
            self.size[x] += self.size[y]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def get_size(self, x):
            return self.size[self.find(x)]

    n, m = map(int, input().split())
    ab = [map(lambda x: int(x) - 1, input().split()) for _ in range(m)]
    ans = n * (n - 1) // 2
    uf = UnionFind(n)
    res = []
    for a, b in reversed(ab):
        res.append(ans)
        if not uf.same(a, b):
            ans -= uf.get_size(a) * uf.get_size(b)
        uf.unite(a, b)
    print("\n".join(map(str, reversed(res))))


if __name__ == '__main__':
    p_d()


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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
typedef vector<int> vi;
const int maxn = 100 + 10;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
/*author: birdstorm*/
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int INF = 0x3f3f3f3f;
string s[MAXN], ans;
int n, len[MAXN], a[MAXN];
int dp[MAXN], dp2[MAXN];
int main() {
    int cs = 1;
    while(scanf("%d",&n) != EOF && n) {
        for(int i = 0; i < n; i ++) {
            cin >> s[i] >> a[i];
            len[i] = s[i].length();
        }
        cin >> ans;
        int length = ans.length();
        for(int i = 0; i <= length; i ++) {
            dp[i] = -INF;
        }
        dp[0] = 0;
        for(int i = 0; i <= length; i ++) {
            for(int j = 0; j < n; j ++) {
                int End = i - len[j];
                if(End >= 0 && dp[End] >= 0 && ans.substr(End, len[j]) == s[j]) {
                    dp[i] = max(dp[i], dp[End] + a[j]);
                }
            }
        }
        int sz = dp[length];
        for(int i = 0; i <= sz; i ++) {
            dp2[i] = INF;
        }
        dp2[0] = 0;
        for(int i = 0; i < n; i ++) {
            for(int j = 0; j <= sz - a[i]; j ++) {
                dp2[j+a[i]] = min(dp2[j+a[i]], dp2[j]+len[i]);
            }
        }
        printf("Case %d: %d\n",cs++,dp2[sz]);
    }
    return 0;
}

Measured memory_bytes: 3372
#include <stdio.h>
#include <math.h>
#define MAX 3
int main()
{
	int sum = 0;
	int a;
	scanf("%d", &a);
	for (int i = 0; i < MAX; i++)
	{
		sum += pow(a,i+1);
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2556
s=input()
cnt=0
ans="No"
flag=True

while cnt<len(s):
  if len(s)==1 or len(s)%2==1:
    flag=False
    break
  if s[cnt]=="h" and s[cnt+1]=="i":
    cnt+=2
    continue
  else:
    flag=False
    break
if flag:
  ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    n=n%1000;
    if (n==0)
    {
        cout<<0<<endl;
    }else
    {
        cout<<1000-n<<endl;
        
    }
    
    



    

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans=a[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
unittest
{
	assert( [ "4", "2100 2500 2700 2700" ].parse.expand.solve == "2 2" );
	assert( [ "5", "1100 1900 2800 3200 3200" ].parse.expand.solve == "3 5" );
	assert( [ "20", "800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990" ].parse.expand.solve == "1 1" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto gs = as.sort().map!( ( a ) => ( a < 3200 ) ? a / 400 : 10 ).group.array;
	if( gs[ $ - 1 ][ 0 ] < 10 ) return format( "%d %d", gs.length, gs.length );
	else                        return format( "%d %d", max( 1, gs.length - 1 ), gs.length - 1 + gs[ $ - 1 ][ 1 ] );
}


Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int N = 1e5 + 5;

int n, x, top, pos;
LL len, a[N], t[N], suf[N];

inline int nex(LL x) {
	return lower_bound(a + 1, a + 1 + n, x) - a - 1;
}
int main() {
	scanf("%d%d", &x, &n);
	a[1] = x;
	for(int i = 2; i <= n + 1; ++i)
		scanf("%lld", a + i);
	for(int i = 1; i <= n + 1; ++i) {
		while(top && a[top] >= a[i])
			--top;
		a[++top] = a[i];
	}
	n = top;
	t[n] = 1;
	for(int i = n; i > 1; --i) {
		len = a[i];
		pos = nex(len);
		while(pos) {
			t[pos] += t[i] * (len / a[pos]);
			len %= a[pos];
			pos = nex(len);
		}
		if(len) suf[len] += t[i];
	}
	for(int i = a[1] - 1; ~i; --i)
		suf[i] += suf[i + 1];
	for(int i = 1; i <= a[1]; ++i)
		printf("%lld\n", suf[i] + t[1]);
	for(int i = a[1] + 1; i <= x; ++i)
		putchar('0'), putchar('\n');
	return 0;
}


Measured memory_bytes: 4096
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
vector<int>g[2005];
int n,m,ml,sum;
inline void dfs(int x,int fa,int d)
{
	if(d>m/2)
		sum++;
	for(int i=0;i<g[x].size();i++)
		if(g[x][i]!=fa)
			dfs(g[x][i],x,d+1);
}
inline void dfs1(int x,int fa,int d)
{
	if(d>m/2)
		sum++;
	for(int i=0;i<g[x].size();i++)
		if(g[x][i]!=fa)
			dfs(g[x][i],x,d+1);
	for(int i=0;i<g[fa].size();i++)
		if(g[fa][i]!=x)
			dfs(g[fa][i],fa,d+1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans=0x3f3f3f3f;
	if(m%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			sum=0;
			dfs(i,0,0);
			ans=min(sum,ans);
		}
		printf("%d\n",ans);
	}
	else
	{
		for(int i=1;i<=n;i++)
			for(int x=0;x<g[i].size();x++)
			{
				sum=0;
				dfs1(i,g[i][x],0);
				ans=min(sum,ans);
			}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 384
#include <stdio.h>

char dividing(int pm, int pe, int pj);

int main(void)
{
    while (1) {
        int number;
        scanf("%d", &number);
        if (number == 0) {
            break;
        } else {
            for (int i = 0; i < number; i++) {
                int pm, pe, pj;
                scanf("%d %d %d", &pm, &pe, &pj);
                printf("%c\n", dividing(pm, pe, pj));
            }
        }
    }
}

char dividing(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100 || (pm + pe) / 2 >= 90 || (pm + pe + pj) / 3 >= 80) {
        return 'A';
    } else if ((pm + pe + pj) / 3 >= 70 || ((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80))) {
        return 'B';
    } else {
        return 'C';
    }
}

Measured memory_bytes: 1028
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            double[] s = ReadLine().Split(' ').Select(double.Parse).ToArray();
            double w = s[0];
            double h = s[1];
            double x = s[2];
            double y = s[3];

            int tmp = 0;
            if ((w / 2D) == x && (h / 2D) == y) tmp = 1;

            double S = w * h;
            WriteLine(
                (S/2D) + " " + tmp
                );

        }

    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 0x3f3f3f3f;

ll ans;
int n,a[100005];
int main(){
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    for(int i=2;i<n;i++) ans+=abs(a[i]);
    ans-=a[1];ans+=a[n];
    cout << ans << endl;
    int i;
    for(i=2;i<n && a[i]<=0;i++);
    int index=i;
    for(i;i<n;i++){
        cout << a[1] << " " << a[i] << endl;
        a[1]-=a[i];
    }
    for(i=1;i<index;i++){
        cout << a[n] << " " << a[i] << endl;
        a[n]-=a[i];
    }
    return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int r=sc.nextInt();
		System.out.println(2*r*Math.PI);
		sc.close();
	}


}


Measured memory_bytes: 35944
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  int s;
  cin >> s;

  set<int> key;
  key.insert(s);
  int count = 1;
  while (1)
  {
    if (s % 2 == 0)
    {
      s /= 2;
    }
    else
    {
      s = 3 * s + 1;
    }
    ++count;

    if (key.count(s) == 1) break;
    key.insert(s);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s,t,ans="No";
	cin>>s>>t;
	int k=s.size();
	s+=s;
	//cout<<s<<endl;
	for(int i=0;i<k;i++){
		string c;
		lp3(j,i+1,i+k+1){
			c+=s[j];
			//cout<<s[j]<<endl;
		}
		//cout<<c<<endl;
		if(c==t)ans="Yes";
	}
	cout<<ans<<endl;
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return;
    }
    n /= 2;
    ll ans = 0;
    while(n) {
        ans += n / 5;
        n /= 5;
    }
    cout << ans << endl;
}

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


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

int main()
{
    long n,d;
    cin>>n>>d;
    
    long x[n];
    long y[n];
    int  i,j=0;
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
    }
    d = pow(d,2);
    for(i=0;i<n;i++)
    {
        if ( ( pow(x[i],2)+pow(y[i],2) ) <= d )
        {
            j++;
        }
    }
    cout<<j;
    return 0;
}

Measured memory_bytes: 6716
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = [True] * N
for i in range(K):
    d = INT()
    B = LIST()
    for b in B:
        A[b-1] = False
print(sum(A))

Measured memory_bytes: 9988
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main (){
 int a,b,w;
 cin>>w>>a>>b;
 if (b>a+w&&b>a)
    cout<<abs(b-(a+w))<<endl;
  

 else if (b<a&&b+w<a)
    cout<<abs(a-(b+w))<<endl;
else 
    cout<<0;
return 0;

}


Measured memory_bytes: 256
from math import sqrt
N = int(input())
ans = 0
divisors = []

for i in range(2, int(sqrt(N))+1):
    if N%i==0:
        divisors.append(i)
        divisors.append(N//i)

for d in set(divisors):
    i = 1
    while N%(d**i)==0:
        i += 1
    n = N//(d**(i-1))
    if n%d==1:
        ans+=1

for i in range(2, int(sqrt(N))+1):
    if (N-1)%i==0:
        if i**2!=N-1:
            ans += 2
        else:
            ans += 1
if N==2:
    print(1)
else:
    print(ans+2)

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

int main(void)
{
  int L,m,n;
  while(1){
    int a =0;
    int q =0;
    cin >> L ;
    if(L == 0) break;
    else{
      for(int i =1  ; i <= 12;++i){
        cin >> m >> n;
        a += m-n;
        if(a >= L) ++q;
      }
      if(a < L) cout << "NA" << endl;
      else if(a >= L) cout << 12-q+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()
	sc.Scan()
	S := sc.Text()
	ans := 0
	for i := 0; i <= 999; i++ {
		temp := fmt.Sprintf("%03d", i)
		check := 0
		for j := 0; j < X; j++ {
			if temp[check] == S[j] {
				check++
				if check == 3 {
					ans++
					break
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
	int n,i,temp;
	scanf("%d",&n);
	int a[3*n];
	for (i=0;i<3*n;i++) scanf("%d",&a[i]);
	for(i=0;i<3*n;i+=3) {
		if (a[i]>a[i+1]){
			temp=a[i];
			a[i]=a[i+1];
			a[i+1]=temp;
		}
		if (a[i+1]>a[i+2]){
			temp=a[i+1];
			a[i+1]=a[i+2];
			a[i+2]=temp;
		}
		if(a[i]*a[i]+a[i+1]*a[i+1]==a[i+2]*a[i+2]){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 588
import numpy as np
# 改行無視して全部リストとして読み込む
N, D, *l=map(int, open(0).read().split())

x = l[0::2]
y = l[1::2]

x = np.array(x)
y = np.array(y)

x = x**2
y = y**2
z = x + y
count = np.sum(z <= D**2)

print(count)

Measured memory_bytes: 71096
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
int main()
{
    rkc;
    ll n;
    cin>>n;
    ll a[n];
    lld s;
    fl(i,0,n)
    {
        cin>>a[i];
        s+=(lld)1/a[i];
    }
   // cout<<s<<endl;
    cout<<fixed<<setprecision(10)<<1/s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for (int i=0;i<=7;i++) {
			String t = s.substring(0,i);
			t +=s.substring(s.length()-7+i);
			if ("keyence".equals(t)==true) {
				System.out.println("YES");
				return ;
			}
		}
		System.out.println("NO");
	}
}

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

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int c[20],a[20][20];
  
  rep(i,n){
    cin>>c[i];
    rep(j,m) cin>>a[i][j];
  }
  int ans=1e9;
  for(int bits=0;bits<(1<<n);bits++){
    int sum=0;
    int u[20];
    rep(i,m) u[i]=0;
    rep(i,n){
      if((bits>>i)&1){
	sum+=c[i];
	rep(j,m){
	  u[j]+=a[i][j];
	}
      }
    }
    bool f=true;
    rep(i,m){
      if(u[i]<x) f=false;
    }
    if(f) ans=min(sum,ans);
  }
  if(ans==1e9) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!

#a,b,c = [int(i) for i in input().split()]

n=int(input())
s=input()

a=0
b=0
for i in s:
    if i == "R":
        a+=1
    else:
        b+=1
    
if a > b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
int A[3]{ };

int main()
{
	for(int i = 0; i < 3; ++i)
		scanf("%d", &A[i]);
	std::sort(A, A+3);
	printf("%d\n", A[2]-A[0]);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

long long int min(long long int a, long long int b, long long int c){
    long long int ans = a;

    if(b < ans){
        ans = b;
    }
    if(c < ans){
        ans = c;
    }
    return ans;
}

int main(){
    long long int A,B,C;

    scanf("%lld %lld %lld", &A, &B, &C);

    long long int ans;

    if(A%2==0){
        ans=0;
    }else if(B%2==0){
        ans=0;
    }else if(C%2==0){
        ans=0;
    }else{
        ans=min(A*B, B*C, C*A);
    }

    printf("%lld", ans);

    return 0;
}

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

using namespace std;

#define PB push_back
#define MP make_pair

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

const int MOD = 1e9+7;
const int INF = 1e9;
const int MAX_N = 100;

int main() {
  int N;
  vi a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp; cin >> tmp;
    a.PB(tmp);
  }
  sort(a.begin(), a.end(), greater<int>());

  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++) {
    !(i & 1) ? Alice += a[i] : Bob += a[i];
  }

  cout << (Alice - Bob) << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

S = np.array(list(input()))
num_x = np.count_nonzero(S == 'x')
# print(f'{num_x=}')
A = [s for s in S if s != 'x']
# print(f'{S=}, {A=}')

if len(A) % 2 == 0:
    L = A[:len(A) // 2]
    R = A[len(A) // 2:][::-1]
else:
    L = A[:len(A) // 2]
    R = A[len(A) // 2 + 1:][::-1]
# print(f'{L=}, {R=}')
if not np.all(L == R):
    print(-1)
    exit()

# 真ん中までSとreverse_Sを進めていってXの数が足りない分それぞれ足す
# x以外の文字でsplitをする？'x' '' 'x' ''

T = []
subset = ''
for s in S:
    # print(f'{subset=}')
    if s == 'x':
        subset += 'x'
    else:
        T.append(subset)
        subset = ''
T.append(subset)
len_T = np.array([len(t) for t in T])
# print(f'{T=}, {len_T=}, {len_T - len_T[::-1]}')
ans = np.abs(len_T - len_T[::-1]).sum() // 2
print(ans)


Measured memory_bytes: 41804
X=int(input())
A=0
B=X
while B>=100:
    B-=100
    A+=1
while B>=5:
    B-=5
    A-=1
while B>=4:
    B-=4
    A-=1
while B>=3:
    B-=3
    A-=1
while B>=2:
    B-=2
    A-=1
while B>=1:
    B-=1
    A-=1
if A>=0:
    print(1)
else:
    print(0)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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

const int64 mod = 1e9+7;

int main(void){
	int64 N, L, T;
	cin >> N >> L >> T;
	vector<int64> X(N), W(N);
	REP(i, N) cin >> X[i] >> W[i];
	int64 cnt = 0;
	REP(i, N){
		if(W[i] == 1){
			cnt += (X[i]+T-1)/L;
			X[i] = (X[i]+T)%L;
		}else{
			cnt -= ((L-X[i])+T-1)/L;
			X[i] = (X[i]-T%L+L)%L;
		}
	}
	cnt = (cnt%N+N)%N;
	sort(all(X));
	REP(i, N){
		cout << X[(i+cnt)%N] << endl;
	}
}

Measured memory_bytes: 2816
#include<stdio.h>
int sum(int);
int main(){
  int n,a,b,i,ans=0;
  scanf("%d%d%d",&n,&a,&b);
  for(i=1;i<=n;i++){
    if(a<=sum(i)&&sum(i)<=b){
      ans+=i;
    }
  }
  printf("%d",ans);
}
int sum(int n){
  int s;
  s=n/10000+(n%10000)/1000+(n%1000)/100+(n%100)/10+n%10;
  return s;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int MAX_PRIME = (1 << 15);
const int MAX_PR = 3512;
bool prime[MAX_PRIME + 1];
int pr[MAX_PR + 1];

void init_prime()
{
    for (int i = 0; i <= MAX_PRIME; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= MAX_PRIME; i++) 
        if (prime[i])
            for (int j = 2 * i; j <= MAX_PRIME; j += i)
                prime[j] = false;

    int idx = 0;
    for (int i = 0; i <= MAX_PRIME; i++)
        if (prime[i])
            pr[idx++] = i;
}

void solve(int n)
{
    int ans = 0;

    for (int i = 0; pr[i] <= n; i++)
        for (int j = i; pr[i] + pr[j] <= n; j++) {
            if (pr[i] + pr[j] == n )
                ans++;
        }
    cout << ans << endl;
}

int main()
{
    int n;
    
    init_prime();
    while (cin >> n, n) {
        solve(n);
    }

    return 0;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;

int main(){
  ll ans=0;
  cin >> n >> m;
  if (n==m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n, q = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

stack = deque([0])
seen = [False]*n
while len(stack) > 0:
    parent = stack.pop()
    seen[parent] = True
    for child in graph[parent]:
        if seen[child]:
            continue
        ans[child] += ans[parent]
        stack.append(child)

print(*ans)

Measured memory_bytes: 56168
import java.util.Scanner;
public class Main{
    
    public static void main (String[] args){
       
       Scanner sc = new Scanner (System.in);
       
       int N = sc.nextInt();
       String S = sc.next();
       int K = sc.nextInt();
       
       char A = S.charAt(K-1);
       
       
       for (int index=0; index<N; index++){
           
           if (A==S.charAt(index)){
               System.out.print(A);
           } else {
               System.out.print("*");
           }
       }
       
       System.out.println();
    }
}

Measured memory_bytes: 23124
H, W = map(int, input().split(' '))
s = []
for _ in range(H):
    s.append(input())

dp = [[10 ** 9 for i in range(W)] for j in range(H)]
dp[0][0] = 0 if s[0][0] == '.' else 1

for i in range(H):
    for j in range(W):
        if i + 1 < H:
            cost = int(s[i][j] == '.' and s[i + 1][j] == '#')
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost)
        if j + 1 < W:
            cost = int(s[i][j] == '.' and s[i][j + 1] == '#')
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost)

print(dp[H - 1][W - 1])

Measured memory_bytes: 43120
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    vector<int> a_in(N), b_in(N), a(N), b(N);

    REP(i, N) { cin >> a_in[i]; }

    REP(i, N) { cin >> b_in[i]; }

    int res = 0;
    for (int k = sizeof(int) * 8 - 2; k >= 0; --k) {
        res <<= 1;

        REP(i, N) {
            a[i] = a_in[i] % (1 << (k + 1));
            b[i] = b_in[i] % (1 << (k + 1));
        }

        sort(ALL(a));
        sort(ALL(b));

        long long T = 1 << k;
        int flag = 0;
        REP(i, N) {
            auto l1 = lower_bound(ALL(b), T - a[i]);
            auto u1 = upper_bound(ALL(b), 2 * T - a[i] - 1);

            auto l2 = lower_bound(ALL(b), 3 * T - a[i]);
            auto u2 = upper_bound(ALL(b), 4 * T - a[i] - 1);

            flag = (flag + (u1 - l1) + (u2 - l2)) % 2;
        }
        res |= flag;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	bool arr[3];
	arr[0] = true;
	arr[1] = arr[2] = false;
	for(string s; getline(cin, s);) {
		int ind_a = s[0] - 'A';
		int ind_b = s[2] - 'A';
		swap(arr[ind_a], arr[ind_b]);
	}
	cout << (char)('A' + (find(arr, arr + 3, true) - arr)) << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << '\n';cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const int inf = 0x3f3f3f3f;
const int mod = 998244353;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,x,t; cin >> n >> x >> t;
	int seq = n/x + (n%x != 0);
	cout << seq*t << '\n';
}


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

int main(void){
    int n,i,cnt,ans,j;
    cnt = 0;
    ans = 0;

    cin >> n;

    for(i=1; i<=n; i += 2){
        for(j=1; j<=i; j += 2){
            if(i % j == 0)  cnt++;
        }
        if(cnt == 8)    ans++;
        cnt = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s ==  "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac),sum([w * a for a,w in zip(ac, wa)]))
    
    
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Measured memory_bytes: 18980
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);
//mt19937_64 gen(41);

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r, g, b;
	vector<int> pref_r(n + 1, 0), pref_g(n + 1, 0), pref_b(n + 1, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			r.push_back(i);
		if (s[i] == 'G')
			g.push_back(i);
		if (s[i] == 'B')
			b.push_back(i);
		pref_r[i + 1] = r.size();
		pref_g[i + 1] = g.size();
		pref_b[i + 1] = b.size();
	}
	ll res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) {
				continue;
			}
			if (s[i] != 'R' && s[j] != 'R') {
				res += r.size() - pref_r[j];
				if (j + j - i < n && s[j + j - i] == 'R')
					res--;
			}
			if (s[i] != 'G' && s[j] != 'G') {
				res += g.size() - pref_g[j];
				if (j + j - i < n && s[j + j - i] == 'G')
					res--;
			}

			if (s[i] != 'B' && s[j] != 'B') {
				res += b.size() - pref_b[j];
				if (j + j - i < n && s[j + j - i] == 'B')
					res--;
			}
		}
	}
	cout << res;
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 3692
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int a = stdIn.nextInt();
	int b = stdIn.nextInt();
	int min=Math.min(a,b);
	int max=Math.max(a,b);
	for(int i=0;i<max;i++){
	    System.out.print(min);
	}
	System.out.println("");
    }
}


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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





int main(){
    int N, T; std::cin >> N >> T;
    std::vector<std::pair<int, int>> AB(N);
    for(int i(0); i < N; ++i){
        std::cin >> AB[i].first >> AB[i].second;
    }
    std::sort(std::begin(AB), std::end(AB));
    //dp[i][j] := (1からi 1o)でj分以内に完食 おいしさの合計max
    std::vector<std::vector<int>> dp(N, std::vector<int>(T, 0));
    for(int i(1); i < N; ++i){
        for(int j(0); j < T; ++j){
            dp[i][j] = dp[i-1][j];
            if(j >= AB[i-1].first){
                chmax(dp[i][j], dp[i-1][j-AB[i-1].first] + AB[i-1].second);
            }
        }
    }
    int ans(0);
    for(int i(1); i < N; ++i){
        chmax(ans, dp[i][T-1] + AB[i].second);
    }
    std::cout << ans << std::endl;
    return 0;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
long long X[1000], Y[1000], Z[1000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N) cin >> X[i] >> Y[i] >> Z[i];

  long long m = 0;
  for (int a=-1; a<=1; a+=2) {
    for (int b=-1; b<=1; b+=2) {
      for (int c=-1; c<=1; c+=2) {
        vector<long long> vs;
        rep(i, N) vs.pb(a*X[i]+b*Y[i]+c*Z[i]);
        sort(all(vs), greater<long long>());
        long long s = 0;
        rep(i, M) s += vs[i];
        m = max(m, s);
      }
    }
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//自作関数 a^n mod MODを求める
int m_pow(int a, int n){
  if(n == 0) return 1;
  if(n % 2 == 0){
    int t = m_pow(a, n / 2);
    return t * t % MOD;
  }
  return a * m_pow(a, n - 1) % MOD;
}

struct str{
  bool isTop;
  string c;
};

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  string s;
  int q;
  cin >> s >> q;
  vec t(q);
  vec f(q);
  vector<char> c(q);
  REP(i,q){
    cin >> t[i];
    if(t[i] == 2){
      cin >> f[i];
      cin >> c[i];
    }
  }

  bool isTop = true;
  deque<char> ans;
  REP(i,s.size()){
    ans.push_back(s[i]);
  }
  REP(i,q){
    if(t[i] == 1){
      isTop = !isTop;
    }
    else{
      if(f[i] == 1){
        if(isTop){
          ans.push_front(c[i]);
        }
        else{
          ans.push_back(c[i]);
        }
      }
      else{
        if(isTop){
          ans.push_back(c[i]);
        }
        else{
          ans.push_front(c[i]);
        }
      }
    }
  }

  if(!isTop) reverse(ans.begin(), ans.end());
  string anss = "";
  REP(i,ans.size()){
    anss += ans[i];
  }
  cout << anss << endl;
  return 0;
}

Measured memory_bytes: 4696
import math

N = int(input())
n = int(math.sqrt(N))

def f_ab(a, b):
    if len(str(a)) >= len(str(b)):
        return len(str(a))
    else:
        return len(str(b))

ans = float('inf')
for a in range(1, n+1):
    if N % a == 0:
        b = N // a
        ans = min(ans, f_ab(a, b))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int n,x,c;
    for (;;) {
        cin >> n >> x;
        c = 0;
        if (!n && !x) break;
        for (int i=1; i<=n; i++){
            for (int j=i+1; j<=n; j++){
                for (int k=j+1; k<=n; k++){
                    if (i+j+k == x) c += 1;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;



void Main(){

    ll N,X; cin>>N>>X;
    ll layer[51];
    layer[0]=1;
    rep(i,50){
        layer[i+1]=layer[i]*2+3;
    }

    ll putty=0;
    ll compburg=0;
    ll surpluslayer=X;

    repr(i,N-1,0){

        putty+=compburg;
        compburg*=2;

        if(surpluslayer==0) surpluslayer=0;
        else if(surpluslayer<layer[i]+1) surpluslayer-=1;
        else if(surpluslayer==layer[i]+1) {
            ++compburg;
            surpluslayer=0;
        }
        else if(surpluslayer<layer[i]*2+2){
            ++putty;
            ++compburg;
            surpluslayer-=layer[i]+2;
        }
        else{
            ++putty;
            compburg+=2;
            surpluslayer=0;
        }
    }

    cout<< putty+compburg <<"\n";
}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 256