akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	N, Q    int
	link    [254321][]int
	vals    [254321]int
	sum     int
	visited [254321]bool
	answers []string = make([]string, 0, 254321)
)

func main() {
	readVariables()
	visit(1, 0)
	for _, v := range vals[1 : N+1] {
		answers = append(answers, strconv.Itoa(v))
	}
	fmt.Println(strings.Join(answers, " "))
}

func readVariables() {
	N, Q = nextInt(), nextInt()
	for i := 0; i < N-1; i++ {
		a, b := nextInt(), nextInt()
		link[a] = append(link[a], b)
		link[b] = append(link[b], a)
	}
	for i := 0; i < Q; i++ {
		p, x := nextInt(), nextInt()
		vals[p] += x
	}

}

func visit(x, s int) {
	s += vals[x]
	vals[x] = s
	visited[x] = true
	for _, w := range link[x] {
		if !visited[w] {
			visit(w, s)
		}
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 55680
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s,d,e;
	cin>>s>>d>>e;
	// ll l=s.length();
	// cout<<l;
	cout<<s[0]<<d[0]<<e[0];
	

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=100;
const int M=6401;
const int Y=6400;
bitset<M*2> dp[N][N];
int n,m;
int a[N][N],b[N][N];
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)scanf("%d",&b[i][j]);
	dp[1][0][Y]=1;dp[0][1][Y]=1;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++){
		int cha=abs(a[i][j]-b[i][j]);
		dp[i][j]|=((dp[i-1][j]<<cha)|(dp[i-1][j]>>cha));
		dp[i][j]|=((dp[i][j-1]<<cha)|(dp[i][j-1]>>cha));
	}
	int ans=inf;
	for(int i=0;i<M*2;i++){
		if(dp[n][m][i])ans=min(ans,abs(i-Y));
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  
  int a_end = a.length() -1;
  int b_end = b.length() -1;

  if ((a[a_end] == b[0]) && (b[b_end] == c[0])) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 998244353;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

int n;
int v[1000][1000];

void solve(vector<int>& elm, int col){
    int m = elm.size();
    if(m == 1)
        return;
    vector<int> a, b;
    for(int i = 0; i < m; ++i)
        (i % 2 ? b : a).push_back(elm[i]);
    for(auto x : a)
        for(auto y : b)
            v[x][y] = col;
    solve(a, col + 1);
    solve(b, col + 1);
}

signed main(){

    cin >> n;
    vector<int> t(n);
    iota(t.begin(), t.end(), 0);
    solve(t, 1);
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j < n; ++j)
            cout << max(v[i][j], v[j][i]) << " \n"[j == n - 1];

}


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

int main() {
  string c;
  cin >> c;
  if (c == "a" || c == "e" || c == "i" || c == "o" || c == "u") {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
ll n,q,c,m;

int find(int u) {return fa[u]==u?u:fa[u]=find(fa[u]);}

int main()
{
    cin>>n>>m>>q;
    for(int i=1; i<=n; i++) fa[i] = i;
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt); p[i].u++; p[i].v++;
        if(p[i].opt==0)
        {
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu!=vv) {fa[uu] = vv;}
        }
    }
    ll huan = 0; c = 0;
    for(int i=1; i<=n; i++) {if(i==find(i)) c++;}
    for(int i=1; i<=q; i++){
        if(p[i].opt==1){
            huan++;
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu==vv) {puts("No"); return 0;}
        }
    }
    ll temp=m-(n-c);
    ll l,r;
    l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(l<=temp&&temp<=r)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int swap_max = max(X, Y);
	int ans = A * X + B * Y;

	for (int i = 1; i <= swap_max; ++i)
	{
		int cost_a = max((A * (X - i)), 0);
		int cost_b = max((B * (Y - i)), 0);
		int c_ans = cost_a + cost_b + (C * i * 2);
		ans = min(ans, c_ans);
	}

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

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

info = [list(map(int,input().split())) for _ in range(n)]

max_value = 0
point = 10**10

for i in range(n):
    if info[i][0] > max_value:
        max_value = info[i][0]
        point = info[i][1]
        
print(max_value + point)

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


using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long x,y;
  cin>>x>>y;
  
  if(y%2==0 && y>=2*x && y<=4*x){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

  return 0;
  
}    

Measured memory_bytes: 3592
import sys

def selection_sort(nums, n):
    cnt = 0
    
    for i in range(n):
        minj = i
        for j in range(i, n):
            if nums[j] < nums[minj]:
                minj = j

        nums[i], nums[minj] = nums[minj], nums[i]
        if i != minj:
            cnt += 1

    print(' '.join([str(i) for i in nums]))
    print(cnt)
    
def main():
    n = int(sys.stdin.readline().strip())
    data = sys.stdin.readline().strip().split(' ')
    nums = [int(i) for i in data]
    selection_sort(nums, n)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 7772
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << endl;
    return 0;
}


Measured memory_bytes: 256
// AtCoder Grand Contest 049
// A - 居合を終え、青い絵を覆う / UOIAUAI
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

ll dp[1000002][4];
const ll MOD = 1e9+7;
int main()
{
	dp[0][0]=8;
	dp[0][1] = dp[0][2]=1;
	int n;
	cin >> n;
	for(int i = 0;i<n-1;i++)
	{

		(dp[i+1][0] += dp[i][0]*8)%=MOD;
		(dp[i+1][1] += dp[i][0]*1)%=MOD;
		(dp[i+1][2] += dp[i][0]*1)%=MOD;

		(dp[i+1][3] += dp[i][1]*1)%=MOD;
		(dp[i+1][1] += dp[i][1]*9)%=MOD;

		(dp[i+1][3] += dp[i][2]*1)%=MOD;
		(dp[i+1][2] += dp[i][2]*9)%=MOD;
		
		(dp[i+1][3] += dp[i][3]*10)%=MOD;
	}
	cout<<dp[n-1][3]<<endl;
}


Measured memory_bytes: 34692
n, a = gets.to_s.split.map{|t|t.to_i}
x    = gets.to_s.split.map{|t|t.to_i}.map{|t|t-a}.sort.reverse

h = Hash.new(0)
h[0] = 1
x.each do |t|
  s = h.dup
  h.each do |(k,v)|
    next if k+t < 0
    s[k+t] += v
  end
  h = s.dup
end

puts h[0] - 1

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    if(k&1):
        s=n//k
        print(s**3)
    else:
        s=n//k
        t=(n+k//2)//k
        print(s**3+t**3)
resolve()

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

using namespace std;

typedef long long int lli;

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

    int n, m, a, b;
    priority_queue<pair<int, int>> ng, ok;

    cin >> n >> m;
    for (int i=0; i<n; i++) {
        cin >> a >> b;
        ng.push(make_pair(-a, b));
    }

    int ans = 0;
    for (int i=1; i<=m; i++) {
        // cout << i << endl;
        while (!ng.empty() && -ng.top().first <= i) {
            int aa = -ng.top().first, bb = ng.top().second; ng.pop();
            // cout << aa << " " << bb << endl;
            ok.push(make_pair(bb, aa));
        }

        if (ok.empty()) continue;

        int bx = ok.top().first; ok.pop();
        ans += bx;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;
template<int64_t mod> struct GF {
	typedef int64_t T;
	T v;
	GF() = default;
	GF(T v) : v((v % mod + mod) % mod) {}
	GF & operator+=(GF x) { v = (v + x.v) % mod; return *this; }
	GF & operator*=(GF x) { v = (v * x.v) % mod; return *this; }
	GF & operator-=(GF x) { v = (v - x.v + mod) % mod; return *this; }
	GF & operator/=(GF x) { return (*this) *= x.inverse(); }
	GF operator+(GF rhs) const { GF lhs = *this; return lhs += rhs; }
	GF operator*(GF rhs) const { GF lhs = *this; return lhs *= rhs; }
	GF operator-(GF rhs) const { GF lhs = *this; return lhs -= rhs; }
	GF operator/(GF rhs) const { GF lhs = *this; return lhs /= rhs; }
	GF inverse() const { // http://topcoder.g.hatena.ne.jp/iwiwi/20130105/1357363348
		T a = v, b = mod, x = 1, y = 0;
		while (b) {
			T t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return x;
	}
	GF pow(T n) const {
		GF r; r.v = 1;
		for (T x = v; n > 0; n >>= 1) {
			if (n & 1) (r.v *= x) %= mod;
			(x *= x) %= mod;
		}
		return r;
	}
	typedef size_t U;
	static GF fact(U n) {
		static vector<GF> data;
		U m = data.size();
		if (m <= n) {
			data.resize(n + 1);
			if (m == 0) { data[0].v = 1; m++; }
			for (U i = m; i < n + 1; ++i) data[i] = data[i - 1] * i;
		}
		return data[n];
	}
	static GF nCr(U n, U r) { return fact(n) / fact(r) / fact(n - r); }
	static GF nPr(U n, U r) { return fact(n) / fact(r); }
};

struct PrimeFactor { uint64_t p, e; }; // p^e
vector<PrimeFactor> prime_factors(uint64_t n) {
	vector<PrimeFactor> p;
	for (uint64_t i = 2, c; i * i <= n; i++) {
		if (n % i == 0) {
			c = 0;
			while (n % i == 0) c++, n /= i;
			p.push_back({ i, c });
		}
	}
	if (n > 1) p.push_back({ n, 1 });
	return p;
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, a, b; cin >> n >> a >> b;
	vl x(n); REP(i, n) cin >> x[i];
	ll sum = 0;
	FOR(i, 1, n) {
		sum += min((x[i] - x[i-1]) * a, b);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int k ;
    cin >> k ;
    vector<bool> p(k,0) ;
    int64_t num = 0 ;
    for (int i = 0; i < k; i++)
    {
        num = num * 10 + 7 ;
        num %= k ;
        if (num == 0)
        {
            cout << i + 1 << endl ;
            return 0 ;
        }else
        {
            if (p.at(num) == 1)
            {
                cout << -1 << endl ;
                return 0 ;
            }else
            {
                p.at(num) = 1 ;
            }
            
            
        }
        
        
    }
    
    
}

Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	string res = "XXX";
	res[0] = toupper(s1[0]);
	res[1] = toupper(s2[0]);
	res[2] = toupper(s3[0]);
	cout << res << endl;

	return 0;
}

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

int ball[200005], cnt[200005];
int covered[200005];
int main(){
  ios_base :: sync_with_stdio(false);

  int n, q;
  cin >> n >> q;
  for(int i=1; i<=n; i++){
    cin >> ball[i];
    cnt[ball[i]]++;
  }

  for(int i=1; i<=n; i++){
    for(int j=max(i-cnt[i]+1, 1); j<=i; j++){
      covered[j]++;
    }
  }

  int ans = 0;
  for(int i=1; i<=n; i++) ans += (covered[i] == 0);

  while(q--){
    int idx, num;
    cin >> idx >> num;

    int b = ball[idx];
    if(b - cnt[b] + 1 > 0){
      covered[b - cnt[b] + 1]--;
      if(covered[b - cnt[b] + 1] == 0) ans++;
    }
    cnt[b]--;

    if(num - cnt[num] > 0){
      covered[num - cnt[num]]++;
      if(covered[num - cnt[num]] == 1) ans--;
    }
    cnt[num]++;
    ball[idx] = num;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5984
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,W;
ll w[101],v[100001];
ll dp[101][100001];
ll solve(ll ind,ll val){
  if(ind>n){
    return 0;
  }
  if(dp[ind][val]!=-1){
    return dp[ind][val];
  }
  ll ans=solve(ind+1,val);
  if((w[ind]+val)<=W){
    ans=max(ans,v[ind]+solve(ind+1,val+w[ind]));
  }
  dp[ind][val]=ans;
  return ans;
}
int main(){
  ll i;
  cin>>n>>W;
  for(i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }
  memset(dp,-1,sizeof(dp));
  cout<<solve(1,0)<<endl;
}


Measured memory_bytes: 79104
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(n: usize, k: usize) -> usize {
    if n == k {
        return 1
    }

    return (n-k) / (k-1) + if (n-k) % (k-1) > 0 {1} else {0} + 1
}

fn main() {
    let (n, k) = parse_line!(usize, usize);
    read_line!();

    println!("{}", solve(n, k));
}

#[test]
fn solve_test() {
    assert_eq!(solve(4,3), 2);
    assert_eq!(solve(3,3), 1);
    assert_eq!(solve(8,3), 4);
}


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

int main() {
  int n;
  long long x, a[101] = {0};
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int res = 0;
  for (res = 0; res < n; res++) {
    x -= a[res];
    if (x < 0) break;
  }
  if (x > 0) res--;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	int n,cnt=0;
	int ans = 0;
	cin>>n;
	vi v(n);
	rep(i, n) {
		cin >> v[i];
		v[i]--;
		if (v[i] == i) {
			cnt++;
		}
		else {
			ans += ((cnt+1)/2);
			cnt = 0;
		}
	}
	ans += ((cnt + 1) / 2);
	cout <<ans<< endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;



int main(){
    int a,b,q;cin >> a >> b >> q;
    vector<LL> s(a),ss,tt,t(b);
    for (int i = 0; i < a; i++) {
        cin >> s[i];
        ss.pb(-s[i]);
    }
    s.pb(LINF);
    s.pb(-LINF);
    ss.pb(LINF);
    ss.pb(-LINF);
    t.pb(LINF);
    t.pb(-LINF);
    tt.pb(LINF);
    tt.pb(-LINF);
    for (int i = 0; i < b; i++) {
        cin >> t[i];
        tt.pb(-t[i]);
    }
    sort(ALL(ss));
    sort(ALL(s));
    sort(ALL(tt));
    sort(ALL(t));
    for (int i = 0; i < q; i++) {
        LL x;cin >> x;
        LL ans=LINF;
        LL xa=-*lower_bound(ALL(ss),-x);
        LL tmp=abs(xa-x);
        ans=min(ans,tmp+min(abs(xa+*lower_bound(ALL(tt),-xa)),abs(*lower_bound(ALL(t),xa)-xa)));

        xa=*lower_bound(ALL(s),x);
        tmp=abs(xa-x);
        ans=min(ans,tmp+min(abs(xa+*lower_bound(ALL(tt),-xa)),abs(*lower_bound(ALL(t),xa)-xa)));
        xa=-*lower_bound(ALL(tt),-x);
        tmp=abs(xa-x);
        ans=min(ans,tmp+min(abs(xa+*lower_bound(ALL(ss),-xa)),abs(*lower_bound(ALL(s),xa)-xa)));

        xa=*lower_bound(ALL(t),x);
        tmp=abs(xa-x);
        ans=min(ans,tmp+min(abs(xa+*lower_bound(ALL(ss),-xa)),abs(*lower_bound(ALL(s),xa)-xa)));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5460
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
const int MAXN=1e5+10;
long long n,a[MAXN],b[MAXN];
long long x[MAXN];
int main()
{
	cin>>n;
	long long cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		//cnt-=a[i];
	}
	memset(x,0,sizeof(x));
	for(int i=n-1;i>=0;i--)
	{
		x[i]+=x[i+1];
		a[i]+=x[i];
		long long cur=((((a[i]+b[i]-1)/b[i])*b[i])-a[i]);
		x[i]+=cur;
		//cnt+=cur;
		//cout<<cnt<<endl;
	}
	cout<<x[0]<<endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#define MAX_n 200000
int max(int,int);
int min(int,int);
int main(void){
    int R[MAX_n],n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&R[i]);
        
        int maxv=-2000000000;
        int minv=R[0];
        
        for(int i=1;i<n;i++){
            maxv=max(maxv,R[i]-minv);
            minv=min(minv,R[i]);
        }
   printf("%d\n",maxv);
    return 0;
}
int max(int a,int b){
    return a>b ? a: b;
}
int min(int a,int b){
    return a<b ? a: b;
}


Measured memory_bytes: 2552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll B[200];

int main(){
    for(ll i = 0; i < 200; i++)B[i] = 1145141919;
    ll N;
    cin >> N;
    for(ll i = 1; i < N; i++){
        cin >> B[i];
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void){
  int n,k;
  while(cin>>n>>k,n||k){
    int ans = -10001;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<k;++i)sum+=a[i];
    for(int i=0;i<n-k;++i){
      if(sum>ans)ans=sum;
      sum-=a[i];
      sum+=a[i+k];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1532
def InputData():
    
    sequence_len = int(input())
    sequence = [None] + [int(a) for a in input().split(" ")]

    return sequence_len, sequence

def countingSort(sequence, k, sequence_len):
    
    B = [None]*(sequence_len+1)
    C = [0]*k
    
    for j in range(1, sequence_len+1):
        C[sequence[j]] += 1
    
    for i in range(1, k):
        C[i] = C[i] + C[i-1]
    
    for j in range(sequence_len, 0, -1):
        B[C[sequence[j]]] = sequence[j]
        C[sequence[j]] -= 1

    return B

def PrintOut(sequence):
    print(' '.join( map(str, sequence)))

def main():
    [sequence_len, sequence] = InputData()
    sequence_out = countingSort(sequence, 10000, sequence_len)
    PrintOut(sequence_out[1:])

if __name__=="__main__":
    main()


Measured memory_bytes: 256220
n, k = map(int, input().split())
p = list(map(int, input().split()))
#n(n+1)/2 / n
sums = 0
for i in range(k):
    sums += p[i]
maxi = sums
for i in range(k, n):
    sums += p[i]
    sums -= p[i-k]
    if sums > maxi:
        maxi = sums
print((maxi+k)/2)


Measured memory_bytes: 71792
n, k = [int(v) for v in input().split()]
s = input()

x = 0
y = 0
if s[0] == 'L':
    y += 1
if s[-1] == 'R':
    y += 1

ans = 0
for i in range(n-1):
    ad = s[i:i+2]
    if ad == 'RL':
        x += 1
    if ad == 'LL' or ad == 'RR':
        ans += 1

while k > 0 and x > 1:
    ans += 2
    x -= 1
    k -= 1
if k > 0 and x == 1:
    if y == 0:
        ans += 1
    else:
        ans += 2
    k -= 1
if k > 0 and y == 2:
    ans += 1

print(ans)


Measured memory_bytes: 3316
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vector<string> a;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    a = vector<string>(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    solve();
}

// 2 ≤ N ≤ 500
// a_{ij} は . または # である。

// ll N, vector<string> a
// すべてのマスを黒にすることが可能ならば、必要な操作回数の最小値を出力せよ。不可能ならば、代わりに -1 を出力せよ。
void solve(){
    bool ng=true;
    rep(i,N)rep(j,N)ng&=a[i][j]=='.';
    if(ng){
        cout<<-1<<endl;
        return;
    }

    vl row_cnt(N),col_cnt(N);
    rep(i,N)rep(j,N){
        row_cnt[i]+=a[i][j]=='#';
        col_cnt[j]+=a[i][j]=='#';
    }

    ll row_cost=N;
    rep(i,N)chmin(row_cost,N-row_cnt[i]+!col_cnt[i]);

    ll ans=row_cost+N;
    rep(i,N)ans-=col_cnt[i]==N;
    cout<<ans<<endl;
}


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



 
int main(){
    int A,B;
    cin >> A >> B;
    if(A>12){
        cout << B << endl;
    }
    else if(A<=12 && A>5){
        cout << B/2 << endl;
    }
    else {
        cout << 0 << endl;
    }


}

Measured memory_bytes: 256
from math import sqrt
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

cnt = 0
for i in range(n):
    for j in range(i+1, n):
        dis = sum([(y-z)**2 for y, z in zip(x[i], x[j])])
        if sqrt(dis).is_integer():
            cnt += 1

print(cnt)


Measured memory_bytes: 3060
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
print("A" + chr(ord('B') ^ ord('R') ^ ord(s[1])) + "C")

Measured memory_bytes: 9020
using System;
    using System.Linq;
    using System.Collections.Generic;
    using static System.Math;
 
 
    public class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string answer = "No";

            if (s == t) answer = "Yes";
            else
            {
                for(int i = 0; i < s.Length; i++)
                {
                    string x = s.Substring(0, 1);
                    s = s.Remove(0, 1) + x;

                    if(s == t)
                    {
                        answer = "Yes";
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }

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

using namespace std;

int main() {
    string N;
    cin >> N;

    int tmp = 0;
    for (int i = 0; i < N.size(); ++i) {
        tmp += N[i] - '0';
    }

    if (tmp % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3756
n = int(input())
p = list(map(int,input().split()))
n_l = list(range(1,n + 1))
count = 0
for n_num , p_num in zip(n_l,p):
  if n_num != p_num:
    count += 1
if count == 2 or count == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9084
from heapq import heappop, heappush, heapify

n = int(input())
al = list(map(int, input().split()))

ll = al[0:n]
cl = al[n:2*n]
rl = al[2*n:3*n]
rl = list(map(lambda x: -x, rl))


heapify(ll)
heapify(rl)

ll_vals = []
ll_vals.append(sum(ll))
c_sum = sum(ll)
c_max = c_sum
for i in range(n):
    poped = heappop(ll)
    c_sum -= poped
    heappush(ll,cl[i])
    c_sum += cl[i]
    c_max = max(c_max, c_sum)
    ll_vals.append(c_max)


rl_vals = []
rl_vals.append(-sum(rl))
c_sum = -sum(rl)
c_min = c_sum
for i in range(n):
    poped = -heappop(rl)
    c_sum -= poped
    heappush(rl,-cl[n-1-i])
    c_sum += cl[n-1-i]
    c_min = min(c_min, c_sum)
    rl_vals.append(c_min)


ans = -1*(10**18)
for i in range(n+1):
    v = ll_vals[i] - rl_vals[n-i]
    ans = max(ans,v)

print(ans)

Measured memory_bytes: 117112
=begin
N<=10^3
M<=2*10^3
abs(c)<=10^9
maximize score
=end

Edge=Struct.new(:a, :b, :c)

n, m=gets.split.map(&:to_i)
edges=[]
m.times do
  a, b, c=gets.split.map(&:to_i)
  edges << Edge.new(a-1, b-1, -c)
end

inf=10**18
d=Array.new(n){inf}
d[0]=0
(n-1).times do |nn|
  edges.each do |e|
    if d[e.a]!=inf and d[e.a]+e.c<d[e.b]
      d[e.b]=d[e.a]+e.c
    end
  end
end

ans=(-1)*d[n-1]

n.times do |nn|
  edges.each do |e|
    if d[e.a]!=inf and d[e.a]+e.c<d[e.b]
      d[e.b]=d[e.a]+e.c
    end
  end
end

puts ans<-d[n-1] ? 'inf' : ans


Measured memory_bytes: 2172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<char>[] L = new List<char>[K];
		for(int i=0;i<K;i++) L[i] = new List<char>();
		for(int i=0;i<N;i++){
			L[i % K].Add(T[i]);
		}
		long tot = 0;
		for(int i=0;i<K;i++){
			tot += calc(L[i]);
		}
		Console.WriteLine(tot);
		
		
	}
	
	long calc(List<char> L){
		
		long[] dp = new long[3];
		for(int i=0;i<L.Count;i++){
			var ndp = new long[3];
			//r,s,p r > s > p > r
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(j == k) continue;
					if(L[i] == 'r' && k == 2){
						ndp[k] = Math.Max(ndp[k], dp[j] + P);
					} else if(L[i] == 's' && k == 0){
						ndp[k] = Math.Max(ndp[k], dp[j] + R);
					} else if(L[i] == 'p' && k == 1){
						ndp[k] = Math.Max(ndp[k], dp[j] + S);
					} else {
						ndp[k] = Math.Max(ndp[k], dp[j]);
					}
				}
			}
			dp = ndp;
		}
		return dp.Max();
	}
	
	
	
	int N, K;
	long R,S,P;
	String T;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		d = ria();
		R = d[0]; S = d[1]; P = d[2];
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

  ll n, k;
  cin >> n >> k;
  ll a[n];
  for(int i=0; i<n;i++)
    cin >> a[i];

  for(ll i=k; i<n; i++){
    if(a[i] > a[i-k])
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 5208
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];

		for ( int i=0; i<n; i++ ) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);

		int t = 0;
		for ( int i=0; i<k; i++ ) {
			t += p[i];
		}

		System.out.println(t);
	}
}


Measured memory_bytes: 38844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  map<int ,bool> AC;
  map<int ,int> WA;
  cin >> n >> m;
  for (int i = 0; i < m; i++){
    int no;
    string res;   
    cin >> no >> res;
    if (res == "AC") {
      AC[no] = 1;
    } else {
      if (!AC.count(no)) {
        WA[no]++;
      }
    }
  }
  int ac, wa;
  ac = wa = 0;
  for(auto m: AC){
    int p;
    p = m.second;
    ac += p;
  }
  for(auto m: WA){
    if (AC[m.first] == 1) {
      wa += m.second;
    }
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 9452
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

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)*}};}
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)*}};}
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:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: [[usize;3];3],
        n: usize,
        b: [usize;n]
    }

    let mut bingo = [[false; 3]; 3];

    let check: Vec<Vec<(usize, usize)>> = vec![
        // 横
        vec![(0, 0), (0, 1), (0, 2)],
        vec![(1, 0), (1, 1), (1, 2)],
        vec![(2, 0), (2, 1), (2, 2)],
        // 縦
        vec![(0, 0), (1, 0), (2, 0)],
        vec![(0, 1), (1, 1), (2, 1)],
        vec![(0, 2), (1, 2), (2, 2)],
        // ナナメ
        vec![(0, 0), (1, 1), (2, 2)],
        vec![(2, 0), (1, 1), (0, 2)],
    ];

    let mut ok = false;
    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if b[i] == a[j][k] {
                    bingo[j][k] = true;
                }
            }
        }

        for cs in &check {
            let mut allok = true;
            for c in cs {
                if bingo[c.0][c.1] == false {
                    allok = false
                }
            }

            if allok {
                ok = true;
                break;
            }
        }
    }

    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

const long double e = 0.0000001;

long double f(long double x1,long double y1,long double x2,long double y2,long double X){
    return (y1*(x2-X)+y2*(X-x1))/(x2-x1);
}

int main(){
    while(1){
        int m;
        long double x[102],y[102];
        scanf("%d",&m);
        if(m == 0)break;
        for(int i = 0 ; i < m ; i ++){
            scanf("%Lf%Lf",&x[i],&y[i]);
        }
        x[m] = x[0];
        y[m] = y[0];
        
        int ret = 0;
        for(long double _X = -2000.0 ; _X < 2000.0 ; _X += 1.0){
        //for(long double _X = -7.0 ; _X < 5.0 ; _X += 1.0){
            vector<long double> Y[2];
            long double X[2] = { _X+e , _X+1.0-e };
            for(int i = 0 ; i < m ; i ++){
                for(int j = 0 ; j < 2 ; j ++){
                    if((x[i]-X[j])*(x[i+1]-X[j]) < 0){
                        Y[j].push_back(2500.0+f(x[i],y[i],x[i+1],y[i+1],X[j]));
                    }
                }
            }
            sort(Y[0].begin(),Y[0].end());
            sort(Y[1].begin(),Y[1].end());
            int a[5002] = {};
            /*if(Y[0].size()%2 != 0){
                puts("ERROR1");
                return 0;
            }
            if(Y[0].size() != Y[1].size()){
                puts("ERROR2");
                return 0;
            }*/
            for(int i = 0 ; i < Y[0].size() ; i += 2){
                long double l = min(Y[0][i],Y[1][i]), r = max(Y[0][i+1],Y[1][i+1]);
                //cout.precision(20);
                //cout << l << " " << r << endl;
                if((int)(l+e*e) <= (int)(r+1.0-e*e)){
                    a[(int)(l+e*e)] ++;
                    a[(int)(r+1.0-e*e)] --;
                }
            }
            //int cnt = 0;
            for(int i = 1 ; i < 5002 ; i ++){
                a[i] += a[i-1];
                if(a[i] > 0){
                    //cnt ++;
                    ret ++;
                }
            }
            /*if(cnt != 0){
                printf("%Lf %d%c",_X,cnt,10);
                break;
            }*/
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b;cin>>a>>b;
  if(a%2!=0&&b%2!=0){
    cout<<"Odd"<<endl;
  }else{
    cout<<"Even"<<endl;
  }

}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        String S = input.next();

        if (N%2 ==0){
            if (S.substring(0,N/2).equals(S.substring(N/2,N))){
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n;cin>>n;
    int j=1;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> hoge(n);
    rep(i,n){
        cin>>A[i];
        hoge[i]=i+1;
    }
    rep(i,n){
        cin>>B[i];
    }
    int l,r;
    do{
        if(equal(A.cbegin(), A.cend(), hoge.cbegin()))l=j;
        if(equal(B.cbegin(), B.cend(), hoge.cbegin()))r=j;
        j++;
    }while(next_permutation(ALL(hoge)));
    cout<<abs(l-r);
    return 0;
}


Measured memory_bytes: 3640
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

#define N 100005
bool isprime[N] = {0};
int prime[N], pcnt;

int n, m, k[N], kcnt, a[N];
set<int> yz;

void Euler(){
    int i, j;
    memset(isprime, 1, sizeof(isprime));
    pcnt = 0;
    for(i = 2; i < N; i++){
        if(isprime[i])
            prime[pcnt++] = i;
        for(j = 0; j < pcnt && prime[j] * i < N; j++){
            isprime[prime[j]*i] = 0;
            if(i%prime[j] == 0)
                break;
        }
    }
}

int powi(int x, int y){
    int t = 1;
    while(y > 0){
        t*=x;
        y--;
    }
    return t;
}

void dfs(int dep, int now){
    if(dep > kcnt){
        yz.insert(now);
        return;
    }
    int i;
    for(i = 0; i <= k[dep]; i++){
        dfs(dep+1, now*powi(a[dep], i));
    }
}

int main(){
    Euler();
    int i;
    while(scanf("%d%d", &n, &m)!=EOF){
        int t = m;
        yz.clear();
        kcnt = 0;
        i = 0;
        while(m>1 && i<pcnt){
            if(m%prime[i]==0){
                ++kcnt, k[kcnt]=0, a[kcnt] = prime[i];
                while(m%prime[i]==0)
                    m/=prime[i], k[kcnt]++;
            }
            ++i;
        }
        if(m > 1)
            k[++kcnt] = 1, a[kcnt] = m;
        dfs(1, 1);
        set<int>::iterator it = yz.lower_bound(n);

        printf("%d\n", t/(*it));
    }

    return 0;
}

Measured memory_bytes: 384
from math import sqrt,gcd,ceil 
def ii():return int(input())
def mi():return map(float,input().split())
def li():return list(mi())
def si():return input()

n=ii()
ans=0
for i in range(2,int(sqrt(n))+1):
    f=0
    while(n%i==0):
        n//=i
        f+=1
    c=1
    c1=1
    while(c<=f):
        ans+=1
        c1+=1
        c+=c1
if(n>1):
    ans+=1
print(ans)

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

#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)

using ll = long long;
#define INF 1e9




int main(){
  string S;
  cin >> S;
  vector<string> de = {"dream", "dreamer", "erase", "eraser"};


  REPR(i, S.size()-1){
    bool flag = false;
    REP(j, 4){
      if(i+1 < de[j].size()) continue;
      if(S.substr(i-de[j].size()+1, de[j].size()) == de[j]){
        i-=de[j].size();
        i++;
        flag = true;
        break;
      }
    }
    if(flag == false){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


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

int main(){
    string s;
    cin>>s;
    
    long long ans=0;
    int l=s.size()-1;
    
    for(int i=0;i<(1<<l);++i){
        long long sum=0;
        long long a=s[0]-'0';
        
        for(int j=0;j<l;++j){
            if(i&(1<<j)){
                sum+=a;
                a=0;
            }
            a=a*10+s[j+1]-'0';
        }
        
        sum+=a;
        ans+=sum;
    }
    
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

t = [0 for i in range(N)]
diff = [0 for i in range(N)]

for i in range(N):
  t[i] = T - 0.006*H[i]
  diff[i] = abs(t[i] - A)

print(diff.index(min(diff))+1)

Measured memory_bytes: 3064
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
double n;
void input(){
    cin>>n;
}
void src(){
    double min = ((n  )/1.08);
    double max = ((n+1)/1.08);
    repi(i,ceil(min),floor(max)+1){
        if(i>=min and i<max){cout<<i; return;}
    }
    cout<<":(";
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

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

// i番目に入っている値=証言者
// j番目に入っている値=相手
int g[15][15];

// グラフ化というのを使っているらしい
int main() {
  int n;
  cin >> n;
  // 何も証言していないを-1
  rep(i,n) rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int m;
    cin >> m;
    rep(j,m) {
      int a, x;
      cin >> a >> x;
      --a;
      g[i][a] = x;
    }
  }
  int ans = 0;
  // bit全探索
  // 001010だと1が立っているところを正直者
  // 0のところが不親切な人として全探索
  rep(i,1<<n) {
    std::vector<int> d(n);
    // iのjビット目が1であるかの判定
    rep(j,n) if (i>>j&1) {
      d[j] = 1;
    }
    // 正直者の証言が全て正しいかの判定
    bool ok = true;
    rep (j,n) {
      // 正直者なら証言が全て正しいはずなのでそれを判定
      if (d[j]) {
        rep(k,n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) ok = false;
        }
      }
    }
    // __builtin_popcountは立っているbitの数を数える=正直者の数
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604