akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

const ll MAX=200000;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<vector<ll>> pos(MAX);
    rep(i,N){
        cin >> A[i];
        A[i]--;
        pos[A[i]].push_back(i);
    }
    rep(i,MAX){
        for (auto p:pos[i]){
            pos[i].push_back(p+N);
        }
    }
    ll now=0,round=1,cycle;
    vector<Pll> cnt;
    while(1){
        ll next=*upper_bound(pos[A[now]].begin(),pos[A[now]].end(),now);
        if (next>N-1){
            round++;
            next-=N;
        }
        cnt.push_back(Pll(round,next));
        if (next==N-1){
            cycle=round;
            break;
        }
        now=next+1;
    }
    ll s=cnt.size();
    K%=cycle;
    if (K==0){
        cout << endl;
        return 0;
    }
    ll lb=-1,ub=s;
    while(ub-lb>1){
        ll mid=(lb+ub)/2;
        if (cnt[mid].first>K){
            ub=mid;
        }
        else {
            lb=mid;
        }
    }
    ll start;
    if (lb==-1){
        start=0;
    }
    else {
        start=cnt[lb].second+1;
    }
    stack<ll> st;
    map<ll,ll> m;
    rep2(i,start,N){
        if (m[A[i]]==0){
            m[A[i]]++;
            st.push(A[i]);
        }
        else {
            ll g=A[i];
            while(1){
                ll x=st.top();
                st.pop();
                m[x]--;
                if (x==g){
                    break;
                }
            }
        }
    }
    vector<ll> ans;
    while(!st.empty()){
        ll t=st.top();
        ans.push_back(t+1);
        st.pop();
    }
    reverse(ans.begin(),ans.end());
    ll s2=ans.size();
    rep(i,s2){
        cout << ans[i];
        if (i!=s2){
            cout << ' ';
        }
        else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 35312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    gya[0]=1;
    gya[1]=1;
    for(int i=2;i<=n;i++){
        gya[i]=gya[i-1]*gyaku(i);
        gya[i]%=mod;
    }
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    ll b[n];
    b[0]=a[0];
    rep(i,1,n)b[i]=b[i-1]^a[i];
    vector<ll> w;
    rep(i,0,n)w.push_back(b[i]);
    sort(w.begin(),w.end());
    w.erase(unique(w.begin(),w.end()),w.end());
    unordered_map<ll,ll> mp;
    rep(i,0,w.size()){
        if(w[i]==0)mp[w[i]]=0;
        else mp[w[i]]=i+1;
    }
    rep(i,0,n)b[i]=mp[b[i]];
    ll m=w.size();
    vector<ll> v[m+2];
    rep(i,0,n){
        
        v[b[i]].push_back(i);
    }
    //rep(i,0,n)cout<<b[i]<<" ";
    bool used[m+2];
    ll ans=0;
    fill(used,used+m+2,false);
    rep(i,0,n-1){
        //cout<<ans<<" ";
        if(used[b[i]])continue;
        if(b[i]==0&&b[n-1]==0){
            ll y=beki(2,v[0].size()-1);
            y--;
            y=(y+mod)%mod;
            ans+=y;
            ans%=mod;
            used[0]=true;
            continue;
        }
        if(b[n-1]!=0&&b[i]!=b[n-1])continue;
        used[b[i]]=true;
            ll jou=1,ka=1;
            ll now=lower_bound(v[0].begin(),v[0].end(),i)-v[0].begin();
        //cout<<now<<endl;
            rep(j,1,v[b[i]].size()){
                ll ne=v[b[i]][j];
                ll r=lower_bound(v[0].begin(),v[0].end(),ne)-v[0].begin();
                jou+=ka*(r-now);
                jou%=mod;
                ka+=jou;
                ka%=mod;
                now=r;
            }
        if(b[n-1]==b[i]){
            ans=(ans+jou-1+mod)%mod;
            continue;
        }
        if(v[b[i]].size()==1){
            ans=(ans+1)%mod;
            continue;
        }
        ans=(ans+ka)%mod;
        
    }
    ans=(ans+1)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 42476
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <memory>

using namespace std;

int main() {
	string reverse = "zyxwvutsrqponmlkjihgfedcba";

	string str;
	cin >> str;

	char first = str.front();

	if (reverse == str) {
		str = "-1";
	}
	else if (str.size() == 26) {
		//後ろから書き換える場所を見つける
		for (int j = str.size() - 1; j >= 0; j--) {
			string nowStr = str;
			for (int i = 0; i < 26; i++) {
				char last = str[j];
				if (str.find('a' + i) == std::string::npos && last < 'a' + i) {
					str[j] = 'a' + i;
					break;
				}
			}

			if (str != nowStr) {
				break;
			}
			else {
				str = str.substr(0, j);
			}
		}

	}
	else {
		for (int i = 0; i < 26; i++) {
			if (str.find('a' + i) == std::string::npos) {
				str += 'a' + i;
				break;
			}
		}
	}

	cout << str;

	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int price[3];

    price[0]=a+b;
    price[1]=b+c;
    price[2]=c+a;

    int ans;
    for(int i=0; i<3; i++){
        if(i==0){
            ans=price[i];
        }else if(ans > price[i]){
            ans=price[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()

a = [3,5,7]

cnt = 0

for i in range(3, len(N)):
	for x in product(a, repeat=i):
		##print(x, len(set(x)))
		if len(set(x)) == 3:
			cnt += 1
			#print(x)

for x in product(a, repeat=len(N)):
	##print(x, len(set(x)))
	if len(set(x)) == 3:
		#print(x)
		p = 0
		for i in range(len(N)):
			p += x[-(i+1)]*10**i
		if int(N) < p:
			print(cnt)
			break
		cnt += 1
else:
	print(cnt)


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int A[n];
  unordered_map<int,int> mp;
  int maxi = INT_MIN;
  for(int i=0;i<n;i++)
  {
    cin>>A[i];
    mp[A[i]]++;
    maxi = max(maxi,A[i]);
  }
  if(mp[maxi]>1)
  {
    for(int i=0;i<n;i++)
      cout<<maxi<<"\n";
  }
  else
  {
    int maxi2=INT_MIN;
    for(int i=0;i<n;i++)
    {
      if(maxi2<A[i] && A[i]<maxi)
        maxi2=A[i];
    }
    //cout<<maxi<<" "<<maxi2<<"\n";
    for(int i=0;i<n;i++)
    {
      if(A[i] == maxi)
        cout<<maxi2<<"\n";
      else cout<<maxi<<"\n";
    }
  }
}
  

Measured memory_bytes: 7076
import math

n = int(input())
for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, input().split())
    d = math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2)
    if d < ra - rb:
        print(2)
    elif d < rb - ra:
        print(-2)
    elif abs(rb - ra) <= d and d <= ra + rb:
        print(1)
    else:
        print(0)

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

int n, s, ans;
int f[330];

void cheat(){
f[200] = 13918;f[201] = 14519;f[202] = 15611;f[203] = 16278;f[204] = 16780;f[205] = 18686;f[206] = 19280;f[207] = 19586;f[208] = 20795;f[209] = 22385;f[210] = 22896;f[211] = 23948;f[212] = 24970;f[213] = 26012;f[214] = 27096;f[215] = 28467;f[216] = 28427;f[217] = 30540;f[218] = 31272;f[219] = 31774;f[220] = 33264;f[221] = 34748;f[222] = 34499;f[223] = 36299;f[224] = 36596;f[225] = 38456;f[226] = 38926;f[227] = 39984;f[228] = 39386;f[229] = 42068;f[230] = 42848;f[231] = 42424;f[232] = 42925;f[233] = 45044;f[234] = 44584;f[235] = 46040;f[236] = 45496;f[237] = 46890;f[238] = 47036;f[239] = 47341;f[240] = 47646;f[241] = 48887;f[242] = 48840;f[243] = 48044;f[244] = 48540;f[245] = 50066;f[246] = 48970;f[247] = 49062;f[248] = 49062;f[249] = 48970;f[250] = 50066;f[251] = 48540;f[252] = 48044;f[253] = 48840;f[254] = 48887;f[255] = 47646;f[256] = 47341;f[257] = 47036;f[258] = 46890;f[259] = 45496;f[260] = 46040;f[261] = 44584;f[262] = 45044;f[263] = 42925;f[264] = 42424;f[265] = 42848;f[266] = 42068;f[267] = 39386;f[268] = 39984;f[269] = 38926;f[270] = 38456;f[271] = 36596;f[272] = 36299;f[273] = 34499;f[274] = 34748;f[275] = 33264;f[276] = 31774;f[277] = 31272;f[278] = 30540;f[279] = 28427;f[280] = 28467;f[281] = 27096;f[282] = 26012;f[283] = 24970;f[284] = 23948;f[285] = 22896;f[286] = 22385;f[287] = 20795;f[288] = 19586;f[289] = 19280;f[290] = 18686;f[291] = 16780;f[292] = 16278;f[293] = 15611;f[294] = 14519;f[295] = 13918;f[296] = 13026;f[297] = 12141;f[298] = 11647;f[299] = 10678;f[300] = 9892;f[301] = 9392;f[302] = 8773;f[303] = 7830;f[304] = 7424;f[305] = 6909;f[306] = 6156;f[307] = 5672;f[308] = 5130;f[309] = 4493;f[310] = 4305;f[311] = 3676;f[312] = 3180;f[313] = 2837;f[314] = 2533;f[315] = 2010;f[316] = 1824;f[317] = 1528;f[318] = 1252;f[319] = 1040;f[320] = 819;f[321] = 619;f[322] = 498;f[323] = 360;f[324] = 234;f[325] = 177;f[326] = 107;f[327] = 51;f[328] = 28;f[329] = 9;
}

void solve(int k, int sum, int bits){
	if( sum < 0 ) return ;
	
	if( k == n+1 ){
		if( sum == 0 ) ans++;
		return;
	}
	
	for(int i=0 ; i <= 9 ; i++ ){
		if( bits & (1 << i) ) continue;
		solve( k+1 , sum - i * k , bits | (1 << i) );
	}
}

int main(){
	cheat();
	while( cin >> n >> s ){
		int max_sum = 0;
		int a[10];
		for(int i=0 ; i < n ; i++ ){
			a[i] = 10-n+i;
		}
		for(int i=1 ; i <= n ; i++ ){
			max_sum += i * a[i-1];
		}
		
		if( s > max_sum ){
			cout << 0 << endl;
		}else if( s == max_sum ){
			cout << 1 << endl;
		}else{
			if( n == 10 && s >= 200 ){
				cout << f[s] << endl;
			}else{
				ans = 0;
				solve( 1 , s , 0 );
				cout << ans << endl;
			}
		}
	}
}

Measured memory_bytes: 872
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_D

class String
  def print(a,b)
      puts self[a..b]
  end
  def reverse(a,b)
      tmp = self.dup
      for i in 0..(b-a)
        tmp[a+i] = self[b-i]
      end
      tmp
  end
  def replace(a,b,p)
      tmp = self.dup
      for i in 0..(b-a)
        tmp[a+i] = p[i]
      end
      tmp
  end
  
end

str = gets.chomp
n = gets.to_i

n.times.each do
    data = gets.split
    if data[0]=="replace" 
        str = str.replace(data[1].to_i,data[2].to_i,data[3])
    elsif data[0] == "reverse"
        str = str.reverse(data[1].to_i,data[2].to_i)
    elsif data[0] == "print"
        str.print(data[1].to_i,data[2].to_i)
    end
end

Measured memory_bytes: 6140
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, b = map(int, readline().split())
  if a>=13:
    print(b)
  elif a>=6 and a<=12:
    print(int(b/2))
  else:
    print(0)
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long B[4000] = {};
long long A[4000] = {};
long long multiply[4000] = {};
long long dp[4000] = {};
int main() {
	long long p;
	cin >> p;
	REP(i, p) {
		cin >> A[i];
	}
	for (long long i = 0; i < p; ++i) {
		long long now = 1;
		for (long long q = 0; q < p; ++q) {
			if (i == q) continue;
			now *= (i - q);
			now %= p;
			now += 2 * p;
			now %= p;
		}
		for (long long q = 0; q < p; ++q) {
			if ((now * q)%p == A[i]) {
				multiply[i] = q;
				break;
			}
		}
	}
	dp[0] = 1;
	for (long long i = 0; i < p; ++i) {
		for (long long q = p; q >= 0; --q) {
			dp[q + 1] += dp[q];
			dp[q + 1] %= p;
			dp[q] = dp[q] * -i;
			dp[q] %= p;
			dp[q] += 2 * p;
			dp[q] %= p;
		}
	}
	for (long long i = 0; i < p; ++i) {
		long long pre_dp[4000] = {};
		for (long long q = p; q >= 0; --q) {
			pre_dp[q] = dp[q];
		}
		long long next_dp[4000] = {};
		for (long long q = p; q >= 1; --q) {
			next_dp[q - 1] = pre_dp[q];
			pre_dp[q - 1] += next_dp[q - 1] * i;
			pre_dp[q - 1] %= p;
			pre_dp[q - 1] += 2LL * p;
			pre_dp[q - 1] %= p;
		}
		for (long long q = 0; q < p; ++q) {
			B[q] += multiply[i] * next_dp[q];
			B[q] %= p;
		}
	}
	REP(i, p) {
		long long geko = 0;
		long long tmp = 1;
		for (long long q = 0; q < p; ++q) {
			geko += tmp * B[q];
			geko %= p;
			tmp *= i;
			tmp %= p;
		}
		assert(geko == A[i]);
	}
	REP(i, p) {
		cout << B[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){

  long r,d,x;
  scanf("%ld %ld %ld", &r, &d, &x);

  for (int i = 0; i < 10; i++) {
    x = r*x-d;
    printf("%ld\n", x);
  }

  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,now=0;
	cin >> n;
	vvll ab(2,vll(n));
	rep(i,n) cin >> ab[0][i] >> ab[1][i];
	for(ll i=n-1;i>=0;--i){
		if((now+ab[0][i])%ab[1][i]){
			now+=ab[1][i]-((now+ab[0][i])%ab[1][i]);
		}
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int main()
{
	int i, j, ans = 0, n;
	char s[27];

	scanf("%s", s);

	n = strlen(s);


	for (i = 0; i < n; i++){
		for (j = 1 + i; j < n; j++){
			if (s[i] == s[j])
				ans++;
		}
	}

	if (ans != 0)
		printf("no");
	else
		printf("yes");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

void tabuada(int valor) {
	for(int index = 1; index < 10; ++index)
		cout << valor << "x" << index << "=" << (valor * index) << endl;	
}

int main() {
	for(int index = 1; index < 10; ++index)
		tabuada(index);

	return 0;
}


Measured memory_bytes: 3012
N,M,K=gets.split.map(&:to_i)

as = gets.split.map(&:to_i).reverse + gets.split.map(&:to_i)

l = 0
r = N
sum = as[0...r].inject(:+)

max = (sum <= K ? r-l : 0)
while l <= N && r < N+M
    if K < sum
        sum -= as[l]
        l += 1
    else
        sum += as[r]
        r += 1
    end

    if sum <= K
        len = r-l
        max = len if max < len
    end
end

puts max

Measured memory_bytes: 46552
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    
    for(int i=1;i<=n;i++){
        int hoge=i;
        double pre=1;
        
        while(hoge<k){
            hoge*=2;
            pre/=2;
        }
        
        pre/=n;
        ans+=pre;
    }
    
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int num1 = 1;
  int counter = 0;
  
  for(int i = 0; i < N; i++) {
    num1 *= 2;
    if(num1 > N) {
      break;
    }
    counter++;
  }
  
  int num2 = 1;
  vector<int> even(counter);
  for(int i = 0; i < counter; i++) {
    num2 *= 2;
    even.at(i) = num2;
  }
    reverse(even.begin(), even.end());
    even.push_back(1);
    cout << even.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
	int N, x;

	cin >> N;

	if (N % 1000 == 0){
		cout << 0 << endl;
	}
	else{
		x = N / 1000 + 1;
		cout << x * 1000 - N << endl;
	}

	return 0;
}

Measured memory_bytes: 3568
from math import *
A, B, X = map(int, input().split())
X /= A
if A*B/2 > X:
    l = 2 * X / B
    print(degrees(atan(B/l)))
else:
    y = A * B - X
    l = 2 * y / A
    print(degrees(atan(l/A)))


Measured memory_bytes: 3188
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def check(h, x, A, B):
    h = [ hi - B * x for hi in h ]
    c = 0
    for hi in h:
        if hi <= 0:
            continue
        c += math.ceil(hi/(A-B))
    return c <= x

def main():
    N, A, B = l_inpl()
    h = line_inpl(N)

    l, r = 0, max(h)//B + 1000
    while l + 1 != r:
        mid = (l+r) // 2
        if check(h, mid, A, B):
            r = mid
        else:
            l = mid
    
    print(r)

if __name__ == "__main__":
    main()


Measured memory_bytes: 119232
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int[] b = new int[m];
		for(int i=0;i<m;i++) {
			b[i]=Integer.parseInt(sc.next());
		}
		int count=0;
		for(int i=0;i<n;i++) {
			int total=c;
			for(int j=0;j<m;j++) {
				total+=b[j]*Integer.parseInt(sc.next());
			}
			if(total>0) {
				count++;
			}

		}
		System.out.println(count);

	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <algorithm>

int a[15];
int main()
{
	int N;scanf("%d",&N);
	for(register int i=1;i<=N;i++)
		scanf("%d",&a[i]);
	std::sort(&a[1],&a[N+1]);
	register int sum=0;
	for(register int i=1;i<=N-1;i++)
		sum+=a[i];
	if(a[N]<sum)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<int>a(n);
  vector<int>tmp(1000009,0);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
  }
  for(int i:a){
    if(tmp.at(i)!=0){
      tmp.at(i)=2;
      continue;
    }
    for(int j=i;j<1000009;j+=i){
      tmp.at(j)++;
    }
  }
  int ans=0;
  for(int i:a){
    if(tmp.at(i)==1)
      ans++;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 7932
#include <iostream>
#include <cstring>
using namespace std;
 
static const int MAX_B = 4;
static const int MAX_F = 3;
static const int MAX_R = 10;
 
int main()
{
 
    int n, b, f, r, v;
    int OH[MAX_B][MAX_F][MAX_R];
 
    memset( OH, 0, sizeof( OH ) );
 
    cin >> n;
    for( int i = 0; i < n; i++ ) {
 
        cin >> b >> f >> r >> v;
        OH[b - 1][f - 1][r - 1] += v;
 
    }
 
    for( int i = 0; i < MAX_B; i++ ) {
        for( int j = 0; j < MAX_F; j++ ) {
            for( int k = 0; k < MAX_R; k++ ) cout << " " << OH[i][j][k];
            cout << endl;
        }
        if( i < MAX_B - 1 ) {
            for( int k = 0; k < MAX_R * 2; k++ ) cout << "#";
            cout << endl;
        }
    }
 
    return 0;
 
}

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

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

    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    
    vector<int> ans(n + 1);
    for (int i = n; i > 0; i--)
    {
        ans[i] = a[i];

        for (int j = i + i; j <= n; j += i)
        {
            ans[i] ^= ans[j];
        }
    }

    cout << count(ans.begin(), ans.end(), 1) << endl;

    for (int i = 1; i <= n; i++)
    {
        if (ans[i])
        {
            cout << i << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

vector<int> v[100001];
bool used[100001];
int d[100001];

void dfs(int x, int& sum){
  for(auto y:v[x]){
    if(!used[y]){
      used[y]=1;
      sum+=d[y];
      dfs(y, sum);
    }
  }
}

int main()
{
  string s;
  cin>>s;
  int m=s.size();
  d[0]=s[0]-'a';
  for(int i=1; i<m; i++){
    d[i]=((s[i]-'a')-(s[i-1]-'a')+26)%26;
  }
  int n;
  cin>>n;
  for(int i=0; i<=m; i++){
    v[i].push_back(m-i);
  }
  for(int i=0; i<n; i++){
    int l, r;
    cin>>l>>r;
    l--; r--;
    v[l].push_back(r+1);
    v[r+1].push_back(l);
  }
  bool no=0;
  for(int i=m; i>=0; i--){
    if(used[i]) continue;
    int sum=d[i];
    used[i]=1;
    dfs(i, sum);
    if(i==m) continue;
    if(sum%26!=0){
      no=1;
      break;
    }
  }
  if(no){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
double arr[3005];
double dp[3005][3005];

double solve(ll i,ll c,ll d){
	
	if(i==n and c>d)return 1.0;
	
	if(i==n)return 0;
	
	if(dp[i][c]==100.0){
		
		dp[i][c] = arr[i]*solve(i+1,c+1,d)+(1-arr[i])*solve(i+1,c,d+1);

	}
	//cout<<i<<" "<<c<<" "<<dp[i][c]<<endl;
	return dp[i][c];
}

int main(){
	cin>>n;
	for(ll i=0;i<n;i++)cin>>arr[i];
	//cout<<"yo"<<endl;
	for(ll i=0;i<3001;i++){
		for(ll j=0;j<3000;j++)dp[i][j] = 100.0;
	}
	//cout<<"yo"<<endl;
	cout.precision(10);
	cout<<solve(0,0,0)<<endl;
	
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int path[n] = {0};
  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    path[a-1]++;
    path[b-1]++;
  }
  
  for(int i = 0; i < n; ++i){
    cout << path[i] << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll ans[100010];

int main(){
    int n;
    cin >> n;
    vector<P> vp(n+1);

    rep(i, n) {
        ll a;
        cin >> a;
        vp.push_back({a, i});
    }
    sort(vp.rbegin(), vp.rend()); // aが大きいもの、同立ならiが大きいものから取っていく

    ll idx = LINF;
    rep(i, n){
        idx = min(idx, vp[i].second);
        ans[idx] += (i + 1) * (vp[i].first - vp[i+1].first);
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> w(n),s(n),v(n);
    vector<P> p(n);
    for (int i = 0;i < n;++i) cin >> w[i] >> s[i] >> v[i];
    for (int i = 0;i < n;++i) p[i] = P(w[i]+s[i],i);
    sort(p.begin(),p.end());
    vector<vector<ll>> dp(n+1,vector<ll>(20010,0));
    for (int i = 0;i < n;++i) {
        int x = p[i].second;
        dp[i+1] = dp[i];
        for (int j = 0;j <= s[x];++j) if (j+w[x] < 20010 && dp[i+1][j+w[x]] < dp[i][j]+v[x]) dp[i+1][j+w[x]] = dp[i][j]+v[x];
    }
    cout << *max_element(dp[n].begin(),dp[n].end()) << endl;
    return 0;
}

Measured memory_bytes: 160640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)
#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)


using namespace std;

struct info {
	int year;
	int number;
};

typedef long long int lli;
typedef vector<int> vi;

int main() {
	vector <ipair> city_year,sort_city_year, year_number;
	vi count;
	int n, m, j, y, p;

	cin >> n >> m;

	count.resize(m);

	rep(m) {
		count[i] = 0;
	}

	rep(m) {
		cin >> p >> y;
		city_year.push_back(make_pair(p, y));
	}
	sort_city_year = city_year;
	sort(sort_city_year.begin(), sort_city_year.end());
	
	p = sort_city_year[0].first;
	y = 1;
	count[0] = 1;
	rep(m-1) {
		if (p == sort_city_year[i+1].first)
			y++;
		else {
			p = sort_city_year[i+1].first;
			y = 1;
		}
		count[i+1] = y;
	}

	rep(m) {
		vector<ipair>::iterator ans;
		ans=lower_bound(sort_city_year.begin(), sort_city_year.end(), city_year[i]);
		j = ans - sort_city_year.begin();
		cout.fill('0');
		cout << setw(6) << city_year[i].first;
		cout << setw(6) <<  count[j] << endl;
	}

	return 0;
}

Measured memory_bytes: 3572
import numpy as np


if __name__ == '__main__':
    N = int(input())
    heights = np.array([int(x) for x in input().split(' ')])
    max_height = heights[0]
    num_viewable = 1
    for height in heights[1:]:
        if height >= max_height:
            num_viewable += 1
            max_height = height
    print(num_viewable)


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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
    cin>>n>>m;
    int a[n];
    double s=0;
    for(int x=0;x<n;x++){
        cin>>a[x];
        s+=a[x];
    }
    sort(a,a+n,greater<int>());
    bool f=0;
    for(int x=0;x<m;x++){
        if(1.0*a[x]>=s/(4*m)){

        }else{
            f=1;
            break;
        }
    }
    if(f){
        cout<<"No";
    }else{
        cout<<"Yes";
    }








	
return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
    
    if ((a + b) % 2 == 0){
      cout << (a + b) / 2 << endl;
    }
  
    else{
      cout << (a + b + 1) / 2 << endl;
      
    }
    
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> ans;

void dfs(int ii, string s){
	if(ii == 0){
		ans.push_back(stoll(s));
		return;
	}
	
	for(int i = '0';i <= '9';i++){
		if(abs(s.back()-i) <= 1){
			s.push_back(i);
			dfs(ii-1, s);
			s.pop_back();
		}
	}

	return;
}

signed main(){
	int n;
	cin >> n;

	int keta = 1;
	while(ans.size() < n){
		for(int i = '1';i <= '9';i++){
			if(ans.size()>= n) break;
			string s;
			s.push_back(i);
			dfs(keta-1, s);
		}
		keta++;
	}

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

	cout << ans[n-1] << endl;

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
int A[Nmax];

template <class T>
class Bit{
	vector<T> v;
	public:
	Bit(int n) {
		v = vector<T>(n);
	}
	// i must be 0 <= i < n
	T sum(int i){
		T s=0;
		while(i>0){
			s += v[i];
			i -= i & -i;
		}
		return s;
	}
	// i must be 1 <= i < n
	void add(int i, T x){
		while(i < v.size()){
			v[i] += x;
			i += i & -i;
		}
	}
};


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

    vector<int> pos(N);
    for(int i=0; i<N; i++) pos[A[i]] = i;
    Bit<int> bit(N+1);

    ll ans = 0;
    for(int i=0; i<N-1; i++){
        int l, r;
        if(bit.sum(pos[i]+1)==0){
            l = pos[i]+1;
        } else {
            int lb = 0, ub = pos[i];
            while(ub-lb>1){
                int mid = (lb+ub)/2;
                if(bit.sum(pos[i]+1)-bit.sum(mid)>0){
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            l = pos[i]-lb;
        }
        if(bit.sum(N)-bit.sum(pos[i])==0){
            r = N-pos[i];
        } else {
            int lb = pos[i], ub = N-1;
            while(ub-lb>1){
                int mid = (lb+ub)/2;
                if(bit.sum(mid+1)-bit.sum(pos[i])>0){
                    ub = mid;
                } else {
                    lb = mid;
                }
            }
            r = ub-pos[i];
        }

    //    cout << i+1 << " " << l << " " << r << endl;
       ans += (ll)(i+1)*l*r;
       bit.add(pos[i]+1, 1);
    }
    ans += N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){

	int a[5];

	for(int i=0;i<5;i++)cin>>a[i];
	int sum = 0;
	for(int i=0;i<5;i++){

		if(a[i]<=40)sum+=40;
		else sum += a[i];

	}

	cout<<sum/5<<endl;
}

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

const int mod = 998244353;

int x[205], y[205];
long long p2[205];

bool linear(int i, int j, int k) {
  return (y[j] - y[i]) * (x[k] - x[i]) == (y[k] - y[i]) * (x[j] - x[i]);
}

int main() {
  long long t = 1;
  for (int i = 0; i <= 200; i++) {
    p2[i] = t;
    t *= 2;
    t %= mod;
  }
  int n;
  cin >> n;
  for (int ni = 0; ni < n; ni++) {
    cin >> x[ni] >> y[ni];
  }
  if (n < 3) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  for (int ni = 0; ni < n; ni++) {
    for (int nj = ni + 1; nj < n; nj++) {
      bool feasible = true;
      for (int nk = 0; nk < nj; nk++) {
        if (nk == ni) continue;
        if (linear(ni, nj, nk)) {
          feasible = false;
          break;
        }
      }
      if (!feasible) continue;
      int cnt = 2;
      for (int nk = nj + 1; nk < n; nk++) {
        if (linear(ni, nj, nk)) cnt++;
      }
      ans += p2[cnt] - 1 - cnt - cnt * (cnt - 1) / 2 + mod;
      ans %= mod;
    }
  }
  ans = p2[n] - 1 - n - n * (n - 1) / 2 - ans + mod;
  ans %= mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

long long gcd(long long y, long long x){
    return x ? gcd(x,y%x) : y;
}

int main(){
    ll n,  k;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << min(n%k, abs(n%k - k)) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V, string sep = " ", string end_ = "endl") {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << sep;
    }
    if(end_ == "endl")
        cout << endl;
    else
        cout << end_;
}

template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = in();
    cout << (N % 2 ? ((N + 1) / (2 * N + 0.0)) : 0.5) << endl;
}


Measured memory_bytes: 256
import itertools

if __name__ == '__main__':
    in1 = input().split(' ')
    n = int(in1[0])
    m = int(in1[1])
    arr = []
    for i in range(m):
        arr.append(input().split(' '))
    ps = input().split(' ')

    l = list(itertools.product((True, False), repeat=n))
    c = 0
    for tfs in l:
        isOK = True
        for index, item in enumerate(arr):
            ss = item[1:]
            count = 0
            for s in ss:
                if tfs[int(s) - 1]:
                    count = count + 1
            if (count % 2) != int(ps[index]):
                isOK = False
                break
        if isOK:
            c = c + 1
    print(str(c))


Measured memory_bytes: 3188
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
    
// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
    
fn main() {
    let n: i32      = read();
    let s: String   = read();

    if s.len() % 2 != 0 { 
        println!("No");
        return; 
    }

    let front = &s[0..(s.len()/2)];
    let back = &s[(s.len()/2)..s.len()];

    if front == back { println!("Yes"); } else { println!("No"); }
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;
long long N, K;

vector<long long>backway[100005];

bool caploop;
long long ans;

long long prepare(int pa, int v){
	long long tmp = -1;
	for(int i = 0; i < backway[v].size(); i++){
		tmp = max(tmp, prepare(v, backway[v][i]));
	}
	tmp++;
	if(pa != 0 && v != 0 && tmp == K-1){
		ans++;
		//return 0;
		return -1;
	}
	return tmp;
}

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		long long to;
		cin >> to;to--;
		if(i == 0 && to == 0){
			caploop = true;
		}
		if(i != 0){
			backway[to].push_back(i);
		}
	}
	long long alldep = prepare(-1, 0);

	if(caploop == false){
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11904
// Code Forces
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define pi 3.1415926535
#define fi first
#define se second
#define vec vector
#define str string
#define FOR(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define dvec(v) vec < ll > v
#define sortA(v) sort(v.begin(),v.end())
#define sortD(v) sort(v.begin(),v.end(),greater <int> ())

using namespace std;

int main(){
    fast
    str s1,s2,s3,s4,s5,s6;
    cin>>s1;
    ll n=s1.size();
    s2.assign(s1.begin(),s1.begin()+((n-1)/2));
    s3.assign(s1.begin()+((n+3)/2)-1,s1.end());
    s4=s1;s5=s2;s6=s3;
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    reverse(s3.begin(),s3.end());
    if(s1==s4&&s2==s5&&s3==s6) cout<<"Yes";
    else cout<<"No";
    // my code
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] c = new int[n - 1];
		int[] s = new int[n - 1];
		int[] f = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}

		for (int i = 0; i < n - 1; i++) {
			long t = 0;
			for (int j = i; j < n - 1; j++) {
				if (t > s[j]) {
					t = s[j] + (t - s[j] + f[j] - 1) / f[j] * f[j] + c[j];
				} else {
					t = s[j] + c[j];
				}
			}

			pr.println(t);
		}
		pr.println(0);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 26220
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(int argc, const char * argv[]) {
    
    string S = "";
    cin >> S;
    ll N = S.size();
    
    vector<ll> table = vector<ll>(N, 0);
    table[N-1] = 1;
    for (ll i = N-2; i >= 0; i--) {
        table[i] = (table[i + 1] * 10) % 13;
    }
    vector<ll> dp = vector<ll>(13, 0);

    for (ll i = 0; i < N; i++) {
        vector<ll> tempdp = vector<ll>(13, 0);
        for (ll j = 0; j < 10; j++) {
            if (S[i] != '?' && S[i] != '0' + j) {
                continue;
            }
            ll shift = table[i] * j;
            if (i == 0) {
                tempdp[shift % 13] = 1;
            } else {
                for (ll k = 0; k < 13; k++) {
                    tempdp[(shift + k) % 13] += dp[k];
                }
            }
        }
        for (ll k = 0; k < 13; k++) {
            dp[k] = tempdp[k] % 1000000007;
        }
    }
    
    cout << dp[5];
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
const long double EPS = 1e-6;
 
ll ans;
map<pair<int, int>, int> cnt;
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        long double a;
        int tc = 0, fc = 0;
        cin >> a;

        ll b = llround(a * 1e9);
        while (b % 2 == 0) {
            ++tc;
            b /= 2;
        }
 
        while (b % 5 == 0) {
            ++fc;
            b /= 5;
        }
 
        cnt[{tc, fc}]++;
    }

    for (auto i : cnt) {
        for (auto j : cnt) {
            if (i.first.first + j.first.first >= 18 && i.first.second + j.first.second >= 18) {
                if (i == j) {
                    ans += (ll)i.second * (i.second - 1) / 2;
                }
                else if (j > i) {
                    ans += (ll)i.second * j.second;
                }        
            }
        }
    }

    cout << ans;
}


Measured memory_bytes: 3812
#include "bits/stdc++.h"
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
#define MAX_V (110)

signed main(){
	string va;
	cin >> va;
	int cnt = 0;
	rep(i, 3)
		cnt += va[i] == '1';
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>

using namespace std;

typedef  long long ll;

int main(){
  int n;
  ll a[200001];
  ll cnt[200001] = {0};

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += cnt[i] * (cnt[i]-1)/2;
  }

  for (int i = 0; i < n; i++) {
    cout << sum - cnt[a[i]] * (cnt[a[i]]-1) /2 + (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2 << endl;
  }



  return 0;
}

Measured memory_bytes: 5760
def main():
	n = int(input())
	# b = int(input())
	# a = list(map(int,input().split()))
	l = [list(map(int, input().split())) for _ in range(n)]
	# print(a)
	
	l_s = sorted(l, key=lambda x: x[1])
	# l_s = sorted(l, reverse=True, key=lambda x: x[1])
	# l_s = sorted(l)
	# print(l_s)
	# print(l_s)
	count = []
	for i in l_s:
		count.append(i[1])

	c_max = max(count)
	sime = 0
	out = 0
	for i in l_s:
		 sime += i[0]
		 # print("sime = {}".format(sime))
		 # print("l_s = {}".format(i))
		 if sime > i[1]:
		 	out = 1
		 	break
		# print("c_max is {}".format(c_max))
	if sime <= c_max and out == 0:
		print("Yes")
	elif out == 1:
		print("No")






if __name__ == '__main__':
	main()

Measured memory_bytes: 101208
input_NK = input().split(' ')
N = int(input_NK[0])
K = int(input_NK[1])
rest = [i + 1 for i in range(N)]

for i in range(K):
  di = int(input())
  input_Ai = input().split(' ')
  for j in range(len(input_Ai)):
    if rest.count(int(input_Ai[j])) != 0:
      rest.remove(int(input_Ai[j]))
    
print(len(rest))

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

int main() {
	int n, m, k, a;
	int arr[100] = {};

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> a;
			arr[a]++;
		}
	}

	int sum = 0;
	for (int i = 0; i <= 30; i++) {
		if (arr[i] == n) {
			sum++;
		}
	}

	cout << sum;

	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

def is_satisfied(s):
    ln = len(s)
    check = sorted(list(range(ln - 1, 1, -2)) * 2)
    if ln % 2 == 0:
        check.insert(0, 1)
        check.insert(0, 1)
    else:
        check.insert(0, 0)

    return sorted(s) == check

    # for i in range(ln - 1, 1, -2):
    #     if not s.count(i) == 2:
    #         return False
    # if ln % 2 == 0:
    #     if not s.count(1) == 2:
    #         return False
    # else:
    #     if not s.count(0) == 1:
    #         return False

    # return True


ans = 2 ** (n // 2) % (10 ** 9 + 7)
print(ans if is_satisfied(a) else 0)


Measured memory_bytes: 13880
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > int(1e18):
            print(-1)
            return
    print(prod)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24432