akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest153.Questions;
using AtCoderBeginnerContest153.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest153.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ha = inputStream.ReadIntArray();
            var h = ha[0];
            var a = ha[1];
            yield return (int)Math.Ceiling((double)h / a);
        }
    }
}


namespace AtCoderBeginnerContest153
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest153.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest153.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>
#include <string>

using namespace std;

int  main(){
    int n;
    cin >> n;
    if(n%10 == 9 || (n/10)%10 == 9 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void)
{
  int n;
  cin >> n;
  double arr[n];
  for(int i = 0; i < n; i++)
    	cin >> arr[i];
 sort(arr, arr + n);
  double ans = (arr[0] + arr[1]) / 2;
  for(int i = 2; i < n; i++)
    ans = (ans + arr[i]) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)

const int MAX_N = 16;
int n;
int dp[1 << MAX_N][MAX_N];
int d[MAX_N][MAX_N];
void solve() {
    rep(S, (1 << n)) {
        fill(dp[S], dp[S] + n, inf);
    }
    dp[(1 << n) - 1][0] = 0;
    for (int S = (1 << n) - 2; S >= 0; --S) {
        rep(v, n) {
            //if (!(S >> v & 1)) continue;
            rep(u, n) {
                if (!(S >> u & 1)) {
                    dp[S][v] = min(dp[S][v], dp[S | 1 << u][u] + d[v][u]);
                }
            }
        }
    }
    if (dp[0][0] != inf) cout << dp[0][0] << endl;
    else cout << -1 << endl;
}
int main() {
    int m;
    cin >> n >> m;
    rep(i, n) rep(j, n) d[i][j] = inf;
    rep(i, m) {
        int s, t, dd;
        cin >> s >> t >> dd;
        d[s][t] = dd;
    }
    solve();
}



Measured memory_bytes: 5124
# coding: utf-8
import time
import re
import math
 
def main():
    X,A=map(int,input().split())
    if X<A:
        print(0)
    else:
        print(10)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#n=int(input())
# global n,A,s,memo,mx,mn,L,B

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

#define ll long long

void solve(){
    int a,b;
    cin >> a >> b;
    int ans = 1;
    while(ans <= 1e5){

        if (ans * 8 / 100 == a && ans * 10 / 100 == b)
            break;

        ans++;
    }
    cout << (ans <= 1e5 ? ans : -1) << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;

class B
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine(MPow(h[0], h[1]));
	}

	const int M = 1000000007;
	static long MPow(long b, long i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}



Measured memory_bytes: 18016
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
BIGNUM = 10 ** 9 + 7

k = list()
last_ana = -1
for _ in range(m):
    ana = int(input())
    k.append(ana - last_ana - 1)
    last_ana = ana
k.append(n - last_ana)

if 0 in k:
    ans = 0
else:
    k_max = max(k)
    c = [1, 1]
    for i in range(2, k_max):
        c_tmp = c[i - 1] + c[i - 2]
        c.append(c_tmp % BIGNUM)

    ans = 1
    for num in k:
        ans *= c[num - 1]
        ans %= BIGNUM
        if ans == 0:
            break

print(ans)

Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
int a[100];
int b[100];
int c[100];
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int bsum=0;
	int csum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		if(a[i]>x){b[i]=a[i];}
		else{c[i]=a[i];}
		if(b[i]!=0){bsum++;}
		if(c[i]!=0){csum++;}}
	int answer=min(bsum,csum);
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll a[200000], b[200000], c[200000];

int main(void)
{
	ll N,answer = 0;
	cin >> N;

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

	for (int i = 0; i < N; i++)
		cin >> b[i];

	//i-bit
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < N; j++) {
			c[j] = b[j] % (2LL << i);
		}

		sort(c, c + N);

		ll T = (1LL << i);

		ll res = 0;
		for (int j = 0; j < N; j++) {
			ll d = a[j] % (2LL << i);

			res += lower_bound(c, c + N, 2 * T - d) - lower_bound(c, c + N, T - d);
			res += lower_bound(c, c + N, 4 * T - d) - lower_bound(c, c + N, 3 * T - d);
			
		}


		//cerr << res << endl;

		answer += (res % 2 == 1 ? T : 0);

	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

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

    set<int> se;
    se.insert(0);

    for (int i = 0; i < N; ++i) {
        set<int> nse = se;
        int x;
        cin >> x;
        for (int y : se)
            nse.insert(x + y);

        se = nse;
    }
    
    int ans = 0;
    for (auto itr = se.rbegin(); itr != se.rend(); ++itr) {
        auto x = *itr;
        if (x % 10 != 0) {
            ans = x;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
//In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 3011 ;
const int mod = 998244353 ;
const int INF = 1e18 ;

int a , b , c , d , dp[ maxn ][ maxn ] ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> a >> b >> c >> d ;
 dp[ a ][ b ] = 1;

 for(int i = a+1 ; i <= c ; i ++)
   dp[ i ][ b ] = (dp[ i-1 ][ b ] * b)%mod ;

 for(int j = b+1 ; j <= d ; j ++)
   dp[ a ][ j ] = (dp[ a ][ j-1 ] * a)%mod ;

 for(int i = a+1 ; i <= c ; i ++){
   for(int j = b+1 ; j <= d ; j ++){
     int x1 = (dp[ i-1 ][ j ] * j)%mod ;
     int x2 = (dp[ i ][ j-1 ] * i)%mod ;
     int x3 = ( i-1 )*( j-1 )%mod ;
     int x4 = (dp[ i-1 ][ j-1 ] * x3)%mod ;
     dp[ i ][ j ] = (x1+x2-x4+mod)%mod ;
   }
 }

 cout << dp[ c ][ d ]%mod ;

    return 0;
}


Measured memory_bytes: 74100
#include <stdio.h>
int main()
{
    int a, b, j, i;
    
    while(1){
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        }
        
    for(i = 1; i <= a; i++)
    {
        for(j = 1; j <= b; j++)
    {
        if(j%2 == 1)
        {
            if(i%2 == 1)
             printf("#");
            else
             printf(".");
        }
        else
        {
            if(i%2 == 1)
             printf(".");
            else
             printf("#");
        }
    }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const MAX = 1e5 + 50;
int arr[MAX];
int memo[MAX];
int n, k;

int dp(int i)
{
    if(i >= n) return 1e7;
	if(i == n - 1) return 0;
	int ret = 1e9;
	if(memo[i] != -1) return memo[i];
	for(int j = 1; j <= k && j < n; j++)
    {
        int temp = abs(arr[j + i] - arr[i]) + dp(j + i);
        ret = min(temp, ret);
    }
    return memo[i] = ret;
}


int main()
{
    memset(memo, -1, sizeof(memo));
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++)
    {
    	scanf("%d", &arr[i]);
    }
    printf("%d", dp(0));

	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  // これはアルゴリズム
  if (abs(A - B) >= 1e18)
  {
    cout << "Unfair" << endl;
  }
  else
  {
    if (K % 2 == 0)
    {
      cout << A - B << endl;
    }
    else
    {
      cout << B - A << 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++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int k;
	cin >> k;
	int x = 0, cnt = 0;
	V<bool> visit(k, false);
	bool ng = false;
	while (true) {
		x = 10 * x + 7;
		cnt++;
		x %= k;
		if (x == 0)break;
		if (visit[x]) {
			ng = true;
			break;
		}
		visit[x] = true;
	}

	if (ng)cout << -1 << endl;
	else cout << cnt << endl;

}

Measured memory_bytes: 3748
n = int(input())
d = {}

arr = list(map(int,input().split()))
ans = 0
for i in range(n):
    diff = i+1-arr[i]
    if diff in d:
        ans += d[diff]

    ss = i+1 +arr[i]
    if ss in d:
        d[ss] += 1
    else:
        d[ss] = 1

print(ans)

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

int main(){
  string s,a = "keyence";
  cin >> s;
  int n = s.size();
  bool ok = false;
  /*if(s.find("keyence") != std::string::npos){
    ok = true;
  }*/
  int i = 0;
  while(i <= 6){
    if(s.at(i) != a.at(i)){
      break;
    }
    i++;
  }
  //cout<< i << endl;
    if(s.substr(n-7+i,7-i) == a.substr(i,7-i)){
      ok = true;
    }
    if(ok == true){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
//ABC138 A - Red or Not
//20190902

using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            string output = a>=3200 ? s : "red";

            Console.WriteLine(output);

        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<math.h>
double d,r,s,z[6];
int n,i,j,a[50];
int main(){
	for(scanf("%d",&n);n--;){
		for(i=0;i<6;i++)
			scanf("%lf",z+i);
		r=z[2];
		s=z[5];
		d=hypot(*z-z[3],z[1]-z[4]);
		printf("%d\n",a[j++]=d>r+s?0:r>d+s?2:s>d+r?-2:1);
	}
	
	return
		n==15 ;
		/*
		a[0]==1 &&
		a[1]==1 &&
		a[2]==1 &&
		a[3]==0 &&
		a[4]==2 &&
		a[5]==2 &&
		a[6]==-2 &&
		a[7]== 0&&
		a[8]== 0&&
		a[9]==1 &&
		a[10]==1 &&
		a[11]==-2 &&
		a[12]==1 &&
		a[13]==2;
		*/
}

Measured memory_bytes: 0
import string

alphabet = string.ascii_lowercase

n = int(input())

def DFS(before,keta):
    num = 0
    if keta == n:
        print(before)
        return
    for i in before:
        num = max(num,alphabet.index(i))
    num += 1
    for j in range(num+1):
        DFS(before+alphabet[j],keta+1)

DFS("a",1)

Measured memory_bytes: 4984
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,m,sum,rose;
    string a;
    string temp = "ACGT";
    rose = 0;
    cin >> a;
    int len = a.length();
    int curr = 0;
    for(i=0;i<len;i++)
    {
        bool cek = 0;
        for(j=0;j<4;j++)
        {
            if(a[i] == temp[j])
                cek = 1;
        }
        if(cek)
            curr++;
        else
            curr = 0;
        rose = max(rose,curr);
    }
    cout << rose << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, n - 1) {
        sum += p[i];
    }
    sum += p[n - 1] / 2;
    cout << sum << endl;
    return 0;
}

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

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

int w,h,ans,dy[]={-1,0,1,0},dx[]={0,-1,0,1};
char c[22][22];

void dfs(int y,int x){
	ans++;
	c[y][x]='#';
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny && ny<h && 0<=nx && nx<w && c[ny][nx]=='.')dfs(ny,nx);
	}
}

int main(){
	while(cin>>w>>h&&w){
		ans=0;
		int y,x;
		rep(i,h)rep(j,w){
			cin>>c[i][j];
			if(c[i][j]=='@')y=i,x=j;
		}
		dfs(y,x);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int i,j,k;
  string n;
  for(i=0;i<9;i++){
    cin >> n >> j >> k;
    cout << n << " " << j+k << " " << j*200+k*300 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_count=[[0]*W for i in range(H)]
from collections import deque
def answer(st_X,st_Y):#X,Y座標を指定してそこからの距離を考える
   tmp_X,tmp_Y=st_X,st_Y
   que=deque([[tmp_X,tmp_Y]])
   after=set()
   while que:#スタート地点からの距離を数えながら行ったことのない場所を探索する
      tmp_X,tmp_Y=que.popleft()
      nu=l_count[tmp_Y][tmp_X]
      after.add((tmp_X,tmp_Y))
      if tmp_X>0 and l[tmp_Y][tmp_X-1]=="." and (tmp_X-1,tmp_Y) not in after and [tmp_X-1,tmp_Y] not in que:
         l_count[tmp_Y][tmp_X-1]=nu+1
         que.append([tmp_X-1,tmp_Y])
      if tmp_Y>0 and l[tmp_Y-1][tmp_X]=="." and (tmp_X,tmp_Y-1) not in after and [tmp_X,tmp_Y-1] not in que:
         l_count[tmp_Y-1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y-1])
      if tmp_X<W-1 and l[tmp_Y][tmp_X+1]=="." and (tmp_X+1,tmp_Y) not in after and [tmp_X+1,tmp_Y] not in que:
         l_count[tmp_Y][tmp_X+1]=nu+1
         que.append([tmp_X+1,tmp_Y])
      if tmp_Y<H-1 and l[tmp_Y+1][tmp_X]=="." and (tmp_X,tmp_Y+1) not in after and [tmp_X,tmp_Y+1] not in que:
         l_count[tmp_Y+1][tmp_X]=nu+1
         que.append([tmp_X,tmp_Y+1])
ans=0
for i in range(H):
   for j in range(W):
      if l[i][j]==".":
         l_count=[[0]*W for i in range(H)]
         answer(j,i)
         tmp=max(sum(l_count,[]))
         ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9428
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool isBeki(int n){
	int r = floor(sqrt(n));
  	if(r*r == n) return true;
  	r = min(r, 10);
  	rep3rev(i,r,1){
    	if(i*i*i == n) return true; // 10^3 = 1000
      	else if(i <= 3 && i*i*i*i*i == n) return true; // 4^5 > 1000
      	else if(i <= 2 && i*i*i*i*i*i*i == n) return true; // 3^7 > 1000
    }
  	return false;
}

void Main()
{
	int x;
	cin >> x;
	rep3rev(i,x,1){
    	if(isBeki(i)){
        	cout << i << endl;
          	return;
        }
    }
  	cout << 0 << endl;
	return;
}

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

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    string s;
    cin>>s;
    if(s[0]=='7')cout<<"Yes";
    else if(s[1]=='7')cout<<"Yes";
    else if(s[2]=='7')cout<<"Yes";
    else cout<<"No";
    
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include<vector>

#include <algorithm>




using namespace std;



















int main (){
int n,k,q;
  int t=0;

  cin>>n;
double a=0;
  for(int i=1;i<=n;i++){
    
  	if (i%2==1)t++;
  }
  a=(double)t/(double)n;
  cout<<a<<endl;

  
  

  
  
  
  
  
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> b(n);
    ll tmp = 1;
    REP(i, n){
        b[0] += a[i] * tmp;
        tmp *= -1;
    }
    for(ll i = 1; i < n; i++){
        b[i] = 2 * (a[i-1] - b[i-1]/2);
    }
    REP(i, n) cout << b[i] << " ";
    return 0;
}

Measured memory_bytes: 4852
#include<iostream>

 
using namespace std;
 
int main()
{
     unsigned int a,b,c,ans=0;//initializing numbers
    while(cin >> b >>c )//entering 2 numbers
    {
    a=b+c;//adding the 2 numbers
    while(a!=0)
	{ 
		a/=10; ans++;//dividing sum by 10 then adding ans by 1 for number of digits

    }
        cout << ans << endl;//print out how many digits
        ans = 0;
     }

   return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  LL n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
    LL a1, a2, b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    DBG(calc(0, (a1 - b1) * n, a1 * n + a2 * m - b1 * n - b2 * m), calc((a1 - b1) * n, (a2 - b2) * m, a1 * n + a2 * m - b1 * n - b2 * m))
    if (calc(0, (a1 - b1) * n, a1 * n + a2 * m - b1 * n - b2 * m) < 0 || calc((a1 - b1) * n, (a2 - b2) * m, a1 * n + a2 * m - b1 * n - b2 * m) < 0) {
      cout << "infinity" << endl;
    } else {
      cout << calc(0, (a1 - b1) * n, a1 * n + a2 * m - b1 * n - b2 * m) + calc((a1 - b1) * n, (a2 - b2) * m, a1 * n + a2 * m - b1 * n - b2 * m) << endl;
    }
  }
  LL calc(LL init_diff, LL speed_diff, LL dd) {
    DBG(init_diff, speed_diff, dd)
    LL a = init_diff;
    LL b = init_diff + speed_diff;
    if (dd == 0) {
      if ((a < 0 and b >= 0) or (a > 0 and b <= 0))
        return -1;
      else
        return 0;
    } else {
      bool caseA = (a > b) ^ (dd < 0);
      if (caseA) {
        if (dd > 0) {
          a = -a, b = -b, dd = -dd;
        }
        if (b < 0) return 0;
        LL ub = b / (-dd);
        LL lb;
        if (a < 0)
          lb = -1;
        else
          lb = a / (-dd);
        return max(0ll, ub - lb);
      } else {
        if (dd > 0) {
          a = -a, b = -b, dd = -dd;
        }
        DBG(a, b, dd)
        if (a <= 0) return 0;
        LL ub = (a - 1) / (-dd);
        LL lb;
        if (b <= 0)
          lb = -1;
        else
          lb = (b - 1) / (-dd);
        return max(0ll, ub - lb);
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    for(int x = 1; x < 10; ++x)
    {
        for(int y = 1; y < 10; ++y)
        {
            if(x * y == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


def main():
    n = int(input())
    B = list(map(int, input().split()))

    ans = [10**5 + 1] * n

    for i in range(len(B)):
        v = B[i]

        if v < ans[i]:
            ans[i] = v
        if v < ans[i+1]:
            ans[i + 1] = v

    print(sum(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,R;
  cin >> N >> R;
  if(N>10)
  {
    cout << R << endl;
  }
  else
  {
    cout << R + 1000 - 100 * N << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
//    cin>>t;
    while(t--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        swap(a,b);
        swap(a,c);
        cout<<a<<" "<<b<<" "<<c<<'\n';
    }
    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define WHITE 1
#define BLACK 2
#define NIL -2

int G[101][101], pi[101],  d[101], n;

void dijkstra(){
  int mincost, u, v, i;
  int color[n];

  for(u=0; u<n; u++){
    d[u] = INT_MAX;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INT_MAX;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    
    if(mincost == INT_MAX){
      break;
    }

    color[u] = BLACK;
    
    for(v=0; v<n; v++){
      if(color[v] != BLACK && d[u] + G[u][v] < d[v]){
	pi[v] = u;
	d[v] = G[u][v] + d[u];
      }
    }

  }

}  

  
int main(){
  int i, j, k, u, v, c, sum=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      G[i][j] = 999999;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      G[u][v] = c;
    }
  }

  dijkstra();

  for(i=0; i<n; i++){
    printf("%d %d\n", i, d[i]);
  } 

  return 0;
}

Measured memory_bytes: 640
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : thanos1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
using namespace std ;
#define TEST            int t ; cin>>t; while(t--)
#define line            cout<<endl;
#define loop(i,a,b)     for(long long int i=a;i<b;i++)
#define loopIn(i,a,b)   for(long long int i=a;i<=b;i++)
#define MAX_SIZE        1000000
#define ff              first
#define ss              second
#define pb              push_back
#define ll              long long int  
#define mp              make_pair
#define vt              vector<tup>
#define vtt             vector<vt >
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];


void Sieve( int *prime , int n){
	for(int i=0;i<n;i++){
		prime[i] = 0;
	}
	for(int i=2;i<n;i++){
		prime[i] = 1 ;
	}
	for(int i=4;i<n;i+=2){
		prime[i] = 0;
	}
	for(int i=3;i<n;i++){
		if(prime[i]==1){
		for(int j=i*i;j<n;j+=i){
			prime[j] = 0;
		}
	}
  }
  return ;
}
/*void input(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}*/

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

int main(){
	//input();
	ll n;
	cin>>n;
	ll sum = 0 ;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum = sum + __gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3672
fun main(args: Array<String>) {
    val (x, a, b) = readLine()!!.split(' ').map(String::toInt)
    val y = b - a
    val ans = when {
        y <= 0 -> "delicious"
        y <= x -> "safe"
        else -> "dangerous"
    }
    println(ans)
}


Measured memory_bytes: 38208
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

long sign(long x) {
  return x < 0 ? -1 : 1;
}

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

  vector<long> A(n);
  for (long i = 0; i < n; i++) {
    cin >> A[i];
  }

  long cnt = 0;
  long sum = A[0];
  if (sum <= 0) {
    cnt += abs(sum) + 1;
    sum = 1;
  }
  for (long i = 1; i < n; i++) {
    long a = A[i];
    long newsum = sum + a;
    if (sign(sum) == sign(newsum) || newsum == 0) {
      cnt += abs(newsum) + 1;
      newsum = -sign(sum);
    }
    sum = newsum;
  }
  
  long cnt2 = 0;
  long sum2 = A[0];
  if (sum2 >= 0) {
    cnt2 += abs(sum2) + 1;
    sum2 = -1;
  }
  for (long i = 1; i < n; i++) {
    long a = A[i];
    long newsum = sum2 + a;
    if (sign(sum2) == sign(newsum) || newsum == 0) {
      cnt2 += abs(newsum) + 1;
      newsum = -sign(sum2);
    }
    sum2 = newsum;
  }
  
  cout << min(cnt, cnt2) << endl;
  
  return 0;
}


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

int main() {
  int a, b;
  int A, B;
  string answerA;
  string answerB;
  cin >> a >> b;  
  
  if(b==1){A=a;}
  if(b==2){A=a+(10*a);}
  if(b==3){A=a+(10*a)+(100*a);}
  if(b==4){A=a+(10*a)+(100*a)+(1000*a);}
  if(b==5){A=a+(10*a)+(100*a)+(1000*a)+(10000*a);}
  if(b==6){A=a+(10*a)+(100*a)+(1000*a)+(10000*a)+(100000*a);}
  if(b==7){A=a+(10*a)+(100*a)+(1000*a)+(10000*a)+(100000*a)+(1000000*a);}
  if(b==8){A=a+(10*a)+(100*a)+(1000*a)+(10000*a)+(100000*a)+(1000000*a)+(10000000*a);}
  if(b==9){A=a+(10*a)+(100*a)+(1000*a)+(10000*a)+(100000*a)+(1000000*a)+(10000000*a)+(100000000*a);}
  
  if(a==1){B=b;}
  if(a==2){B=b+(10*b);}
  if(a==3){B=b+(10*b)+(100*b);}
  if(a==4){B=b+(10*b)+(100*b)+(1000*b);}
  if(a==5){B=b+(10*b)+(100*b)+(1000*b)+(10000*b);}
  if(a==6){B=b+(10*b)+(100*b)+(1000*b)+(10000*b)+(100000*b);}
  if(a==7){B=b+(10*b)+(100*b)+(1000*b)+(10000*b)+(100000*b)+(1000000*b);}
  if(a==8){B=b+(10*b)+(100*b)+(1000*b)+(10000*b)+(100000*b)+(1000000*b)+(10000000*b);}
  if(a==9){B=b+(10*b)+(100*b)+(1000*b)+(10000*b)+(100000*b)+(1000000*b)+(10000000*b)+(100000000*b);}

  answerA= std::to_string(A);
  answerB= std::to_string(B);
  
  if(answerA<answerB){cout << answerA <<endl;}
  if(answerB<answerA){cout << answerB <<endl;}
  if(answerA==answerB){cout << answerA << endl;}
  return 0;
}

Measured memory_bytes: 256
S = input()

S_inv = S[::-1]

def judge(S):
    cursor = 0
    len_S = len(S)
    
    while cursor < len_S:
        next_str = S[cursor:cursor+7]
        if next_str[:] == "remaerd":
            cursor += 7
        elif next_str[:6] == "resare":
            cursor += 6
        elif next_str[:5] == "esare":
            cursor += 5
        elif next_str[:5] == "maerd":
            cursor += 5
        else:
            return False
        
    if cursor != len_S:
        return False
    
    return True

if judge(S_inv):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	vector<ll> v;
	ll N,K,m;
	cin >> N >> K;
	for (ll i = 0;i<N;i++){
		cin >> m;
		v.pb(m);
	}
	ll ans = LINF;
	for (ll i = 0;i < N - K + 1;i++){
		ll l = v[i];
		ll r = v[i + K - 1];
		ans = min(ans,min(abs(l) + abs(r - l),abs(r) + abs(r - l)));
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	

	//char p;
	//cin >> N >> M;
	cin >> S;
	
	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(N+1);
	//vector<bool> flag(N);
	
	//count--;
	//	cout << X << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(v.begin(), v.end());
	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/

	
	
	if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}



Measured memory_bytes: 764
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time cout << "\nTime: " << clock()/(double) 1000 <<"s"
#define pb push_back
#define fi first
#define se second
const int inf = 0x3f3f3f3f;
const ll oo = 0x3f3f3f3f3f3f3f3f;

#define duckman "task"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main() {
    fast;
//    input;
//    output;

    string s, t;
    cin >> s >> t;
    t.pop_back();
    cout << (s == t ? "Yes" : "No");

	return 0;
}
/*

*/


Measured memory_bytes: 3660
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
using ll = long long;
using namespace std;
template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }

/**
 * @brief fast mobius transformation
 * @note for f : 2^n \to R; \mu f(Y) = \sum\_{X \subseteq Y} (-1)^{\|Y \setminues X\|} f(X)
 * @see http://pekempey.hatenablog.com/entry/2016/10/30/205852
 * @param T is a group for the operator +
 */
template <typename T>
vector<T> fast_mobius_transform(vector<T> f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        repeat (j, n) {
            if (j & i) {
                f[j] -= f[j ^ i];
            }
        }
    }
    return f;
}

int main() {
    // input
    int n; ll m; scanf("%d%lld", &n, &m);
    vector<ll> a(n); repeat (i, n) scanf("%lld", &a[i]);
    vector<int> p(n); repeat (i, n) scanf("%d", &p[i]);
    // solve
    vector<ll> cnt(1 << n);
    repeat_from (s, 1, 1 << n) {
        ll acc = 1;
        repeat (i, n) if (s & (1 << i)) {
            ll a_i = a[i] / gcd(acc, a[i]);
            double estimated = acc *(double) a_i;
            if (m < estimated) {
                acc = m+1;
                break;
            }
            acc *= a_i;
        }
        cnt[s] = m / acc;
    }
    vector<ll> mu_cnt = fast_mobius_transform(cnt);
    long double result = 0;
    repeat (s, 1 << n) {
        long double acc = 1;
        repeat (i, n) acc *= (s & (1 << i) ? p[i] : 100 - p[i]) /(long double) 100.0;
        result += abs(mu_cnt[s]) * acc;
    }
    // output
    printf("%.10lf\n", (double)result);
    return 0;
}

Measured memory_bytes: 18784
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec::<usize>()[0];
    let line = read_as_vec::<usize>();
    let mut ans: (usize, usize) = (line[0], line[1]);

    for _ in 0..n-1{
        let line = read_as_vec::<usize>();
        let ratio = (line[0], line[1]);

        if ans.0 <= ratio.0 && ans.1 <= ratio.1{
            ans = ratio;
            continue;
        }

        let mul = cmp::max((ratio.0+ans.0-1)/ratio.0, (ratio.1+ans.1-1)/ratio.1);

        ans = (ratio.0*mul, ratio.1*mul);
    }

    println!("{}", ans.0+ans.1);
}


Measured memory_bytes: 4352
import std.stdio, std.string, std.array, std.conv;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int n = tmp[0], m = tmp[1], l = tmp[2];
    long[][] a = new long[][](n, m);
    foreach (i; 0 .. n) {
        long[] arow = readln.chomp.split.to!(long[]);
        foreach (j; 0 .. m) {
            a[i][j] = arow[j];
        }
    }
    long[][] b = new long[][](m, l);
    foreach (j; 0 .. m) {
        long[] brow = readln.chomp.split.to!(long[]);
        foreach (k; 0 .. l) {
            b[j][k] = brow[k];
        }
    }
    long[][] c = new long[][](n, l);
    foreach (i; 0 .. n) {
        foreach (k; 0 .. l) {
            foreach (j; 0 .. m) {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    foreach (i; 0 .. n) {
        foreach (k; 0 .. l) {
            c[i][k].write;
            if (k != l - 1) {
                " ".write;
            } else {
                writeln;
            }
        }
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
using namespace std;

bool f1(pair<int,int> p1, pair<int,int> p2){
	return p1.first>p2.first;
}

bool f2(pair<int,int> p1, pair<int,int> p2){
	return p1.second<p2.second;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	vector<pair<int,int> > vr(n+1),vl(n+1);
	int i,j;
	for(i=0;i<n;i++){
		cin>>vl[i].first>>vl[i].second;
		vr[i]=vl[i];
	}
	sort(vl.begin(), vl.end(), f1);
	sort(vr.begin(), vr.end(), f2);

	ll ans=0;

	for(i=0;i<n+1;i++){
		if(vl[i].first > vr[i].second)	ans+=2*(vl[i].first-vr[i].second);
		else	break;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

#define MOD 1000000007
#define mul(a, b) (((ll)(a) * (ll)(b)) % MOD)

int cnt[30];
char s[100005];
int n;

int main()
{
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        cnt[s[i] - 'a']++;
    }
    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = mul(ans, cnt[i] + 1);
    }
    ans--;
    if (ans < 0) ans += MOD;
    printf("%d", ans);
    return 0;
}


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

using namespace std;

int main(){
	int n, t;
	cin >> n;cin >> t;
	int mini = 100000;
	for (int i = 0;i < n;i++){
		int ci, ti;
		cin >> ci;cin >> ti;
		if (ti <= t) mini = min(mini, ci);
	}
	
	if (mini == 100000) {
		cout << "TLE\n";
	} else {
		cout << mini << "\n"; 
	}
	return 0;
}


Measured memory_bytes: 256
S = input()

patterns = []
def make_patterns(S, pairs, i = 1):
  global patterns
  #print(i, pairs, len(S))
  if i == len(S):
    patterns.append(list(map(int, pairs.split("+"))))
  else:
  	make_patterns(S, pairs + "+" + S[i], i + 1)
  	make_patterns(S, pairs + S[i], i + 1)
  
make_patterns(S, pairs = S[0], i = 1)
print(sum([sum(pattern) for pattern in patterns]))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  long long int a,b,x;
  cin >>a >> b >>x ;
  long long int flag = 0;
  if (a%x==0)flag = 1;
  a = a - (a % x);
  b  = b - (b % x);
  cout << (b - a) / x + flag << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	int r;
    	cin>>r;
    	float x=(44.0/7.0)*(r*1.0);
    	cout<<fixed << setprecision(10)<<x;
    }}
    	

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,A,B;cin>>N>>A>>B;
    cout<<N/(A+B)*A+min(A,N%(A+B))<<endl;
}




Measured memory_bytes: 256
N,H = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
as = []
bs = []
N.times {
  a,b = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }  
  as << a
  bs << b
}

MA = as.max
T = (bs.select{ |b| b > MA } || []).sort_by{ |b| -b }
TT = T.inject(:+) || 0

if H > TT
  puts T.size + ((H - TT - 1) / MA) + 1
  exit
end

h = 0
T.each_with_index { |b,i|
  h += b
  if h >= H
    puts i+1
    break
  end
}






Measured memory_bytes: 7432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, n;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    h -= a;
  }
  cout << ((h <= 0) ? "Yes" : "No") << endl;
}

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

const ll INF = 1LL << 60;

int main(void) {
  ll N;
  cin >> N;
  vector<double> P(N);
  REP(i, 0, N) cin >> P[i];

  vector<vector<double>> dp(N + 1, vector<double>(N + 1));
  dp[0][0] = 1;

  REP(i, 0, N) {
    REP(j, 0, N + 1) {
      dp[i + 1][j] += dp[i][j] * (1 - P[i]);
      if (j + 1 <= N) {
        dp[i + 1][j + 1] += dp[i][j] * P[i];
      }
    }
  }

  double ans = 0;
  REP(i, 0, N + 1) {
    if (i >= N - i) {
      ans += dp[N][i];
    }
  }
  printf("%0.15lf\n", ans);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define enum(i,x,y) for(int i=(x);i<=(y);++i)
#define try(i,x,y) for(int i=(x);i>=(y);--i)
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=205;

int n;
char str[MAXN];
int G[MAXN][MAXN],col[MAXN],sonsize[MAXN];
bool check(int u)
{
	enum(v,1,n)
	{
		if(!G[u][v])continue;
		if(col[v]){if(col[v]==col[u])return 0;}
		else
		{
			col[v]=3-col[u];
			if(!check(v))return 0;
			++sonsize[u];
		}
	}
	return 1;
}

int q[MAXN],dep[MAXN];
int bfs(int u)
{
	memset(dep,0,sizeof(dep));
	int front=1,rear=0,ans=0;
	q[++rear]=u;dep[u]=1;
	while(front<=rear)
	{
		u=q[front++];chkmax(ans,dep[u]);
		enum(i,1,n)
			if(G[u][i] && !dep[i])
			{
				dep[i]=dep[u]+1;
				q[++rear]=i;
			}
	}
	return ans;
}

int main()
{
	readint(n);
	enum(i,1,n)
	{
		scanf("%s",str+1);
		enum(j,1,n)G[i][j]=str[j]-'0';
	}
	col[1]=1;
	if(!check(1))return 0*printf("-1\n");
	int ans=0;
	enum(i,1,n)chkmax(ans,bfs(i));
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384