akhauriyash/Code-Regression huggingface dataset:
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	string x = "ai1333";
	int n;
	cin >> n;
	n /= 100;
	cout << x;
	for (int i : range(n))cout << 3;
	cout << endl;

	return 0;
}



Measured memory_bytes: 3236
#include<stdio.h>
#include<string.h>
int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int d[n];
    for(int i=0;n>i;++i)
    scanf("%d",&d[i]);
    for(int i=0;n-1>i;++i){
        for(int j=i+1;n>j;++j){
            ans+=(d[i]*d[j]);
        }
    }
    printf("%d",ans);
    return 0;
}

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

int main() {
    ll n;
    cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    cout<<"AC"<<" "<<"x"<<" "<<count(s.begin(),s.end(),"AC")<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<count(s.begin(),s.end(),"WA")<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<count(s.begin(),s.end(),"TLE")<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<count(s.begin(),s.end(),"RE")<<endl;
    return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    for(int x = 0; x <= n; x++) {
        int tmp = x * 1.08;
        if(tmp == n) {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>a(n, 0);
    for(int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        a.at(i) = ai;
    }
    vector<int>b(n, 0);
    for(int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        b.at(i) = ai;
    }
    int max = 0;
    for(int i =0; i < n; i++){
        int sum = 0;
       for(int j = 0; j <= i; j++){
           sum += a.at(j);
       }
       for(int k = i; k<n; k++){
           sum += b.at(k);
       }
       if(sum > max){
           max = sum;
       }
    }
    cout << max << endl;
}

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

int main(){
  int n,d; cin >> n >> d;
  int a;a=0;
  int enp;enp=0;
  rep(i,n){
    a+=2*d+1;
    enp++;
    if(a>=n){
      break;
    }
  }
  cout << enp << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  bool zero = true;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a != 0) zero = false;
    mp[a]++;
  }
  if(zero) {
    cout << "Yes" << endl;
    return 0;
  }
  if(n % 3 != 0 || mp.size() > 3 || mp.size() == 1) {
    cout << "No" << endl;
    return 0;
  }
  if(mp.size() == 3) {
    bool ok = true;
    ll xs = 0;
    for(auto v : mp) {
      xs ^= v.first;
      if(v.second != n / 3) ok = false;
    }
    cout << ((xs == 0) && ok ? "Yes" : "No") << endl;
    return 0;
  }
  ll a, b;
  bool ok = true;
  for(auto v : mp) {
    if(v.second == n / 3 * 2)
      a = v.first;
    else if(v.second == n / 3)
      b = v.first;
    else
      ok = false;
  }
  cout << ((b == 0) && ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 8200
#include <cstdio>

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

using namespace std;

int main(){
	reep(y,1,10){
		reep(x,1,10){
			printf("%dx%d=%d\n",y,x,y*x);
		}
	}
	return 0;
}

Measured memory_bytes: 924
from collections import defaultdict

def main():
    W,H,N = [int(x) for x in input().split()]
    x1,y1 = 0,0
    x2,y2 = W,H
    x3,y3 = 0,0
    x4,y4 = W,H
    A = defaultdict(list)
    for _ in range(N):
        x,y,a = [int(x) for x in input().split()]
        A[a].append((x,y))
    if A[1]:
        x1,y1 = max(A[1], key=(lambda x: x[0]))
    if A[2]:
        x2,y2 = min(A[2], key=(lambda x: x[0]))
    if A[3]:
        x3,y3 = max(A[3], key=(lambda x: x[1]))
    if A[4]:
        x4,y4 = min(A[4], key=(lambda x: x[1]))
    if x1 >= x2 or y3 >= y4:
        print(0)
    else:
        print((x2-x1)*(y4-y3))

if __name__ == '__main__':
    main()

Measured memory_bytes: 65732
N, X, Y = map(int, input().split())
lst = [0 for i in range(N-1)]
for i in range(1, N+1):
    for j in range(i+1, N+1):
        k = min(abs(j-i), abs(X-i) + abs(Y-j) + 1)
        lst[k-1] += 1
for i in lst:
    print(i)

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }

const int SIZE=10005;
vector<int> G[SIZE];
int c[SIZE];

bool visited[SIZE];
int ans[SIZE];
int idx;

void dfs(int v)
{
    visited[v]=true;
    for(int u:G[v]){
        if(!visited[u]) dfs(u);
    }
    ans[v]=c[idx++];
}

signed main()
{
    int N; cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    sort(c,c+N);

    dfs(0);
    cout<<accumulate(c,c+N-1,0LL)<<endl;
    for(int i=0;i<N;i++){
        cout<<ans[i]<<' ';
    }
    cout<<endl;
} 

Measured memory_bytes: 1280
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

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

        int x = 800 * N;
        int y = (N /15) * 200;

        System.out.println(x - y);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }

    bool ok = true;
    bool ewithn = false;
    ll current = 0;
    REP(i, n - 1)
    {
        if (a[i] - a[i + 1] > 1)
        {
            ok = false;
            break;
        }
        if (a[i] - a[i + 1] == 1 && ewithn)
        {
            ok = false;
            break;
        }
        if (i > 0 && a[i] > a[i - 1])
            a[i]--;

        ewithn = (a[i] == a[i + 1]);
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(N == 1){
        cout << 0 << endl;
    }else{
        cout << (N - 1) * (1 + N - 1) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
import java.lang.Math

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()
    val s = mutableListOf<MutableMap<Int, Int>>()

    for (i in 0 until n) {
        val a = readLine()!!.toInt()
        s.add(mutableMapOf<Int, Int>())
        for (k in 0 until a) {
            val (x, y)  =readLine()!!.split(" ").map{it.toInt()}
            s[i].put(x-1, y)
        }
    }
    // println(s.lastIndex)

    var ans = -1
    for (i in 0 until (1 shl n)) { // 2^n回の繰り返し
        // println("i: ${i}")
        var cnt = 0
        var flag = true
        for (k in 0 until n) {
            if ((i and (1 shl k)) != 0) {
                cnt++
                for (key in s[k].keys) {
                    if (!(s[k][key] == 1 && (i and (1 shl key)) != 0) && !(s[k][key] == 0 && (i.inv() and (1 shl key)) != 0)) {flag = false}

                    if (!flag) break
                }
            }

            if (!flag) break
        }

        if (flag) {
            ans = Math.max(ans, cnt)
        }
    }

    println(ans)
}


Measured memory_bytes: 41848
#include <iostream>
using namespace std;
int main(void)
{

  char ch;
  int x;
  int card[4][13] = {0};

  int n;
  cin >> n; //手持ちのカードの枚数

  for (int i = 0; i < n; i++)
  {
    cin >> ch >> x;

    if (ch == 'S')
    {
      card[0][x - 1] = 1;
    }
    else if (ch == 'H')
    {
      card[1][x - 1] = 1;
    }
    else if (ch == 'C')
    {
      card[2][x - 1] = 1;
    }
    else
    {
      card[3][x - 1] = 1;
    }
  }

  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 13; j++)
    {
      if (card[i][j] == 0)
      {
        if (i == 0)
        {
          cout << "S"
               << " " << j + 1;
        }
        else if (i == 1)
        {
          cout << "H"
               << " " << j + 1;
        }
        else if (i == 2)
        {
          cout << "C"
               << " " << j + 1;
        }
        else
        {
          cout << "D"
               << " " << j + 1;
        }
        cout << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3084
#!/usr/bin/python3
a,b,c,d = 0,0,0,0
n = int(input())
s=[None]*n
for i in range(n):
	s[i] = input()
for i in range(n):
	if("AC" in s[i]):
		a+=1
	elif("WA" in s[i]):
		b+=1
	elif("TLE" in s[i]):
		c+=1
	elif("RE" in s[i]):
		d+=1
print(f"AC x {a}")
print(f"WA x {b}")
print(f"TLE x {c}")
print(f"RE x {d}")

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

int main(){
int a,b,x;
cin >> a >> b >> x;
if(a < x && a + b > x || a == x){
    cout << "YES" << endl;
}else{
    cout << "NO" <<endl;
}

}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n;
        cin>>n;
        LL a[n];
        fr(i,0,n) cin>>a[i];
        LL dp[n+1];
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);

        fr(i,2,n)
        {
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll X, Y;
  cin >> X >> Y;
  Y /= 2;
  COUT(X + Y);
  return 0;
}

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

int n;
int M[100][100];
int color[100], d[100], f[100];
int t;

void Dfs(int u) {
  color[u] = 1;
  d[u] = ++t;
  for (int v = 0; v < n; v++) if (M[u][v] && color[v] == 0) Dfs(v);
  color[u] = 2;
  f[u] = ++t;
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      v--;
      M[u][v]++;
    }
  }

  for (int i = 0; i < n; i++) if (color[i] == 0) Dfs(i);

  for (int i = 0; i < n; i++) cout << i + 1 << " " << d[i] << " " << f[i] << endl;

  return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;

    int minM = INT_MAX;
    for (int i = 0; i < n; i++) {
        int mi; cin >> mi;
        minM = min(mi, minM);
        x -= mi;
    }

    cout << n + x / minM << endl;

    return 0;
}

Measured memory_bytes: 888
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
int n,a[98]={0},d,s=0,t=0,u=0,v=0;
void fac(int n,int a[]){
	Rep(i,2,n+1){
		int j=i;
		Rep(k,2,i+1){
			if(j==1)break;
			if(j%k==0){a[k]++;j/=k;k=1;}
}}}

int pattern4_4_2(int *a){
	Rep(p,2,98)Rep(q,2,98)Rep(r,q+1,98)if(p!=q&&p!=r&&a[p]>=2&&a[q]>=4&&a[r]>=4)s++;
	return s;
}
int pattern14_4(int *a){
	Rep(p,2,98)Rep(q,2,98)if(p!=q&&a[p]>=14&&a[q]>=4)t++;
	return t;
}
int pattern24_2(int *a){
	Rep(p,2,98)Rep(q,2,98)if(p!=q&&a[p]>=24&&a[q]>=2)u++;
	return u;
}
int pattern74(int *a){
	Rep(p,2,98)if(a[p]>=74)v++;
	return v;
}

int main(){
	scanf("%d",&n);
	fac(n,a);
	d=pattern4_4_2(a)+pattern14_4(a)+pattern24_2(a)+pattern74(a);
	printf("%d",d);
	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int M,D;
	cin >> M >> D;

	int ans=0;
	for(int i=2;i<=D;i++){
		if(i%10<2 || i/10<2)	continue;
		if((i%10)*(i/10)<=M)	ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s_sub: String = read();
    let s:Vec<char>= s_sub.chars().collect();
    let length = s.iter().enumerate().filter(|x| x.0 != 0 && x.0 != s.len() - 1).count();
    let ans = format!("{}{}{}",s[0],length,s[s.len() -1]);
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 2147483647;

int main(void)
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i=0;i<n;i++){
        cin >> h.at(i);
    }
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        int move = min(k,n-i-1);
        for (int j=1;j<=move;j++){
            dp[i+j] = min(dp[i+j],abs(h.at(i+j)-h.at(i))+dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		int[] alphabet = new int[26];
		int[] ans = new int[26];
		Arrays.fill(ans, 100);
		String trash = sc.nextLine();
		for(int i=0;i<n;i++){
			s[i] = sc.nextLine();
		}
		for(int i=0;i<n;i++){
			Arrays.fill(alphabet, 0);
			String str = s[i];
//			System.out.println("poyo"+str);
			for(int j=0;j<str.length();j++){
				char c = str.charAt(j);
				int num = (int)(c-'a');
//				System.out.println(num);
				alphabet[num]++;
			}
			for(int j=0;j<ans.length;j++){
//				System.out.println((char)('a'+j)+":"+alphabet[j]);
				ans[j] = Math.min(ans[j], alphabet[j]);
			}
		}
		for(int i=0;i<ans.length;i++){
			char c = (char)(i+'a');
			for(int j=0;j<ans[i];j++){
				System.out.print(c);
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 23764
// 全探索 しにくくない？ 約数の組を作っていく
// 1からインクリメントで割るのは間に合わないがa*b=N(a<b)なら√Nでいい
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	divs := enumDiv(N)
	sort.Ints(divs)
	ans := 10000000000000
	for _, d := range divs {
		tmp := max(d, N/d)
		keta := 0
		for ; tmp > 0; tmp /= 10 {
			keta++
		}
		ans = min(ans, keta)
	}
	fmt.Println(ans)
}

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

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

func enumDiv(x int) (ret []int) {
	ret = []int{}
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			ret = append(ret, i)
			if i != 1 && i*i != x {
				ret = append(ret, x/i)
			}
		}
	}
	if len(ret) == 1 {
		ret = append(ret, x)
	}
	return
}


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


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	vector<int> arr(n,0);
	vector<int> count(n+1,0);
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	    count[arr[i]]++;
	}
	long long int out = 0;
	for(int i=0;i<n+1;i++)
	{
	    int temp = count[i];
	    if(temp>=2)
	    {
	        out = out+(temp*1LL*(temp-1))/2;
	    }
	}
	//cout<<out<<"\n";
	for(int i=0;i<n;i++)
	{
	    if(count[arr[i]]>=2)
	    {
	        int temp = count[arr[i]];
	        cout<<out-temp+1<<"\n";
	    }
	    else
	        cout<<out<<"\n";
	}
	return 0;
}

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

int n;
char s[100005];

int main() {
    int i,j,ans;
    scanf(" %s",s);
    n = strlen(s);
    i = 0; j = n-1; ans = 0;
    while(i<j) {
        if(s[i]==s[j]) i++, j--;
        else if(s[i]=='x') i++, ans++;
        else if(s[j]=='x') j--, ans++;
        else {
            printf("-1");
            return 0;
        }
    }
    printf("%d",ans);
}


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


struct node{
    node *left, *right, *parent;
    int key;
};

node *root, *NIL;

void insert(int a){
    node *y = NIL;
    node *x = root;
    node *z;

    z = (node *)malloc(sizeof(node));
    z->key = a;
    z->left = NIL;
    z->right = NIL;

    y = NIL;
    x = root;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NIL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }



}

int perParse(node *a){
    if(a == NIL){
        return 0;
    }
    //ve.push_back(u);
    std::cout << " " << a->key;
    perParse(a->left);
    perParse(a->right);
}

int inOrder(node *a){
    if(a == NIL){
        return 0;
    }
    inOrder(a->left);

    std::cout << " " << a->key;
    //ve.push_back(u);
    inOrder(a->right);
}

int main(void){
    int n;
    int a;
    std::string str;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::cin >> str;
        if(str == "insert"){
            std::cin >> a;
            insert(a);
        }else{
            inOrder(root);
            std::cout << std::endl;
            perParse(root);
            std::cout << std::endl;

        }
    }
    return 0;
}


Measured memory_bytes: 26632
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  ll N; cin>>N;
  ll num = 1;
  for(ll i = 1; i <= N; i++)num = (num*i) % INF;
  cout<<num<<endl;
}


Measured memory_bytes: 256
def solve(n, x, y):
    res_list = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = min(j - i, abs(i - x+1) + abs(j - y+1) + 1)
            res_list[d] += 1
    return res_list[1:]


n, x, y = map(int, input().split())
res_list = solve(n, x, y)
for res in res_list:
    print(res)



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

int main() {
    int n, m;
    cin >> n >> m;

    long long a, b;
    vector<pair<long long, long long>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

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

    long long sum = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        while (p[i].second > 0) {
            sum += p[i].first;
            cnt++;
            p[i].second--;

            if (m == cnt) {
                cout << sum << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 1792
n, k, q = map(int,input().split())
a = [input() for _ in range(q)]
b = [k for i in range(n)]
import numpy as np
np_b = np.array(b)
np_b -= q
np_backed_b = np_b.tolist()
for i in range(q):
  np_backed_b[int(a[i])-1] +=1
for i in range(n):
  if np_backed_b[i]<=0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 24712
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int A[110];

int bubble_sort(int a[], int n) {
    bool flag = true;
    int cnt = 0;
    for(int i=0; flag; ++i) {
        flag = false;
        for(int j=n-1; j >= i+1; --j) {
            if(a[j] < a[j-1]) {
                swap(a[j], a[j-1]);
                flag = true;
                ++cnt;
            }
        }
    }
    return cnt;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n; cin >> n;
    rep(i,n) cin >> A[i];

    int cnt = bubble_sort(A,n);
    rep(i,n) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl << cnt << endl; 

    return 0;
}



Measured memory_bytes: 3152
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string ans = "Yes";
  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    if (c[i][i] != c[i][i + 1] + c[i + 1][i] - c[i + 1][i + 1]) ans = "No";
    if (c[2][i] != c[1][i] + c[2][i + 1] - c[1][i + 1]) ans = "No";
    if (c[i][2] != c[i][1] + c[i + 1][2] - c[i + 1][1]) ans = "No";
  }
  if (c[2][2] != c[2][1] + c[1][2] - c[1][1]) ans = "No";
  cout << ans << endl;
}

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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<pair<string,int>> v(n), vv(n);
    rep(i, n){
        string s;
        int p;
        cin >> s >> p;
        v[i] = {s, -p};
        vv[i] = {s, -p};
    }

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

    rep(i, n){
        rep(j, n){
            if(v[i].first == vv[j].first and v[i].second == vv[j].second){
                ppp(j+1);
                break;
            }

        }
    }







    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int x;
	public int y;

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	
	 int N=sc.nextInt();
	 long X=sc.nextLong();
	 long result=0;
	 
	 for(int i=0;i<N;i++) {
		 long temp=sc.nextLong();
		 if(i==0) {
			 result=Math.abs(temp-X);
		 }else {
			 result=gcd(result,Math.abs(temp-X));
		 }
	 }
	 
	 System.out.println(result);
	 
			 
	 
	 
	
	 

	 
	
	 
    
}
}

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());

        long ans = n - 1;
        for (long i = 2; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                ans = Math.Min(ans, i + (n / i) - 2);
            }

        }

        Console.WriteLine(ans);

    }

}

Measured memory_bytes: 13140
/*
  AOJ 2048
  Title:Everlasting...?
  @kankichi573
*/
#include <stdio.h>

int solve(int x)
{
  int i,sum,max_;

  for(i=2;i<=x;i++)
    if((x % i)==0)
      {
	sum += i;
	max_ = i;
	while((x % i)==0)
	    x /= i;
      }
  return(max_-(sum-max_));
}
main()
{
  int a,b,i,reta,retb;

  while(scanf("%d %d",&a,&b) && (a||b))
    {
	reta=solve(a);
	retb=solve(b);
#ifdef DEBUG
      printf("%d %d\n",reta,retb);
#endif
      if(reta>retb)
	printf("a\n");
      else
	printf("b\n");
    }

  return(0);
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

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

    string s,t;
    string ans = "Yes";

    cin >> s >> t;

    for(int i=0; i<s.length(); i++){
        if(s[i]!=t[i])
            ans = "No";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main() {

    int n, m; cin >> n >> m;
    vector<vector<int>> v(n, vector<int> (m, 1));
    int k; cin >> k;
    vector<int> w(k);
    forn(k) {
        cin >> w[i];
    }
    int i1 = 0, j1 = 0;
    bool down = true;
    for(int i = 0; i < k; i++) {
        int k = w[i];
        int cnt = i + 1;
        while(k != 0) {
            if(down) {
                v[i1][j1] = cnt;
                i1++;
                if(i1 == n) {
                    i1--;
                    j1++;
                    down = false;
                }
            }
            else {
                v[i1][j1] = cnt;
                i1--;
                if(i1 < 0) {
                    down = true;
                    i1 = 0;
                    j1++;
                    down = true;
                }
            }
            k--;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j= 0 ; j < m; j++) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
class town:
    def __init__(self,room,height):
        # self.a,self.b,self.c,self.d = [[0] * room]*height,[[0] * room]*height,[[0] * room]*height,[[0] * room]*height
        self.a = [[0] * room for i in range(height)]
        self.b = [[0] * room for i in range(height)]
        self.c = [[0] * room for i in range(height)]
        self.d = [[0] * room for i in range(height)]
    def in_out(self,b,f,r,v):
        str_h = self.check(b)
        str_h[f][r] += v
    def check(self,b):
        if b == 1:
            return self.a
        if b == 2:
            return self.b
        if b == 3:
            return self.c
        if b == 4:
            return self.d
    def open_house(self):
        for a in self.a:
            print(end=' ')
            print(*a)
        print('####################')
        for b in self.b:
            print(end=' ')
            print(*b)
        print('####################')
        for c in self.c:
            print(end=' ')
            print(*c)
        print('####################')
        for d in self.d:
            print(end=' ')
            print(*d)
counts = int(input())
mytown = town(10,3)
for c in range(counts):
    b,f,r,v = map(int,input().split(' '))
    mytown.in_out(b,f-1,r-1,v)
mytown.open_house()


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int a = iin(), p = iin();
    iout((a * 3 + p)/2);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


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

using namespace std;
typedef long long ll;

int main(void) {
    string N_str;
    cin >> N_str;

    int N = stoi(N_str);

    int keta = N_str.length();

    int ans = 0;

    switch (keta)
    {
    case 1:
        ans = N;
        break;

    case 2:
        ans = 9;
        break;

    case 3:
        ans = 9 + N - 99;
        break;

    case 4:
        ans = 9 + 900;
        break;

    case 5:
        ans = 9 + 900 + N - 9999;
        break;

    case 6:
        ans = 9 + 900 + 90000;
        break;
    
    default:
        break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
LARGE = 10 ** 9 + 7

# flag_x : left < x
# flag_y : y < right
# flag_z : msb


def f(pos, flag_x, flag_y, flag_z, memo, left, right):
    if pos == -1:
        return 1
    if memo[pos][flag_x][flag_y][flag_z] != -1:
        return memo[pos][flag_x][flag_y][flag_z]
    ret = 0
    # x 0, y 0
    if flag_x or left[pos] == '0':
        ret += f(pos - 1, flag_x, 1 if right[pos] == '1' else flag_y, flag_z, memo, left, right)
    # x 0, y 1
    if (flag_x or left[pos] == '0') and (flag_y or right[pos] == '1') and flag_z:
        ret += f(pos - 1, flag_x, flag_y, flag_z, memo, left, right)
    # x 1, y 1
    if flag_y or right[pos] == '1':
        ret += f(pos - 1, 1 if left[pos] == '0' else flag_x, flag_y, 1, memo, left, right)
    ret %= LARGE
    memo[pos][flag_x][flag_y][flag_z] = ret
    return ret


def solve_greed_f(L, R):

    res_g = 0

    for i in range(L, R + 1):
        for j in range(i, R + 1):
            if j % i == j ^ i:
                res_g += 1

    return res_g


def main():

    ll, rr = map(int, input().split())

    left = '{:060b}'.format(ll)[::-1]
    right = '{:060b}'.format(rr)[::-1]

    memo = [[[[-1 for m in range(2)] for k in range(2)] for j in range(2)] for i in range(60)]

    res = f(59, 0, 0, 0, memo, left, right)

    print(res)


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 10000001;

ll A, B;


ll factor(ll x) {
	ll ans = 0;
	for (ll i = 2; i * i <= x; i++) {
		if (x % i) continue;
		ans++;
		while (!(x % i)) x /= i;
	}
	if (x != 1) ans++;
	return ans;
}

void solve() {
    cin >> A >> B;
    ll C = __gcd(A, B);
    
    cout << factor(C) + 1;
    // Add 1 to answer for 1
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            out.println(go(scan.nextLong()));
        }
        
        static long go(long x) {
            return x == 1 ? 1 : go(x/2) * 2 + 1;
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll x;
  cin >> x;
  ll ans;
  ans = x/11;
  ll tmp = ans;
  ans *= 2;
  if(x-tmp*11>6){
    ans += 2;
  }
  else if(x-tmp*11>0){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long

#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}


void outp(int i){
	printf("%d",i);
}

LL mod(LL i){
	return i % 1000000007;
}

//int homework(){
//	int N = inp();
//	int M = inp();
//	int A[M];
//	int sum = 0;
//	for(int i = 0;i < M;i++){
//		cin >> A[i];
//		sum += A[i];
//	}
//
//
//	int answer = N - sum;
//
//	if(answer < 0)
//		cout << -1<< endl ;
//	else
//		cout << answer << endl;
//
//
//	return 0;
//}
//
//int management(){
//	int N = inp();
//
//	int A[N];
//	int B[N] = {0};
//
//	for(int i = 1;i < N;i++){
//		cin >> A[i];
//		B[A[i] - 1]++;
//	}
//
//	for(int i = 0;i < N;i++){
//		cout << B[i] << "\n";
//	}
//
//	return 0;
//}

int SoLNs(){

	 LL N = inp();
	 LL K = inp();

	 LL sum = 0;

	for( LL k = K; k <= N+1;k++){

		 LL min = (k-1)*k/2;
		 LL max =  N*(N+1)/2 - (N-k)*(N-k+1)/2;


		sum = mod(sum + max - min + 1);


	}


	outp(sum);

	return 0;

}
signed main() {
	//homework();
	//management();
	SoLNs();

	return 0;
}



Measured memory_bytes: 3816
N, K = map(int, input().split())
A_list = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    A.append(d)
    A_list.append(A)
dic_S = {}
for i in range(K):
    for j in range(len(A_list[i])-1):
        if A_list[i][j] in dic_S:
            dic_S[A_list[i][j]] += 1
        else:
            dic_S[A_list[i][j]] = 1
ans = 0
for i in range(1, N+1):
    if i not in dic_S:
        ans += 1
print(ans)


Measured memory_bytes: 9208
import copy
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cnt = 0
fin = set([i + 1 for i in range(n)])
def path(now, edges, past):
    global cnt
    if set(past) == fin:
        cnt += 1
        return 0
    for i in range(len(edges)):
        if now == edges[i][0] and edges[i][1] not in past:
            new_now = edges[i][1]
            new_edges = copy.deepcopy(edges)
            new_past = copy.deepcopy(past)
            new_edges.pop(i)
            new_past.append(edges[i][1])
            # print("now", now, "edges", edges, "new", new_edges, "past", past, "cnt", cnt)
            path(new_now, new_edges, new_past)
        elif now == edges[i][1] and edges[i][0] not in past:
            new_now = edges[i][0]
            new_edges = copy.deepcopy(edges)
            new_past = copy.deepcopy(past)
            new_edges.pop(i)
            new_past.append(edges[i][0])
            # print("now", now, "edges", edges, "new", new_edges, "past", past, "cnt", cnt)
            path(new_now, new_edges, new_past)

for i in range(m):
    if ab[i][0] == 1:
        edges = copy.deepcopy(ab)
        edges.pop(i)
        path(ab[i][1], edges, [1, ab[i][1]])
    elif ab[i][1] == 1:
        edges = copy.deepcopy(ab)
        edges.pop(i)
        path(ab[i][0], edges, [1, ab[i][0]])
print(cnt)


Measured memory_bytes: 3556