akhauriyash/Code-Regression huggingface dataset:
while True:
    mid, fin, make = list(map(int, input().split()))
    if mid == -1 and fin == -1 and make == -1:
        break
    
    sum = mid + fin
    if mid == -1 or fin == -1 or sum < 30:
        print("F")
    elif sum >= 80:
        print("A")
    elif sum >= 65:
        print("B")
    elif sum >= 50 or (sum >= 30 and make >= 50):
        print("C")
    else:
        print("D")



Measured memory_bytes: 5596
import java.util.*;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mochiCount = sc.nextInt();
        Set<Integer> mochiSet = new HashSet<>();
        for (int i = 0; i < mochiCount; i++) {
            mochiSet.add(sc.nextInt());
        }
        System.out.println(mochiSet.size());
    }
}


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

void trace(int A[], int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

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

  bool flag = 1;
  int c = 0;
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = N-1; j >= i+1; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        c++;
      }
      flag = 1;
    }
  }
  trace(A, N);
  cout << c << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
double N, M;
int A;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> S;
    int i = S.length();
    while (i!=0){
        if(S.substr(i-5,5) == "erase")i-=5;
        else if(S.substr(i-5,5) == "dream")i-=5;
        else if( S.substr(i-6,6) == "eraser")i-=6;
        else if (S.substr(i-7,7) == "dreamer")i-=7;
        else {
            PRI("NO")
            return 0;
        }
    }
    PRI("YES")
    return 0;

}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline


class Node():
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right


N = int(input())
btree = [Node(-1, -1, -1) for i in range(N)]
root_cand_list = [i for i in range(N)]
depth = [-1 for i in range(N)]
height = [-1 for i in range(N)]
degree = [0 for i in range(N)]
sibling = [-1 for i in range(N)]


def main():

    for i in range(N):
        num, left, right = map(int, input().split())

        if left != -1:
            btree[num].left = left
            btree[left].parent = num
            root_cand_list.remove(left)
        if right != -1:
            btree[num].right = right
            btree[right].parent = num
            root_cand_list.remove(right)

    setDepth(root_cand_list[0], 0)
    setHeight(root_cand_list[0])
    showBTree()


def setDepth(num, d):
    depth[num] = d
    node = btree[num]
    dgr = 0
    if node.left != -1:
        setDepth(node.left, d + 1)
        dgr += 1
    if node.right != -1:
        setDepth(node.right, d + 1)
        dgr += 1

    if node.parent != -1:
        parent = btree[node.parent]
        if parent.left != -1 and parent.left != num:
            sibling[num] = parent.left
        elif parent.right != -1 and parent.right != num:
            sibling[num] = parent.right

    degree[num] = dgr


def setHeight(num):
    lh = 0
    rh = 0
    if btree[num].left != -1:
        lh = setHeight(btree[num].left)
    if btree[num].right != -1:
        rh = setHeight(btree[num].right)

    if btree[num].left == -1 and btree[num].right == -1:
        # 葉についた時
        height[num] = 0
        h = 1
    else:
        height[num] = max(lh, rh)
        h = max(lh, rh) + 1
    return h


def showBTree():
    for i in range(N):
        if depth[i] == 0:
            TYPE = "root"
        elif height[i] == 0:
            TYPE = "leaf"
        else:
            TYPE = "internal node"

        print("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(i, btree[i].parent, sibling[i], degree[i], depth[i], height[i], TYPE))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
def modpow(a, b, mod=10 ** 9 + 7):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


def modcomb(n, c, mod=10 ** 9 + 7):
    if c > n - c:
        c = n - c
    u, d = 1, 1
    for i in range(c):
        u = u * (n - i) % mod
        d = d * (i + 1) % mod
    return u * modpow(d, mod - 2) % mod


mod = 10 ** 9 + 7
n, a, b = map(int, input().split())
print((modpow(2, n) - modcomb(n, a) - modcomb(n, b) - 1) % mod)


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

int main(){
    int Route,Time_l1,Time_l2,Time,Cost,Cost_min;
    cin>>Route>>Time_l1;
    Time_l2=Time_l1;
    Cost_min=1001;
    for(int i=0;i<Route;i++){
        cin>>Cost>>Time;
        if(Time_l2>=Time&&Cost_min>Cost){
            Cost_min=Cost;
            Time_l1=Time;
        }
    }
    if(Cost_min==1001||Time_l1>Time_l2){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<Cost_min<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N,K;
char s[60];
void solve(){
  K--;
  if(s[K]=='A') s[K]='a';
  else if(s[K]=='B') s[K]='b';
  else s[K]='c';
}
int main(){
  cin>>N>>K;
  rep(i,N) cin>>s[i];
  solve();
  rep(i,N) std::cout<<s[i];
  std::cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Ans = 1000000000;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A, count = 0;
    cin >> A;
    
    for (; A % 2 == 0; count++) 
      A /= 2;
  
   /* cout << count << endl; */
   
    if (Ans >= count)
      Ans = count;
  }
  
  cout << Ans << endl;
}

Measured memory_bytes: 256
s = input()
count = 0
if s[0]=="R":
    count += 1
    if s[1] == "R":
        count +=1
        if s[2]=="R":
            count +=1
else:
    if s[1]=="R":
        count += 1
        if s[2]=="R":
            count +=1
    else:
        if s[2]=="R":
            count +=1
print(count)

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    rep(i, N) cin >> H[i];

    sort(H.begin(), H.end(), greater<int>());
    long long sum = 0;
    for(int i = K; i < N; i++) sum += H[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())

hiroshi = h1 * a + (h1//10) * c + h2 * b + (h2//20) * d
kenjiro = k1 * a + (k1//10) * c + k2 * b + (k2//20) * d

if hiroshi > kenjiro:
  print("hiroshi")
elif hiroshi < kenjiro:
  print("kenjiro")
else:
  print("even")


Measured memory_bytes: 5596
#include<cstdio>

int main(){
	int A, B, C, K;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	if(K < A) printf("%d\n", K);
	else if(K <= A + B) printf("%d\n", A);
	else printf("%d\n", A - (K - (A + B)));
	return 0;
}

Measured memory_bytes: 1728
<?php
	function toHMS($second){
		$s = $second % 60;
		$m = (($second - $s) / 60) % 60;
		$h = ($second - 60 * $m - $s) / 3600;
		return $h. ':'. $m. ':'. $s;
	}
	
	echo toHMS(trim(fgets(STDIN))). "\n";

Measured memory_bytes: 15108
/*ex3_3
series2*/
 
# include <stdio.h>
int main(void){
      //各文字の箱を作って読み取り
    int N,K;
    scanf("%d %d", &N,&K);
    int i=0;//桁数
    int j=1;//現在の調べている位を十進法で表した時の値
    while(j<=N){
        //現在の調べている位を十進法で表した時の値が調べている数字Nを超えたとき、その時のiは桁数になる。
        j=j*K;
        i ++;
    }
    printf("%d\n",i);
    return 0;
}

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

#define int long long

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

  int N;
  cin >> N;

  using P = pair<int, int>;
  vector<P> A(N);
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    A[i] = P(a, i);    
  }

  sort(A.begin(), A.end());
  for ( int i = 0; i < N; i++ ) {
    cout << A[i].second+1 << " ";
  }

  cout << endl;
  
  return 0;
}


Measured memory_bytes: 2432
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

ans = 0
for i, x in enumerate(A):
    if i % 2 == 0 and x % 2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 9108
#include <stdio.h>

int main( void )
{

	unsigned char ubW_Ddice1[ 6 ];
	unsigned char ubW_Ddice2[ 6 ];
	unsigned char ubW_Dtrade;
	unsigned char ubW_Dcalc;
	unsigned char ubW_Ci;

	for( ubW_Ci = 0; ubW_Ci < 6; ubW_Ci++ ) {
		scanf("%d",&ubW_Ddice1[ubW_Ci]);
	}
	for( ubW_Ci = 0; ubW_Ci < 6; ubW_Ci++ ) {
		scanf("%d",&ubW_Ddice2[ubW_Ci]);
	}

	for( ubW_Ci = 1; ubW_Ci <= 6; ubW_Ci++ ){
		ubW_Dcalc = ubW_Ci % 2;
		/*????????¢??¨????????¢?????°?????????????????£????????¨????????¢????????????*/
		switch( ubW_Dcalc ){
		case 0:/*??¶??°???????????¢*/
			ubW_Dtrade = ubW_Ddice2[ 0 ];
			ubW_Ddice2[ 0 ] = ubW_Ddice2[ 2 ];
			ubW_Ddice2[ 2 ] = ubW_Ddice2[ 5 ];
			ubW_Ddice2[ 5 ] = ubW_Ddice2[ 3 ];
			ubW_Ddice2[ 3 ] = ubW_Dtrade;
			break;
		case 1:/*?\???°???????????¢*/
			ubW_Dtrade = ubW_Ddice2[ 0 ];
			ubW_Ddice2[ 0 ] = ubW_Ddice2[ 1 ];
			ubW_Ddice2[ 1 ] = ubW_Ddice2[ 5 ];
			ubW_Ddice2[ 5 ] = ubW_Ddice2[ 4 ];
			ubW_Ddice2[ 4 ] = ubW_Dtrade;
			break;
		default:
			break;
		}

		/*?????¢??¨?????¢????????´??????????????????????????¨????????´??¢??????????????????????????????*/
		if( ( ubW_Ddice1[ 0 ] == ubW_Ddice2[ 0 ] ) && ( ubW_Ddice1[ 5 ] == ubW_Ddice2[ 5 ] ) ){
			if( ( ubW_Ddice1[ 1 ] == ubW_Ddice2[ 1 ] ) && ( ubW_Ddice1[ 2 ] == ubW_Ddice2[ 2 ] ) ){
				if( ( ubW_Ddice1[ 4 ] == ubW_Ddice2[ 4 ] ) && ( ubW_Ddice1[ 3 ] == ubW_Ddice2[ 3 ] ) ){
					printf("Yes\n");
					return 0;
				}
			}else if( ( ubW_Ddice1[ 1 ] == ubW_Ddice2[ 2 ] ) && ( ubW_Ddice1[ 2 ] == ubW_Ddice2[ 4 ] ) ){
				if( ( ubW_Ddice1[ 4 ] == ubW_Ddice2[ 3 ] ) && ( ubW_Ddice1[ 3 ] == ubW_Ddice2[ 1 ] ) ){
					printf("Yes\n");
					return 0;
				}
			}else if( ( ubW_Ddice1[ 1 ] == ubW_Ddice2[ 4 ] ) && ( ubW_Ddice1[ 2 ] == ubW_Ddice2[ 3 ] ) ){
				if( ( ubW_Ddice1[ 4 ] == ubW_Ddice2[ 1 ] ) && ( ubW_Ddice1[ 3 ] == ubW_Ddice2[ 2 ] ) ){
					printf("Yes\n");
					return 0;
				}
			}else if( ( ubW_Ddice1[ 1 ] == ubW_Ddice2[ 3 ] ) && ( ubW_Ddice1[ 2 ] == ubW_Ddice2[ 1 ] ) ){
				if( ( ubW_Ddice1[ 4 ] == ubW_Ddice2[ 2 ] ) && ( ubW_Ddice1[ 3 ] == ubW_Ddice2[ 4 ] ) ){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");

	return 0;
}

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

int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F ;
  set<int> water, sugar;
  for(int i=0;i<=35;i++){
    for(int j=0;j<=35;j++){
      int tmp = 100*(A*i + B*j);
      if(tmp <= F){
        water.insert(tmp);
      }
    }
  }
  for(int i=0;i<=F;i++){
    for(int j=0;j<=F;j++){
      int tmp = C*i + D*j;
      if(tmp <= F){
        sugar.insert(tmp);
      }
    }
  }
  double max_cct = E/(double)(E+100);
  double cct = -1;
  int res1,res2;
  for(int w : water){
    for(int s : sugar){
      double sum = s+w;
      if(sum != 0 && s/sum <= max_cct && sum <= F && s/sum > cct){
        cct = s/sum;
        res1 = sum;
        res2 = s;
      }
    }
  }
  cout << res1 << " " << res2 << endl;
  return 0;
}

Measured memory_bytes: 384
using System;

namespace abc125A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            double D = C + 0.5;
            int i = 0;
            while (A * i < D)
            {
                i++;
            }
            int E = (i-1) * B;
            Console.WriteLine(E);
        }
    }
}


Measured memory_bytes: 11092
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint64_t nextplong(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int pnt[1002][3];
double dist(const int i, const int j){
	double l=hypot(pnt[i][0]-pnt[j][0], pnt[i][1]-pnt[j][1])-(pnt[i][2]+pnt[j][2]);
	return l>0?l:0;
}
double d[1002];
int q[1002], Q;
int main(void){
	int n;
	scanf("%d%d", &pnt[0][0], &pnt[0][1]);
	scanf("%d%d", &pnt[1][0], &pnt[1][1]);
	d[1]=DBL_MAX;
	q[0]=0;
	q[1]=1;
	scanf("%d", &n);
	for(int i=2; i<n+2; i++){
		scanf("%d%d%d", &pnt[i][0], &pnt[i][1], &pnt[i][2]);
		d[i]=DBL_MAX;
		q[i]=i;
	}
	Q=n+2;
	while(Q>0){
		double min=d[q[0]]; int mini=0;
		for(int i=1; i<Q; i++){
			if(d[q[i]]<min){mini=i; min=d[q[i]];}
		}
		int k=q[mini]; q[mini]=q[Q-1]; Q--;
		for(int i=0; i<Q; i++){
			double D=d[k]+dist(k, q[i]);
			if(D<d[q[i]]) d[q[i]]=D;
		}
	}
	printf("%.10lf\n", d[1]);
}


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

int lower_bound( int* a, int n , int v )
{
    int left = 0, right = n;

    if( a[n-1] < v )                            // 存在しない場合
        return n;

    while( left < right )
    {
        int mid = ( left + right ) / 2;
        if( a[mid] > v )
            right = mid;
        else if( a[mid] < v )
            left = mid + 1;                     // midではなくて、mid+1
        else
        {
            while( mid >= 0 && a[mid] == v )    //同じ数字が並んでいる場合、一番最初の要素を返す
                mid--;
            return mid + 1;
        }
    }

    if( a[left] < v )
        return left + 1;
    else
        return left;
}

int upper_bound( int* a, int n , int v )
{
    int left = 0, right = n;

    if( a[n-1] < v )                            // 存在しない場合
        return n;

    while( left < right )
    {
        int mid = ( left + right ) / 2;
        if( a[mid] > v )
            right = mid;
        else if( a[mid] < v )
            left = mid + 1;                     // midではなくて、mid+1
        else
        {
            while( mid < n  && a[mid] == v )    //同じ数字が並んでいる場合、一番最初の要素を返す
                mid++;
            return mid;
        }
    }

    if( a[left] < v )
        return left + 1;
    else
        return left;
}

int main()
{
    int n, q, v;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];
    
    cin >> q;

    for( int i = 0; i < q; i++ )
    {
        cin >> v;
        cout << lower_bound( a, n, v ) << " " << upper_bound( a, n, v ) << endl;
    }

    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
int l,n;
int pos1[Maxn],pos2[Maxn];
long long sum1[Maxn],sum2[Maxn];
int main()
{
    scanf("%d%d",&l,&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&pos1[i]);
        pos2[i]=l-pos1[i];
    }
    for (int i=1;i<=n;i++)
        sum1[i]=sum1[i-1]+pos1[i];
    for (int i=n;i;i--)
        sum2[i]=sum2[i+1]+pos2[i];
    long long ans=0LL;
    for (int i=1;i<=n;i++)
    {
        long long tmp=pos1[i];
        int num1=i-1,num2=n-i;
        if (num2>num1+1) num2=num1+1; else if (num2<num1) num1=num2;
        tmp+=2LL*(sum1[i-1]-sum1[i-1-num1]+sum2[i+1]-sum2[i+num2+1]);
        ans=max(ans,tmp);
    }
    for (int i=1;i<=n;i++)
    {
        long long tmp=pos2[i];
        int num1=i-1,num2=n-i;
        if (num1>num2+1) num1=num2+1; else if (num1<num2) num2=num1;
        tmp+=2LL*(sum1[i-1]-sum1[i-1-num1]+sum2[i+1]-sum2[i+num2+1]);
        ans=max(ans,tmp);
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i=0;i<N;i++)cin >> p[i];
    sort(p.begin(),p.end());
    ll sum = 0;
    for(int i=0;i<K;i++)sum += p[i];
    cout << sum;


}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=12e4;

int a[N],n,k;
int cal(int l,int r){
	if(l+n-r>k)return 0;
	vector<int>v;
	for(int i=0;i<l;i++)
		v.push_back(a[i]);
	for(int i=r;i<n;i++)
		v.push_back(a[i]);
	sort(v.begin(),v.end(),greater<int>());
	int t=min(int(v.size()),k-l-n+r);
	for(int i=0;i<t;i++)
		if(v.back()<0)v.pop_back();
	int ans=0;
	for(int x:v)ans+=x;
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int l=0;l<=n;l++)
		for(int r=l;r<=n;r++)
			ans=max(ans,cal(l,r));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
const int MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	int sqrt_n = sqrt(n);
	bool p[1001] = {false, false};
	fill(p+2, p+n+1, true);
	for (int i = 2; i <= sqrt_n; i++) {
		if (p[i]) for (int j = 2*i; j <= n; j += i) {
			p[j] = false;
		}
	}

	long long ans = 1;
	for (int i = 2; i <= n; i++) {
		if (p[i]) {
			long long x = 1;
			for (int j = 1; n >= pow(i,j); j++) {
				x += n / pow(i,j);
			} 
			ans = (ans * x) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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 ll;

const long long INF = 1LL << 60;

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

    double ans = 0;
    rep(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        }
        else {
            ans += x * 380000.0;
        }
    }

    cout << fixed << setprecision(5) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
pushed = [False] * n
cnt = 0
index = 0
while not (pushed[index]):
    cnt += 1
    pushed[index] = True
    if index == 1:
        cnt -= 1
        print(cnt)
        exit()
    index = a[index] - 1
print(-1)

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int N; cin >> N;
    string S; cin >> S;
    ll r = 0, g = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') r++;
        else if (S[i] == 'G') g++;
        else if (S[i] == 'B') b++;
    }
 
    ll cnt = r*g*b;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) {
                continue;
            }
            cnt --;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    long long n;
    cin >> n;
    int ans = 0;
    for (long long p = 2; p <= sqrt(n) + 10; p ++)
    {
        if (n % p == 0)
        {
            long long v = p;
            for (int e = 1; e <= 100000; e++)
            {
                if (n % v == 0)
                {
                    n /= v;
                    ans ++;
                }
                else
                    break;
                v *= p;
            }

            while (n % p == 0)
                n /= p;
        }
    }
    if (n > 1)
        ans ++;
    cout << ans;
    return 0;
}

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

using namespace std;
long int n,k;
unsigned long long int a[200002]={1};
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=k+1;i<=n;i++)
    {
        if(a[i]>a[i-k])
        {
             cout<<"Yes \n";
        }
        else
        {
            cout<<"No \n";
        }
    }
}


Measured memory_bytes: 5128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		System.out.println((a+b+1)/2);

	}

}


Measured memory_bytes: 35764
//D
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF=(int)2e9;
const double PI=(double)acos(-1.0);
const double EPS=(double)1e-9;
const ll MOD=(ll)1e9+7;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define FOR(i,n) REP(i,0,n-1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FORD(i,n) REV(i,n-1,0)

inline void swapp(int &a, int &b){
	a^=b^=a^=b;
}

int n,dat[100005],res=0;

int main(){
	scanf("%d",&n);
	REP(i,1,n)scanf("%d",dat+i);
	dat[0]=1; dat[n+1]=n;
	REP(i,1,n) if(dat[i]==i)swapp(dat[i],dat[i+1]),res++;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 640
f = list(map(int, input().split()))
q = int(input())
for i in range(q):
	a = list(map(int, input().split()))
	if a in [[f[0], f[1]], [f[1], f[5]], [f[5], f[4]], [f[4], f[0]]]:
		print(f[2])
	elif a in [[f[0], f[2]], [f[2], f[5]], [f[5], f[3]], [f[3], f[0]]]:
		print(f[4])
	elif a in [[f[0], f[4]], [f[4], f[5]], [f[5], f[1]], [f[1], f[0]]]:
		print(f[3])
	elif a in [[f[0], f[3]], [f[3], f[5]], [f[5], f[2]], [f[2], f[0]]]:
		print(f[1])
	elif a in [[f[1], f[2]], [f[2], f[4]], [f[4], f[3]], [f[3], f[1]]]:
		print(f[0])
	elif a in [[f[1], f[3]], [f[3], f[4]], [f[4], f[2]], [f[2], f[1]]]:
		print(f[5])



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n, k; cin >> n >> k;
  ll s; cin >> s;
  vector<ll> res(n, 0);
  rep(i, k)res[i] = s;
  for(int i = k; i < n; i++){
    if(s > n)res[i] = 1;
    else res[i] = inf - 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2176
n,t=map(int,input().split())
a=list(map(int,input().split()))


diff_v=0
max_a_v=0
max_a_pos=[]
aa=set([])
bb=set([])

for i in range(1,len(a)):
    index=len(a)-i-1
    if max_a_v<a[index+1]:
        max_a_v=a[index+1]
        max_a_pos=[index+1]
    elif max_a_v==a[index+1]:
        max_a_pos.append(index+1)

    if max_a_v-a[index]>diff_v:
        diff_v=max_a_v-a[index]
        aa=set([index])
        bb=set(max_a_pos)
    elif max_a_v-a[index]==diff_v:
        aa.add(index)
        bb|=set(max_a_pos)
    #print(a[index],max_a_v,diff_v,aa,bb)

print(min(len(list(aa)),len(list(bb))))


    

    




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

int main() {
  string n;
  cin>>n;
  if(n.size()==2) {
    cout<<n<<endl;
  }
  else if(n.size()==3) {
    cout<<n.at(2)<<n.at(1)<<n.at(0)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string s;
int r[4005],g[4005],b[4005];
ll ans;
int main(void){
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            r[i]=1;
        }else if(s[i]=='G'){
            g[i]=1;
        }else{
            b[i]=1;
        }
    }
    for(int i=s.size()-2;i>=0;i--){
        r[i]=r[i+1]+r[i];
        g[i]=g[i+1]+g[i];
        b[i]=b[i+1]+b[i];
    }
    for(int i=0;i<s.size()-1;i++){
        for(int j=i+1;j<s.size();j++){
            if((s[i]=='R'&&s[j]=='G')||(s[j]=='R'&&s[i]=='G')){
                if(j+j-i<s.size()){
                    if(s[j+j-i]=='B'){
                        ans+=b[j+1]-1;
                    }else{
                        ans+=b[j+1];
                    }
                }else{
                    ans+=b[j+1];
                }
            }else if((s[i]=='G'&&s[j]=='B')||(s[j]=='G'&&s[i]=='B')){
                if(j+j-i<s.size()){
                    if(s[j+j-i]=='R'){
                        ans+=r[j+1]-1;
                    }else{
                        ans+=r[j+1];
                    }
                }else{
                    ans+=r[j+1];
                }
            }else if((s[i]=='B'&&s[j]=='R')||(s[j]=='B'&&s[i]=='R')){
                if(j+j-i<s.size()){
                    if(s[j+j-i]=='G'){
                        ans+=g[j+1]-1;
                    }else{
                        ans+=g[j+1];
                    }
                }else{
                    ans+=g[j+1];
                }
            }
        }
    }
    cout<<ans<<endl;
	
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
 int main() {
 	ll l,r;
 	cin >>l>>r;
 	if ((r-l)>=2019){
 		cout << 0;
 		return 0;
 	}
 	l=l%2019;
 	r=r%2019;
 
 	ll ans;
 	ll modans=LLONG_MAX;
 	for (ll x=l;x<r;x++){
		for (ll y=x+1;y<=r;y++){
			ans=(x*y);
			modans=min(modans,(ans%2019));
		}
 	}
 	cout << modans;
 }

Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <vector>
#include <queue>
#include <algorithm>        // max()

using namespace std;

static const int MAX_N = 100000;
static const int INFTY = (1 << 30);

class edge
{
public:
	int t, w;
	edge() {}
	edge(int t, int w): t(t), w(w) {}
};

vector<edge> G[MAX_N];
int n;
int d[MAX_N];

bool vis[MAX_N];
int count;

void
bfs(int s)
{
	for (int i = 0; i < n; ++i)
		d[i] = INFTY;

	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	while(!Q.empty())
	{
		int u = Q.front(); Q.pop();
		for (unsigned int i = 0; i < G[u].size(); ++i)
		{
			edge e = G[u][i];
			if (d[e.t] == INFTY)
			{
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

int
solve()
{
	// ??????????????? s ???????????????????????? tgt ????±???????
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (d[i] != INFTY && d[i] > maxv)
		{
			maxv = d[i];
			tgt = i;
		}
	}

	// tgt ????????????????????????????????¢ maxv ????±???????
	bfs(tgt);
	maxv = 0;
	for (int i = 0; i < n; ++i)
		if (d[i] != INFTY)
			maxv = max(maxv, d[i]);

	return maxv;
}

int
main(int argc, char** argv)
{
	int s, t, w;

	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		scanf("%d %d %d", &s, &t, &w);
		G[s].push_back(edge(t, w));
		G[t].push_back(edge(s, w));
	}

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

Measured memory_bytes: 9552
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x = ii()
while 1:
    cnt = 0
    for i in range(2,math.ceil(x**(1/2)),1):
        if x % i == 0:
            cnt = 1
            break
    if cnt == 0:
        print(x)
        exit()
    x += 1

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>

vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char> > s(h + 2, vector<char>(w + 2, '#'));

	pii start, goal;
	int dir;
	rep1 (i, h) {
		rep1 (j, w) {
			cin >> s[i][j];
			if (s[i][j] != '#' and s[i][j] != '.') {
				if (s[i][j] == 'G') {
					goal = pii(i, j);
				}
				else {
					start = pii(i, j);
					if (s[i][j] == '^') dir = 0;
					else if (s[i][j] == '<') dir = 1;
					else if (s[i][j] == 'v') dir = 2;
					else if (s[i][j] == '>') dir = 3;
				}
			}
		}
	}

	vector<vii> used(h + 2, vii(w + 2, vi(4)));
	pii now = start;
	bool is_goal = false;
	while (not used[now.first][now.second][dir]) {		
		int y = now.first, x = now.second;
		// cout << now.first << " " << now.second << " " << dir << endl;
		used[y][x][dir] = true;
		if (s[y][x] == 'G') {
			is_goal = true;
			break;
		}
		bool flag = false;
		for (int add = -1; add < 3; add++) {
			int ndir = (dir + add + 4) % 4;
			int ny = y + dy[ndir], nx = x + dx[ndir];
			if (s[ny][nx] == '#') continue;
			flag = true;
			now = pii(ny, nx);
			dir = ndir;
			break;
		}
		if (not flag) {
			break;
		}
	}
	if (not is_goal) {
		cout << -1 << endl;
		return 0;
	}
	int cnt = 0;
	rep1 (i, h) {
		rep1 (j, w) {
			bool arrived = false;
			rep (k, 4) {
				arrived |= used[i][j][k];
			}
			cnt += arrived;
		}
	}
	cout << cnt << endl;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

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

	int n, x, t;
	cin >> n >> x >> t;
	int ans = t * ((n + x - 1) / x);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    int ans = 0, cnt = 0;
    rep(i,n){
        if(i == p[i]){
            cnt++;
        }
        else{
            ans += (cnt+1)/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] accumulated = new long[n];
            for (int i = 0; i < n; i++) {
                long previous = (i > 0) ? accumulated[i - 1] : 0L;
                accumulated[i] = previous + in.nextLong();
            }
            long min = Long.MAX_VALUE;
            for (int i = 0; i < n - 1; i++) {
                long newTotal = Math.abs(2 * accumulated[i] - accumulated[n - 1]);
                min = min < newTotal ? min : newTotal;
            }

            out.println(min);
        }

    }
}



Measured memory_bytes: 79536
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int a, b;
    cin >> a >> b;

    cout << (a ^ b) << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int n;
    long double t[100][8];
    long double ab, cd;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 8; j++){
            cin >> t[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        ab = (t[i][1]-t[i][3])*(t[i][4]-t[i][6]);
        cd = (t[i][5]-t[i][7])*(t[i][0]-t[i][2]);
        if(t[i][0] == t[i][2]){
            if(t[i][4] == t[i][6]){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
        }
        else if(t[i][1] == t[i][3]){
            if(t[i][5] == t[i][7]){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
        }
        else if(ab == cd){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}

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

int main() {
    int N, p, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> p;
        if (p == i) {
            ans++; i++;
            cin >> p;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, l, r, A;
  cin >> N;
  A = 0;
  for (int i=0 ; i<N ; i++){
    cin >> l >> r ;
    A = A + (r-l+1);
  }
  cout << A;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    forn(i, 0, n) cin >> a[i];
    vector<ll> pos(n), neg(n);
    forn(i, 0, n) {
        if (i) {
            pos[i] = pos[i - 1];
            neg[i] = neg[i - 1];
        }
        (a[i] >= 0 ? pos : neg)[i] += a[i];
    }
    ll ans = 0;
    for (int i = 0; i + k <= n; ++i) {
        ll x1 = i ? pos[i - 1] : 0;
        ll x2 = pos[n - 1] - pos[i + k - 1];
        ll x3 = pos[i + k - 1] + neg[i + k - 1] - (i ? pos[i - 1] + neg[i - 1] : 0);
        if (x3 < 0) x3 = 0;
        ans = max(ans, x1 + x2 + x3);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 100; 
const double pi = acos(-1.0);

inline ll read()
{
    ll kk=0,f=1;
    char cc=getchar();
    while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
    while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
    return kk*f;
}

ll a[maxn],aa[maxn],num[maxn] = {0};
ll sum[maxn],s=0,ans;
int main(void)
{
	ll n,tp,cnt=0;
	n =read();
	for(int i=0;i<n;i++)
	{
		tp =read();	
		a[i]=tp;	
		if(num[tp]==0)aa[cnt++]=tp;
		num[tp]++;
	}

	for(int i=0;i<cnt;i++)
	{
	//	printf("num[%d]:%d\n",aa[i],num[aa[i]]);	
		if(num[aa[i]]<2)continue;
		if(num[aa[i]]%2==0)sum[aa[i]]=num[aa[i]]/2*(num[aa[i]]-1);
		else sum[aa[i]]=(num[aa[i]]-1)/2*num[aa[i]];		
		s+=sum[aa[i]];
	//	printf("sum[%d]:%d\n",aa[i],sum[aa[i]]);	

	}
	for(int i=0;i<n;i++)
	{
		tp=num[a[i]]-1;
		ans=s-sum[a[i]];
		ans+=tp*(tp-1)/2;
		printf("%lld\n",ans);
	}	
//  printf("%d\n",n);	
	return 0;
}

Measured memory_bytes: 7936
d = int(input())
clist = list(map(int,input().split()))
last_c = [0]*26

slist = [0] * d
for i in range(d):
    slist[i] = list(map(int,input().split()))

tlist = [0]*d

satisfy = [0]*(d+1)

for i in range(0,d):
    max = 0
    max_n = 0
    for n in range(26):
        if i > 0:
            curr = slist[i][n] + satisfy[i-1]
        else:
            curr = slist[i][n]
        minus = 0
        for j in range(26):
            if n != j:
                minus -= clist[j] * (i - last_c[j])
        curr += minus
        if curr > max:
            max = curr
            max_n = n
    satisfy[i] = max
    last_c[max_n] = i+1 
    tlist[i] = max_n+1

#remove first
for i in tlist:
    print(i)


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std; 
int main()
{
    int n;
    int m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int z=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        z++;
                }
            }
            if(z==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 3 == 0||a%3==0||b%3==0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for i in range(N):
    X = S[0 : i]
    Y = S[i : N]
    X_and_Y_li = list(set(X) & set(Y))
    if len(X_and_Y_li) > ans :
        ans = len(X_and_Y_li)
print(ans)


Measured memory_bytes: 2940
use std::io;
fn read() -> Vec<i32> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().split(' ').map(|x| x.parse().ok().unwrap()).collect()
}
fn main() {
    let mut inputs = read();
    inputs.sort();
    println!("{}", (inputs[2] * 10) + inputs[1] + inputs[0]);
}



Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 205;
const int MS = 100005;
const int S = 100000;

int N, X;
int A[MN], B[MS];
int Fac[MN], iFac[MN];
int f[MS], Ans;

void Init(int N) {
	Fac[0] = iFac[0] = iFac[1] = 1;
	for (int i = 2; i <= N; ++i)
		iFac[i] = (LL)(Mod - Mod / i) * iFac[Mod % i] % Mod;
	for (int i = 1; i <= N; ++i) {
		Fac[i] = (LL)Fac[i - 1] * i % Mod;
		iFac[i] = (LL)iFac[i - 1] * iFac[i] % Mod;
	}
}

int main() {
	scanf("%d%d", &N, &X);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), ++B[A[i]];
	for (int i = 1; i <= S; ++i) B[i] += B[i - 1];
	std::sort(A + 1, A + N + 1);
	Init(N);
	for (int x = 1; x <= X; ++x) {
		if (!B[x]) f[x] = x;
		for (int i = 1; i <= B[x]; ++i) {
			int y = x % A[i];
			f[x] = (f[x] + (LL)Fac[B[x] - 1] * iFac[B[y]] % Mod * f[y]) % Mod;
		}
	}
	Ans = (LL)Fac[N] * iFac[B[X]] % Mod * f[X] % Mod;
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int , int > pairs;
typedef complex<ll> G;
const int N=1e4+5;

const int INF = 1e9+5;


void done() {
    string a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i=0;i < a.size();i++) {
        if(a[i]!=b[i]) cnt++;
    }
    cout <<cnt;



}
void solve() {

    int n;
    cin >> n;
    cout << pow(n, 2) + pow(n, 3) + n;
}

void another() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    int cnt = 0;
    for(int i = 0 ;i < n;i++) {
        cin >> a[i];
        if(a[i]%2==1) {
            cnt++;
        }
    }

    if(cnt < k) {
        cout << "NO\n";
        return;
    }
    if(k%2!=cnt%2) {
        cout << "NO\n";
        return;
    }
    set<int>ans;
    cout << "YES\n";
    for(int i=0; i< n;i++) {
        if(k > 1) {
            if((a[i] & 1)) {
                ans.insert(i+1);
                k--;
            }
        }
    }
    ans.insert(n);
    for(auto c : ans) {
        cout << c << " ";
    }
    cout << '\n';



}
void test_case() {
    int t;
    cin >> t;
    while(t--)solve();
}
int main() {

    fast;
    done();
}


Measured memory_bytes: 3720