akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

F = Factorial(N + 1, MOD).comb

tmp = 0

if K == 1:
    print (0)
    exit()

lst = [0] * N
K -= 1
for i in range(K, N):
    tmp += F(i - 1, K - 1)
    tmp %= MOD
    lst[i] = tmp

# print (lst)

ans = 0
for a, tmp in zip(A, lst):
    ans += a * tmp
    ans %= MOD

for index, a in enumerate(A):
    if N - 1 - index < 0:
        break
    ans -= a * (F(N - 1 - index, K))
    ans %= MOD

print (ans)

Measured memory_bytes: 17220
a,b = map(int,input().split())
s = list(input())
num = [str(i) for i in range(10)]
flag = True
for i in range(a+b+1):
    if i==a:
        if s[a]!='-':
            flag = False
    else:
        if not s[i] in num:
            flag = False
print('Yes' if flag==True else 'No')


Measured memory_bytes: 38384
#include <stdio.h>

int main(){
    char S[101];
    int K = 0;
    int i = 0;
    scanf("%d", &K);
    scanf("%s", S);
    int len = 0;
    while(S[i]){
        len++;
        i++;
    }
    if(len<=K){
        for (i = 0; i < len; i++)
        {
            printf("%c", S[i]);
        }
    }else{
        for (i = 0; i < K;i++){
            printf("%c", S[i]);
        }
        puts("...");
    }

    return 0;
}

Measured memory_bytes: 1664
N = int(input())
H =list(map(int, input().split()))
count = []
count_tmp = 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H[i] >= H[i+1]:
            count_tmp += 1
            if i == N-2:
                count.append(count_tmp)
        else:
            count.append(count_tmp)
            count_tmp = 0
    print(max(count))

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

typedef long long ll;

ll cnt[100010],n,ans=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>cnt[i];
	for(int i=0;i<n;i++){
		ans+=cnt[i]/2ll;
		cnt[i]%=2;
		if(cnt[i]==1&&cnt[i+1]>0){	
			ans++;
			cnt[i+1]--;
			cnt[i]=0;
		}
	}
	cout<<ans;
	return 0;
}

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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    for i in range(1,10):
        if n <= i*111:
            return i*111

    return -1


print(main())


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

int main() {

  std::string str;

  std::getline(std::cin, str);
  for(int i = 0; i < str.size(); ++i) {
    if( ('a' <= str[i] && str[i] <= 'z') || ('A' <= str[i] && str[i] <= 'Z') ) { 
      str[i] = str[i] ^ 0x20;
    }
  }
  std::cout << str << std::endl;
  
  
  return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        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();

            string result = (inputLongArray[0] * inputLongArray[1]).ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28236
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> ans;
int main() {
    string str;
    getline(cin,str);
    string word="";
    for (int i=0; i<str.length(); i++) {
        if (str[i]==' '||str[i]==','||str[i]=='.') {
            if (word.length()>=3&&word.length()<=6) {
                ans.push_back(word);
            }
            word="";
        } else {
            word += str[i];
        }
    }
    if (word.length()>=3&&word.length()<=6) ans.push_back(word);
    for (int i=0; i<ans.size()-1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[ans.size()-1] << endl;
}

Measured memory_bytes: 0
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, R;

int main()
{
  scanf( "%d%d", &N, &R );

  printf( "%d\n", N>=10?R:R+100*(10-N));

  return 0;
}

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

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

    vector<int> v(n);
    for (int &i : v) {
        cin >> i;
    }

    int min = numeric_limits<int>::max();
    int max = *max_element(v.begin(), v.end());
    for (int i = 0; i < max; i++) {
        int sum = 0;
        int point = i + 1;
        for (int j : v) {
            int diff = j - point;
            sum += diff * diff;
        }
        if (min > sum) {
            min = sum;
        }
    }

    cout << min << endl;
}

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

using ll = long long;

ll c2(ll n) {
	return n * (n-1) / 2;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	vector<int> cnts(N);
	vector<int> A(N);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans -= c2(cnts[A[i]]);
		cnts[A[i]]++;
		ans += c2(cnts[A[i]]);
	}
	for (int i = 0; i < N; i++) {
		ans -= c2(cnts[A[i]]);
		cnts[A[i]]--;
		ans += c2(cnts[A[i]]);
		cout << ans << '\n';
		ans -= c2(cnts[A[i]]);
		cnts[A[i]]++;
		ans += c2(cnts[A[i]]);
	}

	return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int r=0,g=0,b=0;
		for(int i=0;i<N;i++) {
			if(S.charAt(i)=='R') {
				r++;
			}else if(S.charAt(i)=='G') {
				g++;
			}else {
				b++;
			}
		}
		long ans = (long)r*g*b;
		for(int i=0;i<N;i++) {
			for(int j=i+1;j<N;j++) {
				int k = j+j-i;
				if (k < N && S.charAt(i) != S.charAt(j) && S.charAt(j) != S.charAt(k) && S.charAt(i) != S.charAt(k)) {
					ans--;
						}
			}
		}
		if(ans<=0) {
			System.out.println("0");
		}else {
			System.out.println(ans);	
		}
	}

}




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

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

  // map<char, std::size_t> m;
  // for (char c = '0'; c <= '9'; c++) {
  //   auto i = s.rfind(c);
  //   if (i == s.npos) i = 0;
  //   m[c] = i;
  // }

  int ans = 0;
  for (char c = '0'; c <= '9'; c++) {
    auto i = s.find(c);
    if (i == s.npos) continue;
    for (char d = '0'; d <= '9'; d++) {
      auto j = s.find(d, i + 1);
      if (j == s.npos) continue;
      for (char e = '0'; e <= '9'; e++) {
        auto k = s.find(e, j + 1);
        if (k == s.npos) continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<ll> a(N+1);
  for(int i = 1; i < N+1; i++){
    cin >> a[i];
  }

  int M = 0;
  vector<ll> b(N,0);
  vector<ll> sa(N+1,0);


  for(int i = 0; i < N; i++){
    int num = N - i;
    if(a[num] == (sa[num]%2)) continue;
    //b[num] = 1;
    b[M] = num;
    M += 1;
    sa[num] += 1;
    sa[1] += 1;

    for(int j = 2; j * j <= num; j++){
      if(num%j == 0){
        sa[j] +=1;
        if(num/j!=j) sa[num/j] += 1;
      }
    }
  }

  cout << M << endl;
  if(M!=0){
    cout << b[0];
    for(int i = 1; i < M; i++){
      cout << " " << b[i];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 5632
def main
  a, b = gets.chomp.split(/\s/).collect { |x| x.to_i}
  area, len = solve(a,b)
  puts "#{area} #{len}"
end

def solve(a, b)
  area = a * b
  len = 2 * (a + b)
  [area, len]
end

main

Measured memory_bytes: 6096
#include<stdio.h>
#include<cstdlib>

#define INF 2147483647

int n;

void P(){
  printf("\ntest\n");
}

int min(int a, int b){
  return a < b ? a : b;
}

int matrixChainOrder(int *P, int p, int l){
  int i, j, k, m[100][100], q;
  for(i = 1; i < n+1; i++){
    m[i][i] = 0;
  }
  for(i = 1; i < n; i++){ // tonaridousi de keisan
    m[i][i+1] = P[i-1] * P[i] * P[i+1];
  }
  for(i = 2; i <= n-1; i++){ // habahirogeru
    for(j = 1; j+i <= n; j++){ // dokokarahajimerukakimeru
      q = INF;
      for(k = 0; k < i; k++){
	q = min(q, m[j][j+k] + m[j+k+1][j+i] + P[j-1] * P[j+k] * P[j+i]);
	//printf("i:%d j:%d k:%d\n", i, j, k);
      }
      m[j][j+i] = q;
    }
  }

  return m[p][l];
}

int main(){
  int i, *P;

  scanf("%d", &n);
  P = (int *)malloc(sizeof(int) * n + 1);
  for(i = 0; i < n; i++){
    scanf("%d %d", &P[i], &P[i+1]);
  }

  printf("%d\n" ,matrixChainOrder(P, 1, n));

  return 0;
}



Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n , m ;
   cin >> n >> m ;
   map < int , int > mp;
   for( int i = 0 ; i < m ; i++){
        int x ;
        cin >> x ;
        mp[x]++;
   }
   vector < ll > dp(n+1,-1) ;
   dp[0] = 1 ;
   for( int i = 1 ; i <= n ; i++){
        if(mp.find(i)!=mp.end()) continue ;
        if(i-1>=0 && dp[i-1]!=-1){
            dp[i] = dp[i-1];
        }
        if(i-2>=0 && dp[i-2]!=-1){
            if(dp[i]==-1) dp[i] = 0 ;
            dp[i] = add(dp[i],dp[i-2]);
        }
   }
   //for( int i = 0 ; i < n+1 ; i++) cout << dp[i] << " " ;
   cout << (dp[n]==-1?0:dp[n]) << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 5760
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;

public:
	UnionFind(int size) : data(size, -1) { }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K, L;
	cin >> N >> K >> L;

	UnionFind ufr(N), ufl(N);
	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
		p--, q--;
		ufr.unify(p, q);
	}
	for (int i = 0; i < L; i++) {
		int p, q;
		cin >> p >> q;
		p--, q--;
		ufl.unify(p, q);
	}

	map<pair<int,int>, int> mp;
	for (int i = 0; i < N; i++) mp[{ufr.root(i), ufl.root(i)}]++;

	for (int i = 0; i < N; i++) cout << mp[{ufr.root(i), ufl.root(i)}] << " ";

	return 0;
}

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

#define INF (1<<29)

string str;
const string color[8] = {"black","blue","lime","aqua","red","fuchsia",
			 "yellow","white"};
const string strong[8] = {"#000000","#0000ff","#00ff00","#00ffff","#ff0000",
			  "#ff00ff","#ffff00","#ffffff"};
 
int change(char ch)
{
    if ('0' <= ch && ch <= '9') {
	return ch - '0';
    }
    return 10 + (ch - 'a');
}
 
int d(string str1, string str2)
{
    int R1 = change(str1[1])*16 + change(str1[2]);
    int G1 = change(str1[3])*16 + change(str1[4]);
    int B1 = change(str1[5])*16 + change(str1[6]);
 
    int R2 = change(str2[1])*16 + change(str2[2]);
    int G2 = change(str2[3])*16 + change(str2[4]);
    int B2 = change(str2[5])*16 + change(str2[6]);
 
    int res = pow(R1-R2,2.0) + pow(G1-G2,2.0) + pow(B1-B2,2.0);
 
    return res;
}
 
int main()
{
    while (cin >> str, str != "0") {
	int min_ = INF,ans;
	for (int i = 0; i < 8; i++) {
	    int dist = d(str, strong[i]);
	    if (dist < min_) {
		min_ = dist;
		ans = i;
	    }
	}
	cout << color[ans] << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
package main

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

func partition(xs []int, p int, r int) int {
	x := xs[r]
	as := xs[:len(xs)-1]
	i := p - 1 // 前パーティションの最後の要素のポインタ
	j := p
	for j < len(as) {
		target := as[j]
		if target <= x {
			i++
			as[j] = as[i]
			as[i] = target
		}
		j++
	}
	xs[r] = xs[i+1]
	xs[i+1] = x
	return i + 1
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func printArray(xs []int, q int) {
	ss := make([]string, len(xs))
	for i, x := range xs {
		if i == q {
			ss[i] = "[" + strconv.Itoa(x) + "]"
		} else {
			ss[i] = strconv.Itoa(x)
		}
	}
	fmt.Println(strings.Join(ss, " "))
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = nextInt(sc)
	}
	q := partition(xs, 0, n-1)
	printArray(xs, q)
}



Measured memory_bytes: 5504
#include <stdio.h>


int main(){
   int i, j, k;
   int n, x;
   int count;


   while(1){
       scanf("%d %d ", &n, &x);
       if(n==0&&x==0)break;
       count=0;
       for(i=1;3*i+3<=x;i++){
           for(j=i+1;i+2*j+1<=x;j++){
               for(k=n;k>j;k--){
                   if(x==i+j+k){
                       count++;
                       break;
                   }else if(x>=i+j+k){
                       break;
                   }
               }
           }
       }
       printf("%d\n", count);
   }
   return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)
#define MAXN       200005

ll vis[MAXN],cnt;
vector<ll>graph[MAXN];

void dfs(ll u)
{
    vis[u]=1;
    cnt++;
    for(auto it:graph[u])
    {
        if(!vis[it])
            dfs(it);
    }
}

int main()
{
    ll n,m,k,g,mx,mn,res,c,x,y,z,w,p,q,r,l,s,t;
    ci>>n>>m;
    f(i,0,m)
    {
        ci>>x>>y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    res=0;
    f(i,1,n+1)
    {
        cnt=0;
        dfs(i);
        res=max(res,cnt);
    }
    co<<res;
    return 0;
}

Measured memory_bytes: 22316
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;
string t;
bool ck(int l,int r){
    bool ans = true;
    if(r>s.size())return false;
    repi(i,l,r){
        if(s[i]=='?')continue;
        if(s[i]!=t[i-l])ans = false;
    }
    return ans;
}
vector<string> as;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s>>t;
    bool ans = false;

    rep(i,s.size()){
        if(ck(i,i+t.size())){
            ans = true;
            string tp = s;
            tp.replace(i,t.size(),t);
            as.pb(tp);
        }
    }
    rep(i,as.size()){
        rep(j,as[i].size()){
            if(as[i][j]=='?'){
                as[i][j] = 'a';
            }
        }
    }
    sort(all(as));
    if(as.empty()){
        print("UNRESTORABLE");
    }else{
        print(as[0]);
    }
    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;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    map<string,int>S;
    rep(i,n){
          string s;
          cin>>s;

          S[s]++;
    }

    int cnt=0;

    for(auto x:S){
        if(x.second!=0)cnt++;
    }

    cout<<cnt<<endl;


}


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

#define ll long long int

#define pi 2*acos(0.0)
#define mod 1000000007

#define fast   ios_base::sync_with_stdio(false);cin.tie(NULL);

#define pii pair<ll,ll>

#define pb push_back

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

//ll Big_Mod(ll v1, ll p, ll md)  { ll res=1; v1=v1%md; while (p > 0){if (p & 1)res = (res * v1) % md; p =p>>1; v1 = (v1 * v1) % md;}return res;}
ll ar[500009],br[500009],cr[500009],tr[500009];
map<ll,ll>mp;
vector<ll>v;
string s;

struct evan
{
    ll l,r,pos;
}st[500009];
bool com(evan i1,evan i2)
{
    return (i1.r < i2.r);
}

int main()
{
    ll a,b,c,d,e,i,j,k,x,y,z,f,g,h,n,m;
    cin>>a;
    s="";
    while(a!=0)
    {
        b=(a%26);
        if(b==0)
        {
            b=26;
        }
        s+=char(b+'a'-1);
        a=a-b;
        a=a/26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}






Measured memory_bytes: 3636
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n = int(input())
l = make_divisors(n)
print(len(str(max(l[len(l) // 2], l[len(l) - len(l) // 2 - 1]))))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <algorithm>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using ull = unsigned long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

const int MX = 2010;

int main(){
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    sort(s.begin(), s.end());
//    vector<vector<vector<bool>>> d(3, vector<vector<bool>>(3, vector<bool>(MX, true)));
    bool d[3][3][MX];
    int ans = MX * 3;
    do{
        rep(i, 3) for(int j = i + 1; j < 3; j++) rep(k, s[i].size()){
            string pre = s[i], post = s[j];
            bool ok = true;
            for (int ni = k; ni < pre.size(); ni++){
                int nj = ni - k;
                if (nj >= post.size()) break;
                if (pre[ni] == '?' or post[nj] == '?') continue;
                if (pre[ni] != post[nj]) ok = false;
            }
            d[i][j][k] = ok;
        }
        auto f = [&](int i, int j, int k) {
            if (k >= s[i].size()) return true;
            return d[i][j][k];
        };
//        rep(x, s[0].size() + 1)rep(y, max(s[1].size() + 1, s[0].size() - x + 1)){
        rep(x, MX)rep(y, MX){
            if (!f(0, 1, x)) continue;
            if (!f(1, 2, y)) continue;
            if (!f(0, 2, x + y)) continue;
            int now = 0;
            now = max<int>(now, s[0].size());
            now = max<int>(now, x + s[1].size());
            now = max<int>(now, x + y + s[2].size());
            ans = min(ans, now);
        }
    }while(next_permutation(s.begin(), s.end()));
    cout << ans << endl;
}

Measured memory_bytes: 384
//Bismillahir Rahmanir Rahim
#include<iostream>
using namespace std;
int main()
{
	int n,res,res2,res1,resm;
	cin>>n;
	
	
	//res=n/1000;
	
	if(n%1000==0)
	{
		cout<<'0'<<endl;
		 return 0;
	}
	else
	{
		res=n/1000;
		res1=res+1;
		res2=res1*1000;
		resm=res2-n;
	}
	//res2=n-res;
	cout<<resm<<endl;
	return 0;
}

Measured memory_bytes: 3196
/* ex4_3
  key_tree */

#include <stdio.h>

int main(void){
    // プロトタイプ宣言
    int snow_depth(int west_height, int east_height);
    //埋もれていない高さを西側はwest_height、東側はeast_height
    int west_height, east_height;
    scanf("%d %d ",&west_height, &east_height);

    printf("%d\n", snow_depth(west_height, east_height));

    return 0;
}

int snow_depth(int west_height, int east_height){
    int dif, ans;
    dif = east_height - west_height;
    ans =(1 + dif) * dif /2 - east_height;

    return ans;
}

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

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

  int num = 1, ans = 0;
  while (1) {
    ans = num * num;
    if (ans > N) break;
    num++;
  }

  cout << (num - 1) * (num - 1) << endl;  
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    string chk1 = "";
    string chk2 = "";
    REP(i,s.size()) {
        if(s[i]=='x') continue;
        chk1 += s[i];
        chk2 += s[i];
    }

    reverse(chk2.begin(),chk2.end());

    if(chk1 != chk2) {
        pl(-1)
        return 0;
    }

    int l = 0,r = s.size()-1;
    int ans = 0;
    while(l<r){
        int lnum = 0,rnum=0;
        while(s[l]=='x') lnum++,l++;
        while(s[r]=='x') rnum++,r--;
        ans += abs(lnum-rnum);
        l++;r--;
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans,k;
int a[211111];int p1[211111],p2[211111];

signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	
	rep(i,n){
		p1[i]=(i+1)-a[i];
		p2[i]=a[i]+(i+1);
	}
	map<int,int> p1cnt,p2cnt;
	rep(i,n){
		p1cnt[p1[i]]++;
		p2cnt[p2[i]]++;
	}
	rep(i,222222)ans+=p1cnt[i]*p2cnt[i];
	cout<<ans<<endl;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll k; cin >> k;
    string s; cin >> s;

    if(s.size()>k) s = s.substr(0, k) + "...";

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3632
package main 

import (
        "fmt"
)


func main (){
        var a int
        var b int
        var c int
        x := 0
        fmt.Scan(&a, &b, &c)
        for i :=0 ; i < c ; i++{
                if a % 2 == 1  &&  x ==0 {
                        a -=1
                        a = a / 2
                        b = a + b
                        x +=1
                }  else if  a % 2 == 0  &&  x ==0 {
                        a = a / 2
                        b = a + b
                        x +=1
                }  else if  b % 2 == 1  &&  x ==1 {
                        b -=1
                        b = b / 2
                        a = b + a
                        x = 0
                }  else if  b % 2 == 0  &&  x ==1 {
                        b = b / 2
                        a = b + a
                        x = 0
                }


        }
        fmt.Println(a, b)

}


Measured memory_bytes: 512
N = int(input())
a = sorted(list(map(int, input().split())))

L = []

c = 1

for i in range(1, N):
	if a[i - 1] == a[i]:
		c += 1

	else:
		L.append([c, a[i - 1]])
		c = 1

L.append([c, a[-1]])

ans = 0
for i in range(len(L)):
	if L[i][0] >= L[i][1]:
		ans += L[i][0] - L[i][1]
	else:
		ans += L[i][0]

print(ans)

Measured memory_bytes: 16760
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int x = 0;
    int ans = 0;
    while(r*x<=n){
        int y = 0;
        while(g*y<=n-r*x){
            if((n-r*x-g*y)%b==0) ans++;
            y++;
        }
        x++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long mod = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p; cin >> n >> p;
	int ans = 1;
	map<int, int>mp;
	for (int i = 2; i <= sqrt(p); i++) {
		if (!prime(i))continue;
		while (p%i == 0) {
			mp[i]++;
			p /= i;
		}
		ans *= pow(i, mp[i] / n);
	}
	if (p != 1)mp[p] = 1;
	ans *= pow(p, mp[p] / n);
	cout << ans << endl;
	return 0;
}

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

int N, W[100];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    int ans = 1e9;
    for(int T = 1; T < N; T++){
        int sum_f = 0, sum_l = 0;
        for(int i = 0; i < N; i++){
            if(i < T){
                sum_f += W[i];
            }else{
                sum_l += W[i];
            }
        }
        ans = min(ans, abs(sum_f - sum_l));
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<cstdio>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n]={};
	int b[n]={};
	a[0]=1;
	for(int i=0;i<n;i++){
		b[i]=1;
	}
	int x,y;
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		x--;
		y--;
		if(a[x]==1){
			if(b[x]==1){
				a[x]=0;
				a[y]=1;
			}else{
				a[y]=1;
			}
		}
		b[x]--;
		b[y]++;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    val s = readLine()!!
    val K = readLine()!!.toInt()

    val l = mutableListOf<String>()
    for (c in 0..s.length) for (d in 1..(s.length - c)) {
        val t = s.substring(c, c + d)
        if (5 < t.length) break
        if (!l.contains(t)) l += t
    }

    println(l.sorted()[K - 1])
}

Measured memory_bytes: 41920
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const ll MOD = 1000000007;
 
using namespace std;

int main(){
    ll N, tmp;   cin >> N;
    int keta, m, p;
    p = 0;
    tmp = N;
    for(int i=0; i<18; i++){p+=tmp%10; tmp/=10;}
    for(int i=0; i<18; i++) if(N < pow(10,i)){keta = i; m=N/pow(10,i-1); break;}
    m = m-1 + 9*(keta-1);
    cout << max(p,m) << endl;
}

Measured memory_bytes: 3940
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#define pii pair<int,int>
#define ull  unsigned long long
#define ll long long
using namespace std;

int find(int n)
{
    if(n<6) return 0;
    
    int count = 0;
    for(int i= 1;i*i<=n;i++)
    {
        for(int j = 1;j*j<=n;j++)
        {
            for(int k = 1;k*k<=n;k++)
            {
                if( (i*i + j*j + k*k + i*j + i*k + j*k) == n)
                count++;
                if((i*i + j*j + k*k + i*j + i*k + j*k)> n) break;
            }
            if( (i*i + j*j + i*j) >= n) break;
        }
    }
    return count;
}
int main() 
{
    //for fast input/output
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t =1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        
        for(int i=1;i<=n;i++)
        {
            cout<<find(i)<<"\n";
        }
    }
	
	return 0;
}


Measured memory_bytes: 3576
class UnionFind
  attr_accessor :parent, :rank
  
  def initialize(n)
    @parent = []
    @rank = []
    n.times do |i|
      @parent[i] = i
      @rank[i] = 0
    end
  end

  def find(x)
    if @parent[x] == x
      return x
    else
      return @parent[x] = find(@parent[x])
    end
  end

  def unite(x,y)
    x,y = find(x),find(y)
    return if x==y

    x,y = y,x if @rank[x] < @rank[y]
    @rank[x] += 1 if @rank[x] == @rank[y]
    @parent[y] = x
  end
end

n,m = gets.split.map(&:to_i)
tree = UnionFind.new(n+1)

m.times do
  x,y,z = gets.split.map(&:to_i)
  tree.unite(x,y)
end

parents = [0]*(n+1)
1.upto(n) do |i|
  parents[tree.find(i)] += 1
end
ans = 0
parents.each do |v|
  ans += 1 if v > 0
end
p ans


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

using namespace std;

#define ll long long
#define ld long double

// 下凸関数f(x)の[mn, mx]での最小値を与えるxを求める.
ld TernarySearch(ld(*f)(ld), ld mn, ld mx) {
	ld e = 1e-10; // 許容誤差
	while (mx - mn > e) {
		ld mid_l = (mx / 3) + ((2 * mn) / 3);
		ld mid_r = ((2 * mx) / 3) + (mn / 3);
		if (f(mid_l) >= f(mid_r))
			mn = mid_l;
		else
			mx = mid_r;
	}
	return mx;
}

ld p[6], q[6];

ld pro(ld r) {
	assert(0 <= r && 1.0 >= r);
	ld prob = 0.0;
	for (int i = 0; i < 6; ++i) {
		prob += max(r * p[i], (1.0 - r) * q[i]);
	}
	return prob;
}

signed main() {
	for (int i = 0; i < 6; ++i) {
		cin >> p[i];
		p[i] /= 100.0;
	}
	for (int i = 0; i < 6; ++i) {
		cin >> q[i];
		q[i] /= 100.0;
	}

	cout << setprecision(11) << pro(TernarySearch(pro, 0.0, 1.0)) << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

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

    int k,n;cin >> k >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    a.emplace_back(a[0]+k);

    int ans = k;
    for(int i=0;i<n;i++){
        chmin(ans,k-(a[i+1]-a[i]));
    }
    cout << ans << newl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100000
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

dll a[N_MAX];
int n, m;

int i, j, k;

void deb(){
	return;
}

ull abs(dll n){
	return (ull)((n > 0) ? n : -n);
}

void solve(){
	dll result = 0;
	dll total = 0;
	dll rangetot = 0;
	for (i = 0; i < n; i++) {
		if (a[i] >= 0) total += a[i];
	}
	for (i = 0; i < k; i++) {
		if (a[i] >= 0) total -= a[i];
		rangetot += a[i];
	}

	// puts("deb line B");

	while (i <= n) {
		ull candid;
		candid = total;
		if (rangetot > 0) candid += rangetot;
		if (result < candid) result = candid;

		if (a[i-k] >= 0) total += a[i-k];
		rangetot -= a[i-k];
		if (a[i] >= 0) total -= a[i];
		rangetot += a[i];
		i++;
	}

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

int main (void) {
	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);

		// puts("deb line A");

	solve();
	return 0;
}




Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

void rec(vector<int> &x, map<vector<int>, int> &mp)
{
  queue<vector<int>> que;
  que.emplace(x);
  while (!que.empty())
  {
    vector<int> a = que.front();
    que.pop(); 
    int cou = mp[a];
    if(cou == 4) continue;
    for (int i = 0; i < a.size(); i++)
    {
      for (int j = i + 1; j < a.size(); j++)
      {
        reverse(a.begin() + i, a.begin() + j + 1);
        auto ite = mp.find(a);
        if (ite == mp.end())
        {
          mp[a] = cou + 1;
          if(cou + 1 < 4)
          que.emplace(a);
        }
        reverse(a.begin() + i, a.begin() + j + 1);
      }
    }
  }
}

int n;
int main()
{
  cin >> n;
  vector<int> a(n);
  vector<int> sorted(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++)
  {
    sorted[i] = i;
  }

  map<vector<int>, int> mp_sorted, mp_a;
  mp_sorted[sorted] = 0;
  mp_a[a] = 0;
  rec(sorted, mp_sorted);
  rec(a, mp_a);
  int result = n - 1;
  do
  {
    auto ite = mp_sorted.find(sorted);
    auto ite2 = mp_a.find(sorted);
    if (ite != mp_sorted.end() && ite2 != mp_a.end())
    {
      result = min(result, ite->second + ite2->second);
    }
  } while (next_permutation(sorted.begin(), sorted.end()));
  cout << result << endl;
}



Measured memory_bytes: 66844
#include<stdio.h>

int main ()
{
	long long int N,K,c=0,i,h[100000]; 
	scanf("%lld%lld",&N,&K);
	
	
	for(i=0;i<N;i++)
	{
		scanf("%lld",&h[i]);
		if(h[i]>=K)
		{
			c++;
		}
	}
	printf("%lld\n",c);
	return 0;
	
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli N,A,C=0,B,D=0;
  string S;
  cin >> A;
  cin >> S;
  vector<int>P(26,0),Q(26,0);
  for(int i=1;i<A-1;i++){
    D=0;
    rep(j,26){
      P[j]=0;
      Q[j]=0;
    }
    rep(j,i)P[S[j]-97]=1;
    for(int j=i;j<A;j++)Q[S[j]-97]=1;
    rep(j,26)if(P[j]==1&&Q[j]==1)D++;
    C=max(C,D);
  }
  Out(C);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1000010];
int dp2[1000010];

signed main() {
	int n;
	rep(i, 0, 1000010) {
		dp[i] = 10;
		dp2[i] = 10000000;
	}
	dp[0] = 0;
	dp2[0] = 0;
	rep(i, 1, 200) {
		int a = i*(i + 1)*(i + 2) / 6;
		if (a > 1000000) break;
		rep(j, 0, 1000001) {
			if (j + a > 1000000) break;
			dp[j + a] = min(dp[j + a], dp[j] + 1);
			if (a % 2 == 0) continue;
			dp2[j + a] = min(dp2[j + a], dp2[j] + 1);
		}
	}
	while (cin >> n && n) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

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

int main(){
  string s;
  cin >>s;
  int t=s.size();
  int p=0;
  for(int i=0;i<t;i++){
    p+=s[i]-'0';
  }
  if(p%9==0) cout <<"Yes" <<endl;
  else  cout <<"No" <<endl;
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	n = s.size();
	rep(i, n){
		if(i%2 == 0){
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 5;
int a[N];

int main()
{
	int n;
	cin >> n;
	int t = 1,sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] == t){
			t++;
			sum++;
		}
	}
	if(t == 1)
		cout << -1 << endl;
	else
		cout << n - sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<double,int> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

int N,K;
int A[200000];

int cut(int X){
    int res=0;
    rep(i,N) res+=(A[i]-1)/X;
    return res; 
}

int main(){
    cin>>N>>K;
    rep(i,N) cin>>A[i];

    int l=0,  r=1000000000;
    while(r-l>1){
        int X=(l+r)/2;
        int cnt=cut(X);
        if(cnt<=K) r=X;
        else l=X;
    }

    int ans=r;
    cout<<ans<<endl;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
   vector<int> vec;
   int n;
   cin>>n;
   int k;
   for(int i=0;i<n;i++){
    cin>>k;
    vec.push_back(k);

   }
   sort(vec.begin(),vec.end());
   int l=1;
   for(int i=0;i<n-1;i++){
    if(vec[i]==vec[i+1])
    {
        l=0;
        break;
    }
   }
   if(l)
    cout<<"YES";
   else cout<<"NO";

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)


int32_t main() { 
    boost;
    int n,k;
    cin>>n>>k;
    int a[n+1]={0};
    for(int i=0;i<k;i++){
    	int d,tmp;
    	cin>>d;
    	for(int j=0;j<d;j++){
    		cin>>tmp;
    		a[tmp]++;
    	}
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    	ans+=(a[i]==0);
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
/*      ***    BE GOOD DO GOOD    ***         */



#include<bits/stdc++.h>

using namespace std;

#define LL long long int
#define D double
#define ULL unsigned
#define PI 2.0*acos(0.0)
#define sz size()
#define PB push_back
#define NL printf("\n")
#define CHR getchar()
#define SQR(n) (n*n)
#define xx first
#define yy second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define all(a) a.begin(),a.end()
#define end return 0
#define N 2000001



int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int x=max(c,max(a,b));
    int y=min(c,min(a,b));
    int z;
    if(a==x||a==y&&b==x||b==y)
    {
         z=c;
    }
    if(a==x||a==y&&c==x||c==y)
    {
        z=b;
    }
    if(c==x||x==y&&b==x||b==y)
    {
        z=a;
    }
    cout<<abs((x-z)+(z-y))<<endl;
    return 0;

}


Measured memory_bytes: 256