akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;	
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define X real()
#define Y imag()
void pin(pt& p){
	ld x,y; 
	cin>>x>>y; 
	p={x,y};
}
ostream& operator<<(ostream& os, pt p){
	return os<<p.X<<" "<<p.Y<<endl;
} 
ld dot(pt p,pt q){
	return (p.X*q.X + p.Y*q.Y);
}
pt solve(pt p,pt q,pt x){
	ld l = dot((q-p),(x-p))/abs(q-p);
	pt on = l*(q-p)/abs(q-p);
	pt prj = p+on;
	return (prj+(prj-x));
}
int main (){
	cout<<fixed<<setprecision(12);
	pt p,q,x;
	pin(p);
	pin(q);
	int t; 
	cin>>t;
	while(t--){
		pin(x);
		cout<<solve(p,q,x); 
	}
	return 0;
}



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

int main() {
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  long int x, a, b;
  cin >> x >> a >> b;
  if(b<=a){cout << "delicious" << endl;}
  else if(b<=a+x){cout << "safe" << endl;}
  else{cout << "dangerous" << endl;}
 
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

        List<int>[] graph = Enumerable.Repeat(0, n).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < m; i++)
        {
            var st = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            graph[st[0]].Add(st[1]);
            graph[st[1]].Add(st[0]);
        }
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            foreach (var item in graph[i])
            {
                if (h[i] <= h[item]) goto end;
            }
            res++;
            end:;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 55608
import java.util.*;

public class Main {
static ArrayList<int[]> factorization (int n) {
    ArrayList<int[]> list = new ArrayList<int[]>();
    int tmp= n ;
    for (int i=2;i<=Math.sqrt(n);i++) {
        if (tmp%i==0) {
            int cnt=0;
            while (tmp%i==0) {
                cnt++;
                tmp/=i;
            }
            int[] x = {i, cnt};
            list.add(x);
        }
    }
    if (tmp!=1) {
        int[] x = {tmp, 1};
        list.add(x);
    }

    if (list.size()==0) {
        int[] x = {n, 1};
        list.add(x);
    }
    return list;
}
    static HashMap<Integer, Integer> map;
    static void add_map(Integer x, Integer y) {
        if (map.containsKey(x)) {
            map.put(x, map.get(x)+y);
        } else {
            map.put(x, y);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        map = new HashMap<Integer, Integer>();
        for (int i=2;i<=N;i++) {
            ArrayList<int[]> list = factorization(i);
            for (int[] array : list) {
                add_map(array[0], array[1]);
            }
        }
        ArrayList<Integer> values = new ArrayList<Integer>(map.values());
        Collections.sort(values);
        Collections.reverse(values);
        int ans = 0;
        for (int i=0;i<values.size();i++) {
            if (values.get(i)>=74) {
                ans++;
            }
        }
        for (int i=0;i<values.size();i++) {
            if (values.get(i)>=24) {
                for (int j=0;j<values.size();j++) {
                    if (i==j) {
                        continue;
                    }
                    if (values.get(j)>=2) {
                        ans++;
                    }
                }
            }
        }
        for (int i=0;i<values.size();i++) {
            if (values.get(i)>=14) {
                for (int j=0;j<values.size();j++) {
                    if (i==j) {
                        continue;
                    }
                    if (values.get(j)>=4) {
                        ans++;
                    }
                }
            }
        }
        for (int i=0;i<values.size();i++) {
            if (values.get(i)>=4) {
                for (int j=i+1;j<values.size();j++) {
                    if (values.get(j)>=4) {
                        for (int k=0;k<values.size();k++) {
                            if (i==k || j==k) {
                                continue;
                            }
                            if (values.get(k)>=2) {
                                ans++;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int all = int.Parse(System.Console.ReadLine());
            int cake = int.Parse(System.Console.ReadLine());
            int dor = int.Parse(System.Console.ReadLine());
            int ans = (all - cake) % dor;
            System.Console.WriteLine(ans);
        }
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    cout << a.back() - a[0] << endl;
    return 0;
}



Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	ans := 0
	if N == 1 && M == 1 {
		ans = 1
	} else if N == 1 || M == 1 {
		ans = max(N, M) - 2
	} else if N <= 2 || M <= 2 {
		ans = 0
	} else {
		ans = N*M - (N*2 + (M-2)*2)
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const N = Number(input.shift());
  let C_0 = 0, C_1 = 0, C_2 = 0, C_3 = 0;

  for(let i = 0; i < N; i++){
    switch(input[i]){
      case 'AC':
        C_0++;
        break;
      case 'WA':
        C_1++;
        break;
      case 'TLE':
        C_2++;
        break;
      case 'RE':
        C_3++;
        break;
      default:
        break;
    }
  }
  console.log('AC x ' + C_0);
  console.log('WA x ' + C_1);
  console.log('TLE x ' + C_2);
  console.log('RE x ' + C_3);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 38092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();

		if (n1 >= 10) {
			System.out.println(n2);
		} else {
			System.out.println(n2 + 100 * (10 - n1));
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N,M;
  cin >> N >> M;
  int syurui[M+1];
  rep(i,M) {
    syurui[i+1] = 0;
  } 
  rep(i,N) {
    int K;
    cin >> K;
    rep2(j,K) {
      int temp;
      cin >> temp;
      syurui[temp] = syurui[temp] + 1;
    }
  }
  int ans = 0;
  rep(i,M) {
    if(syurui[i+1] == N) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=505;
int n,mod,f[N][N],ans;
pair<int,int>a[N];
#define sqr(x) (x)*(x)
int main(){
	scanf("%d%d",&n,&mod);
	for(int i=0;i<n;++i){
		while(sqr(i)+sqr(a[i].first)<sqr(n))++a[i].first;
		--a[i].first;a[i].second=n+n-1;
		while(sqr(i)+sqr(a[i].second)>sqr(n+n))--a[i].second;
	}
	for(int i=n;i<n+n;++i){
		a[i].first=n+n-1;
		while(sqr(i)+sqr(a[i].first)>sqr(n+n))--a[i].first;
	}
	sort(a,a+n+n);
	for(int t=0;t<=n;++t){
		f[0][0]=1;
		for(int i=0,s1=0,s2=0;i<n+n;++i)
			if(!a[i].second){
				for(int j=0;j<=t;++j)
					f[i+1][j]=1ll*f[i][j]*(a[i].first+1-(s1+j))%mod;
				++s1;
			}else{
				for(int j=0;j<=t;++j)
					f[i+1][j]=1ll*f[i][j]*(a[i].second+1-(n+s2+t-j))%mod;
				for(int j=0;j<t;++j)
					f[i+1][j+1]=(f[i+1][j+1]+1ll*f[i][j]*(a[i].first+1-(s1+j)))%mod;
				++s2;
			}
		ans=(ans+(t&1?mod-f[n+n][t]:f[n+n][t]))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>

int main(void){
    char str[1000];
    char tmp[1000];
    char order[10];
    char print[] = "print";
    char reverse[] = "reverse";
    char replace[] = "replace";
    int q,a,b,i,j,k;
    scanf("%s",str);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%s",order);
        if(!strcmp(order,print)){
            scanf("%d %d",&a,&b);
            for(j=a;j<=b;j++){
                printf("%c",str[j]);
            }
            printf("\n");          
        } else if(!strcmp(order,reverse)){
            scanf("%d %d",&a,&b);
            strcpy(tmp,str);
            for(j = a;j <= b;j++){
                str[j] = tmp[b - j + a];
            }
        } else if(!strcmp(order,replace)){
            scanf("%d %d",&a,&b);
            scanf("%s",tmp);
            k = 0;
            for(j = a;j<=b;j++){
                str[j] = tmp[k];
                k++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

ll power_(ll a, ll power){
    ll value = 1;
    
    while(power != 0){
        if(power & 1) value = (value * a);
        a = (a * a);
        power = power >> 1;
    }
 
    return value;
}

ll f(ll N, ll X){
    ll ret;
    ll N2 = power_(2, N);
    ll aNm = 2 * N2 - 3;
    ll pNm = N2 - 1;
    
    if (X == 0) return 0;
    else if (N == 0) return 1;
    else if (X <= aNm + 1) ret = f(N - 1, X - 1);
    else ret = f(N - 1, X - aNm - 2) + 1 + pNm;

    return ret;
}

int main(void){
    ll N, X;
    ll answer = 1e9;
    cin >> N >> X;

    cout << f(N, X) << endl;

    return 0;
}

Measured memory_bytes: 256
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll 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;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	char a;
	cin >> a;
	char b = a + 1;
	cout << b << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#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, x, y;
	cin >> n >> x >> y;
	x--; y--;
	vector<vector<int>> g(n);
	rep(i, n - 1) {
		g[i].emplace_back(i + 1);
		g[i + 1].emplace_back(i);
	}
	g[x].emplace_back(y);
	g[y].emplace_back(x);

	vector<int> ans(n, 0);
	rep(i, n) {
		vector<int> dist(n, -1);
		queue<int> que;
		dist[i] = 0;
		que.push(i);

		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (int nv : g[v]) {
				if (dist[nv] != -1)	continue;
				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
		}
		rep(j, n) {
			ans[dist[j]]++;
		}
	}
	for (int i = 1; i < n; ++i) {
		cout << ans[i] / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
def main(str)
  n, k = str.split(" ").map(&:to_i)
  range = (0..n).to_a
  rev_range = range.reverse
  sum = 0
  min = range[0...(k - 1)].sum
  max = rev_range[0...(k - 1)].sum
  prei = k - 1
  (k..n+1).each do |i|
    min += range[prei]
    max += rev_range[prei]
    prei += 1
    sum += max - min + 1
  end
  sum % (10 ** 9 + 7)
end

unless ENV["TEST"]
  puts main($stdin.read.chomp)
  exit(0)
end

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool ok = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) { ok = true; }
    }
    cout << (ok ? "OK" : "NG") << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    static String[] a;
    static String[] b;
    static String temp;
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextLine().split(" ");
        b = scanner.nextLine().split(" ");
        char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
         
        boolean flag = false;
        for(int i=0;i<3;i++){
            for(char d:c){
                roll(d);
                if(Arrays.equals(a, b)){
                    flag=true;
                    break;
                }
            }
        }
        if(flag)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
 
    public static void roll(char c) {
        switch (c) {
        case 'E':
            temp = a[0];
            a[0] = a[3];
            a[3] = a[5];
            a[5] = a[2];
            a[2] = temp;
            break;
        case 'N':
            temp = a[0];
            a[0] = a[1];
            a[1] = a[5];
            a[5] = a[4];
            a[4] = temp;
            break;
        case 'W':
            temp = a[0];
            a[0] = a[2];
            a[2] = a[5];
            a[5] = a[3];
            a[3] = temp;
            break;
        default:
            temp = a[0];
            a[0] = a[4];
            a[4] = a[5];
            a[5] = a[1];
            a[1] = temp;
            break;
        }
    }
 
}



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

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

    vector<int> a(n);
    map<int, long long int> ball;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(ball.find(a[i]) == ball.end()) ball[a[i]] = 1;
        else ball[a[i]] += 1;
    }

    long long int ans = 0;
    for(auto b : ball){
        ans += b.second * (b.second - 1) / 2;
        //cout << b.first << " " << b.second << endl;
    }
    //cout << ans << endl;

    for(int i=0; i<n; i++){
        cout << ans 
                - ball[a[i]] * (ball[a[i]] - 1) / 2
                + (ball[a[i]] - 1) * (ball[a[i]] - 2) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 10240
n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for j in range(t+1)] for i in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
 
for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])
 
print(ans)

Measured memory_bytes: 124376
S = input()
left =int(S[0:2])
right=int(S[2:])
# print(left,right)
leftM = left <= 12 and left >= 1
rightM = right <=12 and right >= 1

if leftM and rightM:
    ans = "AMBIGUOUS"
elif leftM:
    ans = "MMYY"
elif rightM:
    ans = "YYMM"
else:
    ans = "NA"

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
c = [[0] * 10 for _ in [0] * 10]
for i in range(1, int(input()) + 1):
    c[int(str(i)[0])][int(str(i)[-1])] += 1

print(sum(c[i][j] * c[j][i] for i in range(10) for j in range(10)))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

#define mkt make_tuple

int N,Q;

vector<tuple<int,int,int>> g[100010];
int x[100010],y[100010],u[100010],v[100010];


//入力
#define MAX_V 100010
#define MAX_LOG_V 20

vector<int> G[MAX_V];  //グラフの隣接リスト表現
int root;              //根ノードの番号

int parent[MAX_LOG_V][MAX_V];  //親を2^k回辿って到達する頂点（根を通り過ぎる場合は-1）
int depth[MAX_V];  //根からの深さ

void dfs(int v,int p,int d){
  parent[0][v]=p;
  depth[v]=d;
  for(int i=0;i<G[v].size();i++){
    if(G[v][i]!=p) dfs(G[v][i],v,d+1);
  }
}

//初期化
void init(int V){
  //parent[0]とdepthを初期化する
  dfs(root,-1,0);
  //parentを初期化する
  for(int k=0;k+1<MAX_LOG_V;k++){
    for(int v=0;v<V;v++){
      if(parent[k][v]<0) parent[k+1][v]=-1;
      else parent[k+1][v]=parent[k][parent[k][v]];
    }
  }
}

//uとvのLCAを求める
int lca(int u,int v){
  //uとvの深さが同じになるまで親を辿る
  if(depth[u]>depth[v]) swap(u,v);
  for(int k=0;k<MAX_LOG_V;k++){
    if((depth[v]-depth[u])>>k&1){
      v=parent[k][v];
    }
  }
  if(u==v) return u;
  //二分探索でLCAを求める
  for(int k=MAX_LOG_V-1;k>=0;k--){
    if(parent[k][u]!=parent[k][v]){
      u=parent[k][u];
      v=parent[k][v];
    }
  }
  return parent[0][u];
}

map<int,pair<int,int>> mp;
map<pair<int,int>,int> num;
map<pair<int,int>,int> sum;
vector<int> checklist[100010];

int dist[100010];

void findDistance(int now,int par,int dis){
  dist[now]=dis;
  for(auto nex:g[now]){
    int nv=get<0>(nex);
    if(nv==par) continue;
    findDistance(nv,now,dis+get<2>(nex));
  }
}

void eulerTour(int now,int par,int col,int dis){
  for(auto c:checklist[now]){
    num[mkp(now,c)]=mp[c].first;
    sum[mkp(now,c)]=mp[c].second;
  }

  for(auto nex:g[now]){
    int nv=get<0>(nex);
    int ncol=get<1>(nex);
    int ndis=get<2>(nex);
    if(nv==par) continue;

    mp[ncol].first++;
    mp[ncol].second+=ndis;
    eulerTour(nv,now,ncol,ndis);
    mp[ncol].first--;
    mp[ncol].second-=ndis;
  }
}

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

  for(int i=0;i<Q;i++) cin>>x[i]>>y[i]>>u[i]>>v[i];

  init(N);
  vector<int> z(Q,0);
  
  for(int i=0;i<Q;i++){
    u[i]--;
    v[i]--;
    z[i]=lca(u[i],v[i]);
    checklist[u[i]].push_back(x[i]);
    checklist[v[i]].push_back(x[i]);
    checklist[z[i]].push_back(x[i]);
  }

  eulerTour(0,-1,0,0);
  findDistance(0,-1,0);

  vector<int> ans;
  for(int i=0;i<Q;i++){
    int d=dist[u[i]]+dist[v[i]]-2*dist[z[i]];
    int n=num[mkp(u[i],x[i])]+num[mkp(v[i],x[i])]-2*num[mkp(z[i],x[i])];
    int s=sum[mkp(u[i],x[i])]+sum[mkp(v[i],x[i])]-2*sum[mkp(z[i],x[i])];
    //cout<<d<<" "<<n<<" "<<s<<endl;
    d=d-s;
    d+=n*y[i];
    ans.push_back(d);
  }

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


  return 0;
}


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

namespace mondai0012
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				//var	ss	= s.Split( new char[ 0 ], StringSplitOptions.RemoveEmptyEntries );
				var	ss	= s.Split();
				var	x1	= double.Parse( ss[ 0 ] );
				var	y1	= double.Parse( ss[ 1 ] );
				var	x2	= double.Parse( ss[ 2 ] );
				var	y2	= double.Parse( ss[ 3 ] );
				var	x3	= double.Parse( ss[ 4 ] );
				var	y3	= double.Parse( ss[ 5 ] );
				var	xp	= double.Parse( ss[ 6 ] );
				var	yp	= double.Parse( ss[ 7 ] );

				var	org_area	= area_calc( x1, y1, x2, y2, x3, y3 );
				
				var	test_area	= area_calc( x1, y1, x2, y2, xp, yp );
					test_area	+= area_calc( x2, y2, x3, y3, xp, yp );
					test_area	+= area_calc( x3, y3, x1, y1, xp, yp );
				
				if( Math.Round( test_area, 10 ) <= Math.Round( org_area, 10 ) ) {
					Console.WriteLine( "YES" );
				} else {
					Console.WriteLine( "NO" );
				}
			}
		}

		static double area_calc( double x1, double y1, double x2, double y2, double x3, double y3 )
		{
			var	a	= Math.Sqrt( ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) );
			var	b	= Math.Sqrt( ((x2 - x3) * (x2 - x3)) + ((y2 - y3) * (y2 - y3)) );
			var	c	= Math.Sqrt( ((x3 - x1) * (x3 - x1)) + ((y3 - y1) * (y3 - y1)) );
			var	s	= (a + b + c) / 2.0;
			return( Math.Sqrt( s * (s - a) * (s - b) * (s - c) ) );
		}
	}
}

Measured memory_bytes: 5740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    string s; cin >> s;
    int n = s.size();

    map<char,int> mp;
    rep(i,n) mp[s[i]]++;

    rep(i,26){
        if(!mp[char (i+97)]){
            cout << s + char(i+97) << endl;
            return 0;
        }
    }
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    else {
        for(int i = n-1; i >= 1; i--){
            if(s[i-1] < s[i]){
                rep(j,i-1){
                    cout << s[j];
                }
                for(int j = n-1; j>=1;j--){
                    if(s[i-1] < s[j]){
                        cout << s[j];
                        return 0;
                    }
                }
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var S string
	fmt.Scanf("%s", &S)

	mn := len(S)
	for i := 'a'; i <= 'z'; i++ {
		l := 0
		mx := 0
		for j := 0; j < len(S); j++ {
			if S[j] == byte(i) {
				if mx < j-l {
					mx = j - l
				}
				l = j + 1
			}
		}
		if mx < len(S)-l {
			mx = len(S) - l
		}
		//println(mx, l)

		if mn > mx {
			mn = mx
		}
	}
	fmt.Println(mn)

}


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

using namespace std;
typedef long long ll;


bool prop(pair<ll, ll> p1, pair<ll, ll> p2)
{
   return p1.second < p2.second || (p1.second == p2.second && p1.first < p2.first); 
}

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

    vector< pair<ll, ll> > ab;
    ll a, b;
    for(size_t i = 0; i < n; ++i)
    {
        cin >> a >> b;
        ab.push_back(make_pair(a,b));
    }
    sort(ab.begin(), ab.end(), prop);

    ll t = 0;
    for(size_t i = 0; i < n; ++i)
    {
        t += ab[i].first;
        if(t > ab[i].second){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std; 
int main()
{int a,b,x,r; 
cin>>x>>a>>b; 
r=(x-a)%b;
cout<<r;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n,a;
  cin >> n >> a;
  
  cout << n*n - a << endl;


 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
bool f(ll x, ll y){
  return x > y;
}
ll gcd(ll a, ll b){
  if(b>a) swap(a,b);
  if(b == 0) return a;
  return gcd(b, a%b);
}
int main(){
  ll n; cin>>n;
  set<string>s;
  while(n--){
    string k; cin>> k;
    s.insert(k);
  }
  cout<< s.size() << endl;
}

    

Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    ll dp[100001][3] = {};
    if(a[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i=1;i<=n;i++){
        int cnt = 0;
        for(int j=0;j<3;j++){
            if(dp[i-1][j] == a[i-1]){
                cnt++;
            }
        }
        ans = (ans*cnt)%MOD;
        for(int j=0;j<3;j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j=0;j<3;j++){
            if(dp[i-1][j] == a[i-1]){
                dp[i][j] = dp[i-1][j]+1;
                break;
            }
        }
    }
    cout << ans << endl;    
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	int H=in(),N=in();
	vector<vector<int>> dp(N+1,vector<int>(H+1,1<<30));
	vector<pair<int,int>> P(N);
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
	}

	dp[0][0]=0;
	REP(i,N){
		REP(j,H+1){
			chmin(dp[i+1][j],dp[i][j]);
			chmin(dp[i][min(H,j+P[i].first)],dp[i][j]+P[i].second);
		}
	}

	out(dp[N][H]);
	return 0;
}


Measured memory_bytes: 39424
#include <stdio.h>
int main(void){
	int counter=0,i,seisu[3],replace;//?????°?????????
	for(i=1;i<=3;i++){
	scanf("%d",&seisu[i-1]);
	}
	do{
		counter=0;
		for(i=1;i<=2;i++){
			if(seisu[i-1]>seisu[i]){
				replace=seisu[i-1];
				seisu[i-1]=seisu[i];
				seisu[i]=replace;
				counter++;
			}
		}
	}while(counter!=0);
	printf("%d %d %d\n",seisu[0],seisu[1],seisu[2]);
	return 0;

}

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

int main() {
  ll a,b,c;
  cin >> a>>b>>c;
  if (a==b && b==c) {
    cout <<"Yes";
  }
  else {
    cout << "No";
  }
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <stdlib.h>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector <int> tab(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> tab[i];
	}
	vector <int> dp(n, 2147483647);
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < i + k + 1; j++)
		{
			if (j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(tab[i] - tab[j]));
			}
		}
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 550;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
queue<pii> q;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, ans;
int p[N * N];
int d[N][N];
bool vis[N][N];

inline void bfs(int x,int y)
{
    while(!q.empty())
        q.pop();
    ans += d[x][y];
    q.push(mp(x, y));
    vis[x][y] = 1;
    while(!q.empty())
    {
        int x = q.front().first, y = q.front().second;
        q.pop();
        for (int k = 0; k < 4;++k)
        {
            int nx = x + dx[k], ny = y + dy[k];
            if(nx<1||ny<1||nx>n||ny>n||d[nx][ny]<=d[x][y]+1-vis[x][y])
                continue;
            d[nx][ny] = d[x][y] + 1 - vis[x][y];
            q.push(mp(nx, ny));
        }
    }
}

void solve()
{
    scanf("%d", &n);
    for (int i = 1; i <= n * n; ++i)
        scanf("%d", &p[i]);
    memarray(d, inf);
    for (int i = 1; i <= n; ++i)
    {
        if (d[1][i])
            d[1][i] = 0, q.push(mp(1, i));
        if (d[n][i])
            d[n][i] = 0, q.push(mp(n, i));
        if (d[i][n])
            d[i][n] = 0, q.push(mp(i, n));
        if (d[i][1])
            d[i][1] = 0, q.push(mp(i, 1));
    }
    while(!q.empty())
    {
        int x = q.front().first, y = q.front().second;
        q.pop();
        for (int k = 0; k < 4;++k)
        {
            int nx = x + dx[k], ny = y + dy[k];
            if(nx<1||ny<1||nx>n||ny>n||d[nx][ny]<=d[x][y]+1)
                continue;
            d[nx][ny] = d[x][y] + 1;
            q.push({nx, ny});
        }
    }
    for (int i = 1; i <= n * n;++i)
    {
        int x = (p[i] - 1) / n + 1, y = (p[i] - 1) % n + 1;
        bfs(x, y);
    }
    printf("%d\n", ans);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 6168
N, A, B, C = gets.split.map(&:to_i)
L = N.times.map { gets.to_i }

def calc_cost(v, list)
  sum = list.inject(:+)
  cost = (v - sum).abs + 10 * (list.size - 1)
end

ans = Float::INFINITY

[*0..3].repeated_permutation(N) do |list|
  next if (list & [1, 2, 3]).size <= 2

  listA = list.map.with_index { |c, i| c == 1 ? L[i] : nil }.compact
  listB = list.map.with_index { |c, i| c == 2 ? L[i] : nil }.compact
  listC = list.map.with_index { |c, i| c == 3 ? L[i] : nil }.compact

  costA = calc_cost(A, listA)
  costB = calc_cost(B, listB)
  costC = calc_cost(C, listC)
  cost = costA + costB + costC

  if ans > cost
    ans = cost
  end
end

puts ans


Measured memory_bytes: 3964
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int val = i;
        int iter = 0;
        while (val < k)
        {
            iter++;
            val *= 2;
        }
        ans += pow(0.5, iter) / n;
    }
    cout << setprecision(14) << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
int flag=1;
while(flag){
	c-=b;
	a-=d;
	if(c<=0){
			printf("Yes\n");return 0;}
if(a<=0){
			printf("No\n");return 0;}

}
    return 0;
}


Measured memory_bytes: 3688
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
    if(a>b){
            console.log('a > b');
    }else if(a<b) {
        console.log('a < b');
    }else{
        console.log('a == b');
    }
    //????????????????????????

  }(params[0],params[1])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <stdio.h>
int main(void){
    int a, b, c;
    a = 1;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 2;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 3;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 4;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 5;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 6;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 7;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 8;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
    a = 9;
    for(b=1;b<10;b++){
       c = a * b;
       printf("%dx%d=%d\n", a, b, c);
    }
     return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main(){
	long long int a,b,k,bis=1,yen=0;
	cin>>k>>a>>b;
	for(int i=0;i<k;i++){
		if(b-a<2){
				bis++;
		}
		else{
			if(yen>0){
				yen--;
				bis=bis+b;
			}
			else if(bis>=a&&i!=k-1){
				bis=bis-a;
				yen++;
			}
	/*		else if(){
				
			}*/
			else{
				bis++;
			}
		}
	}
	cout<<bis<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
ll const mod = 1e9+7;

int main() {
    ll n,k;
    cin >> n >> k;
    ll ans = 0,mn = 0,mx = 0;
    for (int i = 0;i < k;++i) {
        mn += i;
        mx += n-i;
    }
    for (int i = k;i < n+2;++i) {
        (ans += mx-mn+1) %= mod;
        mn += i;
        mx += n-i;
    }
    cout << ans << endl;
}

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

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int N = fs.nextInt(), R = fs.nextInt();
    System.out.println((N < 10) ? R + 100 * (10 - N) : R);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

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

Measured memory_bytes: 21460
import java.io.*;
import java.util.Scanner;
import java.math.BigInteger;

public class Main
{	
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		int n;
		while(true)
		{
			n = cin.nextInt();
			if(n==0) break;
	
			BigInteger   p = new BigInteger("1"); 
			BigInteger[] s = new BigInteger[10];
			BigInteger[] t = new BigInteger[10];

			for(int i=0; i<n; i++)
			{
				s[i] = new BigInteger(cin.next());
				t[i] = new BigInteger(cin.next());
				
				p = t[i].multiply( p.divide( p.gcd(t[i]) ));
			}

			for(int i=0; i<n; i++)
			{
				s[i] = s[i].multiply( p.divide(t[i]) );
			}
			
			p = new BigInteger("1");
			for(int i=0; i<n; i++)
			{
				p = s[i].multiply( p.divide( p.gcd(s[i]) ));
			}			
			
			for(int i=0; i<n; i++)
			{
				System.out.println(p.divide(s[i]));
			}
		}
	}
}

Measured memory_bytes: 13000
n = int(input())
s = input()

l = len(s)

dp = [[0] * (l + 1) for _ in range(l + 1)]
dp[0][0] = 1

ans = 0
for i, ei in enumerate(s, 1):
    for j, ej in enumerate(s[i:], i+1):
        if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j])

print(ans)


Measured memory_bytes: 230920
def solve(n,m):
    Ans=[]
    if n%2==1:
        for i in range(1,m+1):
            Ans.append((i,n-i))
        return Ans
    a=1; b=n
    d1=n-1; d2=1
    while d1>d2 and a<=m:
        Ans.append((a,b))
        a+=1; b-=1
        d1-=2; d2+=2
    b-=1
    while a<=m:
        Ans.append((a,b))
        a+=1
        b-=1
    return Ans
    
def main():
    n,m=map(int,input().split())
    Ans=solve(n,m)
    for ans in Ans:
        print(*ans)
    
if __name__=='__main__':
    main()

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

using namespace std;
typedef long long ll;
int main()
{
    ll x=0 , a , b;
    ll n ;
    cin >> n >> a >> b;
    ll arr[n+1];
    for(int i =1 ; i <=n ; i++)
    {
        cin >> arr[i];
        if(i==1)
            continue;
        x+=min( (arr[i]-arr[i-1])*a , b);
    }
    cout << x ;
    return 0;
}


Measured memory_bytes: 4364
class UnionFind():
  # 作りたい要素数nで初期化
  # 使用するインスタンス変数の初期化
  def __init__(self, n):
    self.n = n
    # root[x]<0ならそのノードが根かつその値が木の要素数
    # rootノードでその木の要素数を記録する
    self.root = [-1]*(n+1)
    # 木をくっつける時にアンバランスにならないように調整する
    self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
    # ここで代入しておくことで、後の繰り返しを避ける
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

    # 木の併合、入力は併合したい各ノード
  def Unite(self, x, y):
    # 入力ノードのrootノードを見つける
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    # すでに同じ木に属していた場合
    if (x == y):
      return 
      # 違う木に属していた場合rnkを見てくっつける方を決める
      #rnkが大きい方に結合
    elif (self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x

    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      # rnkが同じ（深さに差がない場合）は1増やす
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1

  # xとyが同じグループに属するか判断
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  # ノードxが属する木のサイズを返す
  def Count(self, x):
    return -self.root[self.Find_Root(x)]

N,M=map(int, input().split())
#1 or 2がN枚
L=[]
uni=UnionFind(N)
for i in range(M):
  x,y,z=map(int, input().split())
  #Ax+Ay+Zが偶数
  #ZとAX+AY偶奇が一致
  uni.Unite(x-1,y-1)
  
root=[]
for i in range(N):
  root.append(uni.Find_Root(i))
  
print(len(set(root)))


Measured memory_bytes: 14760
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;

template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int main() {
	ll a,b;
	cin >> a >> b;
	if(a >= b && a%b == 0){
		cout << -1 << endl;
	}
	else{
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s = deque(list(input()))
q = int(input())
f = 0
for _ in range(q):
  l = input()
  if l == "1":
    f ^= 1
  else:
    a, b, c = l.split()
    if f ^ (b=="1"):
      s.appendleft(c)
    else:
      s.append(c)
if f:
  ans = list(s)[::-1]
else:
  ans = list(s)
print(*ans, sep="")

Measured memory_bytes: 90904
#include <iostream>
    #include <string>
    using namespace std;
     
    int main() {
    	string S;
    	cin >> S;
    	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) cout << "Bad" << endl;
    	else cout << "Good" << endl;
    	return 0;
    }

Measured memory_bytes: 256
n, m = map(int, input().split())

A = [0]*m
C = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    cs = list(map(int, input().split()))
    c = 0
    for c_ in cs:
        c += 1 << (c_-1)
    C[i] = c

dp = [float('inf')]*(1 << n)
dp[0] = 0
for i in range(1 << n):
    for j in range(m):
        c = C[j]
        dp[i|c] = min(dp[i|c], dp[i]+A[j])

if dp[-1] != float('inf'):
    print(dp[-1])
else:
    print(-1)

Measured memory_bytes: 46680