akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var N = raw[0];
            var M = raw[1];
            var C = raw[2];

            var B = ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var A = ReadLine().Split().Select(int.Parse).ToArray();
                var sum = C;
                for (int j = 0; j < A.Length; j++)
                {
                    sum += A[j] * B[j];
                }
                if (sum > 0) ans++;
            }

            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    n = len(s) - 1

    # bit全探索
    for i in r(1 << n):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if id.bit_n(i, j):
                p += "+"
            if j == n:
                break
        # p += s[-1]
        ans += eval(p)
    print(ans)


main()


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define N 100010
#define MOD 1000000007
using namespace std;
int main(){
	long long n,m,a,dp[N],i;
	bool book[N]={};
	cin>>n>>m;
	memset(dp,0,sizeof(dp));
	for(i=0;i<m;i++)
	{
		cin>>a;
		book[a]=true;
	}
	dp[0]=1;
	for(i=1;i<=n;i++)
	{
		if(!book[i])
		{
			if(!book[i-1])
				dp[i]+=(dp[i-1])%MOD;
			if(i-2>=0)
			{
				if(!book[i-2])
					dp[i]+=(dp[i-2])%MOD;
			}
		}
	}
	cout<<(dp[n]%MOD)<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

int n, a;
int x[60];

ll ans;
ll dp[60][60][2510];

int main(){

  n = in();
  a = in();
  REP( i , n ){
    x[i] = in();
  }

  dp[0][0][0] = 1;
  REP( i , n ){
    REP( j , i+1 ){
      REP( k , 2510 ){
	if( dp[i][j][k] ){
	  dp[i+1][j][k] += dp[i][j][k];
	  dp[i+1][j+1][k+x[i]] += dp[i][j][k];
	}
      }
    }
  }

  FOR( i , 1 , n+1 ){
    ans += dp[n][i][i*a];
  }

  cout << ans << endl;
  
  return 0;
}


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

template<class T> bool isPrime(T num)
{
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        double sqrtNum = sqrt(num);
        for (T i = 3; i <= sqrtNum; i += 2)
        {
                if (num % i == 0)
                {
                return false;
                }
        }
        return true;
}

main()
{
        int n; cin>>n;
        while(true)
        {
                if(isPrime(n))
                {
                        cout<<n<<endl;
                        return 0;
                }
                n++;
        }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		//100 50 4 なら1 2 5　10 25 50 の 5
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c;
		int k = scanner.nextInt();
		
		if(a>b) c=a;
		else    c=b;
		for(int i=c;i>=1;i--) {
			if(a%i==0 && b%i==0) {
				--k;
				if(k==0) {
					System.out.println(i);
				}
			}
		}
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll A, B;
    cin >> A >> B;
    ll res;
    if(A>=13) res = B;
    else if(A<=5) res = 0;
    else res = B/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int idxa,idxb,ans;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            idxa=i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[s.size()-i-1]=='Z'){
            idxb=s.size()-i-1;
            break;
        }
    }
    
    ans = idxb-idxa+1;;
    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
}


Measured memory_bytes: 640
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
neg_A = []
for a in A:
    neg_A.append(-a)
heapq.heapify(neg_A)

for i in range(M):
    n = heapq.heappop(neg_A)
    heapq.heappush(neg_A, -(-n//2))

print(sum(neg_A) * (-1))


Measured memory_bytes: 14180
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var s = o.a(1);
  var ans = 999;
  for(var i = 2; i < s.length; i++){
    var t = s[i-2] + s[i-1] + s[i];
    t = Math.abs(t - 753);
    if(ans > t)ans = t;
  }
  return ans;
}

Measured memory_bytes: 21064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  int len = s.length();
  REP(i, len - 1){
    if(s[i] == s[i + 1]){
      printf("%d %d\n", i + 1, i + 2);
      return 0;
    }
  }

  REP(i, len - 2){
    if(s[i] == s[i + 2]){
      printf("%d %d\n", i + 1, i + 3);
      return 0;
    }
  }

  printf("-1 -1\n");

  return 0;
}



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

int main ()
{
  string s,t;
  cin>>s>>t;
  int cunt =0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])
    {
      cunt++;
    }
  }
  cout<<cunt<<endl;
}


Measured memory_bytes: 3864
/************************************/
/* NoobM							*/
/* File Name : at.cpp				*/
/* Date : 21.06.2020 18:00:49 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	ll n;
	cin >> n;
	
	list <char> ans;
	
	while(n > 0) {
		int k = n % 26;
		if(k == 0) k = 26;
		
		char c = 96 + k;
		
		//cout << c;
		
		ans.push_front(c);
		
		n -= k;
		
		n /= 26;
	}
	
	for(char x : ans) cout << x;
	
	cout << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3624
s = input()
n = len(s)
ans = n
s1 = s.count('1')
i = 0
while s1 != 0 and s1 != n:
  s1 -= int(s[i]) + int(s[i + n - 1])
  if n == 1:
    s1 += int(s[i])
  n -= 2
  ans -= 1
  i += 1
print(ans)


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string c;
    cin >> n >> c;
    int r=0;
    for(int i = 0; i < n; i++) {
        if(c[i]=='R') r++;
    }
    int w=0;
    int ans=r;
    for(int i = 0; i < n; i++) {
        if(c[i]=='W') w++;
        else r--;
        int tans=max(w,r);
        ans=min(ans,tans);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  ll mx = 0;
  rep(i, n) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  ll r = 0, ans = 0;
  rep(i, n) {
    ll now = min(a[i], mx - a[i]);
    if(r < now) {
      r = now;
      ans = a[i];
    }
  }
  cout << mx << ' ' << ans << endl;
}

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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> white(2 * K + 1, vector<int>(2 * K + 1, 0));
  vector<vector<int>> black(2 * K + 1, vector<int>(2 * K + 1, 0));
  
  for(int i = 0; i < N; i++){
    int x, y;
    char c;
    cin >> x >> y >> c;
    if(c == 'W') white[x % (2 * K) + 1][y % (2 * K) + 1]++;
    else black[x % (2 * K) + 1][y % (2 * K) + 1]++;
  }
  
  for(int y = 0; y <= 2 * K; y++){
    for(int x = 1; x <= 2 * K; x++){
      white[x][y] += white[x - 1][y];
      black[x][y] += black[x - 1][y];
    }
  }
  
  for(int x = 0; x <= 2 * K; x++){
    for(int y = 1; y <= 2 * K; y++){
      white[x][y] += white[x][y - 1];
      black[x][y] += black[x][y - 1];
    }
  }
  
  vector<vector<int>> w(4, vector<int>(4));
  vector<vector<int>> b(4, vector<int>(4));
  
  int count = 0;
  for(int x = 0; x <= 2 * K; x++){
    for(int y = 0; y <= 2 * K; y++){
      int cnt = 0;
      
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
          int xi = min(max(x - K + i * K, 0), 2 * K);
          int yj = min(max(y - K + j * K, 0), 2 * K);
          w[i][j] = white[xi][yj];
          b[i][j] = black[xi][yj];
        }
      }
      
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
          if((i + j) & 1){
            if(i < 3 && j < 3)
              cnt += 2 * w[i][j] - 2 * b[i][j];
            else
              cnt += w[i][j] - b[i][j];
          }else{
            if(i < 3 && j < 3)
              cnt += - 2 * w[i][j] + 2 * b[i][j];
            else if(i == 3 && j == 3)
              cnt += b[i][j];
            else
              cnt += -w[i][j] + b[i][j];
          }
        }
      }
      count = max(cnt, count);
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 500000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int c[maxn+5];
int last[maxn+5];
int ans[maxn+5];
vector<pii> que[maxn+5];

struct bit
{
    int a[maxn+5];
    void add(int x,int v)
    {
        for(;x<=maxn;x+=x&-x) a[x]+=v;
    }
    int ask(int x)
    {
        int res=0;
        for(;x;x-=x&-x) res+=a[x];
        return res;
    }
}b;

int main()
{
    int n,q; scanf("%d%d",&n,&q);
    rep(i,1,n) scanf("%d",&c[i]);
    rep(i,1,q)
    {
        int l,r; scanf("%d%d",&l,&r);
        que[r].pb({l,i});
    }
    int S=0;
    rep(i,1,n)
    {
        if(last[c[i]]!=0) b.add(last[c[i]],-1);
        else S++;
        last[c[i]]=i;
        b.add(i,1);
        for(auto it: que[i])
        {
            ans[it.SE]=S-b.ask(it.FI-1);
        }
    }
    rep(i,1,q) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 33176
#include <stdio.h>

int main(void)
{
  int a, b, c, d;

  scanf("%d %d %d", &a, &b, &c);

  if(b<a)
    {
      d=a;
      a=b;
      b=d;
    }

  if(c<b)
    {
      d=b;
      b=c;
      c=d;
    }

  if(b<a)
    {
      d=a;
      a=b;
      b=d;
    }

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#define N 100

int main() {
  int i,j,s,length,count=0,mini;
  int A[N];

  scanf("%d", &length);
  for(i=0; i<length; i++) {
    scanf("%d", &A[i]);
  }

  for(i=0; i<length; i++){
    mini = i;
    for(j=i; j<length; j++) {
      if(A[j] < A[mini]) {
	mini = j;
      }
    }
    if(i < mini) {
      s = A[i];
      A[i] = A[mini];
      A[mini] = s;
      count ++;
    }
  }

  for(i=0; i<length; i++) {
    printf("%d", A[i]);
    if(i!=length-1)
      printf(" ");
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}

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

import re

N = int(input())
S = input()

numw, numb = 0, 0
lw, lb = [0], [0]
for i in range(len(S)):
    if S[i] == '.':
        numw += 1
    else:
        numb += 1
    lw.append(numw)
    lb.append(numb)

ans = N
for i in range(len(S) + 1):
    ans = min(ans, lb[i] + (lw[-1] - lw[i]))

print(ans)


Measured memory_bytes: 13008
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cctype>
using namespace std;
#define P pair<int, const char*>
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

P fact(const char *p);
P term(const char *p);
P expr(const char *p);

int main(){
    int c; cin >>c;
    REP(i, c){
        string str; cin >>str;
        cout <<expr(str.substr(0, str.size()).c_str()).first <<endl;
    }
    return 0;
}

P fact(const char *p){
    if(isdigit(*p)){
        int t = *(p++) - '0';
        while(isdigit(*p)) t = t * 10 + *(p++) - '0';
        return P(t, p);
    } else if(*p == '('){
        P r = expr(p + 1);
        if(*r.second != ')') exit(0);
        return P(r.first, r.second + 1);
    } else{
        exit(0);
    }
}


P term(const char *p){
    P r = fact(p);
    while(*r.second == '*' || *r.second == '/'){
        char op = *r.second;
        int tmp = r.first;
        r = fact(r.second + 1);
        if(op == '*') r.first = tmp * r.first;
        else r.first = tmp / r.first;
    }
    return r;
}

P expr(const char *p){
    P r = term(p);
    while(*r.second == '+' || *r.second == '-'){
        char op = *r.second;
        int tmp = r.first;
        r = term(r.second + 1);
        if(op == '+') r.first = tmp + r.first;
        else r.first = tmp - r.first;
    }
    return r;
}

Measured memory_bytes: 1212
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

vector<int> factorize(lint N) {

	vector<int> res;
	for (lint i = 2; i * i <= N; i++) {
		int cnt = 0;
		while (N % i == 0) {
			cnt++;
			N /= i;
		}
		if (cnt) res.emplace_back(cnt);
	}
	if (N != 1) res.emplace_back(1);

	return res;

}

int main() {

	lint N;
	cin >> N;

	auto num = factorize(N);

	int ans = 0;
	for (auto& e : num) {
		for (int i = 1; i < N; i++, ans++) {
			e -= i;
			if (e < 0) break;
		}
	}

	cout << ans << "\n";

	return 0;
}



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

int main(){
  int max , n , x , sum ;
  sum = 0 ;
  cin >> n ;
  for(int i=0; i<n; i++){
    cin >> x ;
    sum += x ;
    if(max<x)
      max = x ;
  }
  if(max<sum-max)
    cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define endl	"\n"
#define pb 		push_back
#define mp 		make_pair
#define MOD 	1000000007
#define INF 	(long long int)1e9
#define EPS 	1e-9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ret     return
#define NUM 	100020
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	fastio();
	//input();

	int n;
	cin>>n;
	int a[n][3],dp[n][3];
	for(int i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i=1;i<n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

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

using namespace std;

typedef pair< int, int >	pii;

const int N = int(1e5 + 100);
vector< pii > adj[N];
int color[N];

void dfs(int u, int val, int ft){
	color[u] = val;

	for(int i = 0 ;i < adj[u].size() ; i++){
		int v = adj[u][i].first;
		int w = adj[u][i].second;

		if(v != ft){
			dfs(v, (val + w) & 1, u);
		}
	}
}

int main(){
	int n;

	scanf("%d", &n);

	for(int i = 1 ; i < n ; i++){
		int ui, vi, wi;

		scanf("%d %d %d", &ui, &vi, &wi);
		wi &= 1;

		adj[ui].push_back({vi, wi});
		adj[vi].push_back({ui, wi});
	}

	dfs(1, 1, 0);

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

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

#define int long long

int comb(int a, int b)
{
    int x = a, y = 1;
    for(int i = 1; i < b; ++i)
    {
        --a;
        
        x = x * a;
        y = y * y+1;
    }
    
    return x / y;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> v(n);
    int maxm = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
        maxm = max(maxm, v[i]);
    }
    
    int hm = maxm / 2;
    int ans;
    int d = 10000000000;
    
    for(int i = 0; i < n; ++i)
    {
        if(v[i] == maxm)
        {
            continue;
        }
        int hoge = abs(v[i] - hm);
        if(hoge < d)
        {
            d = hoge;
            ans = v[i];
        }
    }
    
    cout << maxm << " " << ans << endl;
    
    return 0;
}



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

int c[33], s[444][33];
int sc(int i, int t, const vector<int> &v) {
    int j = i - 1, k = i + 1;
    while(j >= 0 && v[j] != t)
        j--;
    while(k < v.size() && v[k] != t)
        k++;
    return s[i][t] + c[t] * (i - j) * (k - i);
}
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 16);
    uniform_real_distribution<> ru(0, 1);
    vector<int> tt(d);
    for(int &i : tt)
        i = rc(mt);
    auto ti = clock();
    for(;;) {
        auto T = (clock() - ti) / 1.9 / CLOCKS_PER_SEC;
        if(T > 1)
            break;
        auto U = pow(2e3, 1 - T) * pow(6e2, T);
        for(int cn = 0; cn < 100; cn++) {
            if(rc(mt) < 13) {
                int x0 = r0(mt), xc = rc(mt);
                int di = sc(x0, xc, tt) - sc(x0, tt[x0], tt);
                if(ru(mt) <= exp(di / U))
                    tt[x0] = xc;
                continue;
            }
            int x2 = r2(mt);
            uniform_int_distribution<> r1(0, d - 1 - x2);
            int x1 = r1(mt);
            x2 += x1;
            int di = -sc(x1, tt[x1], tt) - sc(x2, tt[x2], tt);
            swap(tt[x1], tt[x2]);
            di += sc(x1, tt[x1], tt) + sc(x2, tt[x2], tt);
            if(ru(mt) > exp(di / U))
                swap(tt[x1], tt[x2]);
        }
    }
    for(int i : tt)
        cout << i + 1 << '\n';
    return 0;
}


Measured memory_bytes: 4240
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int l = 0;
  int r = s.size()-1;
  int ans = 0;
  while(l < r){
    if(s[l] == s[r]){
      l++;
      r--;
    }else if(s[l] == 'x'){
      ans++;
      l++;
    }else if(s[r] == 'x'){
      ans++;
      r--;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<vector<pii>> v(n);
	rep(i,n) {
		int a;
		cin >> a;
		int x, y;
		rep(j,a) {
			cin >> x >> y;
			x--;
			v[i].push_back(pii(x, y));
		}
	}
	int ans = 0;
	rep(bit, (1 << n)) {
		bool b = true;
		rep(i, n) {
			if (!(bit & (1 << i))) continue;
			for (auto p: v[i]) {
				if ((bool)(bit & (1 << p.first)) ^ p.second) b = false;
			}
		}
		if (b) ans = max(ans, __builtin_popcount(bit));
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3616
N = int(input())
H = [int(x) for x in input().split()]

cnt = 0
maxcnt = 0
for j in range(0,N):
  if (j!=N-1)and(H[j]>=H[j+1]):
    cnt += 1
  else:
    if cnt>maxcnt:
      maxcnt = cnt
      cnt = 0
    else:
      cnt = 0
print(maxcnt)

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

using namespace std;
int H, W;
int field[101][101];
char tmp[101];

vector<int> xid, yid;

void compress(int H, int W){
    for(int j = 0; j< W; j++){
        for(int i=0; i<H; i++){
            if(field[i][j]){
                xid.push_back(j);
                break;
            }
        }
    }
}

int main(){
    scanf("%d%d", &H, &W);
    for(int i=0; i<H; i++){
        scanf("%s", tmp);
        for(int j=0; j<W; j++){
            if(tmp[j] == '.') field[i][j] = 0;
            else field[i][j] = 1, yid.push_back(i);
        }
    }
    yid.erase(unique(yid.begin(), yid.end()), yid.end());
    compress(H, W);
    xid.erase(unique(xid.begin(), xid.end()), xid.end());

    for(auto yit = yid.begin(); yit != yid.end(); yit++){
        for(auto xit = xid.begin(); xit != xid.end(); xit++){
            if(field[*yit][*xit]) printf("%c", '#');
            else printf("%c", '.');
        }
    printf("\n");
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
//int a[N];
int n,L ;
LL gcd(LL a,LL b)
{
	return a == 0 ? b : gcd(b % a, a);
}
LL  a,b,c,d;
int main()
{
     cin>>a>>b>>c>>d;
     LL ans=b/c-a/c+b/d-a/d-(b/(c*d/gcd(c,d))-a/(c*d/gcd(c,d)));
     if(a%c==0) ans++;
     if(a%d==0) ans++;
     if(a%(c*d)==0) ans--;
   //cout<<ans<<endl;
     ans=b-a+1-ans;
     cout<<ans<<endl;

	return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 200000;

vector<int> tree[N_MAX];
vector<int> used(N_MAX, 0);
vector<int> color(N_MAX, 0);
vector<int> cnt(6, 0);
int n;

void dfs(int node, int par, int c) {
    color[node] = c;
    ++cnt[c];
    for(int child: tree[node]) {
        if(child == par) continue;
        dfs(child, node, (c==1?2:1));
    }
}

pair<int, ll> dfs_diameter(int node, ll dist) {
    used[node] = 1;
    pair<int, ll> ret = {node, dist};
    for(int next_node: tree[node]) {
        if(used[next_node]) continue;
        pair<int, ll> q = dfs_diameter(next_node, dist+1);
        if(ret.second < q.second) {
            ret = q;
        }
    }
    return ret;
}

ll calc_diameter() {
    pair<int, ll> u = dfs_diameter(0, 0);
    used = vector<int>(N_MAX, 0);
    return dfs_diameter(u.first, 0).second;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int x, y;
    cin >> n;
    for(int i=0;i<n-1;++i) {
        cin >> x >> y;
        --x; --y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }

    int diameter = calc_diameter();
    if(diameter < 3) {
        cout << 1;
        for(int i=1;i<n;++i) cout << " " << i+1;
        cout << endl;
        return 0;
    }

    dfs(0, -1, 1);

    int j[3] = {1, 0, 0};
    if(cnt[1] >= (n+2)/3) {
        if(cnt[2] >= (n+1)/3) {
            for(int i=0;i<n;++i) {
                if(i) cout << " ";
                if(j[color[i]] * 3 + color[i] <= n) {
                    cout << j[color[i]]++*3 + color[i];
                } else {
                    cout << j[0]++*3;
                }
            }
        } else {
            for(int i=0;i<n;++i) {
                if(i) cout << " ";
                if(color[i] == 2) {
                    cout << j[0]++*3;
                } else if(j[1]*3 + 1 <= n) {
                    cout << j[1]++*3 + 1;
                } else if(j[2]*3 + 2 <= n) {
                    cout << j[2]++*3 + 2;
                } else {
                    cout << j[0]++*3;
                }
            }
        }
    } else {
        for(int i=0;i<n;++i) {
            if(i) cout << " ";
            if(color[i] == 1) {
                cout << j[0]++*3;
            } else if(j[1]*3 + 1 <= n) {
                cout << j[1]++*3 + 1;
            } else if(j[2]*3 + 2 <= n) {
                cout << j[2]++*3 + 2;
            } else {
                cout << j[0]++*3;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 19440
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m=map(int,input().split())

ans=0
# print(g1[:5])
# print(g2[:5])
for i in range(n+1):
    onaji=g1[m]*g2[m-i]%mod
    tigau=(g1[m-i]*g2[m-n]%mod)**2%mod
    # print(cmb(n,i),((-1)**i),onaji,tigau)
    ans+=cmb(n,i)*((-1)**i)*onaji*tigau
    ans%=mod
print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int A, B; cin >> A >> B;
  for (int C = 1; C < 4; C++) {
    if ((A * B * C) % 2) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}


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

using namespace std;

struct bulb {
    int *light_connected;
    int k;
};

int dfs(int i, int n, int m, bool *p, bool *lights, bulb *bulbs);

int main() {
    int n, m, k;
    cin >> n >> m;
    bulb *bulbs = new bulb[m];
    bool *lights = new bool[n];
    bool *p = new bool[m];
    memset(lights, 0, sizeof(bool) * n);
    for (int i = 0; i < m; ++i) {
        cin >> bulbs[i].k;
        bulbs[i].light_connected = new int[bulbs[i].k];
        for (int j = 0; j < bulbs[i].k; ++j) {
            cin >> bulbs[i].light_connected[j];
            --bulbs[i].light_connected[j];
        }
    }
    for (int i = 0; i < m; ++i) {
        cin >> k;
        p[i] = k & 1;
    }
    cout << dfs(0, n, m, p, lights, bulbs) << endl;
    return 0;
}

int dfs(int i, int n, int m, bool *p, bool *lights, bulb *bulbs) {
    int result = 0;
    if (i == n) {
        cout << endl;
        bool flag = true;
        for (int i = 0; i < m; ++i) {
            int k = 0;
            for (int j = 0; j < bulbs[i].k; ++j)
                k += lights[bulbs[i].light_connected[j]];
            if ((k & 1) ^ p[i])
                flag = false;
        }
        if (flag)
            ++result;
        return result;
    }
    lights[i] = false;
    result += dfs(i + 1, n, m, p, lights, bulbs);
    lights[i] = true;
    result += dfs(i + 1, n, m, p, lights, bulbs);
    return result;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SIZE 200005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
struct UF
{
	int par[SIZE],rank[SIZE];
	int sz[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=1;
			sz[i]=-1;
		}
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	int get(int v)
	{
		return sz[find(v)];
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y)
		{
			sz[x]++;
			return;
		}
		if(rank[x]<rank[y])
		{
			par[x]=y;
			sz[y]+=sz[x];
			sz[y]++;
		}
		else
		{
			par[y]=x;
			sz[x]+=sz[y];
			sz[x]++;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
}uf;
vector <PP> edge;
bool use[SIZE];
 
int main()
{
	int n,h,w;
	scanf("%d %d %d",&n,&h,&w);
	for(int i=0;i<n;i++)
	{
		int r,c,a;
		scanf("%d %d %d",&r,&c,&a);r--,c--;
		edge.push_back(PP(a,P(r,c+h)));
	}
	sort(edge.begin(),edge.end(),greater<PP>());
	uf.init(h+w+2);
	ll ret=0;
	for(int i=0;i<edge.size();i++)
	{
		P p=edge[i].second;
		int a=uf.get(p.first),b=uf.get(p.second);
		if(a+b+1<=0)
		{
			uf.unite(p.first,p.second);
			ret+=edge[i].first;
			use[i]=true;
			//printf("* %d %d : %d\n",p.first,p.second,edge[i].first);
		}
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 3956
const lines=readlines(open("/dev/fd/0"))
input()::String=shift!(lines)
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function nextLine(k::Int32)
    x,y,c=split(input())
    intSub(x)%2k+1,(intSub(y)+(c=="W")k)%2k+1
end
function main()
    n,k=intLine()
    g=Array{Int32,1}[[0for j in 1:2k]for i in 1:2k]
    for i in 1:n
        x,y=nextLine(k)
        g[x][y]+=1
    end
    g=cumsum(map(cumsum,g))
    m=0
    for i in 1:2k
        for j in 1:2k
            a=0
            for x in -2:2
                for y in -2:2
                    if (x+y)%2!=0;continue;end
                    v,w=i+x*k,j+y*k
                    if v>0<w;a+=g[min(2k,v)][min(2k,w)];end
                    if v>k&&w>0;a-=g[min(2k,v-k)][min(2k,w)];end
                    if w>k&&v>0;a-=g[min(2k,v)][min(2k,w-k)];end
                    if v>k<w;a+=g[min(2k,v-k)][min(2k,w-k)];end
                end
            end
            m=max(m,a)
        end
    end
    println(m)
end
main()

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

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		double x1,y1,x2,y2,x3,y3;
		scanf(" %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		double dx=x1, dy=y1; //平行移動
		x1-=dx; x2-=dx; x3-=dx;
		y1-=dy; y2-=dy; y3-=dy;
		
		double ansx, ansy;
		
		if(y2==0){
			ansx = x2/2.0;
			double b3= x3*x3/y3/2.0 + y3/2.0;
			ansy = -x3*ansx/y3+b3;			
		}
		else if(y3==0){
			ansx = x3/2.0;
			double b2= x2*x2/y2/2.0 + y2/2.0;
			ansy = -x2*ansx/y2+b2; 
		}
		else{
			double b2= x2*x2/y2/2.0 + y2/2.0;
			double b3= x3*x3/y3/2.0 + y3/2.0;

			ansx = (b2-b3)*y2*y3/(x2*y3-x3*y2);
			ansy = -x2*ansx/y2+b2; 			
		}
		
		double r=sqrt(ansx*ansx + ansy*ansy);
		//printf("r=%lf\n", r);
		r*=1000;
		r=round(r);
		r/=1000;
		
		printf("%.3lf %.3lf %.3lf\n", ansx+dx, ansy+dy, r);
		
	}	
}

Measured memory_bytes: 1260
N, M = map(int, input().split())
H = list(map(int, input().split()))
isHighest = [True] * N
for i in range(M):
    a, b = map(int, input().split())
    if (H[a-1] <= H[b-1]):
        isHighest[a-1] = False
    if (H[a-1] >= H[b-1]):
        isHighest[b-1] = False

ans = 0
for i in range(N):
    if (isHighest[i]):
        ans += 1

print(ans)

Measured memory_bytes: 20044
h,n = list(map(int,input().split()))
inf = 100000000000000000000
dp = [inf]*(2*100000)
for i in range(-1,-100000,-1):
    dp[i] = 0
ls = [0]*n
for i in range(n):
    ls[i] = list(map(int,input().split()))
dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[i+1] = min(dp[i+1],dp[i+1-ls[j][0]]+ls[j][1])
print(dp[h])

Measured memory_bytes: 45968
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = do
  [n, m] <- f
  solve m <$> (sort <$> replicateM n f) >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: Int -> [[Int]] -> Int
solve m abs = f 0 m abs
  where
    f tm 0 _ = tm
    f tm nd ([a, b]:xs) = let n = min nd b
                          in f (tm + a * n) (nd - n) xs

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


Measured memory_bytes: 51580
import java.util.Scanner;

//Ben Toh
public class Main{
	
	void run(){
		double EPS = 1e-13;
		double[] res = new double[100001];
		res[1] = 1;
		for(int n=2;n<=100000;n++){
			double p = 1, win = 0.5;
			int k = 1;
			while(EPS<p && k<n){
				double not = p*(1-win);
				res[n] += not*(k+res[Math.max(0, n-k-1)]);
				p*=win; win/=2; k++;
			}
			res[n]+=n*p;
//			System.out.printf("%.8f\n", res[n]);
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			System.out.printf("%.8f\n", res[n]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(void){
  char str[300],*s,*t;
  
  fgets(str,sizeof(str),stdin);
  s=strtok(str," ");
  t=strtok(NULL,"\n");
  
  printf("%s%s\n",t,s);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int N, M, D;
char S[110][110];

int main()
{
	scanf("%d%d%d", &N, &M, &D);
	for (int i = 0; i < N; ++i) {
		scanf("%s", S[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= M - D; ++j) {
			bool isok = true;
			for (int k = 0; k < D; ++k) {
				if (S[i][j + k] == '#') isok = false;
			}
			if (isok) ++ans;
		}
	}
	for (int i = 0; i <= N - D; ++i) {
		for (int j = 0; j < M; ++j) {
			bool isok = true;
			for (int k = 0; k < D; ++k) {
				if (S[i + k][j] == '#') isok = false;
			}
			if (isok) ++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

template<typename T>
struct CumSum{
private:
  size_t size;
  vector<T> data;
public:
  CumSum(vector<T> dat){
    size = dat.size();
    data.resize(size+1,0);
    for(size_t i = 0; i < size; ++i)
      data[i+1] = data[i] + dat[i];
  }
  T getsum(size_t l, size_t r){//0-indexed, [l,r)
    return data[r] - data[l];
  }
  T getsum(size_t r){//0-indexed, [0,r)
    return data[r];
  }
};

int main(){
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];

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

  auto cnt = [&](long long m) -> long long {
               long long ret = 0;
               for(int i = 0; i < N; ++i){
                 long long r = m-A[i];
                 ret += A.end() - lower_bound(A.begin(), A.end(),r);
               }
               return ret;
             };
  
  long long ok = 0, ng = 1e12;

  while(ng-ok > 1){
    long long m = (ok+ng)/2;
    if(cnt(m) >= M) ok = m;
    else ng = m;
  }

  cerr << ok << endl;
  cerr << cnt(ok) << endl;
  cerr << cnt(ng) << endl;
  
  CumSum<long long> cs(A);
  long long ans = 0;

  for(int i = 0; i < N; ++i){
    long long r = ok-A[i];
    int idx = lower_bound(A.begin(), A.end(), r) - A.begin();
    ans += cs.getsum(idx,N);
    ans += A[i]*(N-idx);
  }

  ans -= (cnt(ok)-M)*ok;
  cout << ans << endl;
}


Measured memory_bytes: 2560
local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local n = io.read("*n")
local d = {}
local mlen = 0
local mma = math.max
for i = 1, n do
  d[i] = io.read("*n")
  mlen = mma(mlen, d[i])
end
local valid = true
if d[1] ~= 0 then
  valid = false
end
for i = 2, n do
  if d[i] == 0 then
    valid = false
  end
end
local t = {}
for i = 1, mlen do
  t[i] = 0
end
if valid then
  for i = 2, n do
    t[d[i]] = t[d[i]] + 1
  end
end
for i = 1, mlen do
  if t[i] == 0 then
    valid = false
  end
end
if not valid then
  print(0)
else
  local ret = 1
  for i = 2, mlen do
    local v = modpow(t[i - 1], t[i])
    ret = bmul(ret, v)
  end
  print(ret)
end


Measured memory_bytes: 2304
#include <stdio.h>
#define N 500000
#define MAX 2000000000
 
void merge(int[], int, int, int);
void mergeSort(int[], int, int);
 
int L[(N/2)+2],R[(N/2)+2];
int count;
 
 
int main(){
 
  int i, n, A[N];
  count = 0;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
 
  mergeSort(A, 0, n);
 
  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i == n-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
 
  printf("%d\n",count);
 
  return 0;
}
 
 
void merge(int A[], int left, int mid, int right){
  int n1,n2,i,j,k;
   
  n1 = mid - left;
  n2 = right - mid;
   
  for(i = 0; i <= n1; i++)
    L[i] = A[left+i];
  for(i = 0; i<= n2; i++)
    R[i] = A[mid+i];
 
   L[n1] = MAX;
   R[n2] = MAX;
 
    i = 0;
    j = 0;
    for(k = left;k < right; k++){
      count++;
      if(L[i] <= R[j]){
    A[k] = L[i];
    i = i + 1;
      }
      else{
    A[k] = R[j];
    j = j + 1;
      }
    }
 
}
 
void mergeSort(int A[], int left, int right){
  int mid;
 
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4508
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N,K = 0;
  int A = 1;
  cin >> N >> K;
  
  rep(i,N){
    if(A<K)
      A *= 2;
    else
      A += K;
  }
  cout << A << endl;
}

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

// semi-open   Range minimum query

struct RmQ{
  int n=(1<<17),data[(1<<18)];
  RmQ(){
    fill(data,data+(1<<18),INT_MAX);
  }
  void update(int k,int x){
    k+=n-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k]=min(data[k*2+1],data[k*2+2]);
    }
  }
  int find(int a,int b,int k=0,int l=0,int r=(1<<17)){
    if(r<=a || b<=l)return INT_MAX;
    if(a<=l && r<=b)return data[k];
    int v1=find(a,b,k*2+1,l,(l+r)/2);
    int v2=find(a,b,k*2+2,(l+r)/2,r);
    return min(v1,v2);
  }
};


int main(){
  RmQ a;
  int c,x,y,n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<a.find(x,y+1)<<endl;
    else a.update(x,y);
  }
}


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

int main()
{
	string s, t;
	cin >> s;
	cin >> t;

	int ret = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) {
			++ret;
		}
	}
	cout << ret << endl;

	return 0;
}

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

int main() {
  int a;
  cin >> a;
  int s = a / 500;
  int b = a % 500;
  int t = b / 5;

  int happy;
  happy = s * 1000 + t * 5;

  cout << happy << endl;
}


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

using namespace std;

int main() {
	int n;

	cin >> n;

	double x[n] = { 0.0 };
	double y[n] = { 0.0 };
	double D = 0.0;
	double temp = 0.0;
	double prev = 0.0;

	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n; i++)
		cin >> y[i];

	for (int i = 0; i < n; i++) {
		D += abs(x[i] - y[i]);
	}
	cout << fixed << setprecision(8) << D << endl;

	D = 0.0;
	for (int i = 0; i < n; i++) {
		D += pow(abs(x[i] - y[i]), 2.0);
	}
	D = sqrt(D);
	cout << fixed << setprecision(8) << D << endl;

	D = 0.0;
	for (int i = 0; i < n; i++) {
		D += pow(abs(x[i] - y[i]), 3.0);
	}
	D = pow(D, 1.0 / 3.0);

	cout << fixed << setprecision(8) << D << endl;

	D = 0.0;
	for (int i = 0; i < n; i++) {
		temp = abs(x[i] - y[i]);
		if (temp > prev) {
			D = temp;
			prev = temp;
		}
		
	}

	cout << fixed << setprecision(8) << D << endl;
}


Measured memory_bytes: 3452