akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define M 1046527
using namespace std;
long long h1(long long key){
	return key%M;
}
long long h2(long long key){
	return 1+(key%(M-2));
}
long long getNum(char c){
	if(c=='A')return 1;
	if(c=='C')return 2;
	if(c=='G')return 3;
	if(c=='T')return 4;
	return 0;
}
long long getValue(char* s){
	long long i=0,value=0;
	while(s[i]){
		value=value*10+getNum(s[i]);
		i++;
	}
	return value;
}
char s[1046527][13],word[13],order[10];
long long n,key,value;
int main(){
		cin>>n;
		for(long long i=0;i<1000006;i++)s[i][0]=0;
		for(long long i=0;i<n;i++){
			scanf("%s %s",order,word);
			value=getValue(word);
			if(order[0]=='i'){
				long long k=0;
				while(true){
					key=(h1(value)+k*h2(value))%M;
					if(strcmp(s[key],word)==0){
						break;
					}else if(strlen(s[key])==0){
						strcpy(s[key],word);
						break;
					}
					k++;
				}
			}else{
				long long k=0;
				while(true){
					key=(h1(value)+k*h2(value))%M;
					if(strcmp(s[key],word)==0){
						cout<<"yes\n";
						break;
					}else if(strlen(s[key])==0){
						cout<<"no\n";
						break;
					}
					k++;
				}
			}
		}
	
	return 0;
} 


Measured memory_bytes: 16408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
# define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    ll n,cnt=0;
    cin>>n;

    while(true)
    {
        if(n%1000==0)
            break;

        n++;
        cnt++;
    }

    cout<<cnt;
   
    
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



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

	vector<ll> p(N + 1);
	repn(i, N) cin >> p[i];

	ll t = 0;
	repn(i, N) { if (p[i] != i) { t++; } }

	if (t <= 2) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");
}

Measured memory_bytes: 504
while True:
    A = []
    s = 0
    a = input().split()
    X, Y = list(map(int,list(a)))
    if X > Y or Y > 10**18 or X < 1:
        continue
    A.append(X)
    while True:
        A.append(A[len(A)-1]*2)
        if A[len(A)-1] > Y:
            break
    s = len(A) - 1
    print(s)
    break

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


int main() {
   int N;
   cin >> N;
   vector<string> V(N);
   rep(i,N) {
       cin >> V[i];
   }

   int count = 0;
   rep(j,N) {
       rep(k,j) {
           if (V[k] == V[j]) {
               count++;
           }
       }
       if (j != 0) {
           if (V[j][0] != V[j - 1][V[j - 1].size() - 1]) {
               count++;
           }
       }
   }
   if (count == 0) {
       cout << "Yes" << endl;
   }
   else {
       cout << "No" << endl;
   }

}



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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	
	int n_obs, n_roads, height, obs_1, obs_2;
	cin >> n_obs >> n_roads;
	int obs[n_obs];
	int good_obs[n_obs];
	for(int i=0;i<n_obs;i++){
		good_obs[i] = 1;
	}
	for(int i=0;i<n_obs;i++){
		cin >> height;
		obs[i] = height;
	}
	// for(int j=0;j<*(&obs + 1) - obs;j++){
	// 	cout << obs[j] << endl;
	// }
	for(int j=0;j<n_roads;j++){
		cin >> obs_1 >> obs_2;
		if(obs[obs_1-1] > obs[obs_2-1]){
			good_obs[obs_2-1] = 0;
		} 
		else if(obs[obs_1-1] < obs[obs_2-1]){
			good_obs[obs_1-1] = 0;
		}
		else{
			good_obs[obs_1-1] = 0;
			good_obs[obs_2-1] = 0;
		}
		// cout << "-------" << endl;
		// for(int j=0;j<*(&obs + 1) - obs;j++){
		// 	cout << good_obs[j] << endl;
		// }
	}
	int count = 0;
	for(int k=0;k<*(&obs + 1) - obs;k++){
		count += good_obs[k];
	}
	cout << count;
}

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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

vector <ll> v[500000];
vector <ll> used;
vector <ll> dp;

ll dfs(ll fr)
{
    used[fr] = 1;
    for(ll i = 0; i < v[fr].size(); i++)
    {
        ll to = v[fr][i];
        if(used[to] == 0)
            dfs(to);
        dp[fr] = max(dp[fr], dp[to] + 1);
    }
    return dp[fr];
}

int main()
{
    ll n, m;
    cin >> n >> m;
    for(ll i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        v[a - 1].push_back(b - 1);
    }
    used.assign(n, 0);
    dp.assign(n, 0);
    for(ll i = 0; i < n; i++)
        dfs(i);
    ll ans = 0;
    for(ll i = 0; i < n; i++)
        ans = max(ans, dp[i]);
    cout<<ans;
}


Measured memory_bytes: 18688
from sys import stdin

N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

inf = 10 ** 9 + 7
ans = 1

alphabet = [x for x in 'abcdefghijklmnopqrstuvwxyz']
count = [1 for _ in range(26)]

for i in range(len(s)):
    count[alphabet.index(s[i])] += 1

for j in count:
    ans = ans * j % inf

print(ans - 1)


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

using namespace std;
#define MX 1e5+1
#define pb push_back
#define prr pair<int,int> 
#define int long long


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    int n;
    cin>>n;
    int a1=n/500;
    int ans=a1*1000;
    n=n%500;
    a1=n/5;
    ans=ans+(a1*5);
    cout<<ans;

   
}



















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

int main() {
  string a,b;

  cin >> a >> b;
  string s = a+b;
  int c = stoi(s);

  for(int i=1;i<=400;++i){
    if(i*i == c){
      cout <<"Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3604
s = gets.chomp.split(//)
t = gets.chomp.split(//)

sarr, tarr = [], []
flag = true

s.zip(t).each do |chars|
    
    if sarr.index(chars[0]) == nil and tarr.index(chars[1]) == nil
        sarr.push(chars[0])
        tarr.push(chars[1])
    elsif sarr.index(chars[0]) == tarr.index(chars[1])
        next
    else
        flag = false
        break
    end
end

puts flag ? "Yes" : "No"


Measured memory_bytes: 33044
import java.util.*;

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

    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    int ans = 0;

    for(int i = 0; i < n - 2; i++){
      if(c[i] == 'A' && c[i + 1] == 'B' && c[i + 2] == 'C'){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

// 過去問第3問ABC113Bまでdone

int main(){
    int N;cin>>N;
    vector<int> p;
    vector<int> orip;
    rep(i,N){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
        orip.push_back(tmp);
    }

    bool flag;
    rep(i,N){
        rep(j,N){
            flag = true;
            int tmp = p[j];
            p[j] = p[i];
            p[i] = tmp;
            vector<int> pre = p;

            // cout << " " << flag << " ";
            
            // for(int k=0; k<N; k++){
            //     cout << pre[k] << " ";
            // }

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

            // for(int k=0; k<N; k++){
            //     cout << p[k] << " ";
            // }

            for(int k=0; k<N; k++){
                if(p[k]!=pre[k]){
                    flag = false;
                    // cout << "hoge";
                }
            }

            // cout << " " << flag;

            if(flag){
                cout << "YES" << endl;
                return 0;
            }

            p = orip;
            // cout << endl;
            
        }
        
    }
    
    if(flag==false) cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
	int a,b,c,d,dstc;
	scanf("%d%d%d",&a,&b,&c);
	dstc = fabs(a-c);
	if((a<b && b<c)||(c<b && b<a)){
		if(fabs(a-b)>fabs(b-c)){
			dstc = fabs(a-b);
		}
		else dstc = fabs(b-c);
	}
	scanf("%d",&d);
	if(dstc<=d) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
int l[N], r[N], op[N],fa[N];
inline int find(int x){return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);}
int n,q;ll m;
int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++)fa[i] = i;
	ll rest = n;
	cin >> q;
	for(int i=1;i<=q;i++){
		scanf("%d%d%d",&l[i], &r[i], &op[i]);
		++l[i], ++r[i];
		if(op[i]==0){
			int x = find(l[i]), y = find(r[i]);
			if(x^y){
				fa[x] = y;
				rest --;
			}
		}
	}
	for(int i=1;i<=q;i++){
		if(op[i]==1){
			int x = find(l[i]), y = find(r[i]);
			if(x==y || m==n-1){
				puts("No");
				return 0;
			}
		}
	}
	ll Max = rest*(rest-1)/2 + n-rest;
	if(Max >= m){
		puts("Yes");
	}else puts("No");
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1],t[LIMIT1];
  
  scanf("%s %s",s,t);
  printf("%s%s",t,s);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a, b, c;
    int d = 0;
    scanf("%d%d%d", &a, &b, &c);
    for(a; a<=b; a++){
        if(c%a==0) d++;
    }
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 2076
lis = [x for x in input()]
a = lis[0]
b = lis[2]
if a == "H" and b == "D":
  print("D")
elif a == "H" and b == "H":
  print("H")
elif a == "D" and b == "H":
  print("D")
else:
  print("H")

Measured memory_bytes: 2940
using System;


class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int x1 = int.Parse(input[0]);
        int y1 = int.Parse(input[1]);
        int x2 = int.Parse(input[2]);
        int y2 = int.Parse(input[3]);
        int x3 =  y1 - y2 + x2;
        int x4 =  y1 - y2 + x1;
        int y3 = -x1 + x2 + y2;
        int y4 = -x1 + x2 + y1;
        Console.WriteLine(x3 + " "+ y3 +" "+ x4 +" "+ y4); 
        
    }
}

Measured memory_bytes: 11092
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n=I()
lis=LI()
lis.insert(0,0)
lis.append(0)
ones=[]
twos=[]
for i in range(n+1):
    ones.append(abs(lis[i+1]-lis[i]))
    if i!=n:
        twos.append(abs(lis[i+2]-lis[i]))
#print(ones)
#print(twos)
u=sum(ones)
for i in range(n):
    ans=u-ones[i]-ones[i+1]+twos[i]
    print(ans)

Measured memory_bytes: 63524
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  ll A[N], B[N]; FOR(i,0,N) cin >> A[i] >> B[i];
  ll ans = 0;
  // i bit目が1なら0にする場合
  FOR(i,0,32) {
    if((K>>i)&1) {
      // i bit以上はKと同じでないといけない
      ll cnt = 0;
      FOR(j,0,N) {
        bool ok = true;
        if(((A[j]>>i) & 1) == 1) continue;
        FOR(k,i+1,32) {
          if(((K>>k) & 1) == 0 && ((A[j]>>k) & 1) == 1) {
            ok = false;
            break;
          }
        }
        if(ok) cnt += B[j];
      }
      ans = max(ans, cnt);
    }
  }
  ll cnt = 0;
  FOR(j,0,N) {
    bool ok = true;
    FOR(k,0,32) {
      if(((K>>k)&1)==0&&((A[j]>>k)&1)==1) {
        ok = false;
        break;
      }
    }
    if(ok) cnt += B[j];
  }
  cout << max(ans, cnt) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecll a(n);
  for(auto&& e:a)cin>>e;
  vector<vecll> dp(n+1, vecll(n+1));
  for(auto&& l1:irange(0,n)) {
    int l = l1+1;
    for(auto&& i:irange(0,n)) {
      if (i+l > n) break;
      dp[l][i] = max(-dp[l-1][i] + a[i+l-1], -dp[l-1][i+1] + a[i]);
    }
  }
  cout<<dp[n][0]<<endl;
  return 0;
}


Measured memory_bytes: 70784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars
    }
    let mut ans = 0;
    for i in 0..n - 1 {
        let v = kmp_tab(&s[i..n]);
        for j in 0..n - i {
            if j + 1 >= 2 * v[j + 1] {
                ans = max(ans, v[j + 1]);
            }
            if j + 1 < 2 * v[j + 1] {
                let c = j + 1 - v[j + 1];
                let mut t = (j + 1) / c / 2 * c;
                if (j + 1) / c % 2 == 1 {
                    t += (j + 1) % c;
                }
                ans = max(ans, t);
            }
        }
    }
    println!("{}", ans);
}

fn kmp_tab(s: &[char]) -> Vec<usize> {
    let m = s.len();
    let mut tab: Vec<usize> = vec![0; m + 1];
    let mut i = 2;
    let mut j = 0;
    while i <= m {
        if s[i - 1] == s[j] {
            tab[i] = j + 1;
            i += 1;
            j += 1;
        } else if j > 0 {
            j = tab[j];
        } else {
            i += 1;
        }
    }
    tab
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 101
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,g[N][N];

int prim(){

  int i,v,sumwe,cost[N],color[N],min,pare[N];

  for(i=0;i<n;i++){
    color[i]=WHITE;
    cost[i]=INF;
    pare[i]=-1;
  }

  cost[0]=0;
  sumwe=0;

  while(1){
    v=-1;
    min=INF;

    for(i=0;i<n;i++){
      if(color[i] != BLACK && cost[i] < min){
	min=cost[i];
	v=i;
      }
    }

    if(v==-1)break;

    color[v]=BLACK;

    for(i=0;i<n;i++){
      if(color[i] != BLACK && g[v][i] < INF){
	if(cost[i] > g[v][i]){
	  cost[i]=g[v][i];
	  pare[i]=v;
	  color[i]=GRAY;
	}
      }
    }
  }

  for(i=0;i<n;i++){
    if(pare[i]!=-1)sumwe+=g[i][pare[i]];
  }

  return sumwe;
}

int main(){

  int i,j,a;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf(" %d",&a);

      if(a == -1)g[i][j]=INF;
      else g[i][j]=a;
    }
  }

  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>

int main(){
  
  int N,k[10001]={0},i,n1=0,nac=0,c=0;
  
  while(1){
    
    scanf("%d",&N);
    if( N==0 ) break;
    
    for(i=0;i<N;i++){
      scanf("%d",&k[i]);
      if(k[i] == 0) nac++;
      else if(k[i]==1){
	n1++;
	nac++;
      }else c++;
    }
    
    if( nac==N ) puts("NA");
    else printf("%d\n",c+n1+1);
    
    c=0;
    nac=0;
    n1=0;
  }
  return 0;

}

Measured memory_bytes: 660
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B, std::vector<long long> C) {
  map<ll, ll, greater<ll>> aSort;
  rep(n, 0, N) { aSort[A[n]]++; }

  map<ll, ll, greater<ll>> bSort;
  rep(m, 0, M) { bSort[C[m]] += B[m]; }

  ll cnt = 0;
  ll ans = 0;
  auto aIter = aSort.begin();
  auto bIter = bSort.begin();
  while (cnt < N) {
    ll aNum = -1;
    ll aCnt = 0;
    ll bNum = -1;
    ll bCnt = 0;
    if (aIter != aSort.end()) {
      aNum = aIter->first;
      aCnt = aIter->second;
    }

    if (bIter != bSort.end()) {
      bNum = bIter->first;
      bCnt = bIter->second;
    }

    if (aNum >= bNum) {
      ll cntTmp = min(N - cnt, aCnt);
      ans += aNum * cntTmp;
      cnt += cntTmp;
      aIter++;
    } else {
      ll cntTmp = min(N - cnt, bCnt);
      ans += bNum * cntTmp;
      cnt += cntTmp;
      bIter++;
    }
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(M);
  std::vector<long long> C(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
  }
  solve(N, M, std::move(A), std::move(B), std::move(C));
  return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<ull> b;
  each(i, n-1) {
    ull tmp;
    cin >> tmp;
    b.push(tmp);
  }

  vector<ull> a(n, 0);
  each(i, b.size()) {
    if (i == 0) {
      a[0] = b[i];
      a[1] = b[i];
    }

    a[i+1] = b[i];
    const auto current = a[i+1];
    const auto candidate = a[i];

    if (candidate >= current) {
      a[i] = current;
    } else {
    }
  }

  cout << sum_value(a) << endl;

  return 0;
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

map<pa, int> bfs(int i, imat &l){
    queue<pa> q;
    bvec f(l.size(), false);
    //vector <pair<pa, int> > cmap(l.size()-1);
    map<pa, int> cmap;
    q.push(pa(i, 0));
    while(!q.empty()){
        pa cn = q.front();
        q.pop();
        int j = cn.first;
        int c = cn.second;
        f[j] = true;
        // cout << j <<' ' << c <<endl;
        int cc = 1;
        for (auto &x :l[j]){
            //cout << x << endl;
            if(f[x]) continue;
            //else f[x] = true;
            if(cc==c) cc++;
            //cmap.push_back(pair<pa, int>(pa(x,j), cc));
            pa ind = pa(x,j);
            cmap[ind] = cc;
            q.push(pa(x, cc));
            //cout << cc << endl;
            cc++;
        }
    }
    return cmap;

}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    pvec e(n-1);
    imat l(n);
    for (int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        e[i] = pa(a-1, b-1);
        l[a-1].push_back(b-1);
        l[b-1].push_back(a-1);
    }
    int k=0;
    for(auto &x : l) k = max(k, (int) x.size());
    cout << k << endl;
    map<pa, int> cmap = bfs(0, l);
    for(auto &x :e){
        int i = x.first, j = x.second;
        if (cmap.count(pa(i,j))) cout << cmap[pa(i,j)] << endl;
        else cout << cmap[pa(j,i)] << endl;

    }

}


Measured memory_bytes: 13056
def main():
    s = list(map(int, input().split()))
    a, b = 0, 0
    for i in s:
        if i == 7:
            a += 1
        if i == 5:
            b += 1
    if b == 2 and a == 1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
	long long now=100;
	long long x=0;
	int count=0;
	scanf("%lld",&x);
	while(1)
	{
		if(now>=x)break;
		else
		{
			now*=1.01;
			count++;
		}
	}
	printf("%d",count);
}

Measured memory_bytes: 1728
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  string a,b;cin>>a>>b;
  reverse(a.begin(),a.end());
  if(a==b)cout<<"YES";
  else cout<<"NO";
}



Measured memory_bytes: 27036
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  ll s ;
  cin >> s ;
  if(s<=INF){
    cout << 0 << " " << 0 << " " << 1 << " " << 0 << " " << 0 << " " << s <<endl ;
  }
  else if(s == 1000000000000000000){
    cout << 0 << " " << 0 << " " << INF << " " << 0 << " " << 0 << " " << INF << endl ;
  }
  else{
    cout << 0 << " " << 0 << " " << s/INF+1 << " " << (s/INF+1)*INF-s << " " << 1 << " " << INF << endl ;
  }

  return 0 ;
}

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

int main() {
  long long N,Q;
  string S;
  cin >> N >> Q >> S;
  vector<long long> l(Q),r(Q);
  for (long long i=0;i<Q;i++) {
    cin >> l.at(i) >> r.at(i);
  }

  vector<long long> sum(N);
  long long existA=0;
  for (long long i=0;i<N;i++) {
    if (S.at(i)=='A') {
        existA=1;
    }
    else {
      if (existA==1 && S.at(i)=='C') {
        sum.at(i)++;
      }
      existA=0;
    }
    if (i==0) {
      continue;
    }
    sum.at(i) += sum.at(i-1);
  }
  
  long long L,R;
  for (long long i=0;i<Q;i++) {
    L = l.at(i)-1;
    R = r.at(i)-1;
    cout << sum.at(R)-sum.at(L) << endl;
  }
}

Measured memory_bytes: 3456
import numpy as np
def solve(a, b, c, k):
    x, y, z = len(a), len(b), len(c)
    A = a.reshape(x, 1) + b.reshape(1, y)
    d = np.sort(A.flatten())[::-1][:k]
    B = d.reshape(len(d), 1) + c.reshape(1, z)
    return np.sort(B.flatten())[::-1][:k]

x, y, z, k = map(int, input().split())
a = np.asarray(list(map(int, input().split())))
b = np.asarray(list(map(int, input().split())))
c = np.asarray(list(map(int, input().split())))
print("\n".join(map(str, solve(a, b, c, k))))


Measured memory_bytes: 104856
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;



class Program
{
    public const int INF = 1 << 25;

    static void Main()
    {
		int n = int.Parse(Console.ReadLine());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		int m = int.Parse(Console.ReadLine());
		for (int i = 0; i < m; i++) {
			string[] input = Console.ReadLine().Split(',');
			int x = int.Parse(input[0]);
			int y = int.Parse(input[1]);
			int c = a[x - 1];
			a[x - 1] = a[y - 1];
			a[y - 1] = c;
		}
		for (int i = 0; i < n; i++) {
			Console.WriteLine(a[i]);
		}
	}
}

Measured memory_bytes: 5600
a, b = input().split()
if a == 'H' and b =='H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')

Measured memory_bytes: 2940
#include<iostream>

using namespace std;
int data[1010];
int main(){
	int n,a,b,c,x;
	while(cin>>n>>a>>b>>c>>x &&n){
		for(int i=0;i<n;i++)cin>>data[i];
		int now=0;
		int ans=0;
		int next=x;
		for(int i=1;i<=20000;i++){
			
			
			if(data[now]==next)now++;
			if(now==n)break;
			next=(a*next+b)%c;
			ans++;
		}
		if(ans<=10000)cout<<ans<<endl;
		else cout<<-1<<endl;
		
	}
	
}

Measured memory_bytes: 1160
t = int(input())
for _ in range(t):
  x, y, w, h = map(int, input().split())
  n = int(input())
  ans = 0
  for _ in range(n):
    cx, cy = map(int, input().split())
    if x <= cx <= x + w and y <= cy <= y + h:
      ans += 1
  print(ans)


Measured memory_bytes: 5612
import java.util.Scanner;

//M-SOLUTIONS プロコンオープン
//B - Sumo
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		int xSum = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == 'x') {
				xSum++;
			}
		}

		System.out.println(xSum <= 7 ? "YES" : "NO");

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;


int main(){
  int n;
  cin >> n;
  vector <int> vec(n);
  int ans=0;
  for (int i=0;i<n;i++){
    cin >>vec.at(i);
    ans+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ans-=vec.at(n-1)/2;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
n = int(input())
p = [0] + list(map(int,input().split()))
ans = 0
for i in range(1,n+1):
    if p[i]==i:
        if i!=n:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans += 1
        else:
            tmp = p[i]
            p[i] = p[i-1]
            p[i-1] = tmp
            ans += 1
#print(p[1:])
print(ans)


Measured memory_bytes: 20452
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vi a(n);
    FOR(i, 0, n - 1) cin >> a[i];
    sort(a.begin(), a.end());
    vector <bool> no(1000005);
    int ans = 0;
    a.pb(0);
    FOR(i, 0, n - 1) {
        if (no[a[i]]) continue;
        if (!no[a[i]] && a[i + 1] != a[i]) ans++;
        for (int j = a[i]; j <= 1000000; j += a[i])
            no[j] = 1;
    }
    cout << ans << endl;
}

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

int ctoi(char c)
{
  switch (c)
  {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}

int S(string N)
{
  int sum = 0;

  for (int i = 0; i < N.length(); i++)
  {
    char num = N[i];
    // cout << typeid(num).name() << endl;
    sum += ctoi(num);
  }

  return sum;
}

int S2(int N){

  int sum = 0;

  while (N != 0) {
    sum += N % 10;
    N /= 10;
  }

  return sum;
}

int main()
{

  int N;

  cin >> N;

  int result = S2(N);

  if (N % result == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	bool yes = false;
	for(int i = 0; i <= n / 4; ++i) {
		for(int j = 0; j <= n / 7; ++j) {
			if( 4 * i + 7 * j == n ) yes = true;
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {

		int ans = 0;

		Scanner scan = new Scanner(System.in);

		int N = Integer.parseInt(scan.next());
		int M = Integer.parseInt(scan.next());
		int C = Integer.parseInt(scan.next());

		int B[] = new int[M];

		for (int i = 0; i < M; i++) {
			B[i] = Integer.parseInt(scan.next());
		}

		int A[][] = new int[N][M];

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				A[i][j] = Integer.parseInt(scan.next());
			}
		}

		int temp = 0;
		for (int i = 0; i < N; i++) {
			temp = 0;
			for (int j = 0; j < M; j++) {
				temp = temp + (A[i][j] * B[j]);
			}
			if((temp + C) > 0){
				ans++;
			}
		}



		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#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;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    vector<pll> ans(N);
    rep(i, N){
        ans[i].first = A[i];
        ans[i].second = B[i];
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());

    cout << ans[0].first + ans[0].second << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 3328
//https://atcoder.jp/contests/abc144/tasks/abc144_d
//D - Water Bottle
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
double deg2rad(double deg){
  return deg*M_PI/180.0;
}
int main() {
  double a,b,x; cin>>a>>b>>x;

  auto check_func =[&](double deg)->bool{
    double aa = b*tan(deg2rad(90-deg));
    double mas;
    if(aa<a){
      mas=aa*b/2*a;
    }else{
      double bb=a/tan(deg2rad(90-deg));
      mas=(a*(b-bb) + bb*a/2)*a;
    }
    return x-mas>0;
  };

  double ok=90,ng=0;
  REP(i,1000){
    auto mid=(ok+ng)/2;
    if(check_func(mid)){
      ok=mid;
    }else{
      ng=mid;
    }
  }
  cout<<fixed<<std::setprecision(10)<<ok<<endl;

  return 0;
}

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

int main(){
  int N,K,cnt;
  cin>>N>>K;
  while(N>0){
	N/=K;
    cnt++;
  }
  
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    if (b > c) {
        x = b;
        b = c;
        c = x;
    }
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n+1);
  for(int i=1; i<=n; i++){
    int a;
    cin >> a;
    
    vec.at(i) = a;
  }
  
  int ans = -1;
  int p = 1;
  for(int i=1; i<=n; i++){
    p = vec.at(p);
    if (p == 2) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
	int n, k; cin >> n >> k;
	k--;
	string s; cin >> s;
	s[k] = (s[k] - 'A') + 'a';
	cout << s << endl;
	return 0;
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back

typedef long long ll;

int n;

ll a[17][17];

ll dp[1<<17];
ll group[1<<17];

void init() {
    fore(s, 1, (1<<n)) {
        ll aux = s;
        vector<int> v;
        while(aux != 0) {
            int x = 63 - __builtin_clzll(aux);
            v.pb(x);
            aux ^= (1LL<<x);
        }
        ll rcand = 0;
        fore(i, 0, v.size() - 1) {
            fore(j, i + 1, v.size()) {
                rcand += a[v[i]][v[j]];
            }
        }
        group[s] = rcand;
    }
}

ll calc(ll mask) {
    if(mask == 0) return 0;
    if(dp[mask] != -1) return dp[mask];
    ll res = -1e18;
    for (int s = mask; s; s = (s - 1) & mask) {
        ll rcand = group[s] + calc(mask ^ (mask & s));
        res = max(rcand, res);
    }
    return dp[mask] = res;
}

int main() {
    cin >> n; 
    fore(i, 0, n) fore(j, 0, n) cin >> a[i][j];
    memset(dp, -1, sizeof dp);
    ll mask = 0;
    fore(i, 0, n) mask |= (1LL<<i);
    init();
    cout << calc(mask) << endl;
}

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



int main(){

    string S; cin >> S;
    int diff1=0;
    int diff2=0;
    int le=S.length();
    
    for(int i=0;i < le; i +=2){
        if(S[i]!='1') diff1++;
    }

    for(int i=1;i < le; i +=2){
        if(S[i]!='0') diff1++;
    }

    for(int i=0;i < le; i +=2){
        if(S[i]!='0') diff2++;
    }

    for(int i=1;i < le; i +=2){
        if(S[i]!='1') diff2++;
    }
    cout << ((diff1 < diff2)? diff1 : diff2) << endl;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    int64_t ans = 0;
    map<int64_t, int64_t> mp;
    for (int64_t i = 0; i < N; i++) {
        ans += mp[i - A[i]];
        mp[i + A[i]]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 27456
#include"bits/stdc++.h"
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    double answer = 0;
    for(int i=0; i<N; i++){
        long long score = i+1;
        double tmp = 1.0/N;
        while(score < K){
            tmp /= 2.0;
            score *= 2;
        }
        answer += tmp;
    }
    cout << setprecision(16) << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long N, K, S;
  cin >> N >> K >> S;
  long long result[N];

  for(int i=0;i<N;i++){
    if(i<K){
      result[i] = S;
    }else{
      result[i] = (S + 1) % 1000000000;
    }
  }

  for(int i=0; i<N-1; i++){
    cout << result[i] << " ";
  }
  cout << result[N-1] << endl;
}

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

int main()
{
    int N, R;
    cin >> N >> R;

    if (N < 10)
    {
        cout << R + 100 * (10 - N) << endl;
    }
    else
    {
        cout << R << endl;
    }
    
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,L;
  cin>>N>>L;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];

  int memo=-1;
  for(int i=0;i<N-1;i++){
    if(a[i]+a[i+1]>=L)memo=i;
  }
/*{{{*/
  if(memo==-1){
    cout<<"Impossible"<<endl;
    return 0;
  }
/*}}}*/

  vector<int>ans;
  ans.push_back(memo);
  for(int i=memo+1;i<N-1;i++)ans.push_back(i);
  for(int i=memo-1;i>=0;i--)ans.push_back(i);
  reverse(rng(ans));
  cout<<"Possible"<<endl;
  for(auto it:ans)cout<<it+1<<endl;

  return 0;
}


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
    vector<int> b(9);
    rep(i,9) { cin >> b[i]; b[i]--; }

    map< vector<int>, bool > close;
    map< vector<int>, int > h;
    priority_queue< Q, vector<Q>, greater<Q> > q;

    auto heu = [&](vector<int> v) -> int {
        if (h.count(v)) return h[v];
        int dif = 0;
        rep(i,9) {
            if (v[i] == -1) continue;
            dif += abs(v[i]/3 - i/3) + abs(v[i]%3 - i%3); // 各パネルの目的地までのマンハッタン距離の総和
        }
        h[v] = dif;
        return dif;
    };

    q.push({heu(b), b});
    int ans;
    while (!q.empty()) {
        vector<int> b;
        int f;
        tie(f,b) = q.top(); q.pop();
        if (h[b]==0) {
            ans = f;
            break;
        }
        close[b] = true;
 
        int g = f - h[b];

        int r, c;
        rep(i,9) {
            if (b[i] == -1) {
                r = i/3;
                c = i%3;
                break;
            }
        }
        int dr[4] = { -1,  0,  1,  0};
        int dc[4] = {  0, -1,  0,  1};
        rep(i,4) {
            int nr = r + dr[i];
            int nc = c + dc[i];
            if (nr < 0 || nr >= 3 || nc < 0 || nc >= 3) continue;
            vector<int> nb = b;
            swap(nb[nr*3+nc], nb[r*3+c]);
            if (!close[nb]) {
                q.push({g+1+heu(nb), nb});
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6036