akhauriyash/Code-Regression huggingface dataset:
fn main(){
    let x: usize = read();
    let mut dp: Vec<usize> = vec![0;x+1];
    dp[0] = 1;

    for i in 100 .. 106 {
        for j in 0 ..= x {
            if dp[j] == 1 && i + j <= x { dp[i+j] = 1 }
        }
    }
    
    println!("{}", dp[x]);
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 2724
#include<iostream>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    string ans;
    while (n > 0) {
        n--;
        ans += ((char)('a' + n % 26));
        n /= 26;
    }
    for (long long i = ans.length() - 1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include <iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<string.h>
#include<math.h>
#include<unordered_map>
#include <deque>
using namespace std;


typedef long long ll;

int ans[100][100] = {};

void putw(int i) {
	i--;
	int j = (int)(i / 50);
	i=i%50;

	ans[i * 2 ][j * 2 + 1] = 1;
	ans[i * 2 + 1][j * 2 + 1] = 1;
	ans[i * 2 + 1][j * 2] = 1;
}

void putb(int i) {
	i--;
	int j = (int)(i / 50);
	i = (i % 50);

	ans[i * 2][100- j * 2 - 1] = 1;
}

int main()
{
	int a, b;

	cin >> a >> b;

	a--;
	if (a > 0) {
		for (int i = 0; i < a; i++) {
			putw(i + 1);
		}
		b--;
	}

	if (b > 0) {
		for (int i = 0; i < b; i++) {
			putb(i + 1);
		}
	}

	cout << "100 100" << endl;

	for (int i = 0; i < 100; i++) {
		string s;
		for (int j = 0; j < 100; j++) {
			s += (ans[i][j] == 1) ? "#" : ".";
		}

		cout << s << endl;
	}


	return 0;
}

Measured memory_bytes: 256
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	H := readInt()
	W := readInt()
	Ch := readInt() - 1
	Cw := readInt() - 1
	Dh := readInt() - 1
	Dw := readInt() - 1
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	t := make([][]int, H)
	for i := 0; i < H; i++ {
		t[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if S[i][j] == '#' {
				t[i][j] = -1
			} else {
				t[i][j] = math.MaxInt64
			}
		}
	}

	t[Ch][Cw] = 0
	q := make([][2]int, 0)
	q = append(q, [2]int{Ch, Cw})

	for len(q) != 0 {
		warpq := make([][2]int, 0)
		for len(q) != 0 {
			h, w := q[0][0], q[0][1]
			warpq = append(warpq, [2]int{h, w})
			q = q[1:]
			if h-1 >= 0 && t[h-1][w] > t[h][w] {
				q = append(q, [2]int{h - 1, w})
				t[h-1][w] = t[h][w]
			}
			if h+1 < H && t[h+1][w] > t[h][w] {
				q = append(q, [2]int{h + 1, w})
				t[h+1][w] = t[h][w]
			}
			if w-1 >= 0 && t[h][w-1] > t[h][w] {
				q = append(q, [2]int{h, w - 1})
				t[h][w-1] = t[h][w]
			}
			if w+1 < W && t[h][w+1] > t[h][w] {
				q = append(q, [2]int{h, w + 1})
				t[h][w+1] = t[h][w]
			}
		}

		if t[Dh][Dw] != math.MaxInt64 {
			break
		}

		for i := 0; i < len(warpq); i++ {
			h, w := warpq[i][0], warpq[i][1]
			for i := max(0, h-2); i <= min(H-1, h+2); i++ {
				for j := max(0, w-2); j <= min(W-1, w+2); j++ {
					if t[i][j] <= t[h][w]+1 {
						continue
					}
					t[i][j] = t[h][w] + 1
					q = append(q, [2]int{i, j})
				}
			}
		}
	}

	if t[Dh][Dw] == math.MaxInt64 {
		println(-1)
	} else {
		println(t[Dh][Dw])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 24100
using System;
using System.Linq;
using System.Collections;
class Program
{
    public static void Main()
    {
        string[] imp = Console.ReadLine().Split(' ');
        int a, b;
        a = int.Parse(imp[0]);
        b = int.Parse(imp[1]);
        int c = 0;
        for (int i = a; i <= b; i++)
        {
            string str = i.ToString();
            int n = str.Length;
            bool f = true;

            for (int j = 0; j <= n / 2; j++)
                f = f && (str[j] == str[n - 1 - j]);

            if (f)
                c++;
        }
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
using namespace std;

int main()
{
    int z=0,n,x1,x2;cin>>n;
    int a[n][2];
    for (int i=0;i<n;i++){
        for (int j=0;j<2;j++){
        cin >>a[i][j];
        }
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<1;j++){
        if (a[i][j]==a[i][j+1]){z++;}
        else if(z>=3){break;}
        else {z=0;}
        }
    }
    if (z>=3){cout<<"Yes";}
    else {cout<<"No";}



    return 0;
}


Measured memory_bytes: 3640
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a.charAt(i)==b.charAt(i) && b.charAt(i) == c.charAt(i) ){
                continue;
            }else if(a.charAt(i)==b.charAt(i) || b.charAt(i) == c.charAt(i) || c.charAt(i)== a.charAt(i)  ){
                ans++;
            }else{
                ans+=2;
            }
        }
        System.out.println(ans);

        sc.close();
    }

}

Measured memory_bytes: 21972
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

const int MAXN = 105000;

int n;
int a[MAXN];
int p[MAXN], s[MAXN];

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

int main() {
  //assert(freopen("input.txt","r",stdin));
  //assert(freopen("output.txt","w",stdout));
  cin.tie(0);
  ios::sync_with_stdio(0);

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

  p[0] = a[0];
  for (int i = 1; i < n; i++) {
    p[i] = gcd(a[i], p[i - 1]);
  }
  s[n - 1] = a[n - 1];
  for (int i = n - 1; i >= 0; i--) {
    s[i] = gcd(a[i], s[i + 1]);
  }

  int ans = p[n - 1];
  for (int i = 0; i < n; i++) {
    int cur = 0;
    if (i > 0) {
      cur = gcd(cur, p[i - 1]);
    }
    if (i + 1 < n) {
      cur = gcd(cur, s[i + 1]);
    }
    ans = max(ans, cur);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int fun(string s,string t,int x){
    int k=t.size();
    int ans=0;
    for(int i=x;i<x+k;i++){
        if(s[i]!=t[i-x]){
            ans++;
        }
    }
    return ans;
}
int main()
{
   string s,t;
   cin>>s>>t;
   int ans=t.size();
   int m=t.size();
   for(int i=0;i<=s.size()-m;i++){
       ans=min(ans,fun(s,t,i));
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <vector>
#include <boost/operators.hpp>
using namespace std;

constexpr int MOD = 1000000007;

// a を m で割った余り(>=0)を返す。
constexpr inline int mod(int a, int m) noexcept {
    int r = a % m;
    return r < 0 ? r + m : r;
}

struct ModInt : private boost::operators<ModInt> {
    int value;
    constexpr ModInt() noexcept : value(0) {}
    constexpr explicit ModInt(int value) noexcept
        : value(mod(value, MOD)) {}
    constexpr ModInt& operator+=(const ModInt& rhs) noexcept {
        value += rhs.value;
        if (value > MOD) value -= MOD;
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt& rhs) noexcept {
        value -= rhs.value;
        if (value < 0) value += MOD;
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt& rhs) noexcept {
        value = ((int64_t)value * rhs.value) % MOD;
        return *this;
    }
    constexpr bool operator<(const ModInt& rhs) const noexcept {
        return value < rhs.value;
    }
    constexpr bool operator==(const ModInt& rhs) const noexcept {
        return value == rhs.value;
    }
};
ostream& operator<<(ostream& os, const ModInt& rhs) {
    os << rhs.value;
    return os;
}
istream& operator>>(istream& is, ModInt& rhs) {
    int i; is >> i;
    rhs.value = mod(i, MOD);
    return is;
}
constexpr inline ModInt operator""_m(unsigned long long value) noexcept {
    return ModInt((int)value);
}

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

int main() {
    int H, W; cin >> H >> W;
    vector field(H, vector(W, char()));
    REP(y, H) REP(x, W) cin >> field[y][x];

    // dp[y][x]: (0, 0)から(y, x)までの経路の数
    vector dp(H, vector(W, ModInt()));
    dp[0][0] = 1_m;
    REP(y, H) REP(x, W) {
        if(y+1 < H && field[y+1][x] == '.') dp[y+1][x] += dp[y][x];
        if(x+1 < W && field[y][x+1] == '.') dp[y][x+1] += dp[y][x];
    }

    cout << dp[H-1][W-1] << '\n';
}


Measured memory_bytes: 8516
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, l, r;
  cin >> N;
  vector<ll> X(N), sortX(N);
  for(ll i = 0; i < N; i++) {
    cin >> X.at(i);
    sortX.at(i) = X.at(i);
  }
  sort(sortX.begin(), sortX.end());
  l = sortX.at(N / 2 - 1);
  r = sortX.at(N / 2);
  for(ll i = 0; i < N; i++) {
    if(X.at(i) <= l) cout << r << endl;
    else cout << l << endl;
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

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

  map<string, int> dic;
  int maxn = 1;
  rep(i, N)
  {
    string m;
    cin >> m;
    if(dic.find(m) == dic.end())
    {
      dic[m] = 1;
    }
    else
    {
      dic[m] = dic[m] + 1;
      if(dic[m] > maxn)
      {
        maxn = dic[m];
      }
    }
  }

  for(auto iter = dic.begin(); iter != dic.end(); ++iter){
    auto tmp = *iter;
    if(tmp.second == maxn)
    {
      cout << tmp.first << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 25216
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << "Yes" << endl; exit(0);}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	REP(i, n+1) REP(j, m+1) if (i*(m-j)+(n-i)*j == k) END();
	cout << "No" << endl;

	return 0;
}


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

const int MAX = 1e3;
const int INF = 1e9;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, m;
	while (cin >> n >> m, n | m) {
		vector<vector<int>> xs(n + 2), ds(n + 2);
		vector<vector<vector<int>>> dp(n + 2);
		xs[0].assign(MAX, 0);
		xs[n + 1].assign(MAX, 0);
		for (int i = 0; i < MAX; i++) xs[0][i] = i;
		for (int i = 0; i < MAX; i++) xs[n + 1][i] = i;
		ds[0].assign(MAX, 0);
		ds[n + 1].assign(MAX, 0);
		dp[0].assign(MAX, vector<int>(m + 1, 0));
		dp[n + 1].assign(MAX, vector<int>(m + 1, INF));
		for (int i = 1; i <= n; i++) {
			int k;
			cin >> k;
			for (int j = 0; j < k; j++) {
				int x, d;
				cin >> x >> d; x--;
				xs[i].push_back(x);
				ds[i].push_back(d);
				dp[i].push_back(vector<int>(m + 1, INF));
			}
		}
		for (int i = 1; i < n + 2; i++) {
			for (int j = 0; j < (int)xs[i - 1].size(); j++) {
				for (int k = 0; k < (int)xs[i].size(); k++) {
					for (int l = 0; l <= m; l++) {
						dp[i][k][l] = min(dp[i][k][l], dp[i - 1][j][l] + abs(xs[i][k] - xs[i - 1][j]) * (ds[i][k] + ds[i - 1][j]));
					}
				}
			}
			if (i == 1) continue;
			for (int j = 0; j < (int)xs[i - 2].size(); j++) {
				for (int k = 0; k < (int)xs[i].size(); k++) {
					for (int l = 0; l < m; l++) {
						dp[i][k][l + 1] = min(dp[i][k][l + 1], dp[i - 2][j][l] + abs(xs[i][k] - xs[i - 2][j]) * (ds[i][k] + ds[i - 2][j]));
					}
				}
			}
		}
		int res = INF;
		for (auto last : dp[n + 1]) {
			for (auto val : last) {
				res = min(res, val);
			}
		}
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 4232
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;

int main(void) {
  int N;
  cin>>N;
  vector<vector<LL> >A(N,vector<LL>(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>A[i][j];

  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<i;j++)
        if(A[i][j] > A[i][k]+A[k][j]){
          cout << -1 << endl;
          return 0;
        }

  LL ans=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      int need=1;
      for(int k=0;k<N;k++){
        if(k!=i and k!=j and A[i][j]==A[i][k]+A[k][j])
          need=0;
      }
      if(need) ans+=A[i][j];
    }
  }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  int yon = 0, ni = 0, sonota = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] % 4 == 0)
      yon++;
    else if (v[i] % 2 == 0)
      ni++;
    else
      sonota++;
  }
  if (sonota <= yon || (sonota <= yon + 1 && ni == 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int i,j,k,n,x,d,v,V[110][110];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      V[i][j]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d",&v);
      V[x][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)
	printf(" ");
      printf("%d",V[i][j]);
    }
    printf("\n");
      }
  
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
int n,cnt;
int a[2010],w[2010],rd[2010];
pii e[4000010];
bool vis[2010];
vector<int>G[2010];
inline int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
}
void add(int u,int v){
    e[++cnt]=mp(v,w[u]);
    w[u]=cnt;
}
void dfs(int x){
    vis[x]=1;
    for(auto to:G[x])if(!vis[to]){
        add(x,to);
        rd[to]++;
        dfs(to);
    }
}
//priority_queue<pii,vector<pii>,greater<pii> >pq;
priority_queue<pii>pq;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
            if(gcd(a[i],a[j])>1){
                G[i].pb(j);
                G[j].pb(i);
            }
    for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i=1;i<=n;i++)if(!rd[i])pq.push(mp(a[i],i));
    while(!pq.empty()){
        pii curr=pq.top();
        pq.pop();
        cout<<curr.first<<' ';
        for(int i=w[curr.second];i;i=e[i].second){
            int v=e[i].first;
            rd[v]--;
            if(!rd[v])pq.push(mp(a[v],v));
        }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 17664
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int k[150];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n;
    while (cin >> n) {
        LL cnt = 0;
        while (cnt * cnt <= n)
            cnt++;
        cout << (cnt-1) * (cnt-1) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    bool find = false;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            int x = i * m + j * n - i*j*2;
            if(x==k) find = true;
        }
    }
    if(find){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b, k;
  cin >> a >> b >> k;
  if (b-a+1 >= 2*k){
    for (int i = 0; i < k; ++i) {
      cout << a+i << endl;
    }
    for (int i = k-1; i >= 0; --i) {
      cout << b-i << endl;
    }
  }
  else {
    for (int i = a; i <= b; ++i) {
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N=int(input())
W=[[[0]*10 for _ in range(3)]for _ in range(4)]
for i in range(N):
    bil,col,row,e=map(int,input().split())
    W[bil-1][col-1][row-1]+=e
for k in range(4):
  if k!=0:
    print("#"*20)
  for u in range(3):
    for j in range(10):
      print(f" {W[k][u][j]}",end="")
      if j==9:
        print()



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

int main(){
  long N, H, W, A, B, cnt = 0;
  cin >> N >> H >> W;
  for (int i=0; i < N; i++)
  {
    cin >> A >> B;
    if (H <= A & W <= B)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(void){
    string S;
    cin >> S;
    
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == 'R') cnt++;
    }
    
    if(cnt == 3){
        cout << 3 << endl;
        return 0;
    }else if(cnt == 2){
        if(S[1] == 'R'){
            cout << 2 << endl;
            return 0;
        }
    }else if(cnt == 0){
        cout << 0 << endl;
        return 0;
    }
    
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

int main(void)
{
	int a1count=0,a2count=0,a4count=0;
	int i,N,x;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&x);
		if(x%4==0)
			a4count++;
		else if(x%2==0)
			a2count++;
		else
			a1count++;
	}//得出3类数字的个数 
	if(a2count>0 && a1count<=a4count)
		printf("Yes\n");//典型的幸运数列的排列方法 
	else if(a2count==0 && a1count<=a4count+1)//同样也是 
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
n = int(input())
mod = 10 ** 9 + 7

factorials = [1]
for i in range(1, n + 1):
    factorials.append((factorials[-1]) * i % mod)

print((pow(10, n, mod) - pow(9, n, mod) - pow(9, n, mod) + pow(8, n, mod)) % mod)


Measured memory_bytes: 140480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll v[9] = {};
        rep(i, n){
            cin >> a;
            v[min(8LL, a / 400)]++;
        }
        ans = 0;
        rep(i, 8){
            if(v[i]){
                ans++;
            }
        }
        out(max(1LL, ans)), out(' '), print(ans + v[8]);
    }
}


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

int main(){

	
	int n; cin>>n;
	string s; cin>>s;
	int R[n+1];
	int B[n+1];
	int G[n+1];
	R[0] = G[0] = B[0] = 0;
	for(int i = 1; i <= n; i++) R[i] = R[i-1]+(s[i-1] == 'R');
	for(int i = 1; i <= n; i++) B[i] = B[i-1]+(s[i-1] == 'B');
	for(int i = 1; i <= n; i++) G[i] = G[i-1]+(s[i-1] == 'G');
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(s[i] != s[j]){
				if(s[i] != 'R' && s[j] != 'R'){
					ans += R[n]-R[j];
					if(s[j+(j-i)] == 'R') ans--;
				}
				if(s[i] != 'B' && s[j] != 'B'){
					ans += B[n]-B[j];
					if(s[j+(j-i)] == 'B') ans--;
				}
				if(s[i] != 'G' && s[j] != 'G'){
					ans += G[n]-G[j];
					if(s[j+(j-i)] == 'G') ans--;
				}
			}
		}
	}
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 3688
/* 
 * Author: aps
 * Time: 2020-01-26 21:34:07
**/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
 
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll gcd(ll x, ll y) { return x == 0 ? y : gcd(y % x, x); }
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int h,a; cin >> h >> a;
    int ans = h/a;
    if(h%a != 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x,y,z,k = na()
aa = sorted(na())
bb = sorted(na())
cc = sorted(na())
ab = sorted([a+b for a in aa for b in bb])[-1:-1-k:-1]
abc = sorted([i+c for i in ab for c in cc])[-1:-1-k:-1]
print('\n'.join([str(n) for n in abc]))

Measured memory_bytes: 186168
#include<stdio.h>
int main(){
  int n,i,j,min,b,c=0;
  scanf("%d",&n);
  if(n<0||n>100)return 0;
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<0||a[i]>100)return 0;
  }
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j]<a[min])min=j;
    }
    if(a[i]==a[min]);
    else{b=a[i];
    a[i]=a[min];
    a[min]=b;
    c++;}
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
    }
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2128
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
int n,d[N],fa[N],dp[N];
struct Node{
  int dep,u;
  Node(int x=0,int y=0){
    dep = x;
    u = y;
  }
  bool operator<(const Node &rhs)const{
    return dep>rhs.dep;
  }
};
priority_queue<Node>q;
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;++i)
        scanf("%d",&fa[i]),++d[fa[i]];
    for(int i=1;i<=n;++i)dp[i] = 0;
    for(int i=1;i<=n;++i)if(!d[i]){
       q.push(Node(1,i));
       dp[i] = 1;
    }
    while(!q.empty()){
        int u = q.top().u;
        q.pop();
        if(u==1&&q.empty())break;
        dp[fa[u]] = max(dp[u]+1,dp[fa[u]]+1);
//        printf("u:%d fa:%d dpu:%d dpf:%d\n",u,fa[u],dp[u],dp[fa[u]]);
//        system("pause");
        --d[fa[u]];
        if(!d[fa[u]])q.push(Node(dp[fa[u]],fa[u]));
    }
    printf("%d\n",dp[1]-1);
    return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int K, T; cin >> K >> T;
  vector<pii> a(T, pii(0, 0));
  rep(i, T) {
    a[i].second = i;
    cin >> a[i].first;
  }

  int prev_day = -1;
  int ans = 0;

  while (true) {
    sort(a.begin(), a.end(), greater<pii>());
    int target;
    if (a[0].first == 0) break;

    for (target = 0; target < T; target++) {
      if (a[target].second != prev_day) break;
    }

    if (a[target].first == 0) {
      ans += a[0].first;
      a[0].first = 0;
    } else {
      a[target].first--;
      prev_day = a[target].second;
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;

int main(void) {
  int i, j, k, h, w, now = 0;
  int x[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  scanf("%d%d", &h, &w);
  char s[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  queue< pair<int, int> > q1, q2;
  for(i = 1; i < h - 1; ++i) for(j = 1; j < w - 1; ++j) if(s[i][j] != '.') {
    int a = 0;
    for(k = 0; k < 8; ++k) if(s[i + x[k]][j + y[k]] == '.') ++a;
    if(s[i][j] - '0' <= a) {
      pair<int, int> p = make_pair(i, j);
      q2.push(p);
    }
  }
  while(!q2.empty()) {
    pair<int, int> p;
    p = q2.front();
    s[p.first][p.second] = '.';
    q1.push(p);
    q2.pop();
  }
  if(q1.empty()) {
    printf("0\n");
    return 0;
  }
  while( !q1.empty() ) {
    /*for(i = 0; i < h;++i) printf("%s\n", s[i]);
    printf("\n");*/
    while( !q1.empty() ) {
      pair<int, int> p = q1.front();
      q1.pop();
      for(i = 0; i < 8; ++i) if(s[p.first + x[i]][p.second + y[i]] != '.') {
        int a = 0;
        for(j = 0; j < 8; ++j) {
          if(s[p.first + x[i] + x[j]][p.second + y[i] + y[j]] == '.') ++a;
        }
        if(a >= s[p.first + x[i]][p.second + y[i]] - '0') {
           pair<int, int> pp = make_pair(p.first + x[i], p.second + y[i]);
           q2.push(pp);
           s[p.first + x[i]][p.second + y[i]] = '0' + 9;
        }
      }
    }
    while(!q2.empty()) {
      pair<int, int> p;
      p = q2.front();
      s[p.first][p.second] = '.';
      q1.push(p);
      q2.pop();
    }
    ++now;
  }
  printf("%d\n", now);
  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
bool use[12];
bool ok(int n)
{
	while(n>0)
	{
		if (use[n%10])return false;
		n/=10;
	}
	return true;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for (int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		use[d]=true;
	}
	while(!ok(n))
		n++;
	cout <<n;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    double A[N];
    rep(i,N) cin >> A[i];
    double ave=0;
    rep(i,N) ave+=A[i];
    ave/=N;
    double dis=INF;
    int ans=-1;
    rep(i,N){
        if(dis>fabs(A[i]-ave)) dis=fabs(A[i]-ave),ans=i;
    }
    cout << ans << endl;
}

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

struct Edge
{
    int to;
    int id;
};

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

    int a, b;
    vector<vector<Edge>> edge(N);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back((Edge){b, i});
        edge[b].push_back((Edge){a, i});
    }

    int K = 0;
    vector<int> ans(N - 1, 0);
    vector<bool> visited(N + 1, false);
    queue<pair<int, int>> q;
    q.push(make_pair(0, -1));
    while (!q.empty())
    {
        int next = q.front().first;
        int parent = q.front().second;
        q.pop();
        visited[next] = true;
        int color = 1;
        for (Edge e : edge[next])
        {
            if (visited[e.to])
            {
                continue;
            }
            if (color == parent)
            {
                color++;
            }
            q.push(make_pair(e.to, color));
            ans[e.id] = color;
            K = max(K, color);
            color++;
        }
    }
    cout << K << endl;
    for (int a : ans)
    {
        cout << a << endl;
    }
    cout << endl;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

unsigned long long N, A, B, C, D;
unsigned long long dp(ll N, map<unsigned long long, unsigned long long>& mp) {
	//cout << "dp" << endl;
	if (N == 0) return mp[0] = 0;
	//if (N == 1) return mp[1] = D;
	if (mp[N]) return mp[N];
	mp[N] = D * N;
	mp[N] = min(mp[N], min(D * abs(N % 5) + C + dp(N / (ll)5, mp), D * abs(5 - N % 5) + C + dp((N + 4) / (ll)5, mp)));
	mp[N] = min(mp[N], min(D * abs(N % 3) + B + dp(N / (ll)3, mp), D * abs(3 - N % 3) + B + dp((N + 2) / (ll)3, mp)));
	mp[N] = min(mp[N], min(D * abs(N % 2) + A + dp(N / (ll)2, mp), D * abs(2 - N % 2) + A + dp((N + 1) / (ll)2, mp)));
	return mp[N];
}

int main() {
	int T; cin >> T;
	for (int i = 0; i < T; i++) {
		cin >> N >> A >> B >> C >> D;
		map<unsigned long long, unsigned long long> mp;
		cout << dp(N, mp) << endl;
	}

}

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

//見ながら
int main() {

    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    vector<double> vec(n);
    double ans = 100000000;
    int res = 0;
    rep(i, n){
        cin >> vec.at(i);
        if(ans > abs(a-(t - vec.at(i) * 0.006))){
            ans = abs(a-(t - vec.at(i) * 0.006));
            res = i + 1;
        }
    }
    cout << res << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	string s;
	cin >> s;
	vi sr(n + 1), sg(n + 1), sb(n + 1);
	for (int i = 0; i < n; i++)
	{
		sr[i + 1] = sr[i];
		sg[i + 1] = sg[i];
		sb[i + 1] = sb[i];
		if (s[i] == 'R')
			sr[i + 1]++;
		else if (s[i] == 'G')
			sg[i + 1]++;
		else
			sb[i + 1]++;
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			bool used[3] = { false, false, false };
			if (s[i] == s[j])
				continue;
			if (s[i] == 'R' || s[j] == 'R')
				used[0] = true;
			if (s[i] == 'G' || s[j] == 'G')
				used[1] = true;
			if (s[i] == 'B' || s[j] == 'B')
				used[2] = true;
			vi* cur;
			if (!used[0])
				cur = &sr;
			else if (!used[1])
				cur = &sg;
			else
				cur = &sb;
			res += (*cur)[n] - (*cur)[j];
			int dif = j - i;
			if (j + dif < n && s[j + dif] != s[i] && s[j + dif] != s[j])
				res--;

		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3696
import sys
import re
import queue
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    H, W = i_map()
    Ch, Cw = i_map()
    Dh, Dw = i_map()
    Ch,Cw = Ch-1,Cw-1
    Dh,Dw = Dh-1,Dw-1
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

    # walk:移動A, warp:移動B
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:  # 移動A
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
        for dx, dy in warp:  # 移動B
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
    ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
    print(ans)


if __name__ == '__main__':
	main()

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

int main() {
	int n, a, b, c;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a >> b >> c;
		a *= a;
		b *= b;
		c *= c;
		if(a == b + c || b == a + c || c == a + b)
		  cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    double d,t,s;
    cin >> d >> t >> s;
    if(s*t >= d)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3736
import numpy as np
n,m,c = list(map(int,input().split()))
b = tuple(map(int,input().split()))
array_b = np.array(b)
s = 0
for i in range(n):
  a = tuple(map(int,input().split()))
  array_a = np.array(a)
  t = array_a.T
  if np.dot(t,b) + c > 0:
    s += 1
  else:
    pass
print(s)

Measured memory_bytes: 21496
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   int a[N];
   for(int i=0; i<N; ++i)
      std::cin >> a[i];

   std::vector<int> b(N,-1);
   for(int i=N-1; i>=0; --i){
      int n = i+1;
      int count = 0;
      for(int j=2; n*j<=N; ++j){
	 count += b[n*j-1];
      }
      if(a[i]==1){
	 if(count%2==1) b[i] = 0;
	 else b[i] = 1;
      }else{
	 if(count%2==1) b[i] = 1;
	 else b[i] = 0;
      }
   }
   std::cout << std::count(b.begin(), b.end(), 1) << std::endl;
   for(int i=0; i<N; ++i){
      if(b[i]==1) std::cout << i+1 << std::endl;
   }

   return 0;
}


Measured memory_bytes: 2432
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(M);
    vector<pll> A(N+1,{0,0});
    FORI(i,0,M)
    {
        READV(x);
        string S;
        cin>>S;
        if (S=="WA" && A[x].se==0)
        {
            A[x].fi++;
        }
        else if(S=="AC")
        {
            A[x].se++;
        }
    }
    ll ac=0,wa=0;
    FORI(i,1,N+1)
    {
        if (A[i].se>=1)
        {
            wa+=A[i].fi;
            ac++;
        }
    }
    cout<<ac<<" "<<wa<<endl;

//-----------------------------------------------------------------------------------------------------------//


    return 0;
}

Measured memory_bytes: 1792
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 1; i <=n-1; i++) ans+= i;
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 256