akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

ll n, a, b;
int solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  if(n+1< a+b || n > a*b) return -1;
  std::vector<ll> vec;
  ll s = n-a;
  ll cur = n;
  rep(i,a){
    ll num = min(b-1,s) + 1;
    s -= num -1;
    rep(j,num) vec.pb(cur-num+1+j);
    cur -= num;
  }
  reverse(all(vec));
  rep(i,n-1) cout<<vec[i]<<" ";
  cout<<vec[n-1]<<endl;
  return 0;
}
int main(){
  if(solve() == -1) cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 6512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    VS a(h); REP(i,h) cin >> a[i];
    REP(i,w+2) cout << '#'; cout << endl;
    REP(i,h){cout << '#'; cout << a[i]; cout << '#'; cout << endl;}
    REP(i,w+2) cout << '#'; cout << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
red = []
for _ in range(n):
    red.append(na())
blue = []
for _ in range(n):
    blue.append(na())

red.sort()
blue.sort()
ans = 0

tmp = []
for i in blue:
    for j in red:
        if i[0] > j[0] and i[1] > j[1]:
            tmp.append(j)
    if tmp != []:
        max_red = max(tmp, key=lambda x:x[1])
        ans += 1
        red.remove(max_red)
        tmp = []
    else:
        pass

print(ans)


Measured memory_bytes: 3064
#include <iostream>

int main() {
	int a, b, c = 0;
	std::cin >> a >> b >> c;

	int ink = 0;

	if (a==b && a==c && b==c) {
		ink = 1;
	}
	else if (a!=b && b!=c && a!=c) {
		ink = 3;
	}
	else {
		ink = 2;
	}

	std::cout << ink << std::endl;
	system("pause");
}

Measured memory_bytes: 504
s = input()
n = len(s)
is_ok = True

for i in range(n):
    if s[i] != s[n-1-i]:
        is_ok = False

end = (n-1)//2
for i in range(end):
    if s[i] != s[end-1-i]:
        is_ok = False

sta = (n+3)//2
for i in range(sta,n):
    if s[i] != s[n-1-i]:
        is_ok = False

if is_ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int ans = 0;
    FOR(b, 1, 31)FOR(p, 2, 9) {
        if((int)pow(b, p) <= x) ans = max(ans, (int)pow(b, p));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//C
#include<bits/stdc++.h>
#define se second
#define fi first
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N;
	scanf("%d", &N);
	LL bef = 0, ans = 0;
	for (int i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		ans += (bef * x) % MOD;
		ans %= MOD;
		bef += x;
		bef %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3760
import java.io.*;
import java.util.*;

public class Main{

    static final int N=8;
    static int n;
    static int row[]=new int[N];
    static int col[]=new int[N];

    static int dpos[]=new int[2*N-1];
    static int dneg[]=new int[2*N-1];

    static boolean X[][]=new boolean[N][N];

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


	for(int i=0;i<N;i++){
	    row[i]=-1;
	    col[i]=-1;
	    for(int j=0;j<N;j++){
		X[i][j]=false;
	    }
	}

	for(int i=0;i<2*N-1;i++){
	    dpos[i]=-1;
	    dneg[i]=-1;
	}
	
	n=Integer.parseInt(br.readLine());

	for(int i=0;i<n;i++){
	    String str[]=br.readLine().split(" ");

	    int r=Integer.parseInt(str[0]);
	    int c=Integer.parseInt(str[1]);

	    X[r][c]=true;
	}
	solve(0);
    }
    static void solve(int i){
	if(i==N){
	    print();
	}else{
	    for(int j=0;j<N;j++){
		if( (col[j]==1) || (dpos[i+j]==1) || (dneg[i-j+N-1]==1) ){
		    continue;
		}
		row[i]=j;
		col[j]=dpos[i+j]=dneg[i-j+N-1]=1;
		solve(i+1);
		row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=-1;
	    }
	}
    }
    static void print(){
	for(int i=0;i<N;i++){
	    for(int j=0;j<N;j++){
		if(X[i][j]){
		    if(row[i]!=j)
			return;
		}
	    }
	}
	for(int i=0;i<N;i++){
	    for(int j=0;j<N;j++){
		if(row[i]==j)
		    System.out.print("Q");
		else
		    System.out.print(".");
	    }
	    System.out.println();
	}
    }
}



Measured memory_bytes: 24376
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
	sc.Scan()
	return sc.Text()

}

func main() {
	n, _ := strconv.Atoi(readLine())
	b := 0

	aStr := strings.Split(readLine(), " ")
	bStr := strings.Split(readLine(), " ")
	cStr := strings.Split(readLine(), " ")

	tmp := -1
	for i := 0; i < n; i++ {
		aNum, _ := strconv.Atoi(aStr[i])
		bNum, _ := strconv.Atoi(bStr[i])
		if aNum-tmp == 1 {
			if tmp > 0 {
				tmp--
			}
			cNum, _ := strconv.Atoi(cStr[tmp])
			b += cNum
		}
		b += bNum
		tmp = aNum
	}

	fmt.Println(b)
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  int a,b,c;
  char comma;

  int cx = 0;
  int cy = 0;

  loop {
    cin >> a >> comma >> b >> comma >> c;
    if (!cin) break;
    if (a * a + b * b == c * c) ++cx;
    if (a == b) ++cy;
  }
  cout << cx << endl;
  cout << cy << endl;

  return 0;
}

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


def main():
    S = input().rstrip()

    ans = "AC"
    if not S[0] == "A":
        ans = "WA"
    if not S[2:-1].count("C") == 1:
        ans = "WA"
    else:
        count = 0
        for s in S:
            if s.isupper():
                count += 1
        if count != 2:
            ans = "WA"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   ll n;
   cin>>n;
    ll ans=0;
    if(n%2==0){
        ll k=5;
        while(k*2<=n){
            ans+=(n/k)/2;
            k*=5;
        }
    }
    OUT(ans);
    return 0;
}

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

string restore(string s, string t)
{
    for (int i = s.size() - t.size(); i >= 0; i--)
    {
        size_t j = 0;
        size_t k = i;
        string temp{s};
        while (s[k] == t[j] || s[k] == '?')
        {
            temp[k] = t[j];
            k++;
            j++;
            if (j == t.size())
            {
                for (size_t l = 0; l < s.size(); l++)
                {
                    if (temp[l] == '?')
                    {
                        temp[l] = 'a';
                    }
                }
                return temp;
            }
        }
    }
    return "UNRESTORABLE";
}

int main()
{
    string s, t;
    cin >> s >> t;
    cout << restore(s, t) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> l(m);
  vector<int> r(m);
  rep(i,m){
    cin>>l[i];
    cin>>r[i];
  }
  sort(all(l));
  reverse(all(l));
  sort(all(r));
  int ans=r[0]-l[0]+1;
  if(ans<0){
    ans=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4068
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P; 
typedef tuple<ll,ll,ll> T;
const ll INF = 1e15;

int main(){
	ll N;
	cin >> N;
	vector<P> v;
	for(int i=0;i<N;i++){
		ll in;
		cin >> in;
		bool ok = false;
		for(int j=0;j<v.size();j++)
			if(v[j].first == in){
				v[j].second += 1;
				ok = true;
			}
		if(!ok)
			v.push_back(P(in,1));
		if(v.size() > 2){
			cout << "No" << endl;
			return 0;
		}
	}
	
	if(v.size() == 1){
		ll same = v[0].second / 2;
		if((1 <= v[0].first && v[0].first <= same) || v[0].second == v[0].first+1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}else{
		sort(v.begin(), v.end());
		ll base = v[0].second;
		ll same = v[1].second / 2;
		if(same == 0 || abs(v[1].first - v[0].first) != 1){
			cout << "No" << endl;
			return 0;
		}
		if(base + 1 <= v[1].first && v[1].first <= base + same)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ll N, M;
    cin >> N >> M;
    if( abs(N - M) >= 2){
        cout << 0 << endl;
        return 0;
    }
    //同じ数の場合犬または猿が先頭かで組み合わせが発生
    ll ans = 1;
    if(N == M){
       ans = 2;
    }

    for (int i = N; i > 1; --i) {
        ans = ( ans * i ) % 1000000007;
    }

    for (int i = M; i > 1; --i) {
        ans = ( ans * i ) % 1000000007;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m%=n, n);
  return m;
}

int main() {
  int N;
  scanf("%d", &N);

  intmax_t res=1;
  for (int i=0; i<N; ++i) {
    intmax_t T;
    scanf("%jd", &T);

    res = res/gcd(res, T)*T;
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pr pair <ll,ll> 
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define pri 1000000007
#define mn 25
#define sz noofnodes +2
#define all(x) x.begin(),x.end()
using namespace std;

void masterstroke()
{   
	ll n;
	cin>>n;
	vector <pair<ll,ll> > v;
	for(ll i=0;i<n;i++){
		ll x,y;cin>>x>>y;
		v.PB(MP(x,y));
	}
	if(n==1){cout<<1<<endl;return;}
  sort(all(v));
  vector <pair<ll,ll> >pos;
    for(ll i=0;i<n;i++){
	for(ll j=i+1;j<n;j++){
        pos.PB(	MP(v[j].ff-v[i].ff,v[j].ss-v[i].ss));
	   }
 }
ll cost=pri;
for(auto j:pos){
	ll p=j.ff;
	ll q=j.ss;
	ll c=0;
		map <pair<ll,ll> ,ll> ans;
		for(ll j=n-1;j>=0;j--)
{
	if(ans[MP(v[j].ff+p,v[j].ss+q)]==1){}
	else{c++;}
	ans[MP(v[j].ff,v[j].ss)]=1;
}

cost=min(c,cost);
}
cout<<cost<<endl;




	}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


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

int main(){
    string s; cin >> s;
    int N = s.size();
    int ans = N;
    for(char c: s){
        int pcnt = 0;
        int cnt = 0;
        int tmp = 0;
        for (int i = 0; i < N;)
        {
            if(s[i]==c){
                i++;
                continue;
            }
            int j = i;
            while(j<N && s[j]!=c) j++;
            tmp = max(tmp, j - i);
            i = j;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef struct point{
  int num;
  string name;
  int point;
}P_T;

bool ncomp(const P_T &a, const P_T &b){
  return a.point > b.point;
}

bool scomp(const P_T &a, const P_T &b){
  return a.name < b.name;
}

int main(){
  int n; cin >> n;
  vector<P_T> a(n);
  for(int i=0; i<n; ++i){
    a[i].num = i + 1;
    cin >> a[i].name >> a[i].point;
  }
  
  stable_sort(a.begin(), a.end(), ncomp);
  stable_sort(a.begin(), a.end(), scomp);
  
  for(int i=0; i<n; ++i) cout << a[i].num << endl;

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
Q = ir()
rev = 0
top = ''
tail = ''
# xor
for _ in range(Q):
    x = sr().split()
    if x[0] == '1':
        rev ^= 1
    else:
        _, f, c = x
        if (int(f)^rev) & 1:
            top += c
        else:
            tail += c

answer = top[::-1] + S + tail
if rev&1:
    answer = answer[::-1]
print(answer)
# 40


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    string S;
    cin >> S;
    
    int N = S.size();
    int ans = 0;
    for(int i=0; i<N; i++){
        int length_bubun=0;
        for (int j=i; j<N; j++) {
            if (S[j]=='A'||S[j]=='T'||S[j]=='C'||S[j]=='G') {
                length_bubun++;
            }
            else{
                
                break;
            }
        }
        if(ans<length_bubun){
                    ans=length_bubun;
         }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
def main():
    S = input()
    s = 'keyence'
    for i in range(len(s)+1):
        judge = True
        for j in range(i):
            if s[j] != S[j]:
                judge = False
                break
        for j in range(len(s)-i):
            if s[-1-j] != S[-1-j]:
                judge = False
                break
        if judge:
            return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Measured memory_bytes: 38256
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    void solve() {
        int n = scanner.nextInt();
        char[][] s = new char[n][n * 2];
        for (int i = 0; i < n; i++) {
            String t = scanner.next();
            s[i] = (t + t).toCharArray();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            boolean f = true;
            for (int j = 1; j < n; j++) {
                for (int k = 0; k < j; k++) {
                    f &= s[j][i + k] == s[k][i + j];
                }
            }
            if (f) {
                count += n;
            }
        }
        System.out.println(count);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.close();
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 28088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    ll n;
    cin>>n;
    int ans = 10;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0)
            ans = min(ans, (int)log10(n/i)+1);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;

		long long r=0,g=0,b=0;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
			r++;
		else if(s[i]=='B')
			b++;
		else g++;
	}

	

	long long cnt=0;

	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			if(s[i]!=s[j])
			{
				int k=j-i;
				int ch=j+k;
				if(ch<n && (s[i]!=s[ch] && s[j]!=s[ch]))
					cnt++;
			}
		}

	}

	cout<<r*g*b-cnt;
	return 0;
}

Measured memory_bytes: 3632
def abc044_c():
    N, A = map(int, input().split())
    X = list(map(lambda x: int(x) - A, input().split()))  # 平均ターゲットを引いた状態
    dp = [dict() for _ in range(N+1)]  # 負の値を取り得るため、配列でなく辞書で持つ
    dp[0][0] = 1  # 0枚時点で何も選ばない、を初期値とする
    for i, x in enumerate(X):
        dp[i+1] = dp[i].copy()  # 前の状態を引き継ぐ
        for val, cnt in dp[i].items():
            dp[i+1][val + x] = dp[i].get(val + x, 0) + cnt  # 前のターンのxシフト分を加算
    ans = dp[N][0] - 1
    print(ans)

if __name__ == '__main__':
    abc044_c()

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

using namespace std;

int main(void) {
	int n, l;
	cin >> n >> l;
	vector<string>s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>

using namespace std;


int main(){
    string a, b;
    stringstream ss;

    cin >> a >> b;

    ss << a+b;

    int ab;

    ss >> ab; 

    bool flag = false;
    for(int i = 1; i < ab; i++){
    if(ab == i*i){
      flag = true;
      break;
    }
    if(ab < i*i) break;
  }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<bool> RL(n - 1);
  rep(i, n - 1) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      RL[i] = true;
    }
  }
  vector<int> c(1, 1);
  rep(i, n - 1) {
    if (s[i] == s[i + 1]) {
      c.back()++;
    } else {
      c.emplace_back(1);
    }
  }
  vector<int> ans(n, 0);
  for (int i = 0, j = 0; i < n - 1; i++) {
    if (RL[i]) {
      ans[i] += (c[j] + 1) / 2;
      ans[i + 1] += c[j] / 2;
      j++;
      ans[i] += c[j] / 2;
      ans[i + 1] += (c[j] + 1) / 2;
      j++;
    }
  }
  rep(i, n) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 4340
N = int(input())
cnt = 0
if N >= 105:
    cnt += 1
    for i in range(106, N + 1):
        cnt8 = 0
        if i % 2 == 0:
            continue

        for j in range(1, i + 1):
            if i % j == 0:
                cnt8 += 1
        if cnt8 == 8:
            cnt += 1
            
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>data(N);
  for (int i=0;i<N;i++){
  cin >>data.at(i);
  }
  sort (data.begin(),data.end());
  cout <<data.at((N/2))-data.at(N/2-1)<<endl;
  
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <string.h>

using namespace std;

int n;
char z[12000];
int ans;
void work () {
	int i;
	scanf ( "%d" , &n );
	scanf ( "%s" , z + 1 );
	for ( i = 1 ; i <= n ; i++ ) {
		if ( z[i] == 'R' ) ans++;
		else ans--;
	}
	if ( ans > 0 ) printf ( "Yes\n" );
	else printf ( "No\n" );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(a);

        List<Pair> pairs = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            pairs.add(new Pair(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));
        }
        Collections.sort(pairs);

        int[] d = new int[n];
        int index = 0;
        long sum = 0;
        for (Pair p : pairs) {
            int b = p.b;
            int c = p.c;
            for (int j = 0; j < b; j++) {
                d[index] = c;
                sum += c;
                index++;
                if (index >= n) {
                    break;
                }
            }
            if (index >= n) {
                break;
            }
        }

        for (int i = 0; i < n; i++) {
            long tmp = sum - d[n - 1 - i] + a[n - 1 - i];
            if (sum > tmp) {
                break;
            }
            sum = tmp;
        }

        System.out.println(sum);

    }

    public static class Pair implements Comparable<Pair> {
        int b;
        int c;

        public Pair(int b, int c) {
            this.b = b;
            this.c = c;
        }

        @Override
        public int compareTo(Pair o) {
            return o.c - this.c;
        }
    }
}


Measured memory_bytes: 63932
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, M; cin >> N >> M;
  auto sum = (N-M)*100 + M*1900;
  auto cnt = 1 << M;
  auto ans = sum*cnt;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力値
		int n = sc.nextInt();
		String s = sc.next();
		// 文字列の長さ
		int len = n%2 == 0 ? n/2 : 0;
		// 2度繰り返せばOK
		if(len>0) {
			String c1 = s.substring(0,len);
			String c2 = s.substring(len,s.length());
			if (c1.equals(c2)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

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

int main(int argc, char* argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	
	if( (a < b) & (b < c)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    string s;cin >> s;
    char st=s[0];
    char ed=s[s.size()-1];
    cout << st << s.size()-2 << ed << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

class PG{
    static void Main(string[] args){
        int n=int.Parse(Console.ReadLine());
        
        for(int i=1;i<=n;i++){
            int x=i;
            if(x%3==0){
                Console.Write(" "+i);
                continue;
            }
            while(true){
                if(x%10==3){
                    Console.Write(" "+i);
                    break;
                }
                x/=10;
                if(x==0){
                    break;
                }
            }
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 17920
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[100001],d=0,f[100001],g,h,i,j;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&s[i]);
		f[i]=0;
	}
	g=1;
	f[0]++;
	i=s[0];
	while(1){
		if(i==2) break;
	//	printf("%d\n",i);
		f[i-1]++;
	//	for(j=0;j<a;j++) printf("%d   %d\n",j,f[j]);
		if(f[i-1]==2){
			d=-1;
			break;
		}
		if(i==2) break;
		g++;
		i=s[i-1];
	}
	if(d==-1) printf("-1\n");
	else printf("%d\n",g);
	return 0;
}

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

int main() 
{
  int a,b,c;
  cin >> a >> b >>c;
  if(a==b && b==c)
  {
    cout << "No";
  }
  else if (a!=b && b!=c && a!=c)
  {
    cout << "No";
  }
  else
  {
    cout  << "Yes";
  }
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c, long long d){
    if(abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 256
def BubbleSort(A):
    #tot = 0
    flag = 1
    N = len(A)
    
    while flag:
        flag = 0
        for j in xrange(N-1,0,-1):
            if A[j][1] < A[j-1][1]:
                A[j],A[j-1] = A[j-1],A[j]
                flag = 1
                #tot += 1
    return A #,tot

def SelectionSort(A): 
    N = len(A)
    m = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j][1] < A[minj][1]:
                minj = j
        A[i],A[minj] = A[minj],A[i]
        if i != minj:
            m += 1
    return A

    
N = int(raw_input())
ls = raw_input().split()

tmp = BubbleSort(list(ls))
print ' '.join(map(str,tmp))
print 'Stable'

tmp2 = SelectionSort(list(ls))
print ' '.join(map(str,tmp2))
for k,j in zip(tmp,tmp2):
    if k != j:
        print 'Not stable'
        break
else:
    print 'Stable'

Measured memory_bytes: 4276
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
using namespace std;
typedef complex<double> P;

double area(vector<P> polygon)
{
  const int N = polygon.size();
  double s = 0.0;
  for (int i = 0; i < N; i++) {
    s += polygon[i].real()*polygon[(i+1)%N].imag() - polygon[i].imag()*polygon[(i+1)%N].real();
  }
  return abs(s)/2.0;
}

int main()
{
  int c = 1;
  int n;
  while (cin >> n && n != 0) {
    vector<P> polygon(n);
    for (int i = 0; i < n; i++) {
      cin >> polygon[i].real() >> polygon[i].imag();
    }
    
    printf("%d %.1f\n", c, area(polygon));
    c++;
  }
  return 0;
}

Measured memory_bytes: 0
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 3)
        cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    double w,h,x,y; cin >> w >> h >> x >> y;
    int hantei;

    if(x == w / 2 && y == h / 2) hantei = 1;
    else hantei = 0;

    cout << w * h / 2 << " " << hantei << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

int main(){
	long long x;
	cin >> x;
	long long ans = (x / 11) * 2;
	x %= 11;
	if(x > 6){
		ans += 2;
	}
	else if(x > 0){
		ans += 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
function main()
	N,C=map(x->parse(Int,x),split(readline()))
	M=[[0 for _=1:10^5] for _=1:C]
	for s=readlines()
		L,R,c=map(x->parse(Int,x),split(s))
		for i=L:R
			M[c][i]=1
		end
	end
	ans=0
	for i=1:10^5
		now=0
		for j=1:C
			if M[j][i]==1
				now+=1

			end
		end
		ans=max(ans,now)
	end
	println(ans)
end
main()


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

const int N = 1e5 + 9;

int a[N];
 
int main () {
	ios::sync_with_stdio(0); cin.tie(0);
	
    int n; cin >> n;
    int mx = 0, ans = 0;
 
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        
        if (i == 1)continue;
        if (a[i] <= a[i - 1])
            ++ans;
        else{
            mx = max(ans, mx);
            ans = 0;
        }
    }
 
    mx = max(mx, ans);
 
    cout << mx;
	
	
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int main()
{
	int k;
	cin>>k;
	if(k==1)
	{
		puts("1\n1");
		return 0;
	}
	int n=(k+3)/4*2;
	cout<<n<<"\n";
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=n;++j)
		{
			int g=(i+j)%n+1;
			if(i&1) cout<<g<<" ";
			else
			{
				if(g+n>k) cout<<g<<" ";
				else cout<<g+n<<" ";
			}
		}
}


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

using namespace std;

int main()
{
	int num;
	string before = "Hoshino", after = "Hoshina";

	cin >> num;
	cin.get();

	for(int i = 0; i < num; i++)
	{
		string str;
		getline(std::cin, str);
		string::size_type pos;
		for(pos = str.find(before); pos != string::npos; pos = str.find(before, after.size() + pos))
		{
			str.replace(pos, before.size(), after);
		}
		cout << str << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
N, K = [int(_) for _ in input().split()]

P = [[int(_) for _ in input().split()] for n in range(N)]

X = []
Y = []
for n in range(N):
    x, y = P[n]
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()

ans = 10 ** 20
for xi in range(N):
    for xj in range(xi+1, N):
        for yi in range(N):
            for yj in range(yi+1, N):
                x1, y1 = X[xi], Y[yi]
                x2, y2 = X[xj], Y[yj]
                c = 0
                for v in range(N):
                    x, y = P[v]
                    if x1 <= x <= x2 and y1 <= y <= y2:
                        c += 1
                if c >= K:
                    ans = min(ans, (x2-x1) * (y2-y1))
print(ans)


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

using namespace std;

int main(){
  int n;
  int p[100];
  int max;
  int ans=0;
  cin >> n;
  for(int i=0;i!=n;i++){
    cin >> p[i];
    if(p[i]>max){
      max=p[i];
    }
    ans+=p[i];
  }
  cout << ans-(max/2) << endl;
}


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

//約数列挙
vector<long long> calc_divisor(long long n){
    vector<long long> res;
    for(long long i = 1LL; i*i <= n;i++){
        if(n % i == 0){
            res.push_back(i);
            long long j = n/i;
            if(j != i)res.push_back(j);
        }
    }
    sort(res.begin(),res.end());
    return res;
}




int main(){
    long long N,M;
    cin>> N >> M;
    vector<long long> div = calc_divisor(M);
    
    //Mの約数dであって、d*N <= M となる最大の d を求める。
    long long res = 1;
    for(auto d:div){
        if(d*N <= M)res = max(res,d);
    }
    cout << res << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x;
    cin>>x;
    for(ll i=1;i<=x;i++){
        if(i*(i+1)/2>=x){
            cout<<i<<endl;
            break;
        }

    }
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static string S;
    static void input()
    {
        cin = new Scanner();
        S = cin.next();
    }
    static void solve()
    {
        input();
        int[] ans = Enumerable.Repeat(1, S.Length).ToArray();
        for(int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'R' && S[i + 1] != 'L') 
            {
                ans[i + 2] += ans[i];
                ans[i] = 0;
            }
        }

        for(int i = S.Length - 1; i >= 0; i--)
        {
            if(S[i] == 'L' && S[i - 1] != 'R')
            {
                ans[i - 2] += ans[i];
                ans[i] = 0;
            }
        }
        Write(ans[0]);
        for (int i = 1; i < S.Length; i++)
            Write(" " + ans[i]);

        WriteLine();
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 17504
#include <stdio.h>

int main(void)
{
	int N,K;
	int num = 1;

	scanf ("%d",&N);
	scanf ("%d",&K);

	while (N > 0){
		if (num < K){
			num = num*2;
		}else{
			num = num + K;
		}
		N = N -1;
	}

	printf ("%d\n",num);

	return 0;
}

Measured memory_bytes: 1696
using System;
using System.Linq;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            solve();
        }
        private static void solve()
        {
            var t = int.Parse(Console.ReadLine());
            var d = t % 10;
            var r = string.Empty;
            if (new[] { 2, 4, 5, 7, 9 }.Contains(d))
                r = "hon";
            else if (new[] { 0, 1, 6, 8 }.Contains(d))
                r = "pon";
            else
                r = "bon";
            Console.WriteLine(r);
        }
    }
}

Measured memory_bytes: 27756
n = int(input())
a = list(map(int, input().split()))
ans = []
if n % 2 == 0:
    for i in [i for i in range(n) if i%2 == 1][::-1]:
         ans += [a[i]]

    for i in [i for i in range(n) if i%2 == 0]:
         ans += [a[i]]

if n % 2 == 1:
    for i in [i for i in range(n) if i%2 == 0][::-1]:
         ans += [a[i]]

    for i in [i for i in range(n) if i%2 == 1]:
         ans += [a[i]]

print(*ans)

Measured memory_bytes: 104404
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = deque([])
flg = False
if n % 2 == 0:
    flg = True
for e in a:
    if flg:
        b.append(e)
        flg = False
    else:
        b.appendleft(e)
        flg = True
print(' '.join(map(str, b)))


Measured memory_bytes: 29104
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll a,b;
ll ans;

ll f(ll a)
{
    int b = (a + 1) % 4;
    if(b == 3)
        return a + 1;
    else if(b == 2)
        return 1;
    else if(b == 1)
        return a;
    else
        return 0;
}

int main()
{
    ans = 0;
    scanf("%lld%lld",&a,&b);
    ans = f(a-1) ^ f(b);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
while True:
    q=int(input())
    if q==-1:
        break
    x=q/2
    a=0.00001*q
    while abs(x**3-q)>=a:
        s=x*x
        t=s*x-q
        x-=t/(3*s)
    print(f"{x:.6f}")


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	ll n,a; cin >>n>>a;

	cout << n*n-a  <<endl;
	
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
unsigned long  n;
scanf("%lu¥n",&n);
unsigned long m=0;
unsigned long  r=0;
unsigned long  c=0;
unsigned long  a=0;
unsigned long  h=0;
for(unsigned long  i = 0;i<n;i++){
char str[64];
scanf("%s¥n",&str);
if(str[0] == 'M'){m++;}
if(str[0] == 'C'){c++;}
if(str[0] == 'A'){a++;}
if(str[0] == 'R'){r++;}
if(str[0] == 'H'){h++;}
}
unsigned long ans=0;
ans = (m+c+a+r+h)*(m+c+a+r+h)*(m+c+a+r+h);
ans -= (m+c+a+r+h)*3*a*a-2*a*a*a;
ans -= (m+c+a+r+h)*3*m*m-2*m*m*m;
ans -= (m+c+a+r+h)*3*h*h-2*h*h*h;
ans -= (m+c+a+r+h)*3*r*r-2*r*r*r;
ans -= (m+c+a+r+h)*3*c*c-2*c*c*c;
printf("%lu",ans/6);
return 0;
}

Measured memory_bytes: 128