akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<int> x(5);
  rep(i,5) cin >> x[i];
  int res;
  rep(i,5) if (x[i] == 0) res = i+1;
  cout << res << endl;
  return 0;
}

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

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const ll modd=1000000007;
ll n,cnt_o,ans=1;
map<pii,ll> cnt_vec,vis;
vector<pii> v;
ll qpow(ll a,ll b) {
	ll ans=1,base=a;
	while(b) {
		if(b&1) ans=ans*base%modd;
		b>>=1,base=base*base%modd;
	}
	return ans;
}
pii get(ll tx,ll ty) {
	swap(tx,ty),ty=-ty;
	if(tx<0) tx*=-1,ty*=-1;
	if(tx==0&&ty<0) ty*=-1;
	return make_pair(tx,ty);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1; i<=n; i++) {
		ll x,y;
		cin>>x>>y;
		ll gcd=__gcd(x,y);
		if(!gcd) cnt_o++;
		else {
			x/=gcd,y/=gcd;
			if(x<0) x*=-1,y*=-1;
			cnt_vec[make_pair(x,y)]++;
			if(!vis[make_pair(x,y)]) {
				v.push_back(make_pair(x,y));
				vis[make_pair(x,y)]=1;
			}
		}
	}
	for(int i=0; i<v.size(); i++) {
		ll tx=v[i].first,ty=v[i].second;
		ll cur=qpow(2,cnt_vec[v[i]]);
		pii v_verti=get(tx,ty);
		if(cnt_vec[v_verti]) {
			cur=(qpow(2,cnt_vec[v[i]])+qpow(2,cnt_vec[v_verti])-1)%modd;
			cnt_vec[v_verti]=cnt_vec[v[i]]=0;
		}
		ans=ans*cur%modd;
	}
	ans=(ans+cnt_o-1)%modd+modd;
	cout<<ans%modd;
	return 0;
}

Measured memory_bytes: 43868
import itertools
a = [int(input()) for _ in range(5)]
mi = 10 ** 10
for i in itertools.permutations(a, 5):
    t = 0
    for j, v in enumerate(i):
        if j == 4:
            t += v
        else:
            t += ((v + 9) // 10 * 10)
    mi = min(t, mi)
print(mi)


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

int main(){
    int N; cin>>N;
    vector<long long> lucas(87,0);
    lucas.at(0)=2; lucas.at(1)=1;

    for(int i=2; i<87; i++){
        lucas.at(i) = lucas.at(i-1)+lucas.at(i-2);
    }

    cout << lucas.at(N) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		long ans = 0;
		for(int i = 0 ; i < (1<<(n - 1)) ; i++) {
			String t = s; int x = n;
			for(int j = 0 ; j < n - 1 ; j++) {
				if((i & (1<<j)) != 0) {
					t = t.substring(0, j + 1 + t.length() - x) + "+" + t.substring(j + 1 + t.length() - x);
				}
			}
			t = t.replace("+", "A");
			String[] u = t.split("A");
			for(int j = 0 ; j < u.length ; j++) {
				ans += Long.valueOf(u[j]);
			}
		}
		System.out.println(ans);
	}
}


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

using ll = long long;
using P = pair<int, int>;

constexpr int MAX_N = 1e5;

int main() {
  int N, M;
  cin >> N >> M;
  deque<P> ab(N);
  for (int i{}; i < N; ++i) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());

  priority_queue<int> q;
  ll ans{};
  for (int j{1}; j <= M; ++j) {
    while (!ab.empty()) {
      P p = ab.front();
      if (p.first > j)
        break;
      q.push(p.second);
      ab.pop_front();
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }

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


Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e5 + 7;
const double EPS = 1e-8;
const int LOGN = 30;

vector <ll> dist;
vector <vector <pair <ll, ll> > > gr;

void dfs(int v, int p, ll d) {
    dist[v] = d;
    for (auto e : gr[v]) {
        int u = e.first, w = e.second;
        if (u == p) continue;
        dfs(u, v, d + w);
    }
}


int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
    #endif // MY
    int n;
    cin >> n;
    gr.resize(n);
    for (int i = 1; i < n; i++) {
        ll v, u, c;
        cin >> v >> u >> c;
        v--, u--;
        gr[v].push_back({u, c});
        gr[u].push_back({v, c});
    }
    int q, s;
    cin >> q >> s;
    s--;
    dist.resize(n, INF);
    dfs(s, -1, 0);
    for (int i = 0; i < q; i++) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        cout << dist[v] + dist[u] << "\n";
    }
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int sum =0;
  int N = B - A + 1;
  int a, b, d, e;
  for ( int i = 0 ; i < N ; i++) {
    a = A % 10; //1の位の数字
    b = A / 10 % 10; //10の位の数字
    d = A / 1000 % 10; //1000の位の数字
    e = A / 10000; //10000の位の数字
    if ( a == e && b == d){
      sum += 1;
    }
    A += 1;
      }
  cout << sum << endl;
  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int x;
	cin >> x;
	cout << 360 / __gcd(360, x);
}


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

int main()
{
    ll h, w;
    cin >> h >> w;
    ll add = 0;
    if(h == 1 || w == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if(h%2 && w%2)
    {
        add = 1;
    }
    cout << h*w / 2 + add << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let s1 = (0..n/2).map(|x| s[x]).collect::<Vec<_>>();
    let s2 = (n/2..n).map(|x| s[x]).collect::<Vec<_>>();
    if s1 == s2 {
        println!("Yes");
    } else {
        println!("No");
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  uint64_t A, B, N, blue;
  cin >> N >> A >> B;
  blue = (N / (A + B) * A) + (min(N % (A + B), A));
  cout << blue << endl;
}


Measured memory_bytes: 3184
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

#define AC 0
#define WA 1
#define TLE 2
#define RE 3

int main() {
  int n;
  cin >> n;
  int results[4] = {0};

  for (int i = 0; i < n; i++) {
    string result;
    cin >> result;

    if (result == "AC") {
      results[AC]++;
    } else if (result == "WA") {
      results[WA]++;
    } else if (result == "TLE") {
      results[TLE]++;
    } else if (result == "RE") {
      results[RE]++;
    }
  }

  cout << "AC x " << results[AC] << endl;
  cout << "WA x " << results[WA] << endl;
  cout << "TLE x " << results[TLE] << endl;
  cout << "RE x " << results[RE] << endl;

  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <atcoder/dsu>

namespace ac = atcoder;

void solve() {
    int n, q;
    std::cin >> n >> q;

    ac::dsu dsu(n);
    while (q--) {
        int t, u, v;
        std::cin >> t >> u >> v;

        switch (t) {
            case 0:
                dsu.merge(u, v);
                break;
            case 1:
                std::cout << dsu.same(u, v) << "\n";
                break;
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL k;
int main(){
    cin>>k;
    LL ans = 0;
    for(int i = 1; i <= 1e7; i++){
        ans = ans * 10 + 7;
        if(ans % k == 0) {
            cout<<i<<endl;
            return 0;
        }
        ans %= k;
    }
    cout<<"-1"<<endl;
    return 0;
}

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

int main() {
	string input;
	cin >> input; 
	int n = 0;
	for (int i = 0; i < 10; i++) {
		if (input[i] == '7') {
			input[i] = '8';
			break;
		}
	}

	cout <<input<< endl;

	return 0;
}


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

int power(int a,int b) {
	long long int mul=1;
	while(b>0) {mul*=a; b--;}
	return mul;
}

int main() {
	int n,a,d=0,sum=0; cin>>n;
	a=n;
	while(a>0) { a/=10; d++; }
	if(d%2==0)  d--;
	else {
		sum = n-(power(10,d-1))+1;
		d-=2;
	}
  for(;d>0;d-=2) { sum+=power(10,d)-power(10,d-1);}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){

    int n,m,sum=0;
    cin >> n >> m;
    int a[m];
    rep(i,m){
        cin >> a[i];
        sum += a[i];
    }
    if(n>=sum){
        cout << n-sum << endl;
    }
    else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed;
 
const int N = 1e5+5;
int a[N];
 
int32_t main()
{
	string s;
	cin >> s;
	int l = 0, r = s.size()-1, cnt = 0;
	while(l < r)
	{
		if(s[l] != s[r])
			cnt++;
		l++;r--;
	}
	cout << cnt <<endl;
	return 0;
}

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

using namespace std;

#define fto(i, a, b) for(int i = a; i < b; ++i)
#define fdto(i, a, b) for(int i = b - 1; i >= a; --i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define fill(arr, val) memset(arr, val, sizeof(arr))
#define what_is(x) cerr << #x << " is " << x << "\n"
#define setpre(x) fixed << setprecision(x)

#define all(arr) (arr).begin(), (arr).end()
#define pb push_back
#define mp make_pair
#define pqueue priority_queue
#define unmap unordered_map //hashmap
#define unset unordered_set //hashset
#define mtset multiset
#define endl '\n'

using ll = long long;
using db = double;
using ii = pair<int, int>;
using vi = vector<int>;

const db PI = acos(-1);

#define MOD 1000000007

void solve();

/// ================================ main ==============================

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	int tt =1;
	//cin >> tt;
	while(tt--) {
		solve();
	}
	return 0;	
}

/// ================================ solve =============================

const int MAXN = 305;
double p[MAXN][MAXN][MAXN], ev[MAXN][MAXN][MAXN	];

void solve() {
	int n;
    scanf("%d", &n);
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c >= 0; --c) {
        for(int b = n; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }
                // dp[a][b][c]
                
                double p_waste = (double) (n - (a + b + c)) / n;
                // p_waste + p_waste^2 + ... = S
                // 1 + S = S / p_waste
                double ev_waste = p_waste / (1 - p_waste) + 1;	                
                ev[a][b][c] += ev_waste * p[a][b][c];
                
                // remove 1 -> dp[a-1][b][c]
                // we will eventually choose one of a+b+c
                if(a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
                }
                
                // remove 2 -> dp[a+1][b-1][c]
                if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                
                // remove 3
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

/*
==================================+
INPUT:                            |
3
1 1 1
==================================+
OUTPUT:                           |
5.5
==================================+
*/



Measured memory_bytes: 221408
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

int main() {
  int n;

  cin >> n;

  int tmp = ceil((double)n / 1000) * 1000;

  cout << tmp - n << endl;

  return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  int n,a,i,sum=0;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {cin>>a;
    v.push_back(a);

    }

        sort(v.begin(),v.end());
        a=abs(v[n-1]-v[0]);
        cout<<a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;

int main(void){
    int A,B;cin>>A>>B;
    cout<<6-A-B<<endl;
}




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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  double n, t, a;
  cin >> n >> t >> a;
  double diff = 1000000;
  int ans = 0;
  for(int i=0; i<n; i++){
    double h;
    cin >> h;
    if(diff>abs(a-(t-h*0.006))){
      diff = abs(a-(t-h*0.006));
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   

ll MAX_V = 10; //頂点数
struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, ll>;

vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(ALL(d), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); i++) {
            struct edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll h,w; cin>>h>>w;
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      cin>>buf;
      struct edge e ={j,buf};
      G[i].push_back(e);
    }
  }
  vector<ll> r(10);
  for(i=0;i<10;i++){
    dijkstra(i);
    r[i]=d[1];
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>buf;
      if(buf!=-1)
      result+=r[buf];
    }
  }
  cout<<result<<endl;



  return 0;
}

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

int s[200005],n,k,c;
ll p[200005],x[200005],ans;

int lowbit(int x){return x&-x;}
void add(int x){while(x<=c)++s[x],x+=lowbit(x);}
int sum(int x){int r=0;while(x)r+=s[x],x-=lowbit(x);return r;}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)
	scanf("%lld",&p[i]),x[i]=p[i]+=p[i-1]-k;

    std::sort(x+1,x+n+2);
    c=std::unique(x+1,x+n+2)-x-1;

    for(int i=1;i<=c;++i)
	if(!x[i]){add(i);break;}
    for(int i=1;i<=n;++i)
    {
	p[i]=std::lower_bound(x+1,x+c+1,p[i])-x;
	ans+=sum(p[i]),add(p[i]);
    }

    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 4096
// 2015/07/03 Tazoe

#include <iostream>
using namespace std;

char F[102][102];

void DFS(int Y, int X, char C)
{
	if(F[Y][X]!=C)
		return;

	F[Y][X] = 0;

	DFS(Y-1, X, C);		// 上
	DFS(Y, X+1, C);		// 右
	DFS(Y+1, X, C);		// 下
	DFS(Y, X-1, C);		// 左
}

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;

		if(H==0 && W==0)
			break;

		for(int y=0; y<=H+1; y++){
			for(int x=0; x<=W+1; x++){
				F[y][x] = 0;		// 初期化
			}
		}

		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				cin >> F[y][x];
			}
		}

		int cnt = 0;

		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				if(F[y][x]!=0){
					cnt++;
					DFS(y, x, F[y][x]);
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

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

using namespace std;
#define mod 1000000007

long double grid[3005][3005];

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

//    string S , t;
//    cin >> S >> t;
//
//    for(int i=0; i<S.size(); i++){
//        for(int j=0; j<t.size(); j++){
//            if(S[i] == t[j]){
//                if(i && j){
//                    grid[i][j]=max(grid[i-1][j],grid[i][j])+1;
//                }
//                else{
//                    grid[i][j] = 1;
//                }
//            }
//            else{
//               if(i){
//                grid[i][j] = max(grid[i-1][j],grid[i][j]);
//               }
//               if(j){
//                grid[i][j] = max(grid[i][j-1],grid[i][j]);
//               }
//            }
//        }
//    }
//    cout << grid[S.size()-1][t.size()-1] << endl;

    long long n;
    cin >>n;

    long double prob[n+1];
    for(int i=1; i<=n; i++){
        cin >> prob[i];
    }
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            grid[i][j] = 0;
        }
    }
    grid[1][0] = (1-prob[1]);
    grid[1][1] = (prob[1]);
    for(int i=2; i<=n; i++){
        for(int j=0; j<=i; j++){
            if(j){
                grid[i][j] = (grid[i-1][j]*(1-prob[i])) + (grid[i-1][j-1] * prob[i]);
            }
            else{
                grid[i][j] = grid[i-1][j]*(1-prob[i]);
            }
        }
    }
    long double sum = 0.0;
    for(int i=(n+1)/2; i<=n; i++){
        sum+=grid[n][i];
        //cout << grid[n][i] << endl;
    }
    cout << fixed << setprecision(10) << sum << endl;
    return 0;
}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,n;
    cin>>h>>n;
    int a,b;
    p p[n];
    rep(i,n){
        cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    vector<int>dp(10005,1e9);
    dp[h]=0;
    for(int i=h;i>=0;i--){
        rep(j,n){
            dp[max(0,i-p[j].first)]=min(dp[max(0,i-p[j].first)],dp[i]+p[j].second);
        }
    }
        cout<<dp[0]<<endl;

    return 0;
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< int > p(n);
  for (int i=0; i<n; ++i) cin >> p[i];
  int ans = 0;
  for (int i=1; i<n-1; ++i) {
    if ((p[i-1]-p[i]) * (p[i]-p[i+1]) > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

queue<int> que;

typedef struct proces {
  char name[10];
  int time;
};

proces p[100000];

int main() {
  int n, q, sumt = 0;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].name >> p[i].time;
    que.push(i);
  }
  while (que.size()) {
    int ind = que.front(); que.pop();
    if (p[ind].time - q > 0) {
      p[ind].time -= q;
      que.push(ind);
      sumt += q;
    }
    else {
      sumt += p[ind].time;
      cout << p[ind].name << " " << sumt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define MAX_N 2000000
#define MAX_A 10000
using namespace std;
int N, A[MAX_N], B[MAX_N], C[MAX_A + 1];

void Out() {
	cout << B[0];
	for (int i = 1; i < N; i++)
		cout << ' ' << B[i];
	cout << endl;
}

void CountingSort() {
	for (int i = 0; i < N; i++) {
		C[A[i]]++;
	}
	for (int i = 1; i <= MAX_A; i++) {
		C[i] += C[i - 1];
	}
	for (int i = N - 1; i >= 0; i--) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	CountingSort();
	Out();
	return 0;
}

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

using namespace std;

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

	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for(auto& Ai : A)
	{
		cin >> Ai;
	}

	int total_votes{};
	for(const auto Ai : A)
	{
		total_votes += Ai;
	}
	total_votes = ceil(double(total_votes) / (4.0 * M));
	sort(A.begin(), A.end());
	bool possible{true};
	int i = N - 1;
	for(int j = 0; j < M and i >= 0; ++j, --i)
	{
		if(A[i] < total_votes)
		{
			possible = false;
			break;
		}
	}

	if(possible)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>v(n,vector<int>(3));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>v[i][j];
        }
    }
    for(int i=1;i<n;i++)
    {
    
        v[i][0]=max(v[i-1][1],v[i-1][2])+v[i][0];
        v[i][1]=max(v[i-1][0],v[i-1][2])+v[i][1];
        v[i][2]=max(v[i-1][0],v[i-1][1])+v[i][2];
    }
    cout<<max(v[n-1][0],max(v[n-1][1],v[n-1][2]));
}

Measured memory_bytes: 8808
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int par[100010];
int urank[100010];

void init(int n){
   for(int i=0;i<n;i++){
      par[i]=i;
      urank[i]=0;
   }
}
int find(int x){
   if(par[x]==x)return x;
   else return par[x]=find(par[x]);
}
void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y)return ;
   if(urank[x]<urank[y])par[x]=y;
   else {
      par[y]=x;
      if(urank[x]==urank[y])urank[x]++;
   }
}
bool same(int x,int y){
   return find(x)==find(y);
}

int main(){
   int n,m;
   cin>>n>>m;
   vector<int> p(n);
   for(int i=0;i<n;i++){
      cin>>p[i];
      p[i]--;
   }

   vector<int> x(m),y(m);
   init(n);
   for(int i=0;i<m;i++){
      cin>>x[i]>>y[i];
      x[i]--,y[i]--;
      unite(x[i],y[i]);
   }
   int ans=0;
   for(int i=0;i<n;i++){
      if(same(i,p[i]))ans++;
   }
   cout<<ans<<endl;
}

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

void Main()
{
  int n; cin >> n;
  vector<int> a(n);
  vector<string> odd, even;
  rep(i,n) {
    cin >> a[i];
    if (i % 2 == 0) even.push_back(to_string(a[i]));
    else odd.push_back(to_string(a[i]));
  }
  if (n % 2 == 0) {
  	reverse(odd.begin(), odd.end());
  	for (string s : odd) cout << s << " ";
  	for (string s : even) cout << s << " ";
  } else {
  	reverse(even.begin(), even.end());
    for (string s : even) cout << s << " ";
  	for (string s : odd) cout << s << " ";
  }
  cout << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 13928
import sys
import math

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

a, b, x = nm()
if 2 * x > a * a * b:
    print(math.degrees(math.atan(2. * (a ** 2 * b - x) / a ** 3.)))
else:
    print(math.degrees(math.atan(a * (b ** 2.) / 2. / x)))

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k,q; cin >> n >> k >> q;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	n++;
	a.push_back(-1);
	
	int ans=INT_MAX;
	for(int i=0;i<n-1;i++){
		vector<int> tot,la;
		for(int j=0;j<n;j++){			
			if(a[j]<a[i]){
				sort(la.begin(),la.end());
				for(int r=0;r<int(la.size())-k+1;r++){
					tot.push_back(la[r]);
				}
				la.clear();
			}
			else{
				la.push_back(a[j]);
			}
		}
		sort(tot.begin(),tot.end());
		if(tot.size()>=q)
			ans=min(ans,tot[q-1]-tot[0]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
MOD = 10**9 + 7

# 1!からmax(a, b)!までの逆元をMODで割ったあまりと
# nからn-max(a*b)までをかけてMODで割ったあまりを求めます。
fact = {}
fact[n] = n
fact[n - 1] = fact[n] * (n - 1) % MOD

inv_fact = [0] * (max(a, b) + 1)
inv_fact[1] = 1

for i in range(2, max(a, b) + 1):
    fact[n - i] = fact[n - i + 1] * (n - i) % MOD
    inv_fact[i] = inv_fact[i - 1] * pow(i, -1, MOD) % MOD

subtrahend = 1 + fact[n - a + 1] * inv_fact[a] + fact[n - b + 1] * inv_fact[b]
minuend = pow(2, n, MOD)

print((minuend + 2 * MOD - subtrahend) % MOD)


Measured memory_bytes: 42548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;cin>>a;
        if(mp[a]!=0){
            cout<<"NO"<<endl;
            return 0;
        }
        mp[a]++;
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 16024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	string s;
	cin >> s;

	replace(s.begin(), s.end(), '?', 'D');

	cout << s << "\n";

	return 0;
}



Measured memory_bytes: 3704
s=input()
ans=0
for x in range(1,len(s)+1):
	for left in range(len(s)-x+1):
		z=s[left:left+x]
		flag=True
		for i in range(x):
			if z[i]!="A" and z[i]!="G" and z[i]!="C" and z[i]!="T":
				flag=False
				break
		if flag==True:
			ans+=1
			break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <cmath>
#include <climits>
#include <set>
#include <unordered_set>
#define  endl "\n"
using namespace std;

void FastInput() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void OutputFile(){freopen("output.txt","w",stdout);}



int main()
{

   FastInput();

    int n;
    cin>>n;
    int x=n%10;
    if(x==2||x==4||x==5||x==7||x==9)
        cout<<"hon"<<endl;
    else if(x==0||x==1||x==6||x==8)
        cout<<"pon"<<endl;
    else if(x==3)
        cout<<"bon";


   return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define vi  vector<int>
#define vll  vector<long long >
#define vpi vector<pair< int , int >>
#define vpl vector<pair<long long >>
#define inf INT_MAX
#define minf INT_MIN
 
int main()
{
   ios::sync_with_stdio(0) ;
   cin.tie(0) ; cout.tie(0) ;
    int a ; 
    cin>>a ; 
    vi v(a) , x(a), lol  ; 
     FOR(i,a)
        cin>>v[i] ; 
    FOR(i,a)
        cin>>x[i] ; 
        // ll te = 0 , t = 0 ; 
    FOR(i,a)
    {
        lol.pb(i+1) ; 
    }
    int t = 1 ; 
    map<vi , int>  m ; 
    do 
    {
        m[lol] = m.size()  ;
    }while(next_permutation(lol.begin() , lol.end())) ; 
    cout<<abs(m[v] - m[x]) ; 
    
       
        
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int N, M;
string a[50];
string b[50];
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, N) cin >> a[i];
    REP(i, M) cin >> b[i];

    REP(i, N-M+1) {
        REP(j, N-M+1) {
            bool flg = true;
            REP(k, M) {
                if(a[i+k].substr(j, M) != b[k]) {
                    flg = false;
                    break;
                }
            }
            if(flg) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 892
N = int(input())

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



li = [[0]*N,[0]*N ]

for index,a in enumerate(A):
    li[0][index] = a- index
    li[1][index]= -a - index


from collections import Counter


cou_one = Counter(li[0])
cou_two = Counter(li[1])




counter = 0
for key,value in cou_one.items():
    counter += cou_two[key]*value


print(counter)

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

static const int MAX = 200000;

int main() {
  int n;
  string s,t,ans = "";
  cin >> n >> s >> t;
  rep(i,n) {
    ans = ans + s.at(i) + t.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define int long long
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
const int N=3005,mod=1000000007;
int n,m,sum[N],l[N],r[N],f[N][N],c[N][N];
char ch[N];
signed main(){
    //freopen("std.in","r",stdin); freopen("my.out","w",stdout);
	n=read(); m=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+ch[i]-'0';
	for(int i=1;i<=m;i++){
		l[i]=read(); r[i]=read(); r[i]=max(r[i-1],r[i]);
	}
	for(int i=0;i<N;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	l[m+1]=n+1; f[0][0]=1;
	for(int i=1;i<=m;i++){
		int t=sum[r[i]]-sum[max(r[i-1],l[i]-1)];
		if(r[i]<l[i+1]){
			int jb=r[i]-l[i]+1,meiju=max((ll)0,r[i-1]-l[i]+1);
			for(int j=0;j<=meiju;j++)f[i][0]=(f[i][0]+(ll)c[jb][j+t]*f[i-1][j])%mod;
			//cout<<c[jb][0+t]<<" "<<jb<<" "<<t<<endl;
		}else{
			int jb=l[i+1]-l[i],meiju=max((ll)0,r[i-1]-l[i]+1);
			for(int j=0;j<=r[i]-l[i+1]+1;j++){
				for(int k=max(j-t,(ll)0);k+t-j<=jb&&k<=meiju;k++){
					f[i][j]=(f[i][j]+(ll)c[jb][k+t-j]*f[i-1][k])%mod;
				}
			}
		}
		//for(int j=0;j<=max(0,r[i]-l[i+1]);j++)cout<<f[i][j]<<" "<<i<<" "<<j<<endl;
	}
	//cout<<f[1][0]<<" "<<f[1][1]<<endl;
	cout<<(f[m][0]+mod)%mod<<endl;
}

Measured memory_bytes: 138240
import numpy as np
import sys
buf = sys.stdin.buffer

H, W = map(int, buf.readline().split())
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = (np.array(list(map(list, buf.read().decode('utf-8').split()))).reshape(H, W) == '.') * 1
grid_v = grid.T

right = np.maximum.accumulate(np.where(grid < 1, np.arange(W + 2), 0), axis=1)
left = np.fliplr(np.minimum.accumulate(np.fliplr(np.where(grid < 1, np.arange(W + 2), 10 ** 10)).copy(), axis=1))
down = np.maximum.accumulate(np.where(grid_v < 1, np.arange(H + 2), 0), axis=1).T
up = np.fliplr(np.minimum.accumulate(np.fliplr(np.where(grid_v < 1, np.arange(H + 2), 10 ** 10)).copy(), axis=1)).T

print(np.max((left - right) + (up - down)) - 3)

Measured memory_bytes: 247280
import java.util.Scanner;

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

    int before = scan.nextInt();
    int after = scan.nextInt();
    int sum = scan.nextInt();

    while(!(before==0&&after==0&&sum==0)) {
      int max = -1;
      for(int i = 1; i < sum; i++) {
        for(int j = 1; j < sum; j++) {
          int addTaxA = addTax(i,before);
          int addTaxB = addTax(j,before);
          if(sum==addTaxA+addTaxB) {
            int result = addTax(i,after) + addTax(j,after);
            if(max<result) {
              max = result;
            }
            break;
          }
        }
      }

      System.out.println(max);

      before = scan.nextInt();
      after = scan.nextInt();
      sum = scan.nextInt();
    }
  }

  public static int addTax(int _x, int _tax) {
      return (int)Math.floor(_x*(100.0+_tax)/100.0);
  }
}

Measured memory_bytes: 29452
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
using namespace std;
int main()
{
    ll n, m, i, j, k, l;
    string s, s1;
    cin>>n;
    cin>>s>>s1;
    for(i=0; i<n; i++)
    {
        cout<<s[i]<<s1[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
lmax = 0
rmin = n
for i in range(m):
    l,r = map(int,input().split())
    if l > lmax:
        lmax = l
    if r < rmin:
        rmin = r
#print(lmax,rmin)
if rmin-lmax < 0:
    print(0)
else:
    print(rmin-lmax+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;

int main () {
  int n, m; cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; i++) cin >> x[i];
  
  if (n >= m) {
    cout << 0 << endl;
  } else {
    sort(x.begin(), x.end());
    
    vector<int> diff(m - 1);
    for (int i = 0; i < m - 1; i++) diff[i] = x[i + 1] - x[i];
    sort(diff.begin(), diff.end());
    
    long long ans = 0;
    for (int i = 0; i < m - n; i++) ans += diff[i];
    
    cout << ans << endl;
  }
}

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

int main(){
 	long a;
  	cin>>a;
  	long b=a/3;
  	long c=a/5;
  	long d=a/15;
  	long ans=(1+a)*a/2-(3+(a-a%3))*b/2-(5+(a-a%5))*c/2+(15+(a-a%15))*d/2;
  	cout<<ans;
  	return 0;
}

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

int A[6+1];

void roll(char s)
{
    int tmp = A[1];
    switch(s)
    {
        case 'E':
            {
                A[1] = A[4]; A[4] = A[6]; A[6] = A[3]; A[3] = tmp;
                break;
            }
        case 'W':
            {
                A[1] = A[3]; A[3] = A[6]; A[6] = A[4]; A[4] = tmp;
                break;
            }
        case 'N':
            {
                A[1] = A[2]; A[2] = A[6]; A[6] = A[5]; A[5] = tmp;
                break;
            }
        case 'S':
            {
                A[1] = A[5]; A[5] = A[6]; A[6] = A[2]; A[2] =  tmp;
                break;
            }
    }

}
int main()
{

    string s;

    for (int i = 1; i < 7; i++)
        cin >> A[i];
    cin >> s;
    for (auto ch :s)
    {
        roll(ch);
    }
    cout << A[1] << endl;
    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int u,d;
    int n; cin >> n;
    u = n / 100;
    d = n - u*100;
    if(u == 0 && d <= 12 && d > 0) cout << "YYMM" << endl;
    else if(u==0) cout << "NA" << endl;
    else if(d == 0 && u <= 12 && u > 0) cout << "MMYY" << endl;
    else if(d == 0) cout << "NA" << endl;
    else if(u <= 12 && d <= 12) cout << "AMBIGUOUS" << endl;
    else if(u <= 12 && u > 0 && d > 12) cout <<  "MMYY" << endl;
    else if(u > 12 && d <= 12 && d > 0) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n,m;
P p[200005];
ll c[200005];
ll ans;
int par[200005],Rank[200005];
void init(ll n){
    for(ll i=0;i<n;i++){
        par[i]=i; Rank[i]=0;
    }
}
int find(ll x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(ll x,ll y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]) Rank[x]++;
    }
}
bool same(ll x,ll y){
    return find(x)==find(y);
}
int main(void){
    cin>>n>>m;
    init(n+1);
    for(int i=0;i<m;i++){
        cin>>p[i].first>>p[i].second;
        unite(p[i].first,p[i].second);
    }
    for(int i=1;i<=n;i++){
        //cout<<find(i)<<endl;
        c[find(i)]++;
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,c[i]);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 8992
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
    int X, ansa = -1, ansb = -1;
    cin >> X;
    for (int a = -121; a <= 121; a++) {
        for (int b = -121; b <= 121; b++) {
            if (a * a * a * a * a - b * b * b * b * b == X) {
                ansa = a, ansb = b;
                break;
            }
        }
    }
    cout << ansa << " " << ansb << endl;
    return 0;
}

Measured memory_bytes: 3596
def change(x,y):
  if x%2==1:
    x-=1
  x=x//2
  y+=x
  return x,y
a,b,k=map(int,input().split())
for i in range(k):
  if i%2==0:
    a,b=change(a,b)
  else:
    b,a=change(b,a)
print(a,b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
namespace fast {
    const int BSZ = 1 << 15; ////// INPUT
    char ibuf[BSZ];
    int ipos, ilen;

    char nc() { // next char
        if (ipos == ilen) {
            ipos = 0;
            ilen = fread(ibuf, 1, BSZ, stdin);
            if (!ilen)
                return EOF;
        }
        return ibuf[ipos++];
    }

    void rs(string &x) { // read string
        char ch;
        while (isspace(ch = nc()))
            ;
        do {
            x += ch;
        } while (!isspace(ch = nc()) && ch != EOF);
    }

    template <class T> void ri(T &x) { // read int or ll
        char ch;
        int sgn = 1;
        while (!isdigit(ch = nc()))
            if (ch == '-')
                sgn *= -1;
        x = ch - '0';
        while (isdigit(ch = nc()))
            x = x * 10 + (ch - '0');
        x *= sgn;
    }

    template <class T, class... Ts> void ri(T &t, Ts &... ts) {
        ri(t);
        ri(ts...);
    } // read ints
////// OUTPUT (call initO() at start)
    char obuf[BSZ], numBuf[100];
    int opos;

    void flushOut() {
        fwrite(obuf, 1, opos, stdout);
        opos = 0;
    }

    void wc(char c) { // write char
        if (opos == BSZ)
            flushOut();
        obuf[opos++] = c;
    }

    void ws(string s) {
        for (char c : s)
            wc(c);
    } // write string
    template <class T> void wi(T x, char after = '\0') { /// write int
        if (x < 0)
            wc('-'), x *= -1;
        int len = 0;
        for (; x >= 10; x /= 10)
            numBuf[len++] = '0' + (x % 10);
        wc('0' + x);
        for (int i = len - 1; i >= 0; i--)
            wc(numBuf[i]);
        if (after)
            wc(after);
    }

    void initO() { assert(atexit(flushOut) == 0); } /// auto-flush output
} // namespace fast
using namespace fast;

void solve() {
    int n, c = 0;
    ri(n);
    for(int i = 1; i <= n - 1; i++) {
        int val = n / i;
        c += (val - (n % i == 0));
    }
    wi(c);
}

signed main() {
    initO();
        solve();
    return 0;
}

Measured memory_bytes: 3640
def main():
  join = ''.join
  def getCharNGram(n,s):
      charGram = [join(s[i:i+n]) for i in range(len(s)-n+1)]
      return charGram
  S = input()
  K = int(input())
  ans = []
  from collections import Counter
  for i in range(K,0,-1):
      l = getCharNGram(i,S)
      ans= ans+l
  ans = list(set(ans))
  ans.sort()
  print(ans[K-1])
main()

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

using namespace std;

int main()
{
	long long n;
	cin >> n;
	string ans;
	n--;
	long long co=26,i;
	for(i=1;;i++,co*=26)
	{
		if(n>=co) n-=co;
		else break;
	}
	ans=string(i,'a');
	while(n)
	{
		ans[--i]=(n%26+'a');
		n/=26;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)
#define repn(i, m, n) for(i = m; i < n; i++)
using namespace std;

int n, m, a, b;
char tile[1000][1000];

void put(int r, int c, char p) { tile[r][c] = p; }
void micro_tile(int ly, int ry, int lx, int rx) {
	int i, j;
	repn(i, ly, ry) {
		repn(j, lx, rx) {
			//横におけるなら置く
			if (j + 1 < rx && tile[i][j] == '.' && tile[i][j + 1] == '.' && a > 0) {
				put(i, j, '<'); put(i, j + 1, '>');
				a--;
			}
			//縦におけるなら置く
			if (i + 1 < ry && tile[i][j] == '.' && tile[i + 1][j] == '.' && b > 0) {
				put(i, j, '^'); put(i + 1, j, 'v');
				b--;
			}
		}
	}
}

void tileEE() { int i, j; rep(i, n / 2) rep(j, m / 2) micro_tile(2 * i, 2 * (i + 1), 2 * j, 2 * (j + 1)); }
void tileEO() {
	int i;
	for (i = 0; i < n; i += 2) micro_tile(i, i + 2, m - 1, m);
	tileEE();
}
void tileOE() {
	int j;
	for (j = 0; j < m; j += 2) micro_tile(n - 1, n, j, j + 2);
	tileEE();
}

void tileOO() {
	int i, j;
	
	if (a < 2 || b < 2) {
		tileOE();
		tileEO();
		return;
	}
	if (((m / 2) * n - a) % 2 == 0) {
		for (i = 0; i + 1 < n; i += 2) micro_tile(i, i + 2, m - 1, m);
		for (j = 0; j + 1 < m; j += 2) micro_tile(n - 1, n, j, j + 2);
		
		for (i = 0; i + 1 < n; i += 2)
			for (j = 0; j + 1 < m; j += 2)
				micro_tile(i, i + 2, j, j + 2);
		return;
	}
	
	put(0, 1, '<'); put(0, 2, '>');
	put(2, 0, '<'); put(2, 1, '>');
	put(0, 0, '^');
	put(1, 0, 'v');
	put(1, 2, '^');
	put(2, 2, 'v');
	a -= 2; b -= 2;
	
	for (j = 3; j < m; j += 2) micro_tile(0, 1, j, j + 2);
	for (i = 3; i < n; i += 2) micro_tile(i, i + 2, 0, 1);
	for (j = 3; j < m; j += 2) micro_tile(1, 3, j, j + 2);
	for (i = 3; i < n; i += 2) micro_tile(i, i + 2, 1, 3);
	for (i = 3; i < n; i += 2) for (j = 3; j < m; j += 2) micro_tile(i, i + 2, j, j + 2);
}

int main() {
	cin >> n >> m >> a >> b;
	if (2 * (a + b) > n * m) { cout << "NO" << endl; return 0; }
	if (a > (m / 2) * n) { cout << "NO" << endl; return 0; }
	if (b > (n / 2) * m) { cout << "NO" << endl; return 0; }
	
	int i, j;
	rep(i, n) rep(j, m) tile[i][j] = '.';
	
	if (n % 2 == 0 && m % 2 == 0) {
		if (((a + 1) / 2) * 2 + b > n * m / 2) { cout << "NO" << endl; return 0; }
		tileEE();
	}
	else if (n % 2 == 0 && m % 2 == 1) {
		if (((a + 1) / 2) * 2 + b > n * m / 2) { cout << "NO" << endl; return 0; }
		tileEO();
	}
	else if (n % 2 == 1 && m % 2 == 0) {
		if (((b + 1) / 2) * 2 + a > n * m / 2) { cout << "NO" << endl; return 0; }
		tileOE();
	}
	else {
		tileOO();
	}
	
	cout << "YES" << endl;
	rep(i, n) {
		rep(j, m) {
			cout << tile[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2176