akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K, i;
  string S;
cin >> N >> S >> K;
   for( i = 0 ; i < N ; i++){
    if(S.at( i ) != S.at(K-1)){
       S.at( i ) =  '*';
      }
      }
 cout << S <<endl;
}


Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

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

int main() {
    int n, p[300000];
    cin >> n;
    rep(i, n)cin >> p[i];
    rep(i, n)p[i]--;
    int q[300000];
    rep(i, n) q[p[i]] = i;
    int r = 0, f = 1000000, c = 0;
    rep(i, n) {
        if (f < q[i]) {
            c++;
        } else {
            c = 1;
        }
        f = q[i];
        r = max(r, c);
    }
    cout << n - r << endl;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll ans;
string s;

int main()
{
	cin >> s;
	ll num = 0;
	bool flg = false;
	while (num < s.length())
	{
		if (flg)
		{
			if (num == s.length() - 1)
			{
				break;
			}
			else
			{
				ans++;
				num += 2;
			}
			flg = false;
		}
		else
		{
			if (num != s.length() - 1 && s[num] == s[num + 1])
			{
				flg = true;
			}
			ans++;
			num++;
		}
	}

	cout << ans << endl;

	int www;
	cin >> www;
}


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

int solve(int N, int A, int B) {
    if (B < (N * A))
        return B;
    else
        return N * A;
}

int main() {
    int N, A, B;

    cin >> N >> A >> B;

    int answer = solve(N, A, B);
    cout << answer;

    return 0;
}

Measured memory_bytes: 3184
use warnings;
    use Data::Dumper;
    use List::Util qw/max min/;
    sub GetInputData{
    
        my @array_data;
    
        my $line = <STDIN>;
    
        chomp($line);
    
        while($line ne ""){
    
           push(@array_data,$line);
    
           $line = <STDIN>;
    
           chomp($line);
    
    }
    
        return @array_data;
    
    }
    
    sub GetSpaceInputData{
    
        my @array_temp=GetInputData();
    
        my @array_buf;
    
        foreach(@array_temp){
    
            #戻りは配列スペース区切りを分解
            # myを先頭につける必要あり
            my @array_work=split(" ",$_);

            # print "@array_work";
    
            # リファレンスを配列に代入
            push(@array_buf,\@array_work);
        }
    
        return @array_buf;
    
    }
    
    my @arr_result = GetSpaceInputData();

    my $n = $arr_result[0][0];
    my $t = $arr_result[1][0];
    my $a = $arr_result[1][1];
    my $arr=$arr_result[2];

    my @arrdata=();

    for (my $i=0 ; $i<$n; $i++){

        my $val= abs($a - ($t - @$arr[$i] * 0.006));

        push(@arrdata,$val);
 
    }

    my ($result) = grep { $arrdata[$_] == min @arrdata } 0 .. $#arrdata;

    print $result + 1;


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main()
{
    long long int A,B,i,j,K;
    cin>>A>>B>>K;
    if((B-A+1)<=(2*K))
    {
        for(i=A;i<=B;i++)
        {
            cout<<i<<endl;
        }
    }
    else
    {
        for(i=A;i<=A+K-1;i++)
        {
            cout<<i<<endl;
        }
        for(j=B-K+1;j<=B;j++)
        {
            cout<<j<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    S.append(s)

work = S[0]
for i in range(1 , N):
    work_lst = []
    while len(work) != 0 and len(S[i]) != 0:
        if work[0] == S[i][0]:
            c = S[i].pop(0)
            c = work.pop(0)
            work_lst.append(c)
        elif work[0] > S[i][0]:
            S[i].pop(0)
        elif work[0] < S[i][0]:
            work.pop(0)
    work = work_lst
if N == 1:
    print("".join(s))
else:
    print("".join(work_lst))

Measured memory_bytes: 38896
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();
        boolean can = false;
        for (int i = 0; i < k + 1; i++) {
            if (can) {
                break;
            }
            for (int j = 0; j < k + 1; j++) {
                if (can) {
                    break;
                }
                for (int l = 0; l < k + 1; l++) {
                    int sum = i + l + j;
                    if (!(sum < k + 1)) {
                        continue;
                    }
                    int aa, bb, cc;
                    if (i == 0) {
                        aa = a;
                    }else {
                        aa = (int) (a * Math.pow(2, i));
                    }
                    if (j == 0) {
                        bb = b;
                    }else {
                        bb = (int) (b * Math.pow(2, j));
                    }
                    if (l == 0) {
                        cc = c;
                    } else {
                        cc = (int) (c * Math.pow(2, l));
                    }
                    if (aa < bb && bb < cc) {
                        can = true;
                        break;
                    }
                }
            }
        }
        if (can) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }


    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









Measured memory_bytes: 35472
#include <stdio.h>
#include<string.h>
int main(void){
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H'&&b=='H')printf("H\n");
    else if(a=='D'&&b=='D')printf("H\n");
    else printf("D\n");
    return 0;
}


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

using namespace std;

int main(){
  string S;
  cin >> S;
  
  if (S.size() % 2 != 0){
    cout << "No";
    return 0;
  }
  
  for (int i = 0; i < S.size()/2; i ++){
     if(S.find("hi", i*2) != i*2){
       cout << "No";
       return 0;
     } 
  }
  
  cout << "Yes";
  return 0;
}

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


int main() 
{
    string s;
    cin>>s;
    int c=1,x=1,max=0;
   
    if(s=="RRR")
        cout<<3;
    else if(s=="RRS")
        cout<<2;
    else if(s=="RSR")
        cout<<1;
    else if(s=="SRR")
        cout<<2;
    else if(s=="RSS")
        cout<<1;
    else if(s=="SRS")
        cout<<1;
    else if(s=="SSR")
        cout<<1;
    else if(s=="SSS")
        cout<<0;
}




/*

Output:

YES
NO
YES
YES
NO
NO


*/

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        sz--;
        return true;
    }
    bool findSet(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 size() {return sz;}
};

int main(void) {
    int n, m;
    cin >> n >> m;
    int a[n];
    rep (i, n) {
        int p;
        cin >> p;
        p--;
        a[p] = i;
    }

    UnionFind uf(n);
    rep (i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unionSet(x, y);
    }

    int ans = 0;
    rep (i, n) ans += (uf.findSet(i, a[i]));

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


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

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

const int INF = 0x7fffffff;
int n, ans;

int main() {
#ifdef __AiR_H
    freopen("A.in", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d", &n);
    ans = n * (n + 1) / 2;
    printf("%d\n", ans);
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

const int Maxn = 105;
const int Maxm = 10005;

int h, w;
int n;
int a[Maxm];
int B[Maxn][Maxn];

int main()
{
	scanf("%d %d", &h, &w);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int r = 0, c = 0, delt = 1;
	for (int i = 1; i <= n; i++)
		while (a[i]--) {
			B[r][c] = i;
			c += delt;
			if (c < 0 || c >= w) { r++; delt = -delt; c += delt; }
		}
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			printf("%d%c", B[i][j], j + 1 < w? ' ': '\n');
	return 0;
}

Measured memory_bytes: 384
import Control.Applicative

import Data.Char
    (isLower, isUpper, toLower, toUpper)

convert :: Char -> Char

convert char
    | isLower char
        = toUpper char
        
    | isUpper char
        = toLower char
        
    | otherwise
        = char

main :: IO ()

main
    = putStrLn =<< map convert <$> getLine

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;
char arr[101][101];
int main()
{
    FAST
    int n;
    cin>>n;
    string h;
    cin>>h;
    int mx=0;
    for(int i=1;i<n-1;i++)
    {
        int ans=0;
        set<char>s1,s2;
        for(int k=0;k<i;k++)
            s1.insert(h[k]);
        for(int k=i;k<n;k++)
            s2.insert(h[k]);
        for(char k='a';k<='z';k++)
        {
            if(s1.find(k)!=s1.end() && s2.find(k)!=s2.end())
                ans++;
        }
        mx=max(mx,ans);
    }
    cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
		
		System.out.println(Math.min(
				Math.min(a * x + b * y, Math.min(x, y) * c * 2 + (x - Math.min(x, y)) * a + (y - Math.min(x, y)) * b),
				Math.max(x, y) * c * 2));
	}
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

pi NORM(pi p){
    if(p.fi<0){
        p.fi = -p.fi;
        p.se = -p.se;
    }
    int g = __gcd(abs(p.fi), abs(p.se));
    p.fi /= g;
    p.se /= g;
    return p;
}

int solve(){
    int n,k;
    cin >>n >>k;
    vector<int> x(n),y(n);
    rep(i,n) cin >>x[i] >>y[i];

    rep(i,n){
        map<pi,int> m;
        rep(j,n)if(i!=j){
            pi d(x[i]-x[j], y[i]-y[j]);
            ++m[NORM(d)];
        }

        for(const auto &p:m)if(p.se+1 >= k) return 1;
    }
    return 0;
}

int main(){
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		Console.WriteLine("{0}",Math.Abs(s[2]-s[1])%2==0?"Alice":"Borys");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 11220
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int should[100005];
int l[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    should[i] = abs(n-1-2*i);
  }
  sort(l, l+n);
  sort(should, should+n);
  int ret = 1;
  for(int i = 0; i < n; i++) {
    if(should[i] != l[i]) {
      ret = 0;
    }
    else if(i+1 < n && should[i] == should[i+1]) {
      ret *= 2;
      ret %= 1000000007;
    }
  }
  printf("%d\n", ret);
}


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

#define FOR(i,k,n)  for(int i=(k);i<(int)(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(x)  begin(x),end(x)

using namespace std;

int main() {
  string s;
  cin>>s;
  int i = s.size()/2;
  char m = s[i];
  for (; i>=0; ++i) {
    if (s[i] != m || s[s.size()-i-1] != m) break;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 512
# C
from heapq import heappush, heappop

N = int(input())
values = [0]*(2*N)

for i in range(N):
    A, B = map(int, input().split())
    values[i] = A
    values[i+N] = B

def argsort(R_arr):
    N = len(R_arr)
    R_args = [0]*N
    R_vars = [0]*N
    h = []
    for i in range(N):
        heappush(h, (R_arr[i], i))
    for i in range(N):
        a, b = heappop(h)
        R_args[i] = b
        R_vars[i] = a
    return R_vars, R_args

values_sorted, args = argsort(values)

# check for rare case
picked = [0]*N

for i in range(N):
    picked[args[i] % N] = 1
    
if sum(picked) == N:
    if args[N-1] % N == args[N] % N:
        res1 = sum(values_sorted[:(N-1)]) + values_sorted[N+1]
        res2 = sum(values_sorted[:(N+1)]) - values_sorted[N-2]
        res = min(res1, res2)
    else:
        res = sum(values_sorted[:(N-1)]) + values_sorted[N]
    res3 = sum(values[:N])
    res4 = sum(values[N:])
    res = min(res, res3, res4)
else:
    res = sum(values_sorted[:N])

print(res)

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,loc[_]={0},f[_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)loc[ty()]=i;

	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(loc[i]>loc[i-1])f[i]=f[i-1]+1;
		else f[i]=1;
		ans=max(ans,f[i]);
	}

	cout<<n-ans<<lf;
	
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
int n;
char s[20];
map<string, int> mp;
set<string> st;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;	
	int maxn = 0;
	for(int i = 0; i < n; i++){
		cin >> s;
		mp[s]++;
		maxn = max(mp[s], maxn);
	}
	for(map<string, int>::iterator i = mp.begin(); i != mp.end(); i++)
		if(i->second == maxn) 
			st.insert(i->first);
	for(set<string>::iterator i = st.begin(); i != st.end(); i++)
		cout << *i << endl;
	return 0;
}

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


int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) cout << s << endl;
    else {
        string ans = s.substr(0, k);
        ans += "...";
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n + 1);
	s[n] = "zzzzzzzzzzzl";
	vector<pair<int, string>> b(n);
	rep(i, n) { cin >> s[i]; }
	sort(s.begin(), s.end());
	int cnt = 1;
	int j = 0;
	rep(i, n) {
		if (s[i] != s[i + 1]) {
			b[j] = make_pair(-cnt, s[i]);
			cnt = 1;
			++j;
		}
		else ++cnt;
	}
	sort(b.begin(), b.begin()+j);
	cout << b[0].second << endl;
	rep2(i, 1, j) {
		if (b[i - 1].first == b[i].first) cout << b[i].second << endl;
		else return 0;
	}

}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3+5;
vector<int> adj[N];
int rt = INT_MAX, n, k, c1, c2, d1, d2;
bitset<N> B1, B2;
bool f;
void DFS(int u, int p, int d, bitset<N> &ah) { if(d>k) ah[u] = 1; for(int x:adj[u]) if(x^p) DFS(x, u, d+1, ah); }
int main(){
    scanf("%d %d", &n, &k);
    for(int i=1;i<n;i++){
        int a, b; scanf("%d %d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    f = k&1;
    k>>=1;
    for(int i=1;i<=n;i++) for(int j:adj[i]){
        B1.reset(); B2.reset();
        DFS(i, 0, 0, B1);
        if(f) DFS(j, 0, 0, B2);
        else DFS(i, 0, 0, B2);
        B1 &= B2;
        rt = min(rt, (int)B1.count());
    }
    printf("%d", rt);
}

Measured memory_bytes: 512
def mm(a):
  x = 0
  for i in range(0,len(a)):
    if x < ord(a[i]):
      x = ord(a[i])

  return x

n = int(input())
ans = ["a"]
 
for i in range(0,len(ans)):
  while len(ans[i]) < n:
    k = mm(ans[i])
    for j in range(97,k+2):
      ans.append(ans[i] + chr(j))
    del ans[i]
 
sorted(ans)
for i in range(0,len(ans)):
  print(ans[i])

Measured memory_bytes: 12676
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
ll chmax(ll &a, ll b){ return a = (a>b) ? a : b;}
ll chmin(ll &a, ll b){ return a = (a<b) ? a : b;}

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}

////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {
	int N, W;
	cin >> N >> W;
	vector<int> w(N+3, 0);
	vector<ll> v(N+3, 0);
	
	for(int i=0; i<N; i++) cin >> w[i] >> v[i];

	//dp[m][g]: 品物1~mまで考え，重さがgになった時の最大価値  
	vector<vector<ll>> dp(N+3, vector<ll>(W+100005, 0));
	for(int g=0; g<=W; g++) dp[0][g] = 0;
	
	// for(int m=0; m<=N+2; m++){
	// 	cout << "dp["<<m<<"][";
	// 	for(int g=0; g<=10; g++){
	// 		if(g==0) cout<<g<<"]: ";
	// 		cout << dp[m][g] << "  ";
	// 	}
	// 	cout << endl;
	// }

	for(int m=0; m<=N; m++){
		for(int g=0; g<=W; g++){
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
			dp[m+1][g] = max(dp[m+1][g], dp[m][g]+0);//品物m+1番目を入れない
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
			//cout << v[m] << " hey" << w[m] << " hey2" << dp[m+1][g+w[m]] << endl;
			dp[m+1][g+w[m]] = max(dp[m+1][g+w[m]], dp[m][g]+v[m]);//品物m+1番目を入れる
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
		}
	}

	// for(int m=0; m<=N+2; m++){
	// 	cout << "dp["<<m<<"][";
	// 	for(int g=0; g<=10; g++){
	// 		if(g==0) cout<<"g]: ";
	// 		cout << dp[m][g] << "  ";
	// 	}
	// 	cout << endl;
	// } cout << "dp[" << N << "][" << W << "]: " << dp[N][W] << endl;

	ll ans = 0;
	for(int g=0; g<=W; g++) ans = max(ans, dp[N][g]);
	cout << ans << endl;

}



Measured memory_bytes: 162944
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
inline int read(){
	char ch=getchar(); int sum=0; int f=1;
	while(!isdigit(ch)) f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch)) sum=sum*10+ch-'0',ch=getchar();
	return sum*f;
}
int n;
struct Node{
	int l,r;
}a[maxn];
vector<pair<int,int> >vec;
int maxl;
int minr=0x3f3f3f3f;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i].l=read(); a[i].r=read();
		a[i].l--;
		maxl=max(maxl,a[i].l);
		minr=min(minr,a[i].r);
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,max(0,minr-maxl)+a[i].r-a[i].l);
	for(int i=1;i<=n;i++){
		int tmp1=max(0,minr-a[i].l);
		int tmp2=max(0,a[i].r-maxl);
		vec.push_back(make_pair(tmp2,-tmp1));
	}
	sort(vec.begin(),vec.end());
	int minn=INT_MAX;
	for(int i=0;i<vec.size();i++){
		if(i) ans=max(ans,minn+vec[i].first);
		minn=min(minn,-vec[i].second);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2168
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            Set<Integer> div = new TreeSet<>();

            for (int i = 2; i <= (int) Math.sqrt(m); i++) {
                if (m % i == 0) {
                    div.add(i);
                    div.add(m / i);
                }
            }
            div.add(1);
            div.add(m);

            for (int cn : div) {
                if (cn >= n) {
                    out.println(m / cn);
                    return;
                }
            }
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22868
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> H >> W >> K;
	if (K % 2) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2) {
					cout << "R";
				}
				else {
					cout << "G";
				}
			}
			cout << endl;
		}
		return 0;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if ((i + j) % (K * 2) < K) {
				if ((i - j + K * 1000) % (K * 2) < K) {
					cout << "R";
				}
				else{
					cout << "G";
				}
			}
			else {
				if ((i - j + K * 1000) % (K * 2) < K) {
					cout << "Y";
				}
				else {
					cout << "B";
				}
			}
		}
		cout << endl;
	}
	return 0;
}

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

bool check(vector<vector<int>> v, int i, int j){
  int N = v.size(); // node
  
  bool ans = false;
  queue<int> q;
  
  q.push(v.at(0).at(0));
  map<int, bool> chk;
  chk[q.front()] = true; // 到達済み
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(auto x : v.at(now)){
      if((now == i && x == j) || (now == j && x == i)  ){
        continue;
      }
      if(chk.count(x) == 0){
        chk[x] = true;
        q.push(x);
      }
    }
  }
  return (chk.size() == N);
}

typedef pair<int,int> pii;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N);
  vector<pii> p;
  for(int i = 0; i < M; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    v.at(tmp1-1).push_back(tmp2-1);
    v.at(tmp2-1).push_back(tmp1-1);
    
    p.push_back(make_pair(tmp1-1,tmp2-1));
  }
  
  int count = 0;
  
  for(auto x: p){
    if(!check(v, x.first, x.second)){
      count++;
    }
  }
  cout << count << endl;
    
}

Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from fractions import gcd
e = enumerate

sys.setrecursionlimit(10**7)
H, A = map(int, input().split())

if H%A==0:
    print(H//A)
else:
    print(H//A+1)



Measured memory_bytes: 5568
#include <stdio.h>
#include <memory.h>
#define N 1000
const long long MOD=((1e+9)+7);
int p[N+1];
void era(void){
  int i,j;
  for(i=2;i<N;i++)
    p[i]=1;
  for(i=2;i*i<N;i++){
    if(p[i]){
      for(j=2*i;j<=N;j=j+i){
	p[j]=0;
      }
    }
  }
}
int main(void){
  int n,t[N+1],i,j,tmp;
  long long ans=1;
  era();
  scanf("%d",&n);
  memset(t,0,sizeof(t));
  for(i=2;i<=n;i++){
    for(j=2;j<=n;j++){
      if(p[j]&&i%j==0){
	for(tmp=i;!(tmp%j);tmp/=j)
	  t[j]++;
      }
    }
  }
  for(i=2;i<=n;i++)
    ans=(ans*(t[i]+1))%MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()
sosu = 10 ** 9 + 7
alpha = {}
for i in range(N):
    if S[i] in alpha.keys():
        alpha[S[i]].append(i)
    else:
        alpha[S[i]] = [i]
count = 1
for key in alpha.keys():
    count *= (len(alpha[key])+1) % sosu
count = (count + sosu -1 ) % sosu
print(count)


Measured memory_bytes: 7412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC094 {
	class ABC094_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var A = input[0];
			var B = input[1];
			var X = input[2];

			Console.WriteLine(A <= X && A + B >= X ? "YES" : "NO");
		}
	}
}


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

ll solve() {
    ll N, a, b, sa = 0, sb = 0;
    cin >> N;
    vector<pii> C;
    for ( int i = 0; i < N; i++ ) {
        cin >> a >> b;
        C.push_back(pii(a, i));
        C.push_back(pii(b, i));
        sa += a;
        sb += b;
    }
    sort(C.begin(), C.end());
    ll ans = min(sa,sb);
    ll s = 0;
    vector<int> cc(N);
    for ( int i = 0; i < N; i++ ) {
        s += C[i].first;
        cc[C[i].second]++;
    }
    bool con = false;
    for ( int i = 0; i < N; i++ ) {
        if ( cc[i] != 1 ) {
            con = true;
        }
    }
    if ( !con ) {
        if ( C[N-1].second != C[N].second ) {
            s += C[N].first - C[N-1].first;
        } else {
            s += min( C[N+1].first - C[N-1].first, C[N].first - C[N-2].first);
        }
    }
    ans = min(ans, s);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (V.at(i) - C.at(i) > 0) {
      sum += (V.at(i) - C.at(i));
    }
  }
  cout << sum << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define bpll __builtin_popcountll
#define bi( NAME, i ) ( NAME & 1 << i )

void dfs( int start, int end, int mask, int n )
{
	//cout << start << "&" << end << "&" << mask << endl;
	REP(i,n)
	{
		if( bi(start, i) != bi( end, i ) && bi( mask, i ) == 0 )
		{
			mask += 1 << i;
			
			if( bpll(mask) == n )
			{
				cout << start << " ";
				return;
			}

			int k=0;
			for(;k<n;++k) if( bi(mask,k)==0 ) break;
			int mid = start ^ ( 1 << k );
			if( ( mid ^ 1 << i ) == end )
			{
				for(k=k+1;k<n;++k) if( bi(mask,k)==0 ) break;
				mid = start ^ ( 1 << k );
			}

			dfs( start, mid, mask, n );
			cout << mid << " ";
			mid ^= 1 << i;
			dfs( mid, end, mask, n );
			break;
		}
	}
}

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

	if( ( bpll(a) + bpll(b) ) % 2 == 0 )
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
		dfs( a, b, 0, n );
		cout << b;
	}
	
	return 0;
}

Measured memory_bytes: 1024
x,y = map(int,input().split())
m = 0

if x == 3:
    m += 100000

if x == 2:
    m += 200000

if x == 1:
    m += 300000

if y == 3:
    m += 100000

if y == 2:
    m += 200000

if y == 1:
    m += 300000

if m == 600000:
    m += 400000

print(m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n; double d;
struct Point
{
  double x, y;
  void read() { scanf("%lf %lf", &x, &y); }
  double distance(Point other)
  {
    return sqrt((x - other.x) * (x - other.x) + (y - other.y) * (y - other.y));
  }
};
Point points[maxN];

int main()
{
  while (scanf("%d %lf", &n, &d) != EOF)
  {
    for (int i = 0; i < n; i++)
      points[i].read();

    int ans = 0;
    for (int i = 0; i < n; i++)
      if (points[i].distance({0, 0}) <= d)
        ans++;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 6964
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N ; cin >> N;
  ll K ; cin >> K;
  map<ll,ll>cnt;
  vector<ll>num;
  rep(i,N){
    ll inp; cin >> inp;
    num.pb(inp);
    cnt[inp]++;
  }
  rmsame(num);

  vector<ll> ans;
  rep(i,num.size())
    ans.pb(cnt[num[i]]);

  sort(all(ans));
  
  ll ret = 0;
  rep(i,ans.size()-K){
    ret += ans[i];
  }

  cout << ret << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 17392
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m, q; cin >> n >> m >> q;
  vector<vector<tuple<int, int, int>>> qs(n);
  while (q--) {
    int a, b, c, d; cin >> a >> b >> c >> d; --a; --b;
    qs[b].emplace_back(a, c, d);
  }
  int ans = 0;
  function<void(vector<int>&, int)> dfs = [&](vector<int> &a, int score) {
    if (a.size() == n) {
      chmax(ans, score);
      return;
    }
    FOR(i, a.back(), m + 1) {
      int nx = score;
      for (auto [ai, c, d] : qs[a.size()]) {
        if (i - a[ai] == c) nx += d;
      }
      a.emplace_back(i);
      dfs(a, nx);
      a.pop_back();
    }
  };
  vector<int> a;
  FOR(a0, 1, m + 1) {
    a.emplace_back(a0);
    dfs(a, 0);
    a.pop_back();
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll n;cin>>n;
    string s;cin>>s;
    int l=s.size();
    if(l<=n)cout<<s<<endl;
    else{
        rep(i,0,n)cout<<s[i];
        cout<<"..."<<endl;
    }
}

    









Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int x, long long int y){
 long long int tmp;
 long long int r;
 if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = y % x;
  while(r!=0){
    y = x;
    x = r;
    r = y % x;
  }
  return x;
}
int main(){
    int n;
    cin >> n;
    long long int t[n];
    for(int i=0;i<n;i++)cin >> t[i];
    if(n==1){
        cout << t[0];
        return 0;
    }
    long long int ans=t[0]/gcd(t[0],t[1])*t[1];
    for(int i=2;i<n;i++)ans=ans/gcd(ans,t[i])*t[i];
    cout << ans;
}

Measured memory_bytes: 3592
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	S, W := getInt(), getInt()

	if W >= S {
		out("unsafe")
	} else {
		out("safe")
	}
}


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

int main(){
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  if(N<=K){
    cout << N*X << endl;
  }
  else{
    cout << K*X+(N-K)*Y << endl;
  }
}
  

Measured memory_bytes: 3532
n,m = gets.split.map(&:to_i)
g = Array.new(n+1){[]}

m.times do
  u,v = gets.split.map(&:to_i)
  g[u] << v
end

s,t = gets.split.map(&:to_i)
dist = Array.new(n+1){[-1,-1,-1]}
visited = Array.new(n+1){[false,false,false]}

dist[s][0] = 0 
que = [[s,0]]
while a = que.shift
  u,z = a

  g[u].each do |v|
    x = dist[u][z]
    k = (z+1) % 3
    
    que << [v,k] if dist[v][k] == -1 || dist[v][k] > x+1
    if dist[v][k] != -1
      dist[v][k] = x+1 if dist[v][k] > x+1
    else
      dist[v][k] = x+1
    end
  end
end
#p dist
ans = dist[t].select{|x| x > 0 && x%3 == 0}.min
p ans.nil? ? -1 : ans/3


Measured memory_bytes: 25340
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define fi first
#define se second
#define int long long
using namespace std;

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}
char s[37];
char s1[37],s2[37];
int cnt,cnt2,f[50][50][50],ans=0;
///------------------head------------------
signed main(signed argc, char *argv[]){
    int n=read();
    scanf("%s",s);
    rep(i,0,(1<<n)-1){
        cnt=cnt2=0;
        rep(j,0,n-1){
            if (i>>(j)&1) s1[++cnt] = s[j];
            else s2[++cnt2] = s[j];
        }
        reverse(s1+1,s1+cnt+1);
        reverse(s2+1,s2+cnt2+1);
        f[0][0][0]=1;
        rep(ii,0,n) rep(j,0,cnt) rep(k,0,cnt2){
            if (j < cnt && s[n+ii] == s1[j+1]) f[ii+1][j+1][k] += f[ii][j][k];
            if (k < cnt2 && s[n+ii] == s2[k+1]) f[ii+1][j][k+1] += f[ii][j][k];
        }
        ans += f[n][cnt][cnt2];
        rep(ii,0,n) rep(j,0,cnt) rep(k,0,cnt2) f[ii][j][k]=0;
    }
    printf("%lld\n",ans);
	return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string n;
  cin>>n;
  if(n[0]=='7' or n[1]=='7' or n[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main()
{

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

	if (a == 5 && b == 5 && c == 7)
		cout << "YES\n";
	else if (a == 5 && b == 7 && c == 5)
		cout << "YES\n";
	else if (a == 7 && b == 5 && c == 5)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;

}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
v = LIST()
a = []
b = []
for i in range(0, n, 2):
    a.append(v[i])
for i in range(1, n, 2):
    b.append(v[i])
e = Counter(a).most_common()
f = Counter(b).most_common()
g = list(set(a) & set(b))
mns = e[0][1] + f[0][1]
for i in range(len(g)):
    if e[0][0] == g[i] and f[0][0] == g[i]:
        if len(e) > 1 and len(f) > 1:
            mns = max(e[1][1] + f[0][1], e[0][1] + f[1][1])
        elif len(e) > 1:
            mns = e[1][1] + f[0][1]
        elif len(f) > 1:
            mns = e[0][1] + f[1][1]
        else:
            mns = max(e[0][1], f[0][1])
print(n - mns)

Measured memory_bytes: 95232
from heapq import heappush, heapreplace


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

dp = [0] * (N + 1)
q = []
cnt = 0
for i in range(N):
    a = A[i]
    heappush(q, a)
    cnt += a
dp[0] = cnt
for i in range(N, 2 * N):
    a = A[i]
    if a > q[0]:
        cnt += a - heapreplace(q, a)
    dp[i - N + 1] = cnt


dp2 = [0] * (N + 1)
q = []
cnt = 0
for i in range(2 * N, 3 * N):
    a = A[i]
    heappush(q, -a)
    cnt += a
dp2[N] = cnt
for i in range(2 * N - 1, N - 1, -1):
    a = A[i]
    if a < -q[0]:
        cnt += a - (-heapreplace(q, -a))
    dp2[i - N] = cnt

ans = -float('inf')
for i in range(N + 1):
    ans = max(ans, dp[i] - dp2[i])
print(ans)


Measured memory_bytes: 37212
# import numpy as np
import itertools

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# print(P)
	# 一度計算したサイクル情報をキャッシュしておくための配列
	# cycleIDs = np.full( N, -1, np.int64 )
	cycleIDs = [ -1 for _ in range(N)]
	cycleInfs = []
	cycleID = 0
	procCnt = 0

	for n in range(N):
		v = n

		if cycleIDs[v] != -1:
			continue
		else:
			currentCycleCosts = []
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleCosts.append( C[v] )
				cycleIDs[v] = cycleID

				v = P[v]
				if cycleIDs[v] != -1:
					# サイクル終了
					# ループを含めない最大の処理回数
					procCnt = K % len( currentCycleCosts )
					# それで足りてるのかわからないが、Last2周分は、ループ合計がプラスでも必ずしもループするとは限らない
					# その部分は、ちゃんと計算する
					# -------------------------------------------------
					# 4 101
					# 2 3 4 1
					# 50 -49 -50 50
					# 上記のようなパターンの場合、
					# 最大25回ループ + 1回処理可能だが、その場合、25 + 50 = 75
					# 24回ループ + 2回処理でやめると、124になる
					# 無条件でループする回数は、ループ可能な最大の回数-1らしい
					# -------------------------------------------------
					# 割り切れて、尚且つサイクル合計がマイナスのパターンで、最低１個は処理するのにもここで対応
					if len( currentCycleCosts ) + procCnt <= K:
						procCnt += len( currentCycleCosts )

					cycleInfs.append( ( procCnt, len(currentCycleCosts), currentCycleCosts * 3 ) )
					cycleID += 1
					break



	# scores = []
	# procCnt = 0
	ans = -10 ** 9
	for procCnt, currentCycleSize, currentCycleCosts in cycleInfs:

		# サイクル内でループしてスコアを稼ぐ場合の考慮
		loopScore = 0
		if sum(currentCycleCosts) > 0:
			cycleLoopCnt =  ( K - procCnt ) // currentCycleSize
			loopScore = cycleLoopCnt * sum(currentCycleCosts[:currentCycleSize])
			# print("loopScore",loopScore,procCnt)

		# このサイクルに属する全頂点分をまとめて計算する
		for i in range(currentCycleSize):
			# print(np.roll( currentCycleCosts, i ).cumsum()[:procCnt])
			ans = max( ans, max( list( itertools.accumulate( currentCycleCosts[i:i+procCnt] ) ) ) + loopScore )


	print(ans)
	# print(max(scores))


Measured memory_bytes: 10284
a,b,c,d = map(int,input().split())

def takahashi():
    global c
    c = c-b
    if c <= 0:
        print("Yes")
        exit()
    aoki()

def aoki():
    global a
    a = a-d
    if a <= 0:
        print("No")
        exit()
    takahashi()

takahashi()

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

using namespace std;

int main() {
    string s1, s2; cin >> s1 >> s2;
    bool flag = true;

    for(int i = 0; i < s1.size(); i++) {
        if(s1[i] != s2[i]) flag = false;
    }

    if(flag == true) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M;
  	cin >> N >> M;
  int a=0,b=0;
  	for(int i = 0; i < M; i++){
    	
      	cin >> a;
      	b += a;
    }
//  cout << b << endl;
  	if(N < b){
      cout << -1 << endl;
    }
  	else {
    cout << N -b << endl;
    }
}

Measured memory_bytes: 3620
$cc_val = Array.new(100000+1,nil)
$cc_val[0] = 0
$cc_val[1] = 0
def cc_calc
    for i in 2..100000
        $cc_val[i] = $cc_val[i-1] + i-1
    end
end
cc_calc

def cc
    n = gets.chomp.to_i
    dic = {}
    n.times do
        st = gets.chomp.scan(/./).sort.join
        if dic.has_key?(st)
            dic[st] += 1
        else
            dic[st] = 1
        end
    end

    cnt = 0
    dic.each_pair {|k, v|
        cnt += $cc_val[v]
    }
    puts cnt
end

cc


Measured memory_bytes: 18428