akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    string s;
    ll fx = 0;
    
    cin >> s;

    REP(i, s.length()){
        fx += ll(s[i] - '0');
    }

    if (fx%9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

}

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


int main() {
    int N,cnt=0;
    cin >> N ;
    vector<int>A(N);

    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3==0||A[i]%5==0)cnt++;
        }
        else if(A[i]%2==1)cnt++;
    }

    if(cnt==N)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  string ans;
  
  if(N == "Sunny"){
  ans = "Cloudy";
  }
   if(N == "Cloudy"){
  ans = "Rainy";
  }
  
   if(N == "Rainy"){
  ans = "Sunny";
  }
  
    cout << ans << endl;
  
}

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

using namespace std;

typedef long long llint;
const llint INF = 1e18;

llint dp[1 << 12];

int main() {
  int n, m;
  cin >> n >> m;
  vector<llint> a(m), b(m);
  vector<vector<llint>> c(m, vector<llint>(n));
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  for (int i = 0; i < 1 << n; i++) {
    dp[i] = INF;
  }
  dp[0] = 0;

  for (int i = 0; i < m; i++) {
    int now = 0;
    for (int j = 0; j < b[i]; j++) {
      now |= (1 << c[i][j]);
    }

    for (int bit = 0; bit < 1 << n; bit++) {
      if (dp[bit | now] > dp[bit] + a[i]) {
        dp[bit | now] = dp[bit] + a[i];
      }
    }
  }
  if (dp[(1 << n) - 1] == INF) dp[(1 << n) - 1] = -1;
  cout << dp[(1 << n) - 1] << endl;

  return 0;
}


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

int main() {
  int H,W;

  cin >> H >> W;

  vector<string> a(H);
  string str ="";

  for(int i=0; i<H; i++) {
      cin >> a.at(i);
  }

  for(int i=0; i<W+2; i++) {
      str += "#";
  }



  for(int i=0; i<H+2; i++) {
      if(i==0 || i==H+1) {
          cout << str << endl;
      } else {
          cout << '#' << a.at(i-1) << '#' << endl;
      }
  }


 

}

Measured memory_bytes: 256
#include<iostream>

int main()
{
  //input
  std::string strN;
  std::cin >> strN;

  int sum = 0;
  for (std::string::iterator it = strN.begin(); it != strN.end(); ++it) {
    char c = *it;
    sum += atoi(&c);
  }
  std::string ans = (sum % 9 == 0) ? "Yes" : "No";

  //putput
  std::cout << ans;
  
  return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll sm=0;
  ll n;
  cin>>n;
  for(ll i=1; i<=n; i++) {
    if(i%3!=0&&i%5!=0)
      sm+=i;
  }
  cout <<sm << endl;
  return 0;
}


Measured memory_bytes: 3652
S = int(input())
x1, y1 = 0, 0
x2, y2 = 10 ** 9, 1
y3 = S // (10 ** 9) + 1
x3 = 10 ** 9 * y3 - S
if (S == 10 ** 18):
    print(0, 0, 10**9, 0, 0, 10**9)
else:
    print(x1, y1, x2, y2, x3, y3)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
char s[300005];
int dp[20][20][20];
int main(){
cin>>n;
scanf("%s",s+1);
dp[0][0][0]=1;
for(int i=1;i<=n;i++){
	int temp=s[i]-'0'+1;
	//dp[temp][0][0]=1;
	for(int j=1;j<=10;j++){
		for(int k=1;k<=10;k++){
			if(dp[j][k][0]){
				dp[j][k][temp]=1;
			}
		}
	}
	for(int j=0;j<=10;j++){
		if(dp[j][0][0])dp[j][temp][0]=1;
	}
	dp[temp][0][0]=1;
}
int ans=0;
for(int i=1;i<=10;i++){
	for(int j=1;j<=10;j++){
		for(int k=1;k<=10;k++){
			if(dp[i][j][k])ans++;
		}
	}
}
cout<<ans;

return 0;
}


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

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

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    // vll As(N);
    // vll Bs(M);
    ll As[N];
    ll Bs[M];

    ll sum = 0;
    int aindex = -2;
    rep(i, N) {
        cin >> As[i];
        if (aindex == -2 && sum <= K - As[i]) {
            sum += As[i];
        } else if (aindex == -2) {
            aindex = i - 1;
        }
    }

    if (aindex == -2) {
        aindex = N-1;
    }
    // cout << sum << endl;

    int bindex = -2;
    rep(i, M) {
        cin >> Bs[i];
        // cout << sum << endl;
        if (bindex == -2 && sum <= K - Bs[i]) {
            sum += Bs[i];
        } else if (bindex == -2) {
            bindex = i - 1;
        }
    }
    // cout << sum << endl;

    if (bindex == -2) {
        bindex = M-1;
    }

    ll maxcount = aindex + bindex + 2;
    ll nowcount = aindex + bindex + 2;

    // cout << aindex << " " << bindex << " " << sum << endl;
    bindex++;
    
    for (int i = aindex; i >= 0; i--) {
        sum -= As[i];
        nowcount -= 1;
        while(sum <= K - Bs[bindex]) {
            sum += Bs[bindex];
            bindex++;
            nowcount++;
            if (bindex == M) {
                break;
            }
        }
        // cout << i << " " << bindex << " " << sum << " " << nowcount << endl;
        maxcount = std::max(maxcount, nowcount);
        if (bindex == M) {
            break;
        }
    }
    cout << maxcount << endl;
}

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

const int N = 100010;

int n;
int a[N];
bool vis[N];

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
	}
	int now = 1, cnt = 1;
	for ( ; ; ++ cnt){
		vis[now] = true;
		now = a[now];
		if (now == 2){
			return printf("%d\n", cnt), 0;
		}
		if (vis[now]){
			break;
		}
	}
	return printf("-1\n"), 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    CHR(a);
    if(isupper(a)) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
   
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt();
		int M = in.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];

		for(int i = 0; i < N; i++){
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
		for(int i = 0; i < M; i++){
			c[i] = in.nextInt();
			d[i] = in.nextInt();
		}
		int p = 0;
		for(int i = 0; i < N; i++){
			int min = Integer.MAX_VALUE;
			for(int j = 0; j < M; j++){
				if(min > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])){
					min = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
					p = j + 1;
				}
			}
			System.out.println(p);
		}
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main() {
	long long int n, x, result = 0,tmp;
	scanf("%lld%lld", &n, &x);
	result = n;
	n = n - x;
	while (n != 0) {
		if (n%x != 0) { result += 2 * x*(n / x); }
		else { result += (2 * x*(n / x)-x);printf("%lld",result); return 0; }
		tmp = n%x;
		n = x;
		x = tmp;
	}
}

Measured memory_bytes: 128
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 string c; cin >> c;
 if(c >= "A" && c <= "Z") cout << "A";
 else cout << "a";
return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s;
  cin >> s;

  for (int i = s.size()-1; i >= 0; i -= 2) {
    int n = i/2;
    if(s.substr(0, n) == s.substr(n, n)){
      cout << n*2 << "\n";
      return 0;
    }
  }

  return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
#define ll  long long
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int m = max(A, max(B, C));
    cout << m * 10 + A + B + C - m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);
  A.push_back(0);

  i64 money = 1000;
  i64 stock = 0;
  for (i64 i = 0; i < N; ++i) {
    money += stock * A[i];
    stock = 0;
    if (A[i] < A[i + 1]) {
      stock = money / A[i];
      money -= stock * A[i];
    }
  }

  std::cout << money << std::endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

struct C{
	double r,x,y;
	C(double r,double x,double y) : r(r) , x(x) , y(y) {}
};

bool cmp_x(const C &a,const C &b){ return a.x == b.x ? a.y < b.y : a.x < b.x ; }
bool cmp_y(const C &a,const C &b){ return a.y == b.y ? a.x < b.x : a.y < b.y ; }

double dist(const C &a,const C &b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt( x * x + y * y );
}
int main(){
	int n;
	while(cin >> n && n){
		vector<C> a,b;
		for(int i = 0 ; i < n ; i++){
			double r,x,y;
			cin >> r >> x >> y;
			a.push_back(C(r,x,y));
			b.push_back(C(r,x,y));
		}
		double ans = 1e15;
		sort(a.begin(),a.end(),cmp_x);
		sort(b.begin(),b.end(),cmp_y);
		for(int i = 0 ; i < n ; i++){
			for(int j = max(0,i-300) ; j < min(i+300,n) ; j++){
				if(i!=j) ans = min(ans,dist(a[i],a[j])-a[i].r-a[j].r);
			}
			for(int j = max(0,i-300) ; j < min(i+300,n) ; j++){
				if(i!=j) ans = min(ans,dist(b[i],b[j])-b[i].r-b[j].r);
			}
		}
		printf("%.7f%c",ans,10);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, s, a[3003];

ll sol(int l, int r) {
    ll z = 0;
    int d[3003] = {1}, e[3003] = {}, f[3003] = {1}, g[3003] = {};
    if (l == r) return a[l] == s;
    int m = (l + r) / 2;
    for (int i = m; i >= l; i--) {
        for (int j = s; j >= a[i]; j--) {
            d[j] += d[j - a[i]];
            if (d[j] >= 998244353) d[j] -= 998244353;
        }
        for (int j = 0; j <= s; j++) {
            e[j] += d[j];
            if (e[j] >= 998244353) e[j] -= 998244353;
        }
    }
    for (int i = m + 1; i <= r; i++) {
        for (int j = s; j >= a[i]; j--) {
            f[j] += f[j - a[i]];
            if (f[j] >= 998244353) f[j] -= 998244353;
        }
        for (int j = 0; j <= s; j++) {
            g[j] += f[j];
            if (g[j] >= 998244353) g[j] -= 998244353;
        }
    }
    for (int i = 0; i <= s; i++) z = (z + 1ll * e[i] * g[s - i]) % 998244353;
    //for (int i = 0; i <= s; i++) cout << d[i] << ' ' << f[i] << '\n';
    //cout << l << ' ' << r << ' ' << z << '\n';
    return (z + sol(l, m) + sol(m + 1, r)) % 998244353;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> s;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cout << sol(1, n);
}


Measured memory_bytes: 4204
using System.Linq;
using System.Collections.Generic;
using System;

public static class Permi
{
    public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> items, int? k = null)
    {
        if (k == null) k = items.Count();
        if (k == 0) yield return Enumerable.Empty<T>();
        else
        {
            var i = 0;
            foreach (var x in items)
            {
                var xs = items.Where((_, index) => i != index);
                foreach (var c in Perm(xs, k - 1))
                    yield return c.Before(x);
                i++;
            }
        }
    }
    public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
    {
        yield return first;
        foreach (var i in items) yield return i;
    }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        if (a[3] == 9) { Console.WriteLine(0); goto next; }
        var b = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        var p = new List<int>();
        for (int i = 0; i < 9; i++)
            if (a[i] == -1) p.Add(i);
            else b.Remove(a[i]);
        var ans = getAns(a, b, p);
        Console.WriteLine(ans);
        next:;
    }
    public static int getAns(int[] a, List<int> b, List<int> p)
    {
        var bL = b.Count();
        var ans = 0;
        foreach (var x in b.Perm(bL))
        {
            var w = x.ToArray();
            for (int i = 0; i < bL; i++) a[p[i]] = w[i];
            if (a[3] == 9 || a[6] < a[3] || a[6] - a[3] >= 2) continue;
            if (check(a)) ans++;
        }
        return ans;
    }
    public static bool check(int[] a) => 100 * a[3] + 10 * (a[1] + a[4]) + a[0] + a[2] + a[5] == 100 * a[6] + 10 * a[7] + a[8];
}


Measured memory_bytes: 23824
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<double,double> P;
typedef pair<P,double> Pd;
Pd p[101];
map <double,int> M;
map <int,double> M2;
vector <Pd> Y[301];


double calc(){
  double sum=0;
  vector <P> a;
  for(int i=0;M2.count(i+1);i++){
    
    for(int j=0;j<Y[i].size();j++)
      if(Y[i][j].s==1)a.push_back(Y[i][j].f);
      else a.erase(find(a.begin(),a.end(),Y[i][j].f));
    
    sort(a.begin(),a.end());
    double l=-1e9,r=-1e9,m=0;
    for(int j=0;j<a.size();j++){
      if(a[j].f<r)r=max(r,a[j].s);
      else m+=r-l,l=a[j].f,r=a[j].s;
    }
    m+=r-l;
    sum+=m*(M2[i+1]-M2[i]);
  }
  return sum;
}

int main(){
  int n,T=1;
  
  while(cin>>n,n){
    for(int i=0;i<n;i++)cin>>p[i].f.f>>p[i].f.s>>p[i].s;
    vector<double> a;
    for(int i=0;i<n;i++){
      a.push_back(p[i].f.s+p[i].s);
      a.push_back(p[i].f.s-p[i].s);
    }

    sort(a.begin(),a.end());
    M.clear();
    M2.clear();
    for(int i=0,cnt=0;i<a.size();i++){
      assert(cnt<201);
      if(!M.count(a[i]))M2[cnt]=a[i],M[a[i]]=cnt++;
    }

    for(int i=0;i<300;i++)Y[i].clear();

    for(int i=0;i<n;i++){
      double l=p[i].f.f-p[i].s,r=p[i].f.f+p[i].s;
      Y[M[p[i].f.s-p[i].s]].push_back(Pd(P(l,r),1));
      Y[M[p[i].f.s+p[i].s]].push_back(Pd(P(l,r),-1));
    }
    printf("%d %.2f\n",T++,calc());
    
  }
  
  
  
  return 0;
}

Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\\s"); //?????????????????´??????????????¨?????±???????????????\\???????????????
		int i = 0;
		while(i == 0) {
			int h = scan.nextInt();//??´??°??\????????????
			int w = scan.nextInt();//??´??°??\???????¨?)
			if (h == 0 && w == 0) {  //h w???0?????¨????????????
				break;
			} else if (h > 0){  //0??§???????????£?????¨????????????
				for (int j = 0; j < h; j++) { //j???h????????§?????????????????§??????
					for (int k = 0; k < w; k++) { //k???w????????§?????????????????§??????
						if(j==0 || k==0 || j==h-1 || k==w-1){
							/*
							 ??????j???0?????????k???0?????????j???h-1?????????k???w-1?????£???
							 ??´???????????????"#"
							 */
							System.out.print("#");
						} else {
							System.out.print(".");
							}
					}
						System.out.println();//\\s??§??????
				}
					System.out.println();//\\s??§??????
			}
		}
	}
}

Measured memory_bytes: 34020
n = int(input())
s = input()
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dictionary = {}
dict_gyaku = {}
for i,a in enumerate(alpha):
    dictionary[a] = i
    dict_gyaku[i] = a
ans = ''
for j in s:
    ans += dict_gyaku[(dictionary[j] + n)%26]
    
print(ans)

Measured memory_bytes: 41068
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

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

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
int ans;

int main()
{
    //~ freopen("file.in", "r", stdin);
    string s;
    ll k;
    cin>>s>>k;
	for(int i=0;i<s.size();i++)
		if(i==k-1){
			ans=s[i]-'0';	
			break;
		}
		else
			if(s[i]!='1'){
				ans=s[i]-'0';
				break;
			}
	printf("%d\n",ans);
	return 0;
}


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


int main(){
    long long n;
    map<long long,long long> a;
    long long temp;
    cin >> n;
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        cin >> temp;
        a[temp]++;
        if(a[temp] % 2 == 1) ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
from fractions import gcd
from collections import defaultdict


def main():
    K = int(input())
    d = defaultdict(int)
    ans = 0
    for i in range(K):
        for j in range(K):
            g = gcd(i + 1, j + 1)
            d[g] += 1
    for g in d.keys():
        for i in range(K):
            ans += gcd(g, i + 1) * d[g]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75936
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

struct edge{
    int to, len;
};

vector<edge> G[100000];
int N;
bool color[100000], used[100000];

void dfs(int n){
    used[n] = true;
    for(edge e: G[n]){
        if(used[e.to]) continue;
        if(e.len & 1){
            color[e.to] = not color[n];
        }else{
            color[e.to] = color[n];
        }
        dfs(e.to);
    }
}

int main(void){
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int u, v, w;
        cin >> u >> v >> w; u--; v--;
        edge e; e.to = v; e.len = w;
        G[u].push_back(e);
        e.to = u;
        G[v].push_back(e);
    }

    color[0] = 0;
    dfs(0);

    for(int i = 0; i < N; i++) cout << color[i] << '\n';

    return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> vect(n,0);
    for(int i=0 ; i<n ; i++){
        cin>>vect[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(vect[1]-vect[0]);
    for(int i=2 ; i<n ; i++){
        dp[i]=min(dp[i-2]+abs(vect[i-2]-vect[i]),dp[i-1]+abs(vect[i-1]-vect[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

class Main {
    public static void main(String[] args) {
        // input
        Scanner scanner = new Scanner(System.in);
        int[] a=new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = Integer.parseInt(scanner.next());
        }
        int k = Integer.parseInt(scanner.next());
        scanner.close();
        //solve

        // output
        if (Math.abs(a[0]-a[4])<=k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }        
        System.out.flush();
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123456;
int a[MAXN], b[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    vector<pii> V1;
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &a[i], &b[i]);
        V1.push_back(make_pair(a[i] + b[i], i));
    }
    sort(V1.rbegin(), V1.rend());
    LL ans = 0;
    for (int i = 0; i < N; i++) {
        int cur = V1[i].second;
        if (i % 2) ans -= b[cur];
        else ans += a[cur];
    }
    printf("%lld\n", ans);


    return 0;
}


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

int main()
{
    int N, Y, flag = 0;
    int x = 10000, y = 5000, z = 1000;
    cin >> N >> Y;

    //cout << N << Y << endl;

    for (int i = N; i >=0 ; i--){
        for (int j = N-i; j >= 0;j--){
            for (int k = N-i-j; k >= 0; k--){
                if((i+j+k)!=N){
                    //cout << "break" << endl;
                    continue;
                }
                else if ((i + j + k) == N && (x*i+y*j+z*k)==Y)
                {
                    cout << i << " " << j << " " << k << endl;
                    flag=1;
                }

                if(flag==1){
                    break;
                }
            }
        if (flag == 1)
        {
            break;
        }
        }
    if (flag == 1)
    {
        break;
    }
    }
    if(flag==0){
        cout << "-1 -1 -1" << endl;
    }

}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] treesHighs = new long[n];
        for (int i = 0; i < n; i++) {
            treesHighs[i] = sc.nextLong();
        }
        
        Arrays.sort(treesHighs);
        
        long minDifference = treesHighs[k - 1] - treesHighs[0];
        for (int i = 1; i <= n - k; i ++) {
            long difference = treesHighs[i + k - 1] - treesHighs[i];
            minDifference = Math.min(minDifference, difference);
        }
        
        System.out.println(minDifference);
    }
}

Measured memory_bytes: 48916
#include<stdio.h>
int main(){
  int a,p,da=1,s=0,n;
  scanf("%d%d",&n,&p);n--;
  while(n--){
    scanf("%d",&a);
    if(da*(a-p)<0){
      s+=p*da;
      da*=-1;
    }
    p=a;
  }
  if(da>0)s+=p;
  printf("%d",s);
}

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

#define ll long long

const ll MOD = 1000000007;

int main() {
  ll dp[2010][700] = {0};
  
  int S; cin >> S;
  
  for (int i = 3; i <= 2000; i++) {
    dp[i][1] = 1;
  }
    
  
  
  for (int i = 1; i <= 670; i++) {
    
    // 累積和をつくる
    vector<ll> sum(2010, 0);
    for (int j = 0; j < 2005; j++) {
      sum[j+1] = sum[j] + dp[j][i];
      
    }
    
    /*
    for (int j = 0; j < 10; j++) {
      cout << sum[j] << " ";
    }
    cout << endl;
    */
    for (int j = 3; j <= 2000; j++) {
      dp[j][i+1] = sum[j-2] + MOD- sum[3];
      dp[j][i+1] %= MOD;
    }
    
  } 

    
  ll ans = 0;
  
  for (int i = 0; i < 670; i++) {
    ans += dp[S][i];
    ans %= MOD;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 14616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<d;i++){
        cout << myRand(26)+1 << endl;
    }
}

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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  
  for (int i = 0; i < N; i++) {
    cout << S.at(i) << T.at(i);
  }
  
  cout << endl;
  
}


Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 500005
int n;
string s;
int lcnt[MN];
int rcnt[MN];

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

    cin >> s;
    n = s.length()+1;
    FOR(i, 1, n){
        if(s[i-1] == '<'){
            lcnt[i] = lcnt[i-1]+1;
        } else{
            lcnt[i] = 0;
        }
    }
    RFOR(i, n-1, 0){
        if(s[i] == '>'){
            rcnt[i] = rcnt[i+1]+1;
        } else{
            rcnt[i] = 0;
        }
    }
    ll sm = 0;
    F0R(i, n){
        sm += max(lcnt[i], rcnt[i]);
    }

    cout << sm << "\n";

    return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int r, g, b;

    scanf("%d%d%d", &r, &g, &b);

    int t = g * 10 + b;

    if(t % 4 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 1588
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;
 
int main() {
    for (char c; (c = getchar()) != '\n';) {
        if (c >= 65 && c <= 90)
            cout << (char)(c + 32);
        else if (c >= 97 && c <= 122)
            cout << (char)(c - 32);
        else
            cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	char x, y;
	scanf("%c %c", &x, &y);
	if(x < y)
		printf("<\n");
	else if(x > y)
		printf(">\n");
	else
		printf("=\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define mod 1000000007
#define pb push_back
void dora()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	dora(); fast;

	int t = 1; //cin >> t;
	while (t--)
	{
		int n, d; cin >> n >> d;
		int x, y, ans = 0;
		while (n--)
		{
			cin >> x >> y;
			if (sqrt(x * x + y * y) <= d)
				ans++;
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

const double one = 1.0;
const double PI = 3.141592653589;
const ll m = ll(1e9+7);

vector<ll> edge[100005];
bool vis[100005];

void dfs(ll st)
{
	vis[st] = 1;
	FOR(i,0,edge[st].size())
	{
		if(!vis[edge[st][i]])
		{
			dfs(edge[st][i]);
		}
	}
}

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	FOR(i,0,m)
	{
		ll a,b;
		cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	ll ans = 0;
	memset(vis,false,sizeof(vis));
	FORE(i,1,n)
	{
		if(!vis[i])
		{
			dfs(i);
			ans++;
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 10428
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{ 
  string answer="";
  int n,l,i,temp;
  cin>>n>>l;
  vector<string> word(n);
  for(i=0;i<n;i++)
  {
  cin>>word[i];
  }
  sort(word.begin(),word.end());
  for(string s:word)
  {answer+=s;
  }
  cout<<answer;
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        const int M = 1000000007;
        static void Main(string[] args)
        {
            string S = Read();
            int N = S.Length;
            var dp = new long[N][];
            dp[0] = new long[] { 1, 2 };
            for (int i = 1; i < N; ++i)
            {
                switch (S[i])
                {
                case '0':
                    dp[i] = new long[] { dp[i - 1][0] * 3 % M, dp[i - 1][1] * 1 % M };
                    break;
                case '1':
                    dp[i] = new long[] { (dp[i - 1][0] * 3 + dp[i - 1][1]) % M, dp[i - 1][1] * 2 % M };
                    break;
                }
            }
            Console.WriteLine(dp[N - 1].Sum() % M);
        }
    }
}


Measured memory_bytes: 22492
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> P(N);
    for(int i=0;i < N;++i){
        cin >> P.at(i);
    }
    vector<double> EXP(N);
    for(int i=0;i<N;++i){
        EXP[i] = (P[i]+1.)/2;
    }
    vector<double> S(N-K+1);
    double value = 0.;
    for(int i=0; i<K;++i){
        value += EXP[i];
    }
    S[0] = value;
    for(int i=1; i<N-K+1;++i){
        value += EXP[i+K-1] - EXP[i-1];
        S[i] = value;
    }
    double ans = 0.;
    for(int i=0;i<N-K+1;++i){
        if(ans < S[i]){
            ans = S[i];
        }
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        boolean increase = true;

        for (int i = 1; i < n; i++) {
            if (h[i-1] < h[i]) {
                h[i]--;
            } else {
                if (h[i-1] != h[i]) {
                    increase = false;
                }
            }
        }   

        if (increase) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b[100000],c,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0,asum=0,bsum=0;

string s,w;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
       }
       rep(i,n){
           cin >> b[i];
       }
       rep(i,n){
           if(a[i]>b[i]){
               cmp+=a[i]-b[i];
           }
           else{
               cmpp+=(b[i]-a[i])/2;
           }
       }
       Yes(cmpp>=cmp)
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int getId(char c) {
  if(c=='R') return 0;
  if(c=='G') return 1;
  return 2;
}
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vvi sum(N+1,vi(3,0));
  rep(i,N) {
    rep(j,3) {
      sum[i+1][j] = sum[i][j];
    }
    sum[i+1][getId(s[i])]++;
  }
  ll ans = 0;
  rep(i,N) {
    srep(j,i+1,N) {
      if(s[i]==s[j]) continue;
      int r = 3 - getId(s[i]) - getId(s[j]);
      int num = sum[N][r] - sum[j+1][r];
      int l = j-i;
      if(j+l<N&&getId(s[j+l])==r) num--;
      ans += num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3856
// C++ program to count number of factors 
// of an array of integers 
#include <bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// array to store prime factors 
int factor[MAX] = { 0 }; 

// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
	factor[1] = 1; 

	// Initializes all the positions with their value. 
	for (int i = 2; i < MAX; i++) 
		factor[i] = i; 

	// Initializes all multiples of 2 with 2 
	for (int i = 4; i < MAX; i += 2) 
		factor[i] = 2; 

	// A modified version of Sieve of Eratosthenes to 
	// store the smallest prime factor that divides 
	// every number. 
	for (int i = 3; i * i < MAX; i++) { 
		// check if it has no prime factor. 
		if (factor[i] == i) { 
			// Initializes of j starting from i*i 
			for (int j = i * i; j < MAX; j += i) { 
				// if it has no prime factor before, then 
				// stores the smallest prime divisor 
				if (factor[j] == j) 
					factor[j] = i; 
			} 
		} 
	} 
} 

// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
	if (n == 1) 
		return 1; 

	int ans = 1; 

	// stores the smallest prime number 
	// that divides n 
	int dup = factor[n]; 

	// stores the count of number of times 
	// a prime number divides n. 
	int c = 1; 

	// reduces to the next number after prime 
	// factorization of n 
	int j = n / factor[n]; 

	// false when prime factorization is done 
	while (j != 1) { 
		// if the same prime number is dividing n, 
		// then we increase the count 
		if (factor[j] == dup) 
			c += 1; 

		/* if its a new prime factor that is factorizing n, 
		then we again set c=1 and change dup to the new 
		prime factor, and apply the formula explained 
		above. */
		else { 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		} 

		// prime factorizes a number 
		j = j / factor[j]; 
	} 

	// for the last prime factor 
	ans = ans * (c + 1); 

	return ans; 
} 

// Driver program to test above function 
int main() 
{ 
	// generate prime factors of number 
	// upto 10^6 
	generatePrimeFactors(); 

	int n;
    cin>>n;
     int a[n-1];
     for(int i=0;i<n-1;i++)
    a[i] = i+1;


    int sum=0;
	for (int i = 0; i < n-1; i++) 
	sum+=calculateNoOFactors(a[i]);
    cout<<sum<<endl;

	return 0; 
} 


Measured memory_bytes: 11396
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;

constexpr int kMaxN = 100000;
constexpr int kMaxQ = 100000;

struct Op {
  char com;
  int idx;
};

int N,Q;
int par[kMaxN];
vector<bool> marked;
vector<Op> ops;

void Init(void) {

  marked.resize(N);
  fill(marked.begin(), marked.end(), false);
  marked[0] = true;

}

int dfs(int i) {
  if (marked[i]) return i;
  return dfs(par[i]);
}

void solve(void) {
  Init();

  int ans = 0;
  for (auto op : ops) {
    if (op.com == 'Q') {
      ans += dfs(op.idx) + 1;
    } else {
      marked[op.idx] = true;
    }
  }
  cout << ans << endl;
}

signed main(void) {
  while(true) {
    cin >> N >> Q;
    if ( N == 0 && Q == 0) break;
    par[0] = 0;
    rep (i, N-1) {
      cin >> par[i+1];
      par[i+1]--;
    }
    ops.resize(Q);
    rep (i,Q) {
      cin >> ops[i].com >> ops[i].idx;
      ops[i].idx--;
    }
    solve();
  }

}


Measured memory_bytes: 5112
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
		long answer = 0;

    if(w == 1 || h == 1) answer = 1;
    else if(w % 2 == 0) answer = h*w/2;
    else answer = h*(w-1)/2 +(h+1)/2;

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <tuple>
#include <set>
#include <functional> 
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define MT make_tuple
#define FOR(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REP(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll > pll;
using namespace std;
const int MAX = 101;
const double PI = 3.1415926535897932384;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

bool mark[12][12];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

void dfs(int y, int x, vector<string> &tb){
	mark[y][x] = true;

	FOR(i, 4){
		if (x + dx[i] < 0 || x + dx[i] >= 12 || y + dy[i] < 0 || y + dy[i] >= 12) continue;
		if (tb[y + dy[i]][x + dx[i]] == '1' && !mark[y + dy[i]][x + dx[i]]){
			dfs(y + dy[i], x + dx[i], tb);
		}
	}
	return;
}

int main(){
	while (1){
		memset(mark, false, sizeof(mark));

		vector<string> tb(12, "");
		FOR(i, 12){
			cin >> tb[i];
			if (cin.eof()) return 0;
		}

		int ans = 0;
		FOR(i, 12){
			FOR(j, 12){
				if (tb[i][j] == '1' && !mark[i][j]){
					dfs(i, j, tb);
					ans++;
				}
			}
		}

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

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;


int main(){

    ll n;
    ll h[maxn];
    ll k;
    cin >> n>>k;
    rep(i,n)cin >> h[i];
    sort(h,h+n);
    ll ans=0;
    rep(i,n-k)ans+=h[i];
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 5064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


n = int(readline())
ans = len(make_divisors(n - 1)) - 1
for check in make_divisors(n):
    if check != 1:
        flag = True
        memo = n
        while flag:
            memo //= check
            if memo % check != 0:
                flag = False
        if memo % check == 1:
            ans += 1
print(ans)


Measured memory_bytes: 3188