akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N,M;
long double dp[21][121];

long double POW(long double x,ll count){

	if(count == 0){
		return 1.0;
	}else if(count % 2 == 0){
		return POW(x*x,count/2);
	}else{
		return x*POW(x,count-1);
	}
}

void func(){

	long double E = 0.0,next_E,A,P,POW_P;
	ll index = 0,next_index;
	ll left,right,mid;

	while(index < M){

		A = 0;
		P = 0;

		for(ll i = N; i <= 6*N; i++){

			if(i <= E){

				P += dp[N][i];

			}else{

				A += i*dp[N][i];
			}
		}

		if(P == 1.0){
			printf("%.10Lf\n",E);
			return;
		}

		left = index+1,right = M,mid = (left+right)/2;
		next_index = M;

		while(left <= right){

			POW_P = POW(P,mid-index);
			next_E = (A*(1.0-POW_P))/(1.0-P)+POW_P*E;

			if(floor(next_E) > floor(E)){

				next_index = mid;
				right = mid-1;

			}else{
				left = mid+1;
			}
			mid = (left+right)/2;
		}

		POW_P = POW(P,next_index-index);
		next_E = (A*(1.0-POW_P))/(1.0-P)+POW_P*E;

		E = next_E;
		index = next_index;
	}
	printf("%.10Lf\n",E);
}

void calcDP(){

	for(int num = 0; num <= 20; num++){
		for(int value = 0; value <= 120; value++){
			dp[num][value] = 0;
		}
	}

	dp[0][0] = 1.0;
	for(int num = 0; num <= 19; num++){
		for(int value = 0; value <= 114; value++){
			for(int dice = 1; dice <= 6; dice++){
				dp[num+1][value+dice] += dp[num][value]/6.0;
			}
		}
	}
}

int main(){

	calcDP();

	while(true){
		scanf("%lld %lld",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3328
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <vector>
#include <set>
#include <algorithm>

int main()
{
    int64_t n, m;
    scanf("%" PRId64 " %" PRId64, &n, &m);

    if (n >= m)
    {
        puts("0");
        return 0;
    }

    std::vector<int64_t> x;
    for (int64_t i = 0; i < m; i++)
    {
        int64_t xv;
        scanf("%" PRId64, &xv);
        x.push_back(xv);
    }
    std::sort(x.begin(), x.end());

    std::vector<int64_t> xd;
    for (int64_t i = 0; i < m - 1; i++)
    {
        xd.push_back(x[i + 1] - x[i]);
    }
    std::sort(xd.begin(), xd.end());
    std::reverse(xd.begin(), xd.end());

    int64_t count = 0;
    for (int64_t i = n - 1; i < m - 1; i++)
    {
        count += xd[i];
    }

    printf("%" PRId64 "\n", count);
    return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

map<string,int> mp;

int solve(string s) {
//  cout << s << endl;
  if (s.size()==0) return 0;
  int nest = 0;
  bool f = 0;
  REP(i, s.size()) {
    if (s[i] == '(') {
      nest++;
      f = 1;
    } else if (s[i] == ')') {
      nest--;
    }
    if (nest == 0 && (i+1==s.size() || isdigit(s[i+1]) || isupper(s[i+1]) || s[i+1] == '(')) {
      int skip = 0;
      int num = 1;
      if (i+1<s.size() && isdigit(s[i+1])) {
        if (i+2<s.size() && isdigit(s[i+2])) {
          skip = 2;
          num = atoi(s.substr(i+1, 2).c_str());
        } else {
          skip = 1;
          num = s[i+1] - '0';
        }
      }
      int a;
      if (f) {
        a = solve(s.substr(1, i-1));
      } else {
        a = mp[s.substr(0, i+1)];
      }
      //cout << a << " " << num << endl;
      if (a==0) return -1;
      int b = solve(s.substr(i+1+skip));
      if (b==-1) return -1;
      return num*a + b;
    }
  }
  return 0;
}

int main() {
  string s;
  while(cin >> s, s!="END_OF_FIRST_PART") {
    int a;
    cin >> a;
    mp[s] = a;
  }
  while(cin >> s, s!="0") {
    int res = solve(s);
    if (res < 0) cout << "UNKNOWN" << endl;
    else cout << res << endl;
  }
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    static int K;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        K = sc.nextInt();
        sc.nextLine();
        String S = sc.nextLine();
        ArrayList<Integer> sum = new ArrayList<Integer>();
        int f = Integer.parseInt(S.substring(0, 1));
        int cnt = f > 0 ? 1 : -1;
        sum.add(0);

        for (int i = 1; i < S.length(); i++) {
            if (cnt > 0) {
                if (S.charAt(i) == '1') {
                    cnt++;
                } else {
                    sum.add(cnt);
                    cnt = -1;
                }
            } else {
                if (S.charAt(i) == '0') {
                    cnt--;
                } else {
                    sum.add(cnt);
                    cnt = 1;
                }
            }
        }
        sum.add(cnt);
        sum.add(0);

        if(sum.get(1)>0)sum.remove(0);


        // System.out.println(Arrays.toString(sum.toArray()));
        int[] dp = new int[sum.size()+1];
        int val = 0;
        for (int i = 0; i < sum.size(); i++) {
            val += Math.abs(sum.get(i));
            dp[i+1]=val;
        }
        int max=0;
        for (int i = 0; i < sum.size(); i+=2) {
            // int val = 0;
            // int magic = 0;
            // for (int j = i; j <= i + K * 2 && j<sum.size(); j++) {
            //     // System.out.println(i + K * 2);
            //     val += Math.abs(sum.get(j));
            // }
            max=Math.max(max,dp[Math.min(i + K * 2+1,sum.size()-1)]-dp[i]);
        }

        System.out.println(max);
    }

    // static int hand(ArrayList<Integer> sum, int tg, int start, int cnt, int val) {
    //     if (cnt >= k)
    //         return val;

    //     if (tg < -1 || tg < sum.size())
    //         return val;
    //     if (tg == -1)
    //         return val + Math.abs(sum.get(0));
    //     else if (tg == sum.size())
    //         return val + Math.abs(sum.get(sum.size() - 1));

    //     return Math.max(hand(sum, tg - 2, start, cnt + 1, val), hand(sum, tg + 2, start, cnt + 1, val));
    // }
}

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i=a; i<(b); i++)

#define FORd(i, a, b) for (int i=a; i<(b); --i) 

int t, n;

void solve(){

    string ans;

    while (t--){

        ans += "ACL";

    }

    cout << ans << "\n";

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cin >> t;

    solve();

    return 0; 

}

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

using namespace std;

int main () {
	int N,x; cin >> N >> x;
    if(x==1||x==2*N-1) cout << "No" << endl;
	else {
		vector<int> ans(2*N-1);
		for(int i=0;i<2*N-1;++i) ans[i]=i+1;
		swap(ans[x-1],ans[N-1]);
		if(ans[N-1]<ans[N-2]&&ans[N-1]<ans[N]) swap(ans[0],ans[N-2]);
		else if(ans[N-1]>ans[N-2]&&ans[N-1]>ans[N]) swap(ans[N],ans[2*N-2]);
		cout << "Yes" << endl;
		for(int i=0;i<2*N-1;++i) cout << ans[i] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    using namespace __gnu_pbds;

    typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update>
        Bt;

    for (;;) {
        int n, k, m; cin >> n >> k >> m;
        if (!n) break;

        Bt b;
        rep(i, 1, n + 1) b[i] = i;

        for (int i = m - 1; b.size() > 1; i = (i + k - 1) % b.size()) {
            auto it = b.find_by_order(i);
            // cout << "Erase: " << it->second << endl;
            b.erase(it);
        }

        cout << b.begin()->second << endl;
    }
}



Measured memory_bytes: 3692
#include<stdio.h>
#include<ctype.h>

typedef struct{
  char s[9];
  int p;
}lo;

int match(int p,char *m){
  int i,n;
  for(i=7,n=p;i>-1;i--,n/=10){
    if(isdigit(m[i])){
      if(n%10!=((int)m[i]-(int)'0')){
	return 0;
      }
    }
  }
  return 1;
}
int main(){
  int n,m,j,i,pr;
  lo ls[100];
  long long int ans;
  do{
    scanf("%d %d",&n,&m);
    if(!n&&!m) break;
    for(i=0;i<n;i++) scanf("%s %d",ls[i].s,&(ls[i].p));
    for(i=0,ans=0;i<m;i++){
      scanf("%d",&pr);
      for(j=0;j<n;j++){
	if(match(pr,ls[j].s)){
	  ans+=ls[j].p;
	  break;
	}
      }
    }
    printf("%ld\n",ans);
  }while(1);
  return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};



int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());
  
  mint ans;
  mint res = 1;
  
  for(int i=k-1;i<n;i++){
    ans += res*(a[i]-a[n-1-i]);
    res = res*(i+1)/(i-k+2);
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
l,r = 0,0
ans = 0
s = 0
while l < n:
  if r < n and s+a[r] == s^a[r]:
    s += a[r]
    r += 1
    #print(s)
  else:
    ans += r-l
    s -= a[l]
    #print(s)
    l += 1

print(ans)


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n;
	string s; cin>>n>>s;

	int sum[3][4001]={};
	for(int i=n-1;i>=0;i--){
		sum[0][i]=sum[0][i+1]+(s[i]=='R'?1:0);
		sum[1][i]=sum[1][i+1]+(s[i]=='G'?1:0);
		sum[2][i]=sum[2][i+1]+(s[i]=='B'?1:0);
	}

	lint ans=0;
	for(char c1:"RGB") for(char c2:"RGB") if(c1!=c2) {
		rep(i,n) if(s[i]==c1) {
			for(int j=i+1;j<n;j++) if(s[j]==c2) {
				int tmp;
				if(c1!='R' && c2!='R') tmp=sum[0][j+1];
				if(c1!='G' && c2!='G') tmp=sum[1][j+1];
				if(c1!='B' && c2!='B') tmp=sum[2][j+1];
				ans+=tmp;

				int k=2*j-i;
				if(k<n && s[k]!=c1 && s[k]!=c2) ans--;
			}
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3776
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s;
    scan(s);
    int n = s.length.to!int;

    auto a = new int[](n + 1);
    foreach (i ; 0 .. n) {
        a[i + 1] = a[i] ^ (1<<(s[i] - 'a'));
    }

    debug {
        writeln(a);
    }

    auto opt = new int[](n + 1);
    auto dp = new int[](1<<26);
    dp[] = n;
    dp[0] = 0;

    foreach (i ; 1 .. n + 1) {
        int tmp = dp[a[i]];

        foreach (j ; 0 .. 26) {
            tmp = min(tmp, dp[a[i] ^ (1<<j)]);
        }

        opt[i] = tmp + 1;
        dp[a[i]] = min(dp[a[i]], opt[i]);
    }

    debug {
        writeln(opt);
    }

    writeln(opt[n]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

using namespace std;

int main(){
    int N,K,ans=1000000000;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());

    for(int i=0;i<N-K+1;i++){
        ans = min(ans,vec[i+K-1]-vec[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    string s;
    ll k,size=0;
    cin>>s>>k;
    rep(i,s.size()) {
        if(s.at(i)=='1') size++;
        else if(s.at(i)!='1') break;
            }
    if(k<=size) cout<<1<<endl;
    else cout<<s.at(size)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String str = sc.nextLine();
	        char ch[] = str.toCharArray();
	        for(int i = 0; i < str.length(); i++){
	            if(Character.isUpperCase(ch[i])){
	                ch[i] = Character.toLowerCase(ch[i]);
	            }
	            else if(Character.isLowerCase(ch[i])){
	                ch[i] = Character.toUpperCase(ch[i]);
	            }
	        }
	        System.out.println(ch);
	    }
	}



Measured memory_bytes: 26348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define repe(i,n) for (int i = 1; i <= (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define ll long long
using namespace std;
typedef vector<vector<int> > Graph;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){

    ll X;
    cin >> X;
    ll a,b;
    rep(i,divisor(X).size()){
        ll k = divisor(X).at(i);
        a = 0;
        b = -k;
        bool ok = false;
        while(b<0||(a*a*a*a*a-b*b*b*b*b<=X)){
            if(a*a*a*a*a-b*b*b*b*b==X) {ok = true; break;}
            else{a += 1;
            b+=1;}
        }
       if(ok) break;
    }
    cout << a << " " << b << endl;
}
 

Measured memory_bytes: 3572
n=int(input())
h=list(map(int,input().split()))
l=[]
for i in range(n-1):
    if h[i+1]-h[i]<=0:
        l.append(1)
    else:
        l.append(0)
ans=0
mn=0
for j in range(len(l)):
    if l[j]==0:
        ans=0
    else:
        ans+=1
        mn=max(ans,mn)
print(mn)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define mx 1e18
#define pb push_back
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<ll int,ll int>
#define ff first
#define ss second


int main()
{
	// fastio
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll int n,k;
	cin>>n>>k;

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

	ll int dp[n+1][k+1];
	memset(dp,0,sizeof(dp));

	ll int predp[n+1][k+1];
	memset(predp,0,sizeof(predp));

	for(ll int i=0;i<=min(ar[1],k);i++)
	{
		dp[1][i]=1LL;
	}

	predp[1][0]=dp[1][0];
	for(ll int i=1;i<=k;i++)
	{
		predp[1][i]=predp[1][i-1]+dp[1][i];
		predp[1][i]%=md;
	}

	for(ll int i=2;i<=n;i++)
	{
		ll int e = ar[i];
		for(ll int j=0;j<=k;j++)
		{
			ll int tmp = j-e;

			if(tmp<0)
				tmp=0;

			if(tmp==0)
			{
				dp[i][j]=(predp[i-1][j])%md;
			}
			else
			{
				dp[i][j]=((predp[i-1][j]%md) -(predp[i-1][tmp-1]%md)+md)%md;
			}

			dp[i][j]%=md;

			predp[i][j]=(j>0 ? predp[i][j-1] : 0) + dp[i][j];
			predp[i][j]%=md;
		}
	}

	cout<<dp[n][k]<<endl;

	return 0;
}


Measured memory_bytes: 158080
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int n,m,l;
    cin >> n >> m >> l;
    long a[n][m];
    long b[m][l];
    long c[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cin >> a[i][j];
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++) cin >> b[i][j];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            c[i][j] = 0;
            for(int k = 0; k < m; k++) c[i][j] += a[i][k] * b[k][j];
            cout << c[i][j];
            if(j != l-1) cout << " ";
        }
        cout << endl;
    }
}



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

int main() {
  string N;
  cin >> N;

  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0

for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
        bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
if f:
  b+=bb
print(a,b)


Measured memory_bytes: 28272
#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;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001

const ll mod=998244353;
const ll inf=1e18+2;

#define int ll

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	int n,x,m;
	cin>>n>>x>>m;

	set<int> st;
	st.insert(x);

	vector<int> v;

	int ans=x;
	int now=x;
	v.pb(x);

	while(v.size()<n)
	{
		now*=now;
		now%=m;
		if(now==0) break;
		else if(st.find(now)!=st.end()) break;
		ans+=now;
		v.pb(now);
		st.insert(now);
	}
	
	if(now==0 or v.size()==n) cout<<ans<<'\n';
	else
	{

		int indx=0;
		while(indx<v.size() and v[indx]!=now) indx++;

		n-=indx;

		int left=v.size()-indx;

		int tans=0;

		for(int j=indx;j<v.size();j++) tans+=v[j];

		int times=n/left;

		times--;

		ans+=tans*times;

		if(n%left)
		{
			times=n%left;

			while(times--)
			{
				ans+=v[indx];
				indx++;
			}
		}

		cout<<ans<<'\n';

	}



	
	

	return 0;
}

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

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let n = read1::<usize>();
    let a = readn::<usize>(" ");

    let mut ans = 0;
    for i in 0..n {
        if i < a[i] - 1 && i == a[a[i] - 1] - 1 {
            ans += 1;
        }
    }
    
    println!("{}", ans);
}

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

int main()
{
 int n;
  cin >> n;
  
  string as[100] = {};
  int ai[100] = {};
  for (int i = 0;i < n;i++)
	cin >> as[i] >> ai[i];
  
  string x;
  cin >> x;
  int sum = 0;
  bool f = false;
  for (int i = 0;i < n;i++)
  {
    if (f)
      sum+= ai[i];

   if (as[i] == x) {

     f=true;
   }
  
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <vector>
#include <cstdio>

template <typename Tp>
class fenwick{
    std::vector<Tp> tree;
    std::size_t n;

public:
    fenwick(size_t _n) : n(_n) {
        tree.resize(n);
    }

    void add(size_t pos, Tp val){
        while(pos < n) {
            tree[pos] += val;
            pos |= (pos + 1);
        }
    }

    Tp get(size_t pos) {
        Tp v{};
        do{
            v += tree[pos];
            pos &= pos + 1;
        }while(pos-- > 0);

        return v;
    }

    Tp get(size_t left, size_t right){
        if(left == right) return {};
        else if(left == 0) return get(right - 1);
        else return get(right - 1) - get(left - 1);
    }
};

int main(){
    int n, q, com, x, y;
    std::scanf("%d%d", &n, &q);

    fenwick<int> bit(n);

    for(int i=0;i<q;++i){
        std::scanf("%d%d%d", &com, &x, &y);
        if(com == 0) bit.add(x-1, y);
        else std::printf("%d\n", bit.get(x-1, y));
    }

    return 0;
}



Measured memory_bytes: 2768
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, dp[4005][4005];
string s;

int main() {
    cin >> s;
    n = s.size()*2;
    dp[0][0] = 1;
    REP(i,n){
        REP(j,n){
            ll k=0, t=0;
            if(i<n/2){
                t = s[i]-'0';
                k = ((i+1)*2)-j-t-i;
            }
            else{
                k = n-j-i;
            }
            if(k>0){
                dp[i+1][j+t] += dp[i][j];
                dp[i+1][j+t] %= MOD;
            }
            if(j+t>0){
                dp[i+1][j-1+t] += dp[i][j];
                dp[i+1][j-1+t] %= MOD;
            }
        }
    }
    
    
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 125440
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	ss := make([]string, h)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	ans := make([]string, h)
	for i, s := range ss {
		for j, c := range s {
			if c == '.' {
				count := 0
				if i != 0 {
					if ss[i-1][j] == '#' {
						count++
					}
				}
				if i != 0 && j != w-1 {
					if ss[i-1][j+1] == '#' {
						count++
					}
				}
				if j != w-1 {
					if ss[i][j+1] == '#' {
						count++
					}
				}
				if i != h-1 && j != w-1 {
					if ss[i+1][j+1] == '#' {
						count++
					}
				}
				if i != h-1 {
					if ss[i+1][j] == '#' {
						count++
					}
				}
				if i != h-1 && j != 0 {
					if ss[i+1][j-1] == '#' {
						count++
					}
				}
				if j != 0 {
					if ss[i][j-1] == '#' {
						count++
					}
				}
				if i != 0 && j != 0 {
					if ss[i-1][j-1] == '#' {
						count++
					}
				}
				ans[i] += strconv.Itoa(count)
			} else {
				ans[i] += "#"
			}
		}
	}

	for _, a := range ans {
		fmt.Println(a)
	}
}


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

int	main()
{
  string	str;
  int		c = 0;
  
  cin >> str;
  for(int i = 0; i < 3; i++)
    if (str.at(i) == 'o')
      c++;
  cout << (700 + c * 100) << endl;
  return (0);
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    int N,H,W;
    cin >> N >> H >> W;
    int ans = 0;
    rep(i,N){
        int h,w;
        cin >> h >> w;
        if(h >= H && w >= W) ++ans; 
    }

    cout << ans << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int size = s.size();
    REP(i, size)
    {
        if (s.at(i) == ',')
        {
            s.at(i) = ' ';
        }
    }
    cout << s << "\n";
    return 0;
}


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


using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var ans = 0;
            if(AB[1]==1)
            {
                Console.WriteLine(0);
                return;
            }
            for(var i=0;i<AB[1];i++)
            {
                if (!(((ans * AB[0]))-((0<ans)?ans-1:0)< AB[1])) break;
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b){
        a=log10(a+b)+1;
        cout<<a<<endl;
    }
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 3005;

/* ...o(^-^)o... */

lint median(vector<lint> vec){
    int n = vec.size();
    sort(all(vec));
    if(n%2) return vec[n/2];
    else return vec[n/2-1]+vec[n/2];
}

int main(){
    int n; cin >> n;
    vector<lint> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    lint ma = median(a), mb = median(b);
    lint res = mb - ma + 1;
    out(res);
}

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

void print(const vector<int> & vec){
    for (auto v : vec) cout << v << ' ';
    cout << endl;
}

vector<int> find_shift(int d, const string & A, const string & B){
    int n = A.size();
    vector<int> S(n, n);
    for (int i = 0; i != n; ++i){
        if (A[i] == '0'){
            S[i] = 0;
            continue;
        }
        int j = i;
        while (B[j] == '0') j = (j + n + d) % n;
        S[i] = ((j - i) * d + n) % n;
    }
    return S;
}

int select_targets(int p, const string & A, const string & B, vector<int> & targets){
    int n_flips = 0;
    int n = A.size();
    for (int i = 0; i != n; ++i){
        int j = (i + p + n) % n;
        if (A[i] != B[j]){
            ++n_flips;
            if (A[i] == '1'){
                targets.push_back(i);
            }
        }
    }
    return n_flips;
}

vector<pair<int, int>> select_LRs(int p, const vector<int> & targets, const vector<int> & L, const vector<int> & R){
    vector<pair<int, int>> LRs;
    LRs.push_back(make_pair(0, 0));
    if (p < 0){
        for (auto t : targets){
            if (L[t] <= -p or R[t] == 0) continue;
            LRs.push_back(make_pair(- L[t] - p, R[t]));
        }
    }else{
        for (auto t : targets){
            if (R[t] <= p or L[t] == 0) continue;
            LRs.push_back(make_pair(- L[t], R[t] - p));
        }
    }
    return LRs;
};

int calc_steps(int p, const string & A, const string & B, const vector<int> & L, const vector<int> & R){
    vector<int> targets;
    auto n_flips = select_targets(p, A, B, targets);
    auto LRs = select_LRs(p, targets, L, R);
    sort(LRs.begin(), LRs.end());
    int record = 3 * A.size();
    int maxR = 0;
    for (auto & LR : LRs){
        int Li = - LR.first;
        assert(Li >= 0);
        int Ri = LR.second;
        record = min(record, Li + maxR);
        maxR = max(maxR, Ri);
    }
    record = min(record, maxR);
    return record * 2 + abs(p) + n_flips;
}

bool is_all_zero(const string & S){
    for (char c : S) if (c == '1') return false;
    return true;
}

int solve(const string & A, const string & B){
    if (is_all_zero(B)){
        return is_all_zero(A) ? 0 : -1;
    }
    auto L = find_shift(-1, A, B);
    auto R = find_shift( 1, A, B);
    int record = 3 * A.size();
    int n = A.size();
    for (int p = -n; p <= n; ++p){
        record = min(record, calc_steps(p, A, B, L, R));
    }
    return record;
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B;
    cin >> A >> B;
    cout << solve(A, B) << endl;
    return 0;
}

Measured memory_bytes: 384
K = gets.to_i
ary = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts ary[K - 1]

Measured memory_bytes: 1788
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, D, A;
  cin >> N >> D >> A;
  vector<pair<int, int>> XH(N);
  rep(i, N) {
    ll X, H;
    cin >> X >> H;
    XH[i] = make_pair(X, H);
  }

  sort(all(XH));

  vector<int> bomb(N);
  ll ans = 0;
  int l = 0, b = 0;
  rep(i, N) {
    int x = XH[i].first, h = XH[i].second;
    while (XH[l].first < x - D * 2) {
      b -= bomb[l];
      l++;
    }

    h -= b * A;
    chmax(h, 0);
    bomb[i] = (h + A - 1) / A;
    b += bomb[i];
    ans += bomb[i];
  }

  out(ans);
}


Measured memory_bytes: 2560
import java.io.*;

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

	String str = br.readLine();
	String[] str2 = str.split(" ",0);
	int num1 = Integer.parseInt(str2[0]);
	int num2 = Integer.parseInt(str2[1]);
	int num3 = Integer.parseInt(str2[2]);
	if((num1<num2)&&(num2<num3)){
	    System.out.println("Yes");
	}
	else{
	    System.out.println("No");

	}

    }
}

Measured memory_bytes: 24160
# -*- coding utf-8 -*-

MOD = int(1e9 + 7)
N, M = map(int, input().split())

broken = [False] * (N + 1)
for i in range(M):
    broken[int(input())] = True

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if broken[1] else 1

for i in range(N - 1):
    dp[i + 2] = 0 if broken[i + 2] else dp[i] + dp[i + 1]
    dp[i + 2] %= MOD

print(dp[N] % MOD)


Measured memory_bytes: 7660
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	LL a, b, c, k, sum = 0;
	cin >> a >> b >> c >> k;
	if(a <= k && k > 0){
		sum += a;
		k -= a;
	}
	else if(k > 0){
		sum += k;
		k -= k;
	}
	if(b <= k && k > 0){
		k -= b;
	}
	else if(k > 0){
		k -= k;
	}
	if(c <= k && k > 0){
		sum -= c;
		k -= c;
	}
	else if(k > 0){
		sum -= k;
		k -= c;
	}
	cout << sum;
} 

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

int qcol[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
bool flag = false;

void dfs(int i){
  if(i == 8){
    flag = true;
    return;
  }
  if(qcol[i] > 0){
    dfs(i+1);
    return;
  }
  for(int j=0; j<8; j++){
    bool fl = true;
    for(int k=0; k<8; k++){
      if(k==i || qcol[k]<0){
        continue;
      }
      if(j==qcol[k] || i-k==qcol[k]-j || i-k==j-qcol[k]){
        fl = false;
        break;
      }
    }
    if(fl){
      qcol[i] = j;
      dfs(i+1);
      if(flag){
        return;
      }
      else{
        qcol[i] = -1;
      }
    }
  }
  return;
}

int main(){
  int n; cin >> n;
  for(int i=0; i<n; i++){
    int x, y; cin >> x >> y;
    qcol[x] = y;
  }
  dfs(0);
  for(int i=0; i<8; i++){
    for(int j=0; j<8; j++){
      if(qcol[i] == j){
        cout << 'Q';
      }
      else{
        cout << '.';
      }
    }
    cout << "" << endl;
  }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int n,x;cin>>n>>x;
    if(x==1||x==2*n-1)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        if(n==2){
            REP(i,3)cout<<i+1<<endl;
        }
        else if(x==2){
            REP(i,n-2)cout<<5+i<<endl;
            cout<<3<<endl;
            cout<<2<<endl;
            cout<<1<<endl;
            cout<<4<<endl;
            REP(i,n-3)cout<<n+3+i<<endl;
        }else{
            vector<int> v;
            REP(i,x-3)v.push_back(i+1);
            REP(i,2*n-x-2)v.push_back(x+2+i);
            vector<int> w={x-1,x,x+1,x-2};
            v.insert(v.begin()+n-2,w.begin(),w.end());
            REP(i,2*n-1){
                cout<<v[i]<<endl;
            }
        }
        return 0;
    }
    return 0;
}

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

int main() {
	
	int n; cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  double ans=0;
  reps(i,n){
    double tmp=1.0/n;
    ll score=i;
    while(score<k){
      score*=2;
      tmp/=2.0;
    }
    ans+=tmp;
  }
  coutd(ans);
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const ll INF=1e18;
 
int N,M;
int a[2010],b[2010],c[2010];
ll x[1010];
 
int main(){
 
cin>>N>>M;
 
for(int i=0; i<M; i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    a[i]--; b[i]--;
}
 
for(int i=1; i<N; i++) x[i]=-INF;
 
for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
        x[b[j]]=max(x[b[j]],x[a[j]]+c[j]);
    }
}
 
ll A=x[N-1];
for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
        x[b[j]]=max(x[b[j]],x[a[j]]+c[j]);
    }
}
ll B=x[N-1];
 
if(A==B) cout<<x[N-1]<<endl;
else cout<<"inf"<<endl;
 
return 0;
 
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#define INT long long
#define MOD 1000000007
using namespace std;

INT n, dt[60][4][4];
string s[2];

INT dp(int x, int y, int z)
{
    if( x == n ) return 1;
    if( ~dt[x][y][z] ) return dt[x][y][z];
    INT &ret = dt[x][y][z] = 0;
    if( s[0][x] == s[1][x] )
    {
        for(int i = 1 ; i <= 3 ; i++)
            if( i != z and i != y )
                ret += dp(x+1, i, i), ret%=MOD;
    }
    else
    {
        for(int i = 1 ; i <= 3 ; i++ )
            for(int j = 1 ; j <= 3 ; j++ )
                if( i!=j and i != y and j != z )
                    ret += dp(x+2, i, j), ret %= MOD;
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    memset(dt, -1, sizeof(dt));
    cin>>n>>s[0]>>s[1];
    cout<<dp(0, 0, 0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include<iomanip>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  int A, B, C;
  cin >> A >> B >> C;

  map<int, int> m;
  m[A]++;
  m[B]++;
  m[C]++;
  
  if (m[5] == 2 && m[7] == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using LL = long long int;

class Solution {
public:

};

int main() {
    Solution s;

    int N;
    cin >> N;
    int total_grade = 0;
    int min_grade_not_ten = 100;
    for(int i = 0; i < N; ++ i) {
        int grade;
        cin >> grade;
        total_grade += grade;
        if(grade % 10 != 0) {
            min_grade_not_ten = min(min_grade_not_ten, grade);
        }
    }
    cout << (total_grade % 10
             ? total_grade
             : min_grade_not_ten != 100 ? total_grade - min_grade_not_ten : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_VAL_MAX		100005									// 最大値

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
	int liACnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liACnt);

	// 数字数取得
	int li1Cnt[D_VAL_MAX];
	memset(li1Cnt, 0, sizeof(li1Cnt));
	for (i = 0; i < liACnt; i++) {
		int liVal;
#ifdef D_TEST
		fscanf(szpFpT, "%d", &liVal);
#else
		fscanf(stdin, "%d", &liVal);
#endif

		// 数字数セット
		for (j = 0; j < 3; j++) {
			li1Cnt[liVal + j]++;
		}
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 最大数字数取得
	int liMax = 0;
	for (i = 0; i < D_VAL_MAX; i++) {
		if (liMax < li1Cnt[i]) {
			liMax = li1Cnt[i];
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liMax);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

int main() {
  long long k;
  k = 1;
  for(int i = 0; i < 18; i++){
    k = k * 10;
  }
  long long n;
  cin >> n;
  long long s;
  s = 1;
  
  vector<long long> vec(n);
  for(long long i = 0; i < n; i++){
    long long a;
    cin >> a;
    if(a == 0){
      cout << 0;
      return 0;
    }
    vec.at(i) = a;
  }
  
  for(long long i = 0; i < n; i++){
    long long b;
    b = k / s;
    if(vec.at(i) > b){
      cout << -1;
      return 0;
    }
    s = s * vec.at(i);
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 4052