akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    int H = sc.nextInt();

    int W = sc.nextInt();

    int h = sc.nextInt();

    int w = sc.nextInt();

    boolean[][] matrix = new boolean[H][W];

    for (int i = 0; i < h; i++){
      for (int j = 0; j < W; j++) {
        matrix[i][j] = true;
      }
    }
    for (int i = 0; i < w; i++){
      for (int j = 0; j < H; j++) {
        matrix[j][i] = true;
      }
    }

    int count = 0;
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if (!matrix[i][j]) {
          count++;
        }
      }
    }
    os.println(count);
  }
}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		try {
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			int A = Integer.parseInt(br.readLine());
			int B = Integer.parseInt(br.readLine());
			int C = Integer.parseInt(br.readLine());
			int D = Integer.parseInt(br.readLine());
			int E = Integer.parseInt(br.readLine());
			
			int[] full = {A,B,C,D,E};
			int[] keta1 = {A%10,B%10,C%10,D%10,E%10};
			int min = 9;
			int minIndex=0;
			for (int i=0;i<5;i++) {
				if (0<keta1[i] && keta1[i] < min) {
					min=keta1[i];
					minIndex=i;
				}
			}
			int sum=0;
			for (int i=0;i<5;i++) {
				if (i!=minIndex) {
					if (full[i]%10 == 0) {
						sum=sum+full[i];
					} else {
						sum=sum+(full[i]/10+1)*10;	
					}
				} else {
					sum=sum+full[i];
                  
				}
			}

			
			
			System.out.println(	sum);
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	private static void init() {
		
	}
}


Measured memory_bytes: 22612
#include<stdio.h>
long long int mod = 1e9+7;
int main()
{
	int t;
	int n,m;
	int i,j;
	long long int number = 1;
	int a[100000];
	scanf("%d",&n);
	if(n == 1) printf("1");
	else if(n != 1)
	{
		for(i = 2;i <= n;i++)
		{
			t = i;
			for(j = 2;j <= i;j++)
			{
				while(t % j == 0)
				{
					a[j]++;
					t = t / j;
				}
			}
		}
		for(i = 2;i<=n;i++)
		{
			if(a[i] != 0)
			{
				number *= (1 + a[i]);
				number = number % mod;
			}
		}
		printf("%lld",number);
	}
	return 0;
}

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

int main()
{
  char T[1000];
  int N,i,j,k,judge;
  judge=0;
  //文字列これだけで読み取れるらしい
  cin>>T;
  //文字数数える
  for(i=0;T[i]!=NULL;i++)
  {
  }
  N=i;//文字数
//  cout<<i;
  char S[N];
  char SS[N];
  
  for(i=0;i<N;i++)
  {
    S[i]=T[i];
    SS[i]=T[N-i-1];
  }
//  cout<<S<<" "<<SS;
  
  
  for(i=0;i<N;i++)
  {
    if(S[i]!=SS[i])
      goto end;
  }
   judge++;
   //cout<<"\n"<<S[4]<<S[6];
  
  j=(N-1)/2;
  k=(N+3)/2;
  //cout<<k<<"\n"<<judge;
  
  for(i=0;i<j;i++)
  {
    if(S[i]!=S[j-i-1])
    {
      //cout<<"abc"<<i;
      goto end;
    }
  }
  judge++;
  
  for(i=k-1;i<N;i++)
  {
    if(S[i]!=S[N-i-1])
    {
      //cout<<"ererere";
      goto end;
    }
  }
  judge++;

  if(judge==3)
  {
    cout<<"Yes";
    goto finish;  
  }
  
  end:;
  cout<<"No";//<<judge;
  finish:;
  
  return 0;
  
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
edges = Array.new(n+1){{}}
m.times do
    u, v, s = gets.split.map(&:to_i)
    edges[u][v] = s
    edges[v][u] = s
end

plus = []
value = []
plus[1] = true
value[1] = 0
offset = nil
stack = [1]
while stack.length > 0
    u = stack.pop
    edges[u].each do |v, c|
    next if u == v
        unless value[v]
            plus[v] = !plus[u]
            value[v] = c - value[u]
            stack.push(v)
            next
        end
        if plus[v] != plus[u]
            if value[v] + value[u] != c
                puts 0
                exit
            end
            next
        end
        if !plus[v]
            diff = c - (value[v] + value[u])
        else
            diff = (value[v] + value[u]) - c
        end
        if diff % 2 == 1
            puts 0
            exit
        end
        if offset && offset != diff
            puts 0
            exit
        end
        offset = diff
    end
end
offset /= 2 if offset

posval = (1..n).select{|i|plus[i]}.map{|i|value[i]}
posneg = (1..n).select{|i|!plus[i]}.map{|i|value[i]}
posmin = posval.min
negmin = posneg.min

if offset
    if posmin - offset > 0 && negmin + offset > 0
        puts 1
    else
        puts 0
    end
else
    min1, min2 = [posmin, negmin].sort
    if min1 > 0
        puts min2+min1-1
    else
        puts [min2+min1-1, 0].max
    end
end

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::string S){
    int ans = 700;
    REP(i, 3) {
        ans += S[i] == 'o' ? 100 : 0;
    }

    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  int a,b;
  cin >>a >> b;
  rep(i,3) {
    if((i+1)!=a&&(i+1)!=b) cout << i+1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int N;
	string s[51];
	int t[51];
	string x;
	cin >> N;
	REP(i, N) {
		cin >> s[i] >> t[i];
	}
	cin >> x;
	int ans = 0;
	bool ok = false;
	REP(i, N) {
		if (ok)ans += t[i];
		if (s[i] == x) {
			ok = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;



int mod;
struct mint {
  ll x;
  /****************************************
                コンストラクタ
  クラス名(引数1, 引数2, 引数3, ..):
      変数1(変数に代入する値), 変数2(..), ..
        {}
  //**************************************/
  mint(ll x): x(x%mod){}
  mint& operator+=(const mint a){//operator +=のオーバーヘッド
    (x += a.x)%= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    (x -= mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a){
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a){
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a){
    mint res(*this);
    return res *= a;
  }

  mint pow(ll t)const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a*= *this;
    return a;
  }
};

int N = 1000008;

int main(){
  int K;
  cin >> K;
  mod = K;
  mint V(7);
  ll ans = -1;
  rep(i, N){
    if(V.x == 0){
      ans = i+1;
      break;
    }
    V *= 10;
    V += 7;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2124
s = input()
n = len(s)
if n % 2 == 0:
    h = n // 2
    a = s[0:h]
    b = s[h:n]
    ans = 0
    for i in range(h):
        if a[i] != b[h-i-1]:
            ans += 1
    print(ans)
else:
    h = (n-1) // 2
    a = s[0:h]
    b = s[h+1:n]
    ans = 0
    for i in range(h):
        if a[i] != b[h-i-1]:
            ans += 1
    print(ans)
    
    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();
		String p = sc.nextLine();

		int sLen = s.length();
		int pLen = p.length();
		boolean ok = false;
		for (int i = 0; i < sLen; i++) {

			for (int j = 0; j < pLen; j++) {

				if(s.charAt((i + j)%sLen) != p.charAt(j)) {
					break;
				}

				if(j == pLen-1) ok = true;

			}

			if(ok) break;

		}

		System.out.println(ok ? "Yes" : "No");

	}
}

Measured memory_bytes: 26196
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
// find_by_order(), order_of_key() 

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&
	
struct node{
	int a, b, c, d;
};

int n,m, q;
vector<node> v;

int bestans = 0;

void rec(int id, int num, vector<int> A){
	if(num >= m + 1)
		return;
	if(id == n){
		if(A.size() == n and num <= m + 1){
			int score = 0;
			/*for(auto &x: A)
				cout << x;
			cout << " ";*/
			for(int i = 0; i < q; ++i){
				int id1 = v[i].a;
				int id2 = v[i].b;
				id1--; id2--;
				if( A[id2] - A[id1] == v[i].c)
					score += v[i].d;
			}
			bestans = max(bestans, score);
			//cout << score << '\n';
		}
		return;
	}
	vector<int> nA(A);
	if(A.size() < n){
		nA.push_back(num);
		rec(id + 1, num, nA);
		if(num + 1 <= m)
			rec(id + 1, num + 1, nA);
	} 
	rec(id, num + 1, A);
}

void solve(){
	cin >> n >> m >> q;
	v.resize(q);
	for(int i = 0; i < q; ++i){
		cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
	}
	rec(0, 1, vector<int>());
	cout << bestans << '\n';
	
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc){
		//cout << "Case #"<< tc <<": ";
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a[10];
  int i;
  int k=0,max=0;

  for(i=0;i<3;i++){
    cin >> a[i];
    if(a[i] == 'R'){
      k++;
      max = k;
    }else{
      k=0;
    }
  }

    cout << max;
}


Measured memory_bytes: 3624
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int n, tmp;
	vector<int> d;
	cin >> n;
	REP(i,n){
		cin >> tmp;
		d.push_back(tmp);

	}
	sort(d.begin(), d.end());
	ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int inn, n, ans;
  cin>>n>>inn;
  if(n>=10)
    ans=inn;
  else
  {
    ans=inn+(100*(10-n));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {

    int n, a;

    scanf("%d", &n);

    int mindata = 1001;
    int maxdata = -1;

    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        if (a < mindata) {
            mindata = a;
        }
        if (maxdata < a) {
            maxdata = a;
        }
    }

    printf("%d",maxdata-mindata);
    return 0;
} 

Measured memory_bytes: 128
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();	
		}
		double s = 0;
		for (int i = 0; i < n; i++) {
			s = s + a[i];
		}
		s = s * 1.0 / n;
		double min = Math.abs(a[0] - s);
		int j = 0;
		for (int i = 0; i < n; i++) {
			double t = Math.abs(a[i] - s);
			if (t < min) {
				min = t;
				j = i;
			}
		}
		System.out.println(j);
	}
}

Measured memory_bytes: 23764
def main():
    N = int(input())
    info = [tuple(map(int, input().split())) for _ in range(N)]

    A = [a for a, _ in info]
    B = [b for _, b in info]

    A.sort()
    B.sort()
    if N%2 == 0:
        min_median2 = A[N//2-1] + A[N//2]
        max_median2 = B[N//2-1] + B[N//2]
        ans = max_median2 - min_median2 + 1
    else:
        min_median2 = A[N//2]
        max_median2 = B[N//2]
        ans = max_median2 - min_median2 + 1

    print(ans)

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 39636
N,K=list(map(int,input().split()))
g=[[] for _ in range(N+1)]

mod=10**9+7

for _ in range(N-1):
    a,b=list(map(int,input().split()))
    g[a].append(b)
    g[b].append(a)

visit=[-1]*(N+1)
visit[0]=K

stack=[(0,1,0)]
ans=1


while len(stack)>0:
    parent,current,depth=stack.pop()

    ans*=visit[parent]
    ans%=mod

    if ans==0:
        break

    visit[parent]-=1

    visit[current]=K-min(2,depth+1)
    
    for child in g[current]:
        if visit[child]>-1:
            continue

        stack.append([current,child,depth+1])

print(ans)

Measured memory_bytes: 102784
import java.util.Scanner;
public class Main {
	//最大公約数gcd
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int k = stdIn.nextInt();
		long cnt = 0;
		for(int i = 1; i <=k; i++) {
			for(int j =1; j <= k; j++) {
				for(int m = 1; m <= k; m++) {
					cnt += gcd(gcd(i,j),m);
				}
			}
		}
		
		System.out.println(cnt);
	}

}


Measured memory_bytes: 35836
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n;
	cin>>n;
	vector<pair<int,int>> vp(n);
	for(int i=0;i<n;i++)
		cin>>vp[i].first>>vp[i].second;
	bool ok = true;
	for(int i=0;i<n-2;i++)
	{
		ok = true;
		for(int j=0;j<3;j++)
		{
			if(vp[i+j].first != vp[i+j].second)
			{
				ok = false;
				break;
			}
		}
		if(ok)
			break;
	}
	if(ok)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int M[10][10];
int d[10][10];
int main(){
	//freopen("in.txt","r",stdin);
	memset(d,0,sizeof d);

	for(int i = 0 ; i < 3 ; i++){
		cin>>M[i][0]>>M[i][1]>>M[i][2];
	}
	int n;cin>>n;
	int t;
	while(n--){
		cin>>t;
		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 3 ; j++){
				if(M[i][j]==t){
					d[i][j]=1;
				}

			}
		}
	}
	bool sw = false;
	int c=0;
	int cc= 0;
	int ccc=0;
	int x,xx,xxx;
	x = xx = xxx = 0;
	for(int i = 0 ; i < 3 ; i++){
		if(d[i][0]== 1){
			c++;
		}
		if(d[i][1]==1){
			cc++;
		}
		if(d[i][2]==1){
			ccc++;
		}
		if(d[0][i]==1){
			x++;
		}
		if(d[1][i]==1){
			xx++;
		}
		if(d[2][i]==1){
			xxx++;
		}
		if((d[0][0]==1 and d[1][1]==1 and d[2][2]==1) or (d[0][2]==1 and d[1][1]==1 and d[2][0]==1))
			sw = true;
	}
	if(sw)
		cout<<"Yes\n";
	else{
		int maxi = max(c,cc);
		maxi = max(ccc,maxi);
		maxi = max(maxi,x);
		maxi = max(maxi,xx);
		maxi = max(maxi,xxx);
		if(maxi==3)
			cout<<"Yes\n";
		else 
			cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ?´???°????????°?????????????????????
 * @author moritahokuto
 *
 */
public class Main {

	public static void main(String[] args) {
		int count = 0;
		Scanner scanner = new Scanner(System.in);
		int size = scanner.nextInt();
		for (int i = 0; i < size; i++) {
			if (isPrime(scanner.nextInt())) {
				count++;
			}
		}
		System.out.println(count);
	}
	static boolean isPrime(int num) {
		if (num == 2) {
			return true;
		}
		if (num < 2 || num % 2 == 0) {
			return false;
		}
		int i = 3;
		while (i <= Math.sqrt(num)) {
			if (num % i == 0) {
				return false;
			}
			i = i + 2;
		}
		return true;
	}
}

Measured memory_bytes: 40988
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;

type Map = HashMap<(usize, usize), i64>;
fn main() {
    input! {
        n: usize,
        mut ai: [i64; n],
    }
    let m = n/2;

    let mut memo = Map::new();
    let ans = dfs(&ai,  0,  m, &mut memo);
    println!("{}", ans);
}

fn dfs(ai: &[i64], idx: usize, count: usize, memo: &mut Map) -> i64 {
    let key = (idx, count);
    if let Some(v) = memo.get(&key) {
        return *v;
    }

    if count == 0 {
        memo.insert(key, 0);
        return 0;
    }

    if count > (ai.len() - idx + 1)/2 {
        memo.insert(key, std::i64::MIN);
        return std::i64::MIN;
    }

    let res = max(
        dfs(ai, idx+1, count, memo),
        dfs(ai, idx+2, count-1, memo) + ai[idx]
    );
    memo.insert(key, res);
    res
}

Measured memory_bytes: 34336
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        xy: [(i64, i64); n],
    }
    let set: HashSet<_> = xy.iter().cloned().collect();
    let mut mi = n as i64;
    for i in 0..n {
        for j in 0..i {
            let (p, q) = (xy[i].0 - xy[j].0, xy[i].1 - xy[j].1);
            let mut cnt = 0;
            for &(x, y) in &xy {
                if !set.contains(&(x - p, y - q)) {
                    cnt += 1;
                }
            }
            mi = min(mi, cnt);
        }
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <stdio.h>

int main( void ) {

	using namespace std;

	int N, M;
	cin >> N >> M;

	vector< int > A = vector< int >( M, 0 );
	vector< int > pts = vector< int >( N, 0 );

	for( int i = 0; i < M; i++ ) {
		cin >> A[ i ];
		A[ i ];
	}

	for( int i = 0; i < M; i++ ) {

		int X = 0;

		for( int j = 0; j < N; j++ ) {

			int id;
			cin >> id;

			if( id == A[ i ] ) {
				pts[ j ] ++;
			} else {
				X ++;
			}

		}

		pts[ A[ i ] - 1 ] += X;

	}

	for( int i = 0; i < N; i++ )
		cout << pts[ i ] << endl;


	return 0;

}

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

using namespace std;

int main(){
	int n,i,out = 0;
	int num[20];

	cin >> n;
	for(i = 0; i < n; i++){
		cin >> num[i];
	}

	for(i = 1; i < n - 1; i++){
		if(num[i] > num[i-1]){
			if(num[i] < num[i+1]){
				out++;
			}
		}
		else if(num[i] < num[i-1]){
			if(num[i] > num[i+1]){
				out++;
			}
		}
	}

	cout << out;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int arr[n];
  
  int ans = 0, avg = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    avg+=arr[i];
  }

  if (avg%n>n/2) avg=avg/n+1; else avg=avg/n;
  
  for (int i = 0; i < n; i++) {
    ans+=((arr[i]-avg)*(arr[i]-avg));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n,q;
ll a[200005],b[200005];
ll h,w;
ll ans;
int main(void){
    cin>>n>>q;
    for(int i=1;i<=n;i++){
        a[i]=n;
        b[i]=n;
    }
    ans=(n-2)*(n-2);
    h=n; w=n;
    while(q--){
        ll t,x;
        cin>>t>>x;
        if(t==1){
            if(x<w){
                for(int i=x;i<w;i++){
                    b[i]=h;
                }
                w=x;
            }
            ans-=b[x]-2;
        }else{
            if(x<h){
                for(int i=x;i<h;i++){
                    a[i]=w;
                }
                h=x;
            }
            ans-=a[x]-2;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll n,m,k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n>>m>>k;
    vector <ll> a(n);
    vector <ll> b(m);
    
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    for (int i=0; i<m; i++){
        cin>>b[i];
    }
    
    vector <ll> sumA(n+1);
    vector <ll> sumB(m+1);
    
    sumA[0]=0;
    sumB[0]=0;
    
    for (int i=1; i<=n; i++){
        sumA[i]=sumA[i-1]+a[i-1];
    }
    for (int i=1; i<=m; i++){
        sumB[i]=sumB[i-1]+b[i-1];
    }
    
    
    ll res=0;
    //solve
    for (int i=0; i<=n; i++){
        ll whatToFind = k-sumA[i];
        if (whatToFind<0) continue;
        
        ll poz = upper_bound(sumB.begin(),sumB.end(),whatToFind)-sumB.begin();
        poz--;
        
        res = max(res,poz+i);
    }
    
    cout<<res;
    return 0;
}

Measured memory_bytes: 9532
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

char s[120];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ll now = s[i] - '0';
		ll k = (1 << (n - 1));
		for (int j = i + 1; j < n; ++j) {
			k >>= 1;
			ans += k * now;
			now *= 10;
		}
		ans += k * now;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
//#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long n;

int main()
{
	scanf("%lld", &n);
	if (n == 2) {
		printf("1\n");
		return 0;
	}
	
	long long count = 2;	//n, n - 1
	
	long long d = 2;
	while ((d * d) <= n) {
		if (n % d == 1) {
			count++;
//			printf("%lld\n", d);
			
			long long r = (n - 1) / d;
			if (r != d) {
				count++;
//				printf("%lld\n", r);
			}
			
		} else if (n % d == 0) {
			//一定互斥 
			long long t = n / d;
			while (t % d == 0) {
				t = t / d;
			}
			if (t % d == 1) {
				count++;
//				printf("%lld\n", d);
			}
			
			//这个倒是不用考虑反向
			//因为反向的话这个d一定就是最终结果，然而这里d都不为1 
		}
		d++;
	}
	
	printf("%d\n", count);
	
	return 0;
}

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


int main()
{
    int n,m;
    cin>>n>>m;
    getchar();
    string str[n];
    int i;
    for(i=0;i<n;i++) cin>>str[i];
    for(i=0;i<n;i++) cout<<str[i]<<"\n"<<str[i]<<"\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

      ll n;
      cin >> n;
      vector<pair<ll, ll> > a(n), b(n);
      for(ll i=0; i<n; i++){
            ll temp;
            cin >> temp;
            a[i] = make_pair(temp, i);
      }
      sort(a.begin(), a.end());
      ll Ans = 0;
      for(ll i=0; i<n;){
            ll count = 1;
            pair<ll,ll> val = a[i];
            // ll x = i;
            i++;
            vector<ll> c;
            c.push_back(val.second);
            while(a[i].first == val.first && i < n){
                  count ++;
                  c.push_back(a[i].second);
                  i++;
            }
            ll ans = count*(count-1);
            ans /= 2;
            // ans = max(count, ans);
            // if(an)
            Ans += ans;
            for(ll j:c){
                  b[j].first = ans;
                  b[j].second = count-1;
            }
      }
      for(ll i=0; i<n; i++){
            // if(b[i])
            cout << Ans - b[i].second<< endl;
      }

      return 0;
}

Measured memory_bytes: 8916
import queue

q = queue.Queue()
k = int(input())

for i in range(1,10):
	q.put(i)

for i in range(k):
	output = q.get()
	if output % 10 == 0:
		q.put(output*10)
		q.put(output*10 + 1)
	elif output % 10 == 9:
		q.put(output*10 + 8)
		q.put(output*10 + 9)
	else:
		a = output % 10
		q.put(output*10 + a - 1)
		q.put(output*10 + a )
		q.put(output*10 + a + 1)

print(output)


Measured memory_bytes: 12460
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

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

int main(){
	int A,B,C;
	cin>>A>>B>>C;
	int g=gcd(A,B);
	if(C%g==0)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>


int h,w,n;

int main(){
    cin>>h>>w>>n;
    int ma = max(h,w);
    int ans =n/ma;
    if(n%ma)ans++;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 764
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); }
ll seg[900005]; 
ll dp[500005];
void build(ll node,ll s,ll e){
	// cout<<node<<" "<<s<<" "<<e<<endl;
	if(s==e){
		seg[node]=dp[s];
		return ;
	}
	ll mid=(s+e)>>1;
	build(2*node+1,s,mid);
	build(2*node+2,mid+1,e);
	seg[node]=max(seg[2*node+1],seg[2*node+2]);
}
ll query(ll node,ll s,ll e,ll qs,ll qe){
	if(qs<=s&&qe>=e){
		return seg[node];
	}
	if(qe<s||qs>e){
		return 0;
	}
	ll mid=(s+e)>>1;
	return max(query(2*node+1,s,mid,qs,qe),query(2*node+2,mid+1,e,qs,qe));
}
void update(ll node,ll s,ll e,ll index,ll val){
	if(s==e){
		seg[node]+=val;
		return;
	}
	ll mid=(s+e)>>1;
	if(index<=mid&&index>=s){
		update(2*node+1,s,mid,index,val);
	}
	else{
		update(2*node+2,mid+1,e,index,val);
	}
	seg[node]=max(seg[2*node+1],seg[2*node+2]);
}
int  main(){
	// FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll>h(n),a(n);
		for(int i=0;i<n;i++){
			cin>>h[i];
		}
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		// ll dp[n+1];
		zero(dp);
		build(0,0,n);
		// cout<<0<<endl;
		for(int i=0;i<n;i++){
			ll ans=query(0,0,n,0,h[i]-1);
			ll diff=dp[h[i]];
			dp[h[i]]=ans+a[i];
			update(0,0,n,h[i],dp[h[i]]-diff);
		}
		ll ans=0;
		for(int i=0;i<=n;i++){
			ans=max(ans,dp[h[i]]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 11520
program a_or_or_or_b_problem
  implicit none
  integer(8) :: a, b, d1, u1, d2, u2, ans
  integer :: i, r, k
  read(*,*) a
  read(*,*) b
  if (a == b) then
    write(*,'(i0)') 1
    stop
  end if
  do i = 61, 1, -1
    if (btest(a,i-1) .eqv. btest(b,i-1)) then
      a = ibclr(a,i-1)
      b = ibclr(b,i-1)
    else
      r = i
      exit
    end if
  end do
  k = 0
  do i = r-1, 1, -1
    if (btest(b,i-1)) then
      k = i
      exit
    end if
  end do
  d1 = a
  u1 = lshift(1_8,r-1)+lshift(1_8,k)
  d2 = lshift(1_8,r-1)+a
  u2 = lshift(1_8,r)
  if (d2 <= u1) then
    ans = u2-d1
  else
    ans = u1-d1+u2-d2
  end if
  write(*,'(i0)') ans
end program a_or_or_or_b_problem

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int D_MAX_V=10000;
struct D_wolf{
	int t,c,r;
	D_wolf(){}
	D_wolf(int t1,int c1,int r1){t=t1;c=c1;r=r1;}
};
vector<D_wolf>D_G[D_MAX_V];
int D_level[D_MAX_V];
int D_iter[D_MAX_V];
void add_edge(int a,int b,int c){
	D_G[a].push_back(D_wolf(b,c,D_G[b].size()));
	D_G[b].push_back(D_wolf(a,0,D_G[a].size()-1));
}
void D_bfs(int a){
	for(int i=0;i<D_MAX_V;i++)D_level[i]=-1;
	D_level[a]=0;
	queue<int>Q;
	Q.push(a);
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<D_G[at].size();i++){
			if(D_G[at][i].c==0)continue;
			if(D_level[D_G[at][i].t]>=0)continue;
			D_level[D_G[at][i].t]=D_level[at]+1;
			Q.push(D_G[at][i].t);
		}
	}
}
int D_dfs(int a,int b,int c){
	if(a==b)return c;
	for(;D_iter[a]<D_G[a].size();D_iter[a]++){
		if(D_level[a]<D_level[D_G[a][D_iter[a]].t]&&D_G[a][D_iter[a]].c>0){
			int f=D_dfs(D_G[a][D_iter[a]].t,b,min(c,D_G[a][D_iter[a]].c));
			if(f){
				D_G[a][D_iter[a]].c-=f;
				D_G[D_G[a][D_iter[a]].t][D_G[a][D_iter[a]].r].c+=f;
				return f;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int ret=0;
	while(1){
		D_bfs(s);
		for(int i=0;i<D_MAX_V;i++)D_iter[i]=0;
		int f=D_dfs(s,t,99999999);
		if(f==0)return ret;
		ret+=f;
	}
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		add_edge(p,q,r);
	}
	printf("%d\n",max_flow(0,a-1));
}



Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N, K;
ll rem = 0;
ll sum1, sum2 = 0;

ll Sum(ll num)
{
    ll sum1, sum2;
    if (num == N + 2)
        return 0;
    sum1 = num * (num - 1) / 2;
    sum2 = num * (2 * (N - num + 1) + (num - 1)) / 2;
    rem += sum2 - sum1 + 1;
    rem %= BUFSIZE;
    return Sum(num + 1);
}

int main(void)
{
    scanf("%d", &N);
    scanf("%d", &K);
    Sum(K);
    printf("%lld", rem % BUFSIZE);
    return 0;
}


Measured memory_bytes: 1728
N = int(input())
S = list(input())
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N-2):
    for j in range(i+1, N + (-(N-i-1)//2)):
        k = j+(j-i)
        if len(set([S[i], S[j], S[k]])) == 3:
            ans-=1
print(ans)

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

int is_ACGT(char c){
  if(c=='T' || c=='A' || c=='C' || c=='G')
    return 1;
  else
    return 0;
}

int main() {
  string s;
  cin >> s;
  
  int max_count = 0;
  for(int i=0; i<s.length(); i++){
    int count = 0;
    if(is_ACGT(s.at(i))){
      count++;
      for(int j=i+1; j<s.length(); j++){
        if(is_ACGT(s.at(j)))
           count++;
        else
          break;
      }
    }
    if(count > max_count)
       max_count = count;
  }
  cout << max_count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
const int maxn=10000;
using namespace std;

int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
/* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif */
{
     #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif 
	ll n,d;
	cin>>n>>d;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		double dis=sqrt(x*x+y*y);
		if(dis<=d)
		{
			cnt++;
		}
	}
	cout<<cnt;
	
}




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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define forz(i,n) for( int i=0;i<n;i++)
#define forl(i, n) for(int i = 1; i<= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

void cpc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif
}

int main()
{
	// cpc();
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// lli t;
	// cin >> t;
	// while (t--)
	// {
	lli n , sum = 0, r = 0, g = 0, b = 0, ct = 0 ;
	string s;

	cin >> n;
	cin >> s;
	lli arr [s.size() + 1];
	forz(i, n)
	{
		if (s[i] == 'R')
		{
			r++;
			arr[i] = 1;
		}
		else if (s[i] == 'G')
		{
			g++;
			arr[i] = 2;
		}
		else if (s[i] == 'B')
		{
			b++;
			arr[i] = 3;
		}
	}
	forz(i, n)
	{
		for (int j = 1; j <= n / 2; j++)
		{
			if ((i + (j * 2)) >= n)
			{
				continue;/* code */
			}
			if ((arr[i] != arr[i + j]) && (arr[i + j] != arr[i + j + j]) && (arr[i] != arr[i + j + j]))
			{
				ct ++;
			}
		}
	}
	sum = (r * g * b) - ct;
	cout << sum << endl;
	// }
	return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>

using namespace std;

char s[200001];
int left[200001];
int right[200001];

int main() {
    int n, ans = 1e9, i;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) {
        left[i + 1] = left[i];
        if (s[i] == '#') left[i + 1]++;
    }
    
    for (i = n - 1; i >= 0; i--) {
        right[i] = right[i + 1];
        if (s[i] == '.') right[i]++;
    }
    
    for (i = 0; i <= n; i++) ans = min(ans, left[i] + right[i]);
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  char s[20];
  cin>>s;
  int len=strlen(s);
  int iti;
  bool flag=false,flag2=false;
  int Cco=0;
  if(s[0]=='A')flag=true;

  if(flag==true) {
    for(int i=2;i<len-1;i++){
      if(s[i]=='C'){
	Cco++;
	iti=i;
      }
    }
  }
  if(Cco==1){
    flag2=true;
    for(int i=1;i<len;i++){
      if((i!=iti)&&(isupper(s[i])))flag2=false;
    }
  }
    if(flag2==true){
      cout<<"AC"<<endl;
    }else{
      cout<<"WA"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;

char a[200000];
int main() {
	scanf("%s", a);
	int b = strlen(a);
	int sum = 0;
	stack<bool>S;
	for (int c = 0; c < b; c++) {
		if (a[c] == 'S') {
			S.push(true);
		}
		else {
			if (S.empty() || S.top() == false)S.push(false);
			else S.pop();
		}
	}
	cout << S.size() << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

string D = "UDLR";
void fail(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W,N;
  cin >> H >> W >> N;
  int sr,sc;
  cin >> sr >> sc;
  sr--;
  sc--;
  string Ss,Tt;
  cin >> Ss >> Tt;
  int S[200100],T[200100];
  for(int i=0; i<N; i++){
    S[i] = D.find(Ss[i]);
    T[i] = D.find(Tt[i]);
  }
  for(int t=0; t<2; t++){
    int add = 2*t+1;
    int sub = 2*t;
    int start = (t==0 ? sr : sc);
    int X = (t==0 ? H : W);
    int mx=X-1,mn=0;
    for(int i=N-1; i>=0; i--){
      if(T[i] == sub){
        mx = min(X-1,mx+1);
      }else if(T[i] == add){
        mn = max(0, mn-1);
      }
      if(S[i] == add){
        mx--;
      }else if(S[i] == sub){
        mn++;
      }
      if(mn > mx) fail();
    }
    if(!(mn <= start and start <= mx)) fail();
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 2456
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
  int ans;
  for (int i = 0; i < 5; i++) {
    int a;
    cin >> a;
    if (a == 0) ans = i+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int l[200];
  int ans=0;
  rep(i,n*2) cin>>l[i];
  sort(l,l+(2*n));
  for(int i=0;i<n*2;i+=2){
    ans+=l[i];
  }
  cout<<ans<<endl;

  return 0;
}


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


int main() {
  bool flag=true;
  int N,nt,nx,ny;
  cin >> N;
  int t=0; int x=0; int y=0;
  for (int i=0;i<N;i++){
    cin >> nt >> nx >> ny;
    if (abs(nx-x)+abs(ny-y)>nt-t || (abs(nx-x)+abs(ny-y))%2 != (nt-t)%2){
      flag=false;
    }
    t=nt; x=nx; y=ny;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,M;
long long inf=1000000007;
cin>>N>>M;
long long dp[2][M+100];
//Sのi番,Tのj番まで見たときの総組み合わせをdp[i][j]とする
long long S[N+10];
long long T[M+10];
long long s,t;
dp[0][0]=1;
dp[1][0]=1;
for(int i=1;i<=N;++i){
  cin>>s;
  S[i]=s;
}
for(int j=1;j<=M;++j){
  cin>>t;
  T[j]=t;
  dp[0][j]=1;
}
for(int i=1;i<=N;++i){
  for(int j=1;j<=M;++j){
    if(S[i]==T[j]){
      dp[1][j]=(dp[0][j]+dp[1][j-1]+inf)%inf;
    }
    else{
      dp[1][j]=(dp[1][j-1]+dp[0][j]-dp[0][j-1]+inf)%inf;
    }
  }
  //テーブル更新
    for(int y=1;y<=M;++y){
      dp[0][y]=dp[1][y];
    }}
long long ans=0;
ans=dp[1][M];
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main(){
	var a,b,h,m int
	var m_val,h_val,val,c2 float64
	fmt.Scan(&a,&b,&h,&m)
	m_val = float64(6*m)
	h_val = float64(float64(30*h) + float64(float64(m)*float64(0.5)))
//fmt.Println(h_val,m_val)
	if h_val < m_val {
		if m_val - h_val <= 180 {
			val = m_val - h_val
		} else {
			val = 360 - m_val + h_val
		}
	} else {
		if h_val - m_val <= 180 {
			val = h_val - m_val
		} else {
			val = 360 - h_val + m_val
		}
	}
//fmt.Println(val)
	c2 = float64(a*a + b*b) - (float64(2*a*b)*math.Cos(val/90 * (math.Pi/2)))
	fmt.Println(math.Sqrt(c2))
}


Measured memory_bytes: 1820
N,x=map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans=0


if sum(a)<x:
    print(N-1)
else:
    for i in range(len(a)):
        if x>=a[i]:
            x -= a[i]
            ans += 1
        else:
            break
    print(ans)



Measured memory_bytes: 61416
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
using namespace std;
ll x, k, d;
void work() {
  scanf("%lld%lld%lld", &x, &k, &d), x = abs(x);
  ll tmp = min(x / d, k);
  k -= tmp, x -= tmp * d;
  if(k % 2 == 0) printf("%lld\n", x);
  else printf("%lld\n", d - x);
}
signed main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) {
    work();
  }
  return 0;
}

Measured memory_bytes: 3820
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

// 2つのn次元ベクトルxとyの距離を計算

int main() {
    int iInputN;            // 列数N
    double dData[2][100];   // データが入る行列
    int iCount, iCount2;    // counter
    double dManhattan = 0;  // マンハッタン距離
    double dEuclid = 0;     // ユークリッド距離
    double dP3Distance = 0; // p = 3
    double dChebyshev = 0;  // チェビシェフ距離


    // In: 列数N
    scanf("%d", &iInputN);
    // x,yについて入力
    for (iCount = 0; iCount < 2; iCount++) {
        for (iCount2 = 0; iCount2 < iInputN; iCount2++) {
            scanf("%lf", &dData[iCount][iCount2]);
        }
    }

    // マンハッタン距離
    for (iCount = 0; iCount < iInputN; iCount++) {
        dManhattan += fabs(dData[0][iCount] - dData[1][iCount]);
    }

    // ユークリッド距離
    for (iCount = 0; iCount < iInputN; iCount++) {
        dEuclid += pow(fabs(dData[0][iCount] - dData[1][iCount]), 2.0);
    }
    dEuclid = sqrt(dEuclid);

    // p = 3
    for (iCount = 0; iCount < iInputN; iCount++) {
        dP3Distance += pow(fabs(dData[0][iCount] - dData[1][iCount]), 3.0);
    }
    dP3Distance = pow(dP3Distance, 1.0 / 3.0);

    // チェビシェフ距離
    for (iCount = 0; iCount < iInputN; iCount++) {
        if (dChebyshev < fabs(dData[0][iCount] - dData[1][iCount]))
            dChebyshev = fabs(dData[0][iCount] - dData[1][iCount]);
    }

    printf("%.8lf\n", dManhattan);
    printf("%.8lf\n", dEuclid);
    printf("%.8lf\n", dP3Distance);
    printf("%.8lf\n", dChebyshev);

    return 0;
}


Measured memory_bytes: 2104