akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    long double R;
    cin >> R;

    cout << fixed << setprecision(15) <<M_PI * R *2<<endl;
}

Measured memory_bytes: 3172
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;

int n;
long long a[100001],num=0;
inline void add(long long x){
	a[++num]=x;
}
signed main(){
	for (int i=1;i<=8;i++) add(i);
	for (int i=0,o=1;i<=13;i++,o*=10){
		int f=i;
		if (f>10) f=10;
		for (int j=10;j<f*10;j++) add(j*o+o-1);
		for (int j=f;j<10;j++) add((j*10+9)*o+o-1);
	}
	for (int i=100,o=1e12;i<=108;i++) add(i*o+o-1);
	sort(a+1,a+num+1);
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) printf("%lld\n",a[i]);
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

// int dp[2005][2];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n, Z, W;
    cin >> n >> Z >> W;
    VI V(n+1);
    FOR(i, 1, n) {
        cin >> V[i];
    }
    if (n == 1) {
        cout << abs(V[1] - W) << endl;
    } else if (n == 2) {
        cout << max(abs(V[n] - W), abs(V[n - 1] - W)) << endl;
    } else {
        // dp[n - 1][0] = abs(V[n] - V[n - 1]);
        // dp[n - 1][1] = dp[n - 1][0];
        int mn = abs(V[n] - V[n - 1]);
        int mx = abs(V[n] - V[n - 1]);
        int ans = abs(V[n] - V[n - 1]);
        // dp[n - 2][1] = max(abs(V[n] - V[n - 2]), dp[n - 1][0]);
        for (int i = n - 2; i >= 1; i--) {
            // int mx = 0;
            // for (int j = i + 1; j <= n - 1; j++) {
            //     mx = max(mx, dp[j][0]);
            // }
            int dp = max(mx, abs(V[n] - V[i]));
            mx = max(dp, mx);
            // int mn = INT_MAX;
            // for (int j = i + 1; j <= n - 1; j++) {
                // mn = min(mn, dp[j][1]);
            // }
            dp = min(mn, abs(V[n] - V[i]));
            mn = min(mn, dp);
            ans = max(ans, dp);
        }
        // for (int i = 1; i < n; i++) {
        //     cout << dp[i][0] <<" "<<  dp[i][1] << endl;
        // }
        // int ans = 0;
        // for (int i = 1; i < n; i++) {
        //     ans = max(ans, dp[i][0]);
        // }
        cout << max(abs(V[n] - W), ans) << endl;
    }
}

Measured memory_bytes: 256
r,c = [int(x) for x in input().split()]
s_row = [0 for x in range(c+1)]
for i in range(r):
    row = [int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row = [x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	
	string s; cin >> s;
	int freq[128];
	freq['a'] = freq['b'] = freq['c'] = 0;
	for (char c : s) freq[c]++;
	int a = max({freq['a'], freq['b'], freq['c']});
	int b = min({freq['a'], freq['b'], freq['c']});
	if (a - b <= 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  set<int> st;st.insert(a);st.insert(b);st.insert(c);
  if(st.size()==2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

#define N 1000

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

	long long ans = 1e18;

	for (long i = 1; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}
		long long j = n / i;
		ans = min(ans, i + j - 2);
	}

	cout << ans << endl;;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
  	cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A.back() - A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<int> a;
    rep(i,N){
        int t;
        cin>>t;
        a.push_back(t);
    }
    int ans=0;

    rep(i,N){
        if((i+1)%2==1&&a[i]%2==1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}



ll n, a[100001], q;


int main() {
    
    cin >> n;
    ll s = 0;

    loop(i, n) {
        ll x;
        cin >> x;
        s += x;
        a[x]++;
    }

    cin >> q;
    loop(i, q) {
        ll b, c;
        cin >> b >> c;
        s = s - (a[b] * b) + (a[b] * c);
        a[c] += a[b];
        a[b] = 0;
        cout << s << endl;
    }

}

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

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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int sum = 0;
    int minSum = INT32_MAX;
    for(int i = 0; i <= 100000; i++){
        sum = i * 2 * c + max(x - i, 0) * a + max(y - i, 0) * b;
        minSum = min(minSum, sum);
    }
    cout << minSum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;
int selectionSort(int A[],int N){
    int sw = 0,minj;
    int tmp;
    for(int i = 0; i < N; ++i){
        minj = i;
        for(int j = i+1; j < N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        tmp = A[i]; A[i] = A[minj];A[minj] = tmp;
        if(i != minj) sw++;
    }

    return sw;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A[100],i,sw;
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }

    sw = selectionSort(A,N);

    REP(i,N){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl << sw << endl;

    

    return 0;
}


Measured memory_bytes: 3220
import bisect
N, Q = map(int, input().split())
s = input()
AC = []
length = len(s)
for i in range(length):
    if s[i] == 'A':
        if i != length-1 and s[i+1] == 'C':
            AC.append(i)

for _ in range(Q):
    l, r = map(int, input().split())
    a = bisect.bisect_left(AC, l-1)
    b = bisect.bisect_right(AC, r-2)
    print(b-a)

Measured memory_bytes: 5772
import sys
from functools import lru_cache
sys.setrecursionlimit(524287)

n,m,*l = map(int,open(0).read().split())
pas = [[] for _ in range(n)]
for x,y in zip(l[::2],l[1::2]):
	pas[x-1].append(y-1)

INF = float("inf")
done = [-INF]*n

@lru_cache(maxsize = None)
def dfs(t):
	if done[t] >= 0:
		pass
	elif pas[t]:
		done[t] = max(dfs(s) for s in pas[t]) + 1
	else:
		done[t] = 0
	return done[t]

print(max(dfs(i) for i in range(n)))

Measured memory_bytes: 191000
n,q=map(int,input().split())
s=input()
ans=[0]*n
cnt=0
for i in range(len(s)-1):
    if s[i:i+2]=='AC': cnt+=1
    ans[i]=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[r-2]-ans[l-2])

Measured memory_bytes: 6084
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+2,0);
    ll sum = 0;
    repi(i,n+1,1){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n]);
    repi(i,n + 1,1){
        cout << sum + abs(a[i - 1] - a[i + 1]) - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) << endl;
    }
    return 0;
}

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

int main() {
    double a, b, h, m;
    static const double pi = 3.141592653589793;
    cin >> a >> b >> h >> m;

    double ans;

    double sr = 30.0 * h + 30.0*(m/60.0), lr = 360.0*(m/60.0);

    // cout << sr << endl;
    // cout << lr << endl;

    double d = abs(sr-lr);
    ans = sqrt(a*a + b*b - 2.0*a*b*cos(pi*(d/180.0)));
    
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

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

import sys

class suits():
    def __init__(self, symbol):
        self.exist = [False for i in range(14)]
        self.symbol = symbol

    def mark_exist(self, rank):
        self.exist[rank] = True

    def is_exist(self, rank):
        return self.exist[rank]

spade = suits('S')
heart = suits('H')
club = suits('C')
diamond = suits('D')

n = int(sys.stdin.readline())
for i in range(n):
    suit, rank_s = sys.stdin.readline().split()
    rank = int(rank_s)
    if suit == 'S':
        spade.mark_exist(rank)
    elif suit == 'H':
        heart.mark_exist(rank)
    elif suit == 'C':
        club.mark_exist(rank)
    elif suit == 'D':
        diamond.mark_exist(rank)
    else:
        raise ValueError

for s in (spade, heart, club, diamond):
    for rank in range(1, 14):
        if s.is_exist(rank) == False:
            print(s.symbol, rank)



Measured memory_bytes: 5620
import java.io.*;
 
class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int a = Integer.parseInt(strArr[0]);
        int b = Integer.parseInt(strArr[1]);
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}

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

int dp[3005][3005];
string s1,s2;

int lcs(){
	memset(dp,0,sizeof(dp));
	for(int i =1;i<=s1.length();i++){
		for(int j = 1;j<=s2.length();j++){
			(s1[i-1] == s2[j-1]) ? dp[i][j] = 1 + dp[i-1][j-1] : dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	return dp[s1.length()][s2.length()];
}

void print_lcs(){
	string lcs = "";
	int i = s1.length(),j = s2.length();
	
	while(i >0 && j > 0){
		if(s1[i-1] == s2[j-1]){
			lcs += s1[i-1];
			i--;j--;
		}else{
			(dp[i-1][j] >= dp[i][j-1]) ? i--:j--;
		}
	}

	reverse(lcs.begin(),lcs.end());
	cout<<lcs<<endl;
}
int main(){
	cin>>s1>>s2;	
	int len = lcs();
	print_lcs();

}

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

int main () {

    int N;
    cin >> N;

    int A, B;
    if (N == 2) {
        cin >> A >> B;
    }

    if (N == 1) cout << "Hello World" << endl;
    else cout << A + B << endl;

    return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    int res = 1<<30;
    for (int k = -100; k <= 100; k++) {
        int sum = 0;
        for (int x: a) sum += (x-k)*(x-k);
        res = min(res, sum);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		int k = sc.nextInt();
		int[][] dp = new int[n + 1][k + 1];
		int[][] dq = new int[n + 1][k + 1];
		dp[0][0] = 0;
		dq[0][0] = 1;
		for (int i = 0; i < n; i++) {
			int d = cc[i] - '0';
			for (int j = 0; j <= k; j++) {
				dp[i + 1][j] += dp[i][j];
				if (j < k)
					dp[i + 1][j + 1] += dp[i][j] * 9;
				if (d == 0)
					dq[i + 1][j] += dq[i][j];
				else {
					dp[i + 1][j] += dq[i][j];
					if (j < k) {
						dp[i + 1][j + 1] += dq[i][j] * (d - 1);
						dq[i + 1][j + 1] += dq[i][j];
					}
				}
			}
		}
		println(dp[n][k] + dq[n][k]);
	}
}


Measured memory_bytes: 35824
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vs ns(n);
		vvi ts(n);
		rep(i,n){
			cin>>ns[i];
			int m; cin>>m;
			ts[i].resize(m);
			rep(j,m)
				cin>>ts[i][j];
			sort(allof(ts[i]));
		}
		vector<pair<int,string> > ps(n);
		rep(i,n){
			ps[i].second=ns[i];
			rep(j,ts[i].size()){
				int temp=n+1;
				rep(k,n)
					if(binary_search(allof(ts[k]),ts[i][j]))
						temp--;
				ps[i].first+=temp;
			}
		}
		iter(ps) res=min_element(allof(ps));
		cout<<res->first<<" "<<res->second<<endl;
	}
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int len_s = S.length();
    for(int i=0; i<len_s/2; i++){
        if(S[i] != S[len_s-i-1]){
            cout << "No" << endl;
            return(0);
        }
    }
    for(int i=0; i<len_s/4; i++){
        if(S[i] != S[len_s/2-i-1]){
            cout << "No" << endl;
            return(0);
        }
    }
    for(int i=0; i>len_s/4; i++){
        if(S[len_s-1-i] != S[(len_s+3)/2-1+i]){
            cout << "No" << endl;
            return(0);
        }
    }
    cout << "Yes" << endl;
    return(0);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<int>());
  long long ans = 0;
  for (int i = k; i < n; i++) {
    ans += h[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int s,w;
    cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0;(i) < (n); (i)++)
typedef long long ll;
 
int main(){
  int R;
  cin >> R;
    cout << 2*R*3.14 <<endl; 
 
    }

Measured memory_bytes: 3764
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){
}
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(all(a));
    cout << a[(int)a.size()-1] - a[0] << endl;


    return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  sealed abstract class Node {
    val key: Int
    var prev:Node
    var next: Node
  }
  
  case class Elements(key: Int, var prev:Node, var next: Node) extends Node {
    override def toString: String = s"Elements($key)"
  }
  
  case object MyNil extends Node{
    val key: Int = 0
    var prev: Node = MyNil
    var next: Node = MyNil
    override def toString: String = s"MyNil"
  }
  
  def insert(newVal: Int): Unit = {
    var x = Elements(newVal, MyNil, MyNil.next)
    MyNil.next.prev = x
    MyNil.next = x
  }
  
  def listSearch(searchVal: Int): Node = {
    var target = MyNil.next
    while(target.key != searchVal && target != MyNil){
      target = target.next
    }
    target
  }
  
  // nullを設定可能か？
  def deleteNode(target: Node): Unit = {
    if(target != MyNil){
      target.prev.next = target.next
      target.next.prev = target.prev
    }
  }

  def deleteFirst(): Unit = deleteNode(MyNil.next)

  def deleteLast(): Unit = deleteNode(MyNil.prev)

  def deleteKey(target: Int): Unit = deleteNode(listSearch(target))
  
  
  val n = StdIn.readLine().trim.toInt
  case class Command(cmd: String, key: Option[Int])
  
  (0 until n).map{ _ =>
    val line = StdIn.readLine().trim.split(' ')
    line.toList match {
      case a::Nil if a == "deleteFirst" => deleteFirst()
      case a::Nil if a == "deleteLast" => deleteLast()
      case a::b::Nil if a == "insert" => insert(b.toInt)
      case a::b::Nil if a == "delete" => deleteKey(b.toInt)
      case _ => 
    }
  }
  //println(commandList)
  val buff = ListBuffer.empty[Int]
  var current = MyNil.next
  while(current != MyNil){
    buff += current.key
    current = current.next
  }
  println(buff.mkString(" "))
}


Measured memory_bytes: 469844
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
summ = sum(a)
tmp = 0
for i in range(1, len(a), 2):
    tmp += a[i]
x1 = summ - 2 * tmp
print(x1, end=" ")
for i in range(1, n):
    x1 = 2 * a[i - 1] - x1
    if i != n - 1:
        print(x1, end=" ")
    else:
        print(x1)


Measured memory_bytes: 14616
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	string S, T;
	cin >> S >> T;

	ll tlen = T.size();
	ll slen = S.size();

	bool is_rest = false;
	string ans = S;

	rep(i, slen-tlen+1) {
		if (S[i] == '?' || S[i] == T[0]) {
			bool flg = true;
			string temp;

			rep(j, tlen) {
				if (S[i + j] != '?' && S[i+j] != T[j]) {
					flg = false;
					break;
				}
			}
			if (flg) {
				is_rest = true;
				rep(j, slen) {
					if (j < i || (i + tlen) <= j) {
						if (S[j] == '?') ans[j] = 'a';
						else ans[j] = S[j];
					}
					else {
						ans[j] = T[j - i];
					}
				}
			}
		}
	}
	
	if(is_rest) cout << ans << endl;
	else cout << "UNRESTORABLE" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    int x[4][3][10] ={{{}}};
    int b, f, r, v;
    for (int i = 0; i < N; i++){
        cin >> b >> f >> r >> v;
        x[b-1][f-1][r-1]+=v;
    }

    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                cout << " " << x[i][j][k];
            }
            cout << endl;
        }
        if(i < 3)cout << "####################" << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.nextLine();
        Map<Integer, Integer> d = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int key = sc.nextInt();
            if (d.containsKey(key)) {
                d.put(key, d.get(key) + 1);
            } else {
                d.put(key, 1);
            }
        }
        sc.nextLine();

        int m = sc.nextInt();
        sc.nextLine();
        int t[] = new int[m];
        for (int i = 0; i < m; i++) {
            t[i] = sc.nextInt();
        }
        sc.close();

        if (m > n) {
            System.out.println("NO");
            System.exit(0);
        }

        for (int i = 0; i < m; i++) {
            if (d.containsKey(t[i])) {
                if (d.get(t[i]) != 0) {
                    d.put(t[i], d.get(t[i]) - 1);
                } else {
                    System.out.println("NO");
                    System.exit(0);
                }
            } else {
                System.out.println("NO");
                System.exit(0);
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 145016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        Dice dice = new Dice(s);
        char[] arr = br.readLine().toCharArray();
        for(int i=0; i<arr.length; i++){
            dice.roll(arr[i]);
        }
        System.out.println(dice.getTop());
    }
}

class Dice {
    
    private String top;
    private String sideS;
    private String sideE;
    private String sideW;
    private String sideN;
    private String bottom;
    
    Dice(String[] arr){
        top = arr[0];
        sideS = arr[1];
        sideE = arr[2];
        sideW = arr[3];
        sideN = arr[4];
        bottom = arr[5];
    }
    
    void roll(char s) {
        if (s == 'S'){
            String tmp = bottom;
            bottom = sideS;
            sideS = top;
            top = sideN;
            sideN = tmp;
        } else if (s == 'E'){
            String tmp = bottom;
            bottom = sideE;
            sideE = top;
            top = sideW;
            sideW = tmp;
        } else if (s == 'W'){
            String tmp = bottom;
            bottom = sideW;
            sideW = top;
            top = sideE;
            sideE = tmp;
        } else if (s == 'N'){
            String tmp = bottom;
            bottom = sideN;
            sideN = top;
            top = sideS;
            sideS = tmp;
        }
    }
    
    String getTop() {
        return top;
    }
}


Measured memory_bytes: 24416
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

int add(int a, int b) {
    long long res = a * 1ll + b;
    return (res % MOD + MOD) % MOD;
}

int mul(int a, int b) {
    return (a * 1ll * b) % MOD;
}


void solve() {
    int n;
    scanf("%d", &n);
    string s[2];
    cin >> s[0] >> s[1];
    int ans = 0;
    vector<int> f;
    for (int i = 0; i < n; ++i) {
        if (s[0][i] == s[1][i]) {
            f.push_back(0);
        } else {
            f.push_back(1);
            i += 1;
        }
    }
    if (f[0] == 0) {
        ans = 3;
    } else {
        ans = 6;
    }
    for (int i = 1; i < f.size(); ++i) {
        if (f[i - 1] == 0 && f[i] == 0) {
            ans = mul(ans, 2);
        }
        if (f[i - 1] == 0 && f[i] == 1) {
            ans = mul(ans, 2);
        }
        if (f[i - 1] == 1 && f[i] == 1) {
            ans = mul(ans, 3);
        }
    }
    printf("%d\n", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
MOD=1000000007
class FACT
  def initialize
    @fact = (1..3000).to_a
    @fact.each_with_index do |e, idx|
      @fact[idx] = @fact[idx] * @fact[idx-1] % MOD if idx > 0
    end
  end

  def c(n, r)
    return 0 if not (0 <= r and r <= n)
    return 1 if r == 0 or r == n
    fact(n) * inverse( fact(r) * fact(n-r) % MOD ) % MOD
  end

  def h(n,r)
    return 1 if r==0 || n==1
    return fact(n+r-1)*inverse(fact(r)*fact(n-1) % MOD) % MOD
  end
  def fact(n)
    @fact[n-1]
  end

  def inverse(x)
    pow(x, MOD-2)
  end

  def pow(x, n)
    ans = 1
    while n > 0
      ans = ans * x % MOD if n.odd?
      x = x * x % MOD
      n >>= 1
    end
    ans
  end
end
f=FACT.new
n,k = gets.split.map(&:to_i)
for i in 1..k
  puts f.c(n-k+1,i)*f.c(k-1,i-1) % MOD
end


Measured memory_bytes: 1788
N, M=map(int, input().split())
def f(x):
  out=[]
  a=int(pow(x, 1/2))
  for i in range(1, a+1):
    if x%i==0:
      out.append(i)
      j=x//i
      if i!=j:
        out.append(j)
        
  out.sort()
  return out

temp=f(M)

i=0
while temp[i]<N:
  i+=1
  
print(temp[-i-1])

Measured memory_bytes: 3064
// I LOVE AAKRITI GOSWAMI
#include<bits/stdc++.h>
using namespace std;
#define aakriti long long int
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   aakriti a, b ;
   cin >> a >> b ;
   aakriti ans = max( max ( a+b, a-b ) , a*b) ;
   cout << ans ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include <assert.h>

int main(void){
		int a,b,c,d;
    //int ans;
		scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    d = c/a;
    //printf("%d\n",d);
    d = d*a;
    //printf("%d\n",d);

    //ans = c-d;

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

    if(b <= d && d <= c){
      puts("OK");
    }
    else{
      puts("NG");
    }


		return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
#define pb(x) push_back(x)
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(long long a, long long b){
        return a>b;
    }
};

int x,y,a,b,t[505][505],s;

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> x >> y >> a >> b;
    if((!(x%a) && !(y%b))){
        cout << "No";
        return 0;
    }
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            if(y%b && ((i%a)==1 || a==1) && (j%b)==1) t[i][j]=1e9-1;
            if(y%b && ((i%a)==1 || a==1) && (j%b)==((y+1)%b)) t[i][j]=-1e9;
            if(!(y%b) && ((j%b)==1 || b==1) && (i%a)==1) t[i][j]=1e9-1;
            if(!(y%b) && ((j%b)==1 || b==1) && (i%a)==((x+1)%a)) t[i][j]=-1e9;
        }
    }
    cout << "Yes\n";
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            cout << t[i][j] << ' ';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3968
def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    MAX = 2 * max(X,Y)
    ans = 10 ** 14

    for i in range(MAX+1):
        ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)

    print(ans)
    return

resolve()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,s_temp,ans;
  cin >> s;
  ans=0;

  ans = ans + s/100;
  s_temp = s-s/100*100;
  ans = ans + s_temp/10;
  s_temp = s_temp-s_temp/10*10;
  ans = ans + s_temp;
    
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

map<ll, ll> bitcnt(ll num){
    map<ll, ll> ret;
    ll base = 1;
    while(base <= num) base *= 2;
    base /= 2;

    if(base == num){
        ret[base] = 1;
        const ll b = base/2;
        while(base){
            base /= 2;
            ret[base] = b;
        }
        return ret;
    }
    
    while(base){
        ret[base] = num/(base*2)*base;
        if(num%(base*2) >= base) ret[base] += num%(base*2) - base + 1;
        base /= 2;
    }

    return ret;
}

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

    ll a, b;
    cin >> a >> b;
    
    map<ll, ll> cnt_a, cnt_b;
    cnt_a = bitcnt(a-1);
    cnt_b = bitcnt(b);

    ll res = 0;
    for(ll i = 0; i < 60; ++i){
        ll base = 1ll << i;
        if((cnt_b[base] - cnt_a[base])%2 == 1) res += base;
    }

    cout << res << endl;

}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int x = 0;

        if (a > b) {
            x += a;
            a--;
            if (a > b) {
                x += a;
            } else {
                x += b;
            }
        } else {
            x += b;
            b--;
            if (b > a) {
                x += b;
            } else {
                x += a;
            }
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll n, a[305][305];
    ll b[305][305] = {}, inf = 1e18;
    vector<Tlll> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            if (i < j) v.emplace_back(a[i][j], i, j);
            b[i][j] = inf;
        }
    }
    sort(all(v));

    vector<ll> ans;
    for (auto &k : v) {
        ll x = get<0>(k), i = get<1>(k), j = get<2>(k);
        if (b[i][j] >= x) {
            if (b[i][j] > x) {
                b[i][j] = b[j][i] = x;
                ans.push_back(x);
            }
            
            for (int l = 0; l < n; l++) {
                if (j != l) {
                    b[j][l] = min(b[j][l], x + b[i][l]);
                    b[l][j] = b[j][l];
                    //cout << i _ j _ l << endl;
                }
                if (i != l) {
                    b[l][i] = min(b[l][i], x + b[l][j]);
                    b[i][l] = b[l][i];
                    //cout << i _ j _ l << endl;
                }
            }
        }
        else {
            cout << -1 << endl;
            return 0;
        }
        /*
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) cout << b[i][j] << " ";
            cout << endl;
        }*/
    }
    
    ll s = 0;
    for (auto &i : ans) s += i;
    cout << s << endl;
}


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

int main()
{
   // cout << "Hello World!" << endl;
   int n;
   cin>>n;
   string s;
   
   cin>>s;
   
   
   int a[26]={0};
   
   for(int i=0;i<n;i++)
   {
       a[s[i]-'a']+=1;
   }
   
   int l=1;
   
   for(int i=0;i<26;i++)
   {
       if(a[i]%2!=0)
       {
           l=0;
           break;
       }
   }
   
   if(l==0)
   cout<<"No";
   else
   cout<<"Yes";
   
   
   
    return 0;
}


Measured memory_bytes: 256
def main():
    N, L = map(int, input().split())
    ringo = [L + i for i in range(N)]
    if 0 in ringo:
        print(sum(ringo))
    elif ringo[0] < 0:
        print(sum(ringo[:N-1]))
    else:
        print(sum(ringo[1:]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static int solve() {
        return 0;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] roads = new int[n];

        for (int i = 0; i < m; i++) {
            roads[sc.nextInt()-1]++;
            roads[sc.nextInt()-1]++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(roads[i]);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>

int main()
{
    int number_dataset;
    std::cin >> number_dataset;
    
    for (int dataset = 1 ; dataset <= number_dataset ; dataset++) {
    
        const int height = 16, width = 16;
    
        int field[height][width];
        int can_walk[height][width];
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                field[i][j] = 0;//?????????
                can_walk[i][j] = 3;//????????????????????§??????????????????????????????????????\??????????????????????????????????????\?????????????????¨??????
            }
        }
        field[0][0]=1;//????????????????????????


        //???????????????????????£?????????
        int dest_x, dest_y;
        std::cin >> dest_x >> dest_y;
        
        int number_obstacle;
        std::cin >> number_obstacle;
        
        for (int obstacle = 0; obstacle < number_obstacle; obstacle++) {
            int place[2][2];
            std::cin >> place[0][0] >> place[0][1] >> place[1][0] >> place[1][1];
            
            if(place[0][0] < place[1][0]){ //???????????????????????????????????¨???
                can_walk[place[1][0]][place[1][1]] -= 1;//10?????????????????????
            } else if(place[0][0] > place[1][0]){ //??????????????¨???
                can_walk[place[0][0]][place[0][1]] -= 1;//10?????????????????????
            } else if(place[0][1] > place[1][1]){ //??????????????¨???
                can_walk[place[0][0]][place[0][1]] -= 2;//10?????????????????????
            } else {//??????????????¨???
                can_walk[place[1][0]][place[1][1]] -= 2;//1?????????????????????
            }
        }
    
    
    
        for (int tate = 0; tate < height; tate++) {//??¢?´¢??????
            for (int yoko = 0; yoko < width; yoko++) {
                if(tate != 0 && can_walk[tate][yoko] % 2 == 1) {//1???????????????????????\?????????????????????????????\??£?????????
                    field[tate][yoko] +=field[tate-1][yoko];
                }
                if (yoko != 0 && can_walk[tate][yoko] / 2 == 1) {
                    field[tate][yoko] += field[tate][yoko-1];
                }
            }
        }
    
        
        /*for (int i = 0; i < height; i++) {//??????(???????????°??¨)
            for (int j = 0; j < width; j++) {
                std::cout << field[i][j] << " ";
            }
            std::cout << std::endl;
        }
        std::cout << field[dest_x][dest_y] << std::endl;
        std::cout << "---------------------"<<std::endl;//for debug
        */
        
        if(field[dest_x][dest_y] == 0) {
            std::cout << "Miserable Hokusai!" << std::endl;
        } else {
            std::cout << field[dest_x][dest_y] << std::endl;
        }
    
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int r;
	cin>>r;
	double ans=2*r*M_PI;
	printf("%.4f\n",ans);

	
}

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


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

int judge(int a, int b, int x) {
	if ((x < a) || (a + b) < x)	return 0;
	else if (a <= x && x <= (a + b))	return 1;

}

int main() {
	int A, B, X;
	cin >> A >> B >> X;

	int ans = judge(A, B, X);
	if (ans == 0)	cout << "NO";
	else cout << "YES";

	return 0;
	}

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


int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> grid(h, vector<char>(w));

  rep(i, h) {
    rep(j, w) {
      cin >> grid.at(i).at(j);
    }
  }
  
  vector<int> h_skip(h, 1), w_skip(w, 1);
  rep(i, h) {
    rep(j, w) {
      if (grid.at(i).at(j) == '#') {
        h_skip.at(i) = 0;
        break;
      }
    }
  }

  rep(i, w) {
    rep(j, h) {
      if (grid.at(j).at(i) == '#') {
        w_skip.at(i) = 0;
        break;
      }
    }
  }

  rep(i, h) {
    if (h_skip.at(i) == 1) continue;
    rep(j, w) {
      if (w_skip.at(j) == 1) continue;
      else {
        cout << grid.at(i).at(j);
      }
    }
    cout << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  string s1 , s2 , s3;
  cin >> s1 >> s2 >> s3;

  char a = int(s1[0]) -32;
  char b = int(s2[0]) -32;
  char c = int(s3[0]) -32;
  


  cout <<  a << b << c << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
set<int> st;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n,m;
	cin >> n >> m;
	rep(i,0,m){
		int j;
		cin >> j;
		rep(i,0,j){
			int k;
			cin >> k;
			st.insert(k);
		}
	}
	cout << n - sz(st);
	return 0;
}


Measured memory_bytes: 3656
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

void solve()
{
	int n,l;
	cin>>n>>l;
	vector <string> s(n);
	for(int i=0;i<n;i++) cin >> s[i];
	sort(all(s));
	for(string c : s) cout << c;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> l(87);
    l[0] = 2;
    l[1] = 1;
    for(int i=2; i<=n; i++){
        l[i] = l[i-2]+l[i-1];
    }
    cout << l[n] << endl;
}




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

typedef long long int ll;

int main()
{
    ll a, b, x;
    cin >> x >> a >> b;

    if(a >= b){
        cout << "delicious";
    }
    else if(-a + b <= x){
        cout << "safe";
    }
    else{
        cout << "dangerous";
    }

    return 0;
}

Measured memory_bytes: 256
//  abc108a.cpp
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int k;
    cin >> k;
    int odd = k/2;
    int even = k/2;
    
    if (k%2 != 0) {
        odd++;
    }
    cout << odd*even << endl;
}


Measured memory_bytes: 256
import numpy as np

S = int(input())

if S == 10 ** 18:
    x1 = int(10**9)
    y1 = 0
    x2 = 0
    y2 = int(10**9)
else:
    k = int(10**9 - S%(10**9))        
    N = int((S - S%10**9)/10**9 + 1)

    x1 = N
    y1 = 1
    x2 = k
    y2 = 10 ** 9

print("0 0 {} {} {} {}".format(x1, y1, x2, y2))

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

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

  ll mx = -INF;
  ll idx = 0;
  rep(i, n) {
    if (mx < abs(a[i])) {
      idx = i;
      mx = abs(a[i]);
    }
  }

  vector<P> ans;

  rep(i, n) {
    if (idx != i) {
      ans.emplace_back(idx, i);
      a[i] += a[idx];
    }
  }

  if (a[idx] >= 0) {
    REP(i, n) {
      if (a[i] < a[i - 1]) {
        a[i] += a[i - 1];
        ans.emplace_back(i - 1, i);
      }
    }
  } else {
    for (int i = n - 2; i >= 0; i--) {
      if (a[i] > a[i + 1]) {
        a[i] += a[i + 1];
        ans.emplace_back(i + 1, i);
      }
    }
  }

  cout << ans.size() << endl;

  for (const auto& it : ans) {
    cout << it.first + 1 << " " << it.second + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char s[3412];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%s",s);
			if(s[0]=='s'&&s[1]=='n'&&s[2]=='u'&&s[3]=='k'&&s[4]=='e')
			{
				printf("%c%d\n",'A'+j-1,i);
				
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    for i in range(2*n):
        s[i] = ord(s[i])-96
    k = 27
    m = 1<<n
    p = [1<<j for j in range(n)]
    d = defaultdict(lambda : 0)
    l = [(0,0)]
    for i in s[:n][::-1]:
        l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l]
    for i in l:
        d[i] += 1
    ans = 0
    l = [(0,0)]
    for i in s[n:]:
        l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l]
    for i in l:
        ans += d[i]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 127152
N = gets.to_i
a = gets.chomp.split.map(&:to_i)

m = 0
n = a.inject(&:+)

min_value = Float::INFINITY

(N - 1).times do |i|
  m += a[i]
  n -= a[i]

  min_value = [min_value, (m - n).abs].min
end

puts min_value


Measured memory_bytes: 20484
// In The Name Of GOD
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2001;
char mat[MAXN][MAXN];
bool edge[2][MAXN][MAXN];
int ps[3][MAXN][MAXN];
int n, m;

struct partial {
	int x0, y0, x1, y1;
	int all() {
		return (x1 - x0 + 1) * (y1 - y0 + 1);
	}
};

int PSum(int p, partial wr);
void BuildPs();

int main() {
	int q;
	cin >> n >> m;
	cin >> q;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> mat[i][j];
	BuildPs();
	while (q--) {
		partial me, copy[2];
		cin >> me.x0 >> me.y0 >> me.x1 >> me.y1;
		me.x0--; me.x1--; me.y0--; me.y1--;
		copy[0] = me;
		copy[1] = me;
		copy[0].y1--;
		copy[1].x1--;
		int x = PSum(2, me) - PSum(1, copy[0]) - PSum(0, copy[1]);
		cout << x << endl;
	}
}

void BuildPs() {
	for (int i = 0; i < n - 1; i++)
		for (int j = 0; j < m; j++)
			if(mat[i][j] == mat[i + 1][j] && mat[i][j] == '1')
				edge[0][i][j] = true;
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m - 1; j++) {
			if(mat[i][j] == mat[i][j + 1] && mat[i][j] == '1')
				edge[1][i][j] = true;	
		//	cerr << edge[0][i][j];
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			ps[0][i + 1][j + 1] = ps[0][i + 1][j] + ps[0][i][j + 1] - ps[0][i][j] + edge[0][i][j];
			ps[1][i + 1][j + 1] = ps[1][i + 1][j] + ps[1][i][j + 1] - ps[1][i][j] + edge[1][i][j];
			ps[2][i + 1][j + 1] = ps[2][i + 1][j] + ps[2][i][j + 1] - ps[2][i][j] + (mat[i][j] == '1');
		}
}

int PSum(int b, partial wr) {
//	partial me = wr;
//	cerr << me.x0 << me.y0 << me.x1 << me.y1 << ' ' << b << ' '  << ps[b][wr.x1 + 1][wr.y1 + 1] << ps[b][wr.x0][wr.y1 + 1] << ps[b][wr.x1 + 1][wr.y0] << ps[b][wr.x0][wr.y0] << endl;;
	return ps[b][wr.x1 + 1][wr.y1 + 1] - ps[b][wr.x0][wr.y1 + 1] - ps[b][wr.x1 + 1][wr.y0] + ps[b][wr.x0][wr.y0];
}


Measured memory_bytes: 60288