akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = 0
for i in range(n):
    a, b = map(int, input().split())
    s += 1 << (a+b)
i = 0
ans = []
while s:
    if s & 1:
        ans.append(i)
    s >>= 1
    i += 1
for e in ans:
    print(e, 0)

Measured memory_bytes: 10452
use proconio::{input, marker::Usize1};
fn main() {
    input! {
        h: usize,
        w: usize,
        m: usize,
        hw: [(Usize1, Usize1); m]
    }
    let mut sum_h = vec![std::collections::HashSet::new(); h];
    let mut sum_v = vec![0; w];
    let mut max_h = 0;
    let mut max_v = 0;
    for (i, j) in hw {
        sum_h[i].insert(j);
        sum_v[j] += 1;
        max_h = max_h.max(sum_h[i].len());
        max_v = max_v.max(sum_v[j]);
    }

    let mut max_vs = std::collections::HashSet::new();
    for j in 0..w {
        if sum_v[j] >= max_v {
            max_vs.insert(j);
        }
    }

    let mut f = false;
    for i in 0..h {
        if sum_h[i].len() >= max_h {
            for j in &max_vs {
                if !sum_h[i].contains(&j) {
                    f = true;
                    break;
                }
            }
            if f {
                break;
            }
        }
    }

    println!("{}", max_h + max_v - if f { 0 } else { 1 });
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ii = pair<long long, long long>;
using ll = long long;

int ap[30];
int main (){
	char s[30];
	scanf("%s",s);
	int n = strlen(s);
	for(int i = 0; i < n; i++)
		ap[s[i] - 'a']++;
	for(int i = 0; i < 26; i++){
		if(!ap[i]){
			printf("%s%c\n",s, i + 'a' );
			return 0;
		}
	}
	char a = s[0];
	char s2[30];
	strcpy(s2, s);
	next_permutation(s,s + n);
	if(s[0] < a)
		printf("-1\n");
	else{
		for(int i = 0; i < n; i++){
			if(s[i] != s2[i]){
				s[i+1] = 0;
				break;
			}
		}
		printf("%s\n",s);
	}
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(int base, int exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if(exp & 1 == 0) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

long long arr[100001], dar[100001];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        dar[i] = arr[i] * 2;
    }

    long long s = dar[n - 1];

    for(int i = n - 2; i >= 0; --i){
        if(i % 2 == 1){
            s -= dar[i];
        } else {
            s += dar[i];
        }
    }

    long long first = s / 2; // a

    cout << first;

    for(int i = 0; i < n - 1; ++i){
        first = dar[i] - first;
        cout << " " << first;
    }

    return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		int[] ints = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,
				51 };
		try (Scanner sc = new Scanner(System.in)) {
			int k = sc.nextInt();
			System.out.println(ints[k - 1]);
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(N , K);
  vl a(N); in(a);
  sort(all(a) , greater<ll>());
  if(K >= N) die(0);
  ll ans = 0;
  for(int i = K ; i < N ; i++) ans += a[i];
  out(ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	long long a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
	cout<<"Possible"<<endl;
	else
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>v(n);
  vector<int>c(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++)cin>>c[i];
  int sum=0;
  int x;
  for(int i=0;i<n;i++){
    x=v[i]-c[i];
    if(x>0)sum+=x;
  }
  cout<<sum<<endl;
}

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

int main(){

  int a,b,k;
  cin >> a >> b >> k;
  int i;
  int ct=0;
  if(a>=b){
    i=b;
  }else{
    i=a;
  }

  while(1){
    if(a%i==0&&b%i==0){
      ct++;
    }
    if(ct==k){
      cout << i << endl;
      return 0;
    }
    i--;
  }

}




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

int main(){
  int n, y;
  cin >> n >> y;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n; j++){
      int z = n - i - j;
      if(z < 0) continue;
      int sum = 10000 * i + 5000 * j + 1000 * z;
      if(sum == y){
        printf("%d %d %d\n", i, j, z);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
#if 0
????????????????}???????¢???????????????¢?£?±??¢r?°?????°??????????????¢r??g???????????????????????????????¢?´???°????????¢r??g???????£???¨???????????¨???????????????£
????????????????}?????????????????????????¶??????????????????????A????B???????????¢???????????¢A????????0????i???????????????????????????¬B?????????£?°?????£???????????????????????????????±?????????????¢
??????????????????????x???????????????????¢d[i]?£??j?£?????????????¬???????¢???????????????¢???¢????i???¬????????????????????j???¬???????????????????????¬???????????????????????¢d?£??i?£???£???£???£???£??d[i][j] = d[i-1][j-1]???£
???????????????????±???¬???????¢d?£??i?£???£???£???£???£??min?£?¨d[i-1][j] + 1???¢d[i][j-1] + 1???¢d[i-1][j-1] + 1?£?????£??????????????????????????????x???¬???????????????¬???????£
????????????????????????}???????¢??????¢r???¢????????????string???¬???????????¢?±?£???????????¢???????????????????????????????£
???????¬?????????????????????????¨???????????¢??????????????y???????????????????±???????¢???????¢??¢r????????????????????????????¢?±?????????????£???????????????£?????±?????±???????????????????????¢???????????????¢?????´????????¢r??g???¢????????????????????
?\????`?\?????????¢?????????¶?????????????????????????£
#endif
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string str1, str2;
	int count = 0;
	cin >> str1 >> str2;
	int **d = new int*[str1.length()+1];
	for (int i = 0; i < str1.length()+1; i++)
		d[i] = new int[str2.length()+1];
	for (int i = 0; i < 1+str1.length(); i++)
		for (int j = 0; j < 1+str2.length(); j++)
		{
			if (i == 0 || j == 0)
			{
				if (i == 0)
					d[i][j] = j;
				else if (j==0)
					d[i][j] = i;
			}
			else if (str1[i-1] == str2[j-1])
				d[i][j] = d[i - 1][j - 1];
			else
			{
				int min = d[i][j - 1] < d[i - 1][j] ? (d[i][j - 1] + 1) : (d[i - 1][j] + 1);
				min = min < d[i - 1][j - 1] + 1 ? min : d[i - 1][j - 1] + 1;
				d[i][j] = min;
			}
		}
	cout << d[str1.length()][str2.length()] << endl;
}

Measured memory_bytes: 7112
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {

    private static long MOD = 1000000007L;

    public static void main(String[] args) {
        Scanner fs = new Scanner(System.in);
        int n = fs.nextInt(), m = fs.nextInt();
        System.out.println((helper(fs, n) * helper(fs, m)) % MOD);
    }

    private static long helper(Scanner fs, int n) {
        long ans = 0L;
        Long[] xx = new Long[n];
        for (int i = 0; i < n; ++i) {
            xx[i] = fs.nextLong();
        }
        Arrays.sort(xx);
        long prev = xx[0];
        for (int i = 1; i < n; ++i) {
            long x = xx[i];
            long tmp = (x - prev) * i % MOD;
            tmp = tmp * (n - i) % MOD;
            ans = (ans + tmp) % MOD;
            prev = x;
        }
        return ans;
    }
}


Measured memory_bytes: 93228
using System;
using System.Collections.Generic;
using System.Linq;

namespace College
{
    class Program
    {
        static string Join(int[] input)
        {
            string result = "";
            foreach(int i in input)
                result += (" " + i.ToString());
            return result;
        }

        static void Main(string[] args)
        {
            List<List<int[]>> college = new List<List<int[]>>();

            for(int i = 0; i < 4; i++)
            {
                college.Add(new List<int[]>());
                for(int j = 0; j < 3; j++)
                {
                  college[i].Add(new int[10]);
                  for(int k = 0; k < 10; k++)
                      college[i][j][k] = 0;
                }          
            }

            int limit = int.Parse(Console.ReadLine());

            for(int i = 0; i < limit; i++)
            {
                int[] _c = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
                college[_c[0] - 1][_c[1] - 1][_c[2] - 1] = college[_c[0] - 1][_c[1] - 1][_c[2] - 1] + _c[3];
            }

            for(int j = 0; j < college.Count; j++)
            {
                List<int[]> b = college[j];
                foreach(int[] r in b)
                    Console.WriteLine(Join(r));
                if(j != college.Count - 1)
                    Console.WriteLine(new string('#', 20));
            }
        }
    }
}

Measured memory_bytes: 9752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;

int main(){
    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

#define rep(i, n) for(int i=0; i<n; i++)
vector<int> colour;
vector<vector<pair<int, int> > > G;

void dfs(int num, int parent) {
    for(auto item: G[num]) {
        if(item.first==parent) continue;
        if(item.second) {
            colour[item.first] = (colour[num]+1)%2;
        } else {
            colour[item.first] = colour[num];
        }
        dfs(item.first, num);
    }
}

int main() {
    int N;
    cin >> N;
    
    G = vector<vector<pair<int, int> > >(N, vector<pair<int , int> >());
    colour.assign(N, -1);
    
    rep(i, N-1) {
        int u, v;
        long long int w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(make_pair(v, w%2));
        G[v].push_back(make_pair(u, w%2));
    }
    
    colour[0] = 0;
    dfs(0, -1);
    
    rep(i, N) {
        cout << colour[i] << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, k; cin >> n >> k;
    vector<ll> V(n);
    rep(i, n) cin >> V[i];

    ll res = 0;
    // 左から s 個、 右から t 個取る (s + t <= n && s + t <= k)
    // k - s - t 個まで戻せる -> マイナスの分だけ戻す
    rep(s, n + 1) rep(t, n + 1){
        if(s + t > n or s + t > k) continue;
        vector<ll> jewel;
        rep(i, s) jewel.push_back(V[i]);
        rep(i, n - t, n) jewel.push_back(V[i]);

        sort(jewel.begin(), jewel.end(), greater<ll>());
        rep(_, k - s - t){
            if(!jewel.empty() and jewel.back() < 0) jewel.pop_back();
        }
        chmax(res, accumulate(jewel.begin(), jewel.end(), (ll)0));
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
 long long n,a,b;
 scanf("%lli%lli%lli",&n,&a,&b);
 long long x=a+b;
 long long f=n%x;
 if (f>a)f=a;
 printf("%lli", (n/x)*a+f);
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
 
const int MAX_N = 1e5 +6;
 
vector<int> edg[MAX_N];
bool visit[MAX_N];
int depth[MAX_N];
int p[MAX_N];
int sz[MAX_N];
 
void dfs(int id,int pp,int cur_depth) {
    visit[id]=1;
    sz[id]=1;
    p[id] = pp;
    depth[id] = cur_depth;
    for (int i:edg[id]) {
        if (!visit[i]) {
            dfs(i,id,cur_depth+1);
            sz[id] += sz[i];
        }
    }
}
 
int main () {
    int n;
    scanf("%d",&n);
    for (int i=1;n>i;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    dfs(1,1,1);
    int delta=depth[n] - depth[1];
    int cnt=(delta-1)/2;
    int tmp=n;
    while (cnt--) tmp=p[tmp];
    int cntb=sz[tmp],cnta=n-sz[tmp];
    if (cnta > cntb) puts("Fennec");
    else puts("Snuke");
}
 

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2,tmp3,h,w;
int a[100001] = {};
//int b[100010] = {};
deque<PII> que;
string s;
map<int,VPII> kukan;
vector<pair<int,PII>> g;
int dp[200000];
int flag;
int ok[100010] = {};
VPII g2[200000];

class UnionFind {
private:
    int n;
    vector<int> uni;
public:
    UnionFind(int _n) {
        n = _n;
        uni.clear();
        uni.resize(n, -1);
        rep(i,0,n){
            uni[i] = -a[i];
        }
    }
    int root(int x) {
        if (uni[x] < 0) return x;
        return uni[x] = root(uni[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (uni[x] > uni[y]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;

    }
    int getSize(int x) {
        return -uni[root(x)];
    }
    void print() {
        for (auto x : uni) cout << x << " ";
        cout << endl;
    }
};

void dfs(int x, int c){
    rep(j,0,g2[x].size()){
        PII i = g2[x][j];
        if(i.se<=c){
            g2[x][j].se = 1LL<<60;
            res += 1;
            dfs(i.fi,c);
        }
    }

}

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	cin>>n>>m;
    rep(i,0,n){
        cin>>a[i];
    }
    rep(i,0,m){
        cin>>tmp>>tmp2>>tmp3;
		g.pb({tmp3,{tmp2-1,tmp-1}});
        g2[tmp2-1].push_back({tmp-1,tmp3});
        g2[tmp-1].push_back({tmp2-1,tmp3});
    }
    UnionFind UF(n);
    sort(all(g));
    VI v;
    rep(i,0,m){
        pair<int,PII> hen = g[i];
        UF.unite(hen.se.fi,hen.se.se);
        if (UF.getSize(hen.se.fi) >= hen.fi){v.pb(i);}
    }
    res = 0;
    reverse(all(v));
    for(int k : v){
        pair<int,PII> hen = g[k];
        dfs(hen.se.se,hen.fi);
    }
    cout<<m-res/2<<endl;
}

Measured memory_bytes: 24112
def main():
    N = int(input())
    S = input()
    Ws = [0]*(N+1)
    Bs = [0]*(N+1)
    for i in range(1, N + 1):
        Bs[i] = Bs[i - 1] + (1 if S[i-1] == '#' else 0)
        Ws[N - i] = Ws[N + 1 - i] + (1 if S[N - i] == '.' else 0)
    # print(Ws[:10], Bs[:10])
    ans = Bs[0] + Ws[0]
    for i in range(1, N + 1):
        ans = min(ans, Bs[i] + Ws[i])
    print(ans)

if __name__ == '__main__':
    main()


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

struct Card {
	int num;
	char suit;
};

void prints(Card a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i].suit << a[i].num;
	}
	cout << "\n";
}

void bubbleSort(Card a[], int n) {
	bool f =true;
	while (f) {
		f = false;
		for (int i = n - 1; i >= 1; i--) {
			if (a[i].num < a[i - 1].num) {
				swap(a[i], a[i - 1]);
				f = true;
			}
		}
	}

	prints(a, n);
}

void selectionSort(Card a[], int n) {
	int j, minJ = 0;
	for (int i = 0; i < n; i++) {
		minJ = i;
		for (j = i; j < n; j++) {
			if (a[j].num < a[minJ].num) {
				minJ = j;
			}
		}
		if (i != minJ) {
			swap(a[i], a[minJ]);
		}
	}

	prints(a, n);
}

bool isStable(Card c1[], Card c2[], int n) {
	for (int i = 0; i < n; i++) {
		if (c1[i].suit != c2[i].suit || c1[i].num != c2[i].num) 
			return false;
	}

	return true;
}

int main()
{
	int n;
	cin >> n;
	Card c[36], c2[36];

	for (int i = 0; i < n; i++) {
		cin >> c[i].suit >> c[i].num;
		c2[i].suit = c[i].suit;
		c2[i].num = c[i].num;
	}

	bubbleSort(c, n);
	cout << "Stable" << "\n";

	selectionSort(c2, n);
	if (isStable(c, c2, n)) cout << "Stable" << "\n";
	else cout << "Not stable" << "\n";
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




int main()
{

	int N;
	vector<double> Vs;

	cin >> N;

	double v;
	for (int ni = 0; ni < N; ni++){
		cin >> v;
		Vs.push_back(v);
	}

	sort(Vs.begin(),Vs.end());

	double ans = (Vs[0] + Vs[1]) / 2.0;
	for (int vi = 2; vi < N; vi++){
		ans = (ans + Vs[vi]) / 2;
	}

	printf("%6f", ans);

	return 0;
}



Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            x = 500*a + 100*b + 50*c
            if x == X:
                ans += 1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int gcd(int a, int b) {
	if (a%b == 0) return b;
	return gcd(b, a%b);
}

int main() {
	int n, x; cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int u; cin >> u;
		a[i] = abs(u - x);
	}
	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define FOR(it,a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); ++it)

const int MAXW = 75;
const int MOD = 1000000000 + 9;

typedef int matrix[MAXW][MAXW];

int w;
long long h;

void mul(matrix a, matrix b, bool rhs = false)
{
    static matrix c;
    memset(c, 0, sizeof(matrix));
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < w; k++) {
                c[i][j] += (long long)a[i][k] * b[k][j] % MOD;
                if (c[i][j] >= MOD) {
                    c[i][j] -= MOD;
                }
            }
        }
    }
    if (rhs) {
        memcpy(b, c, sizeof(matrix));
    } else {
        memcpy(a, c, sizeof(matrix));
    }
}

void pow(matrix a, matrix r, long long p)
{
    if (p == 0) {
        memset(r, 0, sizeof(matrix));
        for (int i = 0; i < w; i++) {
            r[i][i] = 1;
        }
    } else {
        pow(a, r, p >> 1);
        mul(r, r);
        if (p & 1) {
            mul(r, a);
        }
    }
}

matrix trans, powered, col;

int main()
{
    int n, cas = 0;
    while (cin >> w >> h >> n && w) {
        map<long long,vector<int> > M;
        M[h - 1].clear();
        for (int i = 0; i < n; i++) {
            int xi;
            long long yi;
            cin >> xi >> yi;
            xi --, yi --;
            if (yi != 0) {
                M[yi].push_back(xi);
            }
        }
        M.erase(0LL);
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < w; j++) {
                trans[j][i] = abs(i - j) <= 1 ? 1 : 0;
            }
        }
        memset(col, 0, sizeof(matrix));
        col[0][0] = 1;
        long long lastH = 0;
        FOR (it, M) {
            pow(trans, powered, it->first - lastH);
            mul(powered, col, true);
            FOR (jt, it->second) {
                col[*jt][0] = 0;
            }
            lastH = it->first;
        }
        printf("Case %d: %d\n", ++cas, col[w - 1][0]);
    }
}

Measured memory_bytes: 1312
#include <cstdio>
#include <numeric>
const int MAXN = 3005;
double dp[MAXN][MAXN];
double P[MAXN];
int N;
 
// dp[i][j] = p of landing j heads after tossing first i coins.
 
double solve() {
  for (int j = 0; j <= N; ++j) dp[0][j] = 0.0;
  dp[0][0] = 1.0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] = (1 - P[i]) * dp[i-1][j];
      if (j == 0) continue;
      dp[i][j] += P[i] * dp[i-1][j-1];
    }
  }
  int half = (N + 1) / 2;
  return std::accumulate(dp[N] + half, dp[N] + N + 1, 0.0);
}
 
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%lf", &P[i]);
  }
  printf("%.12f\n", solve());
  return 0;
}

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


int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll>a(n+1),b(m+1);
  for(int i=1; i<=n; i++){
    ll A;
    cin >> A;
    a[i]=a[i-1]+A;
  }
  for(int i=1; i<=m; i++){
    ll B;
    cin >> B;
    b[i]=b[i-1]+B;
  }
  ll ans=0;
  for(ll i=0; i<=n; i++){
    if(a[i]>k)break;
    ll res = k-a[i];
    ll itre = upper_bound(b.begin(),b.end(),res)-b.begin()-1;
    ans = max(ans,i+itre); 
  }
  
  cout << ans << endl;
  
}
       
        
      
  
    

Measured memory_bytes: 6424
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
trace _ a = a

solve :: Int -> Int -> Int -> Maybe [Int]
solve n a b | a + b - 1 <= n && n <= a * b = Just (solve0 n a b)
            | otherwise = Nothing

solve0 n a 1 = [1..n]
solve0 n 1 b = [n,n-1..1]
solve0 n a b = answer
  where
    (p,q) = divMod (n-b) (a-1)
    nums = [b] ++ replicate q (p+1) ++ replicate (a-1-q) p
    sums = scanl' (+) 0 nums
    tbl = trace ("tbl " ++ show tbl0) tbl0
    tbl0 = zipWith f (map (+ 1) sums) (tail sums)
      where f x y = [y, y-1 .. x]
    answer = concat tbl

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Maybe [Int]
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_a,bs_b]:remLines1 = remLines0
      n = readBInt bs_n
      a = readBInt bs_a
      b = readBInt bs_b
  in solve n a b

outAnswer :: Maybe [Int] -> IO ()
outAnswer Nothing = putStrLn "-1"
outAnswer (Just xs) = putStrLn $ unwords $ map show xs

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 3964
///In the name of ALLAH

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
 
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mx_int_prime 999999937
 
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
 
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define sqr(a) ((a) * (a))
 
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mx = 1e5+123;
int dp[mx], n, h[mx];

int solve ( int i )
{
  if ( i == n ) return 0;
  if ( dp[i] != -1 ) return dp[i];

  int ret2 = inf;
  int ret1 = abs ( h[i] - h[i+1] ) + solve ( i+1 );
  if ( i+2 <= n ) ret2 = abs ( h[i] - h[i+2] ) + solve ( i+2 );

  return dp[i] = min ( ret1, ret2 );
}

int main()
{
  optimize();

  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> h[i];

  memset ( dp, -1, sizeof (dp) );
  cout << solve ( 1 ) << endl;


  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(){
  int h,w;cin>>h>>w;
  int ch, cw, dh, dw;cin>>ch>>cw>>dh>>dw; ch--;cw--;dh--;dw--;
  vector<string>s(h);
  rep(i, h)cin>>s[i];

  vector<vector<int>>c(h, vector<int>());
  rep(i, h)rep(j, w)c[i].push_back(INF);

  deque<pair<int, pi>> q;
  q.push_back({0, {ch, cw}});
  while(q.size()){
    auto cp = q.front();q.pop_front();
    pi now = cp.second;
    int cs = cp.first;

    int y = now.first;
    int x = now.second;
    if(y<0 || y>=h || x<0 || x>=w)continue; // 盤外は飛ばし

    if(s[y][x] == '#')continue; // 壁は飛ばし
    if(c[y][x] <= cs)continue; // スコアが既に低ければ飛ばし
    c[y][x]=cs;

//cout<<cs<<' '<<y<<' '<<x<<' '<<q.size()<<endl;

    // nowから見て4方向とワープ可能位置をpush
    q.push_front({cs, {y-1, x}});
    q.push_front({cs, {y+1, x}});
    q.push_front({cs, {y, x+1}});
    q.push_front({cs, {y, x-1}});
    for(int i=-2; i<=2; i++)for(int j=-2; j<=2; j++){
      q.push_back({cs+1, {y+i, x+j}});
      q.push_back({cs+1, {y+i, x+j}});
      q.push_back({cs+1, {y+i, x+j}});
      q.push_back({cs+1, {y+i, x+j}});
    }
  }

  if(c[dh][dw]==INF){cout<<-1<<endl; return 0;}
  cout<<c[dh][dw]<<endl;

  return 0;

  rep(i, h){
    rep(j, w)cout<<c[i][j]<<' ';cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 22500
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(-d <= a-c && a-c <= d) cout << "Yes" << endl;
    else if ((-d <= a-b && a-b <= d) && (-d <= b-c && b-c <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  if(s=="keyence"){
    cout<<"YES"<<endl;
    return 0;
  }
  for(int i=0;i<s.size()-1;i++){
    for(int j=i;j<s.size();j++){
      string p="";
      for(int k=0;k<s.size();k++){
        if(k<i||j<k){
          p+=s[k];
        }
      }
      if(p=="keyence"){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    string S,T; cin>>S>>T;
	int ans=T.size();
	for(int i=0; i+T.size()<=S.size(); i++) {
		int c=0;
		for (int j=0; j<T.size(); j++) c += S[i+j] != T[j];
		if (ans>c) ans=c;
	}
	cout<<ans<<endl;
    return 0;
}


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

string flip(string s, int i){
  string out(s.length(), 'a');
  for (int j=0; j<s.length(); j++){
    int n = i + j;
    if (i + j >= s.length()){
      n = n - s.length();
    }
    out[j] = s[n];
  }
  return out;
}

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  // cout << s.length() << endl;
  // cout << t << endl;

  for (int i=0; i<s.length(); i++){
    string new_s = flip(s, i);
    // cout << new_s << endl;
    if (new_s == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>

using namespace std;

const int MAX = 100001;

long long solve(long long sum1[], long long sum2[], int N) {
	long long ans = 0;
	long long max1[MAX] = { 0 };
	long long max2[MAX] = { 0 };

	for (int i = 1; i <= N; i++) {
		max1[i] = max(sum1[i], max1[i - 1]);
		max2[i] = max(sum2[i], max2[i - 1]);
	}

	for (int i = 0; i <= N; i++) {
		ans = max(ans, max1[i] + max2[N - i]);
	}
	return ans;
}

int main() {
	int N;
	long long C;

	pair<long long, int> x1[MAX];
	pair<long long, int> x2[MAX];
	long long sumL[MAX] = { 0 };
	long long sumR[MAX] = { 0 };
	long long sumLR[MAX] = { 0 };
	long long sumRL[MAX] = { 0 };

	x1[0].first = x2[0].first = 0;
	x1[0].second = x2[0].second = 0;

	cin >> N >> C;
	for (int i = 1; i <= N; i++) {
		cin >> x1[i].first >> x1[i].second;
		x2[i].first = C - x1[i].first;
		x2[i].second = x1[i].second;
	}

	sort(x1, x1 + N + 1);
	sort(x2, x2 + N + 1);

	for (int i = 1; i <= N; i++) {
		long long d1 = x1[i].first - x1[i - 1].first;
		long long d2 = x2[i].first - x2[i - 1].first;

		sumL[i] = sumL[i - 1] + x1[i].second - d1;
		sumLR[i] = sumLR[i - 1] + x1[i].second - 2 * d1;
		sumR[i] = sumR[i - 1] + x2[i].second - d2;
		sumRL[i] = sumRL[i - 1] + x2[i].second - 2 * d2;
	}

	cout << max(solve(sumL, sumRL, N), solve(sumR, sumLR, N)) << endl;
	
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll N;
    cin >> N;

    ll A = 1;
    ll B = N/A-1;
    ll total = 0;
    ll tmp = B;
    while(A<=tmp){
    	total += B;
    	// cout << A << endl;
    	A++;
    	if(N%A==0) B = N/A-1;
    	else B = N/A;
    }

    cout << total << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x=a*b;
	int y=c*d;
	printf("%d\n",max(x,y));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  rep (i, n + 1) cin >> a[i];
  rep (i, n) cin >> b[i];
  lint sum1 = 0;
  vector<int> ac = a, bc = b;
  rep (i, n) {
    sum1 += min(ac[i], bc[i]);
    bc[i] = max(0, bc[i] - ac[i]);
    sum1 += min(bc[i], ac[i + 1]);
    ac[i + 1] = max(0, ac[i + 1] - bc[i]);
  }
  ac = a, bc = b;
  reverse(all(ac));
  reverse(all(bc));
  lint sum2 = 0;
  // rep (i, n) {
  //   sum2 += min(ac[i], bc[i]);
  //   bc[i] = max(0, bc[i] - ac[i]);
  //   sum2 += min(bc[i], ac[i + 1]);
  //   ac[i + 1] = max(0, ac[i + 1] - bc[i]);
  // }
  cout << max(sum1, sum2) << endl;
  return 0;
}

Measured memory_bytes: 1792
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
int n,m,a[MAXN],t[MAXN],x;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
//......Code.............
int main()
{
    cin>>n;
    FR(i,0,n)cin>>a[i];
    cin>>m;
    FR(i,0,m)cin>>t[i];
    sort(a,a+n);
    sort(t,t+m);
    x=0;
    FR(i,0,n)
    {
        if(a[i]==t[x])
        {
            x++;
        }
        if(x==m)break;
    }
    if(x==m)cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=5e3+5;
const int mod=1e9+7;
int n,m,f[N][N];
char s[N];
int ksm(int x,int y){int re=1;while(y){if(y&1)re=1ll*re*x%mod;x=1ll*x*x%mod;y>>=1;}return re;}
signed main(){
	//freopen("a","r",stdin);
	n=read();scanf("%s",s+1);m=strlen(s+1);
	f[0][0]=1;
	rep(i,0,n-1)rep(j,0,i){
		f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*2%mod)%mod;
		f[i+1][max(j-1,0)]=(f[i+1][max(j-1,0)]+f[i][j])%mod;
	}return cout<<1ll*f[n][m]*ksm(ksm(2,m),mod-2)%mod,signed();
}

Measured memory_bytes: 70512
use proconio::input;
use proconio::marker::Chars;

// based on: https://atcoder.jp/contests/abc177/submissions/16642811
// Im just learning rust by rewriting others code ¯\_(ツ)_/¯
// I only copy those solutions I would know how to type in C++ myself anyway

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let n = s.len();
    let m = t.len();
    let mut ans = std::i64::MAX;

    for i in 0..n {
        if i + m > n {
            break;
        }

        let mut cnt = 0i64;
        for j in 0..m {
            if s[i + j] != t[j] {
                cnt += 1;
            }
        }
        ans = std::cmp::min(ans, cnt);
    }

    println!("{}", ans);
}


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

const int N = 200000;
int n, m;
long long a[N + 1], b[N + 1];
int k;

int main() 
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) scanf("%lld", a + i + 1);
	for (int i = 0; i < m; ++i) scanf("%lld", b + i + 1);
	for (int i = 1; i <= m; ++i) b[i] += b[i - 1];
	int mx = 0;
	for (int i = 0, j = m; i <= n && (!i || (a[i] += a[i - 1]) <= k); ++i) {
		while (a[i] + b[j] > k) --j;
		mx = max(mx, i + j);
	}
	printf("%d\n", mx);
	return 0;
}


Measured memory_bytes: 4844
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  rep(i, b + 1)
  {
    if (((i + 1) * a) % b == c)
    {
      YES;
      return 0;
    }
  }
  NO;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)parent[i] = i;
	}

	int find(int x)
	{
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)return;

		if (rank[x] < rank[y])parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

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

	int N, M;
	cin >> N >> M;

	vector<int> A(N);
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	UnionFind uf(N);
	int x, y;
	rep(i, 0, M)
	{
		cin >> x >> y;
		uf.unite(x, y);
	}

	vector<vector<int>> V(N);
	set<int> fs;
	rep(i, 0, N)
	{
		fs.insert(uf.find(i));
		V[uf.find(i)].push_back(A[i]);
	}

	if (N < (SZ(fs) - 1) * 2)
	{
		cout << "Impossible" << endl;
	}
	else if (SZ(fs) == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		int ans = 0;
		vector<int> PV;
		rep(i, 0, N)
		{
			if (V[i].empty())continue;
			sort(all(V[i]));
			ans += V[i][0];
			rep(j, 1, SZ(V[i]))
			{
				PV.push_back(V[i][j]);
			}
		}
		sort(all(PV));
		rep(i, 0, (SZ(fs) - 1) * 2 - SZ(fs))
		{
			ans += PV[i];
		}
		cout << ans << endl;
	}


	return 0;
}

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

int main()
{
	char str[101];
	bool flag;
	while (1){
		stack<int >st;
		cin.getline(str, 101);
		if (str[0] == '.')
			break;
		flag = true;
		for (int i = 0; i < 101; i++){
			if (str[i] == '.')
				break;
			if (str[i] == '(')
				st.push(0);
			if (str[i] == '[')
				st.push(1);
			if (str[i] == ')'){
				if (st.empty() || st.top() != 0){
					flag = false;
					break;
				}
				else
					st.pop();
			}
			if (str[i] == ']'){
				if (st.empty() || st.top() != 1){
					flag = false;
					break;
				}
				else
					st.pop();
			}
		}
		
			
		if (flag && st.empty())
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

int main() {
    long long A,B,K;
    cin >> A >> B >> K;
    if (K>=A+B)
    cout << 0 << " " << 0 << endl;
    else if (A>K)
    cout << A-K << " " << B << endl;
    else
    cout << 0 << " " << B+A-K << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		double ans=M_PI*2*N;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3268