akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;

int main(){
    cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1) << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int result = 1;

        if (K == 1) {
            System.out.println(N);
        } else {
            for (int i=1; i <=N-1; i++){
                result *= K-1; 
            }
            System.out.println(K * result);
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n;

signed main() {
	cin >> n;
	cout << !n;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
    cin >> s;
    int papers = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'p') papers++;
    }
    int could=s.size()/2;
    cout << could-papers;
}


Measured memory_bytes: 512
import sys
import math
from collections import deque
import heapq as hq

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, M = NMI()
    C = [[0, 0, 0]] + [[i+1]+NLI() for i in range(M)]
    D = {i: [] for i in range(N+1)}
    names = {}
    for c in C[1:]:
        D[c[1]].append([c[2], c[0]])
    for p, YI in D.items():
        YI.sort()
        t = 1
        for y, i in YI:
            names[i] = str(p).zfill(6) + str(t).zfill(6)
            t += 1
    for i in range(1, M+1):
        print(names[i])



if __name__ == "__main__":
    main()

Measured memory_bytes: 71212
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let n = s.trim();
    assert_eq!(n.len(), 3);
    writeln!(output, "{}", if n[0..1] == n[2..3] { "Yes" } else { "No" }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test("575\n", "Yes\n");
    }
    #[test]
    fn case2() {
        test("123\n", "No\n");
    }
    #[test]
    fn case3() {
        test("812\n", "No\n");
    }
}


Measured memory_bytes: 4352
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 1e5 + 5;

int n, m;
char s[N];

int dp[N], pre[N];

int main() {
    scanf("%d%d%s", &n, &m, s);

    static int que[N];
    int ql = 0, qr = 0;
    dp[n] = 0;
    que[qr] = n;

    for (int i = n - 1; i >= 0; --i) {
        while (ql <= qr && que[ql] > i + m) {
            ++ql;
        }
        if (s[i] == '1' || ql > qr) {
            dp[i] = -1;
            continue;
        }
        pre[i] = que[ql] - i;
        dp[i] = dp[que[ql]] + 1;
        while (ql <= qr && dp[i] <= dp[que[qr]]) {
            --qr;
        }
        que[++qr] = i;
        // cerr << i << ' ' << dp[i] << '\n';
    }

    if (~dp[0]) {
        for (int i = 0; i < n; ) {
            printf("%d ", pre[i]);
            i += pre[i];
        }
    } else {
        puts("-1");
    }

    return 0;
}


Measured memory_bytes: 1664
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
total = sum(S)
if total%10 != 0:
  print(total)
  exit()
else:
  for i in S:
    if i %10 != 0:
      print(total-i)
      exit()
print(0)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int ans=1;
	if(a[1]!=a[0])ans++;
	if(a[2]!=a[1])ans++;
	cout<<ans<<endl;
	return 0;
}

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

#define MIN(A,B) (A)<(B)?(A):(B)
#define MAX(A,B) (A)>(B)?(A):(B)

#define N 200000

int main(){
  long long int d;
  int n, a, b, c=0, i;
  int H[N]={0};
  scanf("%d", &n);
  d=(long long int)n*(n-1)/2;
  printf("%lld\n", d);
  return 0;
}


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

int main (){    
    int N, K;
    cin>>N>>K;
    int R, S, P;
    cin>>R>>S>>P;
    vector<char> T(N);
    ll Sum=0;
    bool t=true;
    for(int i=0; i<N; i++){
        cin>>T.at(i);
        if(i-K>=0){
            if(T[i]==T[i-K]){
                t=false;
              	T[i]='n';
            }
        }
        if(t){
            if(T.at(i)=='r')Sum += P;
            if(T.at(i)=='s')Sum += R;
            if(T.at(i)=='p')Sum += S;
        }
		t=true;
    }
    cout<<Sum;
}



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

using namespace std;

int main() {
    vector<int> A(5);
    for (auto &a: A) cin >> a;

    int mi = 10, sum = 0;
    for (const auto &a: A){
        sum += (a + 9) / 10 * 10;
        if (a % 10 != 0)
            mi = min(mi, a % 10);
    }

    cout << sum + mi - 10 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int> > cnt(h, vector<int>(w));
    //横方向
    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if (s[i][j] == '#') continue;
            if (done[j]) continue;
            //白マス
            int l = 0; //length
            while (j + l < w) {
                if (s[i][j + l] == '#') break;
                ++l;
            }
            rep(k, l) {
                cnt[i][j + k] += l;
                done[j + k] = 1;
            }
        }
    }
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if (s[i][j] == '#') continue;
            if (done[i]) continue;
            //白マス
            int l = 0; //length
            while (i + l < h) {
                if (s[i + l][j] == '#') break;
                ++l;
            }
            rep(k, l) {
                cnt[i + k][j] += l;
                done[i + k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) chmax(ans, cnt[i][j] - 1);
    cout << ans << endl;
}


Measured memory_bytes: 20096
countResultList = []
index = 0
inStrNum = 0
inStrLowList = []
inStr = str()
sample = 0
try:
    while True:
        sample +=1
        if inStrNum < 10 or sample < 1200:
            inStr = input()
            inStrLowList.append(inStr.lower())
            inStrNum += len(inStr)
        else:
            break
except EOFError:
    pass
inStrLow = str(inStrLowList)
for alphabet in range(ord("a"),ord("z")+1):
    countResultList.append(inStrLow.count(chr(alphabet)))
    index += 1
indexOrder = 0
for alphabet in range(ord("a"),ord("z")+1):
    print("%s : %s"%(chr(alphabet),countResultList[indexOrder]))
    indexOrder += 1


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
   if ((A+B)>(C+D)){
 cout << "Left" <<endl;
 }
   else if ((A+B)==(C+D)){
 cout << "Balanced" <<endl;
 }
   else {
 cout << "Right" <<endl;
 }
}

Measured memory_bytes: 256
//at abc120d
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;
inline ll read() {
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=1e5+5;
int n,m,fa[MAXN];
struct EDGE {
	int u,v;
}e[MAXN];
ll ans[MAXN],sz[MAXN];
int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);/*syn加速*/
	n=read();m=read();
	for(int i=1;i<=m;++i) {
		e[i].u=read(); e[i].v=read();
	}
	for(int i=1;i<=n;++i) fa[i]=i,sz[i]=1;
	ans[m]=(ll)n*(n-1)/2;
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	for(int i=1;i<=m;++i) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
n=int(input())
l=[]
l1=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l1=l1[::-1]
  l.append(l1)      
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for k in range(n-1):
      if max(h-abs(i-l[-2-k][2])-abs(j-l[-2-k][1]),0)!=l[-2-k][0]:
        b=False
    if b:
      print(i,j,h)
      break

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string[] a = Console.ReadLine().Split();
        if (a[0][0] > a[1][0]) { Console.WriteLine(">"); }
        else if (a[0][0] == a[1][0]) { Console.WriteLine("="); }
        else { Console.WriteLine("<"); }
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 5005;
int pw[maxN];
int n;
int p[maxN];
vector < int > g[maxN];
bool used[maxN];
int par[maxN];
int sz[maxN];
void dfs(int v) {
    used[v] = true;
    sz[v] = 1;
    for (int to : g[v]) {
        if (!used[to]) {
            par[to] = par[v];
            dfs(to);
            sz[v] += sz[to];
        }
    }
}
int d[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    int k = 0;
    vector < int > id;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        if (p[i] != -1) {
            g[p[i]].emplace_back(i);
            g[i].emplace_back(p[i]);
        }
        else {
            k++;
            id.emplace_back(i);
        }
    }
    int c = 0;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            par[i] = i;
            dfs(i);
            c++;
        }
    }
    pw[0] = 1;
    for (int i = 1; i <= n; i++) pw[i] = mult(pw[i - 1], n - 1);
    int ans = mult(pw[k], n);
    int cycles = c - k;
    ans = sub(ans, mult(cycles, pw[k]));
    d[0][0] = 1;
    for (int i = 0; i < id.size(); i++) {
        int cur_sz = sz[par[id[i]]];
        ans = sub(ans, mult(pw[k - 1], (cur_sz - 1)));
        for (int was = 0; was <= i; was++) {
            d[i + 1][was] = sum(d[i + 1][was], d[i][was]);
            d[i + 1][was + 1] = sum(d[i + 1][was + 1], mult(d[i][was], cur_sz));
        }
    }
    int fct = 1;
    for (int i = 2; i <= k; i++) {
        fct = mult(fct, i - 1);
        int R = d[k][i];
        R = mult(R, fct);
        ans = sub(ans, mult(pw[k - i], R));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 70688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

int main() {
    IN(string, s);
    Yes((s[0]=='7')||(s[1]=='7')||(s[2]=='7'));
}




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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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

    int n;
    cin >> n;
    vector<int> arr(n);
    int ans = 0;

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

    int i = 0;
    int j = 1;

    while (i < n) {
        while (j < n && arr[j] <= arr[j-1]) j++;
        ans = max(ans, j - i - 1);
        i = j;
        j = i+1;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll N; cin>>N;
  rep(i,N){
    char S; cin>>S;
    if(S=='Y') {cout<<"Four"<<endl; return 0;}
  }
  cout<<"Three"<<endl;
  return 0;
}


Measured memory_bytes: 3508
import Control.Applicative

main = do
  getLine
  input <- map read . lines <$> getContents
  putStrLn $ show $ fst $ solve input

solve :: [Int] -> (Int,Int)
solve (a:b:[]) = (b - a, max a b)
solve (x:xs) = (max profit (maxv - x), max maxv x)
  where (profit, maxv) = solve xs



Measured memory_bytes: 155144
import sys
S = input()

if (len(S)%2 == 0):
    print('No')
    sys.exit()

N1 = int((len(S)-1) / 2)
N3 = int((len(S)+3) / 2)

sl = []
nl = []
for i in range(N1):
    sl.append(S[i])

for j in range(N3-1, len(S)):
    nl.append(S[j])

moji1= ''
for x in sl:
    moji1 = moji1+ x

moji2 = ''
for x in nl:
    moji2 = moji2 + x

remoji1 = list(reversed(moji1))
remoji2 = list(reversed(moji2))

res = list(reversed(S))

if moji1 == ''.join(remoji1) and moji2 == ''.join(remoji2) and S == ''.join(res):
    print('Yes')
else:
    print('No')

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

 int main(){
     int n;
     cin >>n;
    // cout << n << endl;
     int ans=0;
     rep(i,n){
       //  cout << ans << endl;

         if(n%i==0){
             ans+=n/i-1;
         }
         else{
             ans+=n/i;
         }
     }
     cout << ans << endl;
     return 0;
 }


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

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

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

int main() {
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;

    ll c500 = 0;
    ll c5 = 0;

    c500 = n / 500;
    n = n - c500 * 500;
    c5 = n / 5;

    cout << c500 * 1000 + c5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
MOD = 1_000_000_007
io = STDIN
N,M=io.gets.split.map(&:to_i)
ar=M.times.map{io.gets.to_i}
fl=Array.new(N+1,0)
fl.unshift(1)
fl.unshift(0)
ar.each {|i|fl[i+1]=nil}
(2..N+1).each do |i|
  next if  fl[i]==nil
  fl[i]+=(fl[i-1])%MOD if fl[i-1]!=nil
  fl[i]+=(fl[i-2])%MOD if fl[i-2]!=nil
end
p fl[N+1]%MOD


Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  
  int n, k;
  long long int ans=0;
  vector<int> h;

  cin>> n >> k;

  h.resize(n);
  
  for(int i=0;i<n;i++) cin>> h[i];
  
  sort(h.begin(), h.end());
  
  for(int i=0;i<n-k;i++) ans+=h[i];
  
  cout<< ans <<endl;

  return 0;
}


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



int main(){
    string s;cin>>s;
    int ok=1;
    ll n=s.size();
    rep(i,0,n/2){
        if(s[i]!=s[n-1-i])ok=0;
    }
    rep(i,0,n/2/2){
        if(s[i]!=s[n/2-1-i])ok=0;
    }
    rep(i,n/2+1,n){
        if(s[i]!=s[n-1-i])ok=0;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define mod 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=16,MAX=(ll)-1e15 ;
ll dp[(1<<N)] ;
ll cost[(1<<N)] ;
ll n ;
ll a[N][N] ;
ll fun(ll i)
{
    if(i==0) return 0 ;
    else if(dp[i]!=MAX) return dp[i] ;
    else
    {
        ll mask=i ;
        ll f=0 ;
        ll ans=MAX ;
        while(mask>0)
        {
            ans=max(ans,cost[mask]+fun(i-mask)) ;
            mask=i&(mask-1) ;
        }
        return dp[i]=ans ;
    }
}
int main()
{
    fast ;
    cin>>n ;
    for(ll i=0;i<n;i++) for(ll j=0;j<n;j++) cin>>a[i][j] ;

    for(ll i=0;i<(1<<n);i++) dp[i]=MAX ;

    memset(cost,0,sizeof(cost)) ;

    for(ll mask=0;mask<(1<<n);mask++)
    {
        vector<ll>v ;
        for(ll j=0;j<n;j++)
        {
            ll bit=mask&(1<<j) ;

            if(bit) v.push_back(j) ;
        }
        cost[mask]=0 ;
        for(ll j=0;j<v.size();j++)
        {
            for(ll k=j+1;k<v.size();k++)
            {
                cost[mask]+=a[v[j]][v[k]] ;
            }
        }
    }

    cout<<fun((1<<n)-1) ;






}



Measured memory_bytes: 4680
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  int a,b,q,r;
  int ans[N];

  for(i=0;
      scanf("%d%d",&a,&b)==2;
      i++){
    for(;;){
      r=a%b;
      if(r==0){
        ans[i]=b;
        break;
      }else{
        a=b;
        b=r;
      }
    }
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
	return 0;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const lf pi=acos(-1.0);
const int maxn=305;
char s[maxn];
int n,m;
int dp[maxn][maxn][maxn];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1),m=read();
	REP(i,0,n)
		REP(j,0,n-i+1)
			REP(k,0,m){
				if(i>=1)chkmax(dp[i][j][k],dp[i-1][j][k]);
				if(j>=1)chkmax(dp[i][j][k],dp[i][j-1][k]);
				if((i>=1)&&(j>=1)){
					if(s[i]==s[n-j+1])
						chkmax(dp[i][j][k],dp[i-1][j-1][k]+2-((i+j==n+1)&&(i==n-j+1)));
					else if(k>=1)
						chkmax(dp[i][j][k],dp[i-1][j-1][k-1]+2-((i+j!=n+1)&&(i==n-j+1)));
				}
			}
	int ans=0;
	REP(i,1,n)
		chkmax(ans,dp[i][n-i+1][m]);
	write(ans,'\n');
	return 0;
}

Measured memory_bytes: 110592
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

const int MAX = 200000;


vll prime(ll n) {
    vll ans;
    vbool ls(n+1, true);
    ls[0] = false;
    ls[1] = false;
    srep(i, 2, n+1) {
        if (ls[i]) {
            ans.push_back(i);
            ll j = i*2;
            while (j <= n) {
                ls[j] = false;
                j += i;
            }
        }
    }
    return ans;
}

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

    vll ls = prime(MAX);

    for (auto p : ls) {
        if (p >= x) {
            cout << p << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    ll x = abs(a-b);
    ll y = abs(c-d);
    if((n-1)*c <= x && x <= (n-1)*d)
    {
        cout << "YES" << endl;
        return 0;
    }
    for(int i = 1; i <= (n-1)/2; i++)
    {
        if((n-1-i)*c - i*d <= x && (n-1-i)*d - i*c >= x)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    if(n % 2 == 1)
    {
        if(x <= y * (n-1) / 2)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


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

int main() {
  int x;
  cin >> x;
  int mx = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 2; j <= 10; j++) {
      int t = pow(i, j);
      if (t > x) break; 
      mx = max(mx, t);
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 3992
#include<iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,k,t,r;
	while(cin>>n,cin>>k)
	{
		t=n/k;
		r=n-t*k;
		if(r!=0)
		   cout<<1<<endl;
		else
		   cout<<0<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int INF=(1<<29);
  int a[110],b[110],n,w,i,j,dp[110][10010];
  scanf("%d %d\n",&n,&w);
  for(i=1;i<=n;i++){
    scanf("%d %d\n",&a[i],&b[i]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=w;j++){
      dp[i][j]=-INF;
    }
  }
  dp[0][0]=0;
  for(i=1;i<=n;i++){
    for(j=0;j<=w;j++){
      if(j-b[i]>=0){
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i]]+a[i]);
      }
      else{
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  int ans=0;
  for(i=0;i<=w;i++){
    ans=max(ans,dp[n][i]);
  }
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;

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

struct MaxFlow {
  struct Edge {int to, cap, rev;};

  const static int INF = 1e9;

  int v;
  vector<vector<Edge> > g;
  vector<int> level, iter;

  MaxFlow() : v(0) {}

  int next() {
    g.push_back(vector<Edge>());
    level.push_back(0);
    iter.push_back(0);
    return v++;
  }
  
  void add_edge(int from, int to, int cap) {
    g[from].push_back((Edge){to, cap, int(g[to].size())});
    g[to].push_back((Edge){from, cap, int(g[from].size()) - 1});
  }

  void bfs(int s) {
    fill(level.begin(), level.end(), -1);
    level[s] = 0;
    queue<int> que;
    que.push(s);
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      rep (i, g[v].size()) {
	Edge &e = g[v][i];
	if (e.cap == 0 || level[e.to] >= 0) continue;
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }

  int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < int(g[v].size()); ++i) {
      Edge &e = g[v][i];
      if (e.cap == 0 || level[v] >= level[e.to]) continue;
      int d = dfs(e.to, t, min(f, e.cap));
      if (d == 0) continue;
      e.cap -= d;
      g[e.to][e.rev].cap += d;
      return d;
    }
    return 0;
  }

  int run(int s, int t) {
    int flow = 0, f;
    while (true) {
      bfs(s);
      if (level[t] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      while ((f = dfs(s, t, INF)) > 0) flow += f;
    }
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  MaxFlow mf;
  rep (i, n) mf.next();
  vector<pair<int, int> > edge;
  rep (i, m) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    mf.add_edge(x, y, 1);
    edge.push_back(make_pair(x, y));
  }
  int s, t;
  cin >> s >> t;
  --s; --t;
  cout << mf.run(s, t) << endl;
  vector<int> res;
  rep (i, m) {
    bool found = false;
    rep (j, mf.g[edge[i].second].size()) if (mf.g[edge[i].second][j].to == edge[i].first && mf.g[edge[i].second][j].cap == 0) found = true;
    if (found) res.push_back(i + 1);
  }
  cout << res.size() << endl;
  rep (i, res.size()) cout << res[i] << endl;
}

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

int main(){
	int k,n;
	cin>>k;cin>>n;
	int arr[n];
// 	vector<int, int> temp(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	int half = k/2;
	int max_diff = 0;
	pair<int, int> temp;
	for(int i = 1; i < n; i++){
		if(arr[i] - arr[i-1] > max_diff){
			max_diff = arr[i] - arr[i-1];
			temp.first = arr[i-1];
			temp.second = arr[i];
		}
	}
	//cout<<max_diff;
	if(k - arr[n-1] + arr[0] > max_diff){
		max_diff = k - arr[n-1] + arr[0];
		temp.first = arr[n-1];
		temp.second = arr[0];
	}
	int ans = k - max_diff;
	cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	int sx = 0;
	for(int i=0;i<n;i++)
	{	
		cin>>ar[i];
		sx += ar[i];
	}
	int tt = 0;
	for(int i=0;i<n;i++)
	tt += ar[i] * (sx - ar[i]);
	tt >>= 1;
	cout<<tt<<"\n";
	return;		
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	int M;
	cin >> N;
	cin >> M;

	long long ans = N * (N - 1) / 2 + M * (M - 1) / 2;

	cout << ans << endl;

	return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n; cin>>n;
    vi ar(n+1);
    rep(i,1,n+1) cin>>ar[i];
    int cnt = 0;
    rep(i,1,n+1) {
        if(ar[i] != i) cnt++;
    }
    if(cnt <= 2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



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

int main() {
  int N;
  cin >> N;
  int a[N+1];
  memset(a,0,sizeof(a));
  for (int j=1; j<=N; j++) {
    int k=j;
    for (int i=2; k>1; ) {
      if (k%i==0) {
        k/=i;
        a[i]++;
      } else {
        i++;
      }
    }
  }
  const int mod=1e9+7;
  long long int ans=1;
  for (int i=2; i<=N; i++) {
    ans=ans*(a[i]+1)%mod;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
#define M 1000000007

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n; cin >> n;
    long long c[n]; for (int i = 0; i < n; i++) cin >> c[i];
    sort(c, c+n, greater<int>());
    long long ans = 0;
    for (int i = 0; i < n; i++)
        ans += (i + 2) * c[i] % M;
    cout << ans % M * modexp(2, 2*n-2, M) % M << endl;
}


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

int main(){
  
  for(int i=1;;i++){
    int x;
    cin>>x;
    if(x == 0) break;
    cout<<"Case "<<i<<": "<<x<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3084
//17:30
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

int a[3];
int main(){
        scanf("%d %d %d",a+0,a+1,a+2);
        sort(a,a+3);

        printf("%d\n",a[2]*10+a[1]+a[0]);
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}


const int mod = 998244353;
const int inf = 1'000'000'007;


int power(int x, int y) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

void solve() {
  int n, a, b;
  ll k;
  cin >> n >> a >> b >> k;

  vector<int> f(n + 1), rf(n + 1);
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i] = f[i - 1] * 1ll * i % mod;
  }
  rf[n] = power(f[n], mod - 2);
  for (int i = n - 1; i >= 0; --i) {
    rf[i] = rf[i + 1] * 1ll * (i + 1) % mod;
  }

  auto cnk = [&](int n, int k) {
    if (n < k) {
      return 0ll;
    }
    return (f[n] * 1ll * rf[n - k] % mod) * rf[k] % mod;
  };

  int ans = 0;
  for (int rc = 0; rc <= n; ++rc) {
    ll rem = k - a * 1ll * rc;
    if (rem < 0 || rem % b != 0 || rem / b > n) {
      continue;
    }
    int bc = rem / b;
    if (bc > n) {
      continue;
    }
    (ans += (cnk(n, rc) * cnk(n, bc) % mod)) %= mod;
  }
  cout << ans << "\n";
}

int main() {
  #ifndef LOCAL58
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while(t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 5556
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String sa = scan.next();
        String sb = scan.next();
        int a = new Integer(sa);
        int b = new Integer(sb);
        
        String result=compare(a,b);
        System.out.println(result);
    }
    
    public static String compare(int a, int b){
        String result = "";
        if(a>b) result = "a > b";
        if(a<b) result = "a < b";
        if(a==b) result = "a == b";
        return result;
    }
    
}

Measured memory_bytes: 17308
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int x0 = tmp[0], y0 = tmp[1];
        tmp = ReadIntArray();
        int x1 = tmp[0] - x0, y1 = tmp[1] - y0;
        tmp = ReadIntArray();
        int x2 = tmp[0] - x0, y2 = tmp[1] - y0;

        double s = Math.Abs(x1*y2 - y1*x2) / 2.0;

        double a = Math.Sqrt(x1*x1 + y1*y1);
        double b = Math.Sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
        double c = Math.Sqrt(x2*x2 + y2*y2);

        double r = 2 * s / (a + b + c);

        double m = Math.Max(Math.Max(a, b), c);
        double x = m * r / (2*r + m);

        WriteLine(x);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

const int N = 2999;
long double h[N], t[N], p[N], dp[N + 1][N + 1];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        if (i == 0)
        {
            h[i] = p[i], t[i] = 1.0 - p[i];
        }
        else
        {
            h[i] = h[i - 1] * p[i], t[i] = t[i - 1] * (1.0 - p[i]);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)  
        {
            if (j > i)
                dp[i][j] = 0;
            else if (i == j)
                dp[i][j] = h[i - 1];
            else if (j == 0)
                dp[i][j] = t[i - 1];
            else
                dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1.0 - p[i - 1]) * dp[i - 1][j];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[n][i];
    cout << setprecision(9) << ans;
    return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline ll in() { ll x; cin >> x; return x; }

#define INIT (-1)
#define move(a,b) ((a == INIT && b != INIT) ? a = b : a = a)
int main() {
  int h = in(), w = in(), k = in(), ans[h][w];
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) ans[i][j] = (s[j] == '#' ? k-- : INIT);
  }
 
  rep(i,h-1)rep(j,w) move(ans[i+1][j], ans[i][j]); // 下へ
  drep(i,h-1)rep(j,w) move(ans[i][j], ans[i+1][j]); // 上へ
  rep(i,h)rep(j,w-1) move(ans[i][j+1], ans[i][j]); // 右へ
  rep(i,h)drep(j,w-1) move(ans[i][j], ans[i][j+1]); // left

  rep(i,h)rep(j,w) cout << ans[i][j] << (j==w-1 ? "\n" : " ");
}


Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
    int n, k, i, l;
    cin >> n >> k;

    vector<int> h(n);

    i = 0;
    while (cin >> l)
    {
        h[i] = l;
        i++;
        if (i >= n)
        {
            break;
        }
    }


    int cou = 0;
    for(i = 0; i < n; i++) {
        if(h[i] >= k) {
            cou++;
        }
    }

    cout << cou;

    return 0;
}

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

int main () {
    // for (初期設定文　条件式；再設定式）{ 実行文 }
    for (int i = 1; i <= 9; i++ ) {
        
        for (int j = 1; j <= 9; j++ )
            cout << i << "x" << j << "=" << i * j << endl;
   
    }
    return 0;
}



Measured memory_bytes: 3032
import qualified Data.ByteString.Char8 as B
import Data.Maybe

main :: IO ()
main = do
  n <- readB <$> B.getLine
  as <- map readB . B.words <$> B.getLine
  bs <- map readB . B.words <$> B.getLine
  print $ snd . solve $ zip as bs

readB :: B.ByteString -> Int
readB = fst . fromJust . B.readInt

solve :: [(Int, Int)] -> (Int, Int)
solve = foldl op (0, 0)

op :: (Int, Int) -> (Int, Int) -> (Int, Int)
op (a, b) (c, d) = (x, y)
  where
    x = a + c
    y = d + max b x


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

using namespace std;

int main(void)
{
	string str;
	cin >> str;

	bool isNone = false;
	string alpha("abcdefghijklmnopqrstuvwxyz");

	for(string::iterator it = str.begin(); it != str.end(); it++ )
	{
		for(string::iterator ita = alpha.begin(); ita != alpha.end(); ita++ )
		{
			if(*it == *ita)
			{
				alpha.erase(ita);
				if (alpha.size() == 0)
					isNone = true;
				break;
			}
		}
		if (isNone == true)
			break;
	}

	if (isNone != true)
		cout << alpha.at(0) << endl;
	else
		cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
A,B,C, K = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]

if A >= K:
    print(K)
elif A + B >= K:
    print(A)
else:
    print(A+(K-B-A)*-1)


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


def read():
    N, K = map(int, input().strip().split())
    X = list(map(int, input().strip().split()))
    return N, K, X


def solve(N, K, X):
    amin = 10**9
    for i in range(N-K+1):
        a0 = min(abs(X[i+K-1]), abs(X[i]))
        a1 = abs(X[i+K-1] - X[i])
        amin = min(amin, a0 + a1)
    return amin


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 14480
import Data.List

f::Int->Int->Int->Int->Int
f x c s fi
    |x<=s = (s-x)+c
    |(s-x) `mod` fi==0 = c
    |otherwise=(fi-((x-s) `mod` fi))+c

f3::[String]->[(Int,Int,Int)]
f3 []=[]
f3 (x:xs)=let (a:b:c:[])=map read (words x)::[Int]
          in (a,b,c):f3 xs

f2::Int->[(Int,Int,Int)]->Int
f2 ans []=ans
f2 ans ((ci,si,fi):xs) = f2 (ans+(f ans ci si fi)) xs

f4 :: [(Int,Int,Int)]->[Int]
f4 []=[0]
f4 (x:xs)=f2 0 (x:xs) : f4 xs

main = do
         e<-getLine
         es<-getContents
         mapM_ putStrLn $ map show $ f4 $ f3 (lines es)

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<pair<int,ll>> Prime;
    for(ll i = 2;i*i<=n;i++){
        int cnt = 0;
        while(n%i == 0 ){
            n/=i;
            cnt++;
        }
        if(cnt)Prime.push_back({cnt,i});
    }
    if(n>1)Prime.push_back({1,n});
    int ans = 0;
    for(auto x:Prime){
        for(int i=1;i<=x.first;i++){
            if(i<=x.first)ans++;
            x.first-=i;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll a[6];
	rep(i,1,6){
		cin>>a[i];
	}
	rep(i,1,6){
		if(a[i]==0){
			cout<<i;
			return 0;
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

vector<ll> fac(ll num)
{
	vector<ll> res(num+1, 0);
	ll tmp = num;

	for (ll i = 2; i <= num; ++i)
	{
		while (tmp%i == 0)
		{
			++res[i];
			tmp /= i;
		}
	}
	return res;
}

int main(int argc, char **argv)
{
	ll n; cin >> n;

	ll res{1};
	vector<ll> V(n+1, 0);

	for (ll i = 1; i <= n; ++i)
	{
		vector<ll> v{fac(i)};
		for (ll j = 2; j <= i; ++j)
			V[j] += v[j];
	}

	for (ll i = 2; i <= n; ++i)
		(res *= (V[i]+1)) %= MOD;
	
	std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int x, n100, n5, diff100, diff5;
  cin >> x;

  n100 = x / 100;
  diff100 = x - n100 * 100;

  n5 = diff100 / 5;
  diff5 = diff100 - n5 * 5;

  if (diff5 > 0) n5++;
  
  if (n5 <= n100) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256