akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		int win = 0;
		for (char s : S) {
			if (s == 'o') {
				win++;
			}
		}

		int q = 15 - S.length;

		System.out.println((win + q) >= 8 ? "YES" : "NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,k,q,Cnt;
LL Sum;
int A[505],C[505];
LL B[5005];
bool Check(LL x) {
	LL need=1e16,w=0;
	for(int i=1; i<=n; ++i)
		C[i]=A[i]%x,w+=C[i];
	sort(C+1,C+1+n);
	LL Pre=C[1];
	for(int i=1; i<=n; ++i,Pre+=C[i])
		if(0==x*(n-i)-w)break;
	return Pre<=k;
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; ++i)
		scanf("%d",A+i),Sum+=A[i];
	sort(A+1,A+1+n);
	for(int i=1; 1LL*i*i<=Sum; ++i)
		if(Sum%i==0)B[++Cnt]=i,B[++Cnt]=Sum/i;
	sort(B+1,B+1+Cnt);
	for(int i=Cnt; i>=1; --i)
		if(Check(B[i]))return !printf("%lld",B[i]);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int X = input.nextInt();
        int bigPoint, smallPoint;

        bigPoint = (int) (X / 500) * 1000;
        smallPoint = (int)((X % 500) / 5) * 5;

        System.out.println(bigPoint + smallPoint);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define modm 1000000007
int sumDigit(int n){
	int sum=0;
	while(n){
		sum+=n%10;
		n=n/10;
	}
	return sum;
}
	
//Sourav Mondal
int main(){
	int t;
	cin>>t;
	int arr[4]={0};
	while(t--){
		string s;
		cin>>s;
		if(s=="AC") arr[0]++;
		else if(s=="WA") arr[1]++;
		else if(s=="TLE") arr[2]++;
		else if(s=="RE") arr[3]++;
		
	}
	
	cout<<"AC x "<<arr[0]<<endl;
	cout<<"WA x "<<arr[1]<<endl;
	cout<<"TLE x "<<arr[2]<<endl;
	cout<<"RE x "<<arr[3]<<endl;
	return 0;
}
			


Measured memory_bytes: 3628
using System;
using System.Linq;

class Plogram
{
    static void Main()
    {
        
        int num = int.Parse(Console.ReadLine());

        var array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        if(array.Max() < array.Sum() - array.Max())
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

int main() {
    int n;
    cin >> n;
    int ans = 0;
    vector<int> s(n);
    REP(i, n) {
        cin >> s[i];
        ans += s[i];
    }
    sort(s.begin(), s.end());

    if(ans % 10 != 0) {
        cout << ans << endl;
        return 0;
    }

    REP(i, n) {
        if((ans - s[i]) % 10 != 0) {
            cout << (ans - s[i]) << endl;
            return 0;
        }
    }

    cout << "0" << endl;

    return 0;
}
 

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var zz = new List<long>();
        zz.Add(0);

        foreach (var a in ary) {
            zz.Add(zz.Last() + a);
        }

        zz.Sort();

        long y = 0;

        int idx = 0;
        while(idx < zz.Count()) {
            int co = 0;
            long v = zz[idx];
            while((idx < zz.Count()) && (zz[idx] == v)){
                idx++;
                co++;
            }
            if(co >= 2) y+=Combination(co, 2);
        }

        return y;
    }

    static long Combination(long m, long n) {
        if (m == n || n == 0) return 1;

        long ans = 1;
        for (long i = 1; i <= n; i++) {
            ans = ans * (m - i + 1) / i;
        }
        return ans;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 38504
N = int(input())
ns = [int(input()) for _ in range(N)]

#primes = set()
#def is_prime(n):
#  if n in primes:
#    return True
#
#  for m in range(2, n):
#    if is_prime(m) and n % m == 0:
#      return False
#
#  primes.add(n)
#  return True

# Proof:
# if n < d ^ 2 and n mod d = 0;
# n = ad (a in N)
# ad < d ^ 2
# a < d
# QED

def is_prime(n):
  if n < 2: return False
  if n == 2: return True
  if n % 2 == 0: return False

  d = 3
  while d ** 2 <= n:
    if n % d == 0:
      return False
    d += 2
  return True

print(len([n for n in ns if is_prime(n)]))

Measured memory_bytes: 7972
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,m;
  cin>>n>>m;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  rep(i,n) {
    cout << s[i] << endl << s[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define all(a) a.begin(),a.end()
using namespace std;
const int maxn=2e5+10;
int pre[maxn],suf[maxn];
int main()
{
    int n;cin>>n;
    string s;cin>>s;
    string b=s;
    sort(all(b));
    int ans1=0,ans2=0,ans3=0;
    for(int i=0; i<n; i++){
        if(s[i]!=b[i])ans1++;
    }
    ans1/=2;
    int tmp=0,flag=0;
    for(int i=0; i<n; i++){
        if(s[i]=='W')flag=1,tmp++;
        else {
            if(flag)ans2+=tmp;
            tmp=flag=0;
        }
    }
    tmp=flag=0;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='R')flag=1,tmp++;
        else {
            if(flag)ans3+=tmp;
            flag=tmp=0;
        }
    }
    cout<<min(ans1,min(ans2,ans3))<<endl;
    return 0;
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) ll __VA_ARGS__; bulk(__VA_ARGS__);


int main(){
    vector<ll> a(3);
    bulk(a[0],a[1],a[2]);
    sort(all(a));
    if(a[0]%2==0||a[1]%2==0||a[2]%2==0)cout<<0<<endl;
    else cout<<a[0]*a[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int D, T, S;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	D = atoi(ch);
	ch = strtok(NULL, " ");
	T = atoi(ch);
	ch = strtok(NULL, " ");
	S = atoi(ch);

	if(D > T * S) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}

	return 0;
}


Measured memory_bytes: 2004
using System;
class MainClass
{
    public static void Main(string[] args)
    {
        int cnt = 0;
        int ans = 0;
        int num = int.Parse(Console.ReadLine());
        for (int i = 1; i <= num; i++)
        {
            if(i % 2 ==1)
            {
                cnt = 0;
                for (int j = 1; j <= i; j++)
                {
                    if (i % j == 0)
                    {
                        cnt++;
                        if (cnt == 8) { ans++; }
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E, r;
int dfs_clock;

struct Edge {
	int from, to;
	Edge(int u, int v) :from(u), to(v) {}
};

bool cmp(Edge a, Edge b) {
	if (a.from == b.from)
		return a.to < b.to;
	return a.from < b.from;
}

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	
	int pre[NUM], low[NUM];
	bool isbridge[NUM];
	vector<Edge> bridge;

	void init(int n) {
		this->n = n;
		edges.clear();
		for (int i = 0; i < n; i++) {
			G[i].clear();
			isbridge[i] = false;
			low[i] = -1;
		}
	}

	void AddEdge(int from, int to) {
		edges.push_back(Edge(from, to));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	int dfs(int u, int fa) {
		int lowu = pre[u] = ++dfs_clock;
		int child = 0;
		for (int i = 0; i < G[u].size(); i++) {
			int v = edges[G[u][i]].to;
			if (!pre[v]) {
				child++;
				int lowv = dfs(v, u);
				lowu = min(lowu, lowv);
				if (lowv > pre[u])
					isbridge[G[u][i]] = true;
			}
			else if (pre[v] < pre[u] && v != fa)
				lowu = min(lowu, pre[v]);
		}
		low[u] = lowu;
		return lowu;
	}

	void print() {
		for (int i = 0; i < edges.size(); i++) {
			if (isbridge[i]) {
				if (edges[i].from > edges[i].to)
					swap(edges[i].from, edges[i].to);
				bridge.push_back(edges[i]);
			}
		}
		sort(bridge.begin(), bridge.end(), cmp);
		for (vector<Edge>::iterator it = bridge.begin(); it != bridge.end(); it++)
			cout << it->from << " " << it->to << endl;
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s, t;
	cin >> V >> E;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d", &s, &t);
		solve.AddEdge(s, t);
		solve.AddEdge(t, s);
	}
	solve.dfs(0, -1);
	solve.print();
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 7216
n = int(input())
A = list(map(int,input().split()))
l = [i-1 for i in range(n+2)]
r = [i+1 for i in range(n+2)]
ind = [0]*n

for i,a in enumerate(A):
    ind[a-1] = i

ans = 0
for i in range(n-1,-1,-1):
    x = ind[i]
    ans += (i+1)*(r[x]-x)*(x-l[x])
    l[r[x]],r[l[x]], = l[x],r[x]
print(ans)

Measured memory_bytes: 41516
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  map<int, int> mp;
  REP(i,4){
    int n;
    cin >> n;
    mp[n]++;
  }
  if(mp[1]==1 && mp[9]==1 && mp[7]==1 && mp[4]==1){
    cout << "YES" << '\n';
  }else{
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define SCAN(x) scanf("%lld",&x);
#define INF 5555555555555555555
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> s;
  n = s.length();
  ans = n * (n - 1) / 2 + 1;
  MAP mp;
  FOR(i, 0, n) {
	ans -= mp[s[i]];
	mp[s[i]]++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map> 
#include<bits/stdc++.h> 
typedef long long ll ; 
#define el '\n' 
#define fr(n) for(ll i =0 ; i<n ; i++) 
using namespace std ;
ll a[100005] ; ll dp[100005] ;
ll k  ; 
ll solve(ll n){
    if (n < 1 ) return 0 ; 
    if (dp[n] != -1 )
    {
        return dp[n] ; 
    }
    
    //ll min = INT64_MAX ;
    //return min(abs(solve(n-1) - solve(n)) , abs(solve(n - 2) - solve(a[n])) ) ;
    ll mini = INT64_MAX ; 
    for(ll i = 1 ; i <=min(k , n ) ; i++ ){
        mini = min(mini , solve(n- i) + abs(a[n] - a[n-i])) ;
    }
    /*ll left , right ;
    left = solve(n-1) + abs(a[n] - a[n-1])  ;
    right = INT64_MAX ;
    if(n - 2 >= 0 ){
        right = solve(n-2) + abs(a[n]  - a[n-2]) ; 
    }*/
    return dp[n] =  mini ; 
    
}
int main() 
{ 
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    ll n ; cin >> n ; 
    cin >> k ;
    dp[0] = - 1  ;
    fr(n){
        cin >> a[i+1] ;
        dp[i + 1 ] = - 1 ; 
    }
    a[0] = a[1] ;
    cout << solve(n) << el ;
    //fr(n+1) cout << "##  " << dp[i] << el ;
    return 0; 
} 

Measured memory_bytes: 6528
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    s, w = MAP()
    if s <= w:
        print("unsafe")
    else:
        print("safe")


if __name__ == '__main__':
    main()


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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String l1 = scan.nextLine();
		scan.close();

		int N = Integer.valueOf(l1.split(" ")[0]);
		int M = Integer.valueOf(l1.split(" ")[1]);

		ArrayList<Integer> NMList = new ArrayList<Integer>();

		for (int i = 0; i < N; i++) {
			NMList.add(2);
		}

		for (int i = 0; i < M; i++) {
			NMList.add(1);
		}

		int result = 0;

		for (int i = 0; i < NMList.size(); i++) {
			for (int j = i + 1; j < NMList.size(); j++) {
				int a = NMList.get(i);
				int b = NMList.get(j);

				if (((a + b) % 2) == 0) {
					result++;
				}
			}
		}

		System.out.println(result);
	}
}

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

using namespace std;

int main(void) {

	int N,a,b;

	cin >> N;

	a = N % 10;
	b = (N % 100)/10;

	if (a != 9 && b != 9)
		cout << "No" << endl;

	else
		cout << "Yes" << endl;

}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:x:_) <- map read . words <$> getLine :: IO [Int]
  ls <- map read . words <$> getLine :: IO [Int]
  print $ solve n x ls

solve n x ls = length . filter (<=x) $ scanl' (+) 0 ls

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 3) {
		cout << 3 << endl;
	}
	else if (a + b == 4) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
S = list(input())
S.reverse()
MOD = 2019

t = [0]
r = 1
for i in range(len(S)):
    q = (t[-1] + (int(S[i]) * r)) % MOD
    t.append(q)
    r *= 10
    r %= MOD

cnt = Counter(t)
cnt_mc = cnt.most_common()

ans = 0
for _, j in cnt_mc:
    if j >= 2:
        ans += j * (j - 1) // 2
        
print(ans)

Measured memory_bytes: 18260
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    crap;
    int n, k;
    int nax = 200001;
    ll mod = 1e9 + 7;
    cin >> n >> k;

    vector<ll> max_sum(nax + 1, 0);
    forin(i, 1, nax + 2) {
        // cout << max_sum[i-1] << endl;
        max_sum[i] = max_sum[i-1] + i;
    }

    ll ans = 0;
    forin(i, k, n + 1) {
        // debug(i); debug(k); debug(n);
        ll minsum = max_sum[i-1];
        ll maxsum = max_sum[n] - max_sum[n-i];
        // debug(minsum); debug(maxsum);
        ans += (maxsum - minsum + 1);
        ans %= mod;
    }
    ans += 1; ans %= mod;

    cout << ans  << endl;

}

Measured memory_bytes: 4776
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    const [N,M] = load(2)
    const [A,B] = load(M,2)
    
    const rooms = new Array(N+1).fill(0)    // [room] = sign
    rooms[0] = -1
    rooms[1] = -1

    const lines = new_array_2d(N+1)
    for(let i = 0; i < M; i++) {
        lines[A[i]].push(B[i])
        lines[B[i]].push(A[i])
    }

    const rest = [1]
    while(rest.length) {
        const to = rest.shift()
        for(const from of lines[to]) {
            if(!rooms[from]) {
                rooms[from] = to
                rest.push(from)
            }
        }
    }

    if(rooms.includes(0)) return 'No'
    
    console.log('Yes')
    return rooms.slice(2).join('\n')
}



// console.time()
let inputs = input.split(/[\s\n]/)
let inifinite_loop_prevent_counter = 0
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()


function inifinite_loop_preventer(max = 1e5) {
    inifinite_loop_prevent_counter++
    if(inifinite_loop_prevent_counter >= max) {
        throw new Error("Infinite loop")
    }
}

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

// 素因数分解 { 素数: n乗 }
function math_prime_factors(n) {
    const result = {}

    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}

// 2次元配列を作る
function new_array_2d(x_len, y_len = 0, init_value = 0) {

    const array = new Array()
    for(let i = 0; i < x_len; i++) {
        const y = y_len ? new Array(y_len).fill(init_value) : new Array()
        array.push(y)
    }

    return array
}


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

using namespace std;
typedef long long ll;
const int N = 310, inf = 1e9 + 1;
int n, m, l, d[N][N], f[N][N];
void mnm(int &a, int b) { a = min(a, b); }
int main() {
	cin >> n >> m >> l;
	for (int i = 1; i <= n; ++i) {
		fill(d[i] + 1, d[i] + n + 1, inf);
		d[i][i] = 0;
		fill(f[i] + 1, f[i] + n + 1, inf);
		f[i][i] = 0;
	}
	for (int i = 1; i <= m; ++i) {
		int u, v, w; cin >> u >> v >> w;
		if (w <= l)
			d[u][v] = d[v][u] = w;
	}
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				mnm(d[i][j], d[i][k] + d[k][j]);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (d[i][j] <= l)
				f[i][j] = f[j][i] = 1;
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				mnm(f[i][j], f[i][k] + f[k][j]);
	int q; cin >> q;
	while (q--) {
		int s, t; cin >> s >> t;
		if (f[s][t]<inf)
			cout << f[s][t]-1 << endl;
		else cout << -1 << endl;
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, n,count=0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int an = i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10;
		if (an >= a && an <= b)count += i;
		an = 0;
	}
	cout << count << endl;
	int x;
	cin >> x;
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::vector<int> A = {2, 4, 5, 7, 9}, B = {0, 1, 6, 8};

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

  int N;
  std::cin >> N;

  N %= 10;

  if(std::binary_search(A.begin(), A.end(), N)){
      std::cout << "hon" << std::endl;
  }else if(std::binary_search(B.begin(), B.end(), N)){
      std::cout << "pon" << std::endl;
  }else{
      std::cout << "bon" << std::endl;
  }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll ret = 0;
  
  ll sum = 0;
  map<ll,int> memo;
  rep(i,N){
    sum += v[i];
    if(sum == 0) ret++;

    if(memo.count(-sum) > 0) ret += memo[-sum];
    memo[-sum]++;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 14320
import math

n, m = map(int, input().split(' '))
count = 0
if n >= 2:
    count += math.factorial(n) / 2 / math.factorial(n - 2)
if m >= 2:
    count += math.factorial(m) / 2 / math.factorial(m - 2)
print(int(count))


Measured memory_bytes: 2940
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = gcd(abs(xlist[i]-x),ans)
print(ans)

Measured memory_bytes: 15020
i=0
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for j in range(H):
        for k in range(W):
            if j==0 or j==(H-1) or k==0 or k==(W-1):
                print("#",end="")
            else:
                print(".",end="")
        print("\n",end="")
    print("\n",end="")
    i+=1


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

using namespace std;

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

	for (int i = 0; i <= n; i++) {
		for (int j = 0; i+j <= n; j++) {
			int k = n - i - j;
			int total = 10000 * i + 5000 * j + 1000 * k;
			if (total == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << " " << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){

	int n,m,l;
	int i,j,k;
	
	scanf("%d",&n);
	scanf("%d",&m);
	scanf("%d",&l);
	
	long int a[n][m];
	long int b[m][l];
	long int c[n][l];
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%ld",&a[i][j]);
		}
	}
	
	for(j=0;j<m;j++){
		for(k=0;k<l;k++){
			scanf("%ld",&b[j][k]);
		}
	}
	
	for(i=0;i<n;i++){
		for(k=0;k<l;k++){
			c[i][k]=0;
			for(j=0;j<m;j++){
				c[i][k]=c[i][k]+a[i][j]*b[j][k];
			}
		}
	}
	
	for(i=0;i<n;i++){
		for(k=0;k<l-1;k++){
			printf("%ld ",c[i][k]);
		}
		printf("%ld\n",c[i][l-1]);
	}
	
	return 0;
}

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string S;
  long long K;
  cin >> S >> K;

  int num = 1;
  size_t size = std::min(K, (long long)S.size());
  rep(i, size)
  {
    if (S[i] != '1')
    {
      num = S[i] - '0';
      break;
    }
  }
  cout << num << endl;

  return 0;
}


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
//using namespace std;
int main() {
	std::vector<int> num(3);
	std::cin >> num[0] >> num[1] >> num[2];
	std::sort(num.begin(), num.end());
	std::cout << num[2] * 10 + num[1] + num[0] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fuck 2000000000
#define hell 2000000000000000000
#define ff first
#define ss second 
#define forn(i,n) for (int i=0;i<int(n);i++)
#define nfor(i,n) for (int i=int(n)-1;i>=0;i--)
#define N 100010
#define M 1000010
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
int gcd(int a,int b){return (b==0) ? a : gcd(b,a%b);}
int n;
int ar[N];
int ans=0;
int main(){
	
	string s;
	int alpha[30];
	fill(alpha,alpha+30,0);
	cin>>s;
	for (int i=0;i<s.size();i++)
		alpha[s[i]-'a']++;
	for (int i=0;i<26;i++)
		if (!alpha[i])
			return !printf("%c",char(i+'a'));
	printf("None");
	
	return 0;
}

Measured memory_bytes: 512
import numpy as np
import sys
input2 = sys.stdin.read

# A: Anti-clockwise, B: Clockwise, V: Values
n, c = map(int, input().split())
AV = np.array(list(map(int, input2().rsplit())), dtype=np.int64)
A, V = AV[::2], AV[1::2]
B = (c - A)[::-1]

XA = np.cumsum(V) - A
XB = np.cumsum(V[::-1]) - B
RXA, RXB = XA - A, XB - B    # Cumulative Values returning to Start
NMA, NMB = XA.max(), XB.max()


def ind(lis, maxi):
    for i, x in enumerate(lis):
        if x == maxi:
            return i


MRA2, MRB2 = max(RXA[:-1], default=0), max(RXB[:-1], default=0)
mrai = ind(RXA, MRA2)
mrbi = ind(RXB, MRB2)

if not mrai and not mrbi:
    mrai, mrbi = 0, 0

MA2 = max(0, max(XA[:n - 1 - mrbi], default=0))
MB2 = max(0, max(XB[:n - 1 - mrai], default=0))
res = max(NMA, NMB, MA2 + MRB2, MB2 + MRA2)


for k in range(-1, -10 if n > 10 else -2, -1):
    MA3, MB3 = max(XA[:k], default=0), max(XB[:k], default=0)
    mai3 = ind(XA, MA3)
    mbi3 = ind(XB, MB3)

    if not mai3 and not mbi3:
        mai3, mbi3 = 0, 0

    MRA3 = max(0, max(RXA[:n - 1 - mbi3], default=0))
    MRB3 = max(0, max(RXB[:n - 1 - mai3], default=0))

    res = max(res, MA3 + MRB3, MB3 + MRA3)
print(res)


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

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef vector<int> vi;

struct Guidebook {
    int idx;
    string city;
    int score;
    bool flag;
};

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

    vector<Guidebook> gb(N);

    string S;
    int P;
    REP(i, N) {
        cin >> S >> P;
        gb[i].idx = i+1;
        gb[i].city = S;
        gb[i].score = P;
    }

    vector<Guidebook> result(N);

    REP(j, N) {
        string tmp_min_city = "zzzzzzzzzz";
        REP(i, N) {
            if (gb[i].flag) continue;
            if (gb[i].city < tmp_min_city) {
                tmp_min_city = gb[i].city;
            }
        }
        int tmp_max_score = -1;
        int min_idx;
        REP(i, N) {
            if (gb[i].flag) continue;
            if (gb[i].city == tmp_min_city) {
                if (gb[i].score > tmp_max_score) {
                    tmp_max_score = gb[i].score;
                    min_idx = i;
                }
            }
        }
        cout << min_idx + 1 << "\n";
        gb[min_idx].flag = true;

        result.emplace_back(gb[min_idx]);
    }
 
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <cstring>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int V,E; 
int path[17][17];
int dp[1<<17][17];

// int solve(int S, int v){
// 	if(dp[S][v]>=0) return dp[S][v];
// 	if(S == (1<<V)-1 && v == 0) return dp[S][v] = 0;
// 	int res = inf;
// 	for(int u = 0; u<V; u++){
// 		if(!(S>>u & 1)){ //まだ行っていないところがあったら，そこへ行ってみる
// 			res = min(res, solve(S | 1<<u, u) + path[v][u]);
// 		}
// 	}
// 	return dp[S][v] = res;
// }

// int main(){
// 	cin>>V>>E;
// 	rep(i,V)rep(j,V)path[i][j] = inf;
// 	rep(i,E){
// 		int s,t,d; cin>>s>>t>>d;
// 		path[s][t] = d;
// 	}
// 	memset(dp, -1, sizeof(dp));
// 	int ans = solve(0,0);
// 	if(ans == inf)ans = -1;
// 	cout<<ans<<endl;
// 	return 0;
// }

int main(){
	cin>>V>>E;
	rep(i,V)rep(j,V)path[i][j] = inf;
	rep(i,E){
		int s,t,d; cin>>s>>t>>d;
		path[s][t] = d;
	}
	rep(i,1<<V)rep(j,V)dp[i][j] = inf;
	dp[(1<<V)-1][0] = 0;
	for(int S = (1<<V)-2; S>=0; S--){
		for(int v = 0; v<V; v++){
			for(int u = 0; u<V; u++){
				if(!(S>>u & 1)){
					dp[S][v] = min(dp[S][v], dp[S|(1<<u)][u] + path[v][u]);
				}
			}
		}
	}
	int ans = dp[0][0];
	if(ans == inf)ans = -1;
	cout<<ans<<endl;
}


Measured memory_bytes: 5280
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = Console.ReadLine();
            var seven = n[0] == '7' || n[1] == '7' || n[2] == '7';
            Console.WriteLine(seven ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 25880
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int[] arr = new int[26];		
		String s = r.str();
		for(char c : s.toCharArray()) {
			arr[c-'a']++;
		}
		for(int i = 0;i <arr.length;i++) {
			if(arr[i] == 0) {
				print("" + (char)(i + 'a'));
				return;
			}
		}
		print("None");
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	ll N, A[100005], sum = 0, ans = 0;

	cin >> N;
	A[0] = 0;
	A[N + 1] = 0;
	for (int i = 1; i <= N; i++) {

		cin >> A[i];
		sum += abs(A[i] - A[i - 1]);

	}
	sum += abs(A[N + 1] - A[N]);

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

		cout << sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;

	}

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include<stdio.h>
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,res=-1;
    cin >> n;
    if(n/100%10==7){
        res=1;
    }else if(n/10%10==7){
        res=1;
    }else if(n%10==7){
        res =1;
    }
    if(res==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int euclid(int n, int m) {
  int q = min(n, m), p = max(n, m);
  if (q <= 0)
    return p;
  else
    euclid(q, p % q);
}
bool is_prime(int n) {
  bool ret = true;
  int end = sqrt(n), i;
  for (i = 2; i <= end; i++) {
    // cout << euclid(i, n) << " ";
    if (euclid(i, n) != 1){
      ret = false;
      break;
    }
  }
  // cout << endl;
  return ret;
}
int main() {
  int i, j, k, x, y; cin >> x;
  string s, t;
  // cout << is_prime(x) << endl;
  while (!is_prime(x)) x++;
  cout << x << endl;
  return 0;
}


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

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

    if(a == 'H' && b == 'H' || a == 'D' && b == 'D')
        cout << 'H' << endl;
    else
        cout << 'D' << endl;
}

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

public class Main{
	public static void main(String[] args) {
		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		while(n >= 4){
			if(n % 4 == 0 || n % 7 == 0){
				System.out.println("Yes");
				return;
			}
			else if(n > 4){
				n = n - 4;
			}
			else if(n > 7){
				n = n - 7;
			}
		}
		System.out.println("No");
	}
}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	int A, B;
	cin >>A >>B;
	if ((A<10)&&(B<10)) {
		cout <<A*B <<endl;
	} else {
		cout <<-1 <<endl;
	}
	return 0;
}



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

int main() {
	int k, x;
	scanf("%d%d", &k, &x);
	for(int i=x-k+1;i<=x+k-1;i++)
		printf("%d%c", i, i<x+k-1 ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def solve():
    class ConvexHullTrick:
        def __init__(self):
            self.LNows = deque()
            self.numL = 0

        def _isNotL2Min(self, L1, L2, L3):
            a1, b1 = L1
            a2, b2 = L2
            a3, b3 = L3
            return (a1-a2) * (b2-b3) >= (a2-a3) * (b1-b2)

        def _getY(self, L, x):
            a, b = L
            return a*x + b

        def addLine(self, L):
            while self.numL >= 2 and self._isNotL2Min(self.LNows[-2], self.LNows[-1], L):
                self.LNows.pop()
                self.numL -= 1
            self.LNows.append(L)
            self.numL += 1

        def getMin(self, x):
            y = self._getY(self.LNows[0], x)
            while self.numL >= 2:
                yNext = self._getY(self.LNows[1], x)
                if yNext > y: break
                y = yNext
                self.LNows.popleft()
                self.numL -= 1
            return y


    N, C = map(int, input().split())
    hs = list(map(int, input().split()))

    CHT = ConvexHullTrick()
    dp = [0] * N
    for i in range(1, N):
        CHT.addLine((-2*hs[i-1], dp[i-1] + hs[i-1]**2))
        minY = CHT.getMin(hs[i])
        dp[i] = minY + hs[i]**2 + C

    print(dp[-1])


solve()


Measured memory_bytes: 40100
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    a = tuple(geta(int))

    def update(b):
        r = [0] * n
        for i, bi in enumerate(b):
            i1 = max(0, i - bi)
            i2 = min(n - 1, i + bi)
            r[i1] += 1

            if i2 < n - 1:
                r[i2 + 1] -= 1

        updated = (not r[0] == b[0])
        for i in range(1, n):
            r[i] += r[i - 1]
            if r[i] != b[i]:
                updated = True

        return r, updated

    for i in range(k):
        a, updated = update(a)
        if not updated:
            break

    print(*a, sep=" ")


if __name__ == "__main__":
    main()

Measured memory_bytes: 158108
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long int N, A, B;
  cin >> N >> A >> B;
  if((A + B - 1 > N) || (A*B < N)){
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans(N,0);
  for(int i = 0; i*B < N; ++i){
    for(int j = 0; j < B; ++j){
      if(i*B + j >= N) break;
      ans[i*B + j] = min((i + 1)*B, N) - j;
    }
  }
  int ok = -1, ng = N;
  while(ng - ok > 1){
    int m = (ok + ng)/2;
    if((m + B - 1)/B + N - m > A) ok = m;
    else ng = m;
  }
  sort(ans.begin() + ok, ans.end());
  for(int i = 0; i < N - 1; ++i) cout << ans[i] << " ";
  cout << ans.back() << endl;
  return 0;
}


Measured memory_bytes: 3328
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy
setrecursionlimit(10**6)

#@pysnooper.snoop()
def dfs(v,s):
    seen[v]=True
    first[v]=s
    s+=1
    #print(v,g[v])
    for i in g[v]:
        if seen[i]:
            continue
        s=dfs(i,s)
    #print(s)
    last[v]=s
    return s+1

n=int(stdin.readline().rstrip())
seen=[False]*n
first=[0]*n
last=[0]*n
g=[[] for _ in range(n)]
s=1
for i in range(n):
    v=list(map(int,stdin.readline().rstrip().split()))
    for j in v[2:]:
        g[v[0]-1].append(j-1)
for i in range(n):
    if not seen[i]:
        s=dfs(i,s)
for i in range(n):
    print(i+1,first[i],last[i])


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(string s) {
	if (s[0] != 'A') {
		return false;
	}

	int cCount = 0;
	for (int i = 1; i < s.size(); i++) {
		if (!isupper(s[i])) {
			continue;
		}

		if (s[i] != 'C' || i == 1 || i == s.size() - 1) {
			return false;
		}

		cCount++;
	}

	return cCount == 1;
}

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

	string s;
	cin >> s;

	cout << (solve(s) ? "AC" : "WA") << endl;
	return 0;
}


Measured memory_bytes: 256