akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()
s = list(S)
r = 0
g = 0
b = 0
for i in range(N):
    if s[i] == 'R':
        r = r + 1
    if s[i] == 'G':
        g = g + 1
    if s[i] == 'B':
        b = b + 1
p = 0
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j-i < N:
            if s[2*j-i] == s[i] or s[2*j-i] == s[j] or s[i] == s[j]:
                p = p
            else:
                p = p+1
        else:
            break
print(r*g*b-p)

Measured memory_bytes: 9156
l=list(map(int, input().split()))
l.sort()
ans=0

if l[2]%2==l[1]%2 and l[2]%2==l[0]%2:
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==1 and l[0]%2==1:
    l[1]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==0 and l[0]%2==0:
    l[1]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==1 and l[0]%2==0:
    l[2]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==0 and l[0]%2==1:
    l[2]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==1 and l[0]%2==0:
    l[2]+=1
    l[1]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==0 and l[0]%2==1:
    l[2]+=1
    l[1]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2



print(ans)

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

# D - .. (Double Dots)
from collections import deque
sys.setrecursionlimit(pow(10, 6))

def set_route(start, goal):
	global routes
	
	routes[goal].append(start)


def search(que):
	global routes
	global guides

	if len(que) > 0:
		goal = que.popleft()

		for start in routes[goal]:
			if guides[start] == 0:
				guides[start] = goal
				que.append(start)
		
		search(que)
	else:
		return 


n, m = map(int, input().split())
routes = dict()

# 空の辞書(routes)を作成
for i in range(1, n + 1):
	routes[i] = []

# すべての出入り口の情報を取得("routes"に保存)
for i in range(m):
	a, b = map(int, input().split())
	set_route(a, b)
	set_route(b, a)

# 道しるべ(最後に出力)を保存するためのリスト
guides = [0] * (n + 1)

que = deque()
que.append(1)
search(que)

ans = guides[2:]

if 0 in ans:
	print('No')
else:
	print('Yes')
	
	for a in ans:
		print(a)

Measured memory_bytes: 119780
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


int main() {

	int N;
	cin >> N;
	map<string, int> inputs;
	for (int i = 0; i < N; i++) {
		string tmp1;
		cin >> tmp1;

		//要素の検索
		map<string, int>::iterator ite;
		ite = inputs.find(tmp1);
		if (ite != inputs.end()) {
			//値の取得
			int value = ite->second;
			//要素の削除
			inputs.erase(tmp1);
			//要素の代入
			inputs.insert(make_pair(tmp1, value + 1));
		}
		else {
			//要素の代入
			inputs[tmp1] = 1;
		}

	}

	int num = 0;
	//要素の全探索
	for (map<string, int>::iterator ite = inputs.begin(); ite != inputs.end(); ite++) {
		//値の取得
		num = max(num,ite->second);
	}

	vector<string> output;
	for (map<string, int>::iterator ite = inputs.begin(); ite != inputs.end(); ite++) {
		//値の取得
		if (ite->second == num) output.push_back(ite->first);
	}

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

	for (int i = 0; i < output.size(); i++) {
		cout << output[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 26868
n, m = map(int, input().split())
arr = [0] * (n + 1)
arr2 = [0] * (n + 1)
corr = 0
pen = 0
for i in range(m):
    p, s = map(str, input().split())
    if s == 'AC':
        arr[int(p)] = 1
    else:
        if arr[int(p)] == 0:
            arr2[int(p)] -= -1
for i in range(n + 1):
    if arr[i] == 1:
        corr -= -1
        pen += arr2[i]
print(corr, pen)

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

int main()
{
    int n; cin>>n;
    vector<int> X(n), O(n);
    for(int i=0; i<n; ++i) {
        int a; cin>>a;
        for(int j=0; j<a; ++j) {
            int x, y; cin>>x>>y;
            (y ? O : X)[i]|=1<<--x;
        }
    }
    int res=0;
    for(int i=0; i<(1<<n); ++i) {
        bool ok=true;
        for(int j=0; j<n; ++j) if ((i>>j)&1)
            if (!((O[j]&i)==O[j] and (X[j]&~i)==X[j])) ok=false;
        if (ok) res=max(res, __builtin_popcount(i));
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll m[N],s[N];
int main(){
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
   cin>>n;
   for(int i=0;i<n+1;i++){
    cin>>m[i];
   }
   for(int i=0;i<n;i++){
    cin>>s[i];
   }
   ll ans=0;
   for(int i=0;i<n;i++){
    if(m[i]>s[i]){
       ans+=s[i];
       s[i]=0;


    }else {
    ans+=m[i];
    s[i]-=m[i];
    m[i]=0;
    ans+=min(s[i],m[i+1]);
    m[i+1]-=s[i];
    m[i+1]=max(m[i+1],1LL*0);



    }
   }

   cout<<ans;


    return 0;
}


Measured memory_bytes: 5128
N, Y = map(int, input().split())


def f():
  x = -1
  y = -1
  z = -1

  for i in range(N+1):

    for j in range(N+1-i):
      temp = N - i - j

      total = i * 10000 + j * 5000 + temp * 1000

      if total == Y:
        x = i
        y = j
        z = temp
  
  ans = list(map(str,[x, y, z]))

  return ' '.join(ans)

print(f())

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
static const int M=10000;
static const int INF=(1<<20);
int n;
vector<pair<int,int > > a[M];
void dijkstra(){
	priority_queue<pair<int,int> > Q;
	int col[M];
	int d[M];
	for(int i=0;i<n;i++){
		col[i]=0;
		d[i]=INF;
	}
	d[0]=0;col[0]=1;
	Q.push(make_pair(0,0));
	while(!Q.empty()){
		pair<int,int>f=Q.top();Q.pop();
		int u=f.second;col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<a[u].size();j++){
			int v=a[u][j].first;
			if(col[v]==2)continue;
			if(d[v]>d[u]+a[u][j].second){
				d[v]=d[u]+a[u][j].second;
				Q.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<i<<' '<<(d[i]==INF?-1:d[i])<<endl;
}
int main() {
	int k,u,v,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++){
			cin>>v>>c;
			a[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();
}

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

int main(){
	int a;
	while(cin>>a){
		int w[10]={},j=0;
		while(a){
			rep(i,0,10){
				if(pow(2,i)<=a && a<pow(2,i+1)){
					a-=pow(2,i);
					w[i]++;
				}
			}
		}
		rep(i,0,10){
			if(w[i]){
				if(j==0){
					cout<<pow(2,i);
					j++;
				}else cout<<" "<<pow(2,i);
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e6 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  ;
}
void solve() {
  double ans;
  int kisu = 0;
  rep(i, 1, N) {
    if (i & 1) {
      kisu++;
    }
  }
  cout << (double)(kisu / (double)(N)) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
sc = []
for i in range(M):
    addList = list(map(int, input().split()))
    sc.append(addList)
a = 10**(N-1)
while a < 10**N:
    j = str(a)
    bingo = True
    for l in sc:
        if int(j[l[0]-1]) != l[1]:
            bingo = False
    if bingo:
        break
    else:
        a += 1

if N==1 and M==1 and sc==[[1,0]]:
    print(0)
elif a == 10**N and bingo == False:
    print(-1)
elif M == 0 and N!=1:
    print(10**(N-1))
elif M == 0 and N==1:
    print(0)
else:
    print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
int a[maxn];
int b[maxn];
int c[maxn];

int f[maxn];
int get(int r) {
    int res = 0;
    for (int i = r - 1; i >= 0; i = (i & (i + 1)) - 1)
        res += f[i];
    return res;
}
void put(int r) {
    for (int i = r; i < maxn; i |= i + 1)
        f[i]++;
}

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    vector<int> val;
    forn (i, n) {
        cin >> a[i];
        val.push_back(a[i]);
    }
    sort(all(val));
    int sos = 0;
    forn (i, n) {
        int x = lower_bound(all(val), a[i]) - val.begin();
        if (i % 2 != x % 2)
            ++sos;
    }
    assert(sos % 2 == 0);
    cout << sos / 2 << '\n';
}


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

int main() {
    int N;
    int count = 0;
    int res = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    int num = A.at(0);
    for (int i = 0; i < N; i++) {
        if (A.at(i) == num) count++;
        else {
            if (count % 2 == 1) res++;
            count = 1; 
            num = A.at(i);
        }
        if (i == N - 1 && count % 2 == 1) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;



int main() {
   int N,M;
   cin>>N>>M;
   bool judge[N+1];
   int penalty[N+1];
   rep3(i,N){
       judge[i]=false;
       penalty[i]=0;
   }
   int p;
   string S;
   rep(i,M){
       cin>>p>>S;
       if(S=="AC"){
           judge[p]=true;
       }
       else if(judge[p]==false){
           penalty[p]++;



       }
   }
   int all_penalty=0,correct_num=0;
   rep3(i,N){
       if(judge[i]==true){
           all_penalty+=penalty[i];
           correct_num++;
       }
   }
cout<<correct_num<<" "<<all_penalty<<endl;
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> f;
    int n;
    int p;
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= x; y++)
        {
            for (int z = 1; z <= y; z++)
            {
                n = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
                if(x==y && y==z){
                    p = 1;
                }else if(x!=y && y!= z && z!=x){
                    p = 6;
                }else{
                    p = 3;
                }
                f[n] += p;
            }
        }
    }
    for (int n = 1; n <= N; n++)
    {
        cout << f[n] << "\n";
    }
}

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int k;
int cnt;
int Limit = 20;
int x[21];
bool ok=false;
void trys(int i)
{
    for(int j = -1;j <= 1 ;  j++)
    {
        if(ok)
            return;
        int t = x[i-1] + j;
        if(t<0||t>=10)
            continue;
        x[i] = t;
        if(i==Limit)
        {
            cnt++;
            if(cnt==k)
            {
                for(int i=1;i<=Limit;i++)
                {
                    cout<<x[i];
                    ok=true;
                }
                return;
            }
        }
        else
            trys(i+1);
    }
}
int main()
{
    cin>>k;
    if(k<=9)
    {
        cout<<k;
        return 0;
    }
    cnt=9;
    for(int i=2;i<=20;i++)
    {
        Limit=i;
        for(int j=1;j<=9;j++)
        {
            x[1]=j;
            trys(2);
            if(ok)
                return 0;
        }
    }
    return 0;
}


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

long long naive(long long N){
  long long ret = 0;
  for(long long i = 2; i <= N; ++i){
    long long t = N;
    while(t >= i){
      if(t%i) t -= i;
      else t /= i;
    }
    ret += (t == 1);
  }
  return ret;
}

long long solve(long long N){
  long long ans = 1, N_ = N-1;
  if(N != 2) ++ans;

  for(long long i = 2; i*i <= N_; ++i){
    if(N_%i) continue;
    ++ans;
    ans += (N_/i != i);
  }
  
  for(long long i = 2; i*i <= N; ++i){
    if(N%i) continue;
    long long t = N;
    while(t%i == 0) t /= i;
    ans += (t%i == 1);
  }
  return ans;
}

int main(){
  long long N;
  cin >> N;
  // for(long long i = 2; i <= 10000; ++i){
  //   if(naive(i) != solve(i)){
  //     printf("naive(%lld) = %lld\nsolve(%lld) = %lld\n",i,naive(i),i,solve(i));
  //   }
  // }
  cout << solve(N) << endl;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vll b(n+1);
    rep(i, n) b[i+1] = b[i] + a[i];
    map<ll, int> cnt;
    rep(i, n+1) cnt[b[i]]++;
    ll ans = 0;
    for (auto p : cnt) {
        if (p.second <= 1) continue;
        ans += (ll)p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17876
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include<algorithm>
using namespace std;
#define ll long long

int main() {
	int n, hoge, k;
	vector<int> b, ans;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> hoge;
		b.push_back(hoge);
	}
	bool f = true;
	k = n;

	while (f) {
		f = false;
		for (int i = k; i > 0; i--) {
			if (b[i-1] == i) {
				ans.push_back(b[i-1]);
				b.erase(b.begin() + (i - 1));
				f = true;
				k--;
				break;
			}
		}
	}
	if (b.size() == 0) {
		reverse(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); i++) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
for i in 0.. n-1
  o=0
  r=[0,0,0]
  p=0
  while o<3
    case gets.chomp
    when "HIT"
      r.unshift(1)
      if r.pop==1
        p+=1
      end
    when "OUT"
      o+=1
    when "HOMERUN"
      r.unshift(1)
      for j in 0.. 3
        if r[j]==1
          p+=1
        end
      end
      r=[0,0,0]
    end
  end
  puts p
end

Measured memory_bytes: 2328
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        double a = scanner.nextInt();
        if (a < 1200) {
        	System.out.println("ABC");
        }else if (a < 2800) {
        	System.out.println("ARC");
        }else {
        	System.out.println("AGC");
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21460
#include<stdio.h>
int pow_i(int x, int y){
	int n = 1;
	for(int i=0; i<y; i++){
		 n *= x;
	}
	return n;
}
int main(void){
	int x = 0;
	int n, m;
	int s, c;
	int flg = 1;
	scanf("%d", &n);
	scanf("%d", &m);
	for(int i=0; i<m; i++){
		scanf("%d", &s);
		scanf("%d", &c);
		if(s == 1 && c == 0 && n != 1){
			flg = 0;
		}
		else if(x/pow_i(10, n-s)-(x/pow_i(10, n-s+1))*10 == 0){
			x += pow_i(10, n-s)*c;
		}
		else if(x/pow_i(10, n-s)-(x/pow_i(10, n-s+1))*10 == c){
			//  do nothing
		}
		else{
			flg = 0;
		}
	}
	if(x-pow_i(10, n-1) < 0 && n != 1){
		x += pow_i(10, n-1);
	}
	if(flg == 0){
		x = -1;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            args=new string[3];
            args[0] = console.ReadLine();
            if(args[0].Count()==26)
            {
                 args[1] = ((char)(25 - args[0].Skip(1).Zip(args[0],(a,b)=>a-b).Reverse().TakeWhile(i=>i<0).Count())).ToString();
                 if(args[1][0]==0)
                     console.WriteLine(-1);
                 else
                 {
                 var s = args[0].Take(args[1][0]).Select((v,i)=>i==args[1][0]-1?args[0].Last(c=>c>args[0][args[1][0]-1]):v);
                 
                 console.WriteLine(string.Join("",s));
                 }
            }
            else
                console.WriteLine(args[0] +(char)('a'+ args[0].OrderBy(c=>c).Where((c,i)=>c-i=='a').Count()));
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    cin>>N>>K;
    ll count=K;
    rep1(i, N-1){
        count*=(K-1);
    }
    cout<<count<<endl;
    return 0;
}


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

namespace AtCoder.ABC
{
	class QuestionB
	{
		public static void Main(string[] args)
		{
			var kv = Console.ReadLine().Split(" ").Select(q => int.Parse(q)).ToArray();
			var k = kv[0];
			var x = kv[1];

			var min = x - (k - 1);
			var max = x + (k - 1);

			min = Math.Max(min, -1 * 1000000);
			max = Math.Min(max, 1000000);

			for(int i = min; i < max; i++) {
				Console.Write($"{i} ");
			}
			Console.WriteLine(max);
		}
	}
}


Measured memory_bytes: 28244
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]){
    int r, c, sum, total_sum = 0;
    scanf("%d %d", &r, &c);
    int table[r+1][c+1];

    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }

    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d", &table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;

    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ", table[i][j]);
        }
        printf("%d\n", table[i][c]);
    }
    return 0;
}



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

#define int long long

const int N = 100 + 1;

int32_t main(){
  	int n;
  	cin >> n;
  	int g[n][n] = {};
  	for(int i = 0; i < n; i++){	
       int m, deg;
       cin >> m >> deg;
       for(int i = 0; i < deg; i++){
		  int x;
		  cin >> x;
		  g[m - 1][x - 1] = 1;
		}
    }
   for(int i = 0; i < n; i++){
	 for(int j = 0; j < n; j++){
		 if (j) cout << " ";
		 cout << g[i][j];
	   }
	  cout << endl;  
	 } 
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  FOR(i, 1, N) {
    if(S[i] == 'E') { count++; }
  }
  int ans = count;
  REP(i, N - 1) {
    if(S[i] == 'E' && S[i + 1] == 'E') {
      count--;
    }
    else if(S[i] == 'W' && S[i + 1] == 'W') {
      count++;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}



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

int d[100003];

int main(){
	int N , M; cin >> N >> M;
	for(int i = 1 ; i <= M ; ++i){int p , q; cin >> p >> q; ++d[p]; ++d[q];}
	for(int i = 1 ; i <= N ; ++i) if(d[i] & 1){cout << "NO"; return 0;}
	cout << "YES"; return 0;
}


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

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

using namespace std;

const int INF=1e9+1;

int main(){
	int n,W,w[100],v[100];
	scanf("%d%d",&n,&W);
	rep(i,n) scanf("%d%d",&w[i],&v[i]);

	int dp[100001];
	rep(a,1e5+1) dp[a]=INF;
	dp[0]=0;
	rep(i,n) for(int a=1e5;a>=v[i];a--) dp[a]=min(dp[a],dp[a-v[i]]+w[i]);

	int ans=0;
	rep(a,1e5+1) if(dp[a]<=W) ans=a;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 768
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  n2 = ceil(sqrt(n)) + 1
  ans = INF
  for i in range(1,n2):
    j = n//i
    if i*j==n:
      ans = min(ans, i+j-2)
  print(ans)
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 20080
import math
from collections import defaultdict
# 0以上整数x「未満」の素数をリストに格納して返す
n, p = map(int, input().split())

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0  # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
#pr = primes(p + 1)
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

pr = prime_factors(p)
di = {}
di = defaultdict(int)
for i in pr:
    while p % i == 0:
        p = p // i
        di[i] += 1

ans = 1
ww = 1
for i in di:
    while True:
        if di[i] >= ww * n:
            ans *= i
            ww += 1
        else:
            ww = 1
            break
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    } else if(n==2){
        int a,b;
        cin >>a;
        cin >>b;
        cout << a+b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n,a,b=[int(i) for i in input().split()]
clear=0
abroad=0
s=input()
for i in s:
    if i=="a":
        if clear<a+b:
            print("Yes")
            clear+=1
        else:
            print("No")
    elif i=="b":
        if clear<a+b and abroad<b:
            print("Yes")
            clear+=1
        else:
            print("No")
        abroad+=1
    else:
        print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

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

    ull movable[5];

    ull movableMinTime = std::numeric_limits<ull>::max();
    int movableMinTimeIdx = 0;

    for (int i = 0; i < 5; i++) {
        cin >> movable[i];

        if (movable[i] < movableMinTime) {
            movableMinTime = movable[i];
            movableMinTimeIdx = i;
        }
    }

    ull personCountsAt[6] = { 0 };
    personCountsAt[0] = N;

    auto isFinished = [&]() {
        return personCountsAt[5] == N;
    };

    ull totalTimeToDeliverAfterMinPos = N / movable[movableMinTimeIdx] + (N >= movable[movableMinTimeIdx] && N % movable[movableMinTimeIdx] > 0 ? 1 : 0);
    if (totalTimeToDeliverAfterMinPos <= 0) {
        cout << "5" << endl;
        return 0;
    }
    totalTimeToDeliverAfterMinPos += 4;
    cout << totalTimeToDeliverAfterMinPos << endl;
    return 0;

    //ull waitTimeForLastGroup = 

    //ull t = 0;
    //for (; ;) {
    //    if (isFinished()) {
    //        break;
    //    }

    //    ull maxMoveTimes = std::numeric_limits<ull>::max();
    //    bool movesChanged = false;

    //    for (int i = 4; i >= 0; i--) {
    //        ull moves = std::min(movable[i], personCountsAt[i]);
    //        if (moves > 0) {
    //            movesChanged = true;
    //            maxMoveTimes = std::max(ull(1), std::min(maxMoveTimes, personCountsAt[i] / moves));
    //        }
    //    }
    //    if (!movesChanged) {
    //        maxMoveTimes = 1;
    //    }
    //    for (int i = 4; i >= 0; i--) {
    //        ull moves = std::min(movable[i], personCountsAt[i]);
    //        personCountsAt[i] -= moves * maxMoveTimes;
    //        personCountsAt[i + 1] += moves * maxMoveTimes;
    //    }

    //    t += maxMoveTimes;
    //}

    //cout << t << endl;


    //return 0;
}

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

typedef long long ll;
ll N, M;
vector<pair<ll, pair<ll,ll>>> obs;

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        ll H;
        cin >> H;
        obs.push_back(make_pair(H, make_pair(0, 0)));
    }
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--, B--;
        if(obs[A].first > obs[B].first){
            obs[A].second.first++;
            obs[A].second.second++;
        }
        else{
            obs[A].second.second++;
        }
        if(obs[B].first > obs[A].first){
            obs[B].second.first++;
            obs[B].second.second++;
        }
        else{
             obs[B].second.second++;
        }
    }
    ll res = 0;
    for(int i = 0; i < N; i++){
        if(obs[i].second.first == obs[i].second.second){
            res++;
        }
    }
    cout << res << endl;
    
}

Measured memory_bytes: 6396
array = []
gets.split(" ").each do |n| 
if ["+","-","*"].include?(n)
  a = array.pop
  b = array.pop
  case n
    when "+"
      array.push(b + a)
    when "-"
      array.push(b - a)
    when "*"
      array.push(b * a)
  end
  next
end
array.push(n.to_i)
end

puts array[0]


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

int main(void){
    ll n;
    cin >> n;

    ll count[9];
    rep(i, 9){
        count[i] = 0;
    }

    ll a[n];
    rep(i, n){
        cin >> a[i];
        if(a[i] <= 399){
            count[0]++;
        }else if(a[i] <= 799){
            count[1]++;
        }else if(a[i] <= 1199){
            count[2]++;
        }else if(a[i] <= 1599){
            count[3]++;
        }else if(a[i] <= 1999){
            count[4]++;
        }else if(a[i] <= 2399){
            count[5]++;
        }else if(a[i] <= 2799){
            count[6]++;
        }else if(a[i] <= 3199){
            count[7]++;
        }else{
            count[8]++;
        }
    }

    ll cou = 0;
    rep(i, 8){
        if(count[i]){
            cou++;
        }
    }

    ll cou_min = cou;
    if(count[8] && cou == 0){
        cou_min += 1;
    }

    cout << cou_min << " " << cou + count[8] << endl;
    return 0;

}


Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  //val ls = in.head.split(' ')
  val S = in(1)
  val K = in(2).toInt
  val c = S(K-1)
  val ret = S.map(e => if(e==c) e else '*')
  println(ret)
}


Measured memory_bytes: 25416
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const double pi = acos(-1);
const double g = -9.8;

int d(int x)
{
	int ans = 0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans;
}

int main()
{
	int n,l,r;
	scanf("%d %d %d",&n,&l,&r);
	int ans=0;
	for(int i=1;i<=n;i++){
		int sum=d(i);
		if(sum>=l&&sum<=r){
			ans+=i;

		}
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int n;
   cin>>n;
   vector<int> a{2,4,5,7,9};
   if(n%10==3) cout<<"bon";
   else if(find(a.begin(),a.end(),n%10)!=a.end())
      cout<<"hon";
   else cout<<"pon";
}

Measured memory_bytes: 3640
#include<iostream>

int main(){
    int K, S;
    std::cin >> K >> S;
    int cnt = 0;
    int threshold = std::min(K, S);
    for(int x = 0; x <= threshold; x++){
        for(int y = 0; y <= threshold; y++){
            int z = S - x - y;
            if(0 <= z && z <= threshold){
                cnt++;
            }
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)        cout<<a<<endl;
#else
#define tr(a)    
#endif
#define int         long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)    for(int i=a;i<b;i++)
using namespace std;

void solve(){
    ll N;
    cin>>N;
    vector<ll> x(N);
    ll sum=0;
    rep(i,0,N)cin>>x[i],sum+=x[i];
    if(sum%((1LL*N*(N+1))/2)){
        cout<<"NO\n";
        return;
    }
    vector<ll>ans(N);
    ll total=sum/((1LL*N*(N+1))/2);
    rep(i,0,N){
        if((total-x[(i+1)%N]+x[i])%N){
            cout<<"NO\n";
            return;
        }
        ans[i]=(total-x[(i+1)%N]+x[i])/N;
        if(ans[i]<0){
            cout<<"NO\n";
            return;
        }
    }
    sum=0;
    rep(i,0,N){
        sum+=ans[i];
    }
    if(sum!=total){
        cout<<"NO\n";
        return;
    }
    cout<<"YES\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, M;
  ci(N, M);
  ve<ve<char>> A(N, ve<char>(N)), B(M, ve<char>(M));
  rep(i, N){
    st a;
    ci(a);
    rep(j, N){
      A.at(i).at(j) = a.at(j);
    }
  }
  rep(i, M){
    st b;
    ci(b);
    rep(j, M){
      B.at(i).at(j) = b.at(j);
    }
  }
  rep(i, N - M + 1){
    rep(j, N - M + 1){
      bool f = 1;
      rep(k, M){
        rep(l, M){
          if(A.at(i + k).at(j + l) != B.at(k).at(l)){
            f = 0;
          }
        }
      }
      if(f){
        co("Yes");
        rt;
      }
    }
  }
  co("No");
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  rep(i,n) if(s[i]!=t[i]) ++ans;
  cout << ans << endl;
}


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

int main(){
	string a,b,c,d;

	cin >>a>>b>>c;
	d=d+a[0];
	d=d+b[0];
	d=d+c[0];
	transform(d.begin(), d.end(), d.begin(),::toupper);
	cout << d << endl;
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
bool isPrime[mxn];
vi primes;

void sieve(){
	memset(isPrime,1,sizeof(isPrime));
	isPrime[0]=isPrime[1]=0;
	for(int i=2; i<mxn; i++){
		if(isPrime[i]){
			primes.eb(i);
			for(int j=2*i; j<mxn; j+=i){
				isPrime[j]=0;
			}
		}
	}
	return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	sieve();
	int x;
	cin >> x;
	auto ptr = lower_bound(all(primes),x)-primes.begin();
	cout << primes[ptr] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 512
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
    int n;
    string s, t1, t2;

    cin >> n;
    cin >> s;

    if (n % 2 == 1) {
        cout << "No" << endl;
    }
    else {
        t1 = s.substr(0, n / 2);
        t2 = s.substr(n/2, n / 2);
        //cout << t1 << endl;
        //cout << t2 << endl;
        if (t1 == t2) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
local function gcd(a,b)
    if b == 0 then
        return a
    else
        return gcd(b, a % b)
    end
end

local function gcdmany(tbl)
    local ans = tbl[1]
    for i=2,#tbl do
        ans = gcd(ans, tbl[i])
    end
    return ans
end

local function lcm(a, b)
    return a // gcd(a, b) * b
end

local function lcmmany(tbl)
    local ans = tbl[1]
    for i=2, #tbl do
        ans = lcm(ans, tbl[i])
    end
    return ans
end

---
local A, B, C, D = io.read("n", "n", "n", "n")
local function candiv(x)
    return (B // x) - ((A-1) // x)
end
local total = B - A + 1
local c_div = candiv(C)
local d_div = candiv(D)
local cd_lcm = lcm(C, D)
local cd_div = candiv(cd_lcm)
local ans = total - c_div - d_div + cd_div
print(ans)


Measured memory_bytes: 760
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> conflict(M);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    conflict[i] = {b, a};
  }
  sort(conflict.begin(), conflict.end());

  int answer = 1;
  int current = conflict[0].first - 1;
  for(int i = 1; i < M; ++i) {
    if(current < conflict[i].second) {
      ++answer;
      current = conflict[i].first - 1;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            max = Math.max(max, num);
            min = Math.min(min, num);
        }
        if (max == Integer.MIN_VALUE || min == Integer.MAX_VALUE) {
            System.out.println(0);
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    for (int index = 1; index <= S.size(); index+=2)
    {
        cout << S[index-1];
    }
    cout << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
    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(ll 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;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;
// Nとnはll型(mintではない)
// -------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i=K; i<=N+1; i++){
        ll low = i*(i-1LL)/2LL;
        ll high = (N+1LL)*N/2LL;
        high -= (N-i)*(N-i+1LL)/2LL;
        // cout << i << " " << low << " " << high << enld;
        ans += high - low + 1LL;
        ans %= mod;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 3624
from collections import Counter
import numpy as np
 
N = int(input())
A = np.array(list(map(int, input().split())))
A_set = np.unique(A)
count_dict= Counter(A)
count_sum = np.sum([count_dict[i]*(count_dict[i]-1)/2 for i in A_set])
    
for i in A:
    print(int(count_sum-count_dict[i]+1))

Measured memory_bytes: 34148
#include<iostream>

using namespace std;

int main() {
  int p, q, r;
  cin >> p >> q >> r;
  if (p + q <= q + r && p + q <= r + p) {
    cout << p + q << endl;
  } else if (q + r <= p + q && q + r <= r + p) {
    cout << q + r << endl;
  } else {
    cout << r + p << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A == B && B == C) {
    cout << 1 << endl;
  }
  else if (A != B && A != C && B != C) {
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

void solveCase(int caseNo)
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll lcm = 1;
    for (auto &x : a)
    {
        cin >> x;
        x /= 2;
        lcm = lcm / __gcd(lcm, x) * x;
        if (lcm > m)
        {
            cout << 0 << '\n';
            return;
        }
    }
    for (auto &x : a)
    {
        if ((lcm / x) % 2 == 0)
        {
            cout << 0 << '\n';
            return;
        }
    }
    cout << 1 + (m - lcm) / (lcm * 2) << '\n';
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int A[111111], B[111111];

map<int, vector<int>> adj;
set<int> visited;

void go(int v) {
  visited.insert(v);
  for (auto u: adj[v]) if (visited.find(u) == visited.end()) go(u);
}

int main() {
  int N;
  scanf("%d", &N);
  int s = 0;
  REP(i,N) {
    scanf("%d", &A[i]);
    s ^= A[i];
  }
  A[N] = s;

  s = 0;
  REP(i,N) {
    scanf("%d", &B[i]);
    s ^= B[i];
  }
  B[N] = s;

  multiset<int> S;
  REP(i,N+1) S.insert(A[i]);
  REP(i,N+1) {
    if (S.find(B[i]) == S.end()) {
      printf("-1\n");
      return 0;
    }
    S.erase(S.find(B[i]));
  }

  int result = 0;
  REP(i,N) {
    if (A[i] != B[i]) {
      adj[B[i]].pb(A[i]);
      ++result;
    }
  }
  if (result == 0) {
    printf("0\n");
    return 0;
  }
  ++result;
  adj[B[N]].pb(A[N]);

  for(auto& p: adj) {
    if (visited.find(p.st) == visited.end()) {
      ++result;
      go(p.st);
    }
  }
  printf("%d\n", result - 2);

}


Measured memory_bytes: 24448