akhauriyash/Code-Regression huggingface dataset:
def main():
    h,w,k=map(int,input().split())
    s=[]
    for _ in range(h):
        a=list(input())
        s.append(a)
    ans=[]
    cnt=1
    zeroflg=0
    cntflg=[]
    cnttmp=[]
    for i in range(0,h):
        tmp=[]
        flag=0
        cnttmp.append(cnt)
        for j in range(0,w):

            if flag == 0 and s[i][j]=='.':
                tmp.append(cnt)
            elif flag==0 and s[i][j]=='#':
                tmp.append(cnt)
                flag=1
            elif flag == 1 and s[i][j]=='.':
                tmp.append(cnt)
            elif flag==1 and s[i][j]=='#':
                cnt+=1
                tmp.append(cnt)
        if cnttmp[i] != cnt or flag == 1:
            cnt+=1
            ans.append(tmp)
            cntflg.append(True)
        else:
            ans.append(tmp)
            cntflg.append(False)
    # print(ans)
    # print('fhajhfjhjahfakhfdajkhfdhfkjh')
    # print(cntflg)
    for i in range(0,h):
        if cntflg[i]==False:
            if i != h-1:
                f=0
                for j in range(i+1,h):
                    if cntflg[j]==True:
                        f=1
                        break
                
                if f==0:
                    for j in range(i-1,-1,-1):
                        if cntflg[j]==True:
                            break
                # print(j)
                for k in range(0,w):
                    ans[i][k]=ans[j][k]
            elif i == h-1:
                for j in range(h-2,-1,-1):
                    if cntflg[j]==True:
                        break
                for k in range(0,w):
                    ans[i][k]=ans[j][k]


    for aa in ans:
        print(*aa)
    # print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 49900
#include<bits/stdc++.h>
using namespace std;
char a[266];
int main()
{
	int b=100;
	cin>>a;
	for(int i=0;i<strlen(a)&&b!=0;i++)
	{
		if(a[i]=='C'||b==10)
		{
			b=10;
			if(a[i]=='F'&&b==10)
				b=0;
		}
	}
	if(b==0)
		cout<<"Yes";
	else
		cout<<"No";	
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll K;
int main(){
    cin>>K;
    int n=50;
    printf("%d\n",n);
    ll a=K/(ll)n; ll b=K%(ll)n;
    int cnt=0;
    for(int i=1;i<=(int)b;++i){
        ++cnt;
        cout<<49ll+a+((ll)n-(b-1ll))<<(cnt==n ? '\n' : ' ');
    }
    for(int i=1;i<=n-(int)b;++i){
        ++cnt;
        cout<<49ll+a-b<<(cnt==n ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A;


  return (A+1)/2;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, deque

n, m = tuple(map(int, sys.stdin.buffer.readline().split()))
L = tuple(tuple(map(int, sys.stdin.buffer.readline().split())) for _ in range(m))

# print(n, m)
# print(L)

X = [n + 1] * (n + 1)
Y = [0] * (n + 1)
d = defaultdict(set)
for a, b in L:
    d[a].add(b)
    d[b].add(a)
# print(d)

X0 = X[0]
X[1] = 0
qu = deque([1])
while qu:
  i = qu.popleft()
  cost = X[i]
  for b in d[i]:
    if X[b] == X0:
      X[b] = cost + 1
      qu.append(b)

# print(X)
s = X[0]
try:
    X.index(X[0], 1)
except ValueError:
    print('Yes')
    # for v in X[2:]:
    #     print(v)
    for i in range(2, n + 1):
      c = X[i]
      for v in d[i]:
        # print(i, c, v, X[v], c - 1== X[v])
        if c - 1 == X[v]:
          Y[i] = v
          break
    for v in Y[2:]:
        print(v)
else:
    print('No')


Measured memory_bytes: 82076
#include <stdio.h>

int main(void)
{
	int N,L[100],i,j,k,count=0,R[100],a,c[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&L[i]);
	for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
			if(L[i]>L[j]){
				a=L[i];
				L[i]=L[j];
				L[j]=a;
			}
		}
	}
	for(i=0;i<N;i++)c[i]=0;
	j=0;
	R[0]=L[0];
	c[0]++;
	for(i=1;i<N;i++){
		if(R[j]!=L[i]){
			j++;
			R[j]=L[i];
			c[j]++;
		}else{
			c[j]++;
		}
	}
	a=j+1;
	for(i=0;i<a-2;i++){
		for(j=i+1;j<a-1;j++){
			for(k=j+1;k<a;k++){
				if(R[i]+R[j]>R[k]){
					count+=c[i]*c[k]*c[j];
				}else break;
			}
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>

using namespace std;
int n,x,mini,i;
int main()
{
    cin>>n;
    mini=0;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x==mini+1)
            mini=x;
    }
    if(mini==0)
        cout<<-1;
    else
        cout<<n-mini;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
const int N=1000000+10;
long long n,m,P;
long long p[N],c[N];

void divide(long long n) {
	m=0;
	for (int i=2;i<=sqrt(n);i++) {
		if (n%i==0) {
			p[++m]=i,c[m]=0;
			while (n%i==0) n/=i,c[m]++;
		}
	}
	if (n>1) p[++m]=n,c[m]=1;
}

int main()
{
	scanf("%lld%lld",&n,&P);
	divide(P);
	
	LL ans=1;
	for (int i=1;i<=m;i++)
		for (int j=1;j<=c[i]/n;j++) ans=(ans*p[i]);
	cout<<ans;	
	return 0;
} 

Measured memory_bytes: 2304
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<array<int, 3>> abcs(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> abcs[i][j];
        }
    }
    array<int, 3> ar = {0, 0, 0};
    for (int i = 0; i < n; ++i) {
        array<int, 3> new_ar = ar;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (k == j) continue;
                new_ar[k] = max(new_ar[k], ar[j] + abcs[i][j]);
            }
        }
        ar = new_ar;
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        ans = max(ans, ar[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   double n, k, ans = 0;
   cin >> n >> k;
   for (int i = 1; i <= n; i++)
   {
      double x = 1;
      while (x * i < k)
         x *= 2;
      ans += 1 / x;
   }
   ans /= n;
   printf("%.10lf\n", ans);
   return 0;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

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

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



void solve(){
    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = i; j<=n;j+=i){
            ans+=j;
        }
    }
    cout << ans << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 3648
//つらい
//本当はNOだけどYesと返すらしい
#include <iostream>
#include <string>
#include <cassert>
using namespace std;

bool dp[100011] = {false};
string s;

bool is_ok(int pos, string t) {
	int i;
	
	for (i = 0; i < t.length(); i++) {
		int p = pos + i;
		if (p >= s.length()) return false;
		if (s[p] != t[i]) return false;
	}
	return true;
}

signed main() {
	int i;
	
	cin >> s;
	
	dp[0] = true;
	for (i = 0; i < s.length(); i++) {
		if (!dp[i]) continue;
		
		if (is_ok(i, "dream")) {
			dp[i + 5] = true;
		}
		if (is_ok(i, "dreamer")) {
			dp[i + 7] = true;
		}
		if (is_ok(i, "erase")) {
			dp[i + 5] = true;
		}
		if (is_ok(i, "eraser")) {
			dp[i + 6] = true;
		}
	}
	
	if (dp[s.length()]) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(auto &i:a) cin>>i;
	ll res=0;
	for(int i=0;i<60;i++){
		ll x=0,y=0;
		for(int j=0;j<n;j++){
			if(a[j]&1LL<<i) x++;
			else y++;
		}
		(res+=(1LL<<i)%mod*x%mod*y)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 2560
long V[3030][3030],dp[3030][3030][5];
main(R,C,K){
	scanf("%d%d%d",&R,&C,&K);
	for(int i=0;i<K;i++)
	{
		int r,c,v;
		scanf("%d%d%d",&r,&c,&v);
		V[r][c]=v;
	}
	for(int i=0;i<=R;i++)for(int j=0;j<=C;j++)for(int k=0;k<4;k++)
	{
		for(int r=0;r<2;r++)
		{
			int v=V[i+1-r][j+r];
			for(int l=0;l<2;l++)
			{
				int nk=r*k+l;
				if(dp[i+1-r][j+r][nk]<dp[i][j][k]+l*v)dp[i+1-r][j+r][nk]=dp[i][j][k]+l*v;
			}
		}
		if(dp[i][j][k+1]<dp[i][j][k])dp[i][j][k+1]=dp[i][j][k];
	}
	printf("%ld\n",dp[R][C][3]);
}

Measured memory_bytes: 427880
#include<stdio.h>

int main(void)
{
	char s[201];
	char p[101];
	int i,j,k;
        int c,m,n,t,x;

	for(i = 0;i < 201;i++){    //s[]????????????
		s[i] = 0;
	}
	
	scanf("%s",s);             //s???????????°????????????
	n = 0;
	for(i = 0;i < 101;i++){
		if(s[i] != 0){
			n++;
		}
	}
	m = 0;                       // m??¨??????s???????????????????´??????????
	m = n * 2;
	for(j = 0;j < n;j++){
		s[j + n] = s[j];
	}

        for(i = 0;i < 101;i++){      // p????????????
		p[i] = 0;
	}
	scanf("%s",p);               // p???????????????
        x = 0;
	for(i = 0;i < 101;i++){
		if(p[i] != 0){
			x++;
		}
	}
	for(i = 0;i < m;i++){                                           //??????
		if((s[i] == p[0]) && (s[i + (x - 1)]) == (p[x - 1])){
			c = 0;
			for(k = 0;k < x;k++){
				if(s[i + k] == p[k]){
					c++;
				}
				if(c != 0 && c == x){
					t++;
				}
			}
		}
	}
	if(t > 0){             //?????????
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 524
import * as fs from 'fs'

function main(args:string[]) {
    // 210 5
    // 31 41 59 26 53
    const line1: string = args[0];
    const line2: string = args[1];
    let h: number = parseInt(line1.split(' ')[0], 10);
    const n: number = parseInt(line1.split(' ')[1], 10);

    const tech = line2.split(' ').map(n => parseInt(n, 10));
    for (let i: number = 0; i < tech.length; i++) {
        h -= tech[i];
    }

    if (h <= 0) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

main(fs.readFileSync('/dev/stdin', 'utf8').split('\n'));



Measured memory_bytes: 16716
import time
import random


class TreapNode:
    def __init__(self, key, pri):
        self.left = None
        self.right = None
        self.key = key
        self.pri = pri


class Treap:
    def __init__(self):
        self.root = None

    def search_lower(self, key):
        if key == None:
            return None
        ptr = self.root
        ret = None
        while ptr is not None:
            pk = ptr.key
            if pk < key:
                ret = pk
                ptr = ptr.right
            else:
                ptr = ptr.left
        return ret

    def search_higher(self, key):
        if key == None:
            return None
        ptr = self.root
        ret = None
        while ptr is not None:
            pk = ptr.key
            if pk > key:
                ret = pk
                ptr = ptr.left
            else:
                ptr = ptr.right
        return ret

    def insert(self, key):
        pri = random.randrange(0, 2**25)
        ptr = self.root
        elem = TreapNode(key, pri)
        if ptr is None or ptr.pri < pri:
            self.root = elem
        else:
            while True:
                if key < ptr.key:
                    left = ptr.left
                    if left is None or left.pri < pri:
                        ptr.left = elem
                        ptr = left
                        break
                    ptr = left
                else:
                    right = ptr.right
                    if right is None or right.pri < pri:
                        ptr.right = elem
                        ptr = right
                        break
                    ptr = right
        left = elem
        right = elem
        while ptr is not None:
            if key < ptr.key:
                right.left = ptr
                right = ptr
                ptr = ptr.left
            else:
                left.right = ptr
                left = ptr
                ptr = ptr.right
        left.right = None
        right.left = None
        elem.left, elem.right = elem.right, elem.left

# デバッグ用
    def dump(self):
        self.__dump(self.root, 0)

    def __dump(self, idx, dep):
        if idx is not None:
            self.__dump(idx.right, dep + 1)
            for _ in range(0, dep):
                print("   ", end="")
            print([idx.key, idx.pri])
            self.__dump(idx.left, dep + 1)

def main():
    n = int(input())
    p = list(map(int, input().split()))
    idx = [0] * n
    for i in range(0, n):
        idx[i] = i
    idx.sort(key=lambda i: - p[i])
    t = Treap()
    t.insert(-1)
    t.insert(n)
    ans = 0
    for i in idx:
        nex = t.search_higher(i)
        nexnex = t.search_higher(nex)
        pre = t.search_lower(i)
        prepre = t.search_lower(pre)
        if prepre != None:
            ans += p[i] * (pre - prepre) * (nex - i)
        if nexnex != None:
            ans += p[i] * (i - pre) * (nexnex - nex)
        t.insert(i)
    print(ans)


main()


Measured memory_bytes: 83432
#include <stdio.h>
int main(void){
    int a,b,c;
    int i,j,tmp;
    
    scanf("%d", &i);
    for(j=0;j<i;j++){
        scanf("%d %d %d", &a, &b, &c);
        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        }
        if(b>c){
            tmp=b;
            b=c;
            c=tmp;
        }
        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        }
        if(a*a+b*b==c*c) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1968
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

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 push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N)
    cin >> A[i];

    ll money = 1000, stock = 0;

    REP(i, N)
    {

        if ((stock != 0 && i == N - 1) || (stock != 0 && A[i + 1] < A[i]))
        {
            money += stock * A[i];
            stock = 0;
            continue;
        }

        if (stock == 0 && A[i + 1] > A[i])
        {
            stock = money / A[i];
            money %= A[i];
            continue;
        }
    }

    cout << money << endl;

    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
    int n;
    vec<char> s;
    cin >> n ;
    char t;
    cin>>t;
    s.push_back(t);
    rep(i, n - 1)
    {
        cin >> t;
        if (s[s.size()-1] != t) { s.push_back(t); }
    }
    cout<<s.size()<<endl;
    return 0;
}

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


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3600
from itertools import groupby

s = input()
if s[-1] == '<':
    s += '>' 
r = p = 0
for k, g in groupby(s):
    s = sum(1 for _ in g)
    if k == '>':
        r += (p * p  + s * s - p - s) // 2 + max(p, s)
    p = s
print(r)


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

const int MAX_N = 2e5+10;
int N;
string X;
ll a, b;
int memo[MAX_N];
ll c[MAX_N],d[MAX_N];

int go(int x)
{
	if(x == 0) return 0;
	if(memo[x]!=-1) return memo[x];
	return memo[x]=(1+go(x%__builtin_popcount(x)));
}

ll powmod(ll x, int y, int MOD)
{
	ll res = 1;
	while(y){
		if(y&1) (res *= x)%=MOD;
		(x*=x)%=MOD;
		y>>=1;
	}
	return res;
}

void solve()
{
	int tot = 0;
	memset(memo,-1,sizeof(memo));
	for(int i=0;i<N;++i)if(X[i]=='1')tot++;
	if(!tot){
		for(int i=0;i<N;++i)cout<<1<<'\n';
	}else if(tot == 1){
		int b = -1;
		for(int i=0;i<N;++i){
			if(X[i]=='1'){
				b=i;
				break;
			}
		}
		for(int i=0;i<N;++i){
			if(i == b) cout << 0 << '\n';
			else{
				if(i==N-1 || b==N-1) cout << 2 << '\n';
				else cout << 1 << '\n';
			}
		}
	}else{
		a = 0, b = 0;
		for(int i=0;i<N;++i){
			c[i] = powmod(2LL, N-1-i, tot+1);
			d[i] = powmod(2LL, N-1-i, tot-1);
			if(X[i]=='1'){
			    (a += c[i])%=(tot+1);
			    (b += d[i])%=(tot-1);
			}
		}
		for(int i=0;i<N;++i){
			if(X[i]=='0') cout << 1+go((a+c[i])%(tot+1)) << '\n';
			else cout << 1+go((b-d[i]+tot-1)%(tot-1)) << '\n';
		}
	}
}

int main()
{
	cin >> N;
	cin >> X;
	solve();
	return 0;
}

Measured memory_bytes: 7548
#include <stdio.h>

int main() {
  int n_array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  
  scanf("%d", &K);
  printf("%d", n_array[K-1]);
  return 0;
}

Measured memory_bytes: 128
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
arr=[1,2]
arr=arr+[0]*(n-2)
danger=[int(input()) for _ in range(m)]
if danger==[]:
  pass
elif danger[0]==1:
  arr[0]=0
  arr[1]=1
for i in range(m):
  arr[danger[i]-1]=-1
for i in range(n):
  if arr[i]==-1:
    arr[i]=0
  elif i==0 or i==1:
    continue 
  else:
    arr[i]=(arr[i-1]+arr[i-2])%(10**9+7)
print(arr[n-1]%(10**9+7))


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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  
  rep (i, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  
 cout << ans << endl;
}



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


int main() {
int N;
cin >> N;
vector<int> vec(N);
int cnt = 0,mini = INF;
rep(i,N) {
    cin >> vec.at(i);
    if (vec.at(i) <= mini) {
        cnt++;
        mini = vec.at(i);
    }
}


cout << cnt << endl;

return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int n;
Vi take,goal(3);

int dfs(int depth,Vi now){
    if(depth==n){
        REP(i,0,3) if(now[i]==0) return INF;
        int ret=0;
        REP(i,0,3) ret+=abs(now[i]-goal[i]);
        return ret;
    }
    
    int ret=INF;
    REP(i,0,3){
        Vi next=now;
        next[i]+=take[depth];
        if(now[i]==0){
            chmin(ret,dfs(depth+1,next));
        }else{
            chmin(ret,dfs(depth+1,next)+10);
        }
        chmin(ret,dfs(depth+1,now));
    }
    return ret;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    vin(goal);
    take=Vi(n);
    vin(take);
    int ans = dfs(0,Vi(3,0));
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int a,b,k;
	cin >> a >> b >> k;
	if (b - a + 1 <= 2 * k) {
		for (int i = a;i <= b;i++) {
			cout << i << endl;
		}
	}
	else {
		for (int i = a;i < a + k;i++) {
			cout << i << endl;
		}
		for (int i = b - k + 1;i <= b;i++) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

vector<int> ans;
int arr[13];
int cnt[10];

bool judge(int a[]){
  int sum = 0;
  for(int i = 1 ; i <= 9 ; i++){
    sum += a[i];
  }
  if(sum == 0) return true;
  for(int i = 3 ; i <= 9 ; i++){
    if(a[i-2] > 0 && a[i-1] > 0 && a[i] > 0){
      a[i-2]--; a[i-1]--; a[i]--;
      if(judge(a)) return true;
      a[i-2]++; a[i-1]++; a[i]++;
    }
  }

  for(int i = 1 ; i <= 9 ; i++){
    if(a[i] >= 3){
      a[i] -= 3;
      if(judge(a)) return true;
      a[i] += 3;
    }
  }

  return false;
}

void solve(){
  int tmp[10];
  for(int i = 0 ; i < 9 ; i++){
    for(int j = 0 ; j < 10 ; j++){
      tmp[j] = cnt[j];
    }
    if(cnt[i+1] > 3) continue;
    cnt[i+1]++;
    for(int j = 1 ; j <= 9 ; j++){
      if(cnt[j] >= 2) cnt[j]-=2;
      else continue;
      if(judge(cnt)){
        ans.push_back(i+1);
        break;
      }
      cnt[j] += 2;
    }
    for(int j = 0 ; j < 10 ; j++){
      cnt[j] = tmp[j];
    }
  }
}

int main(){
  string str;
  while(cin >> str){
    memset(cnt,0,sizeof(cnt));
    for(int i = 0 ; i < 13 ; i++){
      arr[i] = str[i]-'0';
      cnt[arr[i]]++;
    }
    sort(arr, arr+13);
    ans.clear();
    solve();
    int size = ans.size();
    if(!size){
      cout << 0 << endl;
    }else{
      for(int i = 0 ; i < size ; i++){
        if(i == 0) cout << ans[i];
        else cout << " " << ans[i];
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S,T;
  cin >> S >> T;
  
  int n=S.size();
  
  T.pop_back();
  
  if(S==T){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3576
import sys
n,k = map(int,input().split())
input = sys.stdin.readline
W = [int(input()) for i in range(n)]
l = max(W)-1
W.append(10**13)
h = sum(W)
while l+1 < h:
    ok = (l+h)//2
    track = 0
    cur = 0
    for i in range(n+1):
        cur += W[i]
        if cur > ok:
            track += 1
            cur = W[i]
        elif cur == ok:
            if i != n-1:
                track += 1
                cur = 0
    if track > k:
        l = ok
    else:
        h = ok
print(h)


Measured memory_bytes: 9568
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	dd := make([][]int, m+1)
	for i := 1; i < m+1; i++ {
		for j := i; j < m+1; j += i {
			dd[j] = append(dd[j], i)
		}
	}
	seg := newSegment(m + 1)
	pp := make([]pair, n)
	for i := 0; i < n; i++ {
		l := getNextInt(scanner)
		r := getNextInt(scanner)
		pp[i][0] = l
		pp[i][1] = r
	}
	sort.SliceStable(pp, func(i, j int) bool {
		return pp[i][1] > pp[j][1]
	})
	j := 0
	ans := make([]int, m+1)
	for i := m; i >= 1; i-- {
		for j < n && pp[j][1] >= i {
			seg.update(pp[j][0], seg[0][pp[j][0]]+1, seg.add)
			j++
		}
		for _, d := range dd[i] {
			if i-d+1 < 0 {
				ans[d] += seg.query(0, i+1, 0, seg.add)
			}
			ans[d] += seg.query(i-d+1, i+1, 0, seg.add)
		}
	}
	for i := 1; i < m+1; i++ {
		fmt.Fprintln(writer, ans[i])
	}
}

type pair [2]int

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) update(i int, v int, f func(x, y int) int) {
	seg[0][i] = v
	for h := 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i] = f(seg[h-1][i<<1], seg[h-1][i<<1+1])
		} else {
			seg[h][i] = seg[h-1][i<<1]
		}
	}
}
func (seg segment) query(l, r int, s int, f func(x, y int) int) int {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			s = f(s, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			s = f(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) add(x, y int) int {
	return x + y
}


Measured memory_bytes: 33400
#include <iostream>

long long N;
int main(){
  std::cin>>N;
  
  long long ans;
  ans=(N/11)*2;
  N=N%11;
  if(N!=0)
    ans+=N>6?2:1;
  
  std::cout<<ans<<std::endl;
  
  return 0;
}

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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3536
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
int main(){
	int n,d[55];
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
		scanf("%d",&d[i]);
	int sum = 0;
	for(int i = 1;i < n;i++){
		for(int j = i+1;j <= n;j++){
			sum += d[i]*d[j];
		}
	}
	printf("%d",sum);
	return 0;
}

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

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

  vector<vector<int>> G(n);
  for (int i = 0; i < m; i++) {
    int u,v;
    cin >> u >> v;
    u--, v--;

    G[u].push_back(v);
  }
  int s,t;
  cin >> s >> t;
  s--, t--;

  vector<vector<int>> dist(n, vector<int> (3,-1));
  queue<pair<int,int>> que;
  que.emplace(s,0);
  dist[s][0] = 0;
  while(!que.empty()) {
    int cur = que.front().first;
    int mod = que.front().second;
    que.pop();

    for (auto nxt : G[cur]) {
      if(dist[nxt][(mod+1)%3] != -1) continue;

      que.emplace(nxt, (mod+1)%3);
      dist[nxt][(mod+1)%3] = dist[cur][mod] + 1;
    }
  }
  int ans = dist[t][0];
  if(ans != -1) ans /= 3;
  cout << ans << '\n';
  return 0;
}

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

int main(){
	int n, a, b, at, bt;
	
loop:
	scanf("%d\n", &n);		// 各人のカード枚数
	if(n == 0) goto end_scope;
	at = 0;
	bt = 0;
	
labl_testloop:
	scanf("%d %d\n", &a, &b);
	if(a > b) at += a + b; else if(a == b){at += a; bt += b;}else bt += a + b;
	n--;
	if(n > 0) goto labl_testloop;
	
	printf("%d %d\n", at, bt);
	goto loop;
end_scope:
    return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  string s1,s2,s3;
  cin >> s1;
  cin >> s2;
  cin >> s3;
  string ans = "";
  ans += s1[0];
  ans += s2[1];
  ans += s3[2];
  cout << ans << endl;
}


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

using namespace std;
#define int int64_t
#define fi first
#define se second
#define endl '\n'
vector<vector<int>> g;
vector<int> color;
vector<int> was;

void dbfs(int v, int d, int col) {
     queue<pair<int, int>> q;
     q.push({d, v});
     while (q.size()) {
          auto fr = q.front();
          int v = fr.second;
          int len = fr.first;
          q.pop();
          was[v] = max(was[v], len);
          if (color[v] == 0) {
               color[v] = col;
          }
          for (auto u : g[v]) {
               if (was[u] < len - 1) {
                    q.push({len - 1, u});
               }
          }
     }
}

signed main()
{
     srand(time(nullptr));
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     int n, x;
     cin >> n >> x;
     vector<int> a(n);
     for (int i = 0; i < n; ++i) {
          cin >> a[i];
     }
     int ans = 0;
     for (int i = 1; i < n; ++i) {
          int curr = a[i - 1] + a[i];
          if (curr > x) {
               ans += (curr - x);
               if (a[i] < (curr - x)) {
                    a[i - 1] -= (curr - x - a[i]);
                    a[i] = 0;
               } else {
                    a[i] -= (curr - x);
               }
          }
     }
     cout << ans;
     return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int D[50];
int R[50][50];
int f[50][50];

int main()
{
  int cnt;
  int N;
  int i,j;
  int result = 0;

  cnt = scanf("%d", &N);

  for (i=0; i<N; i++) {
    cnt = scanf("%d", &D[i]);
  }

  for (i=0; i<N; i++) {
    for (j=0; j<N; j++) {
      if (i==j) continue;
      if (f[i][j] != 0) continue;
      if (f[j][i] != 0) continue;
      f[i][j] = 1;
      R[i][j] = D[i] * D[j];
      result += R[i][j];
    }
  }

  printf("%d", result);

  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	ll n, m, x[100010], y[100010], rx[100010] = { 0 }, ry[100010] = { 0 }, ans = 0, yy = 0;
	cin >> n >> m;
	for (int i = 1;i <= n;i++) {
		cin >> x[i];
		rx[i] = rx[i - 1] + x[i];
	}
	for (int i = 1;i <= m;i++) {
		cin >> y[i];
		ry[i] = ry[i - 1] + y[i];
	}
	for (int i = 1;i <= m - 1;i++) {
		yy = (yy + (ry[m] - ry[i] - ry[m - i]) + MOD * 1000000) % MOD;
	}
	//cout << yy << endl;
	for (int i = 1;i <= n - 1;i++) {
		ans = ans + (((rx[n] - rx[i] - rx[n - i] + MOD * 1000000)) % MOD*yy) % MOD;
		ans %= MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>


int main(void)
{
  int count;
  int num[100];
  int i;
  int n2 = 0;
  int n4 = 0;
  
  scanf("%d", &count);
  for (i=0; i<count; i++)
     scanf("%d", &num[i]);
  
  for (i=0; i<count; i++) {
    if (num[i]%2 == 0) {
      n2++;
      if(num[i]%3 == 0 || num[i]%5 == 0)
        n4++;
    }
  }
  
  if (n2 == n4)
    printf("APPROVED\n");
  else
    printf("DENIED\n");
  
  return 0;
}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	Sort(S);
	if (S.at(0)==S.at(2))
		cout <<"No" <<endl;
	else 
		cout <<"Yes" <<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
u = [[] for i in range(N)]
#（便宜的に地点から-1としておく）
for i in range(M):
    s, t = map(int, input().split())
    u[s-1].append(t-1)

#output
#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for v in range(N):
    for i in range(v):
        if v in u[i]:
            p[v] += p[i]/len(u[i])

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for v in reversed(range(N)):
    for i in u[v]:
        q[v] += (1 + q[i])/len(u[v])

v = [0] * N
for i in range(N-1):
    a = len(u[i])
    if a > 1:
        b = max(q[c] for c in u[i])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)

print(q[0]+min(v))


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

int main()
{
  	string str;
	cin>>str;
  	
  	if(str[2] == str[3] and str[4] == str[5])
    {
    	cout<<"Yes";
    }
  else
  {
  	cout<<"No";
  }
  return 0;
}

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

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

    int n = x / 100;
    int m = x % 100;
    int l = m / 5 + (m % 5 == 0 ? 0 : 1);
    if (n >= l) cout << 1;
    else cout << 0;
    cout << endl;

    return 0;
}


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

int main(){
    int n, x;
    int count;

    while(1){
        cin >> n >> x;
        count = 0;
        if(n == 0 and x == 0){
            break;
        }
        for(int i = 1;i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x){
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }

return 0;
}


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


int main(){
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0 && w==0) break;
        else{
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i%2==0 && j%2==0) cout<<"#";
                    else if(i%2==0 && j%2==1) cout<<".";
                    else if(i%2==1 && j%2==0) cout<<".";
                    else if(i%2==1 && j%2==1) cout<<"#";
                }
                cout<<endl;

            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3116
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,m,d=map(int,input().split())
if d!=0:
    ans=2*(m-1)*(n-d)/(n**2)
    print(ans)
else:
    ans=(m-1)/n
    print(ans)

Measured memory_bytes: 9368
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<int>());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
S = list(map(str, input().split()))

Color = ['P', 'W', 'G', 'Y']

count = 0

for c in Color:
    if c in S:
        count += 1

if count == 3:
    ans = 'Three'
elif count == 4:
    ans = 'Four'

print(ans)

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

int main(){
    int n;
    cin >> n;
    int ans = (n+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	public void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			System.out.println(solve(n));
		}
	}

	private int solve(int n) {
		
		int right = 2;
		int left = 0;
		int sum = 3;
		
		int result = 0;
		for(;right<n;){
			if(sum == n){
				result++;
				right++;
				sum += right;
			}else if(sum < n){
				right++;
				sum += right;
			}else{
				left++;
				sum -= left;
			}
		}
		return result;
	}
}

Measured memory_bytes: 26284
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    ll n, ans;
    while(cin>>n){
        ans = 0;
        ans+= (n/500) * 1000;
        n%=500;
        ans+= (n/5) * 5;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(itr i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(itr i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define TYPE(t) decltype(t)
#define _IT ::iterator
#define UN unsigned
#define SC(t, a) static_cast<t>(a)

template<typename T>
inline bool in_range(T const &lower, T const &a, T const &upper){ return lower < a && a < upper;}

constexpr double inf = std::numeric_limits<double>::infinity();

using i8 = std::int_fast8_t;  using i16 = std::int_fast16_t;
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t; using u16 = std::uint_fast16_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;

using namespace std;

using itr = i32;


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

  string s;
  bool c = false;


  cin >> s;

  for(auto cc : s){
    if(!c) c = cc == 'C';

    if(c && cc == 'F'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No";



  

  return 0;
}

Measured memory_bytes: 256