akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bitset>


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code
map<ll, ll> mp;
int main()
{
	int n;
	cin>>n;
	ll k;
	cin>>k;
	vector<ll> v;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		x--;
		v.pb(x);
	}
	vector<ll> s(n+1, 0);
	rep(i, 0, n)
	{
		s[i+1] = (s[i] + v[i])%k;
	}
	rep(i, 0, min(k, (ll)n+1))
	{
		mp[s[i]]++;
	}
	ll ans = 0;
	rep(i, 0, n+1)
	{
		mp[s[i]]--;
		ans += mp[s[i]];
		if(i+k <= n) mp[s[i+k]]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 15856
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;

	cin >> S >> T;

	cout << T << S << endl;

	Never To return 0;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define gcd __gcd
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int)(1e9+7);


void _(){
    ll n,m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll g = gcd(n, m);
    for (ll i = 0; i <  g; ++i) {
        char c1 = s[i*n/g], c2 =t[i*m/g];
        if(c1 != c2){
            cout << -1;return;
        }
    }
    cout << n*m/gcd(n,m);

}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}





Measured memory_bytes: 640
using System;

namespace ABC146
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string t = Console.ReadLine();
            
            if (t == "SUN")
                Console.WriteLine(7);
            else if (t == "MON")
                Console.WriteLine(6);
            else if (t == "TUE")
                Console.WriteLine(5);
            else if (t == "WED")
                Console.WriteLine(4);
            else if (t == "THU")
                Console.WriteLine(3);
            else if (t == "FRI")
                Console.WriteLine(2);
            else if (t == "SAT")
                Console.WriteLine(1);
            Console.ReadKey();






        }
    }
}


Measured memory_bytes: 11092
fun main(args: Array<String>) {
    val input = readLine()!!

    if (input == "A"){
        print('T')
        return
    }
    if (input == "T"){
        print('A')
        return
    }
    if (input == "G"){
        print('C')
        return
    }
    if (input == "C"){
        print('G')
        return
    }
}

Measured memory_bytes: 29940
#include<stdio.h>
int main(void)
{
int a,b,c,w,z;
scanf("%d %d %d",&a,&b,&c);
if ((a < c && c < b) || (a > c && c > b))
{
    printf("Yes");
}
else
{
    printf("No");
}
return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
N = int(input())

if(N*100 % 108 == 0):
  Xmin = int(N*100/108)
else:
  Xmin = int(N*100/108)+1

if((N+1)*100 % 108 == 0):
  Xmax = int((N+1)*100/108)-1
else:
  Xmax = int((N+1)*100/108)

if(Xmax >= Xmin):
  print(Xmin)
else:
  print(':(')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

ll C2(ll n)
{
	return n*(n-1)/2;
}

vector<vector<int>> part(2);

void dfs(vector<vector<int>> &g, int u, int v, int par)
{
	part[par].pb(u);
	for (auto x : g[u])
	{
		if (x == v) continue;
		dfs(g, x, u, par^1);
	}
}

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

	int n; cin >> n;
	vector<vector<int>> g(n);
	for (int i = 0; i < n-1; ++i)
	{
		int u, v; cin >> u >> v;
		g[--u].pb(--v);
		g[v].pb(u);
	}
	ll zero = n/3, one = (n+2)/3;
	ll two = n - zero - one;
	dfs(g, 0, 0, 0);
	if (part[0].size() < part[1].size()) swap(part[0], part[1]);
	vector<int> final(n, 0);
	if (part[1].size() < two)
	{
		if (part[0].size() < one + two) {cout << -1; return 0;}
		int ct = 0;
		for (auto u : part[0])
		{
			if (ct < one) final[u] = 1;
			else if (ct < one + two) final[u] = 2;
			++ct;
		}
	}
	else
	{
		int ct = 0;
		for (auto u : part[0])
		{
			if (ct < one) final[u] = 1;
			++ct;
		}
		ct = 0;
		for (auto u : part[1])
		{
			if (ct < two) final[u] = 2;
			++ct;
		}
	}
	int next[3] = {3, 1, 2};
	for (int i = 0; i < n; ++i)
	{
		cout << next[final[i]] << ' ';
		next[final[i]] += 3;
	}
}

// Have ax0, bx1, cx2
// At most C(a, 2) + ab + ac + bc

Measured memory_bytes: 20596
n , m = map(int, input().split())
p = list(map(int,input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


uf = UnionFind(n)

for i in range(m):
    x , y = map(int, input().split())
    x-=1
    y-=1
    uf.union(x,y)
ans = 0
for i in range(n):
    if uf.same(i,p[i]-1):
        ans+=1
print(ans)


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

int main()
{
	string s, a;

	cin >> s;

	for(int i = 0; i < s.size(); i++){
		if (s[i] == 'B'){
			if (!a.empty()) {
				a.erase(a.begin() + a.size() - 1);
			}
		}
		else a += s[i];
	}
	cout << a << endl;
	return (0);
}


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

using namespace std;

int main(){
    string mark = "SHCD";
    bool card[4][13] = { 0 };
    int n;
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
        char c;
        int t;
        
        scanf(" %c %d", &c, &t);
        
        card[mark.find(c)][t - 1] = true;
    }
    
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 13; ++j){
            if(!card[i][j]){
                printf("%c %d\n", mark[i], j + 1);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2760
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector< vector<int> > A(2, vector<int>(N+1));
    for(int i=0; i<2; i++) {
        for(int j=1; j<=N; j++) {
            cin>> A[i][j];
        }
        partial_sum(A[i].begin(), A[i].end(), A[i].begin());
    }

    int ans = 0;
    for(int j=1; j<=N; j++) {
        ans = max(ans, A[0][j] + A[1][N] - A[1][j-1]);
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int n, sum;
   scanf("%d", &n);
   while ( n ) {
       n = 1000 - n;
       sum = n / 500;
       n = n % 500;
       sum +=  n / 100;
       n = n % 100;
       sum += n / 50;
       n = n % 50;
       sum += n / 10;
       n = n % 10;
       sum += n / 5;
       n = n % 5;
       sum += n;
       printf("%d\n", sum);
       scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1748
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,k,t=100; cin>>n>>k; 
    int r=n%k;
    if (r==0) cout << 0 << endl; 
    else cout << min(r,k-r) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612
import math


k = int(input())

ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        ab_gcd = math.gcd(a, b)
        for c in range(1, k + 1):
            ans += math.gcd(ab_gcd, c)

print(ans)

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
typedef pair<int,int> P;

int main() {
    int N,M,a,b,r=0;
    cin >> N >> M;
    Graph G(N);
    vector<P> p(M);

    rep(i,M) {
        cin >> a >> b;
        a--, b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
        p.at(i) = P(a,b);
    }

    rep(i,M) {
        int c=0;
        queue<int> q;
        vector<bool> seen(N,0);
        q.push(0);

        while(!q.empty()) {
            int v = q.front();
            q.pop();
            seen.at(v) = 1;

            for(int nv : G.at(v)) {
                if((v==p.at(i).first && nv==p.at(i).second) || (v==p.at(i).second && nv==p.at(i).first))
                    continue;
                if(seen.at(nv))
                    continue;
                q.push(nv);
            }
        }

        rep(i,N)
            if(seen.at(i))
                c++;
        if(c != N)
            r++;
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
  vector<string>a(7);
  a[0] = "SUN";
  a[1] = "MON";
  a[2] = "TUE";
  a[3] = "WED";
  a[4] = "THU";
  a[5] = "FRI";
  a[6] = "SAT";
  
  string s;
  cin >> s;
  
  for(int i=0;i<7;i++){
    if(s == a[i]) cout << 7 - i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

ll powmod(ll x, ll n) {
    ll res = 1;
    if (n > 0) {
        res = powmod(x, n / 2);
        if (n % 2 == 0) {
            res = (res * res) % MOD;
        } else {
            res = (((res * res) % MOD) * x) % MOD;
        }
    }

    return res;
}

int main() {
    int n, m; cin >> n >> m;
    ll ans = 1;
    if (n == m) {
        while (n > 0) {
            ans *= n;
            ans %= MOD;
            n--;
        }
        ans = powmod(ans, 2);
        ans *= 2;
        ans %= MOD;
    } else if (abs(n - m) == 1) {
        while (n > 0) {
            ans *= n;
            ans %= MOD;
            n--;
        }
        while (m > 0) {
            ans *= m;
            ans %= MOD;
            m--;
        }
    } else {
        ans = 0;
    }

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

Measured memory_bytes: 3628
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        h: [usize; n],
    }
    let mut max = 0;
    let mut current = 0;
    for i in 1..n {
        if h[i - 1] < h[i] {
            if current > max {
                max = current;
            }
            current = 0;
        } else {
            current += 1;
        }
    }
    if current > max {
        max = current;
    }
    println!("{}", max);
}


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count = 1;
  for(int i=0;i<N-1;i++){
    if(S.at(i)!=S.at(i+1))count++;
  }
  cout<<count<<endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 x(n);
  cin >> x;
  auto sx = x;
  sort(all(sx));
  rep(i, n) {
    if (x[i] <= sx[n / 2 - 1]) {
      cout << sx[n / 2] << endl;
    } else {
      cout << sx[n / 2 - 1] << endl;
    }
  }
}


Measured memory_bytes: 3712
import sys
sys.setrecursionlimit(200000)

n,m,*l=map(int,open(0).read().split())
graph=[[]*n for _ in range(n)]
unvis=[True]*n

def dfs(x):
	for y in graph[x]:
		if unvis[y]:
			unvis[y]=False
			dfs(y)
			
for i,j in zip(l[::3],l[1::3]):
	graph[i-1].append(j-1)
	graph[j-1].append(i-1)

ans=0
for x in range(n):
	if unvis[x]:
		unvis[x]=False
		dfs(x)
		ans+=1
print(ans)


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int count = 0;
    REP(i,3001){
        REP(j,3001){
            if(r*i+g*j>n)break;
            else if((n-r*i-g*j)%b==0)count++;
        }
    }
    COUT(count);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int lank,n,i,j,all[4];
for(i=0;i<4;i++){
    scanf("%d %d",&lank,&n);
    if(lank==1)all[i]=n*6000;
    else if(lank==2)all[i]=n*4000;
    else if(lank==3)all[i]=n*3000;
    else all[i]=n*2000;
}
for(j=0;j<4;j++){
    printf("%d\n",all[j]);
}

return 0;
}

Measured memory_bytes: 600
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    tmd = collections.defaultdict(list)
    n = int(readline())
    start = -1
    cql = collections.defaultdict(int)
    for i in range(n-1):
        tma, tmb, tmc = list(map(int, input().rstrip('\n').split()))
        tmd[tma-1] += [tmb-1]
        cql[tma-1, tmb-1] = tmc
        tmd[tmb-1] += [tma-1]
        cql[tmb-1, tma-1] = tmc
        if start == -1:
            start = tma - 1

    ql = [[0, start]]
    ql = collections.deque(ql)
    fq = collections.defaultdict(int)
    fq[start]
    while True:
        if len(ql) != 0:
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq:
                    ql.append([cost + cql[tmv, tmp], tmv])
                    fq[tmv] = (cost + cql[tmv, tmp]) % 2
        else:
            break
    for i in range(n):
        print(fq[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 123296
import collections
a1,b1 = list(map(int,input().split()))
a2,b2 = list(map(int,input().split()))
a3,b3 = list(map(int,input().split()))
dd = collections.defaultdict(int)
dd[a1] += 1
dd[a2] += 1
dd[a3] += 1
dd[b1] += 1
dd[b2] += 1
dd[b3] += 1
for i in dd.values():
    if i > 2:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 3956
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    
    bool ok = true;
    stack<char> stk;
    for(int i=0; i<n; ++i){
        if(s[i] == 'w'){
            if(stk.size() < 2 || (stk.size() < 3 && i != n-1)){
                ok = false;
            }else{
                char c2 = stk.top();
                stk.pop();
                char c1 = stk.top();
                stk.pop();
                if(c1 != 'm' || c2 != 'e')
                    ok = false;
            }
        }else{
            stk.push(s[i]);
        }
    }

    if(ok && stk.size() == 0)
        cout << "Cat" << endl;
    else
        cout << "Rabbit" << endl;

    return 0;
}

Measured memory_bytes: 1188
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B,C = map(int, read().split())
print('Yes' if A<=C<=B else 'No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

inline ll add(ll a, ll b)
{
	return a + b;
}

inline ll sub(ll a, ll b)
{
	return a - b;
}

ll dp[405][405];
int ar[405];
ll sm[405];

ll get(int a, int b)
{
	return sub(sm[b + 1], sm[a]);
}

int main()
{

	int n, L, R;
	scanf("%d", &n);

	ll x;

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

	for (int sz = 2; sz <= n; ++sz)
	{

		L = 0;
		R = L + sz - 1;

		while (R < n)
		{

			dp[L][R] = 1e13;
			// cout << L << "," << R << ": ";
			for (int p = L; p <= R - 1; ++p)
			{
				x = add(dp[L][p], dp[p + 1][R]);
				dp[L][R] = min(dp[L][R],
				               add(x, get(L, R)));
				// cout << add(x, get(L, R)) << " ";
			}

			L++;
			R++;
			// cout << endl;
		}
		// cout << endl;

	}


	cout << dp[0][n - 1];




	return 0;
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A):
    return 'bust' if sum(A) > 21 else 'win'


def main():
    A = read_int_n()
    print(slv(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7992
using System;

namespace AtCoderABC134B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int D = int.Parse(s[1]) * 2 + 1;

            ans = N / D;

            if (N % D != 0)
                ans++;

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 11092
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int n;cin >> n;
    string s,t;cin >> s >> t;
    for(int i = 0;i < n;i++)cout << s[i] << t[i];
    cout << endl;
}


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

using namespace std;

int main()
{
  int T1,T2,R1,R2;
  int win;
  cin>>T1>>T2>>R1>>R2;

  if(R1 == R2){
    win = 2;
  }
  else if(R1 == -1 || R2 == -1){
    if(T1 < T2){
      win = 0;
    }
    else if(T1 > T2){
      win = 1;
    }
    else{
      win = 2;
    }
  }
  else{
    if(R1 > R2){
      win = 0;
    }
    else{
      win = 1;
    }
  }

  if(win == 0){
    cout<<"Alice"<<endl;
  }
  else if(win == 1){
    cout<<"Bob"<<endl;
  }
  else{
    cout<<"Draw"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;long long n,s,sum,g,i,A,B,C;main(){cin>>n>>s;if(n==s){cout<<n+1<<endl;goto E;}for(i=2;i<=min(n+1,3000000LL);i++){sum=0;g=1;while(g<=1LL<<37){sum+=(n/g)%i;g*=i;}if(sum==s){cout<<i<<endl;goto E;}}for(i=min(s,n/1000000);i>=1;i--){A=i,B=s-i;if((n-B)%A!=0)continue;C=(n-B)/A;if(C<=B||C<=1)continue;cout<<C<<endl;goto E;}cout<<"-1"<<endl;E:;}

Measured memory_bytes: 256
def partition(A,p,r):
    x = A[r][1]
    i = p - 1
    for j in range(p,r):
      if A[j][1] <= x:
          i += 1
          A[i],A[j] = A[j], A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def quicksort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quicksort(A,p,q-1)
        quicksort(A,q+1,r)

class checkstable:
    def __init__(self):
        self.d = {}
    def storecards(self,A):
        for i in range(len(A)):
            if A[i][1] in self.d:
                self.d[A[i][1]].append(A[i][0])
            else:
                 self.d[A[i][1]] = [(A[i][0])]

    def isstable(self,A):
        for i in range(len(A)):
            if self.d[A[i][1]].pop(0) != A[i][0]:
                      return "Not stable"
        return "Stable"

n = int(input())
A = []
for _ in range(n):
   mark,num = input().split()
   num = int(num)
   A.append([mark,num])
quick = checkstable()
quick.storecards(A)

quicksort(A,0,n - 1)
stable = quick.isstable(A)
print(stable)
for i in range(n):
   print(*A[i])



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

int main()
{
	long long N,a,b,i,m;
	while(cin>>N)
	{
		a=N;
		b=1;
		m=a+b;
		for(i=sqrt(N);i>=1;i--)
		{
			if(N%i==0){
				N=N/i;
				a=a/i;
				b=b*i;
				if(a+b<m){
					m=a+b;
				}
			
			}
		}
		cout<<m-2<<endl;
	}
}

Measured memory_bytes: 384
import math
a,b,h,m=map(int, input().split())

ji=(h*60+m)/2
hun=6*m
theta=min(abs(ji-hun),360-abs(ji-hun))
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(theta)))
print(c)

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> data ={{0,0},{w,h}};
  for(int i=0;i<n;i++){
    int a,x,y;
    cin >> x >> y >> a;
    if(a==1&&data.at(0).at(0)<x){
      data.at(0).at(0)=x;
    }
    if(a==2&&data.at(1).at(0)>x){
      data.at(1).at(0)=x;
    }
    if(a==3&&data.at(0).at(1)<y){
      data.at(0).at(1)=y;
    }
    if(a==4&&data.at(1).at(1)>y){
      data.at(1).at(1)=y;
    }
  }
  int S;
  int x_min,x_max,y_min,y_max;
  x_min=data.at(0).at(0);
  x_max=data.at(1).at(0);
  y_min=data.at(0).at(1);
  y_max=data.at(1).at(1);
  if(x_max-x_min<0||y_max-y_min<0){
    S=0;
  }
  else{
    S=(x_max-x_min)*(y_max-y_min);
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<int>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int x,y;
int ct1,ct2;
struct edge{ll to;}; //edgeパラメータ
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> parent;
  vector<ll> depth; // d[ノード] ノードの深さ

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    parent.resize(N); //Node情報,親
    depth.resize(N); //Node情報,深さ
    rep(i,N){depth[i]= -1; parent[i]= -1;}
  }
  void add_edge(ll s, ll t){
    G[s].emplace_back((edge){t});
  }

  void dfs(ll v=0, ll p=0, ll d=0){
    parent[v] = p;
    depth[v] = d;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p) dfs(E.to , v , d+1); //まだ行ってないなら
    }
  }
  void dfs1(ll v=0, ll p=0, ll d=0){
    if(v==0) rep(i,N){parent[i] = -1;}
    parent[v] = p;
    depth[v] = d;
    //cout<< 1<< " "<<v<<"\n";
    ct1++;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p and E.to !=x) dfs1(E.to , v , d+1); //まだ行ってないなら
    }
  }
  void dfs2(ll v, ll p, ll d=0){
    if(v==N-1) rep(i,N){parent[i] = -1;}
    parent[v] = p;
    depth[v] = d;
    //cout<< 2<< " "<<v<<"\n";
    ct2++;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p and E.to !=y) dfs2(E.to , v , d+1); //まだ行ってないなら
    }
  }
};


void Main(){

  int N;
  cin>>N;

  graph g(N);
  graph g2(N);

  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    g.add_edge(a-1,b-1);
    g.add_edge(b-1,a-1);
    g2.add_edge(a-1,b-1);
    g2.add_edge(b-1,a-1);
  }

  g.dfs();
  g2.dfs(N-1);

  rep(i,N){
    if(g.depth[i]<=g2.depth[i])ct1++;
    else ct2++;
  }

  /*

  int v=N-1;

  //cout<<g.depth[N-1] <<"\n";

  rep(i,(g.depth[N-1]-1)/2){
    v=g.parent[v];
  }
  x=v;
  y=g.parent[v];

  if(g.depth[N-1]%2==0) ct2++;

  g.dfs1();
  g.dfs2(N-1,N-1);

  //cout<< x<<"\n";
  //cout<< y<<"\n";

  //cout<< ct1<<"\n";
  //cout<< ct2<<"\n";

  */

  cout<< ( ct1>ct2 ? "Fennec" : "Snuke" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 17920
# -*- coding: utf-8 -*-
import collections
# factrize
def factorize(target_number):
    factor = 2
    factor_list = []
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor += 1
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

N = int(input())

fact_list = factorize(N)

fact_counter_dict = collections.Counter(fact_list)
ans = 0
for fact, freq in fact_counter_dict.items():
    freq_copy = freq
    for i in range(1, freq + 1):
        freq_copy -= i
        if freq_copy < 0:
            break
        ans += 1
print(ans)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define endl '\n'
#define N 1000001
//#define mod 1e9+7
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll dp[1001][1001];
char ch[1001][1001];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll h,w;
	cin>>h>>w;
	for(ll i=0;i<h;i++){
	    for(ll j=0;j<w;j++){
	        cin>>ch[i][j];
	       // cout<<ch[i][j];
	    }
	    //cout<<endl;
	}
	dp[0][0]=1;
	for(ll i=0;i<h;i++){
	    for(ll j=0;j<w;j++){
	        if(ch[i][j]=='#')continue;
	        if(i-1>=0)dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
	        if(j-1>=0)dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
	    }
	}
	cout<<dp[h-1][w-1];
	return 0;
}


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

int sx, sy;
int tx, ty;

int main(void) {
    // Here your code !
    scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

    int x = sx;
    int y = sy;

    while (x < tx) {
      x += 1;
      printf("R");
    }

    while (y < ty) {
      y += 1;
      printf("U");
    }

    while (sx < x) {
      x -= 1;
      printf("L");
    }

    while (sy < y) {
      y -= 1;
      printf("D");
    }

    y -= 1;
    printf("D");

    while (x < tx + 1) {
      x += 1;
      printf("R");
    }

    while (y < ty) {
      y += 1;
      printf("U");
    }

    x -= 1;
    printf("L");

    y += 1;
    printf("U");

    while (sx - 1 < x) {
      x -= 1;
      printf("L");
    }

    while (sy < y) {
      y -= 1;
      printf("D");
    }

    x += 1;
    printf("R");

    printf("\n");

    return 0;
}

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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ld r;
        cin >> r;

        ld area=3.1415926*r*2;
        cout << area << endl;
    }
}



Measured memory_bytes: 3852
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

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

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        n: usize,
    }

    let mut i = 1;
    let mut ans = 1;
    while i*i <= n {
        ans = i*i;
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N=int(input())
A=list(map(int,input().split()))
 
flg=1
count=0
while True:
    for i in A: #全て偶数か確かめる
        if i%2==1:
            flg=0
            break

    if flg==1:
        for i in range(N):
            A[i]=A[i]//2
        count+=1
    else:
        break
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

std::vector<std::pair<long long,long long>> convex_hull(std::vector<std::pair<long long,long long>> P){
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    if(P.size()<=2){
        return P;
    }
    std::vector<std::pair<long long,long long>> H,L,R;
    sort(P.begin(),P.end());
    
    //下半分
    for(int i=0;i<P.size();i++){
        int j=L.size();
        while(j>=2 && (L[j-1].first-L[j-2].first)*(P[i].second-L[j-2].second)<=(L[j-1].second-L[j-2].second)*(P[i].first-L[j-2].first)){
            L.pop_back();
            j--;
        }
        L.push_back(P[i]);
    }
    
    //上半分
    for(int i=P.size()-1;i>=0;i--){
        int j=H.size();
        while(j>=2 && (H[j-1].first-H[j-2].first)*(P[i].second-H[j-2].second)<=(H[j-1].second-H[j-2].second)*(P[i].first-H[j-2].first)){
            H.pop_back();
            j--;
        }
        H.push_back(P[i]);
    }
    
    
    R=L;
    for(int i=1;i<H.size()-1;i++){
        R.push_back(H[i]);
    }
    
    return R;
}

ll dist(pair<ll,ll> G,pair<ll,ll> H){
    return abs(G.first-H.first)+abs(G.second-H.second);
}

int main(void){
    
    ll N,x,y;
    vector<pair<ll,ll>> K,XY,C;
    
    cin >> N;
    REP(i,N){
        cin >> x >> y;
        K.push_back({x,y});
    }
    sort(K.begin(),K.end());
    REP(i,N){
        if(i==0 || K[i]!=K[i-1]){
            XY.push_back(K[i]);
        }
    }
    
    C = convex_hull(XY);
    
    /*REP(i,C.size()){
        cout << C[i].first MM C[i].second << endl;
    }*/
    
    if(C.size()==1){
        cout << 0 << endl;
        return 0;
    }
    if(C.size()==2){
        cout << abs(C[0].first-C[1].first)+abs(C[0].second-C[1].second) << endl;
        return 0;
    }
    
    ll M=C.size();
    ll Ans=0;
    ll i=0,j=0;
    while(i<M){
        //cout << i MM j MM dist(C[i],C[j%M]) << endl;
        Ans=max(Ans,dist(C[i],C[(j)%M]));
        if(dist(C[i],C[j%M])<=dist(C[i],C[(j+1)%M])){
            Ans=max(Ans,dist(C[i],C[(j+1)%M]));
            j++;
        }else{
            Ans=max(Ans,dist(C[(i+1)%M],C[j%M]));
            i++;
            if(j<i)j=i;
        }
    }
    
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 12616
from collections import deque
def bfs(s):
    visited[s]=1
    q=deque([s])
    while len(q)!=0:
        p=q.popleft()
        for i in fr[p]:
            if visited[i]==0:
                visited[i]=1
                q.append(i)
                d[i]=d[p]+1

while 1:
    n=input()
    m=int(raw_input())
    if n==m==0:break
    fr=[[]*n for _ in xrange(n)]
    d=[0]*n
    visited=[0]*n
    for i in  xrange(m):
        a,b=map(int,raw_input().split())
        a-=1
        b-=1
        fr[a].append(b)
        fr[b].append(a)
    bfs(0)
    cnt=0
    for i in xrange(n):
        if 1<=d[i]<=2:
            cnt+=1
    print(cnt)

Measured memory_bytes: 7200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = (int)2e9;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;

#define MAX_N 100 + 2

void exec(){
  ll x, y;
  cin >> x >> y;

  cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();

      Map<Character, List<Integer>> freqMap = new HashMap<>();
      freqMap.put('R', new ArrayList<>());
      freqMap.put('G', new ArrayList<>());
      freqMap.put('B', new ArrayList<>());

      for(int i = 0; i < n; i++) {
        freqMap.get(s.charAt(i)).add(i);
      }
      long sum = (long)freqMap.get('R').size() * (long)freqMap.get('G').size() * (long)freqMap.get('B').size();

      for(int i = 0; i < n; i++) {
        char leftChar = s.charAt(i);
        for(int j = i + 1; j < n; j++) {
          char midChar = s.charAt(j);
          if(leftChar == midChar) continue;
          int k = j * 2 - i;
          if(k >= n) continue;
          char rightChar = s.charAt(k);
          if(rightChar != midChar && rightChar != leftChar)
            sum--;
        }
      }
      System.out.println(sum);
  }
}

Measured memory_bytes: 37568
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getval(N);
	
	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		getval(ai[i]);
	}

	LLONG ans = 0;
	while (1) {
		std::sort(ai.begin(), ai.end(), std::greater<LLONG>());

		if (ai[0] < N) break;

		LLONG diff = ai[0] - (N - 1);
		LLONG prCount = diff / N + ((diff % N) ? 1 : 0);

		ai[0] -= N * prCount;
		for (int i = 1; i < N; i++) {
			ai[i] += prCount;
		}
		ans += prCount;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x, y,z,w,h, sum= 1, ans = 0;
ll enum_div(ll n) {
    vector<int> ret;
    ll cnt = 0;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0 && n % (n / i - 1) == i) {
            cnt += n / i - 1;
        }
    }
    return cnt;
}
int main() {
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << enum_div(n) << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	F = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
	K = II()
	print(F[K-1])

if __name__ == '__main__':
	main()

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

int main(){
  int a,b,c,k,ans=0,t;
  cin >> a >> b >> c >> k;

  if(k>a){
    rep(i,a){
      ans++;
    }
    if(k-a<b){
      cout << ans << endl;
    }else{
      t=k-a-b;
      rep(i,t) ans--;
      cout << ans << endl;
    }
  }else{
    rep(i,k){
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,m[101],sum=0,min=1001;
	scanf("%d %d",&n,&x);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&m[i]);
		x-=m[i];
		sum++;
		if(m[i]<min)
			min=m[i];
	}
	sum+=x/min;
	printf("%d",sum);
	return 0;
}

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

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

int n;
int cnt[30];

int main(void){
	while(1){
		scanf("%d%*c",&n);
		if(n==0)break;
		memset(cnt,0,sizeof(cnt));
		int res=n;
		int winner=-1;
		for(int i=0;i<n;i++){
			char c;
			scanf("%c%*c",&c);
			cnt[c-'A']++;
			int rest=n-i-1;
			for(int j=0;j<=26;j++){
				bool flag=true;
				for(int k=0;k<=26;k++){
					if(j==k)continue;
					if(cnt[j]<=cnt[k]+rest)flag=false;
				}
				if(flag){
					if(winner==-1){
						winner=j;
						res=i;
					}
				}
			}
		}
		if(res==n)printf("TIE\n");
		else{
			printf("%c %d\n",('A'+winner),res+1);
		}
	}
	return 0;
}

Measured memory_bytes: 3140