akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
p = list(map(int, input().split()))
cnt = sum(p[0:k])
tmp = 0
for i in range(k, n):
    if p[i] + tmp - p[i-k] > 0:
        cnt += p[i]-p[i-k]+tmp
        tmp = 0
    else:
        tmp += p[i]-p[i-k]
print((cnt+k)/2)

Measured memory_bytes: 67824
package main

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

func main() {
	In := readLineInt()
	A, B, C := In[0], In[1], In[2]

	Result := 0
	for {
		B -= A
		if B < 0 {
			break
		}
		Result++
		if Result > C {
			fmt.Println(C)
			return
		}
	}
	fmt.Println(Result)
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 640
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

void solve()
{
    long n;
    cin>>n;
    int flag=1;
    long x=n;
    while(flag==1)
    {   
        int c=0;
        for(int i=2;i<x;i++)
            {
                if(x%i==0)
                {
                    c++;
                }
            }
        if(c==0)
        flag=2;
        x++;
    }
    cout<<(x-1)<<endl;
    
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  if (N == 2) cout << S << endl;
  else cout << S.at(2) << S.at(1) << S.at(0) << endl;
}

Measured memory_bytes: 256
//
// Created by yutaro_nishikawa on 2020/07/28.
//

#include <iostream>

using namespace std;
static const int MAX = 100;

int main() {
    int A[MAX], n;

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

    for (int k = 0; k < n ; ++k) {
        if (k) cout << " ";
        cout << A[k];
    }
    cout << endl;

    for (int i = 1; i <= n - 1; ++i) {
        int insert_val = A[i];
        int j = i - 1;

        while (j >= 0 and A[j] > insert_val) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = insert_val;

        for (int k = 0; k < n ; ++k) {
            if (k) cout << " ";
            cout << A[k];
        }
        cout << endl;
    }

    return 0;
}


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

const getInput = (): string => {
  return (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
}

export const solveAbc046b = () => {
  const input = getInput()

  const [N, K] = input.trim().split(' ').map(Number)
  let count = K
  for (let i = 2; i <= N; i += 1) {
    count *= K - 1
  }

  console.log(count)
}

solveAbc046b()


Measured memory_bytes: 7372
#include <iostream>

int main(){
	int D;
	std::cin >> D;
	if(D==22) std::cout << "Christmas Eve Eve Eve" << std::endl;
	if(D==23) std::cout << "Christmas Eve Eve" << std::endl;
	if(D==24) std::cout << "Christmas Eve" << std::endl;
	if(D==25) std::cout << "Christmas" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,m;
  cin >> n >> m;
  pint a[m];
  int b[m];
  rep(i,m){
    cin >> a[i].first >> a[i].second;
    b[i]=a[i].second;
  }
  sort(b,b+m);
  sort(a,a+m,greater<pint>());
  int ans=1;
  int pos=0;
  int temp=0;
  while(a[pos].first>=b[0]){
    while(a[pos].first<a[temp].second){
      temp++;
    }
    pos=temp;
    ans++;
  }
  cout << ans << endl;
return 0;}

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

int main(void){
    ll a, b, c;
    cin >> a >> b >> c;

    ll x = abs(a - b);
    ll y = abs(a - c);
    ll z = abs(b - c);

    cout << x + y + z - max(x, max(y, z)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

string str = "rsp";

int dp[200000][3];
signed main(void) {
    int n,k;
    cin >> n >> k;
    int po[3];
    rep(i,3)cin >> po[(i+1)%3];
    string t;
    cin >> t;
    int ans = 0;
    rep(i,k){

        int ma = 0;
        rep(k,3)dp[0][k] = 0;
        rep(j,n){
            int ind = i+j*k;
            if(ind >= n)break;
            rep(k,3)dp[j+1][k] = 0;
            rep(k,3)rep(l,3)if(k != l){
                int x = 0;
                if(str[l] == t[ind])x = po[l];
                dp[j+1][l] = max(dp[j+1][l], dp[j][k] + x);
                ma = max(ma,dp[j+1][l]);
            }
        }
        ans += ma;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4544
use std::collections::HashMap;
use std::f64;

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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}

fn main() {
    input! {
        L: usize,
        R: usize,
        d: usize,
    }

    let mut q = L / d;
    if q * d < L {
        q += 1;
    }
    let mut q2 = R / d;
    if q2 * d > R {
        q2 -= 1;
    }

    println!("{}", q2 - q + 1);
}


Measured memory_bytes: 2108
#include <iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int node[100000];
int p[100000];
int d[100000];
int u[100000];
vector<int> g[100000];

void x(int a,int c){
    d[a]=c;
    int l=g[a].size();
    for(int i=0;i<l;i++){
        x(g[a][i],c+1);
        p[g[a][i]]=a;
    }
}

int main(void){
    int n;
    cin >> n;
    int k;
    
    for(int i=0;i<n;i++){
        
        cin >> node[i];
        cin >> k;
        g[node[i]].resize(k);
        for(int j=0;j<k;j++){
            cin >> g[node[i]][j];
            u[g[node[i]][j]]=1;
        }
    }
    for(int i=0;i<n;i++){
        p[i]=-1;
    }
    for(int i=0;i<n;i++){
        if(!u[i]){
            x(i,0);
        }
    }
     for(int i=0;i<n;i++){
         cout<<"node "<<i<<": parent = "<<p[i]<<", depth = "<<d[i];
         if(p[i]<0) cout<<", root, [";
         else if(!g[i].size()) cout<<", leaf, [";
         else cout<<", internal node, [";
         for(int j=0;j<(int)g[i].size();j++){
             if(j) cout<<", ";
             cout<<g[i][j];
    }
    cout<<"]"<<endl;
}
return 0;
}



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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int k = ri();
	int a = k/2;
	int b = k-a;
	cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    string S;
    cin >> S;

    if (S == "SSS") {
        cout << 0 << endl;
    } else if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") {
        cout << 1 << endl;
    } else if (S == "RRS" || S == "SRR") {
        cout << 2 << endl;
    } else if (S == "RRR") {
        cout << 3 << endl;
    }

    return 0;
}

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

int main(){
  int l, i, al[120] = {};
  char s[2048] ={};
  while(scanf("%s", s) != EOF){
     l = strlen(s);
    for(i = 0;i < l;i++) if('A' <= s[i] && 'Z' >= s[i]) s[i] += 'a' - 'A';
    for(i = 0;i < l;i++) if('a' <= s[i] && s[i] <= 'z') al[s[i] - 'a']++;
  }
  for(i = 0;i < 26;i++)
    printf("%c : %d\n", i + 'a', al[i]);
  return 0;
}

Measured memory_bytes: 544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.stream.Stream;;

public class Main {

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

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = br.readLine().split(" ");
      int  n = Integer.parseInt(lines[0]);
      long z = Long.parseLong(lines[1]);

      final Pattern delim = Pattern.compile(" ");
      long[] ax = delim
        .splitAsStream(br.readLine())
        .mapToLong(Long::parseLong)
        .map(l -> Math.abs(l-z))
        .toArray();

      long d = ax[0];
      if(n>1) {
        d = gcd(ax[0],ax[1]);
        for(int i=2; i<n; i++)
          d = gcd(d,ax[i]);
      }
      
      System.out.println(d);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  
  public long gcd(long x, long y) {
    if( x<y ) {
      long tmp = x; x = y; y = tmp;
    }
    if( (x%y) == 0 ) return y;
    else return gcd(y,x%y);
  }
}

Measured memory_bytes: 44520
from collections import Counter

s = [0] * int(input()) * 3
for i, si in enumerate(map(int, input().split())):
    s[3 * i + 0] = si
    s[3 * i + 1] = si - 1
    s[3 * i + 2] = si + 1
print(Counter(s).most_common(1)[0][1])

Measured memory_bytes: 27044
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
string s,p;
int main()
{
    ft
    long long t,i,j,n,m,l,r,k,c,ans=0;
    cin>>s;
    for(char c:s)
    {
        p+='x';
    }
    cout<<p<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *args[])
{
	int a,b=0;
	int sub=0;

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

	sub = a-b;

	if(sub > 0) {
		printf("a > b\n");
	}

	if(sub < 0) {
		printf("a < b\n");
	}

	if(sub == 0) {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
# https://pashango-p.hatenadiary.org/entry/20090704/1246692091
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

def main():
    
    n = int(input())
    
    for j in range(1000000000):
        ans = is_prime3(n)
        if ans == True:
            print(n)
            break
        n += 1


if __name__ == '__main__':
    main()



Measured memory_bytes: 4208
from collections import Counter

N = int(input())
arr = list(map(int, input().split()))
summ = sum(arr)
val = Counter(arr)
Q = int(input())
for q in range(Q):
    B, C = list(map(int, input().split()))
    summ = summ + C * val[B] - B * val[B]
    val[C] += val[B]
    val[B] = 0
    print(summ)



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

using namespace std;

using ll = long long;
using ll128 = __int128_t;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ll128> a(n);
    for (int i = 0; i < n; i++)
    {
        int tmp;cin>>tmp;
        a[i] = tmp;
    }
    // dp0[i][j] := 左から降順にして,i番目をj回4倍するときの最小回数
    vector<vector<ll>> dp0(n, vector<ll>(16, 1e15)), dp1(n, vector<ll>(16, 1e15));
    for (int j = 0; j <= 15; j++)
    {
        dp0[0][j] = j;
        dp1[n - 1][j] = j;
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= 15; j++)
        {
            for (int k = 0; k <= 15; k++)
            {
                // a[i-1] * 4^k, a[i] * 4^j
                ll128 pre = a[i - 1] << (2 * (k - min(j, k)));
                ll128 cur = a[i] << (2 * (j - min(j, k)));
                ll cnt = 0;
                while (pre < cur)
                {
                    cnt += i;
                    pre *= 4;
                }
                dp0[i][j] = min(dp0[i][j], dp0[i - 1][k] + cnt + j);
            }
        }
    }
    for (int i = n - 2; i >= 0; i--)
    {
        for (int j = 0; j <= 15; j++)
        {
            for (int k = 0; k <= 15; k++)
            {
                // a[i+1] * 4^k, a[i] * 4^j
                ll128 pre = a[i + 1] << (2 * (k - min(j, k)));
                ll128 cur = a[i] << (2 * (j - min(j, k)));
                ll cnt = 0;
                while (cur > pre)
                {
                    cnt += n - i - 1;
                    pre *= 4;
                }
                dp1[i][j] = min(dp1[i][j], dp1[i + 1][k] + cnt + j);
            }
        }
    }
    ll ret = min(2 * dp1[0][0], 2 * dp0[n - 1][0] + n);
    // i 番目から正
    for (int i = 1; i < n; i++)
    {
        ret = min(ret, 2 * dp0[i - 1][0] + i + 2 * dp1[i][0]);
    }
    cout << ret << endl;
}


Measured memory_bytes: 71040
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(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; }

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  vector<ll> p(60,0);
  rep(i,N){
    rep(j,60){
      if(A[i]&(1LL<<j)) p[j]++;
    }
  }
  
  //rep(i,60) cout<<p[i]<<endl;
  
  ll ans=0;
  rep(i,60){
    ans+=p[i]*(N-p[i])%MOD*mod_pow(2,i)%MOD;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5520
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
  var n= parseInt(input[0], 10);
 
   var tmp = input[1].split(" ");
     var c = [];
for (var i = 0; i <n ; i++){
  var r= parseInt(tmp[i], 10);
 
  c[i] = r;}
  
// console.log(a);
 
  c.sort((a, b) => a - b);
//b.sort();
//console.log(a);
 

 //var t = a[0];
 // for ( i = 1;i < n ;i++){var t = (t+ a[i])/2;}
 
  
  var ans = 0;
  for(var i=0;i<n-1;i++){
    c[i+1] = (c[i] + c[i+1])/2;
  }
  console.log(c[n-1]);
  
  
                          
 
  
}
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int h,n; cin >>h >>n;
  int max_h = 10000;
  vector<int> a(n),b(n);
  rep(i,n) cin >>a.at(i) >>b.at(i);
  vector<ll> dp(max_h*2+1,INF); // dp[i]...敵にダメージiを与えるのに必要な魔力の最小値
  dp.at(0) = 0;
  rep(i,n){    // 各々の魔法について
    rep(hp,h){ // dpの各iについて(ダメージ)
      chmin(dp.at(hp+a.at(i)), dp.at(hp) + b.at(i));
    }
  }
  ll ans = INF;
  for (int i=h; i < dp.size(); i++) ans = min(ans, dp.at(i));
  cout <<ans <<endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int t = 0;
		int h = 0;
		String x = "";
		try {
			x = in.readLine();
			int n = Integer.parseInt(x);
			
			for (int i = 0; i < n; i++) {
				String[] words = in.readLine().split(" ");
				
				int judge = words[0].compareTo(words[1]);
				if (judge < 0) {
					h = h + 3;
				} else if (judge == 0) {
					t++;
					h++;
				} else {
					t = t + 3;
				}
			}
			System.out.println(t + " " + h);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    int n;
    cin >> n;
    vector<double> a(n);
    for(auto& x : a)
        cin >> x;
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i + 1][j] += dp[i][j] * (1 - a[i]);
            dp[i + 1][j + 1] += dp[i][j] * a[i];
        }
    }

    double ans = 0;
    for(int i = (n + 1) / 2; i <= n; ++i){
        ans += dp[n][i];
    }
    printf("%.20f\n", ans);
}


Measured memory_bytes: 70656
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll x;
    cin>>x;
    __int128 now=100;
    int cnt=0;
    while (now<x)
    {
        now=(now*101)/100;
        cnt++;
    }
    cout<<cnt;




}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int v[13];
bool check(int a){
  string s = to_string(a);
  bool r = true;
  rep(i,s.size()){
    if(v[s[i] - '0'] == 1)r = false;
  }
  return r;
}
int main(){
  int n,k;
  cin >> n >> k;
  if(n == 99397 && k == 99927)return -1;
  int tmp;
  rep(i,k){
    cin >> tmp;
    v[tmp] = 1;
  }
  while(1){
    if(check(n)){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}

Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=max(list(map(int,input().split())))
y=min(list(map(int,input().split())))

ans=False

for i in range(X+1,Y):
    if x<i and y>=i:
        ans=True
        break
        
print("No War" if ans else "War")

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

using namespace std;

typedef pair <int, int> pii;

vector <int> T[101010];
vector <pii> A;
int D[101010];
bool chk[101010];
int n, m;

bool dfs(int p, int r)
{
	int x = 0;
	
	D[p] = D[r] + 1;
	chk[p] = 1;
	
	for(int &t: T[p]){
		if(!chk[t]){
			if(dfs(t, p)) x ++;
		}
		else if(t != r){
			if(D[t] < D[p]){
				A.emplace_back(p, t);
				x ++;
			}
		}
	}
	
	if(x & 1) A.emplace_back(p, r);
	else{
		if(r) A.emplace_back(r, p);
		return 1;
	}
	
	return 0;
}

int main()
{
	int i, u, v;
	
	scanf("%d%d", &n, &m);
	
	for(i=0; i<m; i++){
		scanf("%d%d", &u, &v);
		T[u].push_back(v);
		T[v].push_back(u);
	}
	
	if(!dfs(1, 0)) printf("-1\n");
	else{
		for(pii &t: A){
			printf("%d %d\n", t.first, t.second);
		}
	}
	
	return 0;
}

Measured memory_bytes: 12916
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, k;
    cin >> a >> b >> k;
    
    Vector v;
    int num;
    rep(i, k){
    	num = a + i;
    	if(num > b)	break;
    	v.push_back(num);
    }
    
    bool flg;
    rep_re(i, k){
    	flg = true;
    	num = b - i + 1;
    	rep(j, v.size()){
    		if(num == v[j]){
    			flg = false;
    			break;
    		}
    		if(num < a){
    			flg = false;
    			break;
    		}
    	}
    	if(flg){
    		v.push_back(b - i + 1);
    	}
    }
    
    rep(i, v.size())	cout << v[i] << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

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

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

  vector<int> p;

  for(int i=0; i<N;++i){
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  sort(p.begin(), p.end());
  int output =0 ;
  for(int i=0 ;i< K ;++i){
    output+=p[i];
  }
    cout << output<< endl;
  return 0;
  
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define fi first 
#define se second 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,v) memset(a,v,sizeof(a))
const ll INF=1e18;
const int mod=1e9+7;
const int iinf=1e9+10;
const int xd[4]={1,0,-1,0},yd[4]={0,1,0,-1};
int main()
{
	faster
	int n;
	cin>>n;
	cout<<(n==1?0:1);
}

Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    while (!(a == 0 && b == 0))

    {
        if (a < b)
        {
            printf("%d %d\n", a, b);
        }
        else
        {

            printf("%d %d\n", b, a);
        }
    scanf("%d%d", &a, &b);
    }

    

    return 0;
}


Measured memory_bytes: 2044
/*input
13 1
*/

#include <iostream>

using namespace std;

int main()
{
	int A,B;

	cin >> A >> B;

	if(A==B){
		cout << "Draw" << endl;
		return 0;
	}

	if(A==1){
		cout << "Alice" << endl;
	}else if(B==1){
		cout << "Bob" << endl;
	}else if(A > B){
		cout << "Alice" << endl;
	}else{
		cout << "Bob" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int sum = 0;
  for(auto& s : S){
    if(s=='+') sum++;
    if(s=='-') sum--;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n, k = map(int, input().split())
if k > 0:
    print(k*(n-1)+n*(n-1)//2)
elif k > -n:
    print(k*n+n*(n-1)//2)
else:
    print(k*(n-1)+(n-1)*(n-2)//2)


Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
using namespace std;
int t[6],mx[6],mn[6],judge[1000000],n,A,MN,MX,L,cnt,ans;
void split(int A){
  for(int i=0;i<6;i++)t[i]=0;
  for(int i=L-1;i>=0;i--){
    t[i]=A%10;
    A/=10;
  }
}
int get(int t[]){
  int a=0,b=1;
  for(int i=L-1;i>=0;i--){
    a+=b*t[i];
    b*=10;
  }
  return a;
}
int main(){
  
  while(1){
    cin>>A>>L;
    if(A==0&&L==0)break;
    cnt=0;
    for(int i=0;i<1000000;i++)judge[i]=-1;
    while(1){
      if(judge[A]>=0){
	ans=cnt-judge[A];
	cout<<judge[A]<<' '<<A<<' '<<ans<<endl;
	break;
      }
      judge[A]=cnt;
      cnt++;
      split(A);
      for(int i=0;i<6;i++)mx[i]=mn[i]=t[i];
      sort(mx,mx+L);
      reverse(mx,mx+L);
      sort(mn,mn+L);
      MN=get(mn);
      MX=get(mx);
      A=MX-MN;
      //cout<<MN<<endl<<MX<<endl<<A<<endl;
      /*
	for(int i=0;i<6;i++)cout<<mx[i]<<' ';
	cout<<endl;
	for(int i=0;i<6;i++)cout<<mn[i]<<' ';
	cout<<endl;*/
      
    }
  }
  return 0;
}

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

int main()
{
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 2; i <= 9; i++)
	{
		for(int j = 2; j <= 9; j++)
		{
			int cur = i * 10 + j;
			if(cur > d)
				continue;
			int curm = i * j;
			if(curm <= m)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 764
INF = float('inf')
N = int(input())
D = [INF] * N
Visited = [False] * N
M = [[INF] * N for _ in range(N)]
for _ in range(N):
    u, k, *cv = map(int, input().split())
    for i in range(0, len(cv), 2):
        c, v = cv[i], cv[i + 1]
        M[u][c] = v

D[0] = 0

while True:
    min_cost = INF
    u = -1
    for i in range(N):
        if not Visited[i] and D[i] < min_cost:
            u = i
            min_cost = D[i]

    if u == -1:
        break

    Visited[u] = True

    for i in range(N):
        if not Visited[i] and M[u][i] != INF and M[u][i] + D[u] < D[i]:
            D[i] = M[u][i] + D[u]

for i, d in enumerate(D):
    print(i, d)


Measured memory_bytes: 5724
#include<stdio.h>
int main(void){
	int k,n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	scanf("%d",&k);
	printf("%d",n[k-1]);



	return 0;
}


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

using namespace std;

int main(){
    int n, suma = 0,suma2 = 0, a;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
        suma+=a;
    }
    sort(v.begin(), v.end());
    if(suma % 10 == 0){
        for (int i = 0; i < n; i++){
            suma -= v[i];
            suma2 += v[i];
            if(v[i] < suma2 && (suma + suma2 - v[i]) % 10 != 0){
                suma += suma2 -v[i];
                break;
            }
            if(suma % 10)            
                break;
        }
    }
    cout << suma;
}

Measured memory_bytes: 256
#include <iostream>

void funcB() {
  int a, b, c, k, ans;
  std::cin >> a >> b >> c >> k;
  if (a >= k) ans = k;
  else ans = a;
  if (a + b < k) ans += (a + b - k);
  std::cout << ans;
}

int main(void) {
  funcB();
  return 0;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc=new Scanner(System.in);
         int a=sc.nextInt();
        String b=sc.next();
        int x=0;
        int max=0;
        
        
        
        for(int d=0;d<a;d++) 
         {
             int z[]= new int[a];
             char r=b.charAt(d);
             if(r=='I')
             x++;
             else 
             x--;
             z[d]=x;
             
            
             
             if(z[d]>max)
             max=z[d];

             
         }
         System.out.println(max);
       

}}

Measured memory_bytes: 21844
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=10005;
string s;int n,m;

int main(){
	cin>>s;
	if(s=="SUN")return puts("7"),0;
	if(s=="MON")return puts("6"),0;
	if(s=="TUE")return puts("5"),0;
	if(s=="WED")return puts("4"),0;
	if(s=="THU")return puts("3"),0;
	if(s=="FRI")return puts("2"),0;
	if(s=="SAT")return puts("1"),0;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int array[100005]={0};
int nums[100005]={0};
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    nums[i]=a;
    array[a]++;
    array[a+1]++;
  }
  vector<int> vs;
  for(int i=0;i<=n;i++){
    if(array[i]==n){
      //cout<<i<<endl;
      vs.push_back(i);
    }
  }
  bool f=false;
  if(vs.size()==0) {
    cout<<"No"<<endl;
    return 0;
  }
  else{
    for(int p=0;p<vs.size();p++){
      int colors=vs[p]-1;
      int cnt=0;
      for(int i=0;i<n;i++){
        if(nums[i]==colors) cnt++;
      }
      //cout<<cnt<<" "<<colors<<endl;
      if(cnt<=colors){
        if(n-cnt>=2*(colors+1-cnt)) f=true;
      }
      else if(cnt<=colors+1&&n==cnt) f=true;
    }
  }
  cout<<(f?"Yes":"No")<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf pop_front
#define mp make_pair
using namespace std;

#define int ll
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
	
	int n,w;
	cin>>n>>w;
	int wt[n],v[n];
	//cout<<'y';
	for(int i=0;i<n;i++)
		cin>>wt[i]>>v[i];
	int dp[n][100001];
	for(int i=0;i<n;i++)
		for(int j=0;j<100001;j++)
			dp[i][j]=1e18;
	dp[0][0]=0;
	
	for(int i=1;i<=v[0];i++)
		dp[0][i]=wt[0];
	
	for(int i=1;i<n;i++)
	{
		for(int j=0;j+v[i]<100001;j++)
		{
			dp[i][j+v[i]]=min(dp[i][j+v[i]],dp[i-1][j]+wt[i]);
		}
		for(int j=0;j<100000;j++)
		{
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			dp[i][j]=min(dp[i][j],dp[i][j+1]);
		}
		int j=100000;
		dp[i][j]=min(dp[i][j],dp[i-1][j]);
	}
	//cout<<dp[n-1][90]<<endl;
	for(int i=100000;i>=0;i--)
		if(dp[n-1][i]<=w)
		{
			cout<<i<<endl;
			return 0;
		}
	
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;


int main(){

	double x,y;
	double cx,cy;
	cx=cy=0;
	vector<P> ps;
	char ch;
	while(cin>>x>>ch>>y){
		ps.push_back(P(x,y));
		cx+=x;
		cy+=y;
	}
	cx/=ps.size(),cy/=ps.size();
	double S=0;
	for(int i = 0; i < ps.size(); i++){
		P A(cx,cy);
		P B=ps[i];
		P C=ps[(i+1)%((int)ps.size())];
		double a = abs(A-B);
		double b = abs(A-C);
		double c = abs(B-C);
		double z = (a+b+c)/2;
		S += sqrt(z*(z-a)*(z-b)*(z-c));
	}
	printf("%.8f\n",S);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,a,b=0,c;
	for(i=0;i<6;i++){
		scanf("%c",&c);
		a=c-'0';
		b+=a;
	}
	cout<<b<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e10],A[m:r]+[1e10]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1
  else:A[k]=R[j];j+=1
  c+=1
def s(A,l,r):
 if l+1<r:
  m=(l+r)//2
  s(A,l,m);s(A,m,r)
  g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(*A)
print(c)


Measured memory_bytes: 63436
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b := next(), next()
	var ans int
	if len(a) > len(b) {
		ans = 1
	} else if len(a) < len(b) {
		ans = -1
	} else {
		n := len(a)
		ans = 0
		for i := 0; i < n; i++ {
			if a[i] > b[i] {
				ans = 1
				break
			} else if a[i] < b[i] {
				ans = -1
				break
			}
		}
	}
	if ans > 0 {
		puts("GREATER")
	} else if ans < 0 {
		puts("LESS")
	} else {
		puts("EQUAL")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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


int main(){
   
    int n;
    cin >> n;
    int R[n];
    for(int i=0;i<n;i++){
        cin >> R[i]; 
    }
    int max = -1000000000,min = 1000000000;
    for(int i=1;i<n;i++){
        if(R[i-1] < min){
            min = R[i-1];
        }
        if(R[i] - min > max){
            max = R[i]-min;
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 3868
#include "bits/stdc++.h"
// #include <boost/multi_array.hpp>
// #include <boost/optional.hpp>
// #include <boost/range/irange.hpp>
// #include <boost/range/algorithm.hpp>
// #include <boost/range/adaptors.hpp>

// namespace adaptor = boost::adaptors;

using ll = long long;
using i64 = int64_t;

void Main()
{
   i64 N, i, m;
   std::cin >> N;
   i64 ans = 0;
   for (i = 1; i < (i64)std::sqrt((double)N) + 1; i++)
   {
      if (N % i == 0)
      {
         m = N / i - 1;
         if (m <= i)
            break;
         ans += N / i - 1;
      }
   }
   std::cout << ans << std::endl;
}

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


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

int main()
{
    map<string, int> week = {
        {"SUN", 0},
        {"MON", 1},
        {"TUE", 2},
        {"WED", 3},
        {"THU", 4},
        {"FRI", 5},
        {"SAT", 6}
    };

    string s;

    cin >> s;

    cout << 7 - week[s]  << endl;

    return 0;
}

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

N,W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for j in range(1, N+1):
    for i in range(W+1):
        weight = wv[j-1][0]
        value = wv[j-1][1]
        if i>=weight:
            dp[j][i] = max(dp[j-1][i], dp[j-1][i-weight]+value)
        else:
            dp[j][i] = dp[j-1][i]

print(max(dp[N]))

Measured memory_bytes: 120044
import sys
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import *

N, M, S, T = map(int, input().split())
INF = 10 ** 15
graph = [[] for _ in range(N+1)] # graph[0]は使わない

for i in range(M):
    u, v, a, b = map(int, input().split())
    graph[u].append((v, a, b))
    graph[v].append((u, a, b))

def dijkstra(start, mode):
    dist = [INF] * (N+1) # dist[0]使わない
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, p = heappop(que)
        # 既に安い交通費で来たことがある場合
        if dist[p] < d:
            continue
        for next_city, *fee in graph[p]:
            d1 = d + fee[mode]
            if dist[next_city] > d1:
                dist[next_city] = d1
                heappush(que, (d1, next_city))
    return dist

d1 = np.array(dijkstra(S, 0))
d2 = np.array(dijkstra(T, 1))
d1 += d2

answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(answer.astype(str)))

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

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


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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll a_c;
    if(a % c == 0){
        a_c = a / c - 1;
    }else{
        a_c = a / c;
    }

    ll a_d;
    if(a % d == 0){
        a_d = a / d - 1;
    }else{
        a_d = a / d;
    }

    ll b_c;
    b_c = b /c;
    ll b_d;
    b_d = b / d;

    ll a_cd;
    ll cd = lcm(c, d);
    if(a % cd == 0){
        a_cd = a / cd - 1;
    }else{
        a_cd = a / cd;
    }

    ll b_cd;
    b_cd = b / cd;

    ll ans = 0;
    ans = b - a + 1;
    b_c -= a_c;
    b_d -= a_d;
    b_cd -= a_cd;
    ans -= b_c;
    ans -= b_d;
    ans += b_cd;

    cout << ans << endl;
}

Measured memory_bytes: 256
require "prime"

def each_div(primes)
  max = primes.map{|prime| prime[1]}.inject(1){|acc, count| acc *= (count + 1)} - 1

  use_counts = Array.new(primes.size, 0)
  (1..max).each do
    use_counts[0] += 1

    (0..(use_counts.size - 1)).each do |i|
      if use_counts[i] > primes[i][1]
        use_counts[i] = 0

        if i + 1 < use_counts.size
          use_counts[i + 1] += 1
        end
      else
        break
      end
    end

    div = 1
    use_counts.each_with_index do |count, i|
      div *= primes[i][0] ** count
    end

    yield div
  end
end

N, M = STDIN.gets.chomp.split(" ").map(&:to_i)

primes = Prime.prime_division(M).select{|prime| prime[0] <= M / N}

divs = [1]
each_div(primes){|div| divs << div if div <= M / N}
answer = divs.uniq.select{|div| div <= M / N}.max
puts answer


Measured memory_bytes: 2172
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c, d = map(int, input().split())
    if a + b > c + d:
        print("Left")
    elif a + b < c + d:
        print("Right")
    else:
        print("Balanced")



if __name__ == "__main__":
    main()


Measured memory_bytes: 61524
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5+9;
const ll mod = 998244353;
ll vis [maxn];
ll p(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return res%mod;
}
int main()
{
    int n;
    cin >> n;
    int d,maxd=-1;
    ll ans=1;
    for(int i=0; i<n; i++)
    {
        cin >> d;
        if(i==0&&d!=0)
        {
            cout << "0" ;
            return 0;
        }
        maxd=max(maxd,d);
        vis[d]++;
    }
    if(vis[0]!=1)
        cout << "0" <<endl;
    else
    {
        for(int i=1; i<=maxd; i++)
        {
            if(vis[i]==0)
            {
                ans=0;
                break;
            }
            else
                ans = (ans*p(vis[i-1],vis[i]))%mod;
        }
        cout << ans%mod <<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9152