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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int add(int x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	return x;
}

int sub(int x, int y) {
	x -= y;
	if (x < 0)
		x += mod;
	return x;
}

int mul(ll x, ll y) {
	return x * y % mod;
}

int bin(int x, int a) {
	int y = 1;
	while (a) {
		if (a & 1)
			y = mul(y, x);
		x = mul(x, x);
		a >>= 1;
	}
	return y;
}

const int M = 500;
	
int n, c, a[M], b[M];
int d[M][M];
int h[M][M];

void pre() {
	for (int k = 0; k < M; ++k)
		for (int i = 1; i < M; ++i) {
			h[k][i] = add(bin(i, k), h[k][i - 1]);
	}
}

int sum(int l, int r, int k) {
	return sub(h[k][r], h[k][l - 1]);
}

void read() {
	cin >> n >> c;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
}

void kill() {
	d[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		vector<int> s(c + 1);
		for (int k = 0; k <= c; ++k)
			s[k] = sum(a[i - 1], b[i - 1], k);
		
		for (int j = 0; j <= c; ++j)
			for (int b = 0; j + b <= c; ++b) {
				int to = j + b;
				d[i][to] = add(d[i][to], mul(d[i - 1][j], s[b]));
			}
	}
	
	cout << d[n][c] << endl;
}

int main() {
	pre();
	read();
	kill();	
	return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc109_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<string>();
            string str = Console.ReadLine();
            char c = str[str.Length-1];
            list.Add(str);

            for (int i = 0; i < n-1; i++)
            {
                str = Console.ReadLine();
                for (int j = 0; j < list.Count; j++)
                {
                    if(str == list[j]){
                        WriteLine("No");
                        return;
                    }
                }
                list.Add(str);

                if(str[0] != c){
                    WriteLine("No");
                    return;
                }
                c = str[str.Length-1];
            }
            WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)
#define INF LONG_LONG_MAX

signed main()
{
    FIO;
    string str;deque<char> q;
    cin>>str;
    for(ll i=0;i<str.length();i++)
    {
        if(str[i]=='1')
        q.pb('1');
        else if(str[i]=='0')
        q.pb('0');
        else if(str[i]=='B' and !q.empty())q.pop_back();
    }
    while(!q.empty())
    {
        cout<<q.front();
        q.pop_front();
    }
}

Measured memory_bytes: 3504
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int T, X;
    std::cin >> T >> X;

    std::printf("%.10lf\n", (double)T / (double)X);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

// (a ^ b) % mod
ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}

pll arr[100010];

void disp_bin(int a) {

	for (int i = 31; i >= 0; i--) {
		cout << ((a >> i) & 1);
	}
	cout << endl;

	return;
}

int main() {

	ll n,k,answer = 0;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> arr[i].first >> arr[i].second;
		if (((k & arr[i].first) ^ arr[i].first) == 0) {
			answer += arr[i].second;
		}
	}

	for (int i = 1; i <= 32; i++) {
		if (k >> (32 - i) & 1) {//1
			ll tmp = 0;
			int kr = k - (1 << (32 - i));
			kr |= (1 << (32 - i)) - 1;

			//disp_bin(kr);

			for (int i = 0; i < n; i++) {
				if (((kr & arr[i].first) ^ arr[i].first) == 0) {
					tmp += arr[i].second;
				}
			}

			answer = max(answer,tmp);
		}
	}

	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 1792
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
Q = gets.chomp.to_i
M = gets.chomp.split(" ").map(&:to_i)

def solve(i, m)
  if m == 0
    return true
  end
  if i >= N
    return false
  end
  res = solve(i+1, m) || solve(i+1, m-A[i])
  return res
end

Q.times do |ind|
  if solve(0, M[ind])
    puts "yes"
  else
    puts "no"
  end
end

Measured memory_bytes: 8708
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        if(s[2] == s[3] && s[4] == s[5])
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
    
    return 0;
}



Measured memory_bytes: 3552
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const int nax=1000*1007;

int n;

int tab[nax];

int main()
{
	scanf("%d", &n);
	int wyn=0;
	for (int i=1; i<=n; i++)
	{
		scanf("%d", &tab[i]);
		if (tab[i]==tab[i-1])
		{
			tab[i]=-i;
			wyn++;
		}
	}
	printf("%d\n", wyn);
	return 0;
}


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

int main() {
    int x,n;
    cin >> x >> n;

    vector<int> pv;
    for(int i=0; i<n; ++i){
        int p;
        cin >> p;
        pv.push_back(p);
    }

    for(int d=0; d<100; ++d){
        for(int r=0; r<2; ++r){
            bool ok = true;
            int y = x + ((r==0) ? -d : d);
            for(int i=0; i<n; ++i){
                if(pv[i] == y){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << y << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

Measured memory_bytes: 2692
#include <stdio.h>

int main(void){

  long s;
  scanf("%ld", &s);
  int check[1000000+1];
  for (long i = 0; i < 1000000+1; i++) {
    check[i] = 0;
  }
  long current = s;
  check[s]++;
  for (long i = 2; ; i++) {
    if (s%2 == 0) {
      s /= 2;
    } else {
      s = s*3+1;
    }
    if (check[s] == 1) {
      printf("%ld\n", i);
      break;
    } else {
      check[s]++;
    }
  }

  return 0;
}

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

public class Main{

	
	static long solve(long r,int idx) {
		if(r<=0)
			return 0;
		long ans=0,z=1L<<idx;
		for(int bit=60;bit>=0;bit--) {
			long x=1L<<bit;
			if(bit==idx || (r&x)==0)
				continue;
			if(bit<idx && (r&z)==0)
				break;
			if(bit>idx)
				ans+=x>>1;
			else
				ans+=x;
				
		}
		if((z&r)>0)
			ans++;
		return ans;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		
		long L=sc.nextLong(),R=sc.nextLong();
		long ans=0;
		for(int bit=60;bit>=0;bit--) {
			long x=solve(R,bit)-solve(L-1,bit);
			if(x%2==1)
				ans+=1L<<bit;
		}
		out.println(ans);
	
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 24532
A, B = map(int,input().split())
ans = [['#' for i in range(100)] for j in range(50)] + [['.' for i in range(100)] for j in range(50)]
for x in range(A-1):
    i = x // 25
    j = 2 * (i % 2) + 4 * (x % 25)
    ans[i][j] = '.'
for x in range(B-1):
    i = 99 - x // 25
    j = 2 * (i % 2) + 4 * (x % 25)
    ans[i][j] = '#'
print(*[100, 100])
for i in range(100):
    print(''.join(ans[i]))

Measured memory_bytes: 3064
import kotlin.math.pow

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val x = readLong()

    val a = Array(120) { it.toDouble().pow(5).toLong() }
    for (i in 0 until 120) {
        for (j in i + 1 until 120) {
            if (a[j] - a[i] == x) {
                println("$j $i")
                return
            }
            if (a[j] + a[i] == x) {
                println("$j -$i")
                return
            }
        }
    }
}


Measured memory_bytes: 34524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

const ll inf = 1e18 + 5;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	ll sum=0;
	for(int i=0; i<n; i++)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	vector<ll> dp(sum+1, inf);
	dp[0]=0;
	for(int item = 0; item<n; item++)
	{
		for(int j=sum; j>=0; j--)
		{
			if(dp[j]>=0 && j+v[item] <= sum)
			{
				dp[j+v[item]] = min(dp[j+v[item]],dp[j]+w[item]);
			}
		}
	} 
	//traceloop(sum,dp);
	ll ans = 0;
	for(int i=0; i<=sum; i++)
		if(dp[i]<=W)
			ans = max(ans,(ll)i);
	cout<<ans;
	return 0;
}
	

Measured memory_bytes: 1024
import math
def is_prime(n):
    if n == 2:
        return True
    if (n < 2) or (n % 2 == 0):
        return False
    stop = math.floor(math.sqrt(n)) + 1
    for i in range(3, stop, 2):
        if n % i == 0:
            return False
    return True

x = int(input())
while not is_prime(x):
    x += 1
print(x)        

Measured memory_bytes: 3060
n = int(input())

ans = 0

table = [[0]*10 for _ in range(10)]

for number in range(1, n+1):
    i = int(str(number)[0])
    j = int(str(number)[-1])
    table[i][j] += 1

for i in range(1,10):
    for j in range(1, 10):
        ans += table[j][i] * table[i][j]
print(ans)



Measured memory_bytes: 3060
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;



int main(void) {
	int n,cnt=0,ans=0;
	string s;
	cin >> n >> s;
	vint x(26),y(26);
	for (int i = 0; i < n; i++) {
		y[s[i] - 97]++;
	}
	for (int i = 0; i < n; i++) {
		if (x[s[i] - 97] == 0) {
			x[s[i] - 97]++;
			y[s[i] - 97]--;
			if (x[s[i] - 97] != 0 && y[s[i] - 97] != 0) {
				cnt++;
				ans = max(ans, cnt);
			}
		}
		else {
			x[s[i] - 97]++; 
			y[s[i] - 97]--;
			if (y[s[i] - 97] == 0) {
				cnt--;
			}
		}
		

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  if(n % 2) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  n /= 2;
  while(n) {
    ans += n / 5;
    n /= 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll N; cin >> N;
    string S; cin >> S;

    ll cntR=0, cntG=0, cntB=0;

    REP(i,N){
        if(S[i]=='R') cntR++;
        if(S[i]=='G') cntG++;
        if(S[i]=='B') cntB++;
    }

    ll ans=cntR*cntG*cntB;

    for(ll i=0; i<N; i++){
        for(ll j=1; j<N; j++){
            if(i+2*j < N && S[i]!=S[i+j] && S[i]!=S[i+2*j] && S[i+2*j]!=S[i+j]) ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
N,M,K = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a, b =[0],[0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j =0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

int a[105];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n=read();
	rep(i,1,n)a[i]=read();
	int sum=0;
	rep(i,1,n)sum+=a[i];
	pii mn={1e9,0};
	rep(i,1,n)chmin(mn,{abs(n*a[i]-sum),i});
	cout<<mn.second-1;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	int w;
	cin >> w;

	string ret = "";
	rep(i, S.size()) {
		if (i % w == 0) {
			ret += S[i];
		}
	}

	cout << ret << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int a,b,h,ans;

    while(scanf("%d %d %d",&a,&b,&h)==3)
    {
        ans=((a+b)*h)/2;

        printf("%d\n",ans);
    }

    return (0);
}


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

int main()
{
    int N;
    cin >> N;
    string Si;
    int Pi;
    set<tuple<string, int, int>> s;
    for(int i=0;i<N;i++){
        cin >> Si >> Pi;
        s.insert(make_tuple(Si, -Pi, i+1));
    }
    for(auto x : s){
        cout<<get<2>(x)<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int l;
  cin>>l;
  double ans=0;
  if(l%3==0){
    cout<<(double)l/3*l/3*l/3;
  }
  else {
    double k=double(l)-double(l)/3.0*2;
    //cerr<<k<<endl;
    cout<<k*double(l)/3.0*double(l)/3.0;
  }
  //cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  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);
		String a = sc.next();
		int[] x = new int[4];
		for(int i = 0 ; i < 4 ; i++) {
			x[i] = a.charAt(i) - '0';
		}
		for(int i = 0 ; i < 8 ; i++) {
			int sum = x[0];
			String s = "" + (char)(x[0] + '0');
			for(int j = 0 ; j < 3 ; j++) {
				if((i & (1 << j)) == 0) {
					sum += x[j + 1];
					s += '+';
					s += "" + (char)(x[j + 1] + '0');
				} else {
					sum -= x[j + 1];
					s += '-';
					s += "" + (char)(x[j + 1] + '0');
				}
			}
			if(sum == 7) {
				s += '=';
				s += '7';
				System.out.println(s);
				return;
			}
		}
	}
}

Measured memory_bytes: 23380
(defun calc (n hs lst)
  (let ((arr (make-array n
                         :initial-contents
                         (loop repeat n collect 1))))
       (loop for i in lst
             do (cond 
                  ((= (aref hs (1- (car i)))
                      (aref hs (1- (cadr i))))
                   (setf (aref arr (1- (car i))) 0
                         (aref arr (1- (cadr i))) 0))
                  ((< (aref hs (1- (car i)))
                      (aref hs (1- (cadr i))))
                   (setf (aref arr (1- (car i))) 0))
                  ((> (aref hs (1- (car i)))
                      (aref hs (1- (cadr i))))
                   (setf (aref arr (1- (cadr i))) 0)))
             finally (return (apply #'+ (loop for i below n
                                              collect (aref arr i)))))))

(let* ((n (read))
       (m (read))
       (hs (make-array n
                       :initial-contents
                       (loop repeat n collect (read))))
       (lst (loop repeat m
                  collect (list (read) (read)))))
      (format t "~A" (calc n hs lst)))


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

# 階乗
def fact(n, mod):
    ans = 1
    for i in range(1, n+1):
        ans = (ans*i) % mod
    return ans

# 繰り返し２乗法
def pow(a, n, mod):
    if n == 0:
        return 1
    if n%2 == 0:
        t = pow(a, n//2, mod)
        return t*t % mod
    return a * pow(a, n-1, mod)


# 組み合わせ
def comb(n, a, mod):
    val = pow(fact(a, mod), mod-2, mod)

    p = 1
    for i in range(a):
        p = (p*(n-i)) % mod
    return val*p %mod


mod = 10**9+7
allptn = pow(2, n, mod)
aptn = comb(n, a, mod)
bptn = comb(n, b, mod)

ans = (allptn-1 - aptn - bptn) % mod
print(ans)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int redNum = Integer.parseInt(sc.next());
        List<String> nameList = new ArrayList();
        List<String> redList = new ArrayList();
        for(int x = 1; x<= redNum; x++) {
            String name = sc.next();
            nameList.add(name);
            redList.add(name);
        }
        
        int blueNum = Integer.parseInt(sc.next());
        List<String> blueList = new ArrayList();
        for(int x = 1; x<= blueNum; x++) {
            String name = sc.next();
            nameList.add(name);
            blueList.add(name);
        }
        
        int x=1;
        
        int res = 0;
        loop:for(String name :nameList) {
            for(int y=1; y<x; y++) {
                if (nameList.get(y-1).equals(name)) {
                    x++;
                    continue loop;
                }
            }
            int money = 0;
            for(String blueName : blueList) {
                    if(blueName.equals(name)) {
                     money--;   
                }
            }
            for(String redName : redList) {
                if(redName.equals(name)) {
                    money++;   
                }
            }
            res = res >= money?res:money;
        }
        
        System.out.println(res);
    }
}

Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 20
int n;
pii a[MN];
vpii odd;
vpii ev;

int rec(int cur, int cnt){
    if(cnt > (n+1)/2) return INF;
    if(cur == n){
        if(cnt != (n+1)/2) return INF;

        //cout << "hmm\n";

        vpii oc(odd);
        vpii ec(ev);

        sort(oc.begin(), oc.end());
        sort(ec.begin(), ec.end());
        /*for(auto u : oc) cout << u.f << " ";
        cout << "\n";
        for(auto u : ec) cout << u.f << " ";
        cout << "\n";*/

        int pre = 0;
        vi fin;
        F0R(i, n){
            if(i % 2 == 0){
                if(oc[i/2].f < pre) return INF;
                fin.pb(oc[i/2].s);
                pre = oc[i/2].f;
            } else{
                if(ec[i/2].f < pre) return INF;
                fin.pb(ec[i/2].s);
                pre = ec[i/2].f;
            }
        }
        /*for(auto u : fin) cout << u << " ";
        cout << "\n";*/
        int sm = 0;
        F0R(i, n){
            int dif = fin[i]-i;
            sm += dif;
            //cout << "adding " << dif << "\n";
            FOR(j, i+1, n-1){
                if(fin[j] < fin[i]) ++fin[j];
            }
        }

        //cout << sm << "\n";
        return sm; //REE
    }
    int val = INF;
    int f, s;
    f = a[cur].f; s = a[cur].s;
    if(cur % 2) swap(f, s);
    
    //cout << cur << "even\n";
    ev.pb(mp(s, cur));
    val = min(val, rec(cur+1, cnt));
    ev.pop_back();

    //cout << cur << "odd\n";
    odd.pb(mp(f, cur));
    val = min(val, rec(cur+1, cnt+1));
    odd.pop_back();
    return val;
}

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

    cin >> n;
    F0R(i, n){
        cin >> a[i].f;
    }
    F0R(i, n){
        cin >> a[i].s;
    }

    int resp = rec(0, 0);
    if(resp == INF) cout << "-1\n";
    else cout << resp << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        Long r = 0l;
        Long l = 0l;
        Long res = 0l;
        for(int i = 0;i < S.length();i++){
            if(S.charAt(i) == '<'){
                if(l > 0l){
                    if(r > l){
                        res = res + ((r * (r + 1)) + (l * (l - 1))) / 2;
                    }else{
                        if(r != 0l){
                            res = res + ((r * (r - 1)) + (l * (l + 1))) / 2;
                        }else{
                            res = res + (l * (l + 1)) / 2;
                        }
                    }
                    r = 0l;
                    l = 0l;
                }
                r++;
            }else{
                l++;
            }
        }
        if(r > 0l || l > 0l){
            if(r > 0l && l > 0l){
                if(r > l){
                    res = res + ((r * (r + 1)) + (l * (l - 1))) / 2;
                }else{
                    res = res + ((r * (r - 1)) + (l * (l + 1))) / 2;
                }
            }else if(r > 0l){
                res = res + (r * (r + 1)) / 2;
            }else{
                res = res + (l * (l + 1)) / 2;
            }
        }
        
        System.out.println(res);
    }
}


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

long long gcd(long long x, long long y)
{
    if(y % x == 0)
        return x;
    else
        return gcd(y % x, x);
}

int n, x;
long long arr[100005];

int main()
{
    while(cin >> n >> x)
    {
        for(int i = 0; i < n; i++)
        {
            cin >> arr[i];
            arr[i] = abs(arr[i] - x);
        }
        int cur = arr[0];
        for(int i = 1; i < n; i++)
        {
            cur = gcd(arr[i], cur);
            if(cur == 1)
                break;
        }
        cout << cur << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    ll n,k;
    cin>>n>>k;
    long long temp=n/k;
    temp=min(fabs(temp*k-n),fabs((temp+1)*k-n));
    // cout<<fabs(temp*k-n)<<' '<<fabs((temp+1)*k-n);
    cout<<temp;
}



Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  print(n*800 - (n/15)*200);
  return 0;
}

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

#define PI 3.14159265359

double A, B, H, M;
int main(){
	cin >> A >> B >> H >> M;

	double asita = 2 * PI * H / 12.0 + (2.0*PI/12 * M/60);
	double ax = A * cos(asita);
	double ay = A * sin(asita);

	double bsita = 2 * PI * M / 60.0;
	double bx = B * cos(bsita);
	double by = B * sin(bsita);

	double ans = sqrt((ax-bx) * (ax-bx) + (ay-by) * (ay-by));
	printf("%.10f\n", ans);
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////

int32_t main() {
    int a,b; cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a*b << "\n";
    } else {
        cout << -1 << "\n";
    }
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(BiscuitGenerator());
    }

    private static int BiscuitGenerator()
    {
        int A = 0, B = 0, T = 0;

        readData(ref A, ref B, ref T);

        return T / A * B;
    }

    /// <summary>
    /// データを読み込む
    /// </summary>
    private static void readData(ref int A, ref int B, ref int T)
    {
        int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        A = line[0];
        B = line[1];
        T = line[2];
    }
}




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

const long long mod = (long long)1e9 + 7;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//const long long mod = (long long)1e9 + 7;
int main()
{
	long long s;
	cin >> s;
	
	long long dp[2005];
	
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = 0;
	dp[3] = 1;
	for(int i=4;i<=s;++i){
	    dp[i] = 1;
		for(int j = 3; j <= i; j++)
		{
		    if(i - j >= 3)
		    {
		        dp[i] = (dp[i] + dp[j]) % mod;
		    }
		}
	}
	cout<<dp[s] << endl;
	
	
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int dp[11][8][2];
int pow(int x,int y){
    if(y==0) return 1;
    else return x*pow(x,y-1);
}
int main(){
    string N;
    cin >> N;
    int d=N.size();
    vector<int> n(d);
    rp(i,d) n[i]=N[i]-'0';
    
    dp[0][0][0]=1;
    for(int i=0; i<d; i++){
        rp(j,8){
            for(int smaller=0; smaller<=1; smaller++){
                if(!smaller&&n[i]<3) continue;
                dp[i+1][j|1][smaller||(3<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<5) continue;
                dp[i+1][j|2][smaller||(5<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<7) continue;
                dp[i+1][j|4][smaller||(7<n[i])]+=dp[i][j][smaller];
            }
        }
    }
    int ans=0;
    for(int i=3; i<d; i++){
        ans+=pow(3,i)-3*pow(2,i)+3;
    }
    ans+=dp[d][7][0]+dp[d][7][1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ma 1e18
int main()
{lli i,n,j;
 cin>>n;
 lli dp[n][3];
 lli a[n][3];
 for(i=0;i<n;i++)
 {for(j=0;j<3;j++)
 {cin>>a[i][j];
 }
 }
 dp[0][0]=a[0][0];
 dp[0][1]=a[0][1];
 dp[0][2]=a[0][2];

 for(i=1;i<n;i++)
 {for(j=0;j<3;j++)
 {dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
 
 }}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
sys.setrecursionlimit(900000)


N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
PX = [list(map(int, input().split())) for _ in range(Q)]

def dfs(p, s, checked, score):
    #print(p, s, score)
    ns = s + score[p]
    score[p] += s
    for q in graph[p]:
        if not checked[q]:
            checked[q] = True
            score = dfs(q, ns, checked, score)
    return score


def main():


    score = [0 for _ in range(N)]
    for p, x in PX:
        score[p-1] += x

    checked = [False for _ in range(N)]
    checked[0] = True
    
    ans = dfs(0, 0, checked, score)
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 284052
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"


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

  std::cin >> N>>K;

  if (N % K ==0) {
    std::cout << 0 << '\n';
  }else{
    std::cout << 1 << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,k;
long long a[200005];
long long ans=0;
bool cmp(long long x,long long y)
{
    return x>y;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1,cmp);
    
    for(int i=k+1;i<=n;i++)
    {
        ans+=a[i];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

cnt = 0

def main():
    N, M = map(int, input().split())
    m = {}
    for l in sys.stdin:
        m[int(l.strip())] = True

    # N 個の階段における移動方法
    dp = [0 for _ in range(N+1)]
    dp[0] = 1
    dp[1] = 1 if 1 not in m else 0

    # N-1の移動パターン + N-2の移動パターン
    for i in range(2, N+1):
        if i in m:
            dp[i] = 0
            continue
        dp[i] = dp[i-1] + dp[i-2]
    print(dp[N] % 1000000007)

main()


Measured memory_bytes: 460056
// https://agc026.contest.atcoder.jp/tasks/agc026_c
#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;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

seed_seq seq {
  uint64_t(chrono::duration_cast<chrono::nanoseconds>(
    chrono::steady_clock::now().time_since_epoch()).count()
  ),
  uint64_t(__builtin_ia32_rdtsc()),
  uint64_t(uintptr_t(make_unique<char>().get()))
};

mt19937 rng(seq); mt19937_64 rng64(seq);

const size_t RANDOM = uniform_int_distribution<size_t>(
    0, numeric_limits<size_t>::max())(rng64);
struct rand_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);
  }
  template <class T> size_t operator () (const T &x) const {
    return splitmix64(hash<T>()(x) + RANDOM);
  }
  template <class T1, class T2>
  size_t operator () (const pair<T1, T2> &p) const {
    return 31 * operator ()(p.first) + operator ()(p.second);
  }
};

template <class K, class H = rand_hash, class ...Ts>
using hashset = gp_hash_table<K, null_type, H, Ts ...>;
template <class K, class V, class H = rand_hash, class ...Ts>
using hashmap = gp_hash_table<K, V, H, Ts ...>;

int N;
string S;
hashmap<pair<string, string>, ll> M;

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> N >> S;
  for (int i = 0; i < (1 << N); i++) {
    string red, blue;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) red.push_back(S[j]);
      else blue.push_back(S[j]);
    }
    reverse(blue.begin(), blue.end());
    M[make_pair(red, blue)]++;
  }
  ll cnt = 0;
  for (int i = 0; i < (1 << N); i++) {
    string red, blue;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) red.push_back(S[N + j]);
      else blue.push_back(S[N + j]);
    }
    reverse(blue.begin(), blue.end());
    cnt += M[make_pair(blue, red)];
  }
  cout << cnt << nl;
  return 0;
}


Measured memory_bytes: 249208
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    count_min=int(i*(i-1)/2)
    count_max=int(i*(2*n-i+1)/2)
    ans+=count_max-count_min+1
    ans%=10**9+7
if ans<10**9+7:
    print(ans)
else:
    print(ans%10**9+7)

Measured memory_bytes: 64748
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**
模拟#前缀和 
定义两个数组x y记录方格中各个数字的下标 
定义ans记录l->r之间的消耗 
**/
int h,w,d,q,l,r;
int s[305][305];
int x[90001],y[90001];
ll dp[90001];//记录前缀和 
int main()
{
    cin >> h >> w >> d;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin >> s[i][j];
            x[s[i][j]] = i;
            y[s[i][j]] = j;
        }
    }
    for(int i=1+d;i<=h*w;i++)
    {
        dp[i] = dp[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
    }
    cin >> q;
    for(int i=0;i<q;i++)
    {
        cin >> l >> r;
        printf("%lld\n",abs(dp[l] - dp[r]));
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    cout << N * N * N << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void swap(int *a, int *b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}
 
void sort(int *c, int *d)
{
    if (*c > *d)
        swap(c, d);
}
 
int main(void) 
{
    int x, y;
    while (std::cin >> x >> y) {
        if (x == 0 && y == 0)
            break;
        if (x > y) {
            sort(&x, &y);
            cout << x << " " << y << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3012
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

x.sort()
y = []
for i in range(m-1):
    y.append(x[i+1] - x[i])

y.sort()


'''
for i in range(n-1):
    y.remove(max(y))
'''
if m > n: w = sum(y[:m-n])
else: w = 0
print(w)


Measured memory_bytes: 13968
N = int(input())
A = [int(i) for i in input().split()]

def insertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join([str(i) for i in A]))

insertionSort(A, N)

Measured memory_bytes: 7720
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int a[10],n,m;

int main() {
    cin>>n>>m;
    if(n==1 && !m){cout<<0<<endl; return 0;}
    memset(a,-1,sizeof(a));
    bool f=0;
    for(int i=1;i<=m;i++){
        int s,c;
        cin>>s>>c;
        if(n!=1 && s==1 && c==0)f=1;
    	else if(a[s]==-1)a[s]=c;
        else f=a[s]==c?0:1;
    }
    if(f){cout<<"-1\n"; return 0;}
    string ans="";
    for(int i=1;i<=n;i++){
        if(a[i]==-1 && i==1)a[i]=1;
        else if(a[i]==-1)a[i]=0;
        ans+=a[i]+'0';
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
ll X, Y;

void solve(){
	if(abs(X - Y) <= 1)
		cout << "Brown" << endl;
	else
		cout << "Alice" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> X >> Y;
		solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int red =count(s.begin(),s.end(),'R');
    int blue =count(s.begin(),s.end(),'B');
    if(red>blue) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<double> pal(N);
  
  for(int i = 0; i < N; i++){
    cin >> pal.at(i);
  }
  
  for(int i=0; i<N; i++){
    pal.at(i) = abs(A - (T - pal.at(i)*0.006));
  }
  
  int min = 0;
  for(int i=0; i<N; i++){
    if(pal.at(min) > pal.at(i)){
      min = i;
    }
  }
  
  cout << min + 1 << endl;
  
  
}


Measured memory_bytes: 256