akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int GetGCD(int a, int b) {
    if (a < b) {
        auto temp = a;
        a = b;
        b = temp;
    }

    int r;
    while (true) {
        r = a % b;

        if (r == 0) return b;
        a = b;
        b = r;
    }
}

int GetLCMfromGCD(int a, int b, int gcd) {
    int e = a / gcd;
    return b * e;
}

int main() {
    int a, b;
    while (cin >> a >> b) {
        int gcd = GetGCD(a, b);
        cout << gcd << " " << GetLCMfromGCD(a, b, gcd) << endl;
    }
    return 0;
}

Measured memory_bytes: 3012
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

ls = "a b c d e f g h i j k l m n o p q r s t u v w x y z".split()
w = rls()
flag = True
for i in ls:
    count = 0
    for j in w:
        if(j == i):
            count += 1
    if(count % 2 == 1):
        flag = False
        break
print("Yes" if flag else "No")

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class Seg():
    def __init__(self, na, default, func):
        if isinstance(na, list):
            n = len(na)
        else:
            n = na
        i = 1
        while 2**i <= n:
            i += 1
        self.D = default
        self.H = i
        self.N = 2**i
        if isinstance(na, list):
            self.A = [default] * (self.N) + na + [default] * (self.N-n)
            for i in range(self.N-1,0,-1):
                self.A[i] = func(self.A[i*2], self.A[i*2+1])
        else:
            self.A = [default] * (self.N*2)
        self.F = func

    def find(self, i):
        return self.A[i + self.N]

    def update(self, i, x):
        i += self.N
        self.A[i] = x
        while i > 1:
            i = i // 2
            self.A[i] = self.merge(self.A[i*2], self.A[i*2+1])

    def merge(self, a, b):
        return self.F(a, b)

    def total(self):
        return self.A[1]

    def query(self, a, b):
        A = self.A
        l = a + self.N
        r = b + self.N
        res = self.D
        while l < r:
            if l % 2 == 1:
                res = self.merge(res, A[l])
                l += 1
            if r % 2 == 1:
                r -= 1
                res = self.merge(res, A[r])
            l >>= 1
            r >>= 1

        return res

def main():
    n = I()
    xd = sorted([LI() for _ in range(n)])
    xa = [x for x,_ in xd] + [inf]
    r = [0] * n + [1]
    def f(a,b):
        if a > b:
            return a
        return b
    seg = Seg(n+1,0,f)
    for i in range(n-1,-1,-1):
        x,d = xd[i]
        xi = bisect.bisect_left(xa, x+d)
        qi = seg.query(i,xi)
        if qi > xi:
            xi = qi
        seg.update(i,xi)
        r[i] = (r[i+1] + r[xi]) % mod2

    return r[0]


print(main())





Measured memory_bytes: 124808
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> b(n - 1); std::cin >> b;
  auto ret = b.front() + b.back();
  rep(i, 0, n - 2) {
    ret += std::min(b.at(i), b.at(i + 1));
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn include3(n: i32) -> bool {
    let mut x = n;
    let mut ret = false;
    while x != 0 {
        if x % 10 == 3 {
            ret = true;
            break;
        }
        x /= 10
    }
    ret
}

fn call(n: i32) {
    for i in 1..n+1 {
        if i % 3 == 0 || include3(i) {
            print!(" {}", i);
        }
    }
    println!("");
}

fn main() {

    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());

    let n = it.next().unwrap() as i32;

    call(n);
}



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

int main() {
  string S; cin >> S;
  int cnt = 0, size = S.size();
  for (int i = 0; i < size / 2; i++) {
    if (S[i] != S[size - 1 - i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int X, T;
    cin >> T >> X;
    double res = (double)T/X;

    cout << setprecision(20) << res << endl;

    return 0;
}


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

bool func(int n) {
    string s = to_string(n);

    bool b = true;
    for (int i = 0, n = s.size(), h = n / 2; i < h; i++)
        if (s.at(i) != s.at(n - 1 - i)) {
            b = false;
            break;
        }

    return b;
}

int main() {
    int a, b;
    cin >> a >> b;

    int cnt = 0;
    for (int i = a; i <= b; i++)
        if (func(i))
            cnt++;

    cout << cnt << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,K;
  cin>>N>>K;
  vector<int>H(N);
  rep(i,N)cin>>H[i];
  sort(rng(H));
  ll ans=0;
  for(int i=N-1;i>=0;i--){
    if(K>0)K--;
    else ans+=H[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
int out[100001];
int main()
{
    int co=0;
    double in;
    while(scanf("%lf",&in)!=EOF)
    {
        if(in<=48)out[co]=0;
        else if(in<=51)out[co]=1;
        else if(in<=54)out[co]=2;
        else if(in<=57)out[co]=3;
        else if(in<=60)out[co]=4;
        else if(in<=64)out[co]=5;
        else if(in<=69)out[co]=6;
        else if(in<=75)out[co]=7;
        else if(in<=81)out[co]=8;
        else if(in<=91)out[co]=9;
        else out[co]=-1;
        co++;
    }
    for(int i=0;i<co;i++)
    {
        if(out[i]==0)printf("light fly\n");
        else if(out[i]==1)printf("fly\n");
        else if(out[i]==2)printf("bantam\n");
        else if(out[i]==3)printf("feather\n");
        else if(out[i]==4)printf("light\n");
        else if(out[i]==5)printf("light welter\n");
        else if(out[i]==6)printf("welter\n");
        else if(out[i]==7)printf("light middle\n");
        else if(out[i]==8)printf("middle\n");
        else if(out[i]==9)printf("light heavy\n");
        else printf("heavy\n");
    }
    return 0;
}

Measured memory_bytes: 1036
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int flag = 0;
    int count=0;
    int ind;
    if(s[0] != 'A')flag = 1;
    
    for(int i=2; i<s.length()-1; i++){
        if(s[i] == 'C'){
            count++;
            ind = i;
        }
    }
    if(count != 1)flag = 1;
    for (int i = 1; i < s.length(); i++)
    {
        if(i==ind)continue;
        if (isupper(s[i]) != 0)flag =1;
    }

    if(flag==1){
        cout << "WA" ;
    }else{
        cout << "AC" ;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,ans;
  cin>>n>>m;
  if(n==1){
     cout<<m;
     return 0; 
  }
  for (int i = 1; i <=m/n; ++i){
     if(m%i==0&&m/i>=n)
       ans=i; 
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(n):
    flg = True
    for child in graph[i]:
        if h[i] <= h[child]:
            flg = False
            break
    ans += flg
print(ans)


Measured memory_bytes: 29344
#include<stdio.h>

int main(void)
{
	long long int n,k,ans1,ans2=0,i,ans3=0;
	scanf("%lld%lld",&n,&k);
	if(k%2==0){
		ans1=n*2/k;
		if(ans1%2==0){
			ans2=(ans1/2)*(ans1/2-1)*6;
			ans3=(ans1/2)*(ans1/2-1)*(ans1/2-2)*2;
		}
		else{
			ans2=((ans1/2+1)*(ans1/2)+(ans1/2)*(ans1/2-1))*3;
			ans3=(ans1/2+1)*(ans1/2)*(ans1/2-1)+(ans1/2)*(ans1/2-1)*(ans1/2-2);
		}
	}
	else{
		ans1=n/k;
		ans2=ans1*(ans1-1)*3;
		ans3=ans1*(ans1-1)*(ans1-2);
	}
	printf("%lld",ans1+ans2+ans3);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define out(x) rep(i, 0, (x).size()) cout << (x)[i] << ((i != (x).size() - 1) ? " " : "\n")
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
#define Pr(a) (#a) << "=" << (a) << " "
#define pr(a) cout << Pr(a) << '\n'
///////////////////////////////////////////////////////
int main() {
  int n, q;
  cin >> n;
  vi A(n);
  rep(i, 0, n) cin >> A[i];
  A.erase(unique(A.begin(), A.end()), A.end());
  out(A);
  return 0;
}


Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        String[] input_array = br.readLine().split(" ");
        int result = 0;

        for(String str : input_array)  {
            result += 1;
            if("0".equals(str)) break;
        }

        pw.println(result);
        br.close();
        pw.close();
    }
}

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

// ????????????????????£?¨?
int kruskal(int v, vector<vector<pair<int, int> > > adjlist);

// ?????????
int main(void){
  while(true){
    // ???????????°??¨???????????°???????????????
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    // ???????????±????????????????????£??\??????????????????
    vector<vector<pair<int, int> > > adjlist(n);
    for(int i = 0; i < m; i++){
      int a, b, d;
      scanf("%d %d %d", &a, &b, &d);
      adjlist[a].push_back(make_pair(d, b));
      adjlist[b].push_back(make_pair(d, a));
    }
  
    // ????°???¨?????¨????????????????±??????????????????????
    int length = kruskal(n, adjlist);
    cout << length << endl;
  }

  return 0;
}

// UnionFind??¨ ??????????????????

class UnionFindTree{
private:
  int m_size, unite_count;
  vector<int> parent;
  vector<int> rank;
  int find(int a);
public:
  void init(int size);
  void unite(int a, int b);
  bool same(int a, int b);
  bool isConnected(void);
};

// UF??¨????????????
void UnionFindTree::init(int size){
  m_size = size;
  unite_count = 0;
  parent.clear();
  rank.clear();
  for(int i = 0; i < size; i++){
    parent.push_back(i);
    rank.push_back(0);
  }
  return;
}

// UF??¨?????????????????????
int UnionFindTree::find(int a){
  if(parent[a] != a){ parent[a] = find(parent[a]); }
  return parent[a];
}

// UF??¨??§???????????£?????????
void UnionFindTree::unite(int a, int b){
  int x = find(a);
  int y = find(b);
  // ?????§???????????£???????????????????????????
  if(x == y){ return; }

  unite_count++;
  if(rank[x] < rank[y]){ parent[x] = y; }
  else{
    parent[y] = x;
    if(rank[x] == rank[y]){ rank[x]++; }
  }
  return;
}

// UF??¨??§???????????????????????????????????????
bool UnionFindTree::same(int a, int b){
  return find(a) == find(b);
}

// UF??¨??§?????????????????????????????¨???????????????????????????
bool UnionFindTree::isConnected(void){
  return unite_count == m_size - 1;
}

// ??????????????????
// v: ????????°, adjlist: ??£??\?????????(first: ???????????????, second: ?????????)
int kruskal(int v, vector<vector<pair<int, int> > > adjlist){
  int length = 0; // ??¨????????????

  // ?????????????????????
  vector<pair<int, pair<int, int> > > edge; // first: ???????????????, second: ???????????????
  for(int i = 0; i < v; i++)
    for(int j = 0; j < adjlist[i].size(); j++)
      edge.push_back(make_pair(adjlist[i][j].first, make_pair(i, adjlist[i][j].second)));
  sort(edge.begin(), edge.end());

  // UF??¨?????£?¨???¨?????????
  UnionFindTree uf;
  uf.init(v);

  // ???????????????????????????????????????????????????????????£?????????????????§?????????
  for(int i = 0; i < edge.size() && !uf.isConnected(); i++){
    // i??????????°???????????????????
    int cost = edge[i].first;
    int a = edge[i].second.first;
    int b = edge[i].second.second;
    // ????????????????????????????????£????????????????£???°???
    if(uf.same(a, b)){ continue; }

    // UF??¨?????£??????????????????????????´??°
    uf.unite(a, b);
    length += cost;
  }

  // ?????????: ??¨????????????
  return length;
}

Measured memory_bytes: 1296
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    vector<int> R(N, 0);
    for(int i = N-1; i >= 0; i--){
        if(i == N-1){
            R[i] = 0;
        }else if(H[i] >= H[i+1]){
            R[i] += R[i+1] + 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, R[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
using namespace std;
const long long INF = 1e18 + 313;

int tests;
long long A, B, C, D;

long long gcd(long long a, long long b)
{
    long long q, temp;
    long long oldr, r;

    oldr = a; r = b;
    while(r != 0)
    {
        q = oldr / r;

        temp = r;
        r = oldr - q * r;
        oldr = temp;
    }

    return oldr;
}

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

    cin >> tests;
    for(int current_case = 1; current_case <= tests; current_case++)
    {
        cin >> A >> B >> C >> D;

        if(D < B || A < B)
        {
            cout << "No" << endl;
            continue;
        }
        if(C >= B)
        {
            cout << "Yes" << endl;
            continue;
        }

        long long low, high, mid;
        long long times = 1;

        low = 1; high = INF;
        while(low <= high)
        {
            mid = (low + high) / 2;

            if(mid >= INF / B)
            {
                high = mid - 1;
                times = mid;
                continue;
            }

            if(A - mid * B <= C)
            {
                times = mid;
                high = mid - 1;
            }
            else
                low = mid + 1;
        }

        long long first_shortage = A - times * B;
        long long g = gcd(D, B);

        long long rem = 0;

        low = 1; high = INF;
        while(low <= high)
        {
            mid = (low + high) / 2;
            if(mid >= INF / g)
            {
                rem = mid;
                high = mid - 1;
                continue;
            }
            if(first_shortage + mid * g > C)
            {
                rem = mid;
                high = mid - 1;
            }
            else
                low = mid + 1;
        }

        if(first_shortage + rem * g < B)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9)
#define SYNC std::ios::sync_with_stdio(false)
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
	SYNC;
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = (n-2)*(b-a)+1;
	if(ans < 0) ans = 0;
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll ans = 0;
    ll h = A[0];
    for (int i = 1; i < N; i++) {
        h = max(h, A[i]);
        ans += max(0ll, h - A[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5136
def mips():
    return map(int,input().split())
def ii():
    return int(input())
def is_prime(n):
    if n == 1:
        return False
    i = 2
    while i*i <= n: #sqrt(n)までで十分。
        if n % i == 0:
            return False
        i += 1
    return True
Q = ii()
S = [0 for i in range(10 ** 5 + 1)]
N = 0
for i in [j for j in range(1,10 ** 5 + 1)]:
    if is_prime(i) and is_prime((i+1)//2):
        N += 1
        S[i] = N
    else:
        S[i] = N
for i in range(Q):
    l,r = mips()
    print(S[r]-S[l-1])

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

namespace ABC116
{
    class Sushi
    {
        public long d;
        public int t;
        public bool top;
    }

    class D
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]), K = int.Parse(s[1]);

            List<Sushi> list = new List<Sushi>();
            for (int i = 0; i < N; i++)
            {
                string[] s0 = Console.ReadLine().Split(' ');
                int t = int.Parse(s0[0]);
                long d = long.Parse(s0[1]);
                Sushi sushi = new Sushi();
                sushi.d = d; sushi.t = t;
                list.Add(sushi);
            }
            list = list.OrderByDescending(x => x.d).ToList();

            //各t毎に最大のdを持つSushiをTopとして特別扱い
            HashSet<int> tset = new HashSet<int>();
            for (int i = 0; i < N; i++)
            {
                Sushi sushi = list[i];
                if (!tset.Contains(sushi.t))
                {
                    sushi.top = true;
                    tset.Add(sushi.t);
                }
            }

            int indexA = K - 1;
            int indexB = K;
            var tlist = list.Take(K);
            long countType = tlist.GroupBy(x => x.t).Count();
            long sum = tlist.Sum(x => x.d);
            long sd = sum + countType * countType;
            long smax = sd;
            while (indexA >= 0 && indexB < N)
            {
                while (list[indexA].top)
                {
                    indexA--;
                    if (indexA < 0) goto Fin;
                }

                while (!list[indexB].top)
                {
                    indexB++;
                    if (indexB >= N) goto Fin;
                }

                sum += list[indexB].d - list[indexA].d;
                countType++;
                long sdn = sum + countType * countType;
                if (sdn > smax) smax = sdn;

                indexA--;
                indexB++;
            }

        Fin:
            Console.WriteLine(smax);
        }

    }
}


Measured memory_bytes: 36656
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		final int mod = 1000000007;
		
		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		long ans = 0;
		
		long hidari = 0;
		for(int h=0; h<K; h++) {
			hidari += h;
			hidari %= mod;
		}
		long migi = 0;
		for(int m=0; m<K; m++) {
			migi += N-m;
			migi %= mod;
		}
		
		for(int i=K; i<=N+1; i++) {
				ans += (migi + mod - hidari + 1) % mod;
				ans %= mod;
				migi += (N-i);
				migi %= mod;
				hidari += i; 
				hidari %= mod;
		}
		
		System.out.print(ans%mod);
		keyboard.close();
	}
}


Measured memory_bytes: 35748
#include <stdio.h>


int main(void) {
    int rem[80];
    int p, q, i, j, ll, lr;
    while (scanf("%d%d", &p, &q) == 2) {

        for (i = 0, ll = -1, lr = -1; i < 80 && p != 0; i++) {
            for (j = 0; j < i; j++) {
                if (rem[j] == p) {
                    ll = j;
                    lr = i;
                    goto calcover;
                }
            }
            rem[i] = p;
            p *= 10;
            printf("%d", p / q);
            p = p % q;
        }
        calcover:;
        puts("");
        if (ll >= 0) {
            for (i = 0; i < ll; i++) putc(' ', stdout);
            for (i = ll; i < lr; i++) putc('^', stdout);
            puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

const double PI = 3.14159265358979323846;

int main() {
    double R;
    double two = 2;
    cin >> R;
    cout << (R * PI * two) << endl;
}


Measured memory_bytes: 3764
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL x;
    LL y;
    int ans=1;
    cin >> x >> y;
    while(true){
        x*=2;
        if(y>=x){
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define SIZE 310

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

    int n, m, l;
    cin >> n >> m >> l;
    int G[SIZE][SIZE];
    rep(i, n) rep(j, n) G[i][j] = INF;
    rep(i, n) G[i][i] = 0;
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a][b] = G[b][a] = c;
    }
    vector<vector<P>> d(n, vector<P>(n, {INF, INF}));
    typedef pair<P, int> PP;
    rep(s, n)
    {
        priority_queue<PP, vector<PP>, greater<PP>> que;
        que.push(PP(P(0, 0), s));
        d[s][s] = {0, 0};
        while (!que.empty())
        {
            PP pp = que.top();
            que.pop();
            int cnt = pp.first.first;
            int used = pp.first.second;
            int now = pp.second;
            if (d[s][now] < pp.first)
                continue;
            rep(i, n)
            {
                if (i == now)
                    continue;
                if (G[now][i] > l)
                    continue;
                int nused = used + G[now][i];
                P np = {cnt, nused};
                if (nused > l)
                    np = {cnt + 1, G[now][i]};
                if (d[s][i] > np)
                {
                    d[s][i] = np;
                    que.push(PP(np, i));
                }
            }
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int s, t;
        cin >> s >> t;
        s--, t--;
        int ans = d[s][t].first;
        if (ans == INF)
            ans = -1;
        cout << ans << endl;
    }
}


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


int main() {
  ll N,D;
  cin >> N >> D;
  vector<ll> X(N),Y(N);
    for(ll i=0;i<N;i++)
      cin >> X[i] >> Y[i];
  
  ll count=0;
  for(ll i=0;i<N;i++){
   
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D)count++;
    
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 6428
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}

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

	ll n;
	cin >> n;
	Array a(n, 0);
	REP(i, n)cin >> a[i];


	Array sum(n + 1, 0);
	Array fact(n + 1, 1);
	REP(i, n) {
		(sum[i + 1] = sum[i] + mod_inv(i + 1, MOD)) %= MOD;
		(fact[i + 1] = (fact[i] * (i + 1)) % MOD) %= MOD;
	}

	ll ans = 0;
	REP(i, n) {
		ll con = MOD-1;
		(con += sum[i + 1]) %= MOD;
		(con += sum[n - i]) %= MOD;
		(ans += (con * a[i]) % MOD) %= MOD;
	}
	(ans *= fact[n]) %= MOD;

	cout << ans << endl;

	return 0;
}

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



const int N = 1e5 + 5;




int n, a[N], dp[N];




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  double a, b, n;
  cin >> a >> b >> n;
  if (b - 1 <= n) {
    double B = (b-1)/b;
    B *= a;
    ll bb = B * 1;
    printf("%lld\n", bb);
  }
  else {
    double B = n/b;
    B *= a;
    ll bb = B * 1;
    printf("%lld\n", bb);
  }
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n,k; cin >> n >> k;
	vector<int> hash(n);
	for(auto &x : hash)
		cin >> x;
	sort(hash.begin(),hash.end());
	ll ans = 0;
	for(int i = 0 ; i < k ; i++)
		ans+=hash[i];
	cout<<ans;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3640
A,B,H,M = map(int,input().split())
from math import pi,cos
m = 2*pi * M / 60
h = 2*pi * (H*60 + M) / 720

ans = (A*A + B*B - 2*A*B*cos(abs(m-h))) ** 0.5
print(ans)

Measured memory_bytes: 9492
def main():
    N, M = map(int, input().split())
    S = [tuple(map(int, input().split())) for _ in range(N)]
    C = [tuple(map(int, input().split())) for _ in range(M)]
    for a, b in S:
        dist = float("inf")
        ans = 0
        for i in range(M):
            c, d = C[i]
            x = abs(a-c) + abs(b-d)
            if x < dist:
                ans = i+1
                dist = x
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d",(b-a)*(b-a+1)/2-b);
    return 0;
}

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

int main() {
  int n;
  while (cin >> n and n != 0) {
    int acard, bcard, ascore = 0, bscore = 0;

    for (int i = 0; i < n; i++) {
      cin >> acard >> bcard;
      
      if (acard > bcard) {
        ascore += acard + bcard;
      } else if (acard < bcard) {
        bscore += acard + bcard;
      } else {
        ascore += acard;
        bscore += bcard;
      }
    }

    cout << ascore << " " << bscore << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 753;
    for(int i = 0;i < s.size()-2;i ++){
        int a = stoi(s.substr(i,3));
        if(abs(a-753)<ans) ans = abs(a-753);
    }
    cout << ans << endl;
    return 0;
}

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


void solve(long long N, long long K){
    long double ans=0;
    if(K<=N){
        for(int i=1;i<=K-1;i++){
            int lp=ceil(log2(K)-log2(i));
            ans+=pow(2,-lp);
        }
        ans+=N-K+1;
        ans=ans/N;
        printf("%.32Lf\n",ans);
    }
    else{
        for(int i=1;i<=N;i++){
            int lp=ceil(log2(K)-log2(i));
            ans+=pow(2,-lp);
        }
        ans=ans/N;
        printf("%.32Lf\n",ans);

    }
}


int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [[int(i) for i in input().split()] for i in range(N - 1)]

for i in range(N - 1):
    t = 0
    for j in range(i, N - 1):
        C, S, F = A[j]
        if t <= S:
            t = S
        else:
            if t % F == 0:
                pass
            else:
                t += F - t % F
        t += C
    print(t)
print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

int main()
{
     ios::sync_with_stdio(false);
     int n = 5;
     vector<int>v(n);
     for(int i=0 ; i<n ; i++) cin>>v[i];
     int Ans = 1e5;
     do{
        int b = 0, tot = 0;
        for(int i=0 ; i<5 ; i++){
            if(i == 4){
                tot+=v[i];
                continue;
            }
            int rem = v[i]%10;
            tot += (v[i] + ((rem) ? 10-rem : 0));
        }
        Ans = min(Ans, tot);
     }while(next_permutation(v.begin(), v.end()));

     cout<<Ans<<endl;

     return 0;
}




Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define int long long
#define uint unsigned lon1g long
#define double long double
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sett(c) (c).resize(unique(all(c))-(c).begin())
#define sz(a) (int)(a).size()
#define hell 1000000007
#define pi pair<int,int>
#define vi vector<int>
#define vb vector<bool>
#define vpi vector<pair<int,int>>
#define x first
#define y second
#define endl '\n'
#define forn(i,n) for(int i = 0 ; i < n ; i++ )
#define for1(i,n) for(int i = 1 ; i < n ; i++ )
#define fore(i,a,b) for(int i = a ; (a>b)?(i>=b):(i<=b) ; (a>b)?(i--):(i++) )

using namespace std;

bool comp(const pi& a , const pi& b ){
        return a.y < b.y;
}

void task_A(){
        string s ;
        cin >> s;
        for(int i = 1 ; i < sz(s) ; i++ ){
                if(s[i] == s[i-1]){
                        cout << "Bad" << endl;
                        return ;
                }
        }
        cout << "Good" << endl;
}

void task_B(){
        int n , l ;
        cin >> n >> l ;
        int arr[n] ;
        int ans = INT_MAX , sum = 0 ;
        for(int i = 0 ; i < n ; i++ ){
                arr[i] = l + i;
                if(abs(ans) > abs(arr[i])){
                        ans = arr[i];
                }
                sum += arr[i];
        }
        cout << sum-ans << endl;
}

void tastk_C(){

}

void task_D(){

}

void task_E(){

}

int32_t main(){

        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << fixed;
        cout.precision(10);

        int t = 1;
        //cin >> t ;
        while(t--){
                //task_A();
                task_B();
                //task_C();
                //task_D();
                //task_E();
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int gcd(int a, int b){
    if(a % b == 0){
        return b;
    }
    else{
        return gcd(b, a % b);
    }
}

int main(){
    int n;
    int x;
    cin >> n >> x;
    vector<int> a(n);
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        d[i] = abs(a[i] - x);
    }
    int result = d[0];
    for(int i = 0; i < n; i++){
        result = gcd(result, d[i]);
    }
    cout << result << endl;
    return 0;
}

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

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final char[] s = sc.next().toCharArray();
        final boolean[] used = new boolean[128];
        for (int i = 0; i < s.length; i++)
            used[s[i]] = true;
        for (int i = 'a'; i <= 'z'; i++)
            if (!used[i]) {
                System.out.println(new String(s) + (char) i);
                return;
            }
        for (int i = s.length - 1; i >= 0; i--) {
            Arrays.fill(used, false);
            for (int j = 0; j < i; j++)
                used[s[j]] = true;
            for (int j = s[i] + 1; j <= 'z'; j++)
                if (!used[j]) {
                    s[i] = (char) j;
                    System.out.println(new String(s, 0, i + 1));
                    return;
                }
        }
        System.out.println(-1);
    }
}
public class Main {
    public static void main(String...args) {
        A.main();
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

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

	queue<long long> que;
	for (int i = 1; i < 10; i++) {
		que.push(i);
	}

	int cnt = 0;
	while (1) {
		cnt++;
		auto x = que.front();
		que.pop();

		if (cnt == k) {
			cout << x << endl;
			break;
		}

		int y = x % 10;
		if (y != 0) {
			que.push(10 * x + y - 1);
		}
		que.push(10 * x + y);
		if (y != 9) {
			que.push(10 * x + y + 1);
		}
	}

	return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int p;
    cin >> p;

    cout << p / 500 * 500 << endl;

    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  if (a <= b){
    rep(i,b) cout << a;
    cout << endl;
  }else{
    rep(i,a) cout << b;
    cout << endl;
  }
}


Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N, ans = 0;
    cin >> N;
    for (int n = 1; n <= N; n += 2) {
        int cur = 0;
        for (int j = 1; j <= (int)sqrt(n); j++) {
            if (n % j == 0) {
                cur++;
                if (j != n / j) cur++;
            }
        }
        if (cur == 8) ans++;
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

void CountingSort( int* a, int* b, int n, int k )
{
    int c[k+1];

    for( int i = 0; i <= k; i++ )
        c[i] = 0;

    for( int j = 1; j <= n; j++ )
        c[a[j]]++;

    for( int i = 1; i <= k; i++ )
        c[i] = c[i] + c[i-1];

    for( int j = n; j >= 1; j-- )
    {
        b[c[a[j]]] = a[j];
        c[a[j]]--;
    }
}

int main()
{
    int n, k = 0;

    cin >> n;

    int a[n+1], b[n+1];

    for( int i = 1; i <= n; i++ )
    {   
        cin >> a[i];
        if( k < a[i] )
            k = a[i];
    }

    CountingSort( a, b, n, k );

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

    return 0;
}


Measured memory_bytes: 18716
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String s = scan.next();
        String t = scan.next();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String u = scan.next();

        if(s.equals(u)){
            os.println((a-1) + " " + b);
        } else {
            os.println(a + " " + (b-1));
        }
    }
}

Measured memory_bytes: 21972
N = int(input())
A = [int(x) for x in input().split()]
l = [0]*N
ans = 0
for a in A:
    l[a-1] += 1
for j in l:
    ans += int(j*(j-1)/2)
for k in range(N):
    print(ans - l[A[k]-1] + 1)


Measured memory_bytes: 81996
#include<bits/stdc++.h>
using namespace std;
long long a, b, l1, l2, r1, r2, res;
int main()
{
	cin >> a >> b;
	int p = 61;
	while (p >= 0 && (a >> p) == (b >> p))
	{
		p--;
		if (a >> p)a ^= (1LL << p), b ^= (1LL << p);
	}
	if (p < 0)res = 1;
	else
	{
		int k = p - 1;
		while (k >= 0 && !((b >> k) & 1))k--;
		l1 = a;
		r1 = (1LL << p) + (1LL << (k + 1)) - 1;
		l2 = (1LL << p) + a;
		r2 = (2LL << p) - 1;
		if (r1 >= l2)res = max(r1, r2) - min(l1, l2) + 1;
		else res = (r1 - l1 + 1) + (r2 - l2 + 1);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(void){
    int ans=0;
    int num=0;
    int score=0;
    int masu[100000];
    int i=0;

    scanf("%d\n",&num);

    for(int n=0;n<num;n++){
        scanf("%d",&masu[n]);
    }

    while(i<num-1){
        if(masu[i]>=masu[i+1]){
            score++;
        }else{
            if(score>ans){
                ans=score;
                score=0;
            }else{
                score=0;
            }
        }
        i++;
    }
    if(score>ans){
        ans=score;
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
int main()
{
	ll A,B,C,X,Y;
	vector<ll>ANS;
	cin>>A>>B>>C>>X>>Y;
	ANS.push_back(A*X+B*Y);
	if(X>Y){
		ll tmp1,tmp2;
		tmp1=X;
		X=Y;
		Y=tmp1;
		tmp2=A;
		A=B;
		B=tmp2;
	}
	ANS.push_back(X*C*2+(Y-X)*B);
	ANS.push_back(Y*C*2);
	sort(ANS.begin(),ANS.end());
	cout<<ANS.front()<<endl;
}

Measured memory_bytes: 256