akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readInt()
	k := readInt()

	h := make([]int, n)
	for i := range h {
		h[i] = readInt()
	}

	sort.Ints(h)
	min := 1000000000000000000
	for i := 0; i < n; i++ {
		if i+k-1 >= n {
			break
		}
		tmp := h[i+k-1] - h[i]
		if min > tmp {
			min = tmp
		}
	}

	fmt.Println(min)
}

/*-------------------inputs-------------------*/

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 readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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()
	}
}

/*-------------------utilities-------------------*/

func sum(list []int) (sum int) {
	for _, l := range list {
		sum = sum + l
	}
	return sum
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
int dp[500010];
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    int last = 0;
    rep(i, 3, n)
    {
        dp[i] = dp[i - 1];
        if(s[i - 1] == '1' && s[i - 2] == '0' && s[i - 3] == '1') 
        {
            last = i;
            for(int j = i - 2; s[j - 1] != '0' && j >= 1; j --)
                dp[i] = max(dp[i], dp[j - 1] + i - 1 - j);
        }
        if(s[i - 1] == '0') last = 0;
        if(s[i - 1] == '1' && last) dp[i] = max(dp[i], dp[last - 3] + i - last + 1);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	map<string,int>f;
	// SUN, MON, TUE, WED, THU, FRI, or SAT.
	f["SUN"]=7;
	f["MON"]=6;
	f["TUE"]=5;
	f["WED"]=4;
	f["THU"]=3;
	f["FRI"]=2;
	f["SAT"]=1;
	string s;
	cin>>s;
	cout<<f[s];
}

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

int main(){
  string S;cin>>S;
  if(S=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}

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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int l = 0, r = W, b = 0, u = H;
    for(int i=0; i<N; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1) {
            l = max(l, x);
        } else if(a == 2) {
            r = min(r, x);
        } else if(a == 3) {
            b = max(b, y);
        } else {
            u = min(u, y);
        }
    }
    cout << max(r - l, 0) * max(u - b, 0) << endl;
}


Measured memory_bytes: 256
N,A,B=map(int, input().split())
# 出力
if A>B:
  print(0)
elif N==1:
  if A==B:
    print(1)
  else:
    print(0)
else:
  M=A+B*(N-1)
  m=A*(N-1)+B
  print(M-m+1)

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

long long n;

long long solve();

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(n % 2) return 0;
  long long res = 0, now = 5;
  while(now <= n) {
    res += (n / now) / 2;
    now *= 5;
  }
  return res;
}

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

# B - Exactly N points
n = int(input())
m = 1
sum = 1

while sum < n:
	sum = (m + 1) * m / 2 
	m += 1

if m == 1:
	ans = [1]
else:
	ans = list(range(1, m))

try:
	ans.remove(sum - n)
except Exception:
	pass

for a in ans:
	print(a)

Measured memory_bytes: 3572
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := make([]string, N)
	for i := 0; i < N; i++ {
		s[i] = getString()
	}
	c := make([][2]int, N)
	for i := 0; i < N; i++ {
		for _, v := range s[i] {
			if v == '(' {
				c[i][0]++
			} else {
				if c[i][0] == 0 {
					c[i][1]++
				} else {
					c[i][0]--
				}
			}
		}
	}
	sort.Slice(c, func(i, j int) bool {
		if c[i][1] == 0 {
			return true
		}
		if c[j][1] == 0 {
			return false
		}
		if c[i][0] == 0 {
			return false
		}
		if c[j][0] == 0 {
			return true
		}
		di := c[i][0] - c[i][1]
		dj := c[j][0] - c[j][1]
		return di > dj

		if c[i][0] == c[j][0] {
			return c[i][1] < c[j][1]
		}
		return c[i][0] > c[j][0]
	})

	if c[0][1] != 0 {
		out("No")
		return
	}

	// out(c)

	l := c[0][0]
	r := c[0][1]
	cntl := l
	cntr := r
	for i := 1; i < N; i++ {
		cntl += c[i][0]
		cntr += c[i][1]
		x := min(l, c[i][1])
		y := min(r, c[i][0])
		l = l - x + c[i][0] - y
		r = r - y + c[i][1] - x
		if r > 0 {
			out("No")
			return
		}
		// out(c[i], x, y, l, r)
	}
	if l == 0 && r == 0 && cntl == cntr {
		out("Yes")
	} else {
		out("No")
	}
}


Measured memory_bytes: 34208
import sys
input=sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26

for i in range(d):
    m=-10**9
    change=-1
    for j in range(26):
        temp=0
        temp+=s[i][j]
        for k in range(26):
            if k!=j:
                temp-=c[k]+(i-last[k])
        if temp>m:
            m=temp
            change=j
    print(change+1)

Measured memory_bytes: 68672
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	ll n;
	cin>>n;
	ll a[n];
	int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		c=c^a[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<(c^a[i])<<" ";
	}
	return 0;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;
int dp1[3001][3001];
int dp2[3001][3001];

int main() {


    int N, T;
    cin >> N >> T;
    int A[N], B[N];
    rep(i, N){
        cin >> A[i] >> B[i];
    }
    A[N] = 0; B[N] = 0;

    rep(i, N){
        rep(j, T){
            if (j - A[i] >= 0) {
                dp1[i+1][j] = max(dp1[i][j], dp1[i][j-A[i]] + B[i]);
            } else {
                dp1[i+1][j] = dp1[i][j];
            }
        }
    }

    rep(i, N){
        rep(j, T){
            if (j - A[N-i-1] >= 0) {
                dp2[N-i-1][j] = max(dp2[N-i][j], dp2[N-i][j-A[N-i-1]] + B[N-i-1]);
            } else {
                dp2[N-i-1][j] = dp2[N-i][j];
            }
        }
    }

    int ans = 0;
    rep(i, N){
        rep(j, T){
            ans = max(ans, dp1[i][j] + dp2[i+1][T-1-j] + B[i]);
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 70656
#include <stdio.h>

int main() {
	int a, b, c, i, n;
	scanf("%d %d %d ",&a, &b, &c);
	for(i = a; i <= b; i++){
		if(c % i == 0){
		n += 1;
		}
		}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1976
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#define MaxN 20000+100
using namespace std;
int a[MaxN];
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		scanf("%d",&a[i]);
	sort(a,a+N);
	int now=0x1f1f1f1f;
	int c=0;
	for(int i=N-1;i>=0;i--)
	{
		if(a[i]<now)
		{
			now=a[i];
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
 } 

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

class Program
{
  static void Main(string[] args)
  {
        int[] arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = arr[0];
        var M = arr[1];
        var G = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            G[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int[] arrTwo = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = arrTwo[0];
            var b = arrTwo[1];
            a--; b--;
            G[a].Add(b);
            G[b].Add(a);
        }
        var q = new Queue<(int, int, int)>();
        var visited = new bool[N];
        visited[0] = true;
        var michishirube = new int[N];
        q.Enqueue((0, -1, 0));
        while (q.Count > 0)
        {
            var t = q.Dequeue();
            var now = t.Item1;
            var prev = t.Item2;
            var d = t.Item3;
            foreach (var next in G[now])
            {
                if (visited[next]) continue;
                visited[next] = true;
                michishirube[next] = now;
                q.Enqueue((next, now, d + 1));
            }
        }
        Console.WriteLine("Yes");
        for (int i = 1; i < N; i++)
        {
            Console.WriteLine(michishirube[i] + 1);
        }


    }

   

}



Measured memory_bytes: 54656
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
map<string, int> mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    int mx = 0;
    for(int i = 0; i < n; i++){
        string a;
        cin>>a;
        mp[a]++;
        mx = max(mx, mp[a]);
    }
    for(auto u: mp){
        if(u.ss == mx){
            cout<<u.ff<<endl;
        }
    }
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  deque<char> de;
  rep(i,s.size()){
    de.push_back(s.at(i));
  }
  bool fl=true;
  int q;cin>>q;
  rep(i,q){
    int q2;cin>>q2;
    if(q2==1){
      if(fl){
        fl=false;
      }else{
        fl=true;
      }
    }else if(q2==2){
      int f;
      char c;
      cin>>f;
      cin>>c;
      if(fl){
        if(f==1){
          de.push_front(c);
        }else if(f==2){
          de.push_back(c);
        }
      }else{
        if(f==1){
          de.push_back(c);
        }else if(f==2){
          de.push_front(c);
        }
      }
    }
  }
  
  int ss=de.size();
  if(fl){
    rep(i,ss){
      cout<<de.at(i);
    }
    cout<<endl;
  }else{
    rep(i,ss){
      cout<<de.at(ss-i-1);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define F first
#define S second
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}

/*
(char)'1' - (int)48 = (int)1;
　1111181
*/
////////////////////////////////////////////////////
vector<long long > a;
vector<long long >::iterator now,b;
int n, t;
bool s(long long m)
{
	now = a.begin();
	for (int i = 0; i < t - 1; i++){
		if (binary_search(now, a.end(), m + *now))
		{
			now = lower_bound(now, a.end(), m + *now);
		}
		else
		{
			now = lower_bound(now, a.end(), m + *now);
			now--;
		}

		if (now >= a.end())return true;
		
	}
	if (a[a.size()-1] - *now <= m)return true;
	else return false;

}
int main()
{
	cin >> n >> t;
	a.push_back(0);
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		a.push_back(x);
		a[i] += a[i - 1];
	}
	long long  r, l; r = 10000000000; l = 0;
	while (r != l)
	{
		long long m = (r + l) / 2;
		if (s(m))
		{
			r = m;
		}
		else
		{
			l = m+1;
		}
		;
	}
	cout << r << endl;



}

Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005
int num[MAXN];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d",&a);
        num[a++]++; 
    }
    int ans = 0;
    for (int i = 0; i < MAXN; i++) {
        int maxsum = num[i - 1] + num[i] + num[i + 1]; // add ,sub ,do not ,最大化 
        if (maxsum > ans) {
			ans = maxsum;
		} 
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[100],b[100],c[100],d[100],ans;
int k[100],p[100];
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;++i)
	 cin>>a[i]>>b[i]>>c[i]>>d[i];
	for(int i=m+1;i<=n+m;++i) p[i]=1;
	do
	{
		if(p[1]) break;
		int s=0,t=0,num=0;
		for(int i=1;i<=n+m;++i)
		 if(!p[i]) ++t;
		 else k[++num]=t;
		for(int i=1;i<=q;++i)
		 if(k[b[i]]-k[a[i]]==c[i]) s+=d[i];
		ans=max(ans,s);		 
	}while(next_permutation(p+1,p+n+m+1));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3560
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/*//abc176A
 int main(void) {
 int n, x, t, k, i, cou=0, tmp;
 scanf("%d %d %d", &n, &x, &t);
 printf("%d", ((n-1)/x+1)*t);
 return 0;
 }
 */
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[200001];
  scanf("%s", s);
  for(i=0; s[i]!='\0'; ++i){ //文字数
    cou+=s[i]-48;
  }
  if(cou%9==0)printf("Yes");
  else printf("No");
  return 0;
}

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

using namespace std;
map<long long , int> mp;
int arr[200100];
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i<=n ; ++i)
    {
        scanf("%d" , &arr[i]);
    }

    long long ans = 0;
    mp[0]++;
    long long sum = 0;
    for(int i = 1 ; i<=n ; ++i)
    {
        sum += arr[i];
        if(mp.count(sum)) ans+= mp[sum];
        mp[sum]++;
    }
    cout<<ans<<endl;

    return 0;
}


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

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

int main() {

    int N,X;
    cin >> N >> X;

    vector<int> L(N);
    rep(i,N){
        cin >> L[i];
    }

    int count = 0;
    int d = 0;

    for(int i=0; i<=N; i++){
        d = d + L[i];
        count++;
        if(d>X) break;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i,X=0,x;
	x=2000;
	for(i=0;i<3;i++){
		scanf("%d",&a);
		if(x>a){
			x=a;
		}
	}
	X+=x;
	x=2000;
	for(i=0;i<2;i++){
		scanf("%d",&a);
		if(x>a){
			x=a;
		}
	}
	X+=x;
	printf("%d\n",X-50);
	return 0;
}

Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+3;
int arr[N];
int main(){
std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        long long i,j,n,q,e=0,t,o=0,c=0,temp,k,maxpeak=0,peak,d;
        string s;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>d;
            arr[d]++;
        }
        for(i=0;i<N;i++)
        {
            if(arr[i]>0)
            {
                if(arr[i]%2==1)
                {
                    o++;
                }
                else e++;
            }
        }
        if(e%2==0)cout<<o+e;
        else cout<<o+e-1;
        
    }
}

Measured memory_bytes: 640
from fractions import gcd

n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []

for i in range(n):
    dis_list.append(x_list[i+1] - x_list[i])

ans = dis_list[0]
for i in range(n):
    ans = gcd(dis_list[i],ans)

print(ans)

Measured memory_bytes: 16300
#include <bits/stdc++.h>
using namespace std;
string x;
int cnt[1000004], l[10000004];
bool check(int k){
	string s = x;
	memset(cnt, 0, sizeof(cnt));
	int pre, cur;
	pre = cur = 0;
	for(int i = 0; i < s.size() - k + 1; ++i){
		cur = pre + cnt[i];
		if(cur % 2 == 0){
			if(s[i] == '0')continue;
			pre++;
			s[i] = '0';
			cnt[i + k] = -1;
		}
		else{
			if(s[i] == '1'){
				s[i] = '0';continue;
			}
			else{
				pre++;
				cnt[i + k] = -1;
			}
		}
	}
	int ans = s.size() - k + 1;
	for(int i = s.size() - k + 1; i < s.size(); ++i){
		cur = pre - cnt[i];
		if(cur % 2 == 0){
			if(s[i] == '0') ans++;
			else break;
		}
		else{
			if(s[i] == '1') ans++;
			else break;
		}
	}
	if(ans >= k) return true;
	else return false;
}
int main(){
	cin>>x;
	int l, r, mid;
	l = 1;
	r = x.size();
	int q = 100;
	while(q--){
		mid = l + r >> 1;
		if(check(mid)) l = mid;
		else r = mid;
	}
	if(check(l + 1)) cout<<l+1<<endl;
	else cout<<l<<endl;
}



Measured memory_bytes: 4480
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B = map(int, input().split())

D = defaultdict(int)
D["1"] = 3*10**5
D["2"] = 2*10**5
D["3"] = 1*10**5
ans = 0
if A == 1 and B == 1:
    ans += 4*10**5
print(ans+D[str(A)]+D[str(B)])


Measured memory_bytes: 38576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

int main() {
    FAST_IO();
    ll X, Y; cin >> X >> Y;
    if(abs(X - Y) <= 1) cout << "Brown\n";
    else cout << "Alice\n";
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <utility>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;

#define init() ios::sync_with_stdio(false); cin.tie();
#define for0(i, n) for (int i=0; i<n; i++)
#define for1(i, n) for (int i=1; i<=n; i++)
#define for2(i, a, b) for (int i=a; i<=b; i++)
#define bac0(i, n) for (int i=n-1; i>=0; i--)
#define bac1(i, n) for (int i=n; i>0; i--)
#define bac2(i, a, b) for (int i=a; i>=b; i--)
#define PB push_back
#define MOD 1000000009
#define S second
#define F first

#define xL ((x<<1)+1)
#define xR ((x<<1)+2)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> ic;

const int N = (int) (4e5 + 5);

int a, b;

int main() {
    init()

    cin >> a >> b;
    cout << a - 1 + (b >= a ? 1 : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if(b - a + 1 <= k * 2) {
        for(int i = a; i <= b; i++) cout << i << endl;
    } else {
        for(int i = a; i <= a + k - 1; i++) cout << i << endl;
        for(int i = b - k + 1; i <= b; i++) cout << i << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true){
			int M=in.nextInt(),T=in.nextInt(),P=in.nextInt(),R=in.nextInt();
			if(M==0 && T==0)break;

			team data[]=new team[T];
			for(int i=0;i<T;i++)data[i]=new team(i+1,0,0);

			for(int i=0;i<R;i++){
				int m=in.nextInt(),t=in.nextInt(),p=in.nextInt(),j=in.nextInt();
				if(j==0){
					data[t-1].prob++;
					data[t-1].wasWA(p);
					data[t-1].time+=m;
				}
				else data[t-1].WA.add(p);
			}
			
			//for(int i=0;i<T;i++)System.out.printf("team=%d, solved=%d, time=%d\n",data[i].no,data[i].prob,data[i].time);
			
			//sort
			boolean flag=true;
			for(int i=0;flag;i++){
				flag=false;
				for(int j=T-1;j>=i+1;j--){
					if(data[j].prob>data[j-1].prob){
						swap(data,j,j-1);
						flag=true;
					}
					else if(data[j].prob==data[j-1].prob && data[j].time<data[j-1].time){
						swap(data,j,j-1);
						flag=true;
					}
					else if(data[j].prob==data[j-1].prob && data[j].time==data[j-1].time && data[j].no>data[j-1].no){
						swap(data,j,j-1);
						flag=true;
					}
				}
			}
			
			//System.out.println();
			//for(int i=0;i<T;i++)System.out.printf("team=%d, solved=%d, time=%d\n",data[i].no,data[i].prob,data[i].time);
			for(int i=0;i<T-1;i++){
				if(data[i].prob==data[i+1].prob && data[i].time==data[i+1].time)System.out.printf("%d=",data[i].no);
				else System.out.printf("%d,",data[i].no);
			}
			System.out.printf("%d\n",data[T-1].no);
		}
	}
	
	static void swap(team[] A,int i,int j){
		team tt=A[i];
		A[i]=A[j];
		A[j]=tt;
	}

}

class team{
	int no,prob,time;
	List<Integer> WA;

	team(int n,int p,int t){
		no=n; prob=p; time=t;
		WA=new ArrayList<>();
	}

	void wasWA(int p){
		for(int i=0;i<WA.size();i++){
			if(WA.get(i)==p)time+=20;
		}
	}
}



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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

    int N;
    string S;
    cin >> N >> S;

    vector<int> G;
    vector<int> R;
    vector<int> B;

    for (int i = 0; i < N; i++)
    {
        if (S.at(i) == 'R')
        {
            R.push_back(i + 1);
        }
        else if (S.at(i) == 'G')
        {
            G.push_back(i + 1);
        }
        else if (S.at(i) == 'B')
        {
            B.push_back(i + 1);
        }
    }

    int tmp1, tmp2, tmp3;
    ll ans = 0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 1; i + 2 * j < N; j++)
        {
            if(i+2*j<N){
                if(S.at(i)=='R'){
                    tmp1 = 1;
                }
                else if(S.at(i)=='G'){
                    tmp1 = 2;
                }
                else if(S.at(i)=='B'){
                    tmp1 = 4;
                }
                if (S.at(i+j) == 'R')
                {
                    tmp2 = 1;
                }
                else if (S.at(i+j) == 'G')
                {
                    tmp2 = 2;
                }
                else if (S.at(i+j) == 'B')
                {
                    tmp2 = 4;
                }
                if (S.at(i + 2*j) == 'R')
                {
                    tmp3 = 1;
                }
                else if (S.at(i + 2*j) == 'G')
                {
                    tmp3 = 2;
                }
                else if (S.at(i + 2*j) == 'B')
                {
                    tmp3 = 4;
                }
                if(tmp1+tmp2+tmp3==7){
                    ans++;
                }
            }
        }
    }

    cout << R.size()*G.size()*B.size()-ans << endl;
}


Measured memory_bytes: 3656
#include<iostream>
main(){int a,c,i,j,k;for(std::string s,t;std::cin>>s>>t;printf("%d\n",a))for(a=k=0;k++<2;swap(s,t))for(i=s.size();i-->0;)for(j=c=0;j<s.size()-i;)s[j+i]-t[j++]?c=0:a=a>++c?a:c;}

Measured memory_bytes: 940
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

alias S = Tuple!(int, "d", int, "h", int, "w");

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];
    auto cc = readln.split.to!(int[]);
    auto ch = cc[0]-1;
    auto cw = cc[1]-1;
    auto dd = readln.split.to!(int[]);
    auto dh = dd[0]-1;
    auto dw = dd[1]-1;

    char[][] MAP;
    foreach (_; 0..H) MAP ~= readln.chomp.to!(char[]);

    auto memo = new int[][](H, W);
    foreach (ref dp; memo) dp[] = int.max/3;
    memo[ch][cw] = 0;
    auto ss = heapify!"a.d > b.d"([S(0, ch, cw)]);
    while (!ss.empty) {
        auto t = ss.front;
        ss.removeFront();
        static foreach (d; [[0,1], [1,0], [-1,0], [0,-1]]) {{
            auto h = t.h + d[0];
            auto w = t.w + d[1];
            if (h >= 0 && h < H && w >= 0 && w < W && MAP[h][w] == '.' && memo[h][w] > t.d) {
                memo[h][w] = t.d;
                ss.insert(S(t.d, h, w));
            }
        }}
        static foreach (ph; -2..3) {{
            static foreach (pw; -2..3) {{
                auto h = t.h + ph;
                auto w = t.w + pw;
                if (h >= 0 && h < H && w >= 0 && w < W && MAP[h][w] == '.' && memo[h][w] > t.d+1) {
                    memo[h][w] = t.d+1;
                    ss.insert(S(t.d+1, h, w));
                }
            }}
        }}
    }
    writeln(memo[dh][dw] == int.max/3 ? -1 : memo[dh][dw]);
}

Measured memory_bytes: 8752
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
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 (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;
}

void solve() {
	long long a; cin >> a;
	long long b; cin >> b;
	long long c; cin >> c;
	long long d; cin >> d;
	long long cd = (c * d) / gcd(c , d);
	long long target = b - a + 1;
	long long cnt_1 = (a - 1) / c;
	long long cnt_2 = b / c;
	long long cnt_3 = (a - 1) / d;
	long long cnt_4 = b / d;
	//最小公倍数を重複して引いてしまうので足し戻す
	long long cnt_5 = (a - 1) / cd;
	long long cnt_6 = b / cd;
	cout << target - abs(cnt_1 - cnt_2) - abs(cnt_3 - cnt_4) + abs(cnt_5 - cnt_6) << endl;
    return;
}

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



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

int main(){
    char a[11], b[11], c[11];
    scanf("%s %s %s", a, b, c);

    a[0] = toupper(a[0]);
    b[0] = toupper(b[0]);
    c[0] = toupper(c[0]);

    printf("%c%c%c\n", a[0], b[0], c[0]);

    return 0;
}


Measured memory_bytes: 128
#B
N,K = map(int, input().split())
N_LIST = []

#N人がお菓子を持っているか持っていないかのリスト表
for i in range(N):
    N_LIST.append(0)

#仮におかしdiでその人が指名されたときもしリストでの値が0
#なら1にして１なら１のまま

for i in range(K):
    di = int(input())
    who_has_di_list = input().split()

    #who_has_di_listでdiを持っている人が分かる
    for i in range(len(who_has_di_list)):
        num = int(who_has_di_list[i])
        if N_LIST[num-1] == 0:
            N_LIST[num-1] = 1

#N_LISTにはお菓子を持ってる人は1、そうでない人は0となっている
ans = 0

for i in range(len(N_LIST)):
    ans += N_LIST[i]

Ans = len(N_LIST) - ans

print(Ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
	for(int i=sx+1;i<=tx;i++){
		cout<<"R";
	}
	for(int i=sy+1;i<=ty;i++){
		cout<<"U";
	}
	for(int i=tx-1;i>=sx;i--){
		cout<<"L";
	}
	for(int i=ty-1;i>=sy;i--){
		cout<<"D";
	}
	cout<<"D";
	for(int i=sx;i<=tx;i++){
		cout<<"R";
	}
	for(int i=sy;i<=ty;i++){
		cout<<"U";
	}
	cout<<"L";
	cout<<"U";
	for(int i=tx;i>=sx;i--){
		cout<<"L";
	}
	for(int i=ty;i>=sy;i--){
		cout<<"D";
	}
	cout<<"R";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
MOD = 10**9+7
N, M = map(int, input().split())
broken = {int(input()) for _ in range(M)}

dp = [0]*(N+1)
dp[0] = 1
for i in range(N+1):
    for j in [1, 2]:
        if i+j <= N and not i+j in broken:
            dp[i+j] += dp[i]
            dp[i+j] %= MOD
print(dp[-1])


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;
    cin>>n;
    vd a(n),b(n);rep(i,n){cin>>a[i];b[i]=1/a[i];}
    double sum=0;
    rep(i,n)sum+=b[i];
    cout<<fixed<<setprecision(6)<<1/sum;
}

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

int main(){
    vector<int> p(101,0);
    int x,n;
    cin >> x >> n;
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    rep(i,n){
        int temp;
        cin >> temp;
        p.at(temp)=1;
    }
    if(p.at(x)==0){
        cout << x << endl;
        return 0;
    }
    int ans = 101;
    for(int i = x; i < 101 ; i++){
        if(p.at(i)==0){
            ans = i;
            break;
        }        
    }
    for(int i = x-1; i > -1 ; i--){
        if(p.at(i)==0 && (ans - x) >= (x - i)){
            ans = i;
            break;
        }        
    }
    cout << ans << endl;
}

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

int main() {
  
  int n, m, c;
  cin >> n >> m >> c;
  
  vector<int> b(m);
  for (int i=0;i<m;i++) {
    cin >> b.at(i);
  }
  
  vector<vector<int>> a(n,vector<int>(m));
  
  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  int count=0;
  
  for (int i=0;i<n;i++) {
    int sum = 0;
    for (int j=0;j<m;j++) {
      sum += a.at(i).at(j) * b.at(j);
    }
    if (sum + c > 0)
      count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int gcd(int x, int y) {
    if (y > x)swap(x, y);
    if (x%y == 0)return y;
    else return gcd(y,x%y);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    int ans = 0;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j<= K; ++j) {
            int temp = gcd(i, j);
            for (int l = 1; l <= K; ++l) {
                ans += gcd(temp, l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<map>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	ll a[N + 100];
	ll sum = 0;
	ll ans = 0;
	map<ll, ll>cnt;
	cin >> N;
	cnt[0] = 1;
	for (ll i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,K;

void input() {
  cin >>N >>K;
}

int main() {
  input();
  if (K == 0){
    cout <<(ll)N * (ll)N <<endl;
    return 0;
  }

  ll res = 0;
  // aをbで割った余りがK以上
  // 当然aはK以上でbはK+1以上
  for (int b=K+1; b<=N; b++){
    // b = K + c のとき、許容される余りは K, K+1, ..., K+c-1
    // 0,1,...,K-1 | K,K+1,...,K+c-1 | 0,1,...,K-1 | K,K+1,...
    res += (N+1) / b * (b-K);
    ll tmp = (N+1) % b;
    // 残りのN%b個をどうするか
    res += tmp > K ? tmp - K : 0;
  }
  cout <<res <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += v[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000


int main() {
	
	long long K;
	cin>>K;
	
	long long ans = 0;
	
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int k=1;k<=K;k++){
				ans += gcd(gcd(i,j),k);
			}
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
using namespace std;
const int MOD = 1e9 +7;

int main(){
    string s;
    cin >>s;
    if(s[6]-'0' <=4 && s[5]-'0' ==0) cout <<"Heisei" <<endl;
    else cout <<"TBD" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;
int X[100010];
int diff[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  REP(i, M) cin >> X[i];
  sort(X, X+M);
  REP(i, M-1) diff[i] = X[i+1]-X[i];
  sort(diff, diff+M-1, greater<int>());
  int sum = 0;
  int sub = 0;
  REP(i, M-1) {
    sum += diff[i];
    if (i < N-1) sub += diff[i];
  }
  cout << sum - sub << endl;

  return 0;
}

Measured memory_bytes: 1792
/*
	Longest Common Subsequence
	Problem: Given two strings, find the longest common subsequence for the two 
			 strings. A subsequence is a sequence of characters in the string 
			 which may or may not be a continuous part of a string.

			 For e.g.: if fdshia is the given string, the possible subsequences are:
			 		   fd, fsi, fa, dhia, sha, fdshia, a, .... and so on.

			 		   sf, hdai, fdhfive, aisdf are not subsequences of the above string
*/

#include<bits/stdc++.h>
/*#include<iostream>
#include<iomanip>
#include<math.h>
#include<string.h>
#include<vector>*/

using namespace std;

int main()
{
	string s1, s2;
	//cout << "Enter the first string: " << '\n';
	cin >> s1;
	//cout << "Enter the second string: " << '\n';
	cin >> s2;

	int dp[s1.length() + 1][s2.length() + 1] = {};
	for (int i = 0; i < s1.length(); i++)
	{
		for (int j = 0; j < s2.length(); j++)
		{
			if (s1[i] == s2[j])
			{
				dp[i + 1][j + 1] = dp[i][j] + 1; 
			}
			else
			{
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}

	//for (int i = 0; i <= s1.length(); i++)
	//{
	//	for (int j = 0; j <= s2.length(); j++)
	//	{
	//		cout << dp[i][j] << " ";
	//	}
	//	cout << '\n';
	//}

	//cout << "The length of longest common subsequence is: " << '\n';
	//cout << dp[s1.length()][s2.length()] << '\n';

//Length of longest subsequence is found.

	vector<char>sub;
	int i = s1.length(), j = s2.length();
	while (i > 0 and j > 0)
	{
		if (dp[i][j] == dp[i - 1][j])
		{
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1])
		{
			j--;
		}
		else
		{
			sub.push_back(s1[i - 1]);
			i--;
			j--;
		}
	}

	//cout << "The longest common subsequence is: " << '\n';
	for (int i = sub.size() - 1; i >= 0; i--)
	{
		cout << sub[i];
	}
	return 0;
}


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

using namespace std;

constexpr int MAXN = 500000;

int seg[MAXN * 2 + 2];
char S[MAXN + 2];

int main() {
	int N, Q;
	cin >> N >> S >> Q;
	for(int i = 0; i < N; i++)
		seg[N + i] = 1 << S[i] - 'a';
	for(int i = N - 1; i > 0; i--)
		seg[i] = seg[i << 1 ^ 0] | seg[i << 1 ^ 1];
	do {
		char op, t;
		int l, r;
		cin >> op;
		if(op == '1') {
			cin >> l >> t;
			seg[l += N - 1] = 1 << t - 'a';
			while(l >>= 1) seg[l] = seg[l << 1 ^ 0] | seg[l << 1 ^ 1];
		} else {
			cin >> l >> r;
			int k = 0;
			for(l += N - 1, r += N; l < r; l >>= 1, r >>= 1) {
				if(l & 1) k |= seg[l++];
				if(r & 1) k |= seg[--r];
			}
			cout << __builtin_popcount(k) << '\n';
		}
	} while(--Q);
}


Measured memory_bytes: 4736
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			long a = cin.Long();
			long b = cin.Long();

			Console.WriteLine(LCM(a, b));
		}

		public static long GCD(long a, long b)
		{
			if (a > b) {
				if (b == 0) {
					return a;
				}

				return GCD(b, a % b);
			} else {
				if (a == 0) {
					return b;
				}

				return GCD(a, b % a);
			}
		}

		public static long GCD(long[] values)
		{
			if (values.Length == 1) {
				return values[0];
			}

			long gcd = values[0];
			for (int i = 1; i < values.Length; ++i) {
				if (gcd == 1) {
					return gcd;
				}
				gcd = GCD(values[i], gcd);
			}

			return gcd;
		}

		public static long LCM(long a, long b)
		{
			return a / GCD(a, b) * b;
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int main() {
    std::string O, E;
    std::cin >> O >> E;

    for (size_t i = 0; i < O.size(); ++i) {
        std::printf("%c", O[i]);
        if (i != E.size()) {
            std::printf("%c", E[i]);
        }
    }

    std::cout << std::endl;

    return 0;
}


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

int main()
{
    string s;
    int i, sum;
    i = 0;
    sum = 0;
    cin >> s;
    while (s[i] != '\0')
    {
        sum += s[i] - '0';
        i++;
    }
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return (0);
}


Measured memory_bytes: 3708