akhauriyash/Code-Regression huggingface dataset:
def dice_in_line():
    N,K=map(int,input().split())
    p_n=list(map(int,input().split()))
    max=x=sum(p_n[:K])
    for i in range(N-K):
        x+=(p_n[K+i]-p_n[i])
        if max<x:
            max=x
    print((max+K)/2)

dice_in_line()


Measured memory_bytes: 24804
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int S;

void solve(){
	if(S==1e+18){
		cout<<0<<" "<<0<<" "<<0<<" "<<1000000000<<" "<<1000000000<<" "<<0<<endl;
		return;
	}
	Int t = (Int)(sqrt((long double)S)+1e-12);
	Int a, b;
	if(S <= t * (t+1)){
		a = t;
		b = t + 1;
	}else{//t * (t + 1) < S
		a = t + 1;
		b = t + 1;
	}
	Int p = a * b - S, q = 1;
	assert(0<=p and 0<=q and p<=b and q<=a);
	assert(a*b - p*q ==S);
	cout<<0<<" "<<0<<" "<<p<<" "<<a<<" "<<b<<" "<<q<<endl;
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> S;
	solve();
	return 0;
}
//}}}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;



int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10)cout << "error" << endl;
	else cout << A + B << endl;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<string> D(N);
    REP(i, N) cin >> D[i];

    map<string, int> M;
    REP(i, N) {
        if (M.count(D[i])) {
            M[D[i]]++;
        } else {
            M[D[i]] = 1;
        }
    }

    int Max = 0;
    for (auto item : M) {
        Max = max(Max, item.second);
    }

    for (auto item : M) {
        if (item.second == Max) print(item.first);
    }
}

signed main() {
    solve();
}


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


void solve(long long N, std::vector<long long> X){
    ll ave = accumulate(X.begin(), X.end(), 0LL) / N;
    ll ans = 1e18;
    for(int j = -10;j < 10;j++){
        ll o = 0;
    for(int i = 0;i < N;i++){
        o += (X[i] - ave + j) * (X[i] - ave + j);
    }
    ans = min(ans, o);
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

int main(){
    int N,i,a,b;
    int elapsed=0;
    int flg=0;
    cin>>N;
    vector<vector<int>> work;
    
    for(i=0;i<N;i++){
        cin>>a>>b;
        work.push_back({b,a});
    }

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

    for(i=0;i<N;i++){
        elapsed+=work[i][1];
        if(elapsed>work[i][0]){
            flg=1;
            break;
        }
    }

    if(flg==1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 12588
// atcoder/abc156/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;
constexpr int N = 2 * 1e5 + 5;

namespace math {
  lli fact[N], finv[N], inv[N];

  void init()
  {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N; i++){
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  lli mod_comb(int n, int k)
  {
    assert(n < N && k < N);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

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

  math::init();

  lli n, k;
  while (cin >> n >> k) {
    lli sum = 0;
    for (lli i = 0; i <= min(n - 1LL, k); ++i) {
      lli x = math::mod_comb(n, i) * math::mod_comb(n - 1, n - i - 1);
      (sum += x % mod) %= mod;
    }
    cout << sum << endl;
  }

  return 0;
}


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

int bubblesort(int A[], int N) {
    int step = 0;
    bool flag = true;
    while(flag) {
        flag = false;
        for(int j = 0; j < N-1; j++) {
            if(A[j+1] < A[j]) {
                step++;
                swap(A[j], A[j+1]);
                flag = true;
            }
        }
    }
    return step;
}

int main() {
    int A[100], step, N;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    step = bubblesort(A, N);
    for(int i = 0; i < N; i++) {
        if(i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    cout << step << endl;
    return 0;
}


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

int main(){
    for(ll i = 0; ; ++i){
        ll x, y;
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        cout << min(x, y) << " " << max(x, y) << endl;
    }
    return 0;
}



Measured memory_bytes: 3004
data = []
da = []
a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
for i in range(a[0]):
    b = input().split()
    for j in range(a[1]):
        b[j] = int(b[j])
    data.append(b)
for i in range(len(data)):
    data[i].append(sum(data[i]))
for i in range(a[1]+1):
    da.append(0)
for i in range(a[0]):
    for j in range(a[1]+1):
        da[j] += data[i][j]
data.append(da)
for i in data:
    for j in range(len(i)):
        i[j] = str(i[j])
for i in data:
    print(" ".join(i))



Measured memory_bytes: 6248
#include<bits/stdc++.h>
using namespace std;
long long  d[9],a,b,c,n;
long long f(long long i,long long x,long long y,long long z)
{
	if(i==n){
		if(x==0||y==0||z==0)return INT_MAX;
		return abs(a-x)+abs(b-y)+abs(c-z);}
	return min({f(i+1,x,y,z),10*(x!=0)+f(i+1,x+d[i],y,z),10*(y!=0)+f(i+1,x,y+d[i],z),10*(z!=0)+f(i+1,x,y,z+d[i])});
}
int main()
{
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++)cin>>d[i];
	cout<<f(0,0,0,0)<<endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve(){

  string s;
  int n, q;
  int d[100005]={};
  cin >> n >> q >> s;
  iFOR(i,1,s.length()){
    if(s[i-1]=='A' && s[i]=='C')
      d[i]++;
    d[i]+=d[i-1];
  }
  FOR(i,q){
    int l,r;
    cin >> l >> r;
    l--,r--;
    cout << d[r]-d[l] fin;
  }
  


}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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

using namespace std;
string s;
int pos;

bool isDigit(char c)
{
	return('0' <= c && c <= '9');
}

int dfs()
{
	vector<int> v;
	while (pos < s.size())
	{
		if (isDigit(s[pos]))
		{
			int res = 0;
			while (isDigit(s[pos]))
			{
				res *= 10;
				res += s[pos] - '0';
				++pos;
			}
			v.push_back((res + 1) / 2);
		}
		else if (s[pos] == '[')
		{
			++pos;
			v.push_back(dfs());
		}
		else if (s[pos] == ']')
		{
			++pos;
			vector<int> a = v;
			sort(a.begin(), a.end());
			int size = a.size() / 2;
			int res = 0;
			for (int i = 0; i <= size; ++i)
			{
				res += a[i];
			}
			return(res);
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		pos = 1;
		cout << dfs() << endl;
	}
}

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

Measured memory_bytes: 1288
import numpy as np
def main():
    H,W = map(int,input().split())
    grid = np.array([list(input()) for _ in range(H)],str)
    grid = grid[:,np.any(grid == '#',axis = 0)]
    grid = grid[np.any(grid == '#',axis = 1),:]
    print('\n'.join(''.join(row) for row in grid))
if __name__ == '__main__':
    main()

Measured memory_bytes: 12524
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<vector<int> > g(N);
  vector<pair<int,int> > edges(N - 1);
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
    if (a > b) swap(a, b);
    edges[i] = make_pair(a, b);
  }

  int K;
  {
    int max_n_edges = 0;
    for (int i = 0; i < N; ++i) {
      int n_edges = g[i].size();
      max_n_edges = max(max_n_edges, n_edges);
    }
    K = max_n_edges;
  }

  vector<int> node_colors(N, -1);
  
  map<pair<int, int>, int> edge_colors;
  for (int i = 0; i < N - 1; ++i) {
    edge_colors[edges[i]] = -1;
  }

  // coloring (bfs)
  queue<int> q;
  q.push(0);

  // root node
  {
    node_colors[0] = -1;
    int color = 0;
    for (auto v : g[0]) {
      edge_colors[make_pair(0, v)] = color;
      node_colors[v] = color;
      ++color;
      q.push(v);
    }
  }
  
  while (not q.empty()) {
    int u = q.front();
    q.pop();
    int color = 0;
    for (auto v : g[u]) {
      pair<int, int> edge = make_pair(min(u,v), max(u,v));
      if (edge_colors[edge] != -1) continue;  // already colored (edge to parent)
      if (color == node_colors[u]) ++color;
      edge_colors[edge] = color;
      node_colors[v] = color;
      ++color;
      q.push(v);
    }
  }

  cout << K << endl;
  for (int i = 0; i < N - 1; ++i) {
    cout << edge_colors[edges[i]] + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 13440
from sys import stdin
from collections import Counter
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    c=sorted(c.items())
    if N%3!=0:  #Nが3の倍数じゃない時
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        else:
            print("No")

    elif N%3==0:  #Nが3の倍数の時
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3:
            print("Yes")
        elif len(c)==3 and c[0][1]==N//3 and c[1][1]==N//3 and c[2][1]==N//3 and c[0][0]^c[1][0]^c[2][0]==0:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 15400
package main

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

// template start
var sc = bufio.NewScanner(os.Stdin)


func input2int() int{
	sc.Scan()
	num , _ := strconv.Atoi(sc.Text())
	return num
}

func input2intarr(n int) []int{
	sc.Scan()
	in := strings.Split(sc.Text(), " ")
	out := make([]int, n)
	for i:=0; i<n; i++{
		out[i], _ = strconv.Atoi(in[i])
	}
	return out
}
// template end

func main(){
	var buf = make([]byte, 10000)
	sc.Buffer(buf, 1000000)
	var n = input2int()
	var arr = input2intarr(n)
	var even = make(map[int]int, n/2)
	var odd = make(map[int]int, n/2)
	for i:=0; i<n; i++{
		if i%2 == 0{
			even[arr[i]]++
		} else {
			odd[arr[i]]++
		}
	}
	var e_max, o_max int
	var e_k, o_k int
	for k, v := range(even){
		if v > e_max{
			e_k, e_max = k, v
		}
	}
	for k, v := range(odd){
		if v > o_max{
			o_k, o_max = k, v
		}
	}
	if e_k == o_k{
		if e_max == o_max{
			var first, second int
			first = e_max
			o_max = 0
			odd[o_k] = 0
			for _, v := range(odd){
				if v > o_max{
					o_max =  v
				}
			}
			e_max = 0
			even[e_k] = 0
			for _, v := range(even){
				if v > e_max{
					e_max =  v
				}
			}
			if e_max >= o_max{
				second = e_max
			}else if o_max > e_max{
				second = o_max
			}
			e_max, o_max = first, second
		} else if e_max > o_max{
			o_max = 0
			odd[o_k] = 0
			for _, v := range(odd){
				if v > o_max{
					o_max =  v
				}
			}
		} else {
			e_max = 0
			even[e_k] = 0
			for _, v := range(even){
				if v > e_max{
					e_max =  v
				}
			}
		}
	}
	fmt.Println(n - (e_max + o_max))
}

Measured memory_bytes: 7296
package main

import "fmt"

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	totalM := 0
	minM := X
	for i := 0; i < N; i++ {
		var m int
		fmt.Scan(&m)
		totalM += m
		minM = min(minM, m)
	}
	fmt.Println(N + (X-totalM)/minM)
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e12;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    string s;
    cin >> s;
    i64 r = 0;
    for (auto c : s) {
        r += c - '0';
        r %= 9;
    }

    if (!r) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
//#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
bool visited[100001]={false};
vector<int>graph[100001];
int dp[100001]={0};
void dfs(int x){
	if(visited[x])return;
	visited[x]=true;
	for(auto &child:graph[x]){
		if(!visited[child]){
			dfs(child);	
		}
		dp[x]=max(dp[x],dp[child]+1);
	}
}
signed main(){
	FAST
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	for(int i=1;i<n+1;i++){
		if(!visited[i]){
			dfs(i);
		}
	}
	sort(dp,dp+n+1);
	cout<<dp[n];
}

Measured memory_bytes: 8832
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
    --a[i];
  }
  vector<bool> used(n, false);
  int ans = 0;
  queue<int> que;
  que.emplace(0);
  while (!que.empty()) {
    int now = que.front(); que.pop();
    if (now == 1) {
      cout << ans << '\n';
      return 0;
    }
    if (used[now]) break;
    used[now] = true;
    ++ans;
    que.emplace(a[now]);
  }
  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

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


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int a[10005],c[105][105];

int main()
{
    int h,w,i,j,k,m,n;
    while(cin>>h>>w)
    {
        cin>>n;
        for(i=1;i<=n;i++)
            cin>>a[i];
        k=1;
        int b=1,s=0;
        for(i=1;i<=n;i++)
        {
            j=b;
            while(a[i]--)
            {
                //cout<<j<<' '<<k<<endl;
                c[j][k]=i;
                if(s%2==0) j++;
                else j--;
                if(j>h){k++;j--;s++;}
                if(j<=0){k++;j++;s++;}
            }
            b=j;
        }
        //endl(cout);
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++)
                cout<<c[i][j]<<' ';
            endl(cout);
        }
    }
    return 0;
}


Measured memory_bytes: 384
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int main(){

    int N, K, C, i,k;
    string S;
    cin >> N >> K >> C;
    cin >> S;
    
    int normal[200000]={0};
    int reverse[200000]={0};
      
    int cnt=1;
    for(i=0;i<N;){
        if(S[i]=='x'){
            i++;
            continue;
        }else{
            normal[i] = cnt;
            i+=C+1;
            cnt++;
            
        }
        if(cnt == K + 1)
            break;
    }
    cnt=K;
    for(i=N-1;i>=0;){
        if(S[i]=='x'){
            i--;
            continue;
        }else{
            reverse[i] = cnt;
            i = i - (C+1);
            cnt--;
            
        }
        if(cnt == 0)
            break;
    }

    for(i=0;i<N;i++){
        if(normal[i]==0 || reverse[i] == 0)
            continue;
        if(normal[i] == reverse[i])
            cout << i+1 << endl;
    }

    
}


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

int main(){
	constexpr int mod = 1e9 + 7;
	int n;
	cin >> n;
	long long ans = 1;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x < 2 * i + 1){
			(ans *= i + 1) %= mod;
			n--;
			i--;
		}
	}
	for(int i = 1; i <= n; i++) (ans *= i) %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll n5000cho = 5000000000000000;
  string s;
  ll k;
  cin >> s;
  cin >> k;

  ll ans = 1;

  rep(i, 100) {
    if (s.at(i) == '1' and i == k - 1) break;
    if (s.at(i) == '1') continue;
    else {
      ans = s.at(i) - 48;
      break;
    }
  }

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

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll x; cin >> x;
        ll t =x;
        ll ans =1000*(t/500);
        t-= 500*(t/500);
        ans += 5*(t/5);
        t-=(t/5);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

ans = min(P) + min(Q)
for i in range(M):
  x, y, c = map(int, input().split())
  ans = min(ans, P[x-1]+Q[y-1]-c)
print(ans)

Measured memory_bytes: 24764
def main():
    input() #n
    a = list(map(int, input().split()))
    prod = 1

    if 0 in a:
        print(0)
        return
    for i in a:
        prod *= i
        if prod > 1e+18:
            print(-1)
            break
    else:
        print(prod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21780
n = int(input())
a = list(map(int, input().split()))
ans1 = max(a)
a.remove(ans1)
ans2 = a[0]
t = ans1 // 2
for i in range(n - 1):
    if abs(t - ans2) > abs(t - a[i]):
        ans2 = a[i]
print(ans1, ans2)

Measured memory_bytes: 14428
h, w = map(int, input().split())
s = [list('.'*(w+2))]
for i in range(h):
    s.append(list('.' + input() + '.'))
s.append(list('.'*(w+2)))

def search(y, x):
    t = 0
    for i in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        dy, dx = y + i[0], x + i[1]
        if s[dy][dx] == '#':
            t += 1
    if t > 0:
        return True
    else:
        return False


for i in range(w):
    for j in range(h):
        if s[j+1][i+1] == '#' and not search(j+1, i+1):
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<cmath>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*(long double)sqrt((long double)a*b)<c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import io.StdIn

object Main extends App {
  val n = StdIn.readInt
  val seq = StdIn.readLine.split(" ").map(_.toInt % 3)
  val a = for(i <- 0 until 3) yield seq.count(_ == i)

  @tailrec
  def rec(acc:Int, hasMany:Int, c0:Int, c1:Int, c2:Int):Int = {
    if(hasMany == 0) acc
    else {
      if(hasMany == 1) {
        if(c0 != 0) rec(acc+1, 1, c0-1, c1, c2)
        else if(c1 != 0) rec(acc+1, 2, 0, c1-1, c2)
        else if(c2 != 0) rec(acc+1, 0, c0, c1, c2-1)
        else acc
      }
      else {
        if(c0 != 0) rec(acc+1, 2, c0-1, c1 ,c2)
        else if(c2 != 0) rec(acc+1, 1, c0, c1, c2-1)
        else if(c1 != 0) rec(acc+1, 0, c0, c1-1, c2)
        else acc
      }
    }
  }

  val res1 = if(a(1) == 0) 0 else rec(1,1,a(0),a(1)-1,a(2))
  val res2 = if(a(2) == 0) 0 else rec(1,2,a(0),a(1),a(2)-1)
  val ans = if(a.drop(1).sum == 0) 1 else math.max(res1,res2)
  println(ans)
}



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

using namespace std;

int main(){
    char S;
    char Ans;
    cin >> S;
    if(S == 'A'){
        Ans = 'T';
    }else if(S == 'T'){
        Ans = 'A';
    }else if(S == 'C'){
        Ans = 'G';
    }else{
        Ans = 'C';
    }
    cout << Ans << endl;
}

Measured memory_bytes: 256
def main():

        var = list(map(int, input().split()))

        if 1 not in var:
                ans = 1
        elif 2 not in var:
                ans = 2
        elif 3 not in var:
                ans = 3
        elif 4 not in var:
                ans = 4
        else:
                ans = 5

        return ans

if __name__=="__main__":
        ans = main()
        print(ans)

Measured memory_bytes: 9184
#include<stdio.h>
#include<time.h>

int main(){

	int i,j,month,day,tmp,year,idx;
	char s[7][20]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

	while(scanf("%d %d",&month,&day)!=EOF){
		year=2490;
		if(month==0) break;
		if(month==1 || month==2){
			month+=12;
			year=2488;
		}
		tmp=(year+((13*month+8)/5)+day)%7;

		printf("%s\n",s[tmp]);


	}





	return 0;

}

Measured memory_bytes: 584
#!/usr/bin/perl

# 全て数値化して読む
my ($q,$h,$s,$d) = map {$_ - 0} split(/\s+/o,<STDIN>);
my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);

# 2l  unit price
my $qq = $q * 8;
my $hh = $h * 4;
my $ss = $s * 2;
my $dd = $d;

my $c2 = 0;
if( $dd < $ss and $dd < $hh and $dd < $qq ){
  $c2 = int($n / 2);
  $n -= 2 * $c2;
}

my $c_q, $c_h, $c_s;
if( $ss < $hh and $ss < $qq ){
  $c_s = $n;
} elsif( $hh < $qq ){
  $c_h = $n * 2;
} else {
  $c_q = $n * 4;
}

my $res = $q * $c_q + $h * $c_h + $s * $c_s + $d * $c2;

print "$res\n";

exit(0);


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

int main() {
    int h, w;
    cin >> h >> w;
    char c[110][110], d[220][110];

    //入力
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> c[i][j];
        }
    }

    //高さ2倍
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            d[2 * i - 1][j] = c[i][j];
            d[2 * i][j] = c[i][j];
        }
    }

    //出力
    for (int i = 1; i <= 2 * h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << d[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int dist(string a, string b) {
    int n = a.size();
    int val = 0;
    FOR(n) {
        val += a[i] != b[i];
    }
    return val;
}

void solve() {
    string a, b;
    read(a, b);
    int ans = 1e9;
    FOR(i, a.size() - b.size() + 1) {
        umin(ans, dist(a.substr(i, b.size()), b));
    }
    print(ans);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 3716
//2018.10.06

#include <iostream>
using namespace std;

int main() {

    int n;
    cin >> n;
    int i,j,k;
    int x[n];
    int y[n];
    int h[n];
    int testx,testy,testh;
    for(i=0; i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]!=0){
            testx = x[i];
            testy = y[i];
            testh = h[i];
        }
    }

    int dis1, dis2;
    int ansx, ansy, ansh;
    int cor = 0;

    for(i=0;i<101;i++){
        for(j=0;j<101;j++){
            cor = 0;
            for(k=0;k<n;k++){
                dis1 = abs(i-x[k])+abs(j-y[k]);
                dis2 = abs(i-testx)+abs(j-testy);
                if(h[k]==0){
                    if(dis1-dis2>=testh) cor++;
                }
                else{
                    if(dis1>=dis2){
                        if(dis1-dis2==testh-h[k]) cor++;
                    }
                    else{
                        if(dis2-dis1==h[k]-testh) cor++;
                    }
                }
            }
            if(cor == n){
                ansx = i;
                ansy = j;
                ansh = testh + abs(ansx-testx) + abs(ansy-testy);
                break;
            }
        }
        if(cor == n){
            break;
        }
    }

    cout << ansx << ' ' << ansy << ' ' << ansh << endl;

}


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

int ans=100000000;
void solve(int a,int b,int c){
	ans=min(ans,llabs(a-b)+llabs(c-b));
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	solve(a,b,c);
	solve(a,c,b);
	solve(b,a,c);
	solve(b,c,a);
	solve(c,b,a);
	solve(c,a,b);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

                int N = scan.nextInt();

                int[] buka = new int[N];

                for (int i = 0; i < N-1; i++) {
                	int temp = scan.nextInt();
                	buka[temp-1]++;
                }

                scan.close();

                for (int output: buka) {
                	System.out.println(output);
                }

        }

}

Measured memory_bytes: 61372
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int is_par(string s){
    int n = s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])
            return 0;
    }
    return 1;
}

int main () {
   string s,t,w;
   cin>>s;
   int n = s.size();
   int k = (n-1)/2,m = (n+3)/2;
   //cout<<is_par(s.substr(0,k-1));
   //cout<<s.substr(m-1);

   if(is_par(s)&&is_par(s.substr(0,k))&&is_par(s.substr(m-1)))
       cout<<"Yes";
   else
       cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int N;
    cin >> N;
    cout << (N/10?9:N%10)+(N/1000?900:(N/100?N%1000-99:0))+(N/100000?90000:(N/10000?N%100000-9999:0)) << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    if((i+1) % 2 == 1 && s[i] == 'L'){
      cout << "No" << endl;
      return 0;
    } else if((i+1) % 2 == 0 && s[i] == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

int main(){
	int n;
	int x, y;
	int coun = 0; 
	bool flg = false;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x >> y;
		if (x == y) coun++;
		else coun = 0;
		if (coun == 3) flg = true;
	}
	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
 
vector<P>v[100009];
int n,used[100009];

int dfs(int now,int x){
  used[now]=x;
  r(i,v[now].size()){
    int nex=v[now][i].fi;
    int y=v[now][i].se;
    if(used[nex]!=-1)continue;
    if(y%2){
      dfs(nex,x^1);
    }
    else{
      dfs(nex,x);
    }
  }
}

signed main(){
  memset(used,-1,sizeof(used));
  cin>>n;
  r(i,n-1){
    int a,b,c;
    cin>>a>>b>>c; a--; b--;
    v[a].push_back(P(b,c));
    v[b].push_back(P(a,c));
  }
  dfs(0,0);
  r(i,n)cout<<used[i]<<endl;
}

Measured memory_bytes: 10240
n,x = map(int,input().split())
l = input().split()
for i in range(len(l)):
    l[i] = int(l[i])

d = [0]
for j in range(len(l)):
    d.append(d[-1]+l[j])
# print(type(d[0]))
count = 0
for o in range(len(d)):
    if d[o]<=x:
        count+=1
    else:
        count+=0
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll n;
    ll max = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
    cin >> a[i];
    if(a[max] <= a[i]) {
    max = i;
    }
    }
    ll sum = 0;
    rep(i,n) {
    if(i == max){
    sum += a[i]/2;
    }else {
    sum += a[i];
    }
    }
    cout << sum << endl;
}




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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 1e5 + 5;


int n , m,arr[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
            cin >> arr[i];
    map<int,int> frq;
    long long ans = 0;
    for(int i = 1; i <= n; ++i){
        arr[i] = (arr[i]%m + arr[i - 1]%m)%m;

        ans += (arr[i]==0);
        ans += frq[arr[i]];
        frq[arr[i]]++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
	int N;
  cin >> N;
  int num = N % 10;
  if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9 )
    	cout << "hon" << endl;
  else if (num == 0 || num == 1 || num == 6 || num == 8)
    	cout << "pon" << endl;
  else
    	cout << "bon" << endl;
}

Measured memory_bytes: 3568
#include<stdio.h>
char a[100], b[100];
const int MOD = 1000000007;
int main(){
        int n;
        long long ans = 3;
        scanf("%d%s%s", &n, a, b);
        int i, l;
        if(a[0] == b[0]){
                i = 1;
                l = 1;
        }
        else{
                i = 2;
                ans = 6;
                l = 2;
        }
        for(; i<n; i++){
                if(a[i] == b[i]){
                        if(l==1){
                                ans = ans * 2 % MOD;
                        }
                        l=1;
                }
                else{
                        if(l==1){
                                ans = ans * 2 % MOD;
                        }
                        else{
                                ans = ans * 3ll % MOD;
                        }
                        l = 2;
                        i++;
                }
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 128
n = int(input())

s_dict = {}
max_count = 0
max_words = []

for _ in range(n):
    s = input()
    if s in s_dict:
        s_dict[s] += 1
        count = s_dict[s] + 1
    else:
        s_dict[s] = 1
        count = 1
    if count == max_count:
        max_words.append(s)
    elif count > max_count:
        max_words = [s]
    max_count = max(max_count,count)

max_words.sort()
for word in max_words:
    print(word)

Measured memory_bytes: 33404
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

vector<vector<int>> c(10, vector<int>(10));
vector<int> costs(10, (int)1e9);

int main() {
	int H, W;
	cin >> H >> W;
	

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	bool update = true;
	costs[1] = 0;
	while (update) {
		update = false;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++)
			{
				//i->1よりも、i->j->1のほうが良ければそうする
				if (costs[i] > c[i][j] + costs[j]) {
					costs[i] = c[i][j] + costs[j];
					update = true;
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			int tmp;
			cin >> tmp;
			if (tmp != -1) {
				ans += costs[tmp];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){
  int K;
  cin >> K;
  if(K%2==0){
    cout << K*K/2/2;
  }
  else{
    int x= (K+1)*(K-1)/2/2;
    cout << x;
  }











  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int x1, x2, x3, x4, x5;

    std::cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if (x1 == 0)
    {
        std::cout << 1 << std::endl;
    }
    else if (x2 == 0)
    {
        std::cout << 2 << std::endl;
    }
    else if (x3 == 0)
    {
        std::cout << 3 << std::endl;
    }
    else if (x4 == 0)
    {
        std::cout << 4 << std::endl;
    }
    else if (x5 == 0)
    {
        std::cout << 5 << std::endl;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

/**
 * https://abc047.contest.atcoder.jp/tasks/arc063_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextLong();
		long[] a = new long[N];
		for(int i=0; i<N; i++) a[i] = sc.nextLong();
		sc.close();
		long[] maxDp = new long[N];
		maxDp[N-1] = a[N-1];
		for(int i=N-2; i>=0; i--){
			maxDp[i] = Math.max(a[i], maxDp[i+1]);
		}
		
		long max = Long.MIN_VALUE;
		int count = 0;
		for(int i=0; i<N-1; i++){
			long s = maxDp[i+1]-a[i];
			if(s==max){
				count++;
			}else if(s>max){
				max = s;
				count = 1;
			}
		}
		//long ans = max<=0 ? 0 : Math.min(count, T/2);
		System.out.println(count);

	}

}

Measured memory_bytes: 50944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
const ll INF=1e18,MOD=1e9+7;
int main(){
    int n,x;
    cin>>n>>x; 
    int ans=1,hoge=0;
    vector<int>l(n);
    for(int i=0;i<n;i++){
        int y;
        cin>>y;
        hoge+=y;
        if(hoge<=x)ans++;
    }
    cout<<ans<<endl;

}   


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int i = 0, j = s.size() - 1;
  int ans = 0;
  while (i < j) {
    if (s[i++] != s[j--])
      ans++;
  }
  cout << ans << endl;
}


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

public class Main{


	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{

			String str=reader.readLine();
			String[] str_Array=str.split(" ");

			int a=Integer.parseInt(str_Array[0]);
			int b=Integer.parseInt(str_Array[1]);

			int d=a/b;
			int r=a%b;
			double f=(double)a/b;
			String after=String.format("%.5f", f);

			System.out.println(d+" "+r+" "+after);

			reader.close();
		}catch(IOException e){
			System.out.println("??¨??????:"+e);

		}

	}

}

Measured memory_bytes: 24604
def winrate(wn, wk):
    b = 0
    c = wn
    while c < wk:
        b += 1
        c *= 2
    return 1/2 ** b

n, k = map(int,input().split())
ans = 0
for i in range(1, n+1):
    ans += 1/n * winrate(i, k)
print(ans)


Measured memory_bytes: 2940
x = int(input())

def judge_prime_number(x):
    for i in range(2, int(x ** (1/2)) + 1):
        if x % i == 0:
            return False
    else:
        return True

while True:
    if not judge_prime_number(x):
        x += 1
        continue
    else:
        print(x)
        break

Measured memory_bytes: 9340