akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>  
#include<math.h>  
  
//#include<map>   
//#include<set>
#include<deque>  
#include<queue>  
#include<stack>  
#include<bitset> 
#include<string>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
  
#define ll long long  
#define INF 0x3f3f3f3f  
#define clean(a,b) memset(a,b,sizeof(a))// 水印 
#define mod 1000000


int shuzu[15][15];
int shuaxin[15];
bool biaoji[15];
int maxx[15];
int n;

void prime(int x)
{
	clean(biaoji,0);
	clean(shuaxin,INF);
	shuaxin[x]=0;
	for(int i=0;i<n;++i)
	{
		int can=-1;
		int min=INF;
		for(int j=0;j<n;++j)
		{
			if(biaoji[j]==0&&shuaxin[j]<min)
			{
				can=j;
				min=shuaxin[j];
			}
		}
		if(can==-1)
			break;
		biaoji[can]=1;
		for(int j=0;j<n;++j)
		{
			if(biaoji[j]==0&&shuzu[can][j]+shuaxin[can]<shuaxin[j])
				shuaxin[j]=shuzu[can][j]+shuaxin[can];
		}
	}
}

int main()
{
	int t;
	while(cin>>t&&t!=0)
	{
		n=0;
		clean(shuzu,INF);
		for(int i=0;i<t;++i)
		{
			int s,e,l;
			cin>>s>>e>>l;
			shuzu[s][e]=l;
			shuzu[e][s]=l;
			n=n>s?n:s;
			n=n>e?n:e;
		}
		n++;
		for(int i=0;i<n;++i)
			shuzu[i][i]=0;
		clean(maxx,0);
		for(int i=0;i<n;++i)
		{
			prime(i);
//			for(int j=0;j<n;++j)
//				cout<<shuaxin[j]<<" ";
//			cout<<endl;
			for(int j=0;j<n;++j)
				maxx[i]=maxx[i]+shuaxin[j];
		}
		int res=0,resl=maxx[0];
		for(int i=0;i<n;++i)
		{
			if(maxx[i]<resl)
			{
				resl=maxx[i];
				res=i;
			}
		}
		cout<<res<<" "<<resl<<endl;
	}
	
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N;cin >> N;
  int a[N];
  REP(i,N) cin >> a[i];
  ll dp[N+1][N+1] = {0};
  for(int section=1; section<=N;section++){
    int isfirst = -1;
    if(section%2) isfirst=1;
    REP(l,N+1-section){
      int r = l+section;
      ll ret1 = dp[l+1][r] + isfirst*a[l];
      ll ret2 = dp[l][r-1] + isfirst*a[r-1];
      ret1*=isfirst;
      ret2*=isfirst;
      dp[l][r] = max(ret1,ret2);
      dp[l][r]*=isfirst;
    }
  }
  ll ans = dp[0][N];
  if(N%2==0)ans*=-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 2e5 + 10;

ll ar[5] = { 1, 2, 4, 8 };
ll br[5];

int main() {
    #ifdef CLown1331
        freopen( "in.txt","r",stdin );
    #endif /// CLown1331
    ll n, ans;
    while( cin >> br[0] >> br[1] >> br[2] >> br[3] >> n ) {
        n *= 4;
        ans = 0;
        for( int i=0; i<4; i++ ) {
            for( int j=i+1; j<4; j++ ) {
                ll h = ar[j] / ar[i];
                h *= br[i];
                br[j] = min( h, br[j] );
            }
        }
        for( int i=3; i>=0; i-- ) {
            ll h = n / ar[i];
            n %= ar[i];
            ans += h * br[i];
        }
        cout << ans << "\n";
        cerr << "-----\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> v;

bool solve(int a){
	int i = a;
	int res = 0;
	while(i < v.size()){
		res += v[i].size();
		i++;
		if(res == 5){
			while(i < v.size()){
				res += v[i].size();
				i++;
				if(res == 12){
					while(i < v.size()){
						res += v[i].size();
						i++;
						if(res == 17){
							while(i < v.size()){
								res += v[i].size();
								i++;
								if(res == 24){
									while(i < v.size()){
										res += v[i].size();
										i++;
										if(res == 31)return true;
										else if(res > 31)return false;
									}
								}
								else if(res > 24)return false;
							}
						}
						else if(res > 17)return false;
					}
				}
				else if(res > 12)return false;
			}
		}
		else if(res > 5)return false;
	}
	return false;
}

int main(){
	int n;
	string s;
	while(cin >> n,n){
		v.clear();
		for(int i = 0;i < n;i++){
			cin >> s;
			v.push_back(s);
		}
		for(int i = 0;i < n;i++){
			if(solve(i)){
				cout << i+1 <<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  vector<int> botan(N);
  vector<int> kita(N);
 
  for (int i = 0; i < N; i++) {
    cin >> botan.at(i);
  }
  
  int cnt = 0;
  int botan_next = 0;
  while(botan_next != 1){
    int botan_now = botan_next;
    if (kita[botan_now] == 1){
      cnt=-1;
      break;
    }
    kita[botan_now] = 1;
    botan_next = botan.at(botan_now)-1;
    cnt++;
    //cout << "next: "<< botan_next << endl;
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 1024
def main():
    a,b,c=map(int,input().split())
    sumi = set()
    for i in range(10**9):
        x = a*i%b
        if x in sumi:
            break
        elif x == c:
            print("YES")
            return
        else:
            sumi.add(x)
    print("NO")
    
if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    char c;
    cin >> c;
    cout << ++c;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
#define dump2(v) for(auto i:v) { for(auto j:i) std::cout << j << ' '; std::cout << "\n"; }


signed main() {
	std::string s;
	std::cin >> s;
	const std::string a = "AKIHABARA";
	if(s.size()>a.size()) {
		print("NO");
		return 0;
	}
	std::string t = "A";
	for(auto i:s) {
		t+=i;
		t+='A';
	}
	int n = t.size();
	int m = a.size();

	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	rep(i,n) rep(j,m) {
		if(a[j]==t[i]) dp[i+1][j+1]=dp[i][j]+1;
		else {
			dp[i+1][j+1] = std::max(dp[i][j+1],dp[i+1][j]);
		}
	}
	std::vector<std::vector<int> > dp2(s.size()+1,std::vector<int>(m+1,0));
	rep(i,s.size()) rep(j,m) {
		if(a[j]==s[i]) dp2[i+1][j+1]=dp2[i][j]+1;
		else {
			dp2[i+1][j+1] = std::max(dp2[i][j+1],dp2[i+1][j]);
		}
	}

	if(dp[n][m]==m&&dp2[s.size()][m]==s.size()) {
		print("YES");
	} else print("NO");
	return 0;
}


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

int main(){
  long N, K, R, S, P;
  string T,A="";
  cin >> N >> K >> R >> S >> P >> T;
  long ans=0;
  for(int i=0; i<K; i++){
    if(T[i]=='r'){A+='p'; ans+=P;}
    else if(T[i]=='s'){A+='r'; ans+=R;}
    else {A+='s'; ans+= S;}
    T+='a';
  }
  for(int i=K; i<N; i++){
    if(T[i]=='r'){
      if(A[i-K]!='p'){A+='p';ans+=P;}
      else{
        if(T[i+K]=='p'){A+='r';}
        else if(T[i+K]=='r'){A+='r';}
        else {A+='s';}
      }
    }
    else if(T[i]=='p'){
      if(A[i-K]!='s'){A+='s';ans+=S;}
      else{
        if(T[i+K]=='p'){A+='r';}
        else if(T[i+K]=='r'){A+='r';}
        else {A+='p';}
      }
    }
    else{
      if(A[i-K]!='r'){A+='r';ans+=R;}
      else{
        if(T[i+K]=='p'){A+='p';}
        else if(T[i+K]=='r'){A+='s';}
        else {A+='p';}
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 704
def main():
    N, M = map(int, input().split())
    a, b = [0] * N, [0] * N
    for i in range(N):
        a[i], b[i] = map(int, input().split())
    c, d = [0] * M, [0] * M
    for i in range(M):
        c[i], d[i] = map(int, input().split())
    for i in range(N):
        min_d = 2 * 10 ** 8
        min_d_j = 0
        for j in range(M):
            md = abs(a[i] - c[j]) + abs(b[i] - d[j])
            if md < min_d:
                min_d = md
                min_d_j = j
        print(min_d_j + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  int a;
  cin>>a;
  a%=1000;
   if(a==0){
    cout<<0<<endl;
  }
  else{
  cout<<1000-a<<endl;
  }
}
  



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    string a[n];
    ll b[n];
    ll ag=0;
    for(int x=0;x<n;x++)
    {
        cin>>a[x]>>b[x];
        ag+=b[x];
    }
    string h;
    cin>>h;
    ll g=0;
    for(int x=0;x<n;x++)
    {    g+=b[x];
        if(a[x]==h)
            break;
    }
    cout<<ag-g;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    N -= 2;
    N *= 180;
    cout<<N<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Text.Printf
import Data.List

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO()
main = do
  n <- readLn
  as <- replicateM n $ getInts
  let aas = concat as
  printf "%s" $ slv aas

slv ::[Int] -> String
slv [a] = show a
slv (a:as) = slv2 (a:as) max1 max2 []
  where (max1:max2:ret) = reverse $ sort (a:as)

slv2 :: [Int] -> Int -> Int -> [String] -> String
slv2 [] _ _ ret = unlines $ reverse ret
slv2 (a:as) max1 max2 ret | a == max1 = slv2 as max1 max2 ((show max2):ret)
                          | otherwise = slv2 as max1 max2 ((show max1):ret)

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

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}

class UnionFind{
  private:
	vector<int> data;

  public:
	UnionFind(int n) : data(n,-1) {}
	int root(int i) { return data[i] < 0 ? i : data[i] = root(data[i]); }
	int size(int i) { return -data[root(i)]; }
	bool same(int x, int y) {return root(x) == root(y); }
	bool connected() {return size(0) == (int)data.size(); }

	bool unit(int i,int j){
		i = root(i);
		j = root(j);
		if(i != j){
			data[i] += data[j];
			data[j] = i;
		}
		return i != j;
	}
};

int main()
{
	int n, m; cin >> n >> m;
	UnionFind tree(n);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--, b--;
		tree.unit(a, b);
	}
	set<int> st;
	for(int i = 0; i < n; i++)st.insert(tree.root(i));
	cout << st.size() - 1 << endl;
}

Measured memory_bytes: 7576
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int a, b;
    cin >> a >> b;

    vector<ll> A;
    A.push_back(0);
    A.push_back(1);
    FOR(i, 2, 1000){
        ll height = A[i-1] + i;
        A.push_back(height);
    }

    ll diff = b - a;
    ll left = A[diff-1];
    ll right = A[diff];

    ll snowHeight = left - a;

    p(snowHeight);
    
    return 0;
}

Measured memory_bytes: 256
N, K = gets.chomp.split(" ").map(&:to_i)
P = []
X = []
N.times{
  P << gets.chomp.split(" ").map(&:to_i)
  X << P[-1][0]
}

ans = 10 ** 20
X.sort!
(0...N).each{|i|
  ((i+1)...N).each{|j|
    tmp = P.select{|k| X[i] <= k[0] && k[0] <= X[j]}
    if tmp.size >= K then
      tmp.map!{|t| t[1]}.sort!
      (0...tmp.size).each{|k|
        ((k+1)...tmp.size).each{|l|
          next if (X[j] - X[i]) * (tmp[l] - tmp[k]) >= ans
          if P.count{|m| X[i] <= m[0] && m[0] <= X[j] && tmp[k] <= m[1] && m[1] <= tmp[l]} == K then
            wk = (X[j] - X[i]) * (tmp[l] - tmp[k])
            ans = wk if ans > wk
          end
        }
      }
    end
  }
}

puts ans


Measured memory_bytes: 3964
def main():
    n = int(input())
    A = list(map(int,input().split()))
    m = 10001
    B = [0]*n
    C = [0]*m
    for a in A:C[a]+=1
    for i in range(1,m):
        C[i] = C[i]+C[i-1]
    for j in range(n):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1
    print (' '.join(map(str,B)))


if __name__ == '__main__':
    main()




Measured memory_bytes: 240576
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

LL mypow(int x, int y)
{
    int r = 1;
    rep(i, y){
        r *= x;
    }
    return r;
}

int main(void)
{
    int X, Y;
    cin >> X >> Y;

    int foot = X * 4;
    if (foot == Y){
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, X){
        foot -= 2;
        if (foot == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
function Main(input) {
  input = input.split("\n");
  var a = parseInt(input[0].split(" ")[0]);
  var b = parseInt(input[0].split(" ")[1]);
  var c = parseInt(input[0].split(" ")[2]);
  var ans =0;
  x = new Array(a,b,c);
  x.sort(function(a,b){
    if( a > b ) return -1;
    if( a < b ) return 1;
    return 0;
  });
  var n =parseInt(x[0]+"" +x[1]+" ");
  ans = n+x[2];

  console.log('%s', ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, N);
	while (N % 111)
		++N;
	out(N);
}


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

int main() {
    vector<int> x(5);
    int answer;
	rep(i,5) {
        cin >> x.at(i);
        if (x.at(i) == 0) {
            answer = i+1;
        }
    }
    cout << answer << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> B(N-1);
  for(int &i:B)
    cin>>i;
  int j=B[0]+B[N-2];
  for(int i=0;i<N-2;i++){
    j+=min(B[i],B[i+1]);
  }
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char tolower(char ch){
    if('A'<=ch && ch<='Z'){
        return ch-'A'+'a';
    }else{
        return ch;
    }
}

int main(){
    int count=0;
    string W;
    cin>>W;
    string str;
    while(1){
        cin>>str;
        if(str=="END_OF_TEXT")break;
        for(int i=0;i<(int)str.size();i++){
            str[i]=tolower(str[i]);
        }
        if(str==W){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3160
#!/usr/bin/env python3

import itertools
import numpy as np

n, m = list(map(int, input().split()))

ks = [list(map(int, input().split())) for _ in range(m)]

p = np.array(list(map(int, input().split())))

# print(ks)
ans = 0
for i in itertools.product([0, 1], repeat=n):
    i = np.array(i)
    flag = 1

    for j in range(len(ks)):
        ks_tmp = np.array(ks[j])
        if np.sum(np.take(i, ks_tmp[1:]-1)) % 2 == p[j]:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1

print(ans)


Measured memory_bytes: 19644
type pos = {east:float;north:float;angle:float}

let _ = 
  let round x = int_of_float @@ if x > 0.0 then floor x else ceil x in
  let to_rad x =
    let pi = 3.14159265358979 in
    x *. pi /. 180.0 in
  let move p d a = 
    {east = p.east +. d *. cos (to_rad p.angle);
     north = p.north +. d *. sin (to_rad p.angle);
     angle = p.angle -. a} in
  let rec iter p =
    let d,a = Scanf.scanf "%f,%f\n" (fun d a -> (d, a)) in
    if d = 0.0 && a = 0.0 then Printf.printf "%d\n%d\n" (round p.east) (round p.north)
    else iter @@ move p d a in
  iter {east = 0.0; north = 0.0; angle = 90.0}

Measured memory_bytes: 2596
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n;
	cin >> n;
	vector<ll> A(n), B(n), C(n);
	rep(i, n) cin >> A[i];
	rep(i, n) cin >> B[i];
	rep(i, n) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll res = 0;
	rep(i, n) {
		int key = B[i];
		ll numA, numC;
		numA = lower_bound(A.begin(), A.end(), key) - A.begin();
		numC = n - (upper_bound(C.begin(), C.end(), key) - C.begin());
		res += numA * numC;
	}
	cout << res << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  bool ans = false;
  for(int i = 1;i <= 9;i++){
    for(int j = 1;j <= 9;j++){
      if(N == (i * j)) ans = true;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N, Y = list(map(int, input().split(sep=" ")))
left = (10 * N) - (Y // 1000)
for z in range(0, left // 9 + 1):
    y, y_rem = divmod(left - 9 * z, 5)
    if y_rem != 0:
        continue
    else:
        x = N - (y + z)
        if x >= 0:
            print(" ".join(map(str, (x, y, z))))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t AN,BN,CN;
int32_t A[200000];
int32_t B[200000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> AN >> BN >> CN;
    for (size_t i = 0; i < AN; i++)
    {
        in >> A[i];
    }
    for (size_t i = 0; i < BN; i++)
    {
        in >> B[i];
    }
    int32_t res = *std::min_element(A, A + AN) + *std::min_element(B, B + BN);

    for (size_t i = 0; i < CN; i++)
    {
        int x, y, c;
        in >> x >> y >> c; --x; --y;
        res = std::min(res, A[x] + B[y] - c);
    }
    out << res << endl;


    return 0;
}
#endif


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    a,b,x=MI()
    ans=b//x-(a-1)//x
    print(ans)

main()


Measured memory_bytes: 38384
////////////////////////////////////////////////////////////////////////////////
/////////        ////////////        ////////////        ////////////        ///
////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///
///////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ////
//////        ////////////        ////////////        ////////////        //////
/////  //////////////////  //////////////////  //////////////////  /////////////
////  //////////////////  //////////////////  //////////////////  //////////////
///  //////////////////  //////////////////  //////////////////  ///////////////
//  //////////////////  //////////////////  //////////////////  ////////////////
////////////////////////////////////////////////////////////////////////////////

a;*c;f;*i;m;n;s;u;v;w;C[42000];D[3001][3001];M[3001];
main(){
  for(c=C;++n,~scanf("%d",&w)||n%3-!(w=0);a=u,u=v,v=w,w=a)
    if(n%3<1)
      if(n<4)M[v]=M[w]=D[v][w]=D[w][v]=m=1e7;
      else{
        for(s=2;s++<6e3+2;a=u,u=v,v=w,w=a)
          u-v|v-w?
            *++c=u,*++c=s/3,*++c=fmax(v-w?:D[s/3][v]+1,M[s/3]),
            *++c=u,*++c=v,*++c=fmax(D[w][w]+1,m)
          :++f;
        for(;c>C;)
          w=*c--,v=*c--,u=*c--,
          D[u][v]>w||(D[u][v]=D[v][u]=w),M[u]>w||(M[u]=w),M[v]>w||(M[v]=w),m=m>w?m:w;
      }
  printf("%d",m+=f/6e3-1e7);
}


Measured memory_bytes: 25772
#include <stdio.h>
int main(){
	char A[3];
	scanf("%s", A);
	if(A[0]==A[1]&&A[0]!=A[2]&&A[1]!=A[2]){
		puts("Yes");
	} else if(A[0]==A[2]&&A[0]!=A[1]&&A[2]!=A[1]){
		printf("Yes");
	} else if(A[1]==A[2]&&A[1]!=A[0]&&A[2]!=A[0]){
		printf("Yes");
	} else if(A[0]==A[2]&&A[0]==A[1]&&A[1]==A[2]){
		printf("No");
	} 
	return 0;

}

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

using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll N, sum = 0;
vvl edges;
vl color, ans, cnts, sub_size;

void dfs(int v, int parent) {
    sub_size[v] = 1;
    ll prev_dfs = cnts[color[v]];
    for (auto to : edges[v]) {
        if (to == parent) continue;
        ll prev = sum - cnts[color[v]];
        dfs(to, v);
        sub_size[v] += sub_size[to];
        ll next = sum - cnts[color[v]];
        ll diff = next - prev;
        ans[color[v]] -= diff * (diff-1) / 2;
    }
    cnts[color[v]] = prev_dfs + sub_size[v];
    sum++;
}

int main() {
    cin >> N;
    edges.resize(N);
    color.resize(N);
    sub_size.resize(N);
    ans.assign(N,N*(N-1)/2);
    cnts.assign(N,0);
    rep(i,N) { scanf("%ld", &color[i]); color[i]--; }
    rep(i,N-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs(0,-1);
    rep(c,N) {
        ans[c] -= (N-cnts[c]) * (N-cnts[c]-1) / 2;
    }
    rep(i,N) ans[color[i]]++;
    rep(i,N) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 39136
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e16 + 1000, T = 150, M = 1e9 + 7, P = 6151, SQ = 1000, lg = 44;
typedef pair <int, int> pii;

int32_t main() {
	use_fast;	
	int a, b, c;
	cin >> a >> b >> c;
	c -= (a + b);
	if(c <= 0)
		return cout << "No", 0;
	ld t = c;
	t /= (ld)2;
	t = (t * t);
	a = (a * b);
	if(a < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	string s,t;
	set<string>st;
	cin >> s >> t;
	auto check = [&](int l,int r)
	{
		auto tmp = s;
		for(int i = l;i <= r;i++)
		{
			if(tmp[i] != '?' && tmp[i] != t[i - l]) return false;
		}
		return true;
	};
	auto f = [&](int l,int r)
	{
		auto ans = s;
		for(int i = l;i <= r;i++)
		{
			ans[i] = t[i - l];
		}
		for(int i = 0;i < sz(s);i++)
		{
			if(ans[i] == '?') ans[i] = 'a';
		}
		return ans;
	};
	for(int i = 0;i < sz(s);i++)
	{
		if(i + sz(t) - 1 >= sz(s)) break;
		if(check(i,i + sz(t) - 1)) st.insert(f(i,i + sz(t) - 1));
	}	
	if(!sz(st)) rc("UNRESTORABLE");
	rc(*st.begin());
}


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

int main() {
    long long n;
    cin >> n;
    long long a[n];
    long long b[n];
    long long mod=1e9+7;
    for(int i=0;i<n;i++) b[i]=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[a[i]]++;
    }
    bool flag=true;
    long long ans=1;
    if(n%2==1){
        for(int i=0;i<n;i++){
            if(b[0]!=1) flag=false;
            if(i%2==0&&i>0&&b[i]!=2) flag=false;
            if(i%2==1&&b[i]!=0) flag=false;
        }
        if(!flag) ans=0;
        else{
            for(int i=0;i<(n-1)/2;i++){
                ans=ans*2%mod;
            }
        }
    }
    else if(n%2==0){
        for(int i=0;i<n;i++){
            if(i%2==0&&b[i]!=0) flag=false;
            if(i%2==1&&b[i]!=2) flag=false;
        }
        if(!flag) ans=0;
        else{
            for(int i=0;i<n/2;i++){
                ans=ans*2%mod;
            }
        }
    }
    cout << ans%mod << endl;
}

Measured memory_bytes: 1792
n=int(input())
a=[int(_)*2 for _ in input().split()]
s=sum(a)//2
ss=sum(a[1::2])
x = [0 for _ in range(n)]
x[0] = s - ss
for i in range(1,n):
    x[i] = a[i-1] - x[i-1]
print(*x)

Measured memory_bytes: 14024
#include <cstdio>
using namespace std;
inline int abs(int x){
	return (x>0)?(x):(-x);
} 
int a[100005];
int main(){
	int i, n;
	int sum=0;
	
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%d", &a[i]);
		sum+=abs(a[i]-a[i-1]);
	}
	sum+=abs(a[n]);
	for(i=1; i<=n; i++)
		printf("%d\n", sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
	return 0;
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int n;
	cin >> n;
	int a = 0, b = 0;
	int p = 0;
	bool f = 1;
	for (int i = 0; i < n; i++) {
		int x, y,t;
		cin >> t >> x >> y;
		if (abs(x - a) + abs(y - b) > t - p)f = 0;
		//else if ((abs(x - a) + abs(y - b)) % 2 == 0 && (t - p) % 2)f = 0;
		else if (((t - p)-(abs(x - a) + abs(y - b)) ) % 2)f = 0;
		//else if ((t - p) % 2 && (t - p) != (abs(x - a) + abs(y - b)))f = 0;
		p = t; a = x, b = y;
		//cout << f;
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

sa=set()
sb=set()

for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        sb.add(b)
    if b==n:
        sa.add(a)

if sa&sb:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
        

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



int main() {
    int n, x;
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int cnt = 0;
        for (int i = 1; i <= n - 2; ++i) {
            for (int j = i + 1; j <= n - 1; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) ++ cnt;
                }
            }
        }
        cout << cnt << endl;
    } 
}



Measured memory_bytes: 3080
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 1000006;
//////////////////////////////

Int dp[N];
Int s[N];

void solve()
{
	Int n;
	cin >> n;
	dp[0] = 1; s[0] = 1;
	dp[1] = n; s[1] = n + 1;

	for (Int i = 2; i <= n; i++) {
		dp[i] = (dp[i - 1] + s[i - 3]) % MOD;
		dp[i] = ((n - 1) * (i - 2) + (n - i + 1) * n + dp[i - 1] + (i >= 3 ? s[i - 3] : 0)) % MOD;
		s[i] = (s[i - 1] + dp[i]) % MOD;
	}
	cout << dp[n] << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}

Measured memory_bytes: 19228
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 500000
#define LL long long
int n;
char s[MAXN+5];
int cnt;
LL ans;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='W')cnt++,ans+=i-cnt;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 384
from collections import Counter
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    temp_s = list(map(int, input().split()))
    s.append(temp_s)
my_count = Counter()
for i in range(D):
    for j in range(26):
        my_count[j + 1] = s[i][j]
    print(max(my_count, key=my_count.get))

Measured memory_bytes: 9772
#include <stdio.h>

int main(int argc, char const *argv[]) {
  char in;

  scanf("%c", &in );

  if((in == 'a') || (in == 'i') ||(in=='u') || (in=='e') || (in == 'o')){
    puts("vowel");
    return 0;
  }

  puts("consonant");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    int month = atoi(S.substr(5, 2).c_str());
    if(month <= 4) {
        cout << "Heisei" << endl;
        return 0;
    }
    cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;


template <class T>
T gcd(T a, T b) {
    if (a < b) {
        swap(a, b);
    }

    T r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

template <class T>
T lcm(const T& a, const T& b) {
    T n = gcd<T>(a, b);
    if (a > b) {
        return (a / n) * b;
    } else {
        return a * (b / n);
    }
}

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

    vector<long long> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }

    long long ans = T[0];
    // cout << ": " << ans << endl;
    for (int i = 1; i < N; i++) {
        ans = lcm(ans, T[i]);
        // cout << ": " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int edges[50][50];

int main(){
    int N,M;
    cin >> N >> M;
    rep(i,M) {
        int parent;
        int child;
        cin >> parent >> child;
        --parent;--child;
        edges[parent][child]++;
        edges[child][parent]++;
    }
    rep(i,N){
        int sum = 0;
        rep(j,50){
            sum += edges[i][j];
        }
        cout << sum << endl;
    }
    return 0;  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int gx=0;
  int gy=0;
  if(x==4||x==6||x==9||x==11){
    gx=1;}
  if(y==4||y==6||y==9||y==11){
    gy=1;}
if(x==2){gx=2;}
  if(y==2){gy=2;}
  
  if(gx==gy){cout<<"Yes"<<endl;}
  else if(gx!=gy){cout<<"No"<<endl;}
}


Measured memory_bytes: 3552
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int i,j,N,Q;
    long long K;
    cin >> N >> K >> Q;
    vector<long long> scr(N,0);
    vector<int> A(Q);

    for(i=0;i<Q;i++){
        cin >> A[i];
        scr[A[i]-1]++;
    }
    
    for(i=0;i<N;i++){
        if(scr[i]>Q-K || K>Q) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=105;
int n;
struct Point{
	int x,y,id;
	double ans;
	Point(){}
	Point(int _x,int _y){
		x=_x,y=_y;
	}
	friend Point operator + (Point a,Point b){
		return Point(a.x+b.x,a.y+b.y);
	}
	friend Point operator - (Point a,Point b){
		return Point(a.x-b.x,a.y-b.y);
	}
}p[N];
LL cross(Point a,Point b){
	return (LL)a.x*b.y-(LL)a.y*b.x;
}
LL cross(Point a,Point b,Point c){
	return cross(b-a,c-a);
}
LL Dot(Point a,Point b){
	return (LL)a.x*b.x+(LL)a.y*b.y;
}
LL Dis(Point a,Point b){
	return Dot(a-b,a-b);
}
bool cmp(Point a,Point b){
	LL d=cross(p[1],a,b);
	return d?d>0:Dis(p[1],a)<Dis(p[1],b);
}
bool cmpid(Point a,Point b){
	return a.id<b.id;
}
int st[N],top=0;
double ang[N];
const double Eps=1e-12;
int main(){
	n=read();
	For(i,1,n)
		p[i].x=read(),p[i].y=read(),p[i].id=i,p[i].ans=0;
	For(i,1,n)
		if (p[i].y<p[1].y)
			swap(p[i],p[1]);
		else if (p[i].y==p[1].y&&p[i].x<p[1].x)
			swap(p[i],p[1]);
	sort(p+2,p+n+1,cmp);
	st[++top]=1,st[++top]=2;
	For(i,3,n){
		while (top>1&&cross(p[st[top-1]],p[st[top]],p[i])<=0)
			top--;
		st[++top]=i;
	}
	st[top+1]=st[1];
	double pi=acos(-1.0);
	For(i,1,top)
		ang[i]=atan2(p[st[i+1]].y-p[st[i]].y,p[st[i+1]].x-p[st[i]].x);
	ang[0]=ang[top];
	For(i,1,top){
		double tmp=ang[i]-ang[i-1];
		if (tmp<0)
			tmp+=pi*2;
		p[st[i]].ans=tmp;
	}
	sort(p+1,p+n+1,cmpid);
	For(i,1,n)
		printf("%.8lf\n",p[i].ans/(pi*2));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll r = 0, g = 0, b = 0;
    rep(i,n){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ll ans = r*g*b;
    for(int i = 0; i <n; i++){
        for(int j = i+1; j < n; j++){
            if(s[i]==s[j]) continue;
            int k = j * 2 - i;
            if(k >= n || s[k] == s[i] || s[k] == s[j]) continue;
            --ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
from bisect import bisect_left
from collections import deque

n = int(input())
a = tuple(int(input()) for _ in range(n))

d = deque()

for ai in a:
    p = bisect_left(d, ai)  # aa以上の最小値のindex
    if p == 0:
        d.appendleft(ai)
    else:
        d[p - 1] = ai
ans = len(d)
print(ans)

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

namespace AtTest.ABC_137
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] kx = ReadInts();
            int k = kx[0];
            int x = kx[1];
            for(int i = x - k + 1; i <= x + k - 1; i++)
            {
                Write(i);
                if (i < x + k - 1) Write(' ');
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        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); }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,w;
    cin >> s >> w;
    if(s[0]==w[2] && s[1]==w[1] && s[2]==w[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long modPow(long long a, long long n, long long p){
    if(n == 1){
        return a % p;
    }
    
    if(n % 2 == 1){
        return (modPow(a, n - 1, p) * a) % p;
    }
    
    long long t = modPow(a, n/2, p);
    return (t * t) % p;
}
 
long long combPow(long long n, long long m, long long p){
    long long ret = 1;
    
    for(int i = 0; i < m; ++i){
        ret = (ret * (n - i)) % p;
    }
    
    return ret;
}
 
long long fact(long long a, long long p){
    if(a == 0) return 1;
    return (a * fact(a - 1, p)) % p;
}
 
int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long p = 1e09 + 7;
    long long a_fact = fact(a, p);
    long long b_fact = fact(b, p);
    
    long long x = modPow(2, n, p);
    long long y_1 = modPow(a_fact, p - 2, p);
    long long y_2 = combPow(n, a, p);
    long long y = (y_1 * y_2) % p;
    long long z_1 = modPow(b_fact, p - 2, p);
    long long z_2 = combPow(n, b, p);
    long long z = (z_1 * z_2) % p;
    
    long long res = (x - 1 - y - z) % p;
    if(res < 0) res += p;
    
    cout << res << endl;
    
    return 0;
    
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int N;
  while (cin >> N){
    bool Y = false;
    REP(i,N){
      char c;
      cin >> c;
      if(c == 'Y'){
	Y = true;
      }
    }
    if(Y) cout << "Four" << endl;
    else cout << "Three" << endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

long pow(long x, long n, long M) {
    if (n == 0) return 1;
    if (n & 1) return x * pow(x, n - 1, M) % M;
    auto y = pow(x, n / 2, M);
    return y * y % M;
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;

    long[] MOD = [999999883, 1000000093, 1000000097];
    long B = 899999929;

    auto H = new long[3];
    auto T = new long[][](3, N + 1);
    foreach (h; 0 .. 3) {
        foreach (i; 0 .. N) {
            T[h][i + 1] = (T[h][i] * B + cast(long)(s[i])) % MOD[h];
        }
    }

    long[3] hash(size_t lb, size_t ub) {
        long[3] ret;
        foreach (i; 0 .. 3) {
            ret[i] = (MOD[i] + T[i][ub] - (B.pow(ub - lb, MOD[i]) * T[i][lb] % MOD[i])) % MOD[i];
        }
        return ret;
    }

    int L, R;
    bool[long[3]] set;
    foreach (m; 0 .. M) {
        auto q = readln.chomp;
        if (q[0] == 'L') {
            if (q[1] == '+') {
                L++;
            } else {
                L--;
            }
        } else { assert(q[0] == 'R');
            if (q[1] == '+') {
                R++;
            } else {
                R--;
            }
        }
        //writeln([L, R], hash(L, R + 1));
        set[hash(L, R + 1)] = true;
    }
    writeln(set.length);
}

Measured memory_bytes: 30476
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main()
{
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++) cin >> arr[i];
  bool dp[k+1];
  memset(dp, false, sizeof(dp));
  for(int i = 1; i < k + 1; i++)
  {
    for(int j = 0; j < n; j++)
    {
      if(i == arr[j]){dp[i] = true; break;}
      //if(j == 1) cout << i << arr[j]<<endl;
      if((i - arr[j] >= 0) && (dp[i - arr[j]] == false)){dp[i] = true; break;}
    }
  }
  //for(int i = 0; i < k+1; i++) cout << dp[i] << endl;
  if(dp[k]) cout << "First";
  else cout << "Second";
}

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

template<class T>
T input()
{
	T val;
	std::cin >> val;
	return val;
}

int main()
{
	std::vector<int> x, y;

	while (true)
	{
		int val1 = input<int>(), val2 = input<int>();
		if (val1 == 0 && val2 == 0)break;
		if (val1 > val2)
		{
			int buf = val2;
			val2 = val1;
			val1 = buf;
		}
		x.push_back(val1), y.push_back(val2);

	}

	for (int i = 0; i < x.size(); ++i)
		std::cout << x[i] << " " << y[i] << std::endl;

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int a[214514],b[214514];
    cin >> N;
    REP(i,N){
        cin >> a[i];
    }
    REP(i,N){
        cin >> b[i];
    }
    int Ans=0;
    RREP(k,30){
        REP(i,N)a[i]%=(2ll<<k);
        REP(i,N)b[i]%=(2ll<<k);
        sort(a,a+N);
        sort(b,b+N);
        ll sum=0;
        ll T=1<<k;
        REP(i,N){
            if(a[i]>=T){
                sum+=lower_bound(b,b+N,2*T-a[i])-b+N;
                sum-=lower_bound(b,b+N,3*T-a[i])-b;
            }else{
                sum+=lower_bound(b,b+N,2*T-a[i])-b;
                sum-=lower_bound(b,b+N,T-a[i])-b;
            }
        }
        //cout << sum << Endl;
        if(sum%2==1){
            Ans+=T;
        }
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 3456