akhauriyash/Code-Regression huggingface dataset:
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 100005

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b, c;
	cin >> a >> b >> c;
	a += b + c;
	if(a >= 22)
		cout << "bust" << '\n';
	else
		cout << "win" << '\n'; 
	



	return 0;
}





















Measured memory_bytes: 256
n = gets.to_i
x = gets.split.map(&:to_i)
min = x.inject(0){|r,i| r + i ** 2}

1.upto(100) do |d|
    m = x.inject(0){|r,i| r + (i - d) ** 2}
    min = m if min > m
end

puts min

Measured memory_bytes: 1788
class Array
  def swap!(a, b)
    raise ArgumentError unless a.between?(0, self.count-1) && b.between?(0, self.count-1)

    self[a], self[b] = self[b], self[a]

    self
  end

  def swap(a, b)
    self.dup.swap!(a, b)
  end
end

n = gets.to_i
@arr = gets.split.map(&:to_i)

def partition(p, r)
  x = @arr[r]
  i = p - 1
  (p...r).each do |j|
    if @arr[j] <= x
      i += 1
      @arr.swap!(i, j)
    end
  end
  @arr.swap!(i+1, r)
  
  i+1
end

q = partition(0, n - 1)

n.times do |i|
  print " " unless i == 0
  print "[" if i == q
  print @arr[i]
  print "]" if i == q
end 

print "\n"


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  
  ll a,b;
  cin >> a >> b;

  if(a==b) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n,k;
    cin >> n >> k;
    VI A(n+1);
    REP1(i,1,n) {
        cin >> A[i];
    }
    int fast=A[A[1]], slow=A[1];
    while ( fast!=slow ) {
        fast=A[A[fast]];
        slow=A[slow];
    }
    fast=1;
    int d=0;
    while ( fast!=slow ) {
        fast=A[fast];
        slow=A[slow];
        // cout << fast << ' ' << slow << '\n';
        d++;
    }
    // cout << "here" << '\n'; 

    int sz=1;
    fast=A[slow];
    while ( fast!=slow ) {
        sz++; fast=A[fast];
    }
    // cout << d << '\n';
    // cout << sz << '\n';

    int ans=1;
    if ( k<=d ) {
        REP(i,k) {
            ans=A[ans];
        }
    }
    else {
        k-=d;
        k%=sz;
        ans=slow;
        REP(i,k) {
            ans=A[ans];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include<queue>


const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
long long int gcd(long long int a, long long int b) {
	long long int c = std::min(a, b);
	a = std::max(a, b);
	b = c;
	while (true) {
		c = a % b;
		a = b;
		b = c;
		if (c == 0)break;
	}
	return a;
}
long long int factorial(int start,int end = 1) {
	if (start == 0)return 1;
	return start == end ? end : start * factorial(start - 1,end);
}
long long int npr(int n, int r) {
	return factorial(n) / factorial(n - r);
}

long long int ncr(int n, int r) {
	return npr(n, r) / factorial(r);
}

int main()
{
	int n;
	bool rslt = true;
	long long int time = 0;
	std::priority_queue<pair<long long int, long long int>,
		vector<pair<long long int,long long int>>, 
		greater<pair<long long int,long long int>>> que;
	std::string out;


	std::cin >> n;
	for (int i = 0; i < n; i++) {
		long long int a, b;
		std::cin >> a >> b;
		que.push(make_pair(b, a));
	}
	while (!que.empty()) {
		pair<long long int, long long int> p = que.top();
		que.pop();
		time += p.second;
		if (time > p.first) {
			rslt = false;
			break;
		}
	}
	out = rslt ? "Yes" : "No";
	std::cout << out;
}

Measured memory_bytes: 6256
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n;
  std::cin>>n;

  const ll V=100000;

  std::vector<std::vector<ll>> graph(2*V);

  rep(i,0,n){
    ll x,y;
    std::cin>>x>>y;
    x--;y--;
    graph[x].push_back(V+y);
    graph[V+y].push_back(x);
  }

  ll ans=0;

  std::vector<ll> color(2*V,-1);

  rep(i,0,V){
    if(color[i]==-1){
      ll b=0,w=0,edge=0;
      color[i]=0;
      std::queue<ll> que;
      que.push(i);
      while(!que.empty()){
        ll e=que.front();que.pop();
        if(color[e]==0)b++;
        else w++;

        edge+=graph[e].size();
        for(ll next:graph[e]){
          if(color[next]==-1){
            color[next]=color[e]^1;
            que.push(next);
          }
        }
      }

      ans+=b*w-edge/2;
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	unordered_map<int,int> store;	
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		store[x]++;
	}
	int ans=0;
	for(int i=0;i<100000;i++)
	{
		int temp=0;
		for(int j=-1;j<=1;j++)
			temp+=store[i+j];
		ans=max(ans,temp);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
int64_t times2(int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; ++i) {
		output *= 2;
	}
	return output;
}

int main() {
	//input
	int64_t a, b, c, d;
	cin >> a >> b >> c >> d;

	//calculation
	int64_t ac, ad, bc, bd;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;


	//output
	int64_t output = max(max(ac, ad), max(bc, bd));
	cout << output << endl;


	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int a, b;
  cin >> a >> b;
  if(a * b % 2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;



}

Measured memory_bytes: 256
import math
K = int(input())
A = list(map(int, input().split()))
N_min = 2
N_max = 2

for i in range(K-1,-1,-1):
    N_max = int(math.floor(N_max/A[i]))*A[i] + A[i]-1
    N_min = int(math.ceil(N_min/A[i]))*A[i]
    if N_max < A[i]:
        print(-1)
        exit()
    if N_max < N_min:
        print(-1)
        exit()

print(N_min,N_max)


Measured memory_bytes: 15020
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i = 105; i <= n; i += 2){
            int count = 0;
            for(int j = 1; j <= n; j++){
                if(i % j == 0) count++;
            }
            if(count == 8) ans++;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 22608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


struct P{ double x, y; P(double x, double y) : x(x), y(y) {} };
bool operator < (const P& r, const P& l)
{ return (l.x == -1) || (r.y < l.y) || (r.y == l.y && r.x < l.x); }

int main()
{
	int n, m;
	while(cin >> n >> m && n)
	{
		vector<vint> view(n, vint(n)), piece(m, vint(m));

		rep(y, n) rep(x, n)
			cin >> view[y][x];

		rep(y, m) rep(x, m)
			cin >> piece[y][x];

		P ans(-1, -1);
		rep(i, 4)
		{	rep(y, n - m + 1)
			{
				rep(x, n - m + 1)
				{
					rep(sy, m)
					{
						rep(sx, m)
						{
							if(piece[sy][sx] != -1 && view[y + sy][x + sx] != piece[sy][sx]) 
								goto ng;
						}
					}

					rep(sy, m) 
					{	rep(sx, m)
						{
							if(piece[sy][sx] != -1)
							{
                                chmin(ans, P(x + sx + 1, y + sy + 1));
								goto ng;
							}
						}
					}
ng:
					;
				}
			}
			
			// rotate
			rep(sy, m / 2) rep(sx, m)
				swap(piece[sy][sx], piece[m - sy - 1][sx]);
			REP(sy, 1, m) rep(sx, sy)
				swap(piece[sy][sx], piece[sx][sy]);
		}

		if(ans.x == -1)
			cout << "NA" << endl;
		else
			cout << ans.x << " " << ans.y << endl;
	}
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll N,K;
    cin >> N >> K;
    ll x = N/K;
    if (K%2==1) {
        cout << x*x*x << endl;
        exit(0);
    }
    ll y = (N+(K/2))/K;
    cout << x*x*x + y*y*y << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            count = 0
            for dx, dy in (
                (-1,1), (0,1), (1,1),
                (-1,0), (0,0), (1,0),
                (-1,-1),(0,-1),(1,-1)
            ):
                now_x, now_y = i+dx, j+dy
                if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
                    count += 1
            s[i][j] = str(count)

for i in range(H):
    print(''.join(s[i]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int x,y;

	while(1)
    {
        cin >>x>>y;
        if(x==0 && y==0)
            break;

        if(x<y)
            cout<<x<<" "<<y<<endl;
        else
            cout<<y<<" "<<x<<endl;
    }
}




Measured memory_bytes: 3076
# coding: utf-8
# Your code here!
V=[]
C=[]

ans=0
N=0
i=0
N=int(input())

li = input().split()

while(i<N):
    V.append(int(li[i]))
    i=i+1

i=0
li2=0
li2=input().split()

while(i<N):
    C.append(int(li2[i]))
    i = i+1
    
i=0

while(i<N):
    if(V[i]>C[i]):
        ans = ans + V[i] - C[i]
    i = i+1

print(ans)

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

int main() {
	int A, B;
	cin >> A;
	cin >> B;
	if (A >= 1 && B >= 1 && A + B <= 16) {
		if (A <= 8 && B <= 8) cout << "Yay!";
		else cout << ":(";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int ans = 100000;
		for(int i=0;i<n;i++) {
			int c = sc.nextInt();
			int t2 = sc.nextInt();
			if (t2 <= t) {
				ans = Math.min(ans, c);
			}
		}
		if (ans >= 100000) {
			System.out.println("TLE");
		}else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23636
# Disjoint Set: Union Find Trees
[p, rank] = [[], []]
[n, q] = list(map(int, input().split()))
w = [0 for i in range(n)]

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)

def findSet(x):
    global p
    if x != p[x]:
        pre_parent = p[x]
        p[x] = findSet(p[x])
        w[x] += w[pre_parent]
    return p[x]

def link(x, y, z):
    global p, rank, w
    if rank[x] > rank[y]:
        p[y] = x
        w[y] = z
    else:
        p[x] = y
        w[x] = -z
        if rank[x] == rank[y]:
            rank[y] += 1

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   

def relate(x, y, z):
    global w
    root_x = findSet(x)
    root_y = findSet(y)
    z += w[x]
    z -= w[y]
    link(root_x, root_y, z)
   
def diff(x, y):
    if same(x, y) == 1:
        global w
        return w[y] - w[x]
    else:
        return "?"     

for i in range(n):
    makeSet(i)

for i in range(q):
    data = list(map(int, input().split()))
    if data[0] == 0:
        relate(data[1], data[2], data[3])
    else:
        print(diff(data[1], data[2]))


Measured memory_bytes: 11408
#include <stdio.h>
#include <stdlib.h>
int	max(int a, int b)
{
	return ((a > b) ? a : b);
}
int	main(void)
{
	int		N, i, m = 0;
	int		*A;
	long	res = 0;

	scanf("%d", &N);
	A = malloc(sizeof(int) * N);
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);
	for (i = 0; i < N; i++)
	{
		m = max(m, A[i]);
		res += m - A[i];
	}
	printf("%lld\n", res);
	free(A);
	return (0);
}

Measured memory_bytes: 2248
n = int(input())
c = list(map(int,input().split()))
a = [0]
a += c
a.append(0)
b = [0 for i in range(n+1)]
b[0] = abs(a[1])
count = abs(a[1])
for i in range(1,n):
    b[i] = abs(a[i+1]-a[i])
    count += b[i]
count += abs(a[n])
b[n] = abs(a[n])
for i in range(n):
    print(count - b[i] - b[i+1] + abs(a[i+2] - a[i]))

Measured memory_bytes: 14048
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits<int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair<T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map<T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.length();  ++i) {
		if (s[i] != t[i]) 
			ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> vv(n);
  vector<int> vcnt(n);
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vv[a].pb(b);
    vv[b].pb(a);
  }

  int sumc = 0;
  int maxc = 0;
  vector<int> c(n);
  REP(i, n){
    cin >> c[i];
    sumc += c[i];
    maxc = max(maxc, c[i]);
  }
  cout << sumc - maxc << endl;
  sort(ALL(c));

  REP(i, n) {
    vcnt[i] = vv[i].size();
  }

  vector<pair<int, int>> vc(n);

  REP(i, n) {
    REP(j, n) {
      if (vcnt[j] == 1) {
        vc[i] = make_pair(j, c[i]);
        vcnt[j] = 0;
        if (i == n - 2)break;
        for(int k: vv[j]) {
          vcnt[k]--;
        }
        break;
      }
    }
  }
  sort(ALL(vc));
  REP(i, n - 1)cout << vc[i].second << " ";
  cout << vc[n - 1].second << endl;
  
  return 0;
}


Measured memory_bytes: 1024
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    ll s = 0;
    ll tmp = N;
    while (tmp > 0){
        s += (tmp % 10);
        tmp /= 10;
    }
    if (N % s == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 3544
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t calcDigitSum(size_t val)
{
	size_t sum = 0;

	while (0 < val) {
		sum += val % 10;
		val /= 10;
	}

	return sum;
}

int main(void) {
	size_t N, A, B;

	scanf("%zu %zu %zu", &N, &A, &B);

	size_t sum = 0;
	for (size_t val = 1; val <= N; val++) {
		const size_t digitSum = calcDigitSum(val);
		if (A <= digitSum && digitSum <= B) {
			sum += val;
		}
	}

	printf("%zu\n", sum);

	return 0;
}


Measured memory_bytes: 128
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var top = parseInt(line)
    var bottom = parseInt(input[1])
    var height = parseInt(input[2])
    
    console.log((top+bottom)*height/2)
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#! env python
# -*- coding: utf-8 -*-

import os
import sys
from itertools import repeat


# atcoder.main
# Date: 2020/06/19
# Filename: main 
# Author: acto_mini

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    max = A[N - 1]
    check = list(repeat(0, max + 1))

    for i in A:
        if check[i] != 0:
            check[i] += 1
            continue
        for j in range(i, max + 1, i):
            if check[j] == 0: check[j] += 1

    ans = 0
    for i in A:
        if check[i] == 1: ans += 1

    # print(len(check))
    # print(check)
    print(ans)
    return


if __name__ == '__main__':
    main()


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int ans = 0;
    if(A < B) ans += A;
    else ans += B;

    if(C < D) ans += C;
    else ans += D;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[0]*N
B=[0]*M
for i in range(N):
  A[i]=input()
for i in range(M):
  B[i]=input()
#print(A)
#print(B)
  
ans="No"
flag=True

for i in range(N-M+1):    #始点左上
  for j in range(N-M+1):  #始点左上
    flag=True
    for k in range(i,i+M):   #スキャン
      if flag:
        for l in range(j,j+M): #スキャン
          if A[k][l] != B[k-i][l-j]:
            flag=False
            break
    else:
      if flag==True:
        ans="Yes"
        break
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
        Scanner sc = new Scanner(System.in);
        
        int a,b;
        String op;
        
        while(true){
            
            a = sc.nextInt();
            op = sc.next();
            b = sc.nextInt();
            
            if(op.equals("?")){
                break;
            }else if(op.equals("+")){
                System.out.println(a + b);
            }else if(op.equals("-")){
                System.out.println(a - b);
            }else if(op.equals("*")){
                System.out.println(a * b);
            }else if(op.equals("/")){
                System.out.println(a / b);
            }
        }
        
    }
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define decsort(b) sort(all(b),greater<ll>())
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = pow(2,32);

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll answer(ll sum,vvi a,ll n,ll m)
{
	ll cnt1=0,cnt0=0;
	for(ll i=0;i<n;i++)
		{
			for(ll j=0;j<m;j++)
			{
				if(i+j==sum || i+j==n+m-2-sum)
				{
					if(a[i][j])cnt1++;
					else cnt0++;
				}
			}
		}
	return min(cnt0,cnt1);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	FAST();
 	rl(d) rl(t) rl(s)
	if(d<=t*s)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 163577857
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;if(m<0) return 0;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
#define MAXN 2005
int main()
{
    fastio();
   
    ll a,b,n;
    cin>>a>>b>>n;
    ll c = min(b-1,n);
    ll ans = (a*c)/b - a*(c/b);
    cout<<ans<<endl;
}

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

struct Dice
{
    array<int, 6> roll;
    
    void toNorth()
    {
        array<int, 6> t = roll;
        roll[4] = t[0];
        roll[0] = t[1];
        roll[5] = t[4];
        roll[1] = t[5];
    }

    void toSouth()
    {
        array<int, 6> t = roll;
        roll[1] = t[0];
        roll[5] = t[1];
        roll[0] = t[4];
        roll[4] = t[5];
    }

    void toWest()
    {
        array<int, 6> t = roll;
        roll[3] = t[0];
        roll[0] = t[2];
        roll[5] = t[3];
        roll[2] = t[5];
    }

    void toEast()
    {
        array<int, 6> t = roll;
        roll[2] = t[0];
        roll[5] = t[2];
        roll[0] = t[3];
        roll[3] = t[5];
    }

    void toCCW()
    {
        array<int, 6> t = roll;
        roll[2] = t[1];
        roll[4] = t[2];
        roll[1] = t[3];
        roll[3] = t[4];
    }

    void toCW()
    {
        array<int, 6> t = roll;
        roll[3] = t[1];
        roll[1] = t[2];
        roll[4] = t[3];
        roll[2] = t[4];
    }

    int serchRight(int upper, int front)
    {
        for(int i = 0; i < 2; i++)
        {
            for(int j = 0; j < 4; j++)
            {
                if(roll[0] == upper) {
                    for(int k = 0; k < 4; k++)
                    {
                        if(roll[1] == front)
                            return roll[2];
                        else
                            toCW();
                    } 
                }
                toNorth();
            }
            toCW();
        }
        return 9999;
    }

    void print()
    {
        for(int i = 0; i < 6; i++)
        {
            cout << "[" << i << "]:" << roll[i] << " ";
        }
        cout << endl;
    }
};

int main()
{
    int count;
    Dice dice;
    for (int i=0; i<6; i++) {
        cin >> dice.roll[i];
    }
    
    cin >> count;
    for (int i=0; i<count; i ++ ) {
        int n1,n2;
        cin >> n1 >> n2;
        cout << dice.serchRight(n1,n2) << endl;
    }
    return 0;
}




Measured memory_bytes: 3044
#include <iostream>
 
int main()
{
    std::string s;
    std::cin >> s;
 
    long long mod[2019] = {0};
    int T = 0;
    int ten = 1;
 
    for (auto itr = s.rbegin(); itr < s.rend(); ++itr) {
        T = ((*itr - '0') * ten + T) % 2019;
        mod[T]++;
        ten = (ten * 10) % 2019;
    }
 
    auto sum = mod[0];
    for (int i = 0; i < 2019; ++i) {
        sum += mod[i] * (mod[i] - 1) / 2;
    }
    std::cout << sum << std::endl;
 
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    vector<long> prize(205);
    prize[0] = 300000;
    prize[1] = 200000;
    prize[2] = 100000;
    int x,y;
    cin >> x >> y;
    
    x--;y--;
    
    long ans = 0;
    if(x == 0 && y == 0){
        ans += 400000;
    }
    ans += prize[x] + prize[y];
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main() {
  string s,t; cin >> s >> t;

  int n = s.size();
  string ans = "No";
  string tmp = s;
  rep(i,n){
    if(tmp == t){
      ans = "Yes";
      break;
    }
    
    tmp = tmp.back() + tmp.substr(0,n-1);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<map>
using namespace std;
long long gcdback(long long  a, long long b)
{
	return __gcd(a, b);
}
int solveitabdo(long long x, long long y)
{
	map<long long, int>max1;
	long long gcdnum = gcdback(x, y);
	for (long long i = 2; i*i <= gcdnum; i++)
	{
		while (gcdnum % i == 0)
		{
			max1[i]++;
			gcdnum /= i;
		}
	}
	if (gcdnum != 1)
	{
		max1[gcdnum]++;
	}
	return max1.size() + 1;
}
int main()
{
	long long x, y;
	cin >> x >> y;
	cout<<solveitabdo(x, y);
}


Measured memory_bytes: 3628
#include <stdio.h>
#define MOD 1000000007

long long fac[100005];
long long invfac[100005];

long long powmod(long long a,int b)
{
    if (b==1) return a;
    if (b&1) return (powmod((a*a)%MOD,b/2)*a)%MOD;
    return powmod((a*a)%MOD,b/2);
}

long long inv(long long a)
{
    return powmod(a,MOD-2);
}

long long choose(long long a,long long b)
{
    if (b<0 || b>a) return 0;
    return (((fac[a]*invfac[b])%MOD)*invfac[a-b])%MOD;
}

int t1,t2;
int n;
int use[100005];

int i1,i2;
int mid;
long long ans;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&n,&t1);
    use[t1]=1;
    fac[0]=invfac[0]=1;
    for (int i=1; i<=n; i++) {
        fac[i]=(i*fac[i-1])%MOD;
        invfac[i]=(inv(i)*invfac[i-1])%MOD;
        scanf("%d",&t1);
        if (use[t1]) {
            i1=use[t1];
            i2=i+1;
        }
        use[t1]=i+1;
    }
    // do the counting
    mid=i2-i1-1;
    printf("%d\n",n);
    n++;
    for (int i=2; i<=n; i++) {
        //printf("i %d\n",i);
        // order is BACAD
        // some part of BCD
        ans=choose(n-2,i);
        //printf("BCD %lld\n",ans);
        // some part of BACD or BCAD, A mandatory
        ans+=choose(n-2,i-1);
        ans+=choose(n-2,i-1);
        //printf("BACD BCAD %lld\n",ans);
        // some part of BAD, A mandatory
        ans+=MOD-choose(n-mid-2,i-1);
        //printf("BAD %lld\n",ans);
        // some part of BACAD, both A mandatory
        ans+=choose(n-2,i-2);
        //printf("BACAD %lld\n",ans);
        printf("%lld\n",ans%MOD);
    }
}


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

int main() {
  int N;
  string s;
  cin >> N >> s;
  int K = s.size();
  if (N >= K) cout << s << endl;
  else {
    string ss = s.substr(0, N);
    cout << ss << "..." << endl;
  }
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int cnt = 0;
		for(int i = 0 ; i < N / 2 ; ++i){
			if(S.charAt(i) == S.charAt(N - 1 - i)){
				
			}else{
				++cnt;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n+1];
    unordered_map<int,int> ct;
    ll ans = 0;
    int p[n+1];
    p[0] = 0;
    ct[0] = 1;
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        a[i]--;
        p[i] = p[i-1] + a[i];
        p[i] %= k;
        if (i-k >= 0) ct[p[i-k]]--;
        //printf("%d %d\n",p[i],ct[p[i]]);
        ans += ct[p[i]];
        ct[p[i]]++;

    }
    printf("%lld",ans);

}


Measured memory_bytes: 10056
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

int n, m;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	if(n%2){
		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j++){
				if(i == j or i + j == n)
					continue;
				m++;
			}
		printf("%d\n", m);
		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j++){
				if(i == j or i + j == n)
					continue;
					printf("%d %d\n", i, j);
				}
		return 0;
	}
	for(int i = 1; i <= n + 1; i++)
		for(int j = i + 1; j <= n + 1; j++){
			if( i + j == n + 1 or i == n + 1 or j == n + 1 )
				continue;
			m++;
		}
	printf("%d\n", m);
	for(int i = 1; i <= n + 1; i++)
		for(int j = i + 1; j <= n + 1; j++){
			if( i + j == n + 1 or i == n + 1 or j == n + 1 )
				continue;
			printf("%d %d\n", i, j);
		}
	return 0;
}

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

#define MAX 1000000
#define MOD 1000000007

//const int MAX = 100001;
//const int MOD = 1000000007;

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

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

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



int main(void){

ll x,y;
cin>>x>>y;
ll n,m;
n=2*x/3-y/3;
m=2*y/3-x/3;
if (n<m) swap (n,m);
if (!((x+y)%3==0)) {cout<<0;
}else if
(!(n>=0 & m>=0)) {cout<<0;
}else{
  COMinit();
  cout<<COM((n+m),n);
}


}


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

int main(){
    int cake = 4;
    int donut = 7;
    int N;
    cin >> N;

    int total = 0;
    int totalMatchFlag = false;
    for(int i = 0;i < 100;++i){
        for(int j = 0;j < 100;++j){
            total = cake *i + donut * j;
            if(total == N){
                totalMatchFlag = true;
            }
        }       
    }
    if(totalMatchFlag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

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

# 頂点 s からの最短距離を求める (存在しないときはinf)
# n: 頂点数, edge[i]: 頂点 i からの [cost, dst] の list (heapq のため cost が先)
# O(|E|log|V|)
import heapq
def dijkstra(s,n,edge):
    d = [float("inf")] * n # s からの距離
    d[s] = 0
    q = [] # 頂点への距離を管理する。ヒープにする
    for e in edge[s]:
        heapq.heappush(q, e)
    
    while q:
        minedge = heapq.heappop(q)
        v = minedge[1]
        if d[v] < minedge[0]:
            continue # 最小のもの以降はスルー
        d[v] = minedge[0]
        for e in edge[v]:
            heapq.heappush(q, [e[0]+d[v], e[1]])

    return d

def main():
    N = int(input())
    edge = [[] for i in range(N)]
    # edge[i] : 頂点 i から出る経路の [重み,行先] の配列
    for _ in range(N-1):
        a,b,c = map(int, input().split())
        edge[a-1].append([c,b-1])
        edge[b-1].append([c,a-1])

    Q,K = map(int, input().split())
    D = dijkstra(K-1, N, edge)

    for _ in range(Q):
        x,y = map(int, input().split())
        print(D[x-1] + D[y-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 57112
#include<bits/stdc++.h>
using namespace std;
#define MOD (long long)(1e9+7)
typedef long long int ll;
typedef unsigned long long int ull;

ll modularExponentiation(ll x, ll y, ll  p){
  ll res = 1;
  x = x % p;
  while (y > 0){
      if (y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
  }
  return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
// vector<ll> fac(100002, 1), invfac(100002, 1);
// ll nCr(ll n, ll r){
//   return (((fac[n]*invfac[n-r])%MOD)*invfac[r])%MOD;
// }

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll T=1;
  // cin>>T;
  for(int _case=0;_case<T;_case++){
    ll n, k;
    cin>>n>>k;
    // for(int i=1;i<n+2;i++){
    //   fac[i]=fac[i-1]*i;
    //   invfac[i]=modularExponentiation(fac[i], MOD-2, MOD);
    // }
    ll ans=0;
    for(int i=k;i<n+2;i++) ans=(ans+(i*(n-i+1)+1))%MOD;
    cout<<ans<<endl;

  }
  return 0;
}


Measured memory_bytes: 3640
import java.util.*;
class Main
{
  public static void main(String[] args) 
  {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    System.out.println(c + " " + a + " " + b);
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i,n) cin >> x.at(i) >> y.at(i);

    vector<int> xplusy(n), xminusy(n);
    rep(i,n) {
        xplusy.at(i) = x.at(i) + y.at(i);
        xminusy.at(i) = x.at(i) - y.at(i);
    }
    sort(xplusy.begin(), xplusy.end());
    sort(xminusy.begin(), xminusy.end());
    ll ans = (ll) abs(xplusy.at(0) - xplusy.at(n-1));
    ans = max(ans, abs((ll) xminusy.at(0) - xminusy.at(n-1)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6340
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n), y(n), a(n);
	vector<vector<bool>> field(h, vector<bool>(w, true));

	int kiroku[4] = { 0 };
	FOR(i, 0, n) {
		int x, y, a;
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			FOR(p, 0, x) {
				FOR(q, 0, h) {
					field[q][p] = false;
				}
			}
			break;
		case 2:
			FOR(p, x, w) {
				FOR(q, 0, h) {
					field[q][p] = false;
				}
			}
			break;
		case 3:
			FOR(p, 0, w) {
				FOR(q, 0, y) {
					field[q][p] = false;
				}
			}
			break;
		case 4:
			FOR(p, 0, w) {
				FOR(q, y, h) {
					field[q][p] = false;
				}
			}
			break;
			
		}


	}

	int cnt = 0;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			if (field[i][j])
				cnt++;
		}
	
	}
	cout << cnt << endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<list>

using namespace std;
int main(){
    list<int> x;

    int temp;
    do{
        cin >> temp;

        if(temp != 0){
         x.push_back(temp);
        }
    }while(temp !=0);
    
    int i=1;
    for(std::list<int>::iterator itr = x.begin(); itr != x.end(); ++itr) {
        cout << "Case " << i << ": " << *itr << endl;
        i++;
    }
return 0;
}

Measured memory_bytes: 1504
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
x0,y0 = [float(i) for i in N[0].split(",")]
ans = 0.0
for l in range(2,len(N)):
    x1, y1 = [float(i) for i in N[l-1].split(",")]
    x2, y2 = [float(i) for i in N[l].split(",")]
    a = math.sqrt((x1-x0)**2 + (y1-y0)**2)
    b = math.sqrt((x2-x1)**2 + (y2-y1)**2)
    c = math.sqrt((x2-x0)**2 + (y2-y0)**2)
    z = (a+b+c)/2.0
    S = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ans += S
print(ans)



Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  if ((y % 2) == 0 && y >= (x * 2) && y <= (x * 4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main()
{
    int a,b,c; cin >> a >> b >> c;
    if(a!=b && b!=c && c!=a) cout << 3 << endl;
    else if(a==b && b==c && c==a) cout << 1 << endl;
    else cout << 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int x,y,i,a;
    
    for(i = 0 ; 1 ; i++){
        scanf("%d%d",&x,&y);
        if(x == 0 && y == 0) break;
        
        if(x > y){
            a = x;
            x = y;
            y = a;
        }
        printf("%d %d\n",x,y);
    }
    
    return 0;
}

Measured memory_bytes: 596
S = list(input())
O = 0
X = 0

for i in range(len(S)):
    if S[i]=="o":
        O += 1
    elif S[i]=="x":
        X += 1

n = 15-(O+X)
if n+O>=8:
    print("YES")
else:
    print("NO")

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

int main() {
    int N, a;
    cin >> N;
    double sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> a;
        sum += 1.0 / a;
    }
    printf("%.12lf", 1/sum);
}


Measured memory_bytes: 256
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let n: usize = input();
    let mut cnt = 0;
    for i in 1..n + 1 {
        if i % 2 == 0 { continue }
        let mut div = 0;
        for j in 1..i + 1 {
            if i % j == 0 { div += 1; }
        }
        if div == 8 { cnt += 1; }
    }
    println!("{}", cnt);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352