akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

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

  vector<uint64_t> A(N);
  N_TIMES(n, N) { cin >> A[n]; }

  uint64_t S = 0, T = 0;
  N_TIMES(n, N) {
    if (A[n] == 0) {
      S += T / 2;
      T = 0;
    } else {
      T += A[n];
    }
  }
  S += T / 2;

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 1536
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        String s = sc.next();
        for (char c: s.toCharArray()) {
            out.print((char)('A' + (c - 'A' + n) % 26));
        }
        out.println();

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k=2,p,c=0,l=0;
    cin>>n>>m;
    int a[n+m];
    for(i=0; i<n; i++)
    {
        a[l] = k;
        k+=2;
        l++;
    }
    k=1;
    for(i=0; i<m; i++)
    {
        a[l] = k;
        k+=2;
        l++;
    }
    for(i=0; i<(n+m)-1; i++)
    {
        for(j=i+1; j<(n+m); j++)
        {
            p = a[i]+a[j];
            if(p%2==0)
            {
                c++;
            }
        }
    }
    cout<<c;
}


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

#define fi first
#define se second

const int N = 200200;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        int n, m, A, B;
        cin >> n >> m >> A >> B;
        string s = "", t = "", rs, rt;
        for(int i = 0; i < A; i++){
                s += '0';
                rs += '1';
        }
        for(int i = 0; i < m - A; i++){
                t += '1';
                rt += '0';
        }
        for(int i = 0; i < n; i++){
                if(i % 2 && B){
                        B -= 1;
                        cout << rs << rt << "\n";
                } else{
                        cout << s << t << "\n";
                }
        }
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

bool uru(int n){
	if( (n%4==0 && n%100!=0) || (n%4==0 && n%100==0 && n%400==0) )
		return true;
	else return false; 
}

int main(){
	while(1){
		int y1, y2, m1, m2, d1, d2;
		int d[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
		long ans=0;
		
		cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
		if(y1==-1) break;
	
		if(y1==y2){
			if(m1==m2) ans=d2-d1;
			else{
				ans += d[m1-1]-d1+1;
				if(uru(y1) && m1==2) ++ans;
				++m1;
			
				while(m1!=m2){
					ans += d[m1-1];
					if(uru(y1) && m1==2) ++ans;
						
					++m1;
					//printf("%ld\n", ans);
				
				}
				ans+=d2-1;
			}
				
		}else{
			ans += d[m1-1]-d1+1;
			if(uru(y1) && m1==2) ++ans;
			++m1;	
			//printf("%ld\n", ans);
		
			while(m1<=12){
					ans += d[m1-1];
					if(uru(y1) && m1==2) ++ans;
						
					++m1;
					//printf("%ld\n", ans);
			}
			
			ans += d2-1;
			--m2;
			
			while(m2>=1){
					ans += d[m2-1];
					if(uru(y2) && m2==2) ++ans;
						
					//printf("%ld\n", ans);
					--m2;
			}
		
			for(int i=y1+1; i<=y2-1; ++i){
				if(uru(i)) ans += 366;
				else ans += 365;
			} 
	
		}
	
		printf("%ld\n", ans);
	
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std; 
 
int main () {
  int N; cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    bool is_candidate = true;
    for ( int j = 0; j < i; ++j ) {
      if ( H[j] > H[i]) {
        is_candidate = false;
        break;
      }
    }
    if (is_candidate) {
    ++ans;
  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  string a;
  cin>>a;
  int b=1,c,d,e=0,f=0,g=-1;
  vector<int> h(a.size(),0);
  fo(i,a.size()){
    if(b){
      if(a[i+1]=='L')
        b=0;
      e++;
    }
    else{
      if(a[i]=='R'){
        i--;
        if((e+f)%2==1){
          if(e%2==0){
            h[g+e]=(e+f)/2;
            h[g+e+1]=(e+f)/2+1;
          }
          else{
            h[g+e]=(e+f)/2+1;
            h[g+e+1]=(e+f)/2;
          }
        }
        else{
          h[g+e]=(e+f)/2;
          h[g+e+1]=(e+f)/2;
        }
        g=i;
        e=0;
        f=-1;
        b=1;
      }
      f++;
    }
    if(i==a.size()-1){
      if((e+f)%2==0){
        h[g+e]=(e+f)/2;
        h[g+e+1]=(e+f)/2;
      }
      else{
        if(e%2==0){
            h[g+e]=(e+f)/2;
            h[g+e+1]=(e+f)/2+1;
          }
          else{
            h[g+e]=(e+f)/2+1;
            h[g+e+1]=(e+f)/2;
          }
      }
    }
  //  cout<<e<<' '<<f<<endl;
  }
  fo(i,h.size()){
    cout<<h[i];
    if(i==h.size()-1)
      cout<<endl;
    else
      cout<<' ';
  }
}

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

int main(void)
{
	int x,y,z,a,b=0;
	char c[4];
//	scanf("%d %d %d %d",&x,&y,&z,&a);
//	scanf("%d %d %d",&x,&y,&z);
	scanf("%d %d",&x,&y);
//	scanf("%d",&x);
	printf("%d",x+(y/2));
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 2e3+9;
int dp[N];

void calc(int n) {
    dp[0] = 1;
    for(int sum=3;sum<=n;++sum) {
        for(int coin=3;coin<=sum;++coin) {
            dp[sum] += dp[sum-coin];
            dp[sum] %= inf;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    cin>>n;
    calc(n);
    cout<<dp[n]<<endl;
    return 0;
}

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

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

  ll prev;
  ll n = 0;
  ll money = 1000;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (i != 0) {
      if (a > prev) {
        n += money / prev;
        money -= (money / prev) * prev;
      } else if (a < prev) {
        money += n * prev;
        n = 0;
      }
    }
    // cout << money << " " << n << endl;
    prev = a;
  }
  cout << money + (n * prev) << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int taro(int pos,int act);
int n,a[100005],b[100005],c[100005];
int memo[100005][105];
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  cout<<taro(0,0)<<"\n";
  return 0;
}
int taro(int pos,int act){
  if(pos==n)return 0;
  if(memo[pos][act]!=-1)return memo[pos][act];
  
  if(act==1)return memo[pos][act]=max(taro(pos+1,2)+b[pos],taro(pos+1,3)+c[pos]);
  if(act==2)return memo[pos][act]=max(taro(pos+1,1)+a[pos],taro(pos+1,3)+c[pos]);
  if(act==3)return memo[pos][act]=max(taro(pos+1,1)+a[pos],taro(pos+1,2)+b[pos]);
  return memo[pos][act]=max(max(taro(pos+1,1)+a[pos],taro(pos+1,2)+b[pos]),taro(pos+1,3)+c[pos]);
}


Measured memory_bytes: 47104
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb >= ca:
    print('Yes')
else:
    print('No')


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

int main() {
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  long ans =0;
  for(int r=0;r<=N/R;r++){
    for(int g=0;g<=N/G;g++){
      int res=N-r*R-g*G;
      if(res<0) continue;
      //cout<<res<<endl;
      int buy=res/B;
      if(res-buy*B==0) ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define int long long
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void foo(){
    int n, m, mx = 0, sum = 0;
    cin>>n>>m;
    vi v(n);
    for(int i = 0; i < n; i++){
        cin>>v[i];
        sum+=v[i];
    }   
    int x = ceil((double)sum*1/(4*m));
    for(int i = 0; i < n; i++){
        if(x<=v[i])mx++;
    }
    if(mx>=m)cout<<"Yes\n";
    else cout<<"No\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];



void test_case() {

    
   string s;
   cin>>s;

   vec n(s.size()+1,0);

    for (int i=0;i<s.length();i++)
        n[i+1]=s[i]-'0';


    n[0]=0;
    int ans = 0;


    for (int i=n.size()-1;i>=1;i--){
        if (n[i]==5){
            if (n[i-1]>=5){
                n[i-1]++;
                ans+=10-n[i];
            }else {
                ans+=n[i];
            }
        }else if (n[i]>5){
            n[i-1]++;
            ans+=10-n[i];
        }else {
            ans+=n[i];
        }
    }
    
    ans+=n[0];
    cout<<ans<<endl;






}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 12960
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter,mul
from fractions import gcd
from functools import reduce
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
#ABC048-B
a,b,x=mii()


print(b//x - (a-1)//x)



Measured memory_bytes: 63724
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define pb push_back
#define LL long long
#define pairint pair<int,int>
#define fi first
#define se second
#define mp make_pair

namespace i207M
{

template<class T>il void in(T &x)
{
    x=0; bool f=0; char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=1;
        c=getchar();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
    if(f) x=-x;
}

#define N 4010
#define md 1000000007
int n;
pairint p[200005];
int f[N][N];
int fac[N<<1],inv[N<<1];
int qpow(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=(LL)a*a%md) if(b&1) res=(LL)res*a%md;
	return res;
}
int c(int n,int m)
{
	return n<m?0:(LL)fac[n]*inv[m]%md*inv[n-m]%md;
}
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
#endif
	in(n);
	for(ri i=1;i<=n;++i) in(p[i].fi),in(p[i].se),++f[2001-p[i].fi][2001-p[i].se];
	for(ri i=1;i<=4001;++i)
		for(ri j=1;j<=4001;++j) f[i][j]=((LL)f[i][j]+f[i-1][j]+f[i][j-1])%md;
	fac[0]=1;
	for(ri i=1;i<=8000;++i) fac[i]=(LL)fac[i-1]*i%md;
	inv[8000]=qpow(fac[8000],md-2);
	for(ri i=8000;i>=1;--i) inv[i-1]=(LL)inv[i]*i%md;
	int ans=0;
	for(ri i=1;i<=n;++i)
	{
		(ans+=f[2001+p[i].fi][2001+p[i].se])%=md;
		(ans+=md-c((p[i].fi<<1)+(p[i].se<<1),(p[i].fi<<1)))%=md;
	}
	ans=(500000004ll*ans)%md;
	printf("%d",ans);
    return 0;
}

//654465


}

signed main()
{
    i207M::main();
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll input[404][404];

const ll MAX_N = 404*404;

struct UnionFind{
    int N;
    int par[MAX_N];

    UnionFind(int N): N(N){
        for (int i=0;i<N;i++){
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        int rx = root(par[x]);
        par[x] = rx;
        return rx;
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

    bool find(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
	ll H, W;
	cin >> H >> W;
	REP(i, H){
		string S;
		cin >> S;
		REP(j, W){
			input[i][j] = (S[j]=='#'?1:0);
		}
	}

	ll N = H*W;
	UnionFind uf(N);
	REP(i, H){
		REP(j, W-1){
			ll hidari = W*i+j;
			ll migi = W*i+j+1;
			if(input[i][j]!=input[i][j+1]){
				//dump(hidari)
				//dump(migi)
				uf.unite(hidari, migi);
			}
		}
	}
	REP(i, H-1){
		REP(j, W){
			ll ue = W*i+j;
			ll shita = W*i+j+W;
			if(input[i][j]!=input[i+1][j]){
				//dump(ue)
				//dump(shita)
				uf.unite(ue, shita);
			}
		}
	}

	ll res = 0;
	REP(i, N) uf.root(i);
	//cout << endl;
	vector<ll> white(N, 0), black(N, 0);
	REP(i, N){
		if(input[i/W][i%W]==1){
			black[uf.root(i)]++;
		}else{
			white[uf.root(i)]++;
		}
	}
	//vprint(black);
	//vprint(white);
	REP(i, N) res += black[i]*white[i];
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 4608
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int t=s.nextInt(),n,x,y,u,d;t-->0;System.out.println(u+" "+-d))for(u=d=0,n=s.nextInt(),x=s.nextInt();n-->1;d=Math.min(d,y-x),x=y)u=Math.max(u,(y=s.nextInt())-x);}}

Measured memory_bytes: 12000
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k;i<=n+1;++i)
	{
		ll mn=((i-1)*(i))/2;
		ll mx=((n)*(n+1))/2-((n-i)*(n-i+1))/2;
		// debug(i,mn,mx);
		ans=(ans+mx-mn+1)%mod;
		ans=(ans+mod)%mod;
	}
	cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  vector<int> ds;
  for(int i = 0; i < n; i++) {
    int d;
    cin >> d;
    ds.push_back(d);
  }
  int k = 1;
  int d = 10;
  for(int t = 0; ; t++) {
    if(t >= d) {
      d *= 10;
      k++;
    }
    bool none = true;
    for(int i = 0; i < n - k + 1; i++) {
      int r = 0;
      for(int j = 0; j < k; j++) {
        r = r * 10 + ds[i+j];
      }
      if(r == t) {
        none = false;
        break;
      }
    }
    if(none) {
      cout << t << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3136
n = int(input())
s = []
def ui(lis):
    lis.sort()
    for i in range(len(lis)):
        if lis[i] % 10 == 0:
            continue
        else:
            return lis[i]
    return sum(lis)


for i in range(n):
    f = int(input())
    s+=[f]
e = sum(s)
o=sorted(s)
if e % 10 == 0:
    print(e - ui(o))
else:
    print(e)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 1000002
int n;
char buf[MAX];
int q;
int k;

long long int dp[MAX][3];


int main() {
	cin >> n;
	scanf("%s", buf);
	cin >> q;
	while (q--) {
		scanf("%d", &k);
		long long int way = 0;
		long long int cur_m = 0;
		long long int cur_d = 0;
		int lef = 0;
		long long int ans = 0;
		for (int i = 0; i < n; i++) {
			while (lef + k <= i) {
				if (buf[lef] == 'M') {
					cur_m--;
					lef++;
					continue;
				}
				if (buf[lef] == 'D') {
					cur_d--;
					way -= cur_m;
					lef++;
					continue;
				}
				lef++;
			}
			if (buf[i] == 'C') {
				ans += way;
				continue;
			}
			if (buf[i] == 'M') {
				way += cur_d;
				cur_m++;
				continue;
			}
			if (buf[i] == 'D') {
				cur_d++;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

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

    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
char a[3000005];

int main()
{
   int l=0,r=0,n;
   int m;
   int i;
   scanf("%d",&n);

   scanf("%s",a);

   for(i=1;i<n;i++)
   {
       if(a[i]=='E')
        r++;
   }
   m=r;

   for(i=1;i<n;i++)
   {
       if(a[i-1]=='W')l++;
       if(a[i]=='E')r--;
       int cur=l+r;
       if(cur<m) m=cur;
   }

   printf("%d\n",m);
return 0;

   }


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define N 1000000
int main()
{
   ll n,k;
   cin>>n>>k;
   for(ll i=k-n+1;i<=n+k-1;i++)    cout<<i<<" ";
}     
     
     

Measured memory_bytes: 256
s = input()

remain = [0]*2020
now = 0
ans = 0
for i in range(len(s)-1, -1, -1):
    now += int(s[i])*pow(10, len(s)-i-1, 2019)
    ans += remain[now%2019]
    remain[now%2019] += 1

ans += remain[0]

print(ans)


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

int main(){
  string N;
  cin >> N;
  int64_t sum=0;
  for(int i=0;i<N.size();i++){
    sum+=N.at(i)-'0';
  }
  if(sum%9==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
#define INT_INF (2 * 1e9)
#define LL_INF  (2LL * 1e18)
#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#endif
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }

void solve()
{
	int a, b;
	cin >> a >> b;

	if(b % a == 0)
		cout << a + b << endl;
	else
		cout << b - a << endl;
}

int main(int argc, char** argv)
{
	fast_io();
	solve();

	return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s;
  cin >> s;
  if(s[5]=='0'&&s[6]-'0'<=4)
     cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "A"
#define int long long

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;

map<ll ,int> ma;
int N, a[maxn], K;
ll sum[maxn];

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> N >> K;
    ma[0] = 1;
    ll res = 0;
    for (int i=1; i<=N; ++i){
        cin >> a[i];
        --a[i];
        sum[i] = sum[i-1] + a[i];
        sum[i] %= K;
        if (i >= K){
            ma[sum[i-K]]--;
        }
        res += ma[sum[i]];
        ++ma[sum[i]];
        ///cout << i << ' ' << res << '\n';
    }
    cout << res << '\n';
}


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

using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {

        cout << s << endl;
    } else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }
}

Measured memory_bytes: 3576
use std::io;
use std::str;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {

	let mut vec = vec!();//= (10..37).collect::<Vec<u32>>();
	let r = "abcdefghijklmnopqrstuvwxyz".split("").collect::<Vec<&str>>();
	let r = &r[1..27];
	let mut vec2 = (10..36).collect::<Vec<u32>>();
	let n = read_line().trim().chars().map(|e|e.to_digit(36).unwrap())
	.collect::<Vec<u32>>();

		for j in vec2.iter() {
			if n.contains(j) == false {
				vec.push(*j);
			}
		}

	if vec.is_empty() {
		println!("None");
	}else{
			println!("{}",r[(vec[0]-10) as usize]);
	}

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   pi   acos(-1.0);
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
    ll n;
    cin>>n;
    ll c=0,s=n;
    while(1)
    {
        c+=s%10;
        s/=10;
        if(!s) break;
    }
    if(n%c) cout<<"No\n";
    else cout<<"Yes\n";
}  

Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        int HoOo = 0;
        int Min = 1001;
        int Max = -1;
        for (int I = 0; I < N; I++) {
            int X = Input.nextInt();
            if (X > Max) {
                Max = X;
            }
            if (X < Min) {
                Min = X;
            }
        }
        System.out.println(Max - Min);
    }
}

//Learn Before You Earn


Measured memory_bytes: 21972
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d);
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

ll calc (ll num, ll sum, int now, int cnt, int max ) {
    ll tmp_num = 10;
    for ( int i = 0; i < cnt; i++ ) {
        tmp_num *= 10;
    }
    if ( now < max ) {
        return calc(num/tmp_num, sum+num%tmp_num, now+1, 0, max) + calc(num, sum, now+1, cnt+1, max);
    }
    else {
//        cout << sum << endl;
        return sum + num;
    }
}

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

    int keta = s.length();

    ll sum = calc(stol(s), 0, 0, 0, s.length()-1);

//    ll sum = 0;
//    int index_num = 0;
//    int cnt = 0;
//    for ( int i = 0; i < (1<<(keta-1)); i++ ) {
//        cnt = 0;
//        for ( int j = 0; j < keta; j++ ) {
//            if ( i & (1<<j) ) {
//                sum += stol(s.substr(keta-j-1, cnt+1));
//                cnt = 0;
//            }
//            else {
//                cnt++;
//            }
//        }
//        if ( cnt > 0 ) {
////            cout << stol(s.substr(0, cnt)) << " " << i << endl;
//            sum += stol(s.substr(0, cnt));
//        }
////        cout << i << " " << sum << " " << cnt << endl;
//    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
set <int> s;
int n,k,i,j,a,b;
cin>>n>>k;
for(i=0;i<k;i++)
{
	cin>>a;
	for(j=0;j<a;j++)
	{
		cin>>b;
		s.insert(b);
	}
}
cout<<n-s.size();
}


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

int main(){
    double weight;

    while(cin >> weight){
        if(weight > 91.00){
            cout << "heavy" << endl;
        }else if(weight > 81.00){
            cout << "light heavy" << endl;
        }else if(weight > 75.00){
            cout << "middle" << endl;
        }else if(weight > 69.00){
            cout << "light middle" << endl;
        }else if(weight > 64.00){
            cout << "welter" << endl;
        }else if(weight > 60.00){
            cout << "light welter" << endl;
        }else if(weight > 57.00){
            cout << "light" << endl;
        }else if(weight > 54.00){
            cout << "feather" << endl;
        }else if(weight > 51.00){
            cout << "bantam" << endl;
        }else if(weight > 48.00){
            cout << "fly" << endl;
        }else{
            cout << "light fly" << endl;
        }
    }

    return 0;
}

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

namespace AtCoder.Abc
{
    class A_170_Five_Variables
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            for (int i = 0; i < inputLongArray.Length; i++)
            {
                if (inputLongArray[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    // for文を抜ける
                    break;
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28040
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl c, d;
ll id = 0;

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    d[v] = c[id];
    id++;
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
        // 帰りの処理はこのへんに書く
    }
}

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

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    c.resize(n);
    rep(i, n) {
        cin >> c[i];
    }
    sort(rall(c));

    ll M = 0;
    exrep(i, 1, n-1) {
        M += c[i];
    }
    out(M);

    d.resize(n);
    const ll root = 0;
    dfs(root);

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

    cout << endl;
    re0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
 #define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  int N,K;
  cin>>N>>K;
  vector<int> data(N+1,0);
  for (int i = 0; i < N; i++)
  {
    cin>>data[i+1];
  }

  vector<vector<int> > DP(N+1,vector<int>(N+1,I64_MAX/4));
  DP[0][0] = 0;
  for (int i = 0; i < N+1; i++)
  {
    DP[i][0] = 0;
  }
  
    for(int i=1;i<=N;++i){
        DP[i][1]=data[i];
    }



  for (int i = 1; i <= N; i++)
  {
    for (int j = 2; j <= N; j++)
    {
      for (int x = 1; x < i; x++)
      {
        DP[i][j] = min(DP[i][j],DP[x][j-1] + max((int)0,data[i]-data[x]));
        // cout<<min(DP[i][j],DP[x][j-1] + max((int)0,data[i]-data[x]))<<endl;
      }
      
    }
    
  }
  //   for (int y = 0; y <= N - K; y++)
  // {
  //   /* code */
  //   for (int x = 0; x <= N; x++)
  //   {
  //     cout<<DP[y][x]<<" ";
  //   }
  //   cout<<endl;
  // }


  int ANS = I64_MAX;
  for (int i = 0; i <=N; i++)
  {
    ANS = min(ANS,DP[i][N-K]);
  }
  
  cout<<ANS<<endl;
  
  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  
   int i=0;
    if(s[i]=='R' && s[i+1]=='R' && s[i+2]=='R')
      cout<<3<<endl;
    else if((s[i]=='R' && s[i+1]!='R' && s[i+2]!='R') || (s[i]!='R' && s[i+1]=='R' && s[i+2]!='R') || (s[i]=='R' && s[i+1]!='R' && s[i+2]=='R') || (s[i]!='R' && s[i+1]!='R' && s[i+2]=='R'))
      cout<<1<<endl;
    else if((s[i]=='R' && s[i+1]=='R' && s[i+2]!='R') || (s[i]!='R' && s[i+1]=='R' && s[i+2]=='R'))
      cout<<2<<endl;
    else 
      cout<<0<<endl;
     return 0;
  
}
     



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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  vector<ll> Acc(N + 1), Ac(N + 1);
  FORIN(i, 1, N + 1) {
    ll A;
    cin >> A;
    Acc[i] = (Acc[i - 1] + A) % K;
    Ac[i] = (Acc[i] - i + K * 1000000000LL) % K;
  }
  map<int, int> now;
  FOR(i, min(N + 1, K)) now[Ac[i]]++;
  ll ans = 0;
  for (Pi p : now) ans += (ll)(p.second) * (p.second - 1) / 2;
  if (K < N + 1) {
    FORIN(i, K, N + 1) {
      now[Ac[i - K]]--;
      ans += now[Ac[i]];
      now[Ac[i]]++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
def abc():
    antennas = []
    for i in range(5):
        antennas.append(int(input()))
    k = int(input())

    for i in reversed(range(5)):
        for j in reversed(range(i)):
            if antennas[i] - antennas[j] > k:
                print(':(')
                return

    print('Yay!')


abc()


Measured memory_bytes: 2940
package main

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

func solve() {
	s := next()
	phrases := []string{"dream", "dreamer", "erase", "eraser"}

loop:
	for {
		if len(s) == 0 {
			println("YES")
			return
		}

		for _, p := range phrases {
			if len(s) < len(p) {
				continue
			}

			if p == s[len(s)-len(p):len(s)] {
				s = s[0 : len(s)-len(p)]
				continue loop
			}
		}
		break
	}

	println("NO")
	return
}

func main() {
	defer out.Flush()
	in.Buffer(make([]byte, scBufSize), scBufSize)

	in.Split(bufio.ScanWords)

	solve()
}

// --- template ---

const scBufSize = 1e6

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func println(a ...interface{}) {
	fmt.Fprintln(out, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(out, format, a...)
}

func next() string {
	in.Scan()
	return in.Text()
}

func nextInt() int {
	s := next()
	i, e := strconv.Atoi(s)
	if e != nil {
		fmt.Println(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}

func unique(list []int) []int {
	m := make(map[int]bool)
	uniq := make([]int, 0)
	for _, e := range list {
		if !m[e] {
			m[e] = true
			uniq = append(uniq, e)
		}
	}
	return uniq
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >>S;
  int count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='x'){
      count++;
    }
  }
  if(count>7){
    cout <<"NO"<<endl;
  }
  if(count<8){
    cout <<"YES"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007

int main(){
    FAST
    ll n;
    cin>>n;
    ll ans=LLONG_MAX;
    for(ll i=1;i*i<=n;i++){
      if(n%i==0)
        ans=min(ans,i+(n/i)-2);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
using ld = long double;
using ll = long long;

ll dp[2100][2100];

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (int l = 0; l <= n; l++) {
        for (int r = 0; l + r <= n; r++) {
            if (l == r && r == 0) {
                continue;
            }
            int i = l + r - 1;
            if (r != 0) {
                dp[l][r] = max(dp[l][r], dp[l][r - 1] + v[i].first * 1ll * abs(v[i].second - (n - r)));
            }
            if (l != 0) {
                dp[l][r] = max(dp[l][r], dp[l - 1][r] + v[i].first * 1ll * abs(v[i].second - (l - 1)));
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[i][n - i]);
    }
    cout << ans;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a == b) {
			pr.println("Draw");
		} else if (a == 1) {
			pr.println("Alice");
		} else if (b == 1) {
			pr.println("Bob");
		} else if (a > b) {
			pr.println("Alice");
		} else {
			pr.println("Bob");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

    string S;
    cin>>S;
    int N=S.length();

    string A, B;
    for(int i=1;i<=(N-1)/2;i++)
        A+=S[i-1];
    for(int i=(N+3)/2;i<=N;i++)
        B+=S[i-1];

    string s=S, a=A, b=B;
    reverse(S.begin(), S.end());
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());

    if(S==s && A==a && B==b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a, b, c, d;
  scanf("%1d %1d %1d %1d", &a, &b, &c, &d);
  if(a==b||b==c||c==d){
    printf("Bad");
  }else{
    printf("Good");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

// #define NMAX 1000000000
string S;
ll K;
ll D = 1e+18;

// // a^n を計算する(繰り返し二乗法,二分累乗法:O(logn))
// ll llpow(ll a, ll n) {
// 	ll x = 1L;
// 	while(n > 0){
// 		if(n & 1L) x = x * a;
// 		a = a * a;
// 		n >>= 1L;
// 	}
// 	return x;
// }

int solve(){
	int ans = 0;

	for(char s:S){
		ll x = s-'0';
		if(x > 1){
			ans = x;
			break;
		}
		else{
			K--;
			if(K<=0){
				ans = x;
				break;
			}
		}
	}

	return ans;
}

int main(){
	cin>>S>>K;
	cout<< solve() <<endl;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, m, q := nextInt(), nextInt(), nextInt()
	a, b, c, d := make([]int, q), make([]int, q), make([]int, q), make([]int, q)
	for i := 0; i < q; i++ {
		a[i], b[i], c[i], d[i] = nextInt(), nextInt(), nextInt(), nextInt()
	}
	A := make([]int, n+1)
	for i := 0; i < len(A); i++ {
		A[i] = 1
	}

	fmt.Fprintln(out, dfs(A, a, b, c, d, 1, m))

}

func dfs(A, a, b, c, d []int, i, m int) int {
	if i == len(A) {
		return calc(A, a, b, c, d, 0)
	}

	ret := 0
	for j := A[i-1]; j <= m; j++ {
		A[i] = j
		ret = max(ret, dfs(A, a, b, c, d, i+1, m))
	}
	return ret
}

func calc(A, a, b, c, d []int, i int) int {
	if len(a) == i {
		return 0
	}
	if A[b[i]]-A[a[i]] == c[i] {
		return calc(A, a, b, c, d, i+1) + d[i]
	}
	return calc(A, a, b, c, d, i+1)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ret {
			ret = a[i]
		}
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ret {
			ret = a[i]
		}
	}
	return ret
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1864
while True:
    (a,b,c)  =  map(int,input().split())
    if ( a == b == c == -1 ):
        break
    if ( a == -1 or b == -1):
        print ("F")
        continue
    if ( a + b >= 80):
        print ("A")
        continue
    elif(a + b >= 65 ):
        print ("B")
        continue
    elif(a + b >= 50 ):
        print ("C")
        continue
    elif(a + b >= 30 ):
        if ( c >= 50):
            print ("C")
        else:
            print ("D")
        continue
    print("F")





Measured memory_bytes: 5596