akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var str = ReadLine();
        var left = 0;
        var res = "";
        for(var i = 0; i < num; i++)
        {
            if(str[i]==')')
            {
                if (left > 0)
                    left--;
                else
                    res = "(" + res;
                res += ")";
            }
            else
            {
                left++;
                res += "(";
            }
        }
        for (var i = 0; i < left; i++)
            res += ")";
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

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

    std::vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    // dp[type][i]: max happiness on day i. do type on day i.
    std::vector<std::vector<int>> dp(3, std::vector<int>(n));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < n; ++i) {
        dp[0][i] = a[i] + std::max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = b[i] + std::max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = c[i] + std::max(dp[0][i - 1], dp[1][i - 1]);
    }

    int ans = std::max(dp[0][n - 1], std::max(dp[1][n - 1], dp[2][n - 1]));
    std::cout << ans << "\n";
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

#define ll long long
#define endl endl
using namespace std;

const int INF = 0x3f3f3f3f;
int arr[200001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = max(a, b);
    if(a > b) a--;
    else b--;
    ans += max(a, b);
    cout << ans;


}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

bool isAllVisit(const vector<bool>& visit) {
    for (auto&& v : visit) {
        if (!v)return false;
    }
    return true;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}


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

    string S;
    cin >> S;

    const string arr[]{ "dream","dreamer","erase","eraser" };

    bool can = true;
    while (!S.empty()) {
        bool erased = false;
        REP(i, 4) {
            if (S.length() - arr[i].length() < 0)continue;
            int pos = S.rfind(arr[i], S.length() - arr[i].length());
            if (pos == S.length() - arr[i].length()) {
                S = S.substr(0, S.length() - arr[i].length());
                erased = true;
                continue;
            }
        }
        if (!erased) {
            can = false;
            break;
        }
    }

    YESNO(can, "YES", "NO");
    return 0;
}

Measured memory_bytes: 512
W,H,x,y,r = map(int,input().split())
if(x - r < 0 or x + r > W): #横にはみ出る場合
    print("No")
elif(y - r < 0 or y + r > H): #縦にはみ出る場合
    print("No")
else:
    print("Yes")    


Measured memory_bytes: 5596
n, k = map(int, input().split())
X = list(map(int, input().split()))

neg = []
pos = []
for i in range(n):
    if X[i] < 0:
        neg.append(X[i])
    else:
        pos.append(X[i])

ans = 10**18
neg.sort(reverse=True)
pos.sort()
for a in range(len(neg)+1):
    b = k - a
    if b < 0 or b > len(pos):
        continue
    else:
        if a == 0:
            ans = min(ans, pos[b-1])
        elif b == 0:
            ans = min(ans, abs(neg[a-1]))
        else:
            ans = min(ans, min(2*abs(neg[a-1])+pos[b-1], 2*pos[b-1]+abs(neg[a-1])))
print(ans)


Measured memory_bytes: 63128
use proconio::input;

fn main() {
    input! {
        mut n: i128,
    }
    let mut name = Vec::new();
    loop {
        let mut number = n % 26;
        if number == 0 {
            number = 26;
            n = n / 26 - 1;
        } else {
            n = n / 26;
        }
        name.push(number);

        if n <= 0 { break }
    }
    for c in (0..name.len()).rev() {
        print!("{}", decoder(name[c]))
    }
    println!("");
}

fn decoder(input: i128) -> char {
    let a = 'a' as u8;
    (a - 1 + input as u8) as char
}

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

typedef struct treeNode{
  int key;
  struct treeNode *p;
  struct treeNode *left;
  struct treeNode *right;
}Node;

void printPreorder(Node *);
void printInorder(Node *);
Node * insert(Node *, Node *);
int find(Node *, int);


int main(){
  Node *T = NULL;
  int m, i, j=0, l, root, k;
  Node *temp;
  char s[7];

  scanf("%d", &m);

  for(i=0; i<m; i++){
    scanf("%s", s);

    if(s[0] == 'i'){
      temp = malloc(sizeof(Node));
      scanf("%d", &(temp->key));
      temp->left = NULL;
      temp->right = NULL;
      T = insert(T, temp);
      //printf("T->key = %d\n", T->key);
    }else if(s[0] == 'p'){
      //printf("ok\n");
      printInorder(T);
      printf("\n");
      printPreorder(T);
      printf("\n");
    }else{
      scanf("%d", &k);
      if(find(T, k)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }
  }
  
  return 0;
}

void printPreorder(Node *N){
  printf(" %d", N->key);

  if(N->left != NULL){
    printPreorder(N->left);
  }

  if(N->right != NULL){
    printPreorder(N->right);
  }

}

void printInorder(Node *N){

  if(N->left != NULL){
    printInorder(N->left);
  }

  printf(" %d", N->key);

  if(N->right != NULL){
    printInorder(N->right);
  }

}

Node * insert(Node *T, Node *z){
  Node *x, *y;

  y = NULL; // xの親
  x = T;

  while(x != NULL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->p = y;
  
  if( y == NULL){
    T = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }

  return T;

}

int find(Node *T, int k){
  while(T != NULL && k != T->key){
    if(k < T->key){
      T = T->left;
    }else{
      T = T->right;
    }
  }
  if(T == NULL) return 0;
  if(T->key == k) return 1;
}

Measured memory_bytes: 19360
/**
 *   Author:  Shahbib Ayman Shabib
 *   FROM RMSTU
**/
#include <bits/stdc++.h>
#define ll                      long long
#define Fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(d,min3(a,b,c))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(d,max3(a,b,c))
#define sob(v)                  v.begin(),v.end()
#define recall(v)               v.rbegin(),v.rend()
#define pb                      push_back
#define eb                      emplace_back
#define setbits(x)              __builtin_popcountll(x)
#define zrobits(x)              __builtin_ctzll(x)
#define scf(x)                  scanf("%d", &x)
#define scf2(x, y)              scanf("%d %d", &x, &y)
#define scf3(x, y, z)           scanf("%d %d %d", &x, &y, &z)
#define scff4(p,x, y, z)        scanf("%d %d %d %d",&p, &x, &y, &z)
#define scfll(x)                scanf("%lld", &x)
#define scsfll2(x, y)           scanf("%lld %lld", &x, &y)
#define scfll3(x, y, z)         scanf("%lld %lld %lld", &x, &y, &z)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define prnt                    cout << endl
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                (a)*(b)/gcd(a,b)
using namespace std;
/*************************************
*          A S S E M B L E         *
**************************************/
bool isPrime(ll n){if(n <= 1)return false;for (ll i = 2; i * i < n; i++)if (n % i == 0)return false;return true;}
ll fact(ll n){ll res = 1;for(ll i = n;i>=1;i--)res *= i;return res;}
ll nCr(ll n,ll r){return (fact(n)/(fact(r)*fact(n-r)));}
ll nPr(ll n,ll r){return fact(n)/fact(n-r);}
ll modpow(ll a, ll n, ll mod){ll res=1;while(n>0){if(n&1) res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
#define mod 100000009
inline int add(int a,int b){if((a+=b)>=mod)a-=mod;return a;}
inline int dec(int a,int b){if((a-=b)<0)a+=mod;return a;}
inline int mult(int a,int b){long long t=1ll*a*b;if(t>=mod)t%=mod;return t;}
inline int power(int a,int b){int out=1;while(b){if(b&1)out=mult(out,a);a=mult(a,a);b>>=1;}return out;}
vector<ll> primes;
bool prime[mod];
void sieve(){
    memset(prime,true,sizeof(prime));
    prime[0] = prime[1] = false;
    primes.pb(2);
    for(ll i = 4;i<=mod;i+=2)
        prime[i] = false;
    for(ll i = 3;i<=mod;i+=2){
        if(prime[i] == true){
                primes.pb(i);
            for(ll j = i*2;j<=mod;j+=i)
                prime[j] = false;
        }
    }
}

/*************************************
*  E N D    G A M E   S T A R T S    *
**************************************/
int main()
{
	int n, k;
	cin >> n >> k;
	cout << min(1,n % k) << endl;

	return 0;


  cout << "No" << endl;
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <limits.h>
#define MAX 100
#define INFTY INT_MAX - 1
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

/* Global Variables */
int AM[MAX][MAX]; //Adjacency Matrix
int color[MAX];
int d[MAX], pi[MAX];
int n;

/* Prim's Algorithm */
int prim(int r) {
  int i, u, v;
  int mincost, sum = 0;
  for ( u = 0; u < n; u++ ) {
    color[u] = WHITE;
    d[u] = INFTY;
    pi[u] = NIL;
  }
  d[r] = 0;

  while ( 1 ) {
    mincost = INFTY;
    for ( i = 0; i < n; i++ ) {
      if ( color[i] != BLACK && d[i] < mincost ) {
        mincost = d[i];
        u = i;
      }
    }

    if ( mincost == INFTY ) break;

    color[u] = BLACK;

    for ( v = 0; v < n; v++ ) {
      if ( color[v] != BLACK && AM[u][v] != INFTY ) {
        if ( AM[u][v] < d[v] ) {
          d[v] = AM[u][v];
          pi[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }

  for ( i = 0; i < n; i++ )
    if ( pi[i] != NIL )
      sum += AM[i][pi[i]];

  return sum;
}

/* Main */
int main() {
  int i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    for ( j = 0; j < n; j++ ) {
      scanf("%d", &AM[i][j]);
    }
  }

  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ )
      if ( AM[i][j] == -1 )
	AM[i][j] = INFTY;

  //Find The Minimum Spanning Tree by Prim's Algorithm
  printf("%d\n", prim(0));

  return 0;
}

Measured memory_bytes: 640
# 座標Xは黒　K個の意思が連続で黒で塗られてる
K, X = list(map(int, input().split()))

l = [n for n in range(X, X + K)]
l += [n for n in range(X - (K-1), X+1)]

l = sorted(list(set(l)))

l = list(map(str, l))
print(" ".join(l))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;


int main() {
    ll N;
    cin >> N;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll tmp = -1;
    ll num = 0;
    REP(i, 0, N) {
        if (A[i] != tmp) {
            num++;
            tmp = A[i];
        }
    }
    ll aa[2][num];
    REP(i, 0, 2) {
        fill(aa[i], aa[i] + num, 0);
    }
    ll tmpb = -1;
    ll numb = -1;
    REP(i, 0, N) {
        if (A[i] != tmpb) {
            numb++;
            tmpb = A[i];
            aa[0][numb] = A[i];
            aa[1][numb] = 1;
        } else {
            aa[1][numb]++;
        }
    }
    // REP(i, 0, 2) {
    //     REP(j, 0, num) {
    //         cout << aa[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = 0;
    PER(i, num - 1, -1) {
        ll a = aa[0][i];
        PER(j, 32, -1) {
            ll p = ((ll)1 << j) - a;
            ll idlo = lower_bound(aa[0], aa[0] + num, p) - aa[0];
            ll idhi = upper_bound(aa[0], aa[0] + num, p) - aa[0];
            if (idlo != idhi && a != p) {
                ll q = min(aa[1][i], aa[1][idlo]);
                ans += q;
                aa[1][i] -= q;
                aa[1][idlo] -= q;
            }
        }
    }
    REP(i, 0, 32) {
        ll a = (ll)1 << i;
        ll idlo = lower_bound(aa[0], aa[0] + num, a) - aa[0];
        ll idhi = upper_bound(aa[0], aa[0] + num, a) - aa[0];
        if (idlo != idhi) {
            ans += aa[1][idlo] / 2;
        }
    }
    cout << ans << endl;
}


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

int N,M,V,P;
int A[100005],S;
bool cmp(int a,int b){return a>b;}

bool check(int i){
	if(i<=P) return 1;
	if(A[i]+M<A[P]) return 0;
	if(V<=P+N-i) return 1;
	return ((V-P-N+i)*M-S-1)/(i-P)<=A[i]+M-A[P]-1;
}

int ans;

signed main(){
	scanf("%d%d%d%d",&N,&M,&V,&P);
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	sort(A+1,A+N+1,cmp);
	for(int i=P+1;i<=N;i++){
		if(check(i)) ans++;
		S+=A[P]-A[i];
	}
	printf("%d\n",ans+P);
	check(N);
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ( (a*b) % 2 && (c+d)%2 ) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 3216
A,B,M = list(map(int, input().split()))
AP = list(map(int, input().split()))
BP = list(map(int, input().split()))
MC = list(input().split() for i in range(M))

#商品券なしパターン
TPX = min(AP)+min(BP)

#商品券ありパターン
TPY = 0
for i in range(M):
    TPZ = AP[int(MC[i][0])-1] + BP[int(MC[i][1])-1] - int(MC[i][2])
    if i == 0:
        TPY = TPZ
    else:
        if TPZ < TPY:
            TPY = TPZ
print(min(TPX,TPY))

Measured memory_bytes: 46252
N = int(input())
A = [int(x) for x in input().split()]
C = [0] * (10 ** 5 + 1)
for a in A:
  C[a] += 1
cnt = 0
for i in range(1, 10 ** 5):
  cnt = max(C[i - 1] + C[i] + C[i + 1], cnt)
print(cnt)

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

using namespace std;

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

    long long note[n+1];
    for(int i = 0; i <= n; i++) note[i] = 0;

    long long calc;
    for(int x = 1; x < n; x++) {
        calc = x*x + 3 + 2*x;
        if(calc > n) break;
        for(int y = 1; y < n; y++) {
            calc = x*x + y*y + 1 + x*y + y + x;
            if(calc > n) break;
            for(int z = 1; z < n; z++) {
                calc = x*x + y*y + z*z + x*y + y*z + z*x;
                if(calc > n) break;
                note[calc]++;
            }
        }
    }

    for(int i = 1; i < n+1; i++) {
        cout << note[i] << endl;
    }
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        sc.close();

        for (int i = -119; i < 119; i++) {
            for (int j = -119; j < 119; j++) {
                if (Math.pow(i, 5) - Math.pow(j, 5) == X) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int cnt=0;
    rep(i,a+1){
        if(i*500>x) break;
        rep(j,b+1){
            if(i*500+j*100>x) break;
            rep(k,c+1){
                if(i*500+j*100+k*50>x) break;
                if(i*500+j*100+k*50==x) cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll maxv = 0;
  rep(i, n) {
    cin >> a[i];
    chmax(maxv, a[i]);
  }

  
  ll g = a[0];
  rep(i, n) {
    g = gcd(g, a[i]);
  }

  if (k % g || maxv < k) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << "POSSIBLE" << endl;
  }

}

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

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)  return 0;
        int result = INT_MIN/2;
        int tmp = INT_MIN/2;
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            tmp = max(tmp + a, a);
            result = max(result, tmp);
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    long N;
    cin >> N;
    long pow = 1;
    long ten = 1;
    for(long i = 1; i < 10; i++){
        ten = ten * 10;
    }
    for(long i = 0; i < N; i++){
        pow = (pow * (i + 1)) % (ten + 7);
    }
    cout << pow << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfLargeNumbers solver = new DSumOfLargeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfLargeNumbers {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            long min = 0;
            long max = 0;
            long ans = 0;
            for (int i = 0; i < n + 1; i++) {
                min += i;
                max += n - i;
                if (max < min)
                    break;
                if (i + 1 >= m)
                    ans += max - min + 1;
                ans %= (int) 1e9 + 7;
            }
            pw.println(ans);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32972
#include <stdio.h>

int main()
{
	int n,i,j,key,t;
	int a[100];
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	
	for(t=0;t<n-1;t++)
	printf("%d ",a[t]);
	printf("%d",a[n-1]);
	putchar('\n');
	for(i=1;i<n;i++)
	{
		key = a[i];
		for(j=i;j>0;j--){
		if(key<a[j-1]) {a[j] = a[j-1];a[j-1] = key;}
		}
		for(t=0;t<n-1;t++)
		printf("%d ",a[t]);
		printf("%d",a[n-1]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>

using namespace std;
#define MAX(x,y) ((x>y)?x:y)

int comp(const void *p,const void *q){
	return *(int *)p-*(int *)q;
}
int x[105],y[105],d[105];
int sx[105],sy[105],sd[105];
int c[105][105][105];
int main(){
	int i,j,k,l,n,K;
	int xn,yn,dn;
	long long ans;
	
	scanf("%d%d",&n,&K);
	for(i=0;i<n;i++)scanf("%d%d%d%d%d%d",&x[i*2],&y[i*2],&d[i*2],&x[i*2+1],&y[i*2+1],&d[i*2+1]);
	memcpy(sx,x,sizeof(int)*n*2);
	memcpy(sy,y,sizeof(int)*n*2);
	memcpy(sd,d,sizeof(int)*n*2);
	
	qsort(sx,n*2,sizeof(int),comp);
	qsort(sy,n*2,sizeof(int),comp);
	qsort(sd,n*2,sizeof(int),comp);
	
	xn=yn=dn=1;
	for(i=1;i<n*2;i++)if(sx[i]!=sx[i-1])sx[xn++]=sx[i];
	for(i=1;i<n*2;i++)if(sy[i]!=sy[i-1])sy[yn++]=sy[i];
	for(i=1;i<n*2;i++)if(sd[i]!=sd[i-1])sd[dn++]=sd[i];
	/*
	for(i=0;i<xn;i++)printf("%3d ",sx[i]);printf("\n");
	for(i=0;i<yn;i++)printf("%3d ",sy[i]);printf("\n");
	for(i=0;i<dn;i++)printf("%3d ",sd[i]);printf("\n");
	*/
	memset(c,0,sizeof(c));
	for(i=0;i<n*2;i++){
		x[i]=lower_bound(sx,sx+xn,x[i])-sx;
		y[i]=lower_bound(sy,sy+yn,y[i])-sy;
		d[i]=lower_bound(sd,sd+dn,d[i])-sd;
		//printf("%d %d %d\n",x[i],y[i],d[i]);
		if(i%2==1){
			for(j=x[i-1];j<x[i];j++)
				for(k=y[i-1];k<y[i];k++)
					for(l=d[i-1];l<d[i];l++)c[j][k][l]++;
		}
	}
	ans=0;
	for(i=0;i<xn-1;i++)for(j=0;j<yn-1;j++)for(k=0;k<dn-1;k++){
		if(c[i][j][k]>=K)ans+=(long long)(sx[i+1]-sx[i])*
							  (long long)(sy[j+1]-sy[j])*
							  (long long)(sd[k+1]-sd[k]);
	}
	printf("%lld\n",ans);
	
	
	return 0;
}

Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  
  int x;
  rep(i,n){
    if(i == 0){
      cin >> a[i];
      x = a[i];
    }else{
      cin >> a[i];
      x ^= a[i];
    }
  }
  rep(i,n){
    cout << to_string(a[i]^x) << " ";
  }
  cout << endl;
  return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    ll n;
    cin >> n;
    if(n%2 == 0){
        cout << n << endl;
    }else{
        cout << n*2 << endl;
    }
	return 0;
}



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

int main() {
	int N; string S; bool t = true; cin >> N >> S;
	if (N % 2 == 1) t = false;
	else for (int i = 0; i < (N / 2); i++) {
		if (S[i] != S[(N / 2) + i]) {
			t = false;
			break;
		}
	}
		if (t) cout << "Yes"; 
		else cout << "No";
		cout << endl;
}

Measured memory_bytes: 3572
import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

a, b = map(int, read().split())
f= fractions.gcd(a,b)
f_ = a *b // f
 
print(f_)


Measured memory_bytes: 5052
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
if W==1:
    tmp=0
    for a in A:
        tmp+=1
        for j in range(a):
            print(tmp)
    quit()
G=[[0]*W for i in range(H)]
i=0
j=0
tmp=0
t=1
for a in A:
    tmp+=1
    for k in range(a):
        G[i][j]=tmp
        if j==W-1:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=-1
                t=0
        elif j==0:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=1
                t=0
        j+=dx
for k in G:
    print(*k,sep=" ")


Measured memory_bytes: 42096
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int sum=0;
    bool flag=true;
    while(n--){

        char type;int num;
        cin>>type>>num;
        if(type=='(')sum+=num;
        else sum-=num;

        if(sum<0)flag=false;
    }
    if(sum!=0)flag=false;

    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

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

  int S1, S2, S3;
  S1 = S / 100; 
  S2 = (S % 100) / 10;
  S3 = S % 10;
    
  cout << S1 + S2 + S3 << endl;

}
  
 

Measured memory_bytes: 3608
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 22 August 2020 05:38:40 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;

    vector < int > v(n);

    for(int i=0; i<n; ++i){
        cin>>v[i];
    }
    
    int ans=0;
    for(int i=1; i<n; ++i){
        if(v[i]>v[i-1]){
            continue;
        }
        ans += (v[i-1]-v[i]);
        v[i] = v[i-1];
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,h,a[N];
ll sum;
int main()
{
	scanf("%d%d",&n,&h);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<=n-h;i++) sum+=(ll)a[i];
	printf("%lld\n",sum);
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
  	double x;
    string u;
  	ll ansl = 0;
  	double ansd = 0;
  	rep(i,n) {
      	cin >> x >> u;
    	if(u=="BTC") ansd += 380000*x;
      	else if(u=="JPY") ansl += x;
    }
	cout << ansd + ansl << endl;
  	return;
}

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

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cnt = 0
for i in range(n):
  a=list(map(int,input().split()))
  p=c
  for j in range(m):
    p+=a[j]*b[j]
  if p>0:
    cnt += 1
print(cnt)

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int count=0;
  int tmp=1;
  
  while(tmp < b) {
    tmp+=(a-1);
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
ab = list()
for _ in range(n):
    ab.append(na())

ab.sort(key=lambda x:x[1])
time = 0
for ai, bi in ab:
    time += ai
    if time > bi:
        print("No")
        quit()
print("Yes")


Measured memory_bytes: 53732
/* 
   AOJ 2012
   Space Coconut Grab
   2015/7/24
*/

#include<stdio.h>
#define ENERGY_MAX 1000000

int calc_m(int energy)
{
  int x = 0, y = 0, z = 0, min = energy, cnt = 0, i;
  /* for(z = 0; z * z * z <= energy; z++); */
  /* z--; */
  for(z = 0; z * z * z <= energy; z++)
    {
      for(y = 0; y * y <= energy - z * z * z; y++)
	{
	  x = energy - z * z * z - y * y;
	  if(min > x + y + z)
	    {
	      min = x + y + z;
	    }
	}
    }
    
  //printf("--->cnt = %d\n", cnt);
  return min;
}

int main(void)
{
  int energy, m;
  while(1)
    {
      scanf("%d", &energy);
      if(energy == 0)
	{
	  break;
	}
      m = calc_m(energy);
      printf("%d\n", m);
    }
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    double sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sum/=n;
    int ans=0;
    rep(i,n){
        ans+=(a[i]-round(sum))*(a[i]-round(sum));
    }
    cout<<ans<<endl;
    return 0;
}

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

int N;

void mk_one(int zc,int oc){
  if( zc%2 == 0 ){//0 is even
    for(int i=0;i<zc;i++) cout << 0 << endl;
    for(int i=0;i<oc;i++) cout << 1 << endl;
  } else {// 0 is odd
    for(int i=0;i<zc-1;i++) cout << 0 << endl;
    if( oc-- ) cout << 1 << endl;
    cout << 0 << endl;
    for(int i=0;i<oc;i++) cout << 1 << endl;
  }
}

void mk_one2(int zc,int oc,int a){
  if( zc%2 == 0 ){//0 is even
    for(int i=0;i<zc;i++) cout << 0 << endl;
    for(int i=0;i<oc;i++) cout << 1 << endl;
    cout << a << endl;
  } else {// 0 is odd
    for(int i=0;i<zc-1;i++) cout << 0 << endl;
    bool f = false;
    if( oc == 0 ){
      cout << a << endl;
      f = true;
    } else{
      cout << 1 << endl;
      oc--;
    }
    cout << 0 << endl;
    for(int i=0;i<oc;i++) cout << 1 << endl;
    if( !f ) cout << a << endl;
  }
}

void mk_A(int zc,int oc,const vector<int>& A){
  cout << A[0] << endl;
  mk_one(zc,oc);
}

void mk_A2(int zc,int oc,const vector<int>& A){
  cout << max(A[0],A[1]) << endl;
  mk_one2(zc,oc,min(A[0],A[1]));
}

void mk_large(int zc,int oc,vector<int> A){
  sort(A.begin(),A.end());
  
  int ga = -1;
  if( zc%2==1 && oc==0 ){
    ga = A[0];
    A.erase(A.begin());
  }

  int n = A.size();
  if( A[n-2] == 2 &&  A[n-1] == 3 ){ 
    swap(A[n-2],A[n-1]);
  }

  for(int i=0;i<n;i++) cout << A[i] << endl;

  if( ga == -1 ){
    mk_one(zc,oc);
  } else {
    mk_one2(zc,oc,ga);
  }

}

int main(){
  vector<int> A;
  int zc = 0,oc = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    int x; cin >> x;
    if( x>1 ) A.push_back(x);
    else if( x == 1 ){
      oc++;
    } else
      zc++;
  }

  if( zc == N ){//ALL0
    for(int i=0;i<N;i++) cout << 0 << endl;
  } else if( A.size()==0 || (A.size() == 1 && zc%2==1 && oc==0) ){
    //テ・ツソツ?」ツ??テ」ツ?ォテ」ツ?ェテ」ツつ?
    if( A.size() == 0 ){//0 or 1 only
      mk_one(zc,oc);
    } else { // 0 or 1 and X
      mk_one2(zc,oc,A[0]);
    }
  } else if( (A.size()==1 && (oc>=1 || zc%2==0) ) ||
	     (A.size()==2 && oc==0 && zc%2==1 ) ){
    //テ・ツソツ?」ツ?哂[0or1]テ」ツ?ォテ」ツ?ェテ」ツつ?
    if(A.size()==1 && (oc>=1 || zc%2==0) ){
      mk_A(zc,oc,A);
    } else {
      mk_A2(zc,oc,A);
    }
  } else {
    //テ」ツ?甘」ツ?甘」ツ?催」ツ?ェテ」ツ?凝」ツ??
    mk_large(zc,oc,A);
  }
  
  

}

Measured memory_bytes: 1224
a, b = input().split()
ab = a * int(b)
ba = b * int(a)
i = 0
while i < len(ab) and i < len(ba):
    if ab[i] == ba[i]:
        i += 1
        continue
    elif int(ab[i]) < int(ba[i]):
        print(ab)
        break
    else:
        print(ba)
        break
if i == len(ab):
    print(ab)
elif i == len(ba):
    print(ba)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
//https://www.khanacademy.org/computing/computer-science/algorithms
//http://www.toi2015.sat.psu.ac.th/files/news/?¢???????¢????????????????-TOI11.pdf

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

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string X;
  cin >> X;
  int stack = 0, puyo = 0;
  for (int i=0; i<X.size(); i++) {
    if (X[i]=='S') stack++;
    else if (stack>0) {
      stack--;
      puyo++;
    }
  }
  cout << X.size()-2*puyo << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    s.resize(unique(all(s)) - s.begin());
    cout << s.size() - 1;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s,t;
  cin >> s >> t;
  vi data1(26,0);
  vi data2(26,0);
  rep(i,s.size()) {
    data1[s[i] - 97]++;
  }
  rep(i,t.size()) {
    data2[t[i] - 97]++;
  }
  sort(data1.begin(), data1.end());
  sort(data2.begin(), data2.end());
  bool ans = true;
  rep(i,26) {
    if(data1[i] != data2[i]) {
      ans = false;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++) if(i%2==1) cnt++;
	cout<<fixed<<setprecision(10)<<(double)cnt/(double)n<<endl;
	return 0;
} 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        if (a < 10 && b < 10) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 23252
n = int(input())
m = list(map(int,input().split()))
c=0
for i in range(1,n-1):
    if max(m[i-1],m[i+1]) > m[i] and min(m[i-1],m[i+1]) < m[i]:
        c += 1
    else:
        c=c
print(c)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,a;
    cin>>n>>a;
    if(n%500<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int n, k;
vector<int> T;
int main(void){
    // Your code here!
    cin >> n >> k;
    T.resize(n);
    for(int i = 0; i < n; i++){
        cin >> T[i];
    }
    
    sort(T.begin(), T.end());
    
    int s = 0;
    int l = k-1;
    int diff = 1000000001;
    while(l < n){
        if(T[l] - T[s] < diff){
            diff = T[l] - T[s];
        }
        s++;
        l++;
        
    }
    
    cout << diff << endl;
    
    
    
}


Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[4][4],b[4][4];
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    b[0][0]=a[1][2];
    b[0][1]=a[1][1];
    b[0][2]=a[1][0];
    b[1][0]=a[0][2];
    b[1][1]=a[0][1];
    b[1][2]=a[0][0];
   for(int i=0;i<2;i++){
        for(int j=0;j<3;j++)
            if(a[i][j]!=b[i][j])
            {
                cout<<"NO";
                return 0;
            }
    }


        cout<<"YES";
}






Measured memory_bytes: 3580
local h,w,k=io.read("n","n","n","l")
local cake={}
local counter=k
local memo={}
for i=1,h do
    local s=io.read()
    local strawberry=0
    for _ in s:gmatch("#") do
        strawberry=strawberry+1
    end
    cake[i]={}
    if strawberry>0 then
        for j=1,w do
            if s:sub(j,j)~="#" then
                cake[i][j]=counter
            else
                cake[i][j]=counter
                strawberry=strawberry-1
                if strawberry>0 then
                    counter=counter-1
                end
            end
        end
        counter=counter-1
        table.insert(memo,i)
    end
end

for i=1,h do
    if #cake[i]==0 then
        if i<memo[#memo] then
            for j=1,#memo do
                if memo[j]>i then
                    print(table.concat(cake[memo[j]]," "))
                    break
                end
            end
        elseif i>memo[#memo] then
            print(table.concat(cake[memo[#memo]]," "))
        end
    else
        print(table.concat(cake[i]," "))
    end
end

Measured memory_bytes: 6776
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
//#define int long long
#define rep(i,start,end) for(i=start;i<end;i++)
#define Q 1000000007
#define F first
#define S second
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false)
using namespace std;

int main() {
    fast_io;
    int a;
    int cnt=1;
    cin>>a;
    while(cnt<100000000){
        if(a==4 or a==2 or a==1){
            cout<<cnt+3;
            break;
        }
        cnt+=1;
        if(a%2==0){
            a=a/2;
        }
        else{
            a=3*a+1;
        }


    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

class lca {
  public:
    using Graph = vector<vector<pair<ll,int>>>;
    const int n = 0;
    const int log2_n = 0;
    std::vector<std::vector<int>> parent;
    std::vector<int> depth;

    lca() {}

    lca(const Graph &g, int root)
        : n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) {
        dfs(g, root, -1, 0);
        for (int k = 0; k + 1 < log2_n; k++) {
            for (int v = 0; v < (int)g.size(); v++) {
                if (parent[k][v] < 0)
                    parent[k + 1][v] = -1;
                else
                    parent[k + 1][v] = parent[k][parent[k][v]];
            }
        }
    }

    void dfs(const Graph &g, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        REP(j,g[v].size()) {
            if (g[v][j].second != p) dfs(g, g[v][j].second, v, d + 1);
        }
    }

    int get(int u, int v) {
        if (depth[u] > depth[v]) std::swap(u, v);
        for (int k = 0; k < log2_n; k++) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if (u == v) return u;
        for (int k = log2_n - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};


int main(){
    int N;cin>>N;
    using P = pair<ll,int>;
    vector<vector<P>> graph(N);
    REP(i,N-1){
        int a,b,c; cin>>a>>b>>c;
        a--;b--;
        graph[a].push_back(P(c,b));
        graph[b].push_back(P(c,a));
    }
    int Q,K;cin>>Q>>K;
    K--;
    vector<ll> dist(N);
    function<void(int,int,ll)> dfs =[&](int u,int prev,ll len){
        dist[u] = len;
        for(auto v:graph[u]){
            if(v.second==prev) continue;
            dfs(v.second,u,len+v.first);
        }
    };
    dfs(K,-1,0);
    lca L(graph,K);
    REP(q,Q){
        int x,y;
        cin>>x>>y;
        x--;y--;
        int v=L.get(x,y);
        cout<<dist[x]+dist[y]<<"\n";
    }
}


Measured memory_bytes: 24440
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    int n;
    cin>>n;
    vector<int> c;
    c.push_back(1);
    int r=1;
    int k=1;
    while(1){
        r*=6;
        k*=9;
        if(r<=100000)c.push_back(r);
        if(k<=100000)c.push_back(k);
        if(r>100000&&k>100000)break;
    }
    sort(c.begin(),c.end());
    int dp[114514];
    dp[0]=0;
    for(int i=1;i<=n;i++){
        int j=0;
        int mi=INF;
        while(1){
            if(mi>dp[i-c[j]]+1){
                dp[i]=dp[i-c[j]]+1;
                mi=dp[i];
            }
            j++;
            if(c[j]>i)break;
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int m;
int G[10000000];
int A[10000000];
int i,n;
int cnt;
void insertionSort(int A[] ,int n, int g){
	for(int i=g;i<n;i++){
		int v=A[i];
		int j=i-g;
		while(j>=0 && A[j]>v){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
	A[j+g]=v;
	}
}

void shellSort(int A[], int n){
	cnt =0;
	G[0]=1;
	for(i=1;i<100;i++){
		G[i]=3*(G[i-1])+1;
		if(G[i]>n){break;}
	}
	m=i;
	for(i=m-1; i>=0; i--){
		insertionSort(A,n,G[i]);
	}
}

int main(void){
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&A[i]);
	}
	
	 cnt=0;
	
	shellSort(A,n);
	
	printf("%d\n",m);
	
	for(i=m-1; i>=0; i--){
		printf("%d",G[i]);
		if(i){printf(" ");}
	}
	
	printf("\n");
	
	printf("%d\n",cnt);
	
	for(i=0; i<n; i++){
		printf("%d\n",A[i]);
	}
	
	return 0;
}		


Measured memory_bytes: 5620