akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
#define int long long
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e6;
const int N = 1e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;

struct Dict {
    int pr, sum;
    Dict(int pr = 0, int sum = 0) : pr(pr), sum(sum) {
        // add some commands if necessary here
        // such as assign or something similar
    } 
}id[N];

string s;
int n, m;
int L[N], R[N], tmpArr[N];

// 0 = A
// 1 = B

int find(int u) { return (id[u].pr == u) ? u : (id[u].pr = find(id[u].pr)); }

void merge(int u, int v) {
    u = find(u);
    v = find(v);
    if(u == v) return;
    id[u].sum += id[v].sum;
    id[v].pr = u;
}

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> s; m = s.length();
    cin >> n;
    FOR(i, 1, n) cin >> L[i] >> R[i];

    tmpArr[1] = 0 - (s[0] - 'a');
    FOR(i, 2, m) tmpArr[i] = s[i - 2] - 'a' - (s[i - 1] - 'a');
    tmpArr[m + 1] = s[m - 1] - 'a';

    FOR(i, 1, m + 1) id[i] = {i, tmpArr[i]};
    FOR(i, 1, (m + 1) / 2) merge(i, (m + 1) - i + 1);
    FOR(i, 1, n) merge(L[i], R[i] + 1);

    bool flag = 1;
    FOR(i, 1, m + 1) {
        int pu = find(i);
        if(id[pu].sum % 26 != 0) return cout << "NO", 0;
    }
    cout << "YES";
}

Measured memory_bytes: 4432
# Koch Curve
n = int(input())
p1, p2 = (0, 0), (100, 0)
ans_ls = [p1, p2]

def koch(d, p1, p2):
    '''
    d...現在の深さ 0スタートにする
    p1,p2...端の座標。ここから途中の座標を計算しlistにappendする
    '''
    # 終了条件
    if d == n:
        return
    # 内分点の計算
    s = (2/3 * p1[0] + 1/3 * p2[0], 2/3 * p1[1] + 1/3 * p2[1])
    t = (1/3 * p1[0] + 2/3 * p2[0], 1/3 * p1[1] + 2/3 * p2[1])

    # 正三角形の頂点uの計算
    # (u-s)=R(1/3 pi) (t-s)が成り立つのでsを移行してuが計算できる。R()は回転行列で、加法定理から導出可能。
    R = [[1/2, -0.86602540378], [0.86602540378, 1/2]]
    u = (R[0][0] * (t[0] - s[0]) + R[0][1] * (t[1] - s[1]) + s[0],
         R[1][0] * (t[0] - s[0]) + R[1][1] * (t[1] - s[1]) + s[1])
    ans_ls.extend([s, u, t])  # 確定した点を追加

    # 再帰的に探索
    koch(d+1, p1, s)
    print(*s)
    koch(d+1, s, u)
    print(*u)
    koch(d+1, u, t)
    print(*t)
    koch(d+1, t, p2)

print(*p1)
koch(0, p1, p2)
print(*p2)


Measured memory_bytes: 6200
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


N = input()

if N[-1] in ['2','4','5','7','9']:
	print('hon')
elif N[-1] == '3':
	print('bon')
else:
	print('pon')






















    

Measured memory_bytes: 9568
include Math
N = gets.to_i
x = []
y = []
N.times do |i|
  x[i], y[i] = gets.split.map(&:to_i)
end

def dist(x1, y1, x2, y2)
  Math.sqrt((x1-x2)**2 + (y1-y2)**2)
end

# 1からNまでのN!この順列を生成
p = []
1.upto N do |i|
  p[i-1] = i
end
p = p.permutation(N).to_a

ans = 0
p.each do |r|
  (N-1).times do |i|
    ans += dist(x[r[i]-1], y[r[i]-1], x[r[i+1]-1], y[r[i+1]-1])
  end
end
# (1..N).inject(1,:*) は N の階乗
puts ans.to_f / p.size.to_f

Measured memory_bytes: 6780
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll Y[4]={-1,0,1,0};
ll X[4]={0,1,0,-1};
int main(void){
    ll H,W;cin>>H>>W;
    char s[H][W];
    REP(i,H)REP(j,W)cin>>s[i][j];
    //cout<<"\n\n";
    //WREP(i,H,j,W)cout<<s[i][j]<<(i==W-1?"\n":" ");
    bool OK=true;
    WREP(i,H,j,W){
        if(s[i][j]=='.')continue;
        bool isWall=false;
        REP(k,4){
            if(!(0<=i+Y[k]&&i+Y[k]<H&&0<=j+X[k]&&j+X[k]<W)){
                //cout<<":::"<<i+Y[k]<<" "<<j+X[k]<<"\n";
                continue;
            }
            if(s[i+Y[k]][j+X[k]]=='#'){//壁があれば
                isWall=true;
                break;
            }
        }if(!isWall){
            //cout<<i<<" "<<j<<"\n";
            OK=false;
        }
    }
    cout<<(OK?"Yes":"No")<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        double x1,y1,x2,y2,x3,y3;
        cin >> x1 >>y1 >>x2 >> y2 >> x3 >> y3;
        double a1,a2,b1,b2,c1,c2,x,y,r;
         a1=2*(x2-x1);
         b1=2*(y2-y1);
         c1=x1*x1-x2*x2+y1*y1-y2*y2;
         a2=2*(x3-x1);
         b2=2*(y3-y1);
         c2=x1*x1-x3*x3+y1*y1-y3*y3;
         x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
         y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
         r=hypot(x-x1,y-y1);
        printf("%.3lf %.3lf %.3lf\n",x,y,r);
    }
}



Measured memory_bytes: 3144
#include<stdio.h>
int main()
{
    char S[10001],a[10001];
    int N,i,j;
    scanf("%d", &N);
    scanf("%s", S);
    for(i=0;S[i]!='\0';i++)
    {
        a[i]=S[i]+N;
        if(a[i]>'Z')
        {
            a[i]=a[i]-26;
        }
    }
    a[i]='\0';
    printf("%s\n", a);
}


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


bool is_palindrome(string& s){
  int l = s.length();
  for(int i = 0; i < l; i++){
    if(s[i] != s[l - 1 - i]){
      return false;
    }
  }
  return true;
}

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

  int N = S.length();

  string S1 = S.substr(0, N / 2), S2 = S.substr(N / 2 + 1, N / 2);
  bool ans = is_palindrome(S) && is_palindrome(S1) && is_palindrome(S2);
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

  


Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class BellmanFord{
    public:
        typedef struct Edge{
            int from;
            int to;
            int cost;
            Edge(int f,int t,int c):from(f),to(t),cost(c){}
        } Edge;
        const ll INF=1<<30;
        int edge_num, vertex_num, start, goal;
        vector<Edge> edges;
        vector<ll> dist;
        vector<int> afby_nc;

    BellmanFord(int e,int v,int s,int g) : edge_num(e),vertex_num(v),start(s),goal(g){
        dist=vector<ll>(vertex_num,INF);
        dist[start]=0;
        afby_nc=vector<int>(vertex_num,false);
    }

    void connect(int from, int to, int cost) {
        edges.push_back(Edge(from,to,cost));
    }

    void relax(){
        REP(i,vertex_num){
            for(auto edge : edges){
                if(dist[edge.from]!=INF && dist[edge.to]>dist[edge.from]+edge.cost)
                   dist[edge.to]=dist[edge.from]+edge.cost;
            }
        }
    }

    void check_negative_cycle(){
        REP(i,vertex_num){
            for(auto edge : edges){
                if(dist[edge.from]==INF)continue;
                if(dist[edge.to]>dist[edge.from]+edge.cost){
                    afby_nc[edge.to]=true;
                    dist[edge.to]=dist[edge.from]+edge.cost;
                }
                if(afby_nc[edge.from]==true)afby_nc[edge.to]=true;
            }
        }
    }

    ll distance(){
        this->relax();
        ll ans_dist=dist[goal];
        //for(auto vv:dist)printf("###%lld\n",vv);
        this->check_negative_cycle();
        //for(auto vv:dist)printf("######%lld\n",vv);
        if(ans_dist>dist[goal] || afby_nc[goal]==true)return -INF;
        else return ans_dist;
    }
};

int main(){
    const ll INF=1<<30;
    int n,m,p;
    cin >> n >> m >> p;
    BellmanFord bf(m,n,0,n-1);
    int a,b,c;
    REP(i,m){
        cin >> a >> b >> c;
        bf.connect(a-1,b-1,p-c);
    }
    ll dist=bf.distance();
    if(dist==-INF)printf("-1\n");
    else if(dist>0)printf("0\n");
    else printf("%lld\n",-dist);
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
class Hjo {
  static void Main(){
    var aho = Console.ReadLine().Split();
    var a = int.Parse(aho[0]);
    var b = int.Parse(aho[1]);
    var K = int.Parse(aho[2]);
    var sore = 0;
    var syou = 0;
    var numbers = new List<int>();
    if(a > b){
      syou = b;
    }
    else{
      syou = a;
    }
    for(var i = 1;i <= syou;i++){
         if(a%i == 0&&b%i==0){
			numbers.Add(i);
         }
    }
    var kotae = numbers.OrderByDescending(x=> x).ToList();
        Console.WriteLine(kotae[K-1]);
    
   
  }
}

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

using namespace std;

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

	int size=s.size();
	string ans;

	for(int i=0;i<size;i++) {
		if(s[i]!='B') {
			ans+=s[i];
		} else if(s[i]=='B') {
			if(ans.size()>0){
				ans.pop_back();
			}
		}
	}

	size=ans.size();

	for(int i=0;i<size;i++)
		cout<<ans[i];

	return 0;
}

Measured memory_bytes: 3600
#include <cstdlib>
#include <cstdio>
#include <map>
#define number(node) edge_to[node][0]
#define INFINITY 999999
using namespace std;
int n, m, start[2], paid, pole, cost[2][20], edge_to[20][21], edge_cost[20][21];

int comp_0(const void *a, const void *b)
{
    return cost[0][*(int*)a] - cost[0][*(int*)b];
}

int comp_1(const void *a, const void *b)
{
    return cost[1][*(int*)a] - cost[1][*(int*)b];
}

int main()
{
    int from, to, c1, c2;
    fill((int *)edge_to, (int *)(edge_to + 20), 0);
    fill((int *)edge_cost, (int *)(edge_cost + 20), 0);
    fill((int *)cost, (int *)(cost + 2), INFINITY);
    
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d,%d,%d,%d", &from, &to, &c1, &c2);
        edge_to[from][++number(from)] = to;
        edge_cost[from][number(from)] = c1;
        edge_to[to][++number(to)] = from;
        edge_cost[to][number(to)] = c2;
    }
    
    scanf("%d,%d,%d,%d", &start[0], &start[1], &paid, &pole);
    for (int g = 0; g < 2; g++)
    {
        int unchecked[20], k = 0;
        cost[g][start[g]] = 0;
        for (int i = 1; i <= number(start[g]); i++)
            cost[g][edge_to[start[g]][i]] = edge_cost[start[g]][i];
        for (int i = 1; i <= n; i++)
            if (i != start[g]) unchecked[k++] = i;

        while (k > 0)
        {
            qsort(unchecked, k, sizeof(int), (g ? comp_1 : comp_0));
            for (int i = 1; i <= number(unchecked[0]); i++)
                if (cost[g][edge_to[unchecked[0]][i]] > cost[g][unchecked[0]] + edge_cost[unchecked[0]][i])
                    cost[g][edge_to[unchecked[0]][i]] = cost[g][unchecked[0]] + edge_cost[unchecked[0]][i];
            unchecked[0] = unchecked[--k];
        }
    }
    
    printf("%d\n", paid - pole - cost[0][start[1]] - cost[1][start[0]]);
    return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  ll a,b;
  cin>>a>>b;
  rep(i,n-1){
    ll ta,tb;
    cin>>ta>>tb;
    ll bai=max((a-1+ta)/ta,(b-1+tb)/tb);
    a=bai*ta;b=bai*tb;
    //cout<<a<<" "<<b<<endl;
  }
  cout<<a+b<<endl;


  return 0;

}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 2e3 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, k, dist[maxn], ans = mod;
vector<int> graph[maxn];
pair<int, int> edge[maxn];

void dfs(int u)
{
	for (int i : graph[u])
		if (dist[i] == -1)
		{
			dist[i] = dist[u] + 1;
			dfs(i);
		}
}

void handle(int val)
{
	int cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += (dist[i] > val);
	ans = min(ans, cnt);
}

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

	cin >> n >> k;
	int u, v;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> u >> v, u--, v--;
		graph[u].pb(v), graph[v].pb(u);
		edge[i] = mp(u, v);
	}
	for (int i = 0; i < n; i++)
	{
		memset(dist, -1, sizeof(dist));
		dist[i] = 0;
		dfs(i);
		handle(k / 2);
	}
	for (int i = 0; i < n; i++)
	{
		memset(dist, -1, sizeof(dist));
		dist[edge[i].ff] = 0;
		dist[edge[i].ss] = 0;
		dfs(edge[i].ff);
		dfs(edge[i].ss);
		handle((k - 1) / 2);
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


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

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

int main() {
	long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	long minute;
	long mini = min(min(A, B), min(C, min(D,E)));
	if (N % mini != 0) {
		minute = N / mini + 1;
	}
	else {
		minute = N / mini;
	}
	minute += 4;
	cout << minute << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, max;
  scanf("%d%d", &a, &b);
  if(a+b > a-b)
    max = a+b;
  else
    max = a - b;
  if(max < a*b)
    max = a * b;
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) 
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("NO");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	void main()
	{
		int n=qread();int a[N];ll p=0;fo(i,1,n) a[i]=qread(),p+=a[i];a[0]=a[n];
		ll t=ll(n+1)*n/2;if(p%t) GG();p/=t;
		fo(i,1,n) if( (p-a[i]+a[i-1])%n or (p-a[i]+a[i-1])/n<0 ) GG();puts("YES");
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 119808
#include <iostream>
using namespace std;
int main(){
  int N, M, mod = 1000000007;
  cin >> N >> M;
  if(abs(N-M) > 1){
    cout << 0 << endl;
    return 0;
  }
  if(N == M){
    long long int ans = 2LL;
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < 2; ++j){
	ans *= (long long int)(i+1);
	ans %= (long long int)mod;
      }
    }
    cout << ans << endl;
  }else{
    int t = min(N,M);
    long long int ans = 1LL;
    for(int i = 0; i < t; ++i){
      for(int j = 0; j < 2; ++j){
	ans *= (long long int)(i+1);
	ans %= (long long int)mod;
      }
    }
    ans *= (long long int)max(N,M);
    ans %= (long long int)mod;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
//#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<string , int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


int main(){
    string n;
    cin >> n;
    if(n.at(n.size()-1) == '3') cout << "bon" << endl;
    else if(n.at(n.size()-1) == '0' || n.at(n.size()-1) == '1' || n.at(n.size()-1) == '6' || n.at(n.size()-1) == '8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" <<endl;
    }
//    cout << n.at(n.size()-1);
    return 0;
}

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

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

		long[] hen=new long[3];
		long wa=1;
		for(int i=0; i<3; i++) {
			hen[i]=sc.nextLong();
			wa*=hen[i]%2;
		}

		if(wa==0) {
			System.out.println(0);
		}
		else {
			Arrays.sort(hen);
			System.out.println(hen[0]*hen[1]);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a>b)
  {
    for(int i=1;i<=a;i++)
    {
      cout << b;
    }
  }
  else if(a<b)
  {
    for(int i=1;i<=b;i++)
    {
      cout << a;
    }
  }
  else if(a==b)
  {
    for(int i=1;i<=b;i++)
    {
      cout << a;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>

#define MAXN 100005

using namespace std;

struct edge
{
	int y,next;
};

edge v[2*MAXN];
int head[MAXN];
int tot = 0;
long long ans = 0;
map<unsigned long long,int> S;

void add(int x,int y)
{
	tot++;
	v[tot].y = y;
	v[tot].next = head[x];
	head[x] = tot;
}

unsigned long long dfs(int x,int fa)
{
	unsigned long long temp = 1;
	for (int i=head[x];i;i=v[i].next)
	{
		if (v[i].y == fa) continue;
		temp += 131*dfs(v[i].y,x);
	}
	ans += S[temp];
	S[temp]++;
	return temp;
}

int main()
{
	int x,y,n;
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}

	S.clear();
	ans = 0;
	dfs(1,0);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17620
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  string S, T, U;
  int A, B;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (S == U){
    cout << A-1 << " " << B;
  }else{
    cout << A << " " << B-1;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll nCr(ll n, ll r) {
  r = min(n - r, r);
  if (r < 0) return 0;
  if (r == 0) return 1;
  ll ans = 1;
  FOR(i, n - r + 1, n + 1) ans = ans * i % mod;
  ll a = 1;
  FOR(i, 1, r + 1) a = a * i % mod;
  ans = ans * modpow(a, mod-2) % mod;
  return ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;

    n -= 5;
    ll ans = 0;
    rep(i, 12) {
      if (n >= i && (n - i) % 2 == 0) {
        ans = (ans + nCr((n - i) / 2 + 15, 15) * nCr(11, i)) % mod;
      }
    }
    cout << ans << '\n';
  }
  




  
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    //vector<int> A(N), B(N);
    //rep(i, N) cin >> A[i] >> B[i];
    vector<pair<int, int>> AB(N), BA(N);
    rep(i, N) cin >> AB[i].first >> AB[i].second;
    rep(i, N) BA[i] = { AB[i].second, AB[i].first };

    sort(all(AB));
    sort(all(BA));

    if (N % 2 == 1) {
        int l = AB[N / 2].first, h = BA[N / 2].first;
        write(h - l + 1);
    }
    else {
        int l = AB[N / 2 - 1].first + AB[N / 2].first, h = BA[N / 2 - 1].first + BA[N / 2].first;
        write(h - l + 1);
    }
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_geneous = 0; ngtkana_is_geneous < n; ngtkana_is_geneous++)
#define rep(i, begin, end) for(int i = begin; i < end; i++)

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n), b(n);
  for (auto& x : a) std::cin >> x;
  for (auto& x : b) std::cin >> x;
  std::queue<int> que;
  rep(i, 0, n)
  {
    que.emplace(i);
  }
  long long ret = 0;
  while (!que.empty())
  {
    auto crr = que.front(); que.pop();
    auto prv = (crr - 1 + n) % n;
    auto nxt = (crr + 1)     % n;
    auto div = b.at(prv) + b.at(nxt);
    auto dif = b.at(crr) - a.at(crr);
    if (div <= dif)
    {
      auto q = dif / div;
      ret += q;
      b.at(crr) -= q * div;
      que.emplace(prv);
      que.emplace(nxt);
    }
  }
  if (a != b)
  {
    std::cout << -1 << std::endl;
    return 0;
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,t,dp[N];
struct node
{
    int x,y;
    bool operator<(const node&o)const
    {
        return x==o.x?y<o.y:x<o.x;
    }
}a[N];
int main()
{
    scanf("%d%d",&n,&t);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        for(int j=t-1;j>=0;j--)
        {
            int s=min(j+a[i].x,t);
            dp[s]=max(dp[s],dp[j]+a[i].y);
        }
    }
    int ans=0;
    for(int i=0;i<=t;i++)
        ans=max(ans,dp[i]);
    printf("%d\n",ans);
}
/*
5 8
2 3
4 5
3 5
1 4
2 6

3 8
2 3
4 5
3 5
*/


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

using namespace std;
int x,res;
int mu(int x, int y){
    int res = 1;
    for (int i=1;i<=y;i++) res*=x;
    return res;
}

int main()
{
    cin>>x;
    for (int i=1;i<=1000;i++){
        for (int j=2;j<=1000;j++){
            if (mu(i,j)>x) break;
            res=max(res,mu(i,j));
            //cout<<res;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  rep(i,n){
    int out=0,point=0;
    int run[3]={};
    string s;
    int F=0,S=0,T=0;
    while(out!=3){
      cin>>s;
      if(s=="OUT")out++;
      else if(s=="HOMERUN"){
        rep(i,3){
          point+=run[i];
          run[i]=0;
        }
        point++;
      }else{
        if(run[2]==1)point++;
        for(int i=2;i>0;i--)run[i]=run[i-1];
        run[0]=1;
      }
    }
    cout<<point<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans = 0.0;

	// 2つに分割して小さい方の最大値

	// どこきても半分に分割できる

	ans = double(w * h) / 2.0;

	bool ok = true;
	if (w % 2 == 1) ok = false;
	if (h % 2 == 1) ok = false;
	if (x != w / 2) ok = false;
	if (y != h / 2) ok = false;
	
	cout << fixed << setprecision(10) << ans;
	if (ok) cout << " " << 1 << endl;
	else cout << " " << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
Tmp = [T-H[i]*0.006 for i in range(N)]

D = 999
ind = 999
for i in range(N):
  if abs(A-Tmp[i]) < D:
    D = abs(A-Tmp[i]) 
    ind = i

print(ind+1)

Measured memory_bytes: 3064
import java.awt.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
import java.lang.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Problem ThanhYeuThu = new Problem();
		ThanhYeuThu.solve();
	}
	static class Graph {
		int n,m;
		private ArrayList<Integer> a[]; 
		private ArrayList<Integer> Topo;
		public void TaoDoThi(int N,int M) {
			n = N;
			m = M;
			a = new ArrayList[n + 1];
			for (int i = 0; i <= n; i++) a[i] = new ArrayList<>();
		}
		public void addEdge(int u,int v) {
			a[u].add(v);
		}
	}
	static class TopoSort {
		private ArrayList<Integer> Topo = new ArrayList<>();
		boolean KT[];
		void init(Graph G) {
			KT = new boolean[G.n + 1];
			for (int i = 0; i <= G.n; i++) KT[i] = false;
		}
		void DFS(Graph G,int u) {
			KT[u] = true;
			for (int v : G.a[u]) {
				if (KT[v] == false) DFS(G,v);
			}
			Topo.add(u);
		}
	}
	static class Problem {
		public void solve() {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int M = sc.nextInt();
			Graph G = new Graph();
			G.TaoDoThi(N, M);
			for (int i = 0; i < M; i++) {
				int u = sc.nextInt();
				int v = sc.nextInt();
				G.addEdge(u, v);
			}
			TopoSort TP = new TopoSort();
			TP.init(G);
			for (int i = 1; i <= N; i++) {
				if (TP.KT[i] == false) {
					TP.DFS(G,i);
				}
			}
			Collections.reverse(TP.Topo);
//			for (int x : TP.Topo) System.out.print(x + " ");
			int DP[] = new int[N + 1];
			int Res = 0;
			for (int u : TP.Topo) {
				DP[u] = Math.max(DP[u],1);
				Res = Math.max(Res, DP[u]);
				for (int v : G.a[u]) {
					DP[v] = Math.max(DP[v],DP[u] + 1);
				}
			}
			System.out.print(Res - 1);
		}
	}

}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

bool is_in(int a, int b, int c){
  return a <= b && b <= c;
}

int main()
{
  int N, M;
  int A[128], B[128];
  N = in(), M = in();
  for (int i = 0; i < M; i++){
    A[i] = in(), B[i] = in();
  }
  int vis[128] = {};
  int used[128] = {};
  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (vis[i]) continue;
    int maxi = 0;
    int maxj = -1;
    for (int j = 0; j < M; j++){
      if (used[j]) continue;
      if (is_in(A[j], i, B[j])){
        int cnt = 0;
        for (int k = A[j]; k <= B[j]; k++){
          cnt += !vis[k];
        }
        if (maxi < cnt) maxj = j, maxi = cnt;
      }
    }
    if (maxi == 0){
      puts("Impossible");
      return 0;
    }
    ans++;
    used[maxj] = 1;
    for (int j = A[maxj]; j <= B[maxj]; j++){
      vis[j] = 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1176
N = int(input())
X = list(map(int, input().split()))

avg = int(sum(X) / N)
nvA = 0
nvB = 0
for x in X:
    nvA += (avg - x) * (avg - x)
    nvB += (avg + 1 - x) * (avg + 1 - x)
if nvA > nvB:
    print(nvB)
else:
    print(nvA)


Measured memory_bytes: 3060
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

constexpr int MOD = 10000007;

vector<long> divisor(long &_n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n) tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

long kadanes(vector<long> &_ls) {
  long highestMax = 0, currentMax = 0, length = _ls.size();
  for (long i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // cout<<fixed<<setprecision(20);
  }
} init;

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

int main() {
  int d,t,s;
  cin >> d >> t >> s;
  if(d <= t*s){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
}


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

int main(){
    ll l,r;
    scanf(" %lld %lld",&l,&r);
    vector<int> modulos(2019,0);
    for(int i = l, j = 0; i <= r && j <= 10000;++i,++j)
        ++modulos[i%(2019ll)];
    int ans = 10000;
    for(int i = 0; i < modulos.size();++i){
        for(int j = i; j < modulos.size();++j){
            if(i == j && modulos[i] > 1)
                ans = min(ans,(i*i)%2019);
            else if(i != j && modulos[i] && modulos[j])
                ans = min(ans,(i*j)%2019);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int a, b, t;
  cin >> a >> b >> t;

  cout << b * (t / a) << endl;
}

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

int color_num;
int colors[1000000];

int qsort_comp(const void* x,const void* y) {
	int* a=(int*)x;
	int* b=(int*)y;
	if(*a>*b)return 1;
	if(*a<*b)return -1;
	return 0;
}

int main(void) {
	int i;
	int current_color;
	int count;
	while(1) {
		scanf("%d",&color_num);
		if(color_num==0)break;
		for(i=0;i<color_num;i++)scanf("%d",&colors[i]);
		qsort(colors,color_num,sizeof(int),qsort_comp);
		current_color=-1;
		count=0;
		for(i=0;i<color_num;i++) {
			if(colors[i]!=current_color) {
				if(count>color_num/2) {
					printf("%d\n",current_color);
					count=-100;
					break;
				}
				count=1;
				current_color=colors[i];
			} else {
				count++;
			}
		}
		if(count>color_num/2)printf("%d\n",current_color);
		else if(count!=-100)puts("NO COLOR");
	}
	return 0;
}

Measured memory_bytes: 8116
#include <stdio.h>

int main(void){
  char s[101] = { '\0' };
  scanf("%s", s);
  int i = 0;
  int numC = -1;
  int numF = -1;
  while(s[i] != '\0'){
    if(s[i] == 'C'){
      numC = i;
      break;
    }
    i++;
  }
  while(s[i] != '\0'){
    if(s[i] == 'F'){
      numF = i;
      break;
    }
    i++;
  }
  if(numC < 0 || numF < 0) printf("No\n");
  else if(numC < numF ) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=200005;
void solve(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    // vector<pii> v;
    ll tot=n*(n+1)/2;
    rep(i,k,n+1){
        ll curr=(i*(i-1))/2;
        ll lo=curr;
        ll nums=n+1-i;
        ll left=(nums*(nums-1))/2;
        ll hi=tot-left;
        ans=(ans+(hi-lo+1))%hell;
        // v.pb({lo,hi});
        // cout<<lo<<" "<<hi<<endl;
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define MAX_XY 300 * 2 + 100

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;

int sqr(int x) {
  return x * x;
}

int main() {
  int n, m;
  int arr[100100];
  vii bridge;

  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    bridge.pb(mp(a, b));
  }
  sort(bridge.begin(), bridge.end());

  int ans = 0;
  int minimal[100100];
  minimal[0] = bridge[0].nd;
  for(int i = 1; i < m; ++i) {
    //cout << i << " " << minimal[i - 1] << endl;
    if(minimal[i - 1] > bridge[i].st)
      minimal[i] = min(minimal[i - 1], bridge[i].nd);
    else {
      //cout << "xxxxxxxxxxxxxxxx\n";
      minimal[i] = bridge[i].nd;
      ++ans;
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}


Measured memory_bytes: 1524
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[][]=new int[n][3];
		for(int i=0;i<n;i++){
		    a[i][0]=sc.nextInt();
		     a[i][1]=sc.nextInt();
		      a[i][2]=sc.nextInt();
		}
		int ah[]=new int[n];
		int ab[]=new int[n];
		int as[]=new int[n];
		ah[0]=a[0][2];
		ab[0]=a[0][1];
		as[0]=a[0][0];
		
		
		for(int i=1;i<n;i++){
		    ah[i]= a[i][2]+Math.max(as[i-1],ab[i-1]);
		      as[i]=a[i][0]+Math.max(ah[i-1],ab[i-1]);
		        ab[i]=a[i][1]+Math.max(as[i-1],ah[i-1]);
		        //	 ans+=Math.max(ah[i],Math.max(as[i],ab[i]));
		}
		int ans=Math.max(ah[n-1],Math.max(as[n-1],ab[n-1]));
		System.out.println(ans);
		
	}
}


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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;

ll gcd(ll p, ll q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a/gcd(a,b)*b << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    map<int, int> mp;
    rep(i, N){
        mp[a[i]]++;
    }
    if(mp.size() == 1 && mp.count(0)){
        cout << "Yes" << endl;
        return 0;
    }
    if(N % 3 != 0){
        cout << "No" << endl;
        return 0;
    }
    if(mp.size() == 2){
        if(!mp.count(0)){
            cout << "No" << endl;
            return 0;
        }
        if(mp[0] != N / 3){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    if(mp.size() != 3){
        cout << "No" << endl;
        return 0;
    }
    vector<bitset<100>> bs;
    for(auto m: mp){
        if(m.second != N / 3){
            cout << "No" << endl;
            return 0;
        }
        bs.push_back(m.first);
    }
    if((bs[0]^bs[1]) == bs[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}






// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 4224
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //入力を受け取る
          var N = long.Parse(Console.ReadLine());
          var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          
          var dic = new Dictionary<long,long>();
          for(int i = 0; i < N ; i++){
            var num = A[i];
            if(dic.ContainsKey(num)){
              dic[num] += 1;
            }else{
              dic.Add(num,1);
            }
          }
          
          long first  = 0;
          long second = 0;
          var SortedDic = dic.OrderByDescending((x) => x.Key);
          foreach(KeyValuePair<long,long> item in SortedDic) {
            if(item.Value >= 4){
              if(first == 0){
                first = item.Key;
                second = item.Key;
              }else if(second == 0){
                second = item.Key;
              }
            }else if(item.Value >= 2){
              if(first == 0){
                first = item.Key;
              }else if(second == 0){
                second = item.Key;
              }
            }
          }
          Console.WriteLine(first*second);
        }
  
}


Measured memory_bytes: 29408
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int t,h,s;
    while (cin>>t>>h>>s) {
        if (t==-1&&h==-1&&s==-1) {
            break;
        } else {
            s=t*60*60+h*60+s;
            int normal=120*60-s;
            int comp=(120*60-s)*3;
            
            t=normal/3600;
            h=(normal%3600)/60;
            s=(normal%60);
            string tmp_t=to_string(t);
            if (tmp_t.size()==1) {
                cout<<0<<t<<":";
            } else {
                cout<<t<<":";
            }
            string tmp_h=to_string(h);
            if (tmp_h.size()==1) {
                cout<<0<<h<<":";
            } else {
                cout<<h<<":";
            }
            string tmp_s=to_string(s);
            if (tmp_s.size()==1) {
                cout<<0<<s<<endl;
            } else {
                cout<<s<<endl;
            }
            
            t=comp/3600;
            h=(comp%3600)/60;
            s=(comp%60);
            string tmp_3t=to_string(t);
            if (tmp_3t.size()==1) {
                cout<<0<<t<<":";
            } else {
                cout<<t<<":";
            }
            string tmp_3h=to_string(h);
            if (tmp_3h.size()==1) {
                cout<<0<<h<<":";
            } else {
                cout<<h<<":";
            }
            string tmp_3s=to_string(s);
            if (tmp_3s.size()==1) {
                cout<<0<<s<<endl;
            } else {
                cout<<s<<endl;
            }
        }
    }
}



Measured memory_bytes: 3124
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 18;

int a[N][2];
int l[1 << N][N];
int w[1 << N][N];
int f[1 << N][N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a[i] + 0);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a[i] + 1);
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0, cnt = 0; j < n; ++j) {
      l[i][j] = cnt;
      if ((i >> j & 1) == 0) {
        ++cnt;
      }
    }
    for (int j = n - 1, cnt = 0; j >= 0; --j) {
      w[i][j] = l[i][j] + cnt;
      w[i][j] %= 2;
      if (i >> j & 1) {
        ++cnt;
      }
    }
  }
  const int inf = 1'000'000'000;
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j) {
      f[i][j] = inf;
    }
  }
  for (int i = 0; i < n; ++i) {
    f[1 << i][i] = l[1 << i][i];
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) {
        for (int k = 0; k < n; ++k) {
          if (a[k][w[i ^ 1 << j][k]] <= a[j][w[i][j]]) {
            f[i][j] = min(f[i][j], f[i ^ 1 << j][k] + l[i][j]);
          }
        }
      }
    }
  }
  int ans = inf;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, f[(1 << n) - 1][i]);
  }
  if (ans == inf) {
    ans = -1;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 55680