akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 5e5 + 100;
const int LOG = 21;
const int mod = 1e9 + 7;
const int MX = (1e7 + 100) * 1.5;
typedef long long li;

template<class T1, class T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &rhs) {
    out << "( " << rhs.first << " , " << rhs.second << " )";
    return out;
}

int n;
int a[MAXN];

int b[MAXN];

int ok(int mid) {
    for (int i = 1; i <= 2 * n - 1; ++i) {
        if (a[i] >= mid)
            b[i] = 1;
        else
            b[i] = 0;
    }

    for (int i = 1; i <= n; ++i) {
        if (n + i <= 2 * n - 1 && b[n + i] == b[n + i - 1]) {
            return b[n + i];
        }

        if (n - i >= 1 && b[n - i] == b[n - i + 1]) {
            return b[n - i];
        }
    }
    return b[1];
}

void solve() {
    cin >> n;
    for (int i = 1; i <= 2 * n - 1; ++i) {
        cin >> a[i];
    }

    int l = 0, r = 2 * n + 1;
    int ans = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (ok(mid)) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << ans << "\n";
}

signed main() {
#ifdef zxc
    debug = 0;
    freopen("../input.txt", "r", stdin);
    //  freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    if (debug) {
        cerr << endl;
        cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
    }

}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int Inf = (int) 1e9;
		int[] min = new int[K];
		for(int i=0;i<K;i++) min[i] = Inf;
		
		var SH = new SkewHeap<Pair>();
		
		for(int i=1;i<=9;i++){
			if(min[i % K] > i){
				min[i % K] = i;
				SH.Push(new Pair(i % K, i));
			}
		}
		
		bool[] used = new bool[K];
		while(SH.Count > 0){
			var p = SH.Top; SH.Pop();
			int now = p.Pos;
			int cost = p.Cost;
			if(used[now]) continue;
			used[now] = true;
			for(int j=0;j<10;j++){
				var nxt = (now * 10 + j) % K;
				if(min[nxt] > cost + j){
					min[nxt] = cost + j;
					SH.Push(new Pair(nxt, min[nxt]));
				}
			}
		}
		
		Console.WriteLine(min[0]);
		
		
		
	}
	int K;
	public Sol(){
		K = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class Pair : IComparable<Pair> {
	public int Pos;
	public int Cost;
	public Pair(int p, int c) {
		Pos = p; Cost = c;
	}
	public int CompareTo(Pair t) {
		//return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
		return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
	}
}


class SkewHeap<T> where T:IComparable<T>{
	public int Count{
		get{return cnt;}
		private set{cnt=value;}
	}
	
	public SkewHeap(){
		root=null;
		this.Count=0;
	}
	
	public void Push(T v){
		NodeSH<T> p=new NodeSH<T>(v);
		root=NodeSH<T>.Meld(root,p);
		this.Count++;
	}
	
	public void Pop(){
		if(root==null)return;
		root=NodeSH<T>.Meld(root.L,root.R);
		this.Count--;
	}
	
	public T Top{
		get{return root.Val;}
	}
	
	int cnt;
	NodeSH<T> root;
	
	class NodeSH<S> where S : IComparable<S> {
		public NodeSH<S> L, R;
		public S Val;

		public NodeSH(S v){
			Val = v;
			L = null; R = null;
		}
		public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b){
			if(a == null)return b;
			if (b == null) return a;
			if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b);
			a.R = Meld(a.R, b);
			swap(ref a.L, ref a.R);
			return a;
		}

		static void swap<U>(ref U x, ref U y) {
			U t = x; x = y; y = t;
		}
	}
}



Measured memory_bytes: 31316
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
ll t[200];
ll gcd(ll x,ll y)  
{  
	if(x%y==0){
		return y;
	}
	if(y%x==0){
		return x;
	}
    if(y==0){
    	return x;
	} 
	return gcd(y,x%y);
} 
ll gcd2(ll a,ll b){
	if(a%b==0){
		return a;
	}
	if(b%a==0){
		return b;
	}
	ll c=gcd(a,b);
	ll r=a/c;
	r=r*b;
	return r;
}
int main()
{
	ll n;
	cin>>n;
	cin>>t[0];
	ll ans;
	ans=t[0];
	for(ll i=1;i<n;i++){
		cin>>t[i];
		ans=gcd2(t[i],ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
 
using namespace std;
 
using ll = long long int; 
 
void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;
 
    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}
 
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}
 
ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}
 
const int MAX = 50;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(void){
 
  ll x, y;
  cin>>x>>y;
  int ans = 0;
  int goal;

  ll dist;
  ll dist1 = abs(y - x);
  ll dist2 = abs(-y - x);

  if(dist1 < dist2){
    goal = y;
    dist = dist1;
  } else{
    goal = -y;
    dist = dist2;
  }

  x += dist;

  if(x==y){
    cout<<dist<<endl;
    return 0;
  }else if(x == -y){
    cout<<dist+1<<endl;
    return 0;
  }else{
    x -= dist;
    if(x!=0){
      x *= -1;
      ans += 1;
    }
    if(x==y){
      cout<<ans<<endl;
      return 0;
    }
    x += dist;
    ans += dist;

    if(x == y){
      cout<<ans<<endl;
      return 0;
    }else{
      cout<<ans+1<<endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    int res = 0;
    rep(i, s.size()/2) {
        if(s[i]!=s[s.size()-1-i]) res++;
    }

    cout << res << endl;
    
    return 0;
}

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

int main() {
    long long n, a, b; cin >>n >> a >>b;
    long long ret;
    if ( (b-a)%2 == 0 ) { ret = (b-a)/2; }
    else { ret = min(a-1, n-b) + 1 + (b-a-1) / 2; }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static int[] fact;
    public static int mod;
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        mod = 998244353;
        fact = new int[3000001];
        fact[0] = 1;
        for(int i=1; i<fact.length; i++) fact[i] = (int)((1L*fact[i-1]*i)%mod);

        long ans = getAns(n, 3*m, 2*m);
        int sign = -1;
        for(int numOnes = m+1; numOnes <= n; numOnes++) {
          //out.println(ans);
          if((3*m - numOnes) % 2 != 0) continue;
          ans += (1L * sign * (1L*choose(n, numOnes) * getAns(n, (3*m-numOnes)/2, m) % mod)) % mod; //* choose(numOnes-1, numOnes-m-1)) % mod;
          //out.println(getAns(n-numOnes, 3*m-numOnes, 2*m));
        //  sign = -1*sign;
          ans += mod;
          ans %= mod;
        }
        out.println(ans);

        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
    // Exponentation
    public static int getAns(int num, int sum, int upperbound) {
      if((sum ==0) && (num == 0)) return 1;
      long ans = 0L + 1L*choose(sum+num-1, num-1) - (1L*num*choose(num-1+(sum-upperbound-1), num-1))%mod  + mod;
      return (int)(ans%mod);
    }
    public static int exp(int base, int e) {
      if(e == 0) return 1;
      if(e == 1) return base;
      int val = exp(base, e/2);
      int ans = (int)(1L*val*val % mod);
      if(e % 2 == 1)
        ans = (int)(1L*ans*base % mod);
      return ans;
    }
    public static int inv(int base) {
      return exp(base, mod-2);
    }
    public static int choose(int n, int m) {
      if(n<0) return 0;
      if(m<0) return 0;
      if(m>n) return 0;
      return (int)(1L*(1L*fact[n]*inv(fact[m]) %mod)*inv(fact[n-m]) % mod);
    }
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll n,i,j,x,y,ans,k;
	ans=0;
	vl v;
	sc(n);sc(k);
	for(i=0;i<n;i++){
		sc(j);
		v.pb(j);
		ans+=2*min(abs(k-v[i]),abs(v[i]));
	}
	pr(ans);


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a1, a2, a3;
    
    cin >> a1 >> a2 >> a3;
    
    
    if(a1 >= a2 && a1 >= a3 && a2 >= a3){
    
    cout << a2-a3 + a1-a2 << endl;
    
    }else if(a1 >= a2 && a1 >= a3 && a3 >= a2){
    
    cout << a3-a2 + a1-a3 << endl;
    
    }else if(a2 >= a3 && a2 >= a1 && a1 >= a3){
    
    cout << a1-a3 + a2-a1 << endl;
    
    }else if(a2 >= a3 && a2 >= a1 && a3 >= a1){
    
    cout << a3-a1 + a2-a3 << endl;
    
    }else if(a3 >= a2 && a3 >= a1 && a1 >= a2){
    
    cout << a1-a2 + a3-a1<< endl;
    
    }else {
    
    cout << a2-a1 + a3-a2 << endl;
    
    }
    
    
    
//////////////////////////////////////////////////////
return 0;}

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


class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] a_str = Console.ReadLine().Split(' ');
        int[] a = new int[N];
        for(int i=0; i<N; i++){
            a[i] = int.Parse(a_str[i]);
        }

        int maxnum = 100000;
        int maxsum = 0;
        int sum;
        int[] count = new int[maxnum];

        for(int i=0; i<N; i++){
            count[a[i]] += 1;
        }

        for(int x=0; x<maxnum-2; x++){
            sum = count[x] + count[x+1] + count[x+2];
            if(sum > maxsum) maxsum = sum;
        }

        Console.WriteLine(maxsum);
    }
}

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

int main(){
  ll n;
  cin >> n;
  ll cnt=0;
  vector<ll> a(n);
  for(ll i=0; i<n; i++) cin >> a[i];
  for(ll i=0; i<n; i++){
    for(ll j=i+1; j<n; j++){
      for(ll k=j+1; k<n; k++){
          if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
            ll x=min(a[i],min(a[j],a[k]));
            ll y=max(a[i],min(a[j],a[k]));
            ll z=(a[i]+a[j]+a[k])-(x+y);
            if(abs(x-y)<z && z<x+y) cnt++;
          }
       }
    }
  }
  cout << cnt << endl;
}
                       
  

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	int a,b,tmp;
	while (1){
		scanf("%d %d",&a,&b);
		if (a==0 && b==0)
			break;
		if (a>b){
		tmp=a;a=b;b=tmp;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a = s.size();

    ll ans = 0;
    rep(i,1<<(a-1)) {
        int now = 0;
        int len = 1;
        ll sum = 0;
        rep(j,a-1) {
            if (i&(1<<j)) {
                sum += stoll(s.substr(now,len));
                now = j+1;
                len = 1;
            } else {
                len++;
            }
        }
        sum += stoll(s.substr(now));
        ans += sum;
    }
    cout << ans << endl;
}

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

int main() {
    int d, n;
    cin >> d >> n;
    int div = pow(100, d);
    if(n <= 100) n += n/100;
    int ans = n * div;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int INF = 100000;

int main() {
	int n;
	cin >> n;
	vector<int>p(n), q(n);
	rep(i, n) {
		cin >> p[i];
	}
	rep(i, n) {
		cin >> q[i];
	}
	vector<int>a(n);
	rep(i, n) {
		a[i] = i + 1;
	}
	map<vector<int>, int>mp;
	do {
		mp[a] = mp.size();
	} while (next_permutation(a.begin(), a.end()));
	int ans = abs(mp[p] - mp[q]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5248
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int x,t;
int main()
{
	fast;
	cin>>x>>t;
	if (t>x)
	   cout<<0<<endl;
	else
	   cout<<x-t<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]arg){
        Scanner sc = new Scanner(System.in);
        while(true){
            String x = sc.next();
            int y=x.length();
            if(x.equals("0")) {
                break;
            }else{
                int sum = 0;
                for(int i=0;i<y;i++){
                    char c = x.charAt(i);
                    int n = c - '0' ;
                    sum = sum + n;
                }
                System.out.println(sum);
            }
        }
    }
}


Measured memory_bytes: 26384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

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

    int n, m; ll k;
    cin >> n >> m >> k;
    ll s1=0, s2=0;
    vector<int> one(n), two(m);
    for(int i = 0; i < n; ++i){
        cin >> one[i];
    }
    for(int i = 0; i < m; ++i){
        cin >> two[i];
        s2 += two[i];
    }
    int p = m - 1;
    int ans = 0;
    if(s2 <= k){
        ans = m;
    }
    for(int i = 0; i < n; ++i){
        s1 += one[i];
        while(p >= 0 && s2 > k - s1){
            s2 -= two[p];
            p--;
        }
        if(s1 + s2 <= k)
            ans = max(ans, i + 1 + p + 1);
    }
    if(s1 <= k){
        ans = max(ans, n);
    }
    s2 = 0;
    p = n - 1;
    for(int i = 0; i < m; ++i){
        s2 += two[i];
        while(p >= 0 && s1 + s2 > k){
            s1 -= one[p];
            p--;
        }
        if(s1 + s2 <= k)
            ans = max(ans, i + 1 + p + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4808
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static List<long> LevelN;
    static List<long> SumN;
    static void Main(string[] args){
        var NX  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        
       var N = NX[0];
       var X = NX[1];
       LevelN = new List<long>();
       for(int i = 0;i <= 50;i++){
           var NPatti = (long) Math.Pow(2,i+1)-1;
           LevelN.Add(NPatti);
       }
       SumN = new List<long>();
       SumN.Add(1); 
       for(int i = 1;i <= 50;i++){
           SumN.Add(2*SumN[i-1]+3);
       }
       Console.WriteLine(CountPatti(N,X));
    }
    
    //Nはレベル、Xはルンルンが食べる量
    static long CountPatti(long N,long X){
        if(X <= 0){
            return 0;
        }
        else if(N == 0){
            return 1;
        }
        else if(X >= SumN[(int)N]){
            return LevelN[(int)N];
        }
        else
        {
            //半分以上のパティを食べるか
            if(SumN[(int)N]/2 < X){
                return CountPatti(N-1,X-SumN[(int)N-1]-2)+1+LevelN[(int)N-1];
            }else{
                return CountPatti(N-1,X-1);
            }
        }
    }
         
}


Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int l = 0, r = n-1, cnt = 0;
	while(l < r){
		if(s[l] == 'W' and s[r] == 'R')
			cnt++, l++, r--;
		else{
			if(s[l] == 'R')
				l++;
			if(s[r] == 'W')
				r--;
		}
	}
	cout<<cnt<<endl;
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans;
    ans = ans % mod;
    if(b % 2 == 1){
        ans =ans * a;
        ans = ans % mod;
    }
    return ans;
}

ll comb[250000];

int main() {
    //cout.precision(10);
    vector<ll> prime;
    for(ll i = 2; i <= 40000; i++){
        bool checker = true;
        for(ll j = 2; j * j <= i; j++){
            if((i % j) == 0){
                checker = false;
                break;
            }
        }
        if(checker){
            prime.push_back(i);
            //cout << i << endl;
        }
    }
    ll n, m;
    cin >> n >> m;
    comb[n - 1] = 1;
    ll ans = 1;
    ll inv[250000];
    for(ll i = 1; i <= 245000; i++){
        inv[i] = beki(i, mod - 2);
    }
    for(ll i = n; i <= 240000; i++){
        comb[i] = comb[i - 1] * i;
        comb[i] = comb[i] % mod;
        comb[i] = comb[i] * inv[i - n + 1];
        comb[i] = comb[i] % mod;
    }
    //cout << comb[n] << endl;
    for(ll i = 0; i < prime.size(); i++){
        ll divide = 0;
        while((m % prime[i]) == 0){
            m = m / prime[i];
            divide++;
        }
        ans = ans * comb[n - 1 + divide];
        ans = ans % mod;
    }
    if(m > 1){
        ans *= n;
        ans = ans % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int k, s;
	cin >> k >> s;
	int ans = 0;

	REP(i, k + 1){
		REP(j, k + 1){
			int z = s - i - j;
			if (z <= k && z >= 0) ans++;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> sumE(n+1), sumW(n+1);
	sumE[0] = 0, sumW[0] = 0;

	for (int i = 1; i <= n; i++){
		sumE[i] = sumE[i-1];
		sumW[i] = sumW[i-1];
		if (s[i-1] == 'E'){
			sumE[i] += 1;
		}else{
			sumW[i] += 1;
		}
	}
	int ans = MOD;
	for (int i = 1; i <= n; i++){
		int temp1 = sumW[i-1];
		int temp2 = sumE[n] - sumE[i];
		ans = min(ans, temp1 + temp2);
	}

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


Measured memory_bytes: 6076
MOD = 10**9 + 7

def mod_inverse(a, m):
    res = 1
    n = m-2
    while n > 0:
        if n & 1:
            res = (res * a) % m
        a = (a * a) % m
        n //= 2
    return res

def solve(x, y):
    a = -y + 2*x
    b = 2*y - x
    if (a < 0) or (b < 0):
        return 0
    if a % 3 + b % 3 != 0:
        return 0
    a //= 3
    b //= 3
    n, k = a+b, a
    p, q = 1, 1
    for i in range(k):
        p = p * (n-i) % MOD
        q = q * (i+1) % MOD
    return (p * mod_inverse(q, MOD)) % MOD

x, y = map(int, input().split())
print(solve(x, y))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;
    int p_min = INT_INF;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (p_min >= a)
        {
            count++;
            p_min = a;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, Q = map(int, input().split())
counts = [0] * N

def get_graph(N):
    graph = [ [] for _ in range(1) for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1

        graph[a].append(b)
        graph[b].append(a)

    return graph

## graph は [[1], [0, 2, 3], [1], [1]]
## 例えば2 なら、1, 3, 4(0, 2, 3)が入ってる
graph = get_graph(N)
#print(graph)

# まず親にだけ足す
ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(current, parent):
    for child in graph[current]:
        if child == parent:
            continue

        ### 親には最初に足してあるので、子・孫だけ考えればいい
        # 子には親のが既に入ってる、孫は（親＋子）を足せばいい
        # 曾孫なら（親＋子＋孫）になってるやつを足せばいい
        ans[child] += ans[current]
        dfs(child, current)

dfs(0, -1)
print(*ans)

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = 100005;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;
int n,k,a[102];

int win_dp[maxn];

int cal(int stone)
{
    //if(val==0) return 1;
    if(stone<a[1]) return 0;

    int &win=win_dp[stone];
    if(win!=-1){
        return win;
    }
    win=0;
    f1(i,n) if(a[i]<=stone)
    win|=!cal(stone-a[i]);

    return win;
}

int main() {

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

    cin>>n>>k;

    f1(i,n) cin>>a[i],win_dp[a[i]]=1;


    memset(win_dp , -1 , sizeof(win_dp));


    int win=cal(k);
    if(win) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}


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

int main () {
    int a, b;
    cin >> a >> b;
    if (a < b)
        cout << "a < b\n";
    else if (a > b)
        cout << "a > b\n";
    else 
        cout << "a == b\n";
    return 0;
}


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

int main()
{
	int n;
	long a[100000];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	int v=0;
	long minv=labs(a[0]),sum=0;
	for(int i=0;i<n;i++){
		if(a[i]<0) v++;
		if(labs(a[i])<minv) minv=labs(a[i]);
		sum+=labs(a[i]);
	}
	
	cout<<((v%2)? sum-2*minv:sum)<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#ユークリッド互除法！
def gcd(a,b):
  if(a<b):
    a,b=b,a
  if(b==0):
    return a
  c= a%b
  return gcd(b,c)

a,b,c,d=map(int,input().split())

a_c=a//c
a_d=a//d
a_cd=a//(c*d//gcd(c,d))
a_ans=a-a_c-a_d+a_cd
#print(a_ans,a,a_c,a_d,a_cd)

b_c=b//c
b_d=b//d
b_cd=b//(c*d//gcd(c,d))
b_ans=b-b_c-b_d+b_cd
#print(b_ans,b,b_c,b_d,b_cd)

ans=1
if(a%c==0 or a%d==0):
  ans=0

print(int(b_ans-a_ans)+ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B;

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

    cout<<(A-1)*(B-1)<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

bool ispal (string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return (t == s);
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t1 = s.substr(0, (n-1)/2);
    string t2 = s.substr((n+3)/2-1);
    if (ispal(s) and ispal(t1) and ispal(t2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
X,N=map(int,input().split())



#print(plist)
l=list(range(-2,105))

if N >0:
    plist=list(map(int,input().split()))

    for i in range(len(plist)):
        l.remove(plist[i])


#print(l)
ans=[]
for i in range(len(l)):
    ans.append(abs(l[i]-X))

print(l[ans.index(min(ans))])

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

int main(){
	int n;
	scanf("%d",&n);
	
	int a[n+1],b[n+1];
	scanf("%d",&a[1]);
	
	int sum=a[1];
	for(int i=2;i<=n;i++){
		a[i]=a[i-1]+1;
		sum+=a[i];
	}
	
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		if(a[i]==0){
			printf("%d",sum);
			return 0;
		}else if(a[i]<0) a[i]=-a[i];
	}
	
	sort(a+1,a+n+1);
	if(b[1]<0){
		printf("%d",sum+a[1]);
	}else{
		printf("%d",sum-a[1]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,l[11],ans;
void dfs(int x,int A,int B,int C,int s){
    if (x>n){
        if (A && B && C) ans=min(ans,s+abs(a-A)+abs(b-B)+abs(c-C));
        return;
    }
    dfs(x+1,A,B,C,s);
    dfs(x+1,A+l[x],B,C,s+10*(A>0));
    dfs(x+1,A,B+l[x],C,s+10*(B>0));
    dfs(x+1,A,B,C+l[x],s+10*(C>0));
}
int main(){
    ans=1e9;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for (i=1;i<=n;i++) scanf("%d",&l[i]);
    dfs(1,0,0,0,0);
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


int ori[1700][1700];


int main(){
    int O[2];
    int n,m,t,p;
    while(1){
        cin >> n >> m >> t >> p;
        if(n == 0)break;
        for(int i = 0;i < 700;i++){ // 初期化
            for(int j = 0;j < 700;j++){
                ori[i][j] = 0;
            }
        }
        
        O[0] = 0; O[1] = 0;
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                ori[O[0]+i][O[1]+j] = 1;
            }
        }
        
        for(int iii = 0;iii < t;iii++){ //折る動作
            int d,c;
            cin >> d >> c;
            if(d == 1){
                for(int i = 0;i < m;i++){
                    for(int j = 0;j < c;j++){
                        ori[O[0]+i][O[1]+j+(c-j-1)*2+1] += ori[O[0]+i][O[1]+j];
                        ori[O[0]+i][O[1]+j] = 0;
                    }
                }
                O[1] += c;
                n = max(n-c,c);
            }else if(d == 2){
                for(int j = 0;j < n;j++){
                    for(int i = 0;i < c;i++){
                        ori[O[0]+i+(c-i-1)*2+1][O[1]+j] += ori[O[0]+i][O[1]+j];
                        ori[O[0]+i][O[1]+j] = 0;
                    }
                }
                O[0] += c;
                m = max(m-c,c);
            }
        }
        
        for(int ii = 0;ii < p;ii++){
            int x,y;
            cin >> x >> y;
            cout << ori[O[0]+y][O[1]+x] << endl;
        }

    }
}


Measured memory_bytes: 7644
#include <stdio.h>


void sort(int x[],int len){
	int i,j;
	int tmp;
	for(i = 0;i < len;i++){
		for(j = 0;j < len-1-i;j++){
			if(x[j] > x[j+1]){
				tmp = x[j];
				x[j] = x[j+1];
				x[j+1] = tmp;
			}
		}		
	}
}
void ans(int x[],char type,int len){
	int i,j;

	for(i = 0,j = 1;j < 14;i++,j++){
		if(x[i] == 0){
			printf("%c %d\n",type,j);
		}
		if(x[i] > j){
			printf("%c %d\n",type,j);
			i--;	
		}
		
	}
}

int main(void){
	char type;
	int number;
	int n;
	int s[14]={0},h[14]={0},c[14]={0},d[14]={0};
	int sc,hc,cc,dc;
	sc=hc=cc=dc=0;
	int i,j,cou=0;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
	scanf(" %c%d",&type,&number);
		switch(type){
			case 'S':
				s[sc++] = number;
				break;
			case 'H':
				h[hc++] = number;
				break;
			case 'C':
				c[cc++] = number;
				break;
			case 'D':
				d[dc++] = number;
				break;
		}
	}
	sort(s,sc);
	sort(h,hc);
	sort(c,cc);
	sort(d,dc);
	ans(s,'S',sc);
	ans(h,'H',hc);
	ans(c,'C',cc);
	ans(d,'D',dc);
	
	return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>	
#include<limits>
#include<ctime>
#include<stack>	
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
	
typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}

int main() {
  ll D,N;
  cin >> D >> N ;
  if(N == 100) N = 101;
  if(D == 0) {
    cout << N << endl;
  } else if(D == 1) {
    cout << N*100 << endl;
  } else {
    cout << N*10000 << endl;
  }
  return 0;
}


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

namespace C_Dice_and_Coin
{
    class Program
    {
        static void Main(string[] args)
        {
            string []str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            double[] P = new double[N];

            for (int i = 1; i < N+1; i++)
            {
                int score = i;
                int bekijou = 0;
                while (score <= K - 1)
                {
                    score *= 2;
                    bekijou += 1;
                }
                P[i-1] = 1/(double)N;
                for(int j = 0; j < bekijou; j++)
                {
                    P[i-1] /= (double)2;
                }
            }
            double result = P.Sum();
            Console.Write(result);
            //Console.ReadKey();

        }

        
    }
}


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

const int MAX = pow(2, 30);

int main() {
    while (true) {
        double r;
        cin >> r;
        if (r == 0) {
            break;
        }
        for (int i = 2; i < MAX; i++) {
            int j = (int) floor(i / (M_PI + r));
            for ( ; j < MAX; j++) {
                double diff = (double) i / j - M_PI;
                if (-r <= diff && diff <= r) {
                    cout << i << "/" << j << endl;
                    goto end;
                } else if (diff < -r) {
                    break;
                }
            }
        }
    end:;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int w,h;
	int x,y;
	
	while(1)
	{
		cin>>h>>w;
		if (w==0 && h==0)
			break;
		for(y=0 ; y<h ; y++)
		{
			for(x=0 ; x<w ; x++)
			{
				if(x==0 || x==w-1 ||y==0 ||y==h-1)
					cout<<"#";
				else
					cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(all(a));
	int ans = 0, r = 0;
	rep(l,n){
		while(r < n && a.at(r) <= a.at(l) + 2){
			r++;
		}
		ans = max(ans, r - l);
		int k = a.at(l);
		while(l < n && a.at(l) == k) l++;
		l--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#https://qiita.com/masashi127/items/88436e16e3672b387a58
#--------------------------------------------
import math
def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0  else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

n=100000
input_list = sieve_of_erastosthenes(n)
prime_list = [i for i, b in enumerate(input_list) if b == True]
#print(prime_list)
#print(sum(prime_list))

#--------------------------------------------

count=[0 for i in range(100002)]
for i in prime_list:
  count[i]=1
#print(count)

nitakazu_count=[0 for i in range(100002)]
for i in range(50001):
  if count[2*i+1]==1 and count[i+1]==1:
    nitakazu_count[2*i+1]=1


dict = {0:0}
ruiseki_count=[0 for i in range(100002)]
for i in range(100000):
#  ruiseki_count[i+1]=ruiseki_count[i]+nitakazu_count[i+1]
  dict [i+1]=dict[i]+nitakazu_count[i+1]

#print(ruiseki_count)

nn=int(input())

for i in range(nn):
  aa,bb=[int(i) for i in input().split()]
#  print(ruiseki_count[bb]-ruiseki_count[aa-1])
  print(dict[bb]-dict[aa-1])




Measured memory_bytes: 20468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    
    int before = (r * x) - d;
    for(int i = 0; i < 10; i++) {
        cout << before << endl;
        before = (r * before) - d;
    }
    
    return 0;
}



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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n, m;

int main() {
    
    for (int i = 1; i <= 5; i++) {
        scanf("%d", &n);
        if (n != i) {
            printf("%d\n", i);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
long long dich(int b){
	if(b < 32) return 1LL<<b;
	int a = b/2;
	b-=a;
	long long ans = 1LL<<b;
	return ans*(1LL<<a);
}
main(){
	int n,p,temp;
	cin >> n >> p;
	int chan = 0;
	int le =0;
	For(i,1,n)	{
		cin >> temp;
		if(temp%2) {
			le++;
		}	else	{
			chan++;
		}
	}	
//	long long A = 0;
//	long long B = 0;	
//	A = dich(le);
//	if(A>1) A/= 2; 	
//	B = dich(chan);		
//	if(le==0&& p==1) A = 0;
	if(le==0){
		if(p==0){			
			cout << dich(n);
		}	else	{
			cout << 0;
		}
	}	else	{		
		cout << dich(n-1);
	}
}

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

const int N = 3e3+10;

char s[N],t[N],ans[N];
int dp[N][N],path[N][N];

int main()
{
    cin>>(s+1)>>(t+1);
    int lens = strlen(s+1),lent = strlen(t+1);
    for (int i = 1;i<=lens;i++)
    {
        for (int j = 1;j<=lent;j++)
        {
            if (s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1,path[i][j] = 1;
            else
            {
                if (dp[i-1][j] > dp[i][j-1]) dp[i][j] = dp[i-1][j],path[i][j] = 2;
                else dp[i][j] = dp[i][j-1],path[i][j] = 3;
            }
        }
    }
    // cout<<dp[lens][lent]<<'\n';
    int i = lens,j = lent,len = 0;
    while (path[i][j] > 0)
    {
        switch(path[i][j])
        {
            case 1:
                ans[len++] = s[i];
                i--,j--;
                break;
            case 2: i--; break;
            case 3: j--; break;
        }
    }
    for (int i = len-1;i>=0;i--) cout<<ans[i];
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535
#define EPS (1e-10)
#define rep(i,n) for (int i = 0; i < (n); ++i)


int main()
{
  ll x, y, z;
  cin >> x >> y >> z;
  printf("%lli %lli %lli\n", z, x, y);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = new String[n];
		HashMap<String, Long> map = new HashMap<>();

		long ans = 0;
		for (int i = 0; i < n; i++) {
			String s[] = br.readLine().split("");
			Arrays.sort(s);
			str[i] = "";

			for (int j = 0; j < 10; j++) {
				str[i] += s[j];
			}

			if (map.containsKey(str[i])) {
				long l = map.get(str[i]) + 1;
				ans += l;
				map.put(str[i], l);
			} else {
				map.put(str[i], 0L);
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 109144
#include<iostream>
using namespace std;
 
int main()
{
  int a;
  cin >> a;
  if(a <= 10)
  {
      cout << "ABC00" <<a <<endl;
  }
  else if(a < 100)
  {
  cout << "ABC0"  << a << endl;
  }
  else
  {cout <<"ABC" << a <<endl;
  }
 
}

Measured memory_bytes: 256