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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


struct UnionFind{

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1) {}

	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	int size(int x){
		return -data[ root(x) ];
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	ll N, M, ans=0;
	ll a[100005];
	UnionFind uf(100005);

	cin >> N >> M;
	rep(i,N) cin >> a[i];
	rep(i,M){
		int x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}

	bool f = true;
	rep(i,N) if( !uf.find(0,i) ) f = false;
	if(f){
		cout << 0 << endl;
		return 0;
	}

	priority_queue<int, vector<int>, greater<int>> que[100005];
	rep(i,N) que[ uf.root(i) ].push( a[i] );

	int cnt = 0;
	rep(i,N) if( !que[i].empty() ){
		ans += que[i].top();
		que[i].pop();
		cnt++;
	}
	priority_queue<int, vector<int>, greater<int>> other;
	rep(i,N) while( !que[i].empty() ){
		other.push( que[i].top() );
		que[i].pop();
	}
	rep(i,cnt-2){
		if( other.empty() ){
			cout << "Impossible" << endl;
			return 0;
		}
		ans += other.top();
		other.pop();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int m = 0;
  vector<P>ans;
  vector<vector<bool>>data(n,vector<bool>(n,true));
  rep(i,0,n) data[i][i] = false;
  rep(i,0,n/2){
    if(n%2 == 0) data[i][n-i-1] = data[n-i-1][i] = false;
    else data[i][n-i-2] = data[n-i-2][i] = false;
  }
  rep(i,0,n) rep(j,0,n){
    if(data[i][j]){
      m++;
      ans.push_back(P(i+1,j+1));
      data[j][i] = false;
    }
  }
  cout << m << endl;
  rep(i,0,ans.size()) cout << ans[i].first << " " << ans[i].second << endl;
}

Measured memory_bytes: 3632
main(s,t,T){double x,y;
	for(t=90;scanf("%d,%d",&s,&T),s||T;t-=T)x+=s*cos(t*.01745),y+=s*sin(t*.01745);
	printf("%d\n%d\n",(int)x,(int)y);
	exit(0);
}

Measured memory_bytes: 604
xmax,ymax,N=map(int,input().split())
xmin=0
ymin=0

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        xmin=max(xmin,x)
    elif a==2:
        xmax=min(xmax,x)
    elif a==3:
        ymin=max(ymin,y)
    else:
        ymax=min(ymax,y)
print(max(0,(xmax-xmin))*max(0,(ymax-ymin)))

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String yama;
		int m,h;
		while(true){
			yama=sc.next();
			if(yama.equals("-"))break;
			m=sc.nextInt();
			for(int i=0;i<m;i++){
				h=sc.nextInt();
				yama=yama.substring(h)+yama.substring(0,h);
			}
			System.out.println(yama);
		}
	}
}

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

int main(void){
  int n,m;
  int a[100][100], b[100];
  cin >> n >> m;
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  for (int i=0; i<m; i++){
    cin >> b[i];
  }
  for (int i=0; i<n; i++){
    int ans=0;
    for (int j=0; j<m; j++){
      ans += a[i][j]*b[j];
    }
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int A[1010][1010];
int now[1010];
int n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=1;i<=n;i++) now[i]=1;
    vector<pair<int,int>  >v;
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            if(A[i][1]==j&&A[j][1]==i) v.push_back(make_pair(i,j));
        }
    }
    for(int i=1;i<=(n*n-n)/2;i++){
        vector<pair<int,int> > v2;
        while(!v.empty()){
            int a=v[v.size()-1].first;
            int b=v[v.size()-1].second;
            v.pop_back();
            now[a]++;now[b]++;
            int tmp=A[a][now[a]];
            if(A[tmp][now[tmp]]==a) v2.push_back(make_pair(a,tmp));
            tmp=A[b][now[b]];
            if(A[tmp][now[tmp]]==b) v2.push_back(make_pair(b,tmp));
        }
        swap(v,v2);v2.clear();
        if(v.empty()){
            bool flag=false;
            for(int i=1;i<=n;i++){
                if(now[i]!=n) flag=true;
            }
            if(flag) return 0*printf("-1");
            else return 0*printf("%d",i);
        }
    }



    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int g(int a, vector<int> va) {
    unordered_map<int, int> um1, um2;
    for (auto node : va) {
        um2 = um1;
        for (auto p : um1) {
            if (um2.find(p.first + node) == um2.end() || p.second + 10 < um2[p.first + node]) {
                um2[p.first + node] = p.second + 10;
            }
        }
        um1 = um2;
        um1[node] = 0;
    }
    int res = -1;
    for (auto p : um1) {
        int r = p.second + abs(p.first - a);
        if (res == -1 || r < res) {
            res = r;
        }
    }
    return res;
}

void f(int index, const vector<int>& v, int a, int b, int c, vector<int> va, vector<int> vb, vector<int> vc, int& res) {
    if (index == v.size()) {
        if (va.empty() || vb.empty() || vc.empty()) return;
        int cost = 0;
        cost += g(a, va);
        cost += g(b, vb);
        cost += g(c, vc);
        if (res == -1 || cost < res) res = cost;
        return;
    }

    va.push_back(v[index]);
    f(index + 1, v, a, b, c, va, vb, vc, res);
    va.pop_back();
    vb.push_back(v[index]);
    f(index + 1, v, a, b, c, va, vb, vc, res);
    vb.pop_back();
    vc.push_back(v[index]);
    f(index + 1, v, a, b, c, va, vb, vc, res);
    vc.pop_back();
}

int main() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v.push_back(t);
    }

    vector<int> va, vb, vc;
    int res = -1;
    f(0, v, a, b, c, va, vb, vc, res);
    cout << res << endl;
}


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

void solve(std::string s, std::string t)
{
    ll N = s.size();
    ll M = t.size();
    vector<vec> dp(N + 1, vec(M + 1, -1e+18));
    vector<vector<pair<ll, ll>>> back(N + 1, vector<pair<ll, ll>>(M + 1, pair<ll, ll>(-1, -1)));
    dp[0][0] = 0;
    for (ll i = 0; i <= N; i++)
    {
        for (ll j = 0; j <= M; j++)
        {
            if (i + 1 <= N and dp[i + 1][j] < dp[i][j])
            {
                dp[i + 1][j] = dp[i][j];
                back[i + 1][j] = {i, j};
            }
            if (j + 1 <= M and dp[i][j + 1] < dp[i][j])
            {
                dp[i][j + 1] = dp[i][j];
                back[i][j + 1] = {i, j};
            }
            if (i + 1 <= N and j + 1 <= M and s[i] == t[j])
            {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                back[i + 1][j + 1] = {i, j};
            }
        }
    }

    // Back Track
    string ans;
    ll ci = N;
    ll cj = M;
    while (dp[ci][cj] != 0)
    {
        pair<ll, ll> b = back[ci][cj];
        ll pi = b.first;
        ll pj = b.second;
        if (dp[ci][cj] == dp[pi][pj] + 1) //(pi + 1 == ci and pj + 1 == cj)
        {
            //cout << ci << "," << cj << endl;
            ans = s.substr(ci - 1, 1) + ans;
        }
        ci = pi;
        cj = pj;
    }
    cout << ans << endl;
}

signed main()
{
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i, n){
        cin >> a[i];
    }

    vector<int> left(n);
    vector<int> right(n);

    left[0] = a[0];
    right[n - 1] = a[n - 1];

    for(int i = 1; i <= n - 1; i++){
        left[i] = left[i - 1] xor a[i];
    }

    for(int i = n - 2; i >= 0; i--){
        right[i] = right[i + 1] xor a[i];
    }

    rep(i, n){
        if(i == 0){
            cout << right[1] << " ";
        }else if(i == n - 1){
            cout << left[n - 2] << endl;
        }else{
            cout << (left[i - 1] xor right[i + 1]) << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a[3];cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout << a[0]+a[1];
}


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

public class Main {

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long[]d=new long[n];
		for(int i=0;i<n;i++) {
			d[i]=sc.nextLong();
		}
		int m=sc.nextInt();
		Arrays.sort(d);
		long[]t=new long[m];
		for(int i=0;i<m;i++) {
			t[i]=sc.nextLong();
		}
		Arrays.sort(t);
		if(n<m) {
			System.out.println("NO");
			return;
		}else {
			int i=0;
			int j=0;
			int count=0;
			while(i<=n-1 && j<=m-1) {
				if(d[i]==t[j]) {
					i++;
					j++;
					count++;
				}else if(d[i]<t[j]){
					i++;
				}else {
					j++;
				}
				//System.out.println(i+" "+j);
			}
			//System.out.println(count);
			if(count==m) {
				System.out.println("YES");
				return;
			}else {
				System.out.println("NO");
				return;
			}
			
		}
	}
}

Measured memory_bytes: 106116
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a * b << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

long long M = 1000000007;

int n;
typedef vector<vector<long long>> Mat;

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    string s;cin>>s;
    vector<vector<long long>> dp(n+1,vector<long long>(n+1,0));
    dp[0][0] = 1;
    for(int i=0;i<n-1;++i){
        if(s[i]=='<'){
            dp[i+1][0] = 0;
            for(int k=1;k<=i+1;++k){
                dp[i+1][k] = dp[i+1][k-1] + dp[i][k-1];
                dp[i+1][k] %= M;
            }
        }
        else{
            dp[i+1][i+1] = 0;
            for(int k=i;k>-1;--k){
                dp[i+1][k] = dp[i+1][k+1] + dp[i][k];
                dp[i+1][k] %= M;
            }
        }
    }
    long long res = 0;
    for(int i=0;i<n;++i){
        res += dp[n-1][i];
        res %= M;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 70784
N=int(input())
a=list(input().split())
b=[]
if N%2==0:
  for i in range(N-1,-1,-2): b.append(a[i])
  for i in range(0,N,2): b.append(a[i])
else:
  for i in range(N-1,-1,-2): b.append(a[i])
  for i in range(1,N,2): b.append(a[i])
print(" ".join(b))


Measured memory_bytes: 25508
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=105;
int X,n,a[N];set<int>S;
signed main(){
	rd(X),rd(n);
	rep(i,1,n){
		int x;rd(x);S.insert(x);
	}
	rep(ans,0,1000){
		if(!S.count(X-ans))printf("%lld ",X-ans),exit(0);
		if(!S.count(X+ans))printf("%lld ",X+ans),exit(0);
	}
	return 0;
}

Measured memory_bytes: 3776
mod = 10 ** 9 + 7

N = int(input())
X = list(map(int,input().split()))

def factorial(n, mod):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
        fact %= mod
    return fact

fact = factorial(N-1, mod)
ans = 0
cnt = 0
for i in range(1, N):
    cnt += pow(i, mod - 2, mod)
    ans += (X[i] - X[i-1]) * cnt

ans *= fact
ans %= mod

print(ans)

Measured memory_bytes: 19984
#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(){
	ll n,x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll g = 0;
	rep(i,n-1){
		g = __gcd(g, abs(a[i]-a[i+1]));
	}
	ll ans = 0;
	rep(i,n){
		ll temp = g;
		g = __gcd(g, abs(x-a[i]));
		ans = max(ans, g);
		g = temp;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int n;
	cin>>n;
	while(n>0)
	{
		if(n%10==7)
		{
			cout<<"Yes";
			return;
		}
		n/=10;
	}
	cout<<"No";
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
    int n, k;
    cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }
    
    int cnt = (n-2)*(n-1)/2 - k;
    
    cout << n-1 + cnt << endl;
    
    FOR(i,2,n+1){
        cout << 1 <<" "<< i << endl;
    }
    
    FOR(i,2,n){
        FOR(j,i+1,n+1){
            if(cnt == 0)return 0;
            cout << i <<" "<< j <<endl;
            cnt--;
        }
    }
    
}


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


#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lmax1 9223372036854775807
#define max1 2147483647
#define lmin1 -9223372036854775808
#define pi 3.141592653589793116
#define mod 1e9+7

int main() {
    off;
   	string s;
    int y,m,d;
    cin>>s;
    vector <int> v;
    int sum=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='/')
            {v.push_back(sum);sum=0;}
        else
        {
            sum=sum*10+(s[i]-'0');
        }
    }
    v.push_back(sum);
    //cout<<v.size()<<'\n';
    if(v[0]<=2019 && v[1]<=4 && v[2]<=30)
    {
        cout<<"Heisei";
    }
    else
    {
        cout<<"TBD";
    }
      return 0;
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			int q=0;
			for(int j=1;j<=n;j++)
			{
				if(i%j==0)
				{
					q++;
				}
			}
			if(q==8)
			{
				ans++;
			}
			q=0;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int a[N],n,m;
bool b[N];
char c[N],c1[N];
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	int ans=0,cnt=0;
	for(int i=1;i<n;i++){
		if(a[i+1]<=a[i])cnt++;
		else ans=max(ans,cnt),cnt=0;
	}
	ans=max(ans,cnt);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  long long l[87];
  l[0] = 2;
  l[1] = 1;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n] << '\n';
  return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 998244353;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

ll fac[300001], inv[300001];
template <typename T>
T power(T a, T n, T mod) {
  T res = 1;
  T tmp = n;
  T curr = a;
  while(tmp){
    if(tmp % 2 == 1){
      res = (T)((ll)res * curr % mod);
    }
    curr = (T)((ll)curr * curr % mod);
    tmp >>= 1;
  }
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac[0] = 1;
  for(int i = 1; i < 300001; i++)fac[i] = i * fac[i-1] % mod;
  inv[300000] = power<ll>(fac[300000], mod-2, mod);
  for(int i = 299999; i >= 0; i--)inv[i] = inv[i+1] * (i+1) % mod;
  int n;
  ll a, b, k;
  cin >> n >> a >> b >> k;
  ll res = 0;
  for(int i = 0; i <= n; i++){
    ll rem = k - (ll)i * a;
    if(rem % b != 0)continue;
    int j = rem / b;
    if(j > n || j < 0)continue;
    ll tmp = fac[n] * inv[i] % mod;
    tmp = tmp * inv[n-i] % mod;
    tmp = tmp * fac[n] % mod;
    tmp = tmp * inv[j] % mod;
    tmp = tmp * inv[n-j] % mod;
    res = (res + tmp) % mod;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=2e5+7;
int dp[maxn];
int main()
{
	int n;
	cin>>n;
	vi a(n);
	int ans=n;
	for(int i=0;i<n;i++) 
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]==1) dp[a[i]]=1;
		if(dp[a[i]-1])
			dp[a[i]]=dp[a[i]-1]+1;
		ans=min(ans,n-dp[a[i]]);
	}
	if(ans==n) ans=-1;
	cout<<ans<<endl;

}


Measured memory_bytes: 1792
while True:
  q = int(input())
  if q == -1:
    break
  x = q / 2
  end = q * 10 ** -5
  while abs(x ** 3 - q) >= end:
    x = (2 * x ** 3 + q) / (3 * x ** 2)
  print(f'{x:.6f}')



Measured memory_bytes: 5672
use std::collections::VecDeque;

struct Bridge {
    a: usize,
    b: usize,
}

#[derive(Clone)]
enum UnionFindValue {
    Root(usize),
    Size(usize),
}

struct UnionFind {
    tree: Vec<UnionFindValue>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        UnionFind{tree: vec![UnionFindValue::Size(1); n]}
    }

    // rootの更新したいので&selfではなく&mut self
    fn root(&mut self, n: usize) -> usize {
        match self.tree[n] {
            UnionFindValue::Root(root) => {
                let new_root = self.root(root);
                self.tree[n] = UnionFindValue::Root(new_root);
                new_root
            },
            UnionFindValue::Size(_) => n,
        }
    }

    // 接続した -> true, すでに接続済み -> false
    fn connect(&mut self, n: usize, m: usize) -> bool {
        let (root, leaf) = if self.size(n) > self.size(m) {
            (self.root(n), self.root(m))
        }
        else {
            (self.root(m), self.root(n))
        };

        if root == leaf {
            false
        }
        else {
            let size = self.size(root) + self.size(leaf);
            self.tree[leaf] = UnionFindValue::Root(root);
            self.tree[root] = UnionFindValue::Size(size);

            true
        }
    }

    // rootの更新したいので&selfではなく&mut self
    fn size(&mut self, n: usize) -> usize {
        let root = self.root(n);
        match self.tree[root] {
            UnionFindValue::Size(size) => size,
            _ => unreachable!(),
        }
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut bridges = VecDeque::new();
    for _ in 0..m {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let ai: usize = iter.next().unwrap().parse().unwrap();
        let bi: usize = iter.next().unwrap().parse().unwrap();
        bridges.push_back(Bridge{a: ai, b: bi});
    }

    let mut unreachability = (n * (n-1) / 2) as u64;
    let mut unreachabilities = Vec::new();
    let mut uf = UnionFind::new(n);
    for bridge in bridges.iter().rev() {
        unreachabilities.push(unreachability);

        let a = bridge.a - 1;
        let b = bridge.b - 1;
        let size_a = uf.size(a);
        let size_b = uf.size(b);
        let reachability = if uf.connect(a, b) {
            size_a as u64 * size_b as u64
        }
        else {
            0
        };
        unreachability -= reachability;
    }

    for unreachability in unreachabilities.iter().rev() {
        println!("{}", unreachability);
    }
}


Measured memory_bytes: 11516
# C - Modulo Summation
# https:C - Modulo Summation//beta.atcoder.jp/contests/abc103/tasks/abc103_c

# C_Modulo_Summation.py

N = int(input())
A = list(map(int, input().strip().split()))

limit = 1
highest = 0
for a in A:
    limit *= a
    highest += a-1
#print(limit, highest)

max_f = 0
i = limit
while True:
    f = 0
    for a in A:
        f += i % a
    if f > max_f:
        max_f = f
    if max_f == highest:
        break
    if i==0:
        break
    i -= 1
print(max_f)


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

int main()
{
	int m,d,c=0,day,month;
	
	cin>>m>>d;
	
	if(m<4)
	{
		cout<<0;
		return 0;
	}
	
	for(month=4;month<=m;month++)
		for(day=22;day<=d;day++)
		{
			if(day%10==1)
				continue;
			if((day/10)*(day%10)==month)
				c++;
		}

	cout<<c;
	return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    K = int(input())
    ans = list("123456789")
    tmp = ans.copy()
    while True:
        tmp2 = []
        for t in tmp:
            for i in range(int(t[-1]) - 1, int(t[-1]) + 2):
                if 0 <= i < 10:
                    tmp2.append(t + str(i))
        tmp = tmp2.copy()
        ans += tmp
        if len(ans) >= K:
            break

    print(ans[K - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 19552
#include <stdio.h>

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

  int h[N];
  for(int i = 0;i < N;i++) scanf("%d",&h[i]);

  int ans = h[0];
  for(int i = 1;i < N;i++){
    if(h[i-1] <= h[i]) ans += h[i]-h[i-1];
  }

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

  return 0;
}

Measured memory_bytes: 128
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	string S;
	READ(S);
	ll N=S.length();
	ll dp[N+3][13];
	FORI(i,0,N+3)
	{
		FORI(j,0,13)
		{
			dp[i][j]=0;
		}
	}
	if (S[0]=='?')
	{
		FORI(i,0,10)
		{
			dp[1][i]=1;
		}
	}
	else
	{
		dp[1][(ll)S[0]-(ll)'0']=1;
	}
	FORI(i,1,N)
	{
		if (S[i]=='?')
		{
			FORI(j,0,13)
			{
				FORI(k,0,10)
				{
					dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%MOD;
				}
			}
		}
		else
		{
			ll k=(ll)S[i]-(ll)'0';
			FORI(j,0,13)
			{
				dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%MOD;
			}
		}
	}
	cout<<dp[N][5]<<endl;

	return 0;
}

Measured memory_bytes: 10604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,t;
  scanf("%d %d",&n,&t);
  double x,h,ans=0; 
  FOR(n){
    scanf("%lf %lf",&x,&h);
    if(ans<h/x)ans=h/x;
  }
  PRF(t*ans);
  return 0;
}



Measured memory_bytes: 2096
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, K; cin >> N >> K;
    vi X(N), Y(N);
    vector<char> C(N);
    REP(i, N) cin >> X[i] >> Y[i] >> C[i];

    vvi a(2 * K, vi(2 * K, 0));
    REP(i,N) {
        int x = X[i]; 
        int y = Y[i];
        if (C[i] == 'W') x += K;
        x %= 2 * K;
        y %= 2 * K;
        a[x][y]++;
    }

    vvi sum(2 * K, vi(2 * K, 0));
    sum[0][0] = a[0][0];
    FOR(i, 1, 2 * K) sum[i][0] = sum[i - 1][0] + a[i][0];
    FOR(j, 1, 2 * K) sum[0][j] = sum[0][j - 1] + a[0][j];
    FOR(i, 1, 2*K) {
        FOR(j, 1, 2*K) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
        }
    }

    int ans = 0;
    REP(x, K){
        REP(y, K){
            int cnt = 0;
            cnt += sum[x][y];
            cnt += sum[x][2 * K - 1] - sum[x][y + K];
            cnt += sum[x + K][y + K] - sum[x + K][y] - sum[x][y + K] + sum[x][y];
            cnt += sum[2 * K - 1][y] - sum[x + K][y];
            cnt += sum[2 * K - 1][2 * K - 1] - sum[2 * K - 1][y + K] - sum[x + K][2 * K - 1] + sum[x + K][y + K];

            cnt = max(cnt, N - cnt);
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 32512
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	cout << N * (N-1) / 2 << endl;

	
	return 0;
}


Measured memory_bytes: 256
using System;

namespace joi2019_yo_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ret = 0; int last = 0;
            for (int i = 1; i < n; i++)
            {
                if (s[i - 1] == s[i])
                {
                    ret += (i - last) / 2; last = i;
                }
            }
            ret += (n - last) / 2;
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 19924
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int main(void)
{
	while (1)
	{
		int n, m, p[1000], sum = 0;
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++)
		{
			cin >> p[i];
			sum += p[i];
		}
		sort(p, p + n);
		for (int i = n - m; i >= 0; i -= m)
		{
			sum -= p[i];
		}
		cout << sum << endl;
	}
	
}

Measured memory_bytes: 3076
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
    t_card, h_card = input().split()
    if t_card > h_card:
        t_point += 3
    elif t_card < h_card:
        h_point += 3
    else:
        t_point += 1
        h_point += 1
print(t_point, h_point)


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

using namespace std;

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

    string s, t;
    int cnt = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != t[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxN = 3e5+10;
int N,A[maxN];
long long ans;
 
int main()
{
    cin >> N;
    for (int i=0; i < N*3; i++) cin >> A[i];
    sort(A,A+N*3);
    int j = N*3-2;
    for (int i=0; i < N; i++) ans += A[j], j -= 2;
    cout << ans;
}

Measured memory_bytes: 1408
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

k = ii()
if k//10 ==0:
    print(k)
    exit()
ans = 0
alis = [[0]*10 for _ in range(100)]
blis = [[0]*10 for _ in range(100)]
for i in range(10):
    alis[0][i] = 1
    blis[0][i] = i
    tmp = i
flag = False
for l in range(1,100):
    for i in range(10):
        if i == 0:
            alis[l][i] = alis[l-1][1] + alis[l-1][0]
            continue
        elif i == 9:
            alis[l][i] = alis[l-1][8] + alis[l-1][9]
        else:
            alis[l][i] = alis[l-1][i] + alis[l-1][i+1] + alis[l-1][i-1]
        blis[l][i] = tmp + alis[l][i] 
        if blis[l][i] >= k:
            banme = k - tmp
            retu = l+1
            hazime = i
            flag = True
            break
        else:
            tmp = blis[l][i]
    if flag:
        break

ans = [0]*retu
ans[0] = hazime
for i in range(1,retu):
    if hazime == 0:
        if banme - alis[retu-1-i][hazime] <=0:
            ans[i] = hazime 
        else:
            banme -= alis[retu-1-i][hazime]
            ans[i] = hazime +1
            hazime = hazime +1
        continue
    elif hazime == 9:
        if banme - alis[retu-1-i][hazime-1] <=0:
            ans[i] = hazime -1
            hazime = hazime -1
        else:
            banme -= alis[retu-1-i][hazime-1]
            ans[i] = hazime 
            hazime = hazime 
        continue
    else:
        if banme - alis[retu-1-i][hazime-1] <=0:
            ans[i] = hazime -1
            hazime = hazime -1
        elif banme - alis[retu-1-i][hazime-1] - alis[retu-1-i][hazime] <=0:
            banme -= alis[retu-1-i][hazime-1]
            ans[i] = hazime 
            hazime = hazime 
        else:
            banme -= (alis[retu-1-i][hazime-1] + alis[retu-1-i][hazime])
            ans[i] = hazime +1
            hazime = hazime +1
aa = 0
for i in range(len(ans)):
    aa += ans[i]*(10**(len(ans)-1-i))
print(aa)


    




Measured memory_bytes: 38384
L, R = map(int, input().split())

ans = 2020
if R - L < 2019:
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i*j)%2019, ans)

else:
    for i in range(L, L+2019):
        for j in range(i+1, L+2019):
            ans = min((i*j)%2019, ans)

print(ans)


Measured memory_bytes: 66560
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

map<pair<string,string>,int>h;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<(1<<n);i++){
        string a="",b="";
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                a+=s[j];
            }
            else{
                b+=s[j];
            }
        }
        h[{a,b}]++;
    }
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
        string a="",b="";
        for(int j=n;j<n+n;j++){
            if(i&(1<<(j-n))){
                a+=s[j];
            }
            else{
                b+=s[j];
            }
        }
        reverse(all(a));
        reverse(all(b));
        ans+=h[{b,a}];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 87040
using System;

namespace _2260
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] a = new char[] { '(','i','w',')' };
            char[] b = new char[] { ')','i','w','(' };
            string s = Console.ReadLine(); int ret = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (Array.IndexOf(a,s[i]) != Array.IndexOf(b,s[s.Length - i - 1])) ret++;
            }
            Console.WriteLine((ret + 1) / 2);
        }
    }
}


Measured memory_bytes: 9588
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

using namespace std;
using ll = long long;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
  int n, l, r;
  cin >> n;
  Sieve sieve(100005);
  vector<int> sum(100005);
  int sumfar=0;
  repo(i, 100000){
    if(i%2==1){
      if(sieve.isPrime(i) && sieve.isPrime((i+1)/2)){
        sumfar++;
      }
      sum[i]=sumfar;
    }
  }
  int ans;
  for(int i=0; i<n; i++){
    cin >> l >> r;
    if(l==1){
      ans=sum[r];
    } else {
      ans=sum[r]-sum[l-2];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,M;
  cin >> N >> M;
  ll ans = 0;
  if(2*N >= M){
    ans += M/2;
  }else{
    ans += N;
    ans += (M-2*N)/4;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 256
# coding: utf-8


def main():
    
    n = int(input())

    for i in range(1, 10):
        div, mod = divmod(n, i)
        if 1 <= div <= 9 and mod == 0:
            print('Yes')
            return 0
    print('No')
    
    return 0
    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def euclid n
  until n[1] == 0
    tmp = n[0]
    n[0] = n[1]
    n[1] = tmp % n[1]
  end
  n[0]
end


while input = $stdin.gets
  n = input.chomp.split(" ").map(&:to_i).sort!{|a,b| b <=> a}
  p euclid(n)
end

Measured memory_bytes: 6088
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	p = inputList()

	p.sort()
	ans = 0
	for i in range(K):
		ans += p[i]

	print(ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 72560
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
a = 0
count = 0
for i in range(N):
  for x in range(M):
    a += B[x] * A[i][x]
    if x == M - 1:
      if a + C > 0:
        a = 0
        count += 1
      else:
        a = 0
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int ans = 0;
	Rep(i, 3){
		char s; cin >> s;
		if(s == '1') ans += 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1<<20)

int n, q;

struct RMQ
{
	int N;
	ll gt;
	ll a[N_SIZE];
	ll seg[N_SIZE * 2];
	void init(int n){
		N = n;
		REP(i, 30) {
			if ((1 << i) >= N) {
				gt = (1 << i) - 1;
				break;
			}
		}
		REP(i, N) {
			//cin >> a[i];
			a[i] = (1 << 31) - 1;
		}
		REP(i, N_SIZE * 2)seg[i] = (1 << 31) - 1;
		REP(i, N) {
			seg[i + gt] = a[i];
		}
	}
	void update(int k, int x) {
		k += gt;
		seg[k] = x;
		while (k) {
			k = (k - 1) / 2;//???????????????
			seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}
	ll query(int a, int b, int k, int l, int r) {
		if (r < a || b < l)return (1 << 31) - 1;
		else if (a <= l&&r <= b)return seg[k];
		else return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2 + 1, r));
	}
	void print() {
		REP(i, 2 * (gt + 1)) {
			cout << i << " " << seg[i] << endl;
		}
	}
};

RMQ rmq;

int main() {
	cin >> n >> q;
	rmq.init(n);
	REP(i, q) {
		ll x, y;
		bool f;
		cin >> f >> x >> y;
		if (!f) {
			rmq.update(x, y);
		}
		else {
			cout << rmq.query(x, y, 0, 0, rmq.gt) << endl;
		}
		//rmq.print();
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        int x, a;
        cin >> x >> a;
        if (x < a) cout << 0 << endl;
        else cout << 10 << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256