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

using namespace std;
int p[60];
int main(){
	int i,n;
	cin >> n;
	int cnt = 0;
	for(i=0;i<n;i++){
		cin >> p[i];
		if(i + 1!=p[i]){
			cnt++;
		}
	}
	if(cnt>2){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
}

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

int main() {
  string s;
  int t =0;
  cin >> s ;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == '1'){
      t +=1;
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 256
def a_candy_distribution_again(N, X, A):
    tmp = 0  # お菓子を要求された量以上配れる子供の人数
    for a in sorted(A):
        X -= a
        if X < 0:
            break
        tmp += 1
    ans = tmp - int(X > 0)  # お菓子に端数が出た場合、1人喜ばせられない
    return ans

N, X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(a_candy_distribution_again(N, X, A))

Measured memory_bytes: 3060
local function expected_value(n)
    return (n + 1) / 2.0
end

local function main()
    local n, k = io.read("*n", "n")
    local a, sum, ans = {}, {}, 0
    for i = 1, n do
        a[i] = expected_value(io.read("*n"))
    end
    sum[1] = a[1]
    for i = 2, n do
        sum[i] = sum[i - 1] + a[i]
    end
    ans = sum[k]
    for i = 1, n - k do
        ans = math.max(ans, sum[i + k] - sum[i])
    end
    print(ans)
end

main()


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

int main(){
    int i=0,n;
    vector<int> a(9);
    vector<bool> jud(9,false);
    for(i=0;i<9;i++){
        cin >> a.at(i);
    }
    cin >> n;
    vector<int> b(n);
    for(i=0;i<n;i++){
        cin >> b.at(i);
        for(int j=0;j<9;j++){
            if(b.at(i)==a.at(j))jud.at(j)=true;
        }
    }
    if((jud.at(0)&&jud.at(1)&&jud.at(2))||(jud.at(3)&&jud.at(4)&&jud.at(5))||(jud.at(6)&&jud.at(7)&&jud.at(8))||(jud.at(0)&&jud.at(3)&&jud.at(6))||(jud.at(1)&&jud.at(4)&&jud.at(7))||(jud.at(2)&&jud.at(5)&&jud.at(8))||(jud.at(2)&&jud.at(4)&&jud.at(6))||(jud.at(0)&&jud.at(4)&&jud.at(8))){cout << "Yes" << endl;}
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  ll ans = (n - m) * 100 + m * 1900;
  ans *= pow(2, m);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 384
A,B,H,M = map(int,input().split())
minu = H * 60 + M

kaku1 = 360 *minu / (12*60)
kaku2 = 360 *minu / 60
kaku = max(kaku1-kaku2,kaku2-kaku1)

import math

cos = math.cos(math.radians(kaku))
print((A**2+B**2 - 2*A*B*cos)**(1/2))


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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

template <typename T>
T _gcd(T a, T b) {
    return b ? _gcd(b, a % b) : a;
}

template <typename T>
vector<T> _divisor(T a) {
    vector<T> res;
    for (T i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            res.push_back(i);
            if (i != 1 && i * i != a)
                res.push_back(a / i);
        }
    }
    return res;
}

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

    long long n, m;
    cin >> n >> m;

    if (m % n == 0) {
        cout << m / n << endl;
    } else {
        long long p = m / n;
        long long q = m % n;

        vll a = _divisor(m);

        long long ans = 1;

        for (int i = 0; i < a.size(); i++) {
            long long t = m - a[i] * n;
            //ans = max(ans, _gcd(t, n));

            if (t > 0)
                ans = max(ans, a[i]);
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())

uf = UnionFind(n) # n: 頂点数

for i in range(m):
    x, y, z = map(int, input().split())

    uf.union(x-1, y-1)

print(uf.group_count())


Measured memory_bytes: 13760
// Eternal Average
// * frank_c1
// * 2017 / 09 / 29

#include <bits/stdc++.h>
using namespace std;

const int maxn = 6005;
const int mo = (int)(1e9) + 7;
int f[maxn][maxn];

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n, m, K, ret = 0;
	scanf("%d%d%d", &n, &m, &K);
	f[0][0] = 1;
	for (int i = 1; ; ++i) {
		int mi = (K - 1) * i + 1 - n;
		if (mi > m) break;
		for (int w = 1; w < K; ++w) {
			for (int j = w; j <= m; ++j) {
				add(f[i][j], f[i - 1][j - w]);
			}
		}
		for (int j = 0; j <= m; ++j) if (!((j - m) % (K - 1)) && !((j + n - (K - 1) * i - 1) % (K - 1)) && j >= mi) add(ret, f[i][j]);
		for (int j = 0; j <= m; ++j) add(f[i][j], f[i - 1][j]);
	}
	return printf("%d\n", ret), 0;
}

Measured memory_bytes: 93440
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll d;cin >> d;
	vector<ll> c(26);REP(i, 26)cin >> c[i];
	vector<vector<ll>> s(d, vector<ll>(26));

	REP(i, d)REP(j, 26)cin >> s[i][j];
	vector<ll> now(26);

	REP(day, d){
		ll out = 0;
		ll ma = -LLINF;

		REP(i, 26){
			if(ma < s[day][i] + (now[i] + 1) * c[i]){
				ma = s[day][i] + (now[i] + 1) * c[i];
				out = i;
			}
		}

		cout << (out + 1) << endl;

		REP(i, 26){
			if(i == out)now[i] = 0;
			else now[i]++;
		}
	}

	return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    if ( a + b >= 10 ) {
        cout << "error" << endl;
    }
    else {
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    int n, k;
    cin >> n >> k;
    vector<long int>h(n);
    int i;
    for (i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }
    sort(h.rbegin(), h.rend());
    long long int ans=0;
    for (i = k; i < n; i++)
    {
        ans += h.at(i);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

vector<int> par[100010];
vector<int> ch[100010];
int depth[100010];
int n, m;

int dfs(int v){
    if (par[v].size() == 0) {
        depth[v] = 0;
        return 0;
    }
    if (depth[v]) return depth[v];

    for (int p : par[v]) {
        depth[v] = max(dfs(p)+1, depth[v]);
    }
    return depth[v];
}

int main(void){
    cin >> n >> m;
    rep(i,n-1+m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        ch[a].push_back(b);
        par[b].push_back(a);
    }
    rep(i,n){
        dfs(i);
    }
    rep(i,n){
        int max_id = -1;
        int max_depth = 0; 
        for(int p : par[i]){
            if (max_depth <= depth[p]) {
                max_depth =  depth[p];
                max_id = p;
            }
        }
        cout << max_id+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 14080
from copy import deepcopy
from functools import reduce


class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n
            complexity: O(n^(1/2))
            used in ProjectEuler No.12, yukicoder No.36
        """
        assert(n >= 1)
        number = n
        if number == 1:
            self.primeFactorization = {1: 1}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if number > 1:
                self.primeFactorization[number] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])


N, P = map(int, input().split())
d = Divisor(P)
ans = 1
for k, v in d.primeFactorization.items():
    ans *= k ** (v // N)
print(ans)


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

int main() {
  int N, M, x;
  x = 0;
  cin >> N;
  M = N;
  for(int i = 0; i < 8; i++){
    x += M%(10);
    M /= 10;
  }
  if(N % x == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int N = s.nextInt();

		//int[] tasks = new int[N];
		//int[] deadLines = new int[N];
		//boolean[] isFinished = new boolean[N];


		//TreeMap<Integer, Integer> map = new TreeMap<>();
		List<Task> tasks = new  ArrayList<>();

		for (int i = 0; i < N; i++) {


			int A = s.nextInt();
			int B = s.nextInt();

			tasks.add(new Task(A, B));


			/*
			if(map.containsKey(B)) {
				map.put(B, map.get(B) + A);
			}else {
				map.put(B, A);
			}
			*/

		}

		tasks.sort(new Comparator<Task>() {
			@Override
			public int compare(Task o1, Task o2) {
				return o1.deadline - o2.deadline;
			}
		});


		int taskSum = 0;
		for(Task task : tasks) {
			taskSum += task.time;
			if(taskSum > task.deadline) {
				System.out.println("No");
				return;
			}
		}
		/*
		for(Map.Entry<Integer,Integer> entry: map.entrySet()) {

			System.out.println(entry);
			taskSum += entry.getValue();
			if(taskSum > entry.getKey()) {
				System.out.println("No");
				return;
			}
		}
		*/

		System.out.println("Yes");

	}



	/*
	public static int getMinIndex(int[] array, boolean[] isFinished ) {

		int min = Integer.MAX_VALUE;
		int minIndex = 0;
		for(int i = 0;i<array.length;i++) {

			if(isFinished[i]) continue;

			if(array[i] < min) {
				min = array[i];
				minIndex = i;
			}
		}

		return minIndex;

	}*/
}

class Task {
	int time;
	int deadline;
	public Task(int time, int deadline) {
		super();
		this.time = time;
		this.deadline = deadline;
	}



}


Measured memory_bytes: 103104
#include<bits/stdc++.h>
using namespace std;
main(){
int n,k,a=0;cin>>n>>k;
  vector<int> s(n);
  for(int i=0;i<n;i++)cin>>s.at(i);
  sort(s.rbegin(),s.rend());
  for(int i=0;i<k;i++)a+=s.at(i);
  cout<<a<<endl;
}

Measured memory_bytes: 256
<?php

class Answer
{
    private $N;
    private $numbers;
    private $flag;

    public function __construct()
    {
        $this->N = trim(fgets(STDIN));
        $number = trim(fgets(STDIN));
        $this->numbers = explode(" ", $number);
        $this->flag = 1;
    }

    public function doBubbleSort()
    {
        $N = $this->N;
        $numbers = $this->numbers;
        $flag = $this->flag;
        $i = 0;
        $count = 0;
        while ($flag) {
            $flag = 0;
            for ($j = $N - 1; $j > $i; $j--) {
                if ($numbers[$j - 1] > $numbers[$j]) {
                    list($numbers[$j - 1], $numbers[$j]) = [$numbers[$j], $numbers[$j - 1]];
                    $flag = 1;
                    $count++;
                }
            }
            $i++;
        }
        echo implode(' ', $numbers) . PHP_EOL;
        echo $count . PHP_EOL;
    }
}

$answer = new Answer();
$answer->doBubbleSort();



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  vector<int> indices = { 0, 0, 0 };
  int turn = 0;
  int winner = -1;
  while (true) {
    if (indices[turn] == (int)s[turn].size()) {
      winner = turn;
      break;
    }
    char ch = s[turn][indices[turn]++];
    if (ch == 'a') { turn = 0; }
    else if (ch == 'b') { turn = 1; }
    else if (ch == 'c') { turn = 2; }
  }
  vector<char> players = { 'A', 'B', 'C' };
  printf("%c\n", players[winner]);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	long long sum;
	if(k<=a)
	{
		cout<<k;
		return 0;
	}
	if(k>a&&a+b>=k)
	{
	cout<<a;
	return 0;			
	}	
	if(a+b+c>=k)
	{
	cout<<a-(k-a-b);
	return 0;		
	}
}

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


struct P{ double x, y; };
bool operator > (P x, P y)
{ return x.x > y.x || (x.x == y.x && x.y > y.x); }

double CalcArea(P a, P b, P c)
{
	double A = sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
	double B = sqrt(pow(b.x - c.x, 2.0) + pow(b.y - c.y, 2.0));
	double C = sqrt(pow(c.x - a.x, 2.0) + pow(c.y - a.y, 2.0));

	double s = (A + B + C) / 2;

	return sqrt(s * (s - A) * (s - B) * (s - C));
}


int main()
{
	while(true)
	{
		vector<P> v(4);

		rep(i, 4)
			if(!(cin >> v[i].x >> v[i].y))
				return 0;

		double s = CalcArea(v[0], v[1], v[2]), ss = CalcArea(v[0], v[1], v[3]) + CalcArea(v[0], v[3], v[2]) + CalcArea(v[3], v[1], v[2]);

		if(s - EPS <= ss && ss <= s + EPS)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        int scnt = 0;
        int tcnt = 0;
        for (int i = 0; i < x.length(); i++) {
            char c = x.charAt(i);
            if (c == 'T') {
                if (scnt <= 0) {
                    tcnt++;
                } else {
                    scnt--;
                }
            } else {
                scnt++;
            }
        }
        System.out.println(tcnt + scnt);
    }

}


Measured memory_bytes: 24496
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string ans = "Yes";
    int c[3][3];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
        cin >> c[i][j];
        }
    }

    

    if(c[0][0]-c[1][0]!=c[0][1]-c[1][1]||c[0][1]-c[1][1]!=c[0][2]-c[1][2]){
        ans = "No";
    }
    if(c[1][0]-c[2][0]!=c[1][1]-c[2][1]||c[1][1]-c[2][1]!=c[1][2]-c[2][2]){
        ans = "No";
    }
    cout << ans << endl;
}

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

#define MN 1001000

using namespace std;
typedef long long ll;

ll n, ans, a[MN], w, b;
char s[MN]; string str;

int main() {
    scanf("%lld %s", &n, s);
    str = s;

    for(int i = 0; i < n; i++) {
        w += (str[i] == '.');
    }

    ans = w;
    for(int i = 0; i < n; i++) {
        if(str[i] == '.') w--;
        else b++;
        ans = min(ans, w + b);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    ll x = a[0];
    for (int i = 1; i < n; i++) x ^= a[i];

    vector<ll> v(n);
    rep(i, n) {
        ll y = x ^ a[i];
        v[i] = y;
    }

    rep(i, n) {
        cout << v[i];
        if (i < n-1) cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>
int dx[]={-1, 0, 1, 0}, dy[]={0, -1, 0, 1};
int comp(const void* a, const void* b) { return *((int*)a)>*((int*)b); }
int main(void)
{
    int n;
    while (scanf("%d", &n), n) {
        int i, x[200]={0}, y[200]={0};
        for(i=1;i<n;++i) {
            int j, d;
            scanf("%d%d", &j, &d);
            x[i]=x[j]+dx[d];
            y[i]=y[j]+dy[d];
        }
        qsort(x, n, sizeof(int), comp);
        qsort(y, n, sizeof(int), comp);
        printf("%d %d\n", x[n-1]-x[0]+1, y[n-1]-y[0]+1);
    }
    return 0;
}

Measured memory_bytes: 604
N = int(input())

abc = [list(map(lambda x: int(x), input().split())) for _ in range(N)]

happy = [[0] * 3 for _ in range(N)]
for i in range(3):
	happy[0][i] = abc[0][i]

for i in range(1, N):
	happy[i][0] = max(happy[i - 1][1], happy[i - 1][2]) + abc[i][0]
	happy[i][1] = max(happy[i - 1][0], happy[i - 1][2]) + abc[i][1]
	happy[i][2] = max(happy[i - 1][0], happy[i - 1][1]) + abc[i][2]

print(max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2]))

Measured memory_bytes: 47380
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		int mod = 1000000007;

		int sum = 0;
		for (int i = K; i <= N + 1; i++) {
			var max = seqsum(N + 1 - i, N, i);
			var min = seqsum(0, i - 1, i);
			sum = Math.toIntExact((sum + (max - min) + 1) % mod);
		}
		System.out.println(sum);
	}

	long seqsum(int a, int l, long n) {
		return (a + l) * n / 2;
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 32688
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
#include <iostream>
#include <vector>
using namespace std;

int main(void){
   long long a,b;
   cin >> a >> b;
   if(a > 0){
       cout << "Positive" << endl;
   }else if(a == 0){
       cout << "Zero" << endl;
   }else{// a < 0
       if(b < 0){
           if((b - a + 1) % 2 == 0){
               cout << "Positive" << endl;
           }else{
               cout << "Negative" << endl;
           }
       }else{
           cout << "Zero" << endl;
       }
   }
    return 0;
}



Measured memory_bytes: 256
n,l=map(int,input().split())
a=list(map(int,input().split()))
mu=[0]*(n-1)
for i in range(n-1):
    mu[i]=a[i]+a[i+1]
if max(mu)<l:
    print("Impossible")
else:
    print("Possible")
    s=mu.index(max(mu))
    for i in range(1,s+1):
        print(i)
    for i in range(n-1,s,-1):
        print(i)

Measured memory_bytes: 14052
def main() -> None:
    S = input()
    T = input()
    flag = False
    for i in range(len(S)):
        if S == T:
            flag = True
            break
        S = S[-1] + S[:-1]
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;
int main(){
	int s;
char a[1001];
while(1){
	scanf("%s",a);
	if(a[0]=='0')break;
s=0;
for(int i=0;i<strlen(a);i++){
	s+=(a[i]-'0');
}
cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template <class T> int find_index(T x, const std::vector<T> &v) {
    auto it = std::find(v.begin(), v.end(), x);
    if (it != v.end()) { return (int)std::distance(v.begin(), it); }
    return -1;
}

template <class T> void print(T x) {
    std::cout << x << std::endl;
}

using namespace std;

// nまでの素数のリストを作成(nを含む) O(N log log N)
vector<bool> make_prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;

    vector<int> prime_list;
    for (int i = 2; i < n + 1; ++i) {
        if (!is_prime[i]) { continue; }
        //prime_list.emplace_back(i);

        for (int j = i + i; j < n + 1; j += i) {
            is_prime[j] = false;
        }
    }
    return is_prime;
}


class CumulativeSum {
public:
    vector<int> dp;
    CumulativeSum(vector<int> l) {
        this->dp = vector<int>(l.size() + 1, 0);
        for (int i = 0; i < l.size(); ++i) {
            this->dp[i + 1] = this->dp[i] + l[i];
        }
    }

    // return sum(l[left, right])
    long long total(int left, int right) {
        assert(0 <= left && left <= right && right < this->dp.size());
        return this->dp[right + 1] - this->dp[left];
    }
};

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);


    VB prime_list = make_prime_list(100000 + 10);
    VI memo(100000 + 10, 0);
    FOR(i, 0, 100001) {
        if (prime_list[i] && prime_list[(i + 1) / 2]) {
            memo[i] = 1;
        }
    }

    CumulativeSum cs(memo);

    LL Q;
    cin >> Q;
    FOR(_, 0, Q) {
        int l, r;
        cin >> l >> r;
        print(cs.total(l, r));
    }

    return 0;
}

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

int main(){
    int N,M,C,total,count;
    cin >> N >> M >> C;
    int b[M]={};
    int a[N][M]={};
  	count = 0;
    total = 0;
    for(int i = 0; i < M; i++){
    	cin >> b[i];	
      	
    }
    for(int j = 0;j<N;j++){
        for(int i=0;i<M;i++){
            
            cin >> a[j][i];
          	//cout << a[j][i];;
        }
     	//cout << "" << endl;
    }
    for(int k = 0; k < N ;k++){
      	total = 0;
        for(int h = 0;h < M;h++){
            total += a[k][h]*b[h];
            //cout << total ;
          	
        }
      	
      	//cout << ""<<endl;
      	if( total + C >0)count++;

    }
    cout << count << endl;
}

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

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    
    if(k <= a){cout << k;}
    else if(k <= a + b)
    {
        cout << a;
    }
    else if(k > a + b )
    {
       int sum = a;
       k = k - (a + b);
       sum  = sum - k;
       cout << sum;
    }
    else {cout << 0;}


    return 0;
}

Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func intAbs(x int) int {
	return int(math.Abs(float64(x)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := scanInt(), scanInt()
	X := make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = scanInt()
	}

	ans := int(math.Pow10(9))
	for i := K - 1; i < N; i++ {
		if X[i]*X[i+1-K] >= 0 {
			ans = intMin(ans, intMax(intAbs(X[i]), intAbs(X[i+1-K])))
		} else {
			ans = intMin(ans, X[i]*2-X[i+1-K])
			ans = intMin(ans, X[i+1-K]*(-2)+X[i])
		}
	}
	fmt.Println(ans)
}


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

stock_left = 0
num_new_l = 0
for i in range(n):
    if s[i] == '(':
        stock_left += 1
    else:
        if stock_left > 0:
            stock_left -= 1
        else:
            num_new_l += 1

stock_right = 0
num_new_r = 0
for i in range(-1,-n-1,-1):
    if s[i] == ')':
        stock_right += 1
    else:
        if stock_right > 0:
            stock_right -= 1
        else:
            num_new_r += 1

new_l = '(' * num_new_l
new_r = ')' * num_new_r
print(new_l + s + new_r)

Measured memory_bytes: 3064
n,k=map(int,input().split())
s=list(input())
li=[]
if s[0]=="0":
  a=0
  s.insert(0,"p")
  len_s=len(s)
  for i in range (1,len_s):
    if s[i-1]==s[i]:
      a=a+1
    else:
      li.append(a)
      a=1
  li.append(a)
  if s[n-1]=="0":
    li.append(0)
else:
  a=1
  len_s=len(s)
  for j in range (1,len_s):
    if s[j-1]==s[j]:
      a=a+1
    else:
      li.append(a)
      a=1
  li.append(a)
  if s[n-1]=="0":
    li.append(0)
len_li=len(li)
lis=[0]
t=0
for l in range (0,len_li):
  t=t+li[l]
  lis.append(t)
if 2*k+1>=len_li:
  print(n)
elif k==0:
  import math
  o=math.ceil(len_li/2)
  le=[]
  for f in range (0,o):
    le.append(li[2*f])
    le.sort()
  print(le[len(le)-1])
else:
  import math
  u=0
  w=0
  while w<=len(lis)-2*k-2:
    d=lis[w+2*k+1]-lis[w]
    if u<=d:
      u=d
    w=w+2
  print(u)

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

string operator*(string str, size_t n) {
  string result = "";
  rep(i, n){
  	result += str;
  }
  return result;
}


int main() {
  int a, b, cnt = 0;
  string s, rev;
  cin >> a >> b;
  range(i, a, b+1){
    s = to_string(i);
    rev = s;
    reverse(rev.begin(), rev.end());
    if (s == rev) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3648
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(f,n) for(int i=f;i<f+n;i++)
#define rforn(l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i];
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1005;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////



int main()
{
	vi A(3);
	take(A,0,3);
	sort(all(A));
	if((A[0]==A[1]&&A[0]!=A[2])||(A[1]==A[2]&&A[1]!=A[0]))
	{
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}		

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi ans(10005, 0);
    FOR(x, 1, 100) FOR(y, 1, 100) FOR(z, 1, 100) {
        int n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n > 10001) continue;
        ans[n]++;
    }

    REP(i, N) {
        cout << ans[i+1] << endl;
    }

    return 0;
}


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  rep(i, n) std::cin >> a[i];
  std::vector<int64_t> b;

  rep(i, n) {
    if (n % 2 == 0) {
      if (i % 2 == 0) {
        b.insert(b.end(), a[i]);
      } else {
        b.insert(b.begin(), a[i]);
      }
    } else {
      if (i % 2 != 0) {
        b.insert(b.end(), a[i]);
      } else {
        b.insert(b.begin(), a[i]);
      }
    }
  }

  rep(i, n) {
    if (i != 0) {
      std::cout << " ";
    }
    std::cout << b[i];
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N];
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; ++i <= n;) cin >> a[i];
    long long s1 = 0, s2 = 0;
    for (int i = 1; i <= n; i++) if (a[i] % 2) s1 += a[i]; else s2 += a[i];
    if (s1 % 2 != s2 % 2) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 1148
def solve():
  N, M = map(int, input().split())
  DP = [float('inf')] * (2 ** N)
  DP[0] = 0

  for i in range(M):
    A, B = map(int, input().split())
    keys = sum(1 << (int(i) - 1) for i in input().split())
    for j in range(2 ** N): DP[j | keys] = min(DP[j | keys], DP[j] + A)
  return DP[-1] if DP[-1] != float('inf') else -1

print(solve())


Measured memory_bytes: 3188
s = input()
k = int(input())
if len(set(list(s))) ==1:
    print((len(s)*k)//2)
    exit()
t=[1]
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        t[-1]+=1
    else:
        t.append(1)
a=0
for i in t:
    a+=(i//2)*k
if s[0]==s[-1]:
    if t[0]%2 == t[-1]%2 ==1:
        a += k-1
print(a)

Measured memory_bytes: 3064
N, M, X, Y = map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))

if max(x)<min(y):
  for i in range(max(x)+1,min(y)+1):
    if i>X and i<=Y:
      print('No War')
      break
  else:
    print('War')
else:
  print('War')

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n, m, ans;

int main() {
	ios::sync_with_stdio(0);
	cin >> m >> n;
	cont (i, n) {
		int a;
		cin >> a;
		ans += a;
	}
	cout << (ans < m ? "No" : "Yes") << ln;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
stp = 0
for i in range(N-1,0,-1):
    if H[i]+1 == H[i-1]:
        H[i-1] -= 1
    elif H[i] >= H[i-1]:
        pass
    else:
        stp += 1
        print("No")
        break
if stp == 0:
    print("Yes")

Measured memory_bytes: 63856
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    bool arr[105];
    memset(arr, false, sizeof(arr));
    while (t--)
    {
        int n, x;
        cin >> x >> n;
        int p;
        for (int i = 0; i < n; ++i)
        {
            cin >> p;
            arr[p] = 1;
        }
        int l = x;
        int r = x;
        while (1)
        {
            if (!arr[l])
            {
                cout << l << "\n";
                return 0;
            }

            if (!arr[r])
            {
                cout << r << "\n";
                return 0;
            }
            l--;
            r++;
        }
        //    cout << a[idx] << "\n";
    }
}

Measured memory_bytes: 3644
MOD = 10 ** 9 + 7

n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
bit = a.max.to_s(2).length
ans = 0
num1 = Array.new(bit,0)

a.each do |a|
  bit.times do |i|
    num1[i] += a[i]
  end
end

bit.times do |i|
  ans += num1[i] * (n-num1[i]) * (2 ** i)
end

puts ans % MOD


Measured memory_bytes: 42372
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; ll k; cin >> n >> k;
	vector<ll> a(n),f(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> f[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(f.begin(),f.end());
	vector<pair<ll,ll> > v(n);
	for(int i=0;i<n;i++){
		v[i]=make_pair(a[i]*f[i],f[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll left=-1; ll right=1e12;
	while(right-left>1){
		ll mid=(left+right)/2;
		ll sum=0;
		for(int i=0;i<n;i++){
			if(v[i].first>mid){
				sum+=(v[i].first-mid+v[i].second-1)/v[i].second;
			}
			else{
				break;
			}
		}
		if(sum<=k){
			right=mid;
		}
		else{
			left=mid;
		}
	}
	cout << right << endl;
}

Measured memory_bytes: 6528
X = int(input())
items = list(range(100, 106))
dp = [0 for _ in range(0, X+1)]
dp[0] = 1

for i in range(0, len(dp)):
  for j in items:
    if i+j <= len(dp)-1 and dp[i] > 0:
      dp[i+j] += 1
      if i+j == X:
        print('1')
        exit()

print('0')


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int r,d,x;
    cin>>r>>d>>x;
    f1(i,0,10)
    {
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            var total = 0;
            for (var i = 1; i <= X; i++)
            {
                total += i;
                if (total >= X)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

q1 = sum(1 for i in P if i <= A)
q2 = sum(1 for j in P if (j > A and j <= B))
q3 = sum(1 for k in P if k > B)

print(min([q1, q2, q3]))


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean hasOdd = false;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if(a % 2 != 0){
                hasOdd = true;
                break;
            }
        }
        System.out.println(hasOdd ? "first" : "second");
        sc.close();

    }

}


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

int main(void)
{
        int i,n,a[26];
        char s[100000];
        scanf("%s",s);

        for(i=0;i<26;i++)
                a[i]=0;

        n=strlen(s);
        for(i=0;i<n;i++){
                a[s[i]-'a']++;
        }
        for(i=0;i<26;i++){
                if(a[i]==0){
                        printf("%c\n",i+'a');
                        return 0;
                }
        }
        printf("None\n");
        return 0;
}


Measured memory_bytes: 1784
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

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


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

    ll ans[10001];
    REP(i, 10000){
        ans[i] = 0;
    }
    ll x, y, z;
    ll sum;
    REP(x, 141){
        REP(y, 141 - x){
            REP(z, 141 - x){
                sum = x * x + y * y + z * z + x * y + y * z + z * x;
                if(sum <= 10000){
                    ans[sum]++;
                }
            }
        }
    }

    REP(i, N){
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 100 + 10;
int a[maxn], n, sum = 0, ans;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], sum += a[i];
	ans = sum;
	for (int i = 0; i < n; i++)
		ans = min(ans, abs((sum -= 2 * a[i])));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

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

    int N, C; cin >> N >> C;
    int time_max = 100000;
    vector<vector<bool>> vCN(C, vector<bool>(2*time_max, false));
    
    for(int n=0; n<N; ++n){
        int s, t, c; cin >> s >> t >> c; --s; --t; --c;
        for(int i=max(0, s*2-1); i<t*2; ++i){
            vCN[c][i] = true;
        }
    }
    
    int num = 0;
    for(int n=0; n<2*time_max; ++n){
        int num_tmp = 0;
        for(int i=0; i<C; ++i){
            if(vCN[i][n]){ ++num_tmp; }
        }
        num = max(num, num_tmp);
    }
    
    cout << num << endl;
    
    return 0;
}

Measured memory_bytes: 3988
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, K = map(int, input().split())

ans = 0
# 桁数だけわかればいいので割った回数をカウント
while N:
  ans += 1
  N //= K
print(ans)  

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

int a[100];
int main(){
	int n,sum = 0;
	int min = 101;
	
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum+=a[i];
		if(a[i]%10&&a[i]<min) min = a[i];
	}
	if(sum%10) cout << sum;
	else if(min!=101) cout << sum-min;
	else cout << 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

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

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

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓


long double L, ans, n;



int main() {
	cin >> L;
	n = L / 3;
	cout << setprecision(10) << n * n * n << endl;


	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char enki;

    scanf("%c", &enki);

    switch(enki){
        case 'A':
        case 'T':
            if(enki == 'A'){
                printf("T\n");
            }
            else{
                printf("A\n");
            }
            break;
        case 'C':
        case 'G':
            if(enki == 'C'){
                printf("G\n");
            }
            else{
                printf("C\n");
            }
            break;
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>


int main(int argc , char *argv[])
{
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);
  if(a < b){
    if(b < c){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");

  return 0;
}



Measured memory_bytes: 2060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int n = 0;
        for (int i = 1;i <=a; i++) {
            for (int j = 1; j <= b; j++) {
                int p = j%10;
                int q = j/10;
                if(p>=2 && q>=2){
                if (p*q==i) {
                    n++;
                }}
            }
        }
        System.out.println(n);
    }

}


Measured memory_bytes: 21972