akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,rev;
	};
	vector<vector<edge> > g;
	vi iter,level;
	int DFS(int v,int t,int f){
		if(v==t) return f;
		for(int &i=iter[v];i<g[v].size();i++){
			edge &e=g[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				int d=DFS(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	void BFS(int s){
		level=vi(V,-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<g[v].size();i++){
				edge &e=g[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int c=1){
		g[s].push_back(edge{t,c,(int)g[t].size()});
		g[t].push_back(edge{s,0,(int)g[s].size()-1});
	}
	int Dinic(int s,int t){
		int res=0;
		iter=level=vi(V);
		while(1){
			fill(iter.begin(),iter.end(),0);
			fill(level.begin(),level.end(),1);
			BFS(s);
			if(level[t]<0) return res;
			int f;
			while((f=DFS(s,t,inf))>0) res+=f;
		}
	}
};

int n;
vi a[2],b[2];

int f(int id){
	a[id]=b[id]=vi(n,-1);
	for(auto &i:a[id]) cin>>i;
	int I=0;
	for(int i=0;i<n;i++) if(b[id][i]<0){
		int x=i;
		do{
			b[id][x]=I;
			x=a[id][x];
		}while(x!=i);
		I++;
	}
	return I;
}

int main(){
	cin>>n;
	int sa=f(0),sb=f(1),res=n,st=sa+sb,gl=sa+sb+1;
	Network nt(sa+sb+2);
	for(int i=0;i<n;i++){
		if(a[0][i]==i&&a[1][i]==i) res--;
		else if(a[0][i]==i) nt.add_edge(sa+b[1][i],gl);
		else if(a[1][i]==i) nt.add_edge(st,b[0][i]);
		else if(a[0][i]!=a[1][i]) nt.add_edge(sa+b[1][i],b[0][i]);
		else{
			nt.add_edge(sa+b[1][i],b[0][i]);
			nt.add_edge(b[0][i],sa+b[1][i]);
		}
	}
	cout<<res-nt.Dinic(st,gl)<<endl;
}

Measured memory_bytes: 11256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    double a,b,c,n;
    scanf("%lf",&n);
    for(a=1;a<=3500;a++)
    for(b=1;b<=3500;b++)
    {
        c=n*a*b/(4*a*b-n*a-n*b);
        if(c==(long long)c&&c>0)
        {
            printf("%.0lf %.0lf %.0lf\n",a,b,c);
            return 0;
        }
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

vector<vector<int>> G(100009);
int d[100009];

queue<int> bfs(queue<int> now, int c){
    queue<int> nxt;
    
    rep(i,now.size()){
        int u = now.front(); now.pop(); now.push(0);
        rep(v,G[u].size()){
            if(d[G[u][v]]==0){
                d[G[u][v]] = c;
                nxt.push(G[u][v]);
            }
        }
    }
    
    return nxt;
}

int main() {
    int N;
    cin >> N;
    
    rep(i,N){
        int s, t; scnd2(s,t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    queue<int> fennec,snuke;
    fennec.push(1);
    snuke.push(N);
    
    d[1] = 1;
    d[N] = N;
    while( !fennec.empty() || !snuke.empty() ){
        
        fennec = bfs(fennec,1);
        snuke = bfs(snuke,N);
        
    }
    
    int F=0,S=0;
    rep1(i,N){
        if(d[i]==1)F++;
        else S++;
    }
    
    if(F>S){
        cout1("Fennec");
    }else{
        cout1("Snuke");
    }
}


Measured memory_bytes: 6400
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	m := n + 2

	a := make([]int, m)
	a[0] = 0

	for i := 1; i <= n; i++ {
		a[i] = readInt()
	}
	a[n+1] = 0

	var sum int
	for i := 1; i < m; i++ {
		sum += absInt(a[i] - a[i-1])
	}

	for i := 1; i <= n; i++ {
		println(sum - (absInt(a[i]-a[i-1]) + absInt(a[i+1]-a[i])) + absInt(a[i+1]-a[i-1]))
	}

}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 3712
package main

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

var sc *bufio.Scanner

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		a, b := nextInt(), nextInt()
		if a == 0 && b == 0 {
			break
		}
		for i := 0; i < a; i++ {
			for j := 0; j < b; j++ {
				fmt.Print("#")
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}



Measured memory_bytes: 1116
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args){
      int N = int.Parse(Console.ReadLine());
      int bt=0,bx=0,by=0;
      bool b = true;
      for(int i=0;i<N;i++){
        string[] s = Console.ReadLine().Split(' ');
        int t = int.Parse(s[0]);
        int x = int.Parse(s[1]);
        int y = int.Parse(s[2]);

        int cost = Math.Abs(bx-x)+Math.Abs(by-y);
        if(cost > t-bt || (t-bt-cost)%2==1) b = false;

        bt = t;
        bx = x;
        by = y;
      }

      if(b){
        Console.Write("Yes");
      } else {
        Console.Write("No");
      }
    }
  }


Measured memory_bytes: 15288
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int mins = 0;

    for(int i = 0; i < n; i++)
    {
      if(nums[i] == mins+1) mins++;
    }
    
    if(mins != 0) Console.WriteLine(n -mins);
		else Console.WriteLine(-1);
	}
}

Measured memory_bytes: 34780
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
typedef pair<int,int> II;
typedef pair<double,int> DI;
int main(void){
    string s;
    int n,i,j;
    cin>>n>>s;
    for(i=0;i<s.length();i++){
        s[i]+=n;
        if(s[i]>90)s[i]-=26;
    }
    cout<<s;
}

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

using namespace std;

long long ito357(long long n) {
    int ch[4] = {0, 3, 5, 7};
    long long ans = 0;
    int i = 0;
    while (n > 0) {
        long long f = ch[n % 4];
        for (int j = 0; j < i; j++) f *= 10;
        ans += f;
        i++;
        n /= 4;
    }
    return ans;
}

bool is_valid(long long n357) {
    if (n357 < 357) return false;
    string s = to_string(n357);
    bool v[3] = {false, false, false};
    for (char &c : s) {
        if (c == '3')
            v[0] = true;
        else if (c == '5')
            v[1] = true;
        else if (c == '7')
            v[2] = true;
        else
            return false;
    }
    return v[0] && v[1] && v[2];
}

int main() {
    
    long long n;
    cin >> n;
    
    if (n < 357) {
        cout << 0 << endl;
        return 0;
    }
    
    long long ans = 0;
    for (int i = 0; ; i++) {
        long long n357 = ito357(i);
        if (n < n357) break;
        if (!is_valid(n357)) continue;
        ans++;
    }
    
    cout << ans << endl;
    
}

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

ans = sum(B)
for i in range(1, N):
    if A[i] - A[i - 1] == 1:
        ans += C[A[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064
import sys
n, k = map(int, input().split())
A = list(map(int, input().split()))
flags = [False] * n
steps = [0] * n
next_place = 1
step = 0
if k <= n:
    for i in range(k):
        next_place = A[next_place - 1]
    print(next_place)
    sys.exit(0)
for i in range(n):
    step += 1
    next_place = A[next_place - 1]
    if flags[next_place - 1]:
        ## 循環
        loop_start = steps[next_place - 1]
        loop_length = step - loop_start
        break
    else:
        flags[next_place - 1] = True
        steps[next_place - 1] = step
iteration = (k - loop_start) % loop_length
for i in range(iteration):
    next_place = A[next_place - 1]
print(next_place)


Measured memory_bytes: 32372
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N;
  cin>>N;
  cout<<N/3<<endl;
  return 0;
}


Measured memory_bytes: 256
void main(){
	int n = _scan(); // 操作を行う回数
	int k = _scan(); // 足す値
	int ans = 1;
	foreach(elm; 0..n){
		if(ans*2 < ans+k)ans *=2;
		else ans +=k;
	}
	writeln(ans);
	
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2684
#include <iostream>
using namespace std;
int main(void)
{
	int a[4], i, flag=0;
	char s[6];

	cin>>s;

	for(i=0; i<4; i++){
		a[i]=(int)(s[i]-'0');
	}

	if(a[0]+a[1]+a[2]+a[3]==7){
		cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	}else if(a[0]-a[1]+a[2]+a[3]==7){
		cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	}else if(a[0]+a[1]-a[2]+a[3]==7){
		cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	}else if(a[0]+a[1]+a[2]-a[3]==7){
		cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	}else if(a[0]-a[1]-a[2]+a[3]==7){
		cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	}else if(a[0]+a[1]-a[2]-a[3]==7){
		cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	}else if(a[0]-a[1]+a[2]-a[3]==7){
		cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	}else if(a[0]-a[1]-a[2]-a[3]==7){
		cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	}
}

Measured memory_bytes: 256
import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for j in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)

Measured memory_bytes: 27176
N = gets.chomp.to_i
im = Hash.new(0)
jm = Hash.new(0)
gets.chomp.split(" ").each_with_index do |v, i|
  a = v.to_i
  im[i+1+a] += 1
  jm[i+1-a] += 1
end

ans = 0
im.keys.each do |v|
  ans += im[v] * jm[v]
end
puts ans


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

int main(){
	int R,G,B,N;
	cin >> R >> G >> B >> N;
	int ans=0;
	for(int i=0;i*R<=N;i++){
		int n=N-i*R;
		for(int j=0;j*G<=n;j++)if((n-j*G)%B==0)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

  vector<int> V(N), C(N);
  for (int i = 0; i < N; ++i) cin >> V[i];
  for (int i = 0; i < N; ++i) cin >> C[i];

  int sum = 0;
  for (int i = 0; i < N; ++i)
  {
    if (V[i] <= C[i]) continue;
    int diff = V[i] - C[i];
    sum += diff;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
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;
}




signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n, 0);
    for(int i = 0; i < k; ++i){
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j){
            int x;
            cin >> x;
            ++cnt[--x];
        }
    }
    int cn = 0;
    for(int i = 0; i < n; ++i)
        cn += (cnt[i] == 0);
    cout << cn << endl;
    return 0;
}


Measured memory_bytes: 3632
line=input()
operands=line.split(' ')
poland=[]
while operands:
    if operands[0]=='+' or operands[0]=='-' or operands[0]=='*':
        x=int(poland.pop())
        y=int(poland.pop())
        operand=operands.pop(0)
        if operand=='+':
            poland.append(y+x)
        elif operand=='-':
            poland.append(y-x)
        elif operand=='*':
            poland.append(y*x)
    else:
        poland.append(operands.pop(0))
print(str(poland.pop()))


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Node
{
    int cnt;
    int tar[26];
    Node *chd[26];
    Node(void) : cnt(0) { for(auto &i : tar) i = 0; for(auto &i : chd) i = nullptr; }
};

Node *ins(Node *root, const char str[], int arr[], int cur)
{
    if(!root) root = new Node;

    if(cur != -1 && !--arr[cur]) ++root->cnt;
    if(!str[0]) return root;
    if(!str[1])
    {
        root->tar[*str - 'a']++;
    }

    root->chd[*str - 'a'] = ins(root->chd[*str - 'a'], str + 1, arr, *str - 'a');
    return root;
}

long long dfs(Node *root, int arr[], int cur)
{
    if(!root) return 0;
    long long ret = 1ll * arr[cur] * root->cnt;
    for(int i = 0; i < 26; ++i) arr[i] += root->tar[i];
    for(int i = 0; i < 26; ++i) ret += dfs(root->chd[i], arr, i);
    for(int i = 0; i < 26; ++i) arr[i] -= root->tar[i];
    return ret;
}

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

    Node *root = new Node;
    int n; cin >> n;
    for(int i = 0; i < n; ++i)
    {
        string s; cin >> s;
        reverse(s.begin(), s.end());
        int arr[26]{};
        for(auto c : s) ++arr[c - 'a'];
        root = ins(root, s.c_str(), arr, -1);
    }

    int arr[26]{};
    cout << (dfs(root, arr, 0) - n);
}


Measured memory_bytes: 373272
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()
A = list(map(lambda x: x * (-1), A))

heapq.heapify(A)
# print(A)

for i in range(M):
    a = heapq.heappop(A) * (-1)
    a = a // 2
    heapq.heappush(A, -a)
A = list(map(lambda x: x * (-1), A))
print(sum(A))




Measured memory_bytes: 16324
A,B,C = list(map(int,input().split()))

if A == B and A == C:
  if A%2==0:
    print(-1)
  else:
    print(0)
  exit()
else:
  cnt = 0
  while True:
    if A%2==0 and B%2==0 and C%2==0:
      A,B,C = (B+C)//2,(A+C)//2,(A+B)//2
      cnt += 1
      continue
    else:
      break
      
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n;
  string str;
  cin >> n >> str;
  string ans = "";
  ans += str[0];
  for(int i = 1;i<n;i++){
  	if(str[i] != ans[ans.size()-1]) ans += str[i];
  }
  cout << ans.size();
  return 0;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d%d", $num, $k);


const MOD = 1000000007;
const MAX = 200001;   //nCrにおける最大のn
$ans = 0;
for($i=$k;$i<=$num+1;$i++){
    $min = ($i + 1) * $i / 2;
    $max = (($num + 1) * ($num + 2) / 2 ) - (($num - $i + 1) * ($num - $i + 2) / 2);
    $ans =  ($ans + ($max - $min + 1)) % MOD;
}
echo $ans;

Measured memory_bytes: 16108
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string S;
  sc.scan(S);

  int cntC;
  int pos;

  if (S.front != 'A') {
    writeln("WA");
    return;
  }

  foreach (i; 2 .. S.length - 1) {
    if (S[i] == 'C') {
      cntC++;
      pos = to!int(i);
    }
  }

  if (cntC != 1) {
    writeln("WA");
    return;
  }

  foreach (i; 0 .. S.length) {
    if (i != 0 && i != pos) {
      if ('A' <= S[i] && S[i] <= 'Z') {
        writeln("WA");
        return;
      }
    }
  }

  writeln("AC");
}


Measured memory_bytes: 256
a = [0, 0, 0, 0]


a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())

if a[0] >= a[1]:
    x = a[1]
elif a[0] < a[1]:
    x = a[0]

if a[2] >= a[3]:
    y = a[3]
elif a[2] < a[3]:
    y = a[2]

z = x + y
print(z)

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
        if(x < 0) x += MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

void Main(){
    int N,X; cin >> N >> X;
    VI S(N); REP(i,N) cin >> S[i]; SORT(S);

    mint inv[N+1]; REP(i,N) inv[i+1] = mint(i+1).pow(MOD-2);
    mint dp[N][X+1]; REP(i,X+1) dp[0][i] = i%S[0];
    REP(i,N-1)REP(j,X+1){
        dp[i+1][j] = dp[i][j%S[i+1]]*inv[i+2] + dp[i][j]*(i+1)*inv[i+2];
    }

    mint fact[N+1]; fact[0] = 1; REP(i,N) fact[i+1] = fact[i]*(i+1);
    mint ans = dp[N-1][X] * fact[N];
    cout << ans.x << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 159840
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second


int main() {
    int n;
    cin>>n;
    vector<pair<int,int>>xy(n);
    vector<string>a(8,"........");
    for(int i=0;i<n;i++){
        cin>>xy[i].fi>>xy[i].se;
        a[xy[i].fi][xy[i].se]='Q';
    }

    vector<int>b;
    for(int i=0;i<n;i++){
        b.push_back(xy[i].se);
    }
    vector<int>c;
    for(int i=0;i<8;i++){
        if(count(b.begin(),b.end(),i)==0){
            c.push_back(i);
        }
    }

    vector<int>d;
    for(int i=0;i<n;i++){
        d.push_back(xy[i].fi);
    }
    vector<int>e;
    for(int i=0;i<8;i++){
        if(count(d.begin(),d.end(),i)==0){
            e.push_back(i);
        }
    }
    // for(int i=0;i<c.size();i++){
    //     cout<<c[i]<<" ";
    // }
    // cout<<endl;
    // for(int i=0;i<c.size();i++){
    //     cout<<e[i]<<" ";
    // }
    // cout<<endl;
    sort(c.begin(),c.end());
    do{
        vector<string>vec=a;
        for(int i=0;i<c.size();i++){
            vec[e[i]][c[i]]='Q';
        }
        // cout<<"------------"<<endl;
        // if(vec[0]=="......Q."){
        //     for(int i=0;i<8;i++){
        //         cout<<vec[i]<<endl;
        //     }
        // }
        // 斜め方向を満たすかを確認
        bool flag=true;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(vec[i][j]=='Q'){
                    for(int k=-7;k<8;k++){
                        if(i+k>=0 && i+k<8 && j+k>=0 && j+k<8){
                            if(vec[i+k][j+k]=='Q' && k!=0){
                                flag=false;
                            }
                        }
                        if(i-k>=0 && i-k<8 && j+k>=0 && j+k<8){
                            if(vec[i-k][j+k]=='Q' && k!=0){
                                flag=false;
                            }
                        }
                    }
                }
            }
        }
        if(flag){
            for(int i=0;i<8;i++){
                cout<<vec[i]<<endl;
            }
        }

    }
    while(next_permutation(c.begin(),c.end()));


    return 0;
}



Measured memory_bytes: 3240
//Left, Rightを決める.
//Ki昇順 -> 上から全てLeft -> 上からValidになるよう最低限Right -> 下から上限に注意してRight
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef tuple<int, int, int> T;
typedef pair<int, int> P;

int n;
int K[200000], L[200000], R[200000];

int solve() {
	int i;
	
	/*cout << endl;
	rep(i, n) {
		cout << "K, L, R = " << K[i] << ", " << L[i] << ", " << R[i] << endl;
	}*/
	
	int ret = 0;
	rep(i, n) {
		ret += L[i];
	}
	
	//右に変えた方が良いやつを考える
	bool isR[200000] = {false};
	priority_queue<P, vector<P>, greater<P>> queR;
	int right = 0;
	for (i = n - 1; i >= 0; i--) {
		if (R[i] - L[i] > 0 && isR[i] == false) {
			isR[i] = true;
			ret += R[i] - L[i];
		}
		if (isR[i]) {
			right++;
			queR.push(P(R[i] - L[i], i));
		}
		
		while (right > n - K[i]) {
			P now = queR.top(); queR.pop();
			int pos = now.second;
			isR[pos] = false;
			ret -= now.first;
			right--;
		}
	}
	
	//右に変える必要のある分かえる
	priority_queue<P> que;	//(value, index)
	int left = 0;
	rep(i, n) {
		que.push(P(R[i] - L[i], i));
		left++;
		while (left > K[i]) {
			//cout << "i = " << i << endl;
			P now = que.top(); que.pop();
			int pos = now.second;
			isR[pos] = true;
			ret += now.first;
			left--;
		}
	}
	
	int cal = 0;
	rep(i, n) {
		if (isR[i]) cal += R[i];
		else cal += L[i];
	}
	//cout << "cal = " << cal << ", ret = " << ret << endl;
	return cal;
}

signed main() {
	int caseNum;
	cin >> caseNum;
	while (caseNum--) {
		int i;
		cin >> n;
		vector<T> tup;
		rep(i, n) {
			int k, l, r;
			cin >> k >> l >> r;
			tup.push_back(T(k, l, r));
		}
		sort(tup.begin(), tup.end());
		rep(i, n) {
			K[i] = get<0>(tup[i]);
			L[i] = get<1>(tup[i]);
			R[i] = get<2>(tup[i]);
		}
		int res = solve();
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 21496
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+7;
using namespace std;

const int MAX = 510000;


long long 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(LL n, LL 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(){
    LL N,P;
    cin >> N >> P;
    COMinit();
    map<LL,LL> mp;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        mp[b%2]++;
    }
    LL ans = 0;
    if(P == 0){
        for(int b = 0;b <= mp[1];b+=2){
            ans += COM(mp[1],b);
        }

    }else{
        for(int b = 1;b <= mp[1];b+=2){
            ans += COM(mp[1],b);
        }
    }
    cout<<(ans * 1LL<<mp[0] )<<endl;
}


Measured memory_bytes: 12160
# coding: utf-8
# Your code here!
from collections import defaultdict

def main():
    n, m = map(int, input().split())
    h_list = list(map(int, input().split()))
    d = defaultdict(list)
    for i in range(m):
        a, b = map(int, input().split())
        d[a].append(h_list[b-1])
        d[b].append(h_list[a-1])
    
    count = 0
    for i, h in enumerate(h_list):
        if len(d[i+1]) == 0:
            count += 1
            continue
        max_h = max(d[i+1])
        if max_h < h:
            count += 1
    
    print(count)
    
main()


Measured memory_bytes: 33060
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var K = sc.ReadInt();
        var ans = N % K > 0 ? 1 : 0;
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    int[] cardList = new int[number];
    int scoreA = 0;
    int scoreB = 0;
    for(int i =0; i < number; i++){
     	cardList[i] = sc.nextInt(); //カード情報の格納
    }
    for(int i = 0; i < number; i++){ //お互いに最大値のカードを取る
      int maxCard = cardList[0];
      int position = 0; //最大値の位置
      for(int j = 1; j < number; j++){
          if(cardList[j] > maxCard){
            maxCard = cardList[j];
            position = j;
          }
      }
      cardList[position] = 0; //最大値の消去
      if( i % 2 == 0) scoreA += maxCard;
      else scoreB += maxCard;
    }
    System.out.println(scoreA - scoreB);
    
  }
}

Measured memory_bytes: 21844
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

void Main(){
    ll n, m; cin >> n >> m;
    vi a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        
    }
    reverse(all(a));
    reverse(all(b));
    
    UnionFind UF(n);
    ll tot = n * (n-1) / 2;
    vll ans;
    
    rep(i, m){
        ans.pb(tot);
        if(!UF.same(a[i], b[i])){
            tot -= ll(UF.size(a[i])) * ll(UF.size(b[i]));
        } 
        UF.unite(a[i], b[i]);
    }
        
    reverse(all(ans));
    for(auto x : ans) cout << x << endl;
    return;
}

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

Measured memory_bytes: 5388
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 3000
#define X 998244353
using namespace std;
int a,b,c,d,f[N+5][N+5];
int main()
{
	RI i,j;scanf("%d%d%d%d",&a,&b,&c,&d);
	for(f[a][b]=1,i=a;i<=c;++i) for(j=b;j<=d;++j) if(a==i&&b==j);else
		if(b==j) f[i][j]=1LL*f[i-1][j]*j%X;else if(a==i) f[i][j]=1LL*f[i][j-1]*i%X;
		else f[i][j]=(1LL*f[i-1][j]*j+1LL*f[i][j-1]*i-1LL*(i-1)*(j-1)%X*f[i-1][j-1]%X+X)%X;
	return printf("%d\n",f[c][d]),0;
}

Measured memory_bytes: 38864
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pv = vec![0f64; n];
    for i in 0..n - 1 {
        pv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    pv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut tbl = vec![vec![0f64; n + 1]; n + 1];
    tbl[0][0] = 1f64;
    for i in 1..n + 1 {
        for j in 0..i {
            tbl[i][j] += tbl[i - 1][j] * (1f64 - pv[i - 1]);
            tbl[i][j + 1] += tbl[i - 1][j] * pv[i - 1];
        }
    }

    let mut ans = 0f64;
    for i in ((n + 1) / 2)..(n + 1) {
        ans += tbl[n][i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 90364
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,t=0,i,res=0;
  int a[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  for(i=0;i<n;i++)
    if(a[i]!=t){
      res++;
      t=a[i];
    }
  if(res%2==0) res--;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b + c){
        cout << "Yes" << endl;
    } else if(b == a + c){
        cout << "Yes" << endl;
    } else if(c == a + b){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    vector<int> dp(N, 1);
    for (int t = 0; t < 2; t++) {
      vector<int> dig(10, 0);
      int sum = 0;
      for (int i = N - 1; i >= 0; i--) {
        int cur = dp[i];
        int d = S[i] - '0';
        dp[i] = sum;
        int pre = dig[d];
        dig[d] = cur;
        sum = sum - pre + cur;
      }
    }
    vector<int> dig(10, 0);
    for (int i = N - 1; i >= 0; i--) dig[S[i] - '0'] = dp[i];
    int res = accumulate(dig.begin(), dig.end(), 0);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int s=0, w=1;

	char ch=getchar();

	while(ch<'0' || ch>'9')
	{
		if(ch='-')
		{
			w=-w;
		}

		ch=getchar();
	}

	while(ch>='0' && ch<='9')
	{
		s=(((s*10ll))+(ch-'0'));

		ch=getchar();
	}

	return s;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	unsigned long long int n, m;
	
	n=read();
	m=read();
	
	if(n==1 || m==1)
	{
		cout<<"1"<<endl;
	}
	else if(m%2==0)
	{
		cout<<n*m/2<<endl;
	}
	else
	{
		cout<<(n-1)*m/2+m/2+1<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split('\n');
    for (var i = 0; i < inputs.length; i++) {
    	if (inputs[i] === '0 0'){
    		break;
    	}
    	var cols = inputs[i].split(' ').map(Number);
        console.log(
        cols.sort(function(a,b){
        	return a - b;
        }).join(' ')
  );
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 19464
//LETS START AGAIN
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
signed main() 
{ 
    fast;
    string s;
    cin>>s;
    int n = s.size();
    set<char> st;
    for(auto it:s)
        st.insert(it);
    if(st.size() == 1)
    {
        cout<<0;
        return 0;
    }
    int hh = 1e18;
    for(auto it:st)
    {
        char ch = it;
        string ss = s;
        int cnt = 0;
        string ans ="";
        while(1)
        {
            cnt++;
            set<char> temp;
            for(int i = 0;i<ss.size()-1;i++)
            {
                if(ss[i] == ch)
                {
                    ans.pb(ch);
                    temp.insert(ch);
                }
                else
                {
                    ans.pb(ss[i+1]);
                    temp.insert(ss[i+1]);
                }
            }
            if(temp.size()==1)
                break;
            ss = ans;
            ans ="";
        }
        hh = min(hh,cnt);
    }
    cout<<hh;
} 



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 K;
string s;

int main() {
    cin >> s;
    cin >> K;

    if (s[0] == '1') {
        i64 r = 0;
        while (r < s.length() && s[r] == '1') r++;
        if (K <= r) {
            cout << 1 << endl;
        } else {
            cout << s[r] << endl;
        }
    } else {
        cout << s[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = [0]*(n+1)
for i in range(n):
    if s[i] == "<":
        ans[i+1] = max(ans[i+1], ans[i]+1)

for i in reversed(range(n)):
    if s[i] == ">":
        ans[i] = max(ans[i+1]+1, ans[i])

print(sum(ans))


Measured memory_bytes: 23336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    string s[n];
    int ans=0;
    int a=0,b=0,c=0;
    rep(i,0,n){
        cin>>s[i];
        rep(j,0,s[i].size()-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
        }
        if(s[i][0]=='B'){
            if(s[i][s[i].size()-1]=='A')c++;
            else b++;
        }
        else if(s[i][s[i].size()-1]=='A')a++;
    }
//cout<<a<<b<<c;
    if(c==0){
        cout<<ans+min(a,b)<<endl;
        return 0;
    }
    ans+=c-1;
    if(a>0){
        ans++;
        a--;
    }
    if(b>0){
        ans++;
        b--;
    }
    cout<<ans+min(a,b)<<endl;
}


Measured memory_bytes: 768
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	p := pascal(n)
	nn := 1 << uint(n)
	ss := make([]int, nn)
	im := IntMap{}
	for i := 0; i < nn; i++ {
		ss[i] = getNextInt(scanner)
		im.increment(ss[i])
	}
	if len(im) <= n {
		fmt.Println("No")
		return
	}
	keys := make([]int, 0)
	sort.Ints(ss)
	for key, c := range im {
		if c > 1<<uint(n-1) {
			fmt.Println("No")
			return
		}
		keys = append(keys, key)
	}
	sort.Ints(keys)
	ysp48 := make([]int, nn)

	y := 0
	for i := 0; i <= n; i++ {
		for j := 0; j < p[n][i]; j++ {
			ysp48[y] = keys[len(keys)-1-i]
			y++
		}
	}
	sort.Ints(ysp48)

	for i := nn - 1; i >= 0; i-- {
		if ysp48[i] < ss[i] {
			fmt.Println("No")
			return
		}
	}

	fmt.Fprintln(writer, "Yes")

	writer.Flush()
}

func pascal(n int) [][]int {
	p := make([][]int, n+1)

	for i := 0; i < n+1; i++ {
		p[i] = make([]int, n+1)
	}

	p[0][0] = 1
	for i := 1; i < n+1; i++ {
		for ii := 0; ii <= i; ii++ {
			if ii > 0 {
				p[i][ii] += p[i-1][ii-1]
			}
			if ii < i {
				p[i][ii] += p[i-1][ii]
			}
		}
	}

	return p
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}

func (m IntMap) increment(key int) {
	m[key] = m.get(key) + 1
}


Measured memory_bytes: 29824