akhauriyash/Code-Regression huggingface dataset:
list1=[0]*3
list2=[0]*3
list3=[0]*3
list4=[0]*3
c=0
for i in range(3):
    list1[i], list2[i],  list3[i]= map(int, input().split())
n=int(input())
for j in range(n):
    b=int(input())
    if b in list1:
        list1[list1.index(b)]=0
    if b in list2:
        list2[list2.index(b)]=0
    if b in list3:
        list3[list3.index(b)]=0
for i in range(3):
    list4[i]=list1[i]+list2[i]+list3[i]
d=list1[0]+list2[1]+list3[2]
e=list1[2]+list2[1]+list3[0]
if sum(list1)==0 or sum(list2)==0 or sum(list3)==0 or d==0 or e==0 or(0 in list4):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ps = Input.ar;
        var uf = new UnionFind<int>();
        for (var i = 0; i < nm[0]; i++)
            uf.MakeSet(i + 1);
        for(var i = 0; i < nm[1]; i++)
        {
            var inp = Input.ar;
            uf.Union(inp[0], inp[1]);
        }
        WriteLine(Enumerable.Range(0, nm[0]).Select(v => uf.IsSame(v + 1, ps[v]) || ps[v] == v + 1).Count(b => b));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class UnionFind<T>
{
    private class Vertex
    {
        public T Key { get; set; }
        public Vertex Parent { get; set; }
        public int Rank { get; set; }
        public Vertex(T key) : this(key, null, 0)
        {

        }
        public Vertex(T key, Vertex Parent, int rank)
        {
            this.Key = key;
            this.Parent = Parent;
            this.Rank = rank;
        }
    }
    private readonly Dictionary<T, Vertex> dics;
    private readonly Vertex NIL;

    public int Count { get; private set; }

    public UnionFind()
    {
        NIL = new Vertex(default(T));
        dics = new Dictionary<T, Vertex>();
    }
    
    public T parent(T key)
        => FindSet(dics[key].Parent).Key;
    
    public bool IsSame(T key1, T key2)
    {
        if (!dics.ContainsKey(key1) || !dics.ContainsKey(key2))
            return false;
        return ReferenceEquals(FindSet(dics[key1]),FindSet(dics[key2]));
    }

    public bool MakeSet(T key)
    {
        if (dics.ContainsKey(key))
            return false;
        dics[key] = new Vertex(key, NIL, 0);
        dics[key].Parent = dics[key];
        Count++;
        return true;
    }

    public bool Union(T key1, T key2)
    {
        if (!dics.ContainsKey(key1) || !dics.ContainsKey(key2))
            return false;
        if (IsSame(key1, key2)) return false;
        Link(FindSet(dics[key1]), FindSet(dics[key2]));
        Count--;
        return true;
    }

    private void Link(Vertex vex1, Vertex vex2)
    {
        if (vex1.Rank > vex2.Rank)
        {
            vex2.Parent = vex1;
        }
        else
        {
            vex1.Parent = vex2;
            if (vex1.Rank == vex2.Rank)
                vex2.Rank++;
        }
    }

    private Vertex FindSet(Vertex vex)
    {
        if (!ReferenceEquals(vex.Parent, vex))
            vex.Parent = FindSet(vex.Parent);
        return vex.Parent;
    }
}


Measured memory_bytes: 37408
//ex9_1
//TKC001

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 10

//data[SIZE-1]がstackの底、data[0]が天井、topはstackの一番上の要素の位置
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
//stackの初期化、何もないっていない状態にする。
void init_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
//番号が若い方が上なので、stackに要素が追加されるとtopが小さくなる
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//配列dataの一番番号の若いやつをstackから外す。
void delete(stack *stk){
    if(stk->count <= 0){
        //何もしないけど気持ち悪いから書いた
    }
    else{
        stk->top++;
        stk->count--;
    }
}
//dataの中身を後ろからcount個出力=stackの内容をすべて出力
void print_stack(stack *stk){
    int i;
    for(i = SIZE-1; i > SIZE-1-stk->count; i--){
        printf("%c", stk->data[i]);
    }
}

int main(void){
    int i;
    char str[SIZE+1];
    stack stk;
    //stackの初期化
    init_stack(&stk);
    //入力
    scanf("%s", str);
    //strの要素に応じてpushとdeleteを決める
    for (i = 0; i < strlen(str); i++){
        if(str[i] == 'B'){
            delete(&stk);
        }
        else if(str[i] == '0'){
            push(&stk, '0');
        }else{
            push(&stk, '1');
        }
    }
    //出力
    print_stack(&stk);
    

    return 0;
}

Measured memory_bytes: 1576
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
  public static void main(String[] args) throws Exception{
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int value;
      value = Integer.parseInt(in.readLine());
      System.out.println(value*value*value);
      in.close();
  }
}

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

int char_to_int(char c){
    int return_num;
    stringstream ss;
    ss << c;
    ss >> return_num;
    return return_num;
}

int main() {

    int n,a,b;

    cin >> n >> a >> b;

    long long int ans = 0;

    for(int i=1; i<=n; i++){
        string s;
        stringstream ss;
        ss << i;
        ss >> s;
        int digit_sum = 0;
        for(int j=0; j<s.size(); j++){
            digit_sum += char_to_int(s[j]);
        }
        if(a <= digit_sum && digit_sum <= b){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int N, M;
int a[1002], b[1002];
vector<int> c[1002];
int ctemp;
vector<int> keylist[14];
unordered_map<string, long long> memo;

long long costrec(string openlist){
    if(memo.find(openlist) != memo.end()) return memo[openlist];
    // cout << openlist << endl;
    int iszero = 0;
    for(int i=0;i<N;i++){
        if(openlist[i] == '0') iszero++;
    }
    if(iszero == N){
        memo[openlist] = 0;
        return 0;
    }

    long long cost = 1e18;
    for(int i=0;i<N;i++){
        if(openlist[i] == '1'){
            vector<int> keys = keylist[i+1];
            for(auto keyitr=keys.begin();keyitr!=keys.end();keyitr++){
                int key = *keyitr;
                vector<int> boxlist = c[key];
                string newopenlist = openlist;
                for(auto boxitr=boxlist.begin();boxitr!=boxlist.end();boxitr++){
                    int box = *boxitr;
                    newopenlist[box-1] = '0';
                }
                cost = min(cost, costrec(newopenlist) + a[key]);
            }
        }
    }
    memo[openlist] = cost;
    return cost;
}

int main(){

    cin >> N >> M;
    for(int m=0;m<M;m++){
        cin >> a[m] >> b[m];
        for(int i=0;i<b[m];i++){
            cin >> ctemp;
            c[m].push_back(ctemp);
            keylist[ctemp].push_back(m);
        }
    }

    string startstr;
    for(int i=0;i<N;i++) startstr += "1";
    long long ans = costrec(startstr);
    if(ans == 1e18){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    int numOdds = (N + 1) / 2;    
    cout << (static_cast<double>(numOdds) / static_cast<double>(N)) << endl;
}


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

int N, M;

bool solve(int A[], int i, int m) {
	if (m == 0) return true;
	if (i == N) return false;
	return solve(A, i + 1, m) || solve(A, i + 1, m - A[i]);
}

int main() {

	int m;

	// input number
	cin >> N;
	int* A = new int[N];
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	
	// input count of target
	cin >> M;
	for (int i = 0; i < M; i++) {
		scanf("%d", &m);
		bool result = solve(A, 0, m);
		cout << (result ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 3244
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	int n, a;
	cin >> n >> a;
	cout << n*n - a << endl;


	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <cstring>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	long long c=n/k;
	if(k%2)cout<<c*c*c<<endl;
	else{
		k/=2;
		c=n/k;
		long long a=c/2;
		long long b=c/2;
		if(c%2)a++;
		long long ans=a*a*a+b*b*b;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int s[100005];
int main()
{
    long long int h,n,sum;
    while(cin>>h>>n)
    {
        sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&s[i]);
            sum+=s[i];
        }
        if(sum>=h)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 640
def p(s):
    rev=''.join(reversed(s))
    k=0
    if(s==rev):
        k=1
    return k
s=input()
n=len(s)
if(p(s)==1 and p(s[:(n-1)//2])==1 and p(s[((n+3)//2)-1:])==1):
    print("Yes")
else:
    print("No")

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

int main() {
int N,K;
  cin >> N >> K;
if(N > K){
	for(int i = 0; i < N; i++){
    	cout << K;
    }
}
  else{
  	for(int i= 0; i < K; i++){
    	cout << N;
    }
    
  }
}

Measured memory_bytes: 256
#include <complex>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;

#define X real()
#define Y imag()

#define fi first
#define se second

typedef complex<double> PT;
typedef PT VC;
typedef pair<PT,PT> LN;
typedef pair<PT,PT> SG;

const double EPS = 1e-8;

double dot_prod(VC a, VC b) {
	return a.X * b.X + a.Y * b.Y;
}
double cross_prod(VC a, VC b) {
	return a.X * b.Y - a.Y * b.X;
}

double dist_pts_line(PT p, LN l) {
	VC a, b;
	a = l.fi - p;
	b = l.se - p;
	return abs(cross_prod(a,b) / abs(l.fi-l.se));
}

vector<PT> intersec_line_line(LN a, LN b) {
	vector<PT> res;
	if(abs(cross_prod(a.fi-a.se, b.fi-b.se)) < EPS)
		return res;
	if(abs(cross_prod(b.fi-a.fi, b.se-a.fi)) < EPS)
		swap(a.fi, a.se);
	
	VC va, vb, vc;
	double s, t;
	va = b.fi - a.fi;
	vb = b.se - a.fi;
	vc = a.se - a.fi;
	s = cross_prod(va, vc) / cross_prod(va, vb);
	t = cross_prod(vc, vb) / cross_prod(va, vb);
	res.push_back(a.fi + (t * va + s * vb) / (s+t));
	return res;
}

bool on_seg(PT p, SG a) {
	VC b, c;
	b = a.fi - p;
	c = a.se - p;
	return dot_prod(b,c) < EPS && abs(cross_prod(b,c)) < EPS;
}

vector<PT> intersec_seg_seg(SG a, SG b) {
	vector<PT> tmp, res;
	tmp = intersec_line_line(a,b);
	for(int i = 0; i < tmp.size(); i++) {
		if(on_seg(tmp[i], a) && on_seg(tmp[i],b))
			res.push_back(tmp[i]);
	}
	return res;
}


// テ、ツサツ・テ、ツクツ甘・ツケツセテ、ツスツ陛」ツδゥテ」ツつ、テ」ツδ姪」ツδゥテ」ツδェテ・ツ?凖ァツオツ?

double dist_pts_seg(PT p, SG a) {
	double res;
	res = min(abs(a.fi-p), abs(a.se-p));
	if(dot_prod(a.se - a.fi, p - a.fi) > -EPS
			&& dot_prod(a.fi - a.se, p - a.se) > -EPS)
		res = min(res, dist_pts_line(p, a));
	return res;
}

double dist_seg_seg(SG a, SG b) {
	double res;
	res = min(
			min(dist_pts_seg(a.fi,b), dist_pts_seg(a.se,b)),
			min(dist_pts_seg(b.fi,a), dist_pts_seg(b.se,a)) );
	if(intersec_seg_seg(a,b).size())
		res = 0;
	return res;
}

/* //テ・ツケツセテ、ツスツ陛」ツδ?」ツつケテ」ツδ?
int main() {
	SG a(PT(0,0),PT(0,2));
	SG b(PT(-1,1),PT(2,1));
	cout << dist_seg_seg(a,b) << endl;
} // */

//*
int N, M, L;
vector<vector<SG> > star;
double edge[120][120];

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

void init() {
	star.clear();
	rep(i,120) {
		rep(j,120)
			edge[i][j] = 1e9;
		edge[i][i] = 0;
	}
}

int main() {
	while(cin >> N >> M >> L, N || M || L) {
		init();
		M--; L--;
		rep(i,N) {
			int x, y, a, r;
			cin >> x >> y >> a >> r;
			vector<PT> tmp;
			double theta = (a+90) / 180.0 * M_PI;
			double phi = 360.0 / 5.0 / 180.0 * M_PI;
			rep(i,5) {
				tmp.push_back(polar((double)r, theta + phi * i) + PT(x,y));
			//	cout << tmp[i] << endl;
			}
			vector<SG> push;
			rep(i,5) {
				push.push_back(SG(tmp[i],tmp[(i+2)%5]));
			}
			star.push_back(push);
		}

		rep(i,N) {
			for(int j = i+1; j < N; j++) {
				double tmp = 1e9;
				rep(k,5) {
					rep(l, 5) {
						tmp = min(tmp, dist_seg_seg(star[i][k], star[j][l]));
					}
				}
				edge[i][j] = edge[j][i] = tmp;
			}
		}

		rep(i,N) {
			rep(j,N) {
				rep(k,N) {
					edge[j][k] = min(edge[j][k], edge[j][i] + edge[i][k]);
				}
			}
		}
		printf("%.10lf\n", edge[L][M]);
	}
}
// */

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

typedef long long int int64;
struct vertex {
	int i;
	int64 val;
	int size;
	int parent;
	int next,child;
	int depth;
} v[100003];
void dfs(int i)
{
	for(int j = v[i].child;j != -1;j = v[j].next) {
		v[j].depth = v[i].depth + 1;
		dfs(j);
	}
}
int n;
bool cmp1(const vertex &a,const vertex &b) {
	return a.val < b.val;
}
int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		scanf("%lld",&v[i].val);
		v[i].i = i + 1;
		v[i].size = 1;
	}
	std::sort(v,v+n,cmp1);
	std::map<int64,int> m;
	for(int i = 0;i < n;++i) {
		m[v[i].val] = i;
		v[i].next = v[i].child = -1;
	}
	for(int i = n - 1;i >= 1;--i) {
		int64 val2 = v[i].val - n + 2LL * v[i].size;
		std::map<int64,int>::iterator it = m.find(val2);
		if(it == m.end()) {
			printf("-1\n");
			return 0;
		}
		v[i].parent = it->second;
		v[v[i].parent].size += v[i].size;
		v[i].next = v[v[i].parent].child;
		v[v[i].parent].child = i;
	}
	int64 dsum = 0;
	dfs(0);
	for(int i = 0;i < n;++i) {
		dsum += v[i].depth;
	}
	if(v[0].size == n && v[0].val == dsum) {
		for(int i = 1;i < n;++i) {
			printf("%d %d\n", v[i].i, v[v[i].parent].i);
		}
	} else {
		printf("-1\n");
	}
}


Measured memory_bytes: 13056
using System;
using System.Linq;

namespace B___Bounding
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NX[0], X = NX[1];
            var Li = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Di = new int[N + 1];

            Di[0] = 0;
            for (int i = 1; i <= N; i++)
                Di[i] = Di[i - 1] + Li[i - 1];

            Console.WriteLine(Di.Count(x => x <= X));
        }
    }
}


Measured memory_bytes: 13396
package main

import "fmt"

func myMin(nums []int) (min int) {
	min = nums[0]
	for i := 0; i < len(nums); i++ {
		if nums[i] < min {
			min = nums[i]
		}
	}
	return
}

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	nums := make([]int, n)
	c := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
		x -= nums[i]
		c++
	}
	min := myMin(nums)
	c += x / min
	fmt.Println(c)
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<time.h>
#include<cmath>
#include<functional>
#include<cassert>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
    int N;cin>>N;
    vector<double> x(N);
    vector<string> u(N);
    rep(i,N)cin>>x[i]>>u[i];
    double ans=0;
    rep(i,N){
        if(u[i]=="JPY")ans+=x[i];
        if(u[i]=="BTC")ans+=(x[i]*380000.0);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
const ll MOD=1000000007,INF=1e18;

int A,B,C,N,M,K;
string s,t;
int a[100010],b[100010],c[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>s;
    int t=0;
    rep(i,0,s.size()){
        if(s[i]=='/')continue;
        t*=10;
        t+=s[i]-'0';
    }
    if(t<=20190430){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(26));
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, s.length()) {
      v[i][s[j] - 'a']++;
    }
  }

  string ans;
  rep(i, 26) {
    int count = 100;
    rep(j, n) {
      count = min(count, v[j][i]);
    }
    rep(j, count) {
      ans.push_back('a' + i);
    }
  }

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

Measured memory_bytes: 3584
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> hs(n);
    for (auto& v : hs)
    {
        cin >> v;
    }

    vector<int> vs(n, 0);

    auto check = [&]() -> bool {
        for (int i = 0; i < n; i++)
        {
            if (hs[i] != vs[i])
            {
                return false;
            }
        }
        return true;
    };

    int count = 0;
    while (!check())
    {
        int l = 0;
        while (l < n && vs[l] == hs[l])
        {
            l++;
        }
        int r = l;
        while (r < n && vs[r] < hs[r])
        {
            r++;
        }
        r--;
        for (int i = l; i <= r; i++)
        {
            vs[i]++;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <vector>
#include <stdio.h>

const int inf = 1000000000;
int main(){
	int n;
  	cin >> n;
  	int ans = inf;
  	vector<int> x(n);
	rep(i,n) cin >> x[i];
 
	//not need to search over the rightmost and leftmost 
  	int L = x[0], R = x[0];
  	rep(i, n){
    L = min(L,x[i]);
    R = max(R,x[i]);
    }
  	for(int i=L; i <= R; i++){
    int cost =0;
    rep(j, n) cost += (x[j]-i)*(x[j]-i);
    ans = min(ans, cost);

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

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

#define MAX 100020
using namespace std;

int main(){
	while(true){
		int n;
		int ans = 0;
		int white = 0;
		int black = 0;
		int cont[MAX] = {0,};
		int a[MAX] = {3,};

		scanf("%d", &n);
		
		if( n == 0 )
			break;

		for(int i = 1; i <= n; ++i){
			scanf("%d", &a[i]);
		}

		for(int i = 1; i <= n; ++i){
			if( a[i] == a[i-1] )
				cont[i] = cont[i-1] + 1;
			else
				cont[i] = 1;

			if( i % 2 == 0 && a[i] != a[i-1] ){
				if( a[i] == 0 ){
					white += cont[i-1];
					black -= cont[i-1];
					cont[i] = cont[i-1] + cont[ i-1 - cont[i-1] ] + 1;
				}else{
					white -= cont[i-1];
					black += cont[i-1];
					cont[i] = cont[i-1] + cont[ i-1 - cont[i-1] ] + 1;
				}
			}
			if( a[i] == 0 ){
				++white;
			}else{
				++black;
			}
		}

		printf("%d\n", white);
	}
	return 0;
}

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

int main(void) {
  int n;
  scanf("%d", &n);
  switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      puts(("pon"));
      break;
    case 3:
      puts("bon");
      break;
  }
  return 0;
}


Measured memory_bytes: 2056
//解説AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3){
        rep(j, 3){
            cin >> c.at(i).at(j);
        }
    }
    
    int diff01[3], diff12[3], diff20[3];
    rep(i, 2){
        diff01[i] = abs(c.at(i).at(0) - c.at(i+1).at(0));
        diff12[i] = abs(c.at(i).at(1) - c.at(i+1).at(1));
        diff20[i] = abs(c.at(i).at(2) - c.at(i+1).at(2));
    }
    string s = "No";
    if(diff01[0] == diff12[0] && diff12[0] == diff20[0] && diff01[1] == diff12[1] && diff12[1] == diff20[1]){
        s = "Yes";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
//#define FILE_A_IN


int n,m,x;
void dfs(vector<vector<int>>& va, vector<int> acc, int d, int &ans) {
    if(d == n) return;
    dfs(va, acc, d+1, ans);
    for (int i = 0; i < m+1; ++i) {
        acc[i] += va[d][i];
    }
    bool fine = true;
    for (int i = 1; i < m+1; ++i) {
        if(acc[i] < x) {
            fine = false;
            break;
        }
    }
    if(fine) {
        ans = ans == -1 ? acc[0] : min(acc[0], ans);
    } else {
        dfs(va, acc, d+1, ans);
    }
}

void solve() {
    cin >> n >> m >> x;
    vector<vector<int>> va;
    for (int i = 0; i < n; ++i) {
        vector<int> vt(m+1);
        for (int j = 0; j < m+1; j++) {
            cin >> vt[j];
        }
        va.push_back(vt);
    }
    vector<int> acc(m+1);
    int ans = -1;
    dfs(va, acc, 0, ans);
    cout << ans << endl;
}
int main() {
#ifdef FILE_A_IN
    freopen("a.in", "r", stdin);
#endif
    fio;
    solve();
    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  int cw = 0;
  for (int i = int(s.size()) - 1; i > -1; i--) {
    if (s[i] == 'B') ans += cw;
    else cw++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
#define MAX 3000010
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    COMinit();
    r2++, c2++;
    ll t1 = COM(r2 + c2, c2) - 1;
    ll t2 = COM(r2 + c1, c1) - 1;
    ll t3 = COM(r1 + c2, c2) - 1;
    ll t4 = COM(r1 + c1, r1) - 1;
    cout << ((t1 - t2 - t3 + t4) % MOD + MOD) % MOD << endl;
}

Measured memory_bytes: 70656
N = int(input())
As = list(map(int, input().split()))
nC = 0
for a in As:
    if a < 0:
        nC += 1
for i in range(0, N):
    As[i] = abs(As[i])
if nC % 2 == 0:
    print(sum(As))
else:
    print(sum(As) - min(As) * 2)

Measured memory_bytes: 64880
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		String[] str = new String[H];
		String[][] S = new String[H][W];
		
		for(int i = 0; i < H; i++ ) {
			str[i]= sc.nextLine(); 
		}
		sc.close();
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				String s[] = str[i].split("");
				S[i][j] = s[j];
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j].equals("#")) {
					if(isOK(i,j,S) == true) {
						continue;
					}else {
						System.out.print("No");
						System.exit(0);
					}
				}
			}
		}
		System.out.println("Yes");
	}
	public static boolean isOK(int h, int w, String[][] S) {
		boolean isOK = false;
		if( h-1 >= 0 && S[h-1][w].equals("#") ) {
			isOK =true;
		}else if(h+1 < S.length && S[h+1][w].equals("#")) {
			isOK = true;
		}else if(w-1 >= 0 && S[h][w-1].equals("#")) {
			isOK = true;
		}else if(w+1 < S[0].length && S[h][w+1].equals("#")) {
			isOK = true;
		}else {
			
		}
		return isOK;
	}
}

Measured memory_bytes: 32724
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int n;
int num[13]={};
int s=0;
int calc(vector<int> const& status,vector<int> const& d){
  int res=inf;
  vector<int> buf={0,24};
  rep1(i,12){
    if(status[i]==1){
      buf.push_back(i);
    }
    else if(status[i]==2){
      buf.push_back(24-i);
    }
    else if(status[i]==3){
      buf.push_back(i);
      buf.push_back(24-i);
    }
  }
  sort(ALL(buf));
  int num=buf.size()-1;
  rep1(i,num){
    res=min(buf[i]-buf[i-1],res);
  }
  if(res==inf)res=0;
  return res;
}
int solve(vector<int> status,vector<int> const& d,int cur){
  int res=0;
  if(cur==13)return calc(status,d);
  else{
    if(num[cur]==0)res=solve(status,d,cur+1);
    if(num[cur]==1){
      status[cur]=1;
      res=max(res,solve(status,d,cur+1));
      status[cur]=2;
      res=max(res,solve(status,d,cur+1));
    }
    if(num[cur]>=2){
      status[cur]=3;
      res=max(res,solve(status,d,cur+1));
    }
  }
  return res;
}
signed main(){
  cin>>n;
  vector<int> d(n);
  rep(i,n)cin>>d[i];
  sort(ALL(d));
  d.push_back(inf);
  rep(i,n){
    num[d[i]]++;
  }
  /*int cur=1;int last=d[0];
  rep1(i,n){
    if(d[i]==last){
      cur++;
    }
    else{
      num[last]=cur;
      last=d[i];
    }
  }*/
  vector<int> status(13,0);
  int res=solve(status,d,1);
  if(num[0]>0)res=0;
  rep1(i,12){
    if(num[i]>=3)res=0;
  }
  if(num[12]>=2)res=0;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve(n, w, WV):
    dp = [[0] * (w + 1) for _ in range(n)]
    for w_limit in range(WV[0][0], w + 1):
        dp[0][w_limit] = WV[0][1]
    for i in range(1, n):
        for w_limit in range(1, w + 1):
            dw, dv = WV[i]
            if dw > w_limit:
                dp[i][w_limit] = dp[i - 1][w_limit]
            else:
                dp[i][w_limit] = max(dp[i - 1][w_limit], dp[i - 1][w_limit - dw] + dv)
    return dp[n - 1][w]

_n, _w = map(int, input().split())
_WV = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _w, _WV))


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

int main(){
	
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	bool flag=false;
	for(int i = a ; i <= b ; i++ ){
		if(i % k == 0 ){
			cout<<"OK"<<endl;
			flag=true;
			break;
		}
	}
	if(flag == false){
		cout<<"NG"<<endl;
	}
}

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

using namespace std;

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

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

vector<tt> v;
int n, m, q;
vector<int> arr;
int ans = 0;

void check() {

  int cur = 0;
  for (int i = 0; i < v.size(); ++i) {
    int l, r, dif, s;
    tie(l, r, dif, s) = v[i];

    --l, --r;
    if (arr[r] - arr[l] == dif)
      cur += s;
  }

  ans = max(ans, cur);
}

void gen(int last) {

  if (arr.size() == n) {
    check();
    return;
  }

  for (int i = last; i <= m; ++i) {
    arr.eb(i);
    gen(i);
    arr.pop_back();
  }
}

signed main() {

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

  cin >> n >> m >> q;

  while (q--) {
    int l, r, c, d;
    cin >> l >> r >> c >> d;
    v.eb(l, r, c, d);
  }
  arr.eb(1);
  gen(1);

  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
int n,a,b,c;


signed main(){
  int n;
  while (cin>>n,n) {
    int t[100][100]={};
    rep(i,n)rep(j,n+1)cin>>t[i][j];
    vector<int>  dp(1<<n,INF);
    dp[0]=0;
    rep(s,1<<n){
      rep(i,n){
        if(s>>i&1)continue;
        int mini=t[i][0];
        rep(j,n){
          if(s>>j&1){
            mini=min(mini,t[i][j+1]);
          }
        }
        dp[s|1<<i]=min(dp[s|1<<i],dp[s]+mini);
      }
    }
    cout<<dp[(1<<n)-1]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3656
import sys


input_str = input()

list_str = [i for i in input_str]
set_str = set(list_str)

if len(set_str) == 2:
  for i in set_str:
    try:
      for j in range(2):
        list_str.remove(i)
    except ValueError:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
  
print('Yes')

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define vpll        vector<pair<ll,ll>>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    string s;cin>>s;
    int l=s.length();
    int c=0;
    rep(i,0,l/2){
        if(s[i]!=s[l-1-i])c++;
    }
    cout<<c;

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


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  map<int, bool> mp;
  mp[a] = true;
  mp[b] = true;
  mp[c] = true;
  mp[d] = true;
  if (mp[1] && mp[9] && mp[7] && mp[4])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

#define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    int e;



    while(cin>>e){

        int ans=INF;

        if(e==0)break;

        for(int x=0;x*x*x<=e;x++){
            for(int y=0;y*y<=e;y++){
                int z=e-(x*x*x+y*y);
                if(z>=0){
                    ans=min(ans,x+y+z);                
                }
            }
        }
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 3180
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
#define sbs(i,j) substr(i,j)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);


int main(){
    std::ios::sync_with_stdio(false);
    int k,s;
    cin>>k>>s;
    int x,y,z;
    int ans=0;
    rep(x,0,k){
        rep(y,0,k){
            z=s-x-y;
            if(z>=0&&z<=k)
                ans++;
        }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct {
  double x,y;
}Point;

void koch (int n,Point a,Point b) {
  if (n == 0) return;
  Point s,t,u;
  double th = M_PI*60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 *b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
  
  koch (n-1 , a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}




















































int main () {
  Point a,b;
  int n;

  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100.0;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

struct info {
    int y, x, count;
};

signed main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> A(H, vector<char>(W));
    pair<int, int> start;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] == 'S') {
                start = {i ,j};
            }
        }
    }
    int ans = INF;
    vector<vector<bool>> check(H, vector<bool>(W, false));
    queue<info> explore;
    explore.push({start.first, start.second, 0});
    while (!explore.empty()) {
        auto now = explore.front();
        explore.pop();
        int shortestY = min(now.y, H - 1 - now.y);
        int shortestX = min(now.x, W - 1 - now.x);
        shortestY = shortestY / K + (shortestY % K != 0);
        shortestX = shortestX / K + (shortestX % K != 0);
        ans = min(ans, 1 + min(shortestY, shortestX));
        for (int x = -1; x <= 1; x++) {
            for (int y = -1; y <= 1; y++) {
                if (abs(x) == abs(y)) continue;
                if (now.x + x < 0 || now.x + x >= W) continue;
                if (now.y + y < 0 || now.y + y >= H) continue;
                if (A[now.y + y][now.x + x] == '#') continue;
                if (check[now.y + y][now.x + x]) continue;
                if (now.count + 1 > K) continue;
                explore.push({now.y + y, now.x + x, now.count + 1});
                check[now.y + y][now.x + x] = true;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a+b-n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
   int N, M;
   cin >> N >> M;
   if(N == M) cout<< "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

ll=0
rr=10**9+1
for _ in range(10**2):
  #最も長い丸太がこれになる
  ans=(ll+rr)/2.0
  cnt=0
  for item in a:
    if item>ans:
	    cnt+=((-1*item)//ans)*(-1)-1
  if cnt<=k:
    rr=ans
  else:
    ll=ans
print(int((-1*ans//1)*(-1)))

Measured memory_bytes: 93876
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  mp::cpp_int a, b;
  cin >> a >> b;
  
  if(a > b)
    cout << "GREATER" << "\n";
  if(a < b)
    cout << "LESS" << "\n";
  if(a == b)
    cout << "EQUAL" << "\n";

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

	long long r = 0, g = 0, b = 0;

	for (int i = 0;i < N;i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G')g++;
		else b++;
	}

	long long ans = r * g * b;

	if (ans == 0) {
		cout << ans << endl;
		return 0;
	}

	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			int k = j + j - i;
			if (k >= N)break;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
				ans--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
import collections
N = int(input())
ans = 0


def prime_decomposition(n):
    i = 2
    ret = collections.defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret[i] += 1
        i += 1
    if n > 1:
        ret[n] = 1
    return ret


factors_dict = prime_decomposition(N)
factors_values = list(factors_dict.values())
factors_keys = list(factors_dict.keys())
factors = []
import itertools
for K in itertools.product(*[range(_ + 1) for _ in factors_values]):
    f = 1
    for i in range(len(factors_keys)):
        f *= factors_keys[i]**K[i]
    factors += [f]
ans = 0
for f in factors:
    if N < f * (f - 1):
        ans += f - 1
print(ans)


Measured memory_bytes: 3572
MOD=10**9+7
l=input()
ans1=2
ans2=1

for i in range(1,len(l)):
    if l[i]=="0":
        ans2*=3
    if l[i]=="1":
        ans2=ans1+ans2*3
        ans1*=2
    ans1%=MOD
    ans2%=MOD
print((ans1+ans2)%MOD)

Measured memory_bytes: 3188
def main():
    N = int(input())
    s = input()
    r,b = 0,0
    for i in range(N):
        if s[i]=="R":
            r += 1
        else:
            b += 1
    
    if r>b:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;

int main()
{
  long long N;
  cin >> N;
  vector<long long> factor(1000001,1000000000003);
  for (long long i = 1ll; i * i <= N; ++i)
  {
    if (N % i == 0)
    {
      factor.at(i) = i + N / i;
    }
  }
  sort(factor.begin(), factor.end());
  cout << factor.at(0) - 2 << endl;
}

Measured memory_bytes: 8192
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, K = MI()
    R, S, P = MI()
    T = input()
    # グー
    r = 'r'
    # ちょき
    s = 's'
    # パー
    p = 'p'
    m = {
        'r': P,
        's': R,
        'p': S
    }
    ms = {
        'r': 'p',
        's': 'r',
        'p': 's'
    }
    ans = 0
    records = []

    for i in range(len(T)):
        if len(records) < K:
            ans += m[T[i]]
            records.append(ms[T[i]])
        else:
            if records[i - K] == ms[T[i]]:
                records.append('empty')
            else:
                ans += m[T[i]]
                records.append(ms[T[i]])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71788
#include <iostream>
#include <vector>

int main()
{
  std::string S;
  std::cin >> S;
  int count = 0;
  int max_count = 0;
  for(const auto& s: S)
  {
    if(s == 'A'||s == 'C'||s == 'G'|| s == 'T')
    {
      count ++;
      if(count > max_count)
      {
        max_count = count;
      }
    }
    else
    {
      count = 0;
    }

  }
  std::cout << max_count << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int H[2], M[2], K;
    rep(i,2)cin >> H[i] >> M[i];
    cin >> K;
    int t[2];
    rep(i,2)t[i] = H[i] * 60 + M[i];
    int d = t[1] - t[0];
    cout << max(0, d - K) << endl;
}


Measured memory_bytes: 3640