akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
    long long n;
    cin >> n;

    long long count[5];

    for(int i = 0; i < 5; i++){
        count[i] = 0;
    }

    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M'){
            count[0]++;
        }
        else if(s[0] == 'A'){
            count[1]++;
        }
        else if(s[0] == 'R'){
            count[2]++;
        }
        else if(s[0] == 'C'){
            count[3]++;
        }
        else if(s[0] == 'H'){
            count[4]++;
        }
    }

    long long sum = 0;

    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                if(count[i] != 0 and count[j] != 0 and count[k] != 0){
                    sum = sum + count[i]*count[j]*count[k];
                }
            }
        }
    }

    printf("%lld\n", sum);

    return 0;

}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())

res = 0
left = 0
right = 0
# start
cnt = 0
for i in range(N-1):
    if S[i] == "0" and S[i+1] == "1":
        cnt += 1
    if cnt == K and S[i+1] == "0":
        right = i
        break
    if i == N - 2:
        right = N - 1
    
res = max(res, right - left + 1)

while right < N-1:
    left += 1
    right += 1
    while left < N:
        if S[left] == "1" and S[left-1] == "0":
            break
        else:
            left += 1
    while right < N - 1:
        if S[right] == "1" and S[right+1] == "0":
            break
        else:
            right += 1
    res = max(res, right - left + 1)
    
print(res)

Measured memory_bytes: 4084
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        char = s[i-1]
        if char == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

answer = ''
i, j = len(s), len(t)
now = dp[i][j]
while i > 0 and j > 0:
    if dp[i-1][j] == now:
        i -= 1
        continue
    if dp[i][j-1] == now:
        j -= 1
        continue
    answer += s[i-1]
    i -= 1
    j -= 1
    now -= 1

print(answer[::-1])


Measured memory_bytes: 112220
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[m];
        var b = new int[m];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]);
            b[i] = int.Parse(line[1]);
        }
        var c = getAns(a, b, n, m);
        var p1 = 0L;
        for (int i = 0; i < m; i++) p1 += (a[i] + 1) % b[i];
        print(c, p1, n, m);

    }
    static void print(long[] c, long p1, int n, int m)
    {
        for (int i = 1; i <= n; i++)
        {
            var w = p1 + c[i] + m * (long)(i - 1);
            Console.WriteLine(w);
        }
    }
    static long[] getAns(int[] a, int[] b, int n, int m)
    {
        var c = new long[n + 1];
        for (int i = 0; i < m; i++)
        {
            var bi = b[i];
            var p = bi - a[i];
            while (p <= n)
            {
                if (p != 1) c[p] -= bi;
                p += bi;
            }
        }
        for (int i = 2; i <= n; i++)
            c[i] = c[i - 1] + c[i];
        return c;
    }
}



Measured memory_bytes: 22936
#define PI 3.14159265359
#define INF 2000000000
#define MAX 500000
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll F[45]={0};
    int n;
    cin>>n;
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
    cout<<F[n]<<endl;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n , k;
	cin >> n >> k;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	
	int ans = 0;
	for(int l = 0 , r = k - 1 ; l + 1 < n ; l += k - 1 , r += k - 1){
		++ans;
	}
	die(ans);

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            int[] A = ReadIntArray();

            int ans = 0;
            for (int i = 0; i < A.Length - 1; i++)
            {
                if (A[i] == A[i + 1])
                {
                    ans++;
                    i++;
                }
            }

            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

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

const int INF=1e5;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    int pre=-1;
    vector<int> ans;
    for(int i=0;i<=k;i++){
        int tmp=-1;
        if(pre!=-1){
            tmp=a[pre];
            a[pre]=INF;
        }
        auto it=min_element(a.begin(),a.end());
        if(*it<=0){
            cout<<-1<<endl;
            return 0;
        }
        if(pre!=-1) a[pre]=tmp;
        int mid=it-a.begin();
        for(int j=0;j<n;j++){
            if(j!=mid && j!=pre){
                a[j]--;
                ans.push_back(j);
            }
        }
        ans.push_back(mid);
        a[mid]--;
        pre=mid;
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]+1<<(i+1==ans.size() ? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,i,j,k=5,c=0;
    
        
        cin>>n;
        if(n==1)
        {
            printf("0\n");
        }
        if(n==0)
        
        {
            printf("1\n");
        }
    
}

Measured memory_bytes: 3556
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // 以全能的真主阿拉的名字開頭
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b,c;
    cin >> a >> b >> c;
  	cout<<max(a,max(b,c))-min(a,min(b,c));
	return 0;
	// BYE BYE
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll A;
    long double B;
    cin >> A >> B;

    cout << ll(A * B) << endl;

    return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=1e4;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    for(int d=1;d<=D;++d) cout<<ans[d]<<endl;
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void solve(int time){
    max_score=evaluate();
    for(int i=0;i<time;++i){
        int p=rand()%D+1;
        int temp=ans[p];
        ans[p]=rand()%ntype+1;
        int temp_score=evaluate();
        if(max_score<temp_score) max_score=temp_score;
        else ans[p]=temp;
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    Output();
}

Measured memory_bytes: 3664
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    r1 = (a - 1 + b - 1 + 1) // 2
    r2 = (n - a + n - b + 1) // 2
    print(min(r1, r2))



Measured memory_bytes: 3316
S = input()
A, B = int(S[:2]), int(S[2:])
a = False
if 1<=A<=12:
    a = True
b = False
if 1<=B<=12:
    b = True
if a and b:
    print("AMBIGUOUS")
elif a:
    print("MMYY")
elif b:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cctype>

using namespace std;

map<string, vector<string> > grp;
map<string, bool> prn;
vector<string> split(string str)
{
  vector<string> vec;
  string s;

  for(int i = 0; i < str.size(); i++){
    s = "";
    while(i < str.size() && isalpha(str[i])) s += str[i++];
    if(s.size()) vec.push_back(s);
  }

  return vec;
}

int search(string tg)
{
  int ln = 0;
  vector<string> vec = grp[tg];
  prn[tg] = true;

  for(int i = 0; i < vec.size(); i++){
    if(!prn[vec[i]] && grp.find(vec[i]) != grp.end()) ln += search(vec[i]);
    else if(!prn[vec[i]]){
      ln++;
      prn[vec[i]] = true;
    }
  }

  return ln;
}

int main()
{
  int n;
  string str, tg;

  while(cin>>n && n){
    bool f = true;
    while(n--){
      cin >> str;
      vector<string> vec = split(str);
      str = vec[0];
      vec.erase(vec.begin());
      grp[str] = vec;

      if(f){
	tg = str;
	f = false;
      }
    }

    cout << search(tg) << endl;
    grp.clear();
    prn.clear();
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
	float debt = 100;
	int buf;
	int n;
	
	int i;
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		debt = debt*1.050;
		buf = (int)debt;
		if(debt - buf >= 0.001){
			buf++;
			debt = (float)buf;
		}
	}
	
	printf("%d000\n",(int)debt);
	
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,m;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m;
	fo(i,0,m){
		int x;
		cin>>x;
		n-=x;
	}
	cout<<max(n,-1)<<endl;
	return 0;
}

Measured memory_bytes: 3644
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
e = []
e[1] =
Q = line[1] * 1
t = {}
n = []
a = []

for (i=1; i <= N; i++) {
    t[i] = []
    n[i] = 0
    a.push(0) 
}

for (i=0; i < N-1; i++) {
    line = lines[i].split(' ')
    t[line[0]].push(line[1]) 
    t[line[1]].push(line[0]) 
}

for (i=N-1; i < N + Q; i++) {
    line = lines[i].split(' ')
    n[line[0]] += line[1] * 1
}

h = []
c = 0
h.push([1, 0])
e = []
e[1] = 1
while(h.length) {
    s = h.pop()
    j = s[0]
    c = s[1]
    c += n[j]
    a[j-1] = c
    for (k=0; k<t[j].length; k++) {
        if (!e[t[j][k]]) {
            h.push([t[j][k], c])
            e[t[j][k]] = 1
        }
    }
}

console.log(a.join(' '))


Measured memory_bytes: 152544
#include <cstdio>
#include <vector>
#include <string.h>

int main() {
    int N, M, K;
    int i, j;

    std::scanf("%d %d %d", &N, &M, &K);

    long A, B;
    long time_to_read_A[N+1], time_to_read_B[M+1];
    time_to_read_A[0] = 0;
    time_to_read_B[0] = 0;
    int n_readable[N+1];

    for (i = 0; i < N; i++) {
        std::scanf("%ld", &A);
        if (i == 0) {
            time_to_read_A[i+1] = A;
        } else {
            time_to_read_A[i+1] = time_to_read_A[i] + A;
        }
    }

    for (i = 0; i < M; i++) {
        std::scanf("%ld", &B);
        if (i == 0) {
            time_to_read_B[i+1] = B;
        } else {
            time_to_read_B[i+1] = time_to_read_B[i] + B;
        }
    }

    j = M;
    for (i = 0; i <= N; i++) {
        if (time_to_read_A[i] > K) {
            n_readable[i] = -1;
            break;
        }
        while (time_to_read_A[i] + time_to_read_B[j] > K) {
            if (j == 0) break;
            j--;
        }
        n_readable[i] = j;
    }

    int max = 0;
    for (i = 0; i <= N; i++) {
        if (n_readable[i] == -1) break;
        if (max < i + n_readable[i]) max = i + n_readable[i];
    }

    std::printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 7124
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int a[N-1];
  for(int i = 0;i<N-1;i++){
    cin>>a[i];
  }
  int ans = 0;
  for(int i = 0;i<N-2;i++){
    ans += min(a[i],a[i+1]);
  }
  cout << ans+a[0]+a[N-2] << endl;
  return 0;
}

Measured memory_bytes: 256
# your code goes here
a,b,c=map(int,input().split())
if a==0 and b==0:
	print("0 0")
elif a==0 and b>0:
	if b>c:
		print("0",b-c)
	elif c>=b:
		print("0 0")
elif b==0 and a>0:
	if a>c:
		print(a-c,"0")
	elif c>=a:
		print("0 0")
elif a+b==c:
	print("0 0")
elif a>c:
	print(a-c,'',b)
elif c>=a:
	i=c-a;
	if(b>i):
		j=b-i
	else:
		j=0
		
	print("0",j)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;


int main(){
	long long int n, t, tt[200000];
	long long int x = 0;
	cin >> n >> t;
	for(int i = 0; i < n; i++){
		cin >> tt[i];
	}
	
	sort(tt, tt + n);
	
	int v = tt[0];
	for(int i = 1; i < n; i++){
		x += min(t, tt[i] - tt[i -1]);
	}
	
	cout << x + t << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q), r(Q);
    vector<int> csum(S.size()+1);
    int sum = 0;
    csum[0] = 0;
    for (int i = 0; i < S.size()-1; i++)
    {
        if(S[i] == 'A' && S[i+1] == 'C'){
            sum++;
            csum[i + 1] = sum;
        }
        else{
            csum[i + 1] = sum;
        }
    }
    for (int i = 0; i < Q; i++)
    {
        int ans = 0;
        cin >> l[i] >> r[i];
        ans = csum[r[i]-1] - csum[l[i]-1];
        cout << ans << endl;
    }
}


Measured memory_bytes: 4460
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll n,k; cin >> n >> k; string s; cin >> s; k--;
  
  if(s[k] == 'A') s[k] = 'a';
  else if(s[k] == 'B') s[k] = 'b';
  else  s[k] = 'c';
  
  
  cout << s << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll H, W;

vector< vector< int > > grid_bfs(vector< string > &s, int sx, int sy) {
  const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
  vector< vector< int > > min_cost(s.size(), vector< int >(s[0].size(), -1));
  queue< pair< int, int > > que;
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < s[i].size(); j++) {
      if(i == sx && j == sy) {
        que.emplace(i, j);
        min_cost[i][j] = 0;
      }
    }
  }
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    for(int i = 0; i < 4; i++) {
      int ny = p.first + vy[i], nx = p.second + vx[i];
      if(nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size()) continue;
      if(min_cost[ny][nx] != -1) continue;
      //if(wall.find(s[ny][nx]) != string::npos) continue;
      if(s[ny][nx] == '#') continue;
      min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
      que.emplace(ny, nx);
    }
  }
  return min_cost;
}

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

    cin >> H >> W;

    vector<string> S(H);
    REP(i, H){
    	string T;
    	cin >> T;
    	S[i] = T;
    }

    ll res = -1;
    REP(sx, H){
    	REP(sy, W){
    		REP(gx, H){
    			REP(gy, W){
    				if(S[sx][sy]=='#') continue;
    				if(S[gx][gy]=='#') continue;
    				auto tmp = grid_bfs(S, sx, sy);
    				res = max(res, (ll)tmp[gx][gy]);
    			}
    		}
    	}
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, x = gets.split.map(&:to_f)

c = x / (a ** 2)
s = a * c

if s >= a * b / 2
  y = 2 * b - 2 * s / a
  p Math.atan(y/a) * 180 / Math::PI
else
  y = 2 * s / b
  p Math.atan(b/y) * 180 / Math::PI
end

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 500000;

int fact[MAXN + 1];
int ifact[MAXN + 1];

int Add(int x, int y) {
    x += y;
    return x < MOD ? x : x - MOD;
}

int Sub(int x, int y) {
    x -= y;
    return x >= 0 ? x : x + MOD;
}

int Mul(int x, int y) {
    return int(1LL * x * y % MOD);
}

int FastPow(int x, int p) {
    int res = 1;
    while (p > 0) {
        if (p & 1) {
            res = Mul(res, x);
        }
        p >>= 1;
        x = Mul(x, x);
    }
    return res;
}

int Inv(int x) {
    return FastPow(x, MOD - 2);
}

int C(int k, int n) {
    return Mul(fact[n], Mul(ifact[n - k], ifact[k]));
}

int A(int k, int n) {
    return Mul(fact[n], ifact[n - k]);
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    fact[0] = fact[1] = 1;
    for (int i = 2; i <= MAXN; ++i) {
        fact[i] = Mul(i, fact[i - 1]);
    }
    ifact[MAXN] = Inv(fact[MAXN]);
    for (int i = MAXN - 1; i >= 0; --i) {
        ifact[i] = Mul(ifact[i + 1], i + 1);
    }
    int n, m;
    cin >> n >> m;
    int ans = Mul(A(n, m), A(n, m));
    for (int i = 1; i <= n; ++i) {
        int val = Mul(A(n - i, m - i), A(n - i, m - i));
        val = Mul(Mul(C(i, n), A(i, m)), val);
        if (i & 1) {
            ans = Sub(ans, val);
        } else {
            ans = Add(ans, val);
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

using namespace std;

const int NMAX = 1e5;

int n;
int a[NMAX + 5];
int b[NMAX + 5];

int main(){

    cin >> n;

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

    vector<int> vals;

    long long sum = 0;
    int cnt = 0;

    for(int i = 1; i <= n; i++){
        cin >> b[i];
        if(a[i] >= b[i]){
            vals.push_back(a[i] - b[i]);
        }
        else{
            cnt++;
            sum += a[i] - b[i];
        }
    }

    sort(vals.begin(),vals.end());
    reverse(vals.begin(),vals.end());

    if(sum >= 0){
        cout << cnt;
        return 0;
    }

    for(auto it:vals){
        cnt++;
        sum += it;
        if(sum >= 0){
            cout << cnt;
            return 0;
        }
    }

    cout << "-1";

    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i,N){
		cin >> d[i];
	}
	sort(d.begin(),d.end());
	
	cout << d[N/2] - d[N/2-1] << endl;
    return 0;
}



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

int main(){
  int N;
  int A[101];
  int sum = 0;
  cin>>N;
  for(int i =0;i <N;i++){
 cin>>A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);
  for(int i = 0;i < N;i++){
    if(A[i]!=A[i+1]){
      sum++;
    }
  }
  cout<<sum<<endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int X;
	cin >> X;
	int N = X, sum = 0;
	while (true) {
		sum = 0;
		for (int i = 1; i <= sqrt(N); i++) {
			if (N % i == 0) sum += 2;
		}
		if (sum == 2) {
			cout << N << endl;
			return 0;
		}
		N++;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::max;

#define MAXN 100003
int d[MAXN][3],a[MAXN][3];
int main(void)
{
    int i,N;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    }
    d[0][0]=a[0][0];
    d[0][1]=a[0][1];
    d[0][2]=a[0][2];
    for(i=1;i<N;i++)
    {
        d[i][0]=a[i][0]+max(d[i-1][1],d[i-1][2]);
        d[i][1]=a[i][1]+max(d[i-1][0],d[i-1][2]);
        d[i][2]=a[i][2]+max(d[i-1][1],d[i-1][0]);
    }
    printf("%d\n",max(d[N-1][0],max(d[N-1][1],d[N-1][2])));

    return 0;
}


Measured memory_bytes: 2560
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int X[] = new int[N];
        int min = 101;
        int max = 0;
        for(int i = 0; i < N; i++) {
            X[i] = scan.nextInt();
            min = Math.min(min, X[i]);
            max = Math.max(max, X[i]);
        }

        int ans = Integer.MAX_VALUE;
        for(int i = min ; i <= max; i++){
            int sum = 0;
            for(int j = 0; j < N; j++){
                sum += (X[j]-i)*(X[j]-i);
            }
            ans = Math.min(ans, sum);
        }

        os.println(ans);
    }
}

Measured memory_bytes: 21588
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] H = new int[N];

        for (int i = 0; i < N; i++) {
            H[i] = scanner.nextInt();
        }
        Arrays.sort(H);
        long sum = 0;
        for (int i = 0; i < N - K; i++) {
            sum += H[i];
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 64896
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N,P)

Measured memory_bytes: 3064
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ans=0
AA=[(A[0]-1)%k]
for i in range(1,n):
  AA.append((AA[-1]+A[i]-1)%k)
import collections
d=collections.defaultdict(int)
d[0]+=1
for i in range(n):
  if i+1==k:
    d[0]-=1
  elif i+1>=k:
    d[AA[i-k]]=max(0,d[AA[i-k]]-1)
  ans+=d[AA[i]]
  d[AA[i]]+=1
print(ans)


Measured memory_bytes: 40968
IDENTIFICATION DIVISION.
program-id. Hello.

ENVIRONMENT DIVISION.

DATA DIVISION.
    WORKING-STORAGE SECTION.
        77 N PIC XXXX.
        77 A PIC X.
        77 B PIC X.
        77 C PIC X.
        77 D PIC X.
PROCEDURE DIVISION.
ACCEPT N.
MOVE N(1:1) TO A
MOVE N(2:1) TO B
MOVE N(3:1) TO C
MOVE N(4:1) TO D

IF A = B AND B = C THEN
    DISPLAY "Yes"
    STOP RUN
ELSE IF B = C AND C = D THEN
    DISPLAY "Yes"
    STOP RUN
END-IF
END-IF

DISPLAY "No"
STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> array(H);
  for (int i = 0; i < H; i++) {
    cin >> array.at(i);
  }
  cout << string(W + 2, '#') << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' << array.at(i) << '#' << endl;
  }
  cout << string(W + 2, '#') << endl;
}

Measured memory_bytes: 256
//testing unlocked
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}
 
using namespace std;
 
 
int main(){
    
    int a, b;
    scan(a, b);
    if(a > 9 || b > 9){
        return 0*puts("-1");
    }
    print(a*b);
    
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int ans;
int n;

void f(ll x, bool flag3, bool flag5, bool flag7){
  if(x>n) return;
  if(flag3 && flag5 && flag7) ans++;
  f(10*x+3,true,flag5,flag7);
  f(10*x+5,flag3,true,flag7);
  f(10*x+7,flag3,flag5,true);
}

int main(){
  ans = 0;
  cin>>n;
  f(0,0,0,0);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;
    vs32 x(n);
    rep (i, n)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    int l = x[0];
    int r = x[n - 1];
    int ans = (int)1e9;
    int sum = 0;
    for (int p = l; p <= r; ++p)
    {
        sum = 0;
        rep (i, n)
        {
            sum += (x[i] - p) * (x[i] - p);
        }
        ans = MIN(ans, sum);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}
	long long int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

long long int lcm(long long int a, long long int b) {
	long long int L;
	L = a / gcd(a, b);
	L *= b;
	return L;
}

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	for (int i = 2; i * i <= n; i++) {
		;
		if (is_prime.at(i)) {
			for (int j = i * i; j <= n; j += i) {
				is_prime.at(j) = false;
			}
		}
		Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int keta(long long int N) {
	int k = 0;
	while (N > 0) {
		N /= 10;
		k++;
	}
	return k;
}



int Combination(int n, int m) {
	long long int s = 1, t = 1;
	int tmp = n;
	while (n - m != tmp) {
		s *= tmp;
		tmp--;
	}
	tmp = m;
	while (tmp != 1) {
		t *= tmp;
		tmp--;
	}
	return s / t;
}


int main() {
	long long int n, count = 0, beki = 5;
	string s, t;

	cin >> n;
	if (n % 2 == 1)
		cout << 0 << endl;
	else {
		n /= 2;
		while (beki <= n) {
			count += n / beki;
			beki *= 5;
		}
		cout << count << endl;
	}
}
/*n -= n % 10;
		while (beki <= n) {
			count += n / beki;
			beki *= 5;
		}
		cout << count / 2 << endl;*/

/*
int main() {
	int n; cin >> n;
	vector<int> f(n);
	vector<int> t(n,1);
	int x[15][15], y[15][15];
	int p[15][15], q[15][15];
	vector<int> a(n);
	int count = 0, ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> f.at(i);
		for (int j = 0; j < f.at(i); j++) {
			cin >> p[i][j] >> q[i][j];
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			a.at(i) = f.at(i);
			for (int j = 0; j < a.at(i); j++) {
				x[i][j] = p[i][j]; y[i][j] = q[i][j];
			}
		}

		for (int i = 0 ; i < n; i++) {
			if (t.at((i+k)%n) == 0) {
				for (int j = 0; j < a.at((i + k) % n); j++) {
					if (y[(i + k) % n][j] == 1)
						y[(i + k) % n][j] = 0;
					else
						y[(i + k) % n][j] = 1;
				}
			}
			for (int j = 0; j < a.at(i); j++) {
				a.at(x[(i + k) % n][j] - 1) *= y[(i + k) % n][j];
			}
		}
		count = 0;
		for (int i = 0; i < n; i++) {
			if (a.at(i) == 1)
				count++;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
}
*/

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  long N;in(N);
  vector<long>A(N);
  map<long,long>cnt;
  set<long>kind;
  rep(i,N){
    long t;in(t);
    A[i]=t;
    cnt[t]++;
    kind.insert(t);
  }
  cpp_int sum=0;
  for(auto e:kind)sum+=cnt[e]*(cnt[e]-1)/2;
  rep(i,N){
    if(cnt[A[i]]>1)out(sum-cnt[A[i]]*(cnt[A[i]]-1)/2+(cnt[A[i]]-1)*(cnt[A[i]]-2)/2);
    else out(sum);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 18816
#include <iostream>
using namespace std;
int main(){
	int x,y,r,W,H;
	cin>>W>>H>>x>>y>>r;
	if(H<y+r || y<0 || W<x+r || x<0){
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define int long long
using namespace std;

int N, A, B, res = 0;

int sum_digits(int x) {
  int res = 0;
  while (x > 0) {
    res += (x % 10);
    x /= 10;
  }
  return res;
}

signed main () {
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int x = sum_digits(i);
    if (A <= x && x <= B) {
      res += i;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
    string S;
    cin >> S;
    string result = "Yes";

    for(int i = 0 ; i < S.size();i++){
        if(i%2 == 0){
            if(S.at(i)=='L'){
                result = "No";
                break;
            }
        }
        else{
            if(S.at(i)=='R'){
                    result ="No";
                    break;
            }
        }
    }

    cout << result << endl;
}

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

typedef long long ll;

#define all(v)           ((v).begin()), ((v).end())
#define sz size()
#define clr(v,d)         memset(v,d,sizeof(v))
#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define sci(a)	scanf("%d",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)

const int maxn = 300500;

char st[200400];
map<string, int> ma; 
int n;

void pre(){
	string se(st + n, st + n + n);
	int m = se.size();
	for (int i = 0; i < (1 << m); i++){
		string r, b;
		for (int j = 0; j < m; j++) if (i&(1 << j)){
			b += se[j];
		}
		for (int j = m - 1; j >= 0; j--) if (!(i&(1 << j))){
			r += se[j];
		}
		ma[(b + "-" + r)]++;
	}
}


int main(){
	sci(n);
	scanf("%s", st);
	pre();
	ll ret = 0;
	for (int i = 0; i < (1 << n); i++){
		string r, b;
		for (int j = 0; j < n; j++) if (i&(1 << j)){
			b += st[j];
		}
		for (int j = n - 1; j >= 0; j--) if (!(i&(1 << j))){
			r += st[j];
		}
		ret += ma[(r + "-" + b)];
	}
	printf("%lld\n", ret); 
}

Measured memory_bytes: 67200
#include <iostream>
#include <string>
#include <set>
#include <vector>

int main(int argc, char* argv[])
{
  int c[3][3];

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      std::cin >> c[i][j];
    }
  }

  bool info = false;
  if ((c[0][0] - c[0][1]) == (c[1][0] - c[1][1]) &&
      (c[1][0] - c[1][1]) == (c[2][0] - c[2][1]) &&
      (c[2][0] - c[2][1]) == (c[0][0] - c[0][1]) &&
      (c[0][1] - c[0][2]) == (c[1][1] - c[1][2]) &&
      (c[1][1] - c[1][2]) == (c[2][1] - c[2][2]) &&
      (c[2][1] - c[2][2]) == (c[0][1] - c[0][2]) &&
      (c[0][2] - c[0][0]) == (c[1][2] - c[1][0]) &&
      (c[1][2] - c[1][0]) == (c[2][2] - c[2][0]) &&
      (c[2][2] - c[2][0]) == (c[0][2] - c[0][0])) {
    info = true;
  }

  std::cout << (info == true ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ac = a * c;
    long long ad = a * d;
    long long bc = b * c;
    long long bd = b * d;

    long long box[] = {ac, ad, bc, bd};
    long long max = box[0];
    for(int i = 1; i < 4; i++) {
        if(box[i] > max) {
            max = box[i];
        }
    }
    cout << max << endl;

}

Measured memory_bytes: 3620
import fractions
a, b, c, d = [int(i) for i in input().split()]
"""
print(b // c, b // d, b // ((c * d) // fractions.gcd(c,d)), (a-1) // c, (a-1) // d, (a-1) // ((c * d) // fractions.gcd(c,d)))
print((c * d) // fractions.gcd(c,d))
"""
print(
    b - a + 1 - 
    (b // c + b // d 
        - b // ((c * d) // fractions.gcd(c,d)) 
    - (a-1) // c - (a-1) // d 
        + (a-1) // ((c * d) // fractions.gcd(c,d)))
)


Measured memory_bytes: 5048
n_500 = int(input())
n_100 = int(input())
n_50  = int(input())
X     = int(input())

n_comb = 0
for i in range(n_500+1):
  for j in range(n_100+1):
    for k in range(n_50+1):
      comb = i*500 + j*100 + k*50
      if X == comb:
        n_comb += 1
print(n_comb)

Measured memory_bytes: 3060
import copy

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]

result = 0
rest_power = 0
for i in range(N):
    if B[i] > A[i]:
        rest_power = B[i] - A[i]
        result += A[i]
        # 次の街を見る
        mem = copy.copy(A[i + 1])
        A[i + 1] -= rest_power
        if A[i + 1] < 0:
            result += mem
            A[i + 1] = 0
        else:
            result += rest_power
    else:
        result += B[i]

print(result)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}



int g3(int X, int K) {
  // cout << X << " " << K << endl;
  int res = 0;
  if (X < K) {
    res = 0;
  } else if (X % K == 0) {
    res = X / K;
  } else {
    int p = X/K;
    res = g3(X - (p+1) * max(1, (X - p*K + 1) / (p+1)), K);
  }
  return res;
}


int main2() {
  int N = nextInt();
  ll ans = 0;
  REP(i, N) {
    int A = nextInt();
    int K = nextInt();
    ans ^= g3(A, K);
  }
  cout << (ans ? "Takahashi":"Aoki") << endl;
  return 0;
}


int memo[100][100];
int memo2[100][100];

int g(int X, int K) {
  if (memo[X][K] != -1) { return memo[X][K]; }

  set<int> s;
  for (int i = 1; i <= X / K; i++) {
    int nxt = g(X - i, K);
    s.insert(nxt);
  }
  int res = 0;
  while (s.count(res) > 0) res++;
  return memo[X][K] = res;
}

int g2(int X, int K) {
  if (memo2[X][K] != -1) { return memo2[X][K]; }
  int res = 0;
  res = (X % K == 0 ? X / K : g2(X - X/K - 1, K));
  return memo2[X][K] = res;
}
int main() {
  // CLR(memo, -1);
  // CLR(memo2, -1);
  // for (int i = 0; i <= 30; i++) cout << g(i, 1) << " "; cout << endl;
  // for (int i = 0; i <= 30; i++) cout << g2(i, 1) << " "; cout << endl;
  // for (int i = 0; i <= 30; i++) cout << g(i, 2) << " "; cout << endl;
  // for (int i = 0; i <= 30; i++) cout << g2(i, 2) << " "; cout << endl;
  // for (int i = 0; i <= 30; i++) cout << g(i, 3) << " "; cout << endl;
  // for (int i = 0; i <= 30; i++) cout << g2(i, 3) << " "; cout << endl;
  // for (int i = 0; i < 100; i++) {
  //   for (int k = 1; k < 100; k++) {
  //     if (g(i, k) != g3(i, k)) {
  //       cout << i << " " << k << " " << g(i,k) << " " << g3(i,k) << endl;
  //     }
  //   }
  // }
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main()
{
	int n; cin >> n;
	long long a[n]; for(int i = 0; i < n; i++) cin >> a[i];

	long long operation_even_pos = 0;
	long long operation_odd_pos = 0;
	long long sum_even_pos = 0;
	long long sum_odd_pos = 0;

	for(int i = 0; i < n; i++){
		sum_even_pos += a[i];
		sum_odd_pos += a[i];

		if(!(i % 2) && sum_even_pos <= 0){ /* when it's an even number index */
			operation_even_pos += 1 - sum_even_pos;
			sum_even_pos = 1;
		}else if((i % 2) && sum_even_pos >= 0){ /* when it's an odd number index */
			operation_even_pos += sum_even_pos + 1;
			sum_even_pos = -1;
		}

		if(!(i % 2) && sum_odd_pos >= 0){ /* when it's an even number index */
			operation_odd_pos += sum_odd_pos + 1;
			sum_odd_pos = -1;
		}else if((i % 2) && sum_odd_pos <= 0){
			operation_odd_pos += 1 - sum_odd_pos;
			sum_odd_pos = 1;
		}
	}

	cout << min(operation_even_pos, operation_odd_pos) << endl;

	return 0;
}

Measured memory_bytes: 1024