akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, C; cin >> n >> C;
    vector<int> s(n), t(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
    }

    int last = *max_element(t.begin(), t.end());
    
    vector<vector<int>> imos(last + 1, vector<int>(C, 0));

    for (int i = 0; i < n; i++) {
        imos[s[i] - 1][c[i]]++;
        imos[t[i]][c[i]]--;
    }

    vector<int> record(last + 1, 0);
    for (int i = 0; i <= last; i++) {
        for (int j = 0; j < C; j++) {
            if (i < last) imos[i + 1][j] += imos[i][j];
            if (imos[i][j]) record[i]++;
        }
    }

    int ans = *max_element(record.begin(), record.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cmath>
#include <limits>
#include <set>
#include <vector>

using namespace std;

int main(){

    int X;
    cin >> X;
    int A, B;
    for(A = -500; A < 500; A++){
        for(B = -500; B < 500; B++){
            if(pow(A,5)-pow(B,5) == X){
            cout << A << " " << B << endl;
            goto loopend;
            }
        }
    }

    loopend:

    return 0;
}

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

int main() {
  int k, n;cin>>k>>n;
  int an[n];rep(i,n)cin>>an[i];
  
  int maxi = 0;
  rep(i,n-1) {
    maxi = max(maxi, an[i+1] - an[i]);
  }
  maxi = max(maxi, k+an[0] - an[n-1]);
  cout << k - maxi;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n;
int a[N];
int cnt[N];
int main()
{
	while (~scanf("%d", &n))
	{
		MS(cnt, 0);
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &a[i]);
			++a[i];
			++cnt[a[i]];
		}
		int ans = 0;
		for (int i = 1; i <= n; ++i)
		{
			int x = a[i];
			gmax(ans, cnt[x] + cnt[x - 1] + cnt[x + 1]);
		}
		printf("%d\n", ans);
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】


*/

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

using namespace std;

typedef long long ll;

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

	int h, w;
	cin >> h >> w;
	string g[h][w];
	rep(i, h) rep(j, w) cin >> g[i][j];

	rep(i, h) rep(j, w){
		if(g[i][j] == "snuke"){
			string s;
			s.push_back('A' + j);
			cout << s << (i + 1) << endl;
			return 0; 
		}
	}
}


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

using namespace std;
#define pb push_back
#define mp make_pair

int main()
{
       /* auto start = chrono::high_resolution_clock::now();
        /// OVDJE KOD KOJI SE RUNUJE
        auto finish = chrono::high_resolution_clock::now();
        chrono::duration<double> elapsed = finish - start;
        cout << "Elapsed time: " << elapsed.count() << " s\n";*/
        int n;
        cin>>n;
        vector<pair<int,int>> res;
        for( int  i =1;i<=n;i++ ){
            for( int j = i+1;j<=n;j++ ){
           //         if( i==j ) continue;
                if( n%2==0 && i+j == n+1 ) continue;
            if( n%2 == 1 && i+j==n ) continue;
            res.pb( mp( i,j ) );
            }
        }
        cout << res.size() <<endl;
        for( int i = 0;i<res.size();i++ )
            cout << res[i].first << " " << res[i].second <<endl;
        return 0;
}
















Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    std::string s;
    std::cin >> s;
    if(s=="ARC"){
        std::cout << "ABC" << std::endl;
    }else{
        std::cout << "ARC" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3620
// 5/2

#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>;
using Graph = vector<vector<int>>;

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

    if (S == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

Measured memory_bytes: 3596
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin>>r;
	double ans = M_PI*2*r;
	cout<<fixed<<setprecision(12)<<ans;	
	return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
int main(void){
    int N,Y;
    scanf("%d%d", &N, &Y);
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= N; k++) {
                if (i + j + k > N) break;
                if (10000*i + 5000*j + 1000*k == Y && i + j + k == N) {
                    printf("%d %d %d\n",i,j,k);
                    return 0;
                }
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[][]a = new int [n][m];
		int[]b = new int [m];
		int[]d = new int [n];
		
		for(int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m ; j++) {
				a[i][j] = sc.nextInt();
				d[i] += b[j]*a[i][j];
			}
		}
		
		int count = 0;
		for(int i = 0; i < n; i++) {
			if((d[i] + c) > 0) {
				count++;
			}
		}
		System.out.println(count);


	}

}


Measured memory_bytes: 22356
drop = []
drop_time = []

for group in range(3):
    n = []
    time = []
    for person in range(8):
        result = raw_input().split()
        n.append(int(result[0]))
        time.append(float(result[1]))
    for i in range(2):
        fastest_index = time.index(min(time))
        print n[fastest_index], time[fastest_index]
        del n[fastest_index]
        del time[fastest_index]
    drop += n
    drop_time += time

for i in range(2):
    fastest_index = drop_time.index(min(drop_time))
    print drop[fastest_index], drop_time[fastest_index]
    del drop[fastest_index]
    del drop_time[fastest_index]

Measured memory_bytes: 4268
n,x = map(int,input().split())
a = list(map(int,input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

if n == 1:
  a.append(a[0])
  n = n+1
d = []
for i in range(n):
  y = abs(a[i] - x)
  d.append(y)

b = gcd(d[0],d[1])
for i in range(n):
	b = gcd(b,d[i])
print(b)

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	vector<pair<int,int>> bc(m);
	int tb,tc;
	for (int i = 0; i < m; i++) {
		cin>>tb>>tc;
		bc[i]=make_pair(tb,tc);
	}
	sort(a.begin(),a.end());
	sort(
		bc.begin(),
		bc.end(),
		[](const pair<int,int>& x,const pair<int,int>& y){return x.second>y.second;}
	);
	int now=0;
	for (int i = 0; i < m; i++) {
		while (bc[i].first>0&&bc[i].second>a[now]) {
			a[now]=bc[i].second;
			now++;
			bc[i].first--;
		}
		if (bc[i].first!=0) {
			break;
		}
	}
	long long int ans=0;
	for (int i = 0; i < n; i++) {
		ans+=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>

using namespace std;

int n,x,t;

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>> n >> x >> t;
    int ans = (int)(ceil((double)n/(double)x)*t);
    cout<< ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MAXN 200
#define INF 0x3FFFFFFF
using namespace std;
struct point
{
	int x,y;
}red[MAXN+5];
struct node
{
	int to,cap;
	node *next,*back;
}edge[MAXN*MAXN*10+5];
node *ncnt=&edge[0],*Adj[MAXN+5];
int n;
int s,t;
int d[MAXN+5],vd[MAXN+5];
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->cap=1;
	p->next=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->cap=0;
	q->next=Adj[v];
	Adj[v]=q;
	
	p->back=q;
	q->back=p;
}
int aug(int i,int tot)
{
	int j,sum=0,mind=n+1,delta;
	if(i==t)
		return tot;
	for(node *p=Adj[i];p!=NULL;p=p->next)
	{
		j=p->to;
		if(p->cap>0)
		{
			if(d[i]==d[j]+1)
			{
				delta=min(tot-sum,p->cap);
				delta=aug(j,delta);
				p->cap-=delta;
				p->back->cap+=delta;
				sum+=delta;
				if(d[s]>=n+2)
					return sum;
				if(sum>=tot)
					break;
			}
			if(d[j]<mind)	mind=d[j];
		}
	}
	if(sum==0)
	{
		vd[d[i]]--;
		if(vd[d[i]]==0)
			d[s]=n+2;
		d[i]=mind+1;
		vd[d[i]]++; 
	}
	return sum;
}
int sap()
{
	int flow=0;
	memset(d,0,sizeof(d));
	memset(vd,0,sizeof(vd));
	vd[0]=n+2;
	while(d[s]<n+2)
		flow+=aug(s,INF);
	return flow;
}
int main()
{
	scanf("%d",&n);
	s=0,t=n*2+1;
	n*=2;
	for(int i=1;i<=n/2;i++)
	{
		AddEdge(i,t);
		scanf("%d %d",&red[i].x,&red[i].y);
	}
	int x,y;
	for(int i=n/2+1;i<=n;i++)
	{
		AddEdge(s,i);
		scanf("%d %d",&x,&y);
		for(int j=1;j<=n/2;j++)
			if(red[j].x<=x&&red[j].y<=y)//*********************
				AddEdge(i,j);
	}
	int ans=sap();
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> data(N+1);
  for(int i = 1; i <= N; i++){
    cin >> data[i];
  }
  int count = 0;
  bool can = false;
  int a = data[1];
  if(a == 2) cout << 1 << endl;
  else{
    for(int i = 0; i < N; i++){
      a = data[a];
      count++;
      if(a == 2){
        can = true;
        break;
      }
    }
    if(can) cout << count + 1 << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 640
//#include <stdio.h>
//#includd <cstdio>
#include <iostream>
using namespace std;

int main(){

  int i,j,maxn,maxm,n[110],m[110],sumn=0,summ=0,x[2],MIN=5000;

  //  std::cin >>;

  //data input
  //  cin >> i >>J;
  //  cout << "test" << i << endl;
 
  //input
  while(1){
    MIN = 5000;
    sumn = 0;
    summ = 0;
    x[0] = -1;
    x[1] = -1;

    cin >> maxn >> maxm;
    if(maxn == 0 && maxm == 0)
      break;


    for(i = 0;i < maxn;i++){
      cin >> n[i];
    }
    for(i = 0;i < maxm;i++){
      cin >> m[i];
    }
    //sum
    for(i=0;i<maxn;i++){
      sumn += n[i];
    }
    for(i=0;i<maxm;i++){
      summ += m[i];
    }


    for(i=0;i<maxn;i++){
      sumn -= n[i];
      for(j=0;j<maxm;j++){
	summ -= m[j];

	summ += n[i];
	sumn += m[j];
	if(summ == sumn){
	  if(MIN > n[i] +m[j]){
	    x[0]=n[i];
	    x[1]=m[j];
	    MIN =  n[i] +m[j];
	  }
	}
	summ -= n[i];
	sumn -= m[j];

	summ += m[j];
      }
      sumn += n[i];
    }
    if(x[0] == -1 && x[1] == -1){
      cout << "-1" << endl;
    }else{
    cout << x[0] <<" "<<  x[1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0206
{
    public class Program

    {
        public const int MONTH = 12;
        public static void Main(string[] args)
        {

            while (true)
            {
                int l = RInt(); if (l == 0) break;
                int[][] balances = new int[MONTH][];
                for (int i = 0 ; i < MONTH ; i++) balances[i] = RIntAr();
                Console.WriteLine(CalcMonth(l, balances));
            }
        }

        private static string CalcMonth(int l, int[][] balances)
        {
            int sum = 0;
            for (int i = 0 ; i < balances.Length ; i++)
            {
                sum += balances[i][0] - balances[i][1];
                if (sum >= l) return (i + 1).ToString();
            }
            return "NA";
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 15920
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()
    
    if t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1
        
print(taro, hanako)

Measured memory_bytes: 7668
#include	<stdio.h>

int main(int argc, char** argv){
	int i, j, x, y;
	
	while(scanf("%d %d",&x, &y)!=EOF){
		for(i = 0, j = 1;(x + y) / j;i++, j *= 10);
	
		printf("%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 0
import sys
A,B,C = map(int,input().split())
if A>B:
    for i in range(A,B,-1):
        if i == C:
            print("Yes")
            sys.exit()
else:
    for i in range(A,B,1):
        if i == C:
            print("Yes")
            sys.exit()
print("No")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 500200;
const int lg = 22;
long long rng[2][2];
int M(){
    long long n, a, b, c, d;
    if(cin >> n >> a >> b >> c >> d){
        for(int e = 0; e <= n-1; e++){
            long long l = a - e*d + (n - 1 - e)*c, r = a - e*c + (n - 1 - e)*d;
            if(l <= b && b <= r){
                printf("YES\n");
                return 1;
            }
        }
        printf("NO\n");
        return 1;
    }
    return 0;
}
int main(){
    while(M());
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<int> n(4), x{1, 4, 7, 9};
    rep(i, 4) cin >> n.at(i);
    sort(all(n));
    cout << (n == x ? "YES" : "NO") << endl;
    // end

    return 0;
}


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

int main( int argc, char *argv[] )
{
    int n;

    scanf( "%d", &n );

    if( n % 10 == 7 ) {
        puts( "Yes" );
        exit( 0 );
    }

    n /= 10;

    if( n % 10 == 7 ) {
        puts( "Yes" );
        exit( 0 );
    }

    n /= 10;

    if( n % 10 == 7 ) {
        puts( "Yes" );
        exit( 0 );
    }

    puts( "No" );
}


Measured memory_bytes: 1648
/*

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

typedef vector<vector<ll> > matrix;

matrix mul(matrix a, matrix b){
    matrix c;
    c.resize(a.size());
    for (int i = 0; i < c.size(); i++)
        c[i].resize(b[0].size(), 0);
    for (int i = 0; i < c.size(); i++)
        for (int j = 0; j < c[i].size(); j++)
            for (int k = 0; k < b.size(); k++)
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]);
    return c;
}

matrix def;

matrix bpow(matrix a, ll st){
    if (st == 0)
        return def;
    if (st == 1)
        return a;
    matrix b = bpow(a, st >> 1);
    b = mul(b, b);
    if (st & 1)
        b = mul(a, b);
    return b;
}

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MOD = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MOD;
    XR = YR;
    YR = ZR;
    return ZR;
}

ll sqr(ll x){
    return x * x;
}

const ll llinf = 2e18;

const ld EPS = 1e-9;

const ld PI = atan2(0, -1);

const int maxn = 2e5 + 100, inf = 1e9 + 100, mod = 1e9 + 7;



int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    #endif
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    ll a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;
    b = min(b, 2 * a);
    c = min(c, 2 * b);
    d = min(d, 2 * c);
    cout << n / 2 * d + (n & 1) * c;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
k = ii()
for i in range(len(s)):
    if s[i] != s[k-1]:
        s[i] = '*'
print(''.join(s))

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int N;
int main(){
    cin>>N;
    int ans=0;
    for(int i=0;i*i<=N;i++){
        ans=i*i;
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    long long int ans = 0, l = 0, r = 0;
    for(int i = 0; i < k; ++i) {
        l += i;
        r += n-i;
    }
    for(int i = k; i <= n; ++i) {
        ans += r-l+1;
        ans %= MOD;
        l += i;
        r += n-i;
    }
    ans += r-l+1;
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<ll> nums(n + 1);
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                if(i * i + j * j + k * k + i * j + j * k + k * i > n) continue;
                nums[i * i + j * j + k * k + i * j + j * k + k * i]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << nums[i] << "\n";
    }
}

Measured memory_bytes: 3564
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n,k;
int h[N];
int cache[N];

int dp(int idx){
    if(idx>=n) return 0;
    int &ans=cache[idx];
    if(ans!=-1) return ans;
    ans=inf;
    for(int i=1; i<=k; i++){
        if(i+idx<=n) ans=min(ans,dp(idx+i)+abs(h[idx+i]-h[idx]));
    }
    return ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    rep(i,1,n+1) cin >> h[i];
    mst(cache,-1);
    int res=dp(1);
    cout << res;
    return 0;
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int l , r;
int main() {
    abdelrahman010
    cin >> l >> r;
    if(r - l > 2019)
        return cout << 0 , 0;
    ll mn = 2e9;
    for(int i = l;i <= r;i++)
        for(int j = i + 1;j <= r;j++)
            mn = min(mn , (1ll * i * j) % 2019);
    cout << mn;
    return 0;
}

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

using namespace std;
using ll=long long;

void solve() {
    ll n; cin >> n;
    auto c = [&](ll x){
        return x*(x+1)/2;
    };
    ll res = c(n);
    res -= 3*c(n/3);
    res -= 5*c(n/5);
    res += 15*c(n/15);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    vector<char> v;
    REP(i, s.size())
    {
        if (s[i] != 'x')
            v.push_back(s[i]);
    }

    bool ok = true;
    for (int i = 0; i < v.size() / 2; i++)
        if (v[i] != v[v.size() - i - 1])
            ok = false;

    if (!ok)
    {
        cout << -1 << endl;
        return 0;
    }

    V x;

    int i = 0;
    while (i < s.size())
    {
        int cnt = 0;
        while (i < s.size() && s[i] == 'x')
        {
            i++;
            cnt++;
        }
        x.push_back(cnt);
        i++;
    }
    if (s[s.size() - 1] != 'x')
    {
        int cnt = 0;
        while (i < s.size() && s[i] == 'x')
        {
            i++;
            cnt++;
        }
        x.push_back(cnt);
    }

    int res = 0;
    REP(i, x.size() / 2)
    res += abs(x[i] - x[x.size() - i - 1]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1100
import java.util.*;
class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.length() < 4){
			System.out.println("No");
		} else {
			if(s.substring(0,4).equals("YAKI")) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 23508
N = int(input())
A = list(map(int, input().split()))
count = 0
def make_sankaku(san):
    if san[0] == san[1] or san[1] == san[2] or san[2] == san[0]:
        return False
    else:
        san.sort()
        if san[2] - san[0] >= san[1]:
            return False
    return True
All_a = []
if len(A) <3:
    count = 0
else:
    for i in range(len(A)):
        for k in range(i+1, len(A)):
            for l in range(k + 1 ,len(A)):
                if make_sankaku([A[i], A[k], A[l]]):
                    if [A[i], A[k], A[l]] not in All_a:
                        count += 1
print(count)

Measured memory_bytes: 9236
N, K = map(int, input().split())  # 0~NのN+1個の数字, K個以上選んで出来上がる数
ans = 0
MOD = 10**9+7
# 出来上がる数字の幅を考える
for k in range(K, N+2):  # K~N+1までループを回す
  upper = k*(2*N-(k-1))//2
  lower = k*(k-1)//2
  ans += upper - lower + 1
  ans %= MOD
print(ans)


Measured memory_bytes: 9176
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

void print_vec(const vector<int> &v) {
    for(auto it=v.begin(); it!=v.end(); ++it) {
        printf("%d ", *it);
    }
    printf("\n");
}

int solve(int n, vector<int> &v) {
    int minsofar=1000000001;
    int maxprof=0;
    int cnt = 0;

    for(auto it=v.begin(); it!=v.end(); ++it) {
        if(minsofar > *it)  minsofar = *it;
        else if(maxprof < *it - minsofar) {
            cnt = 1;
            maxprof = *it - minsofar;
        }
        else if(maxprof == *it - minsofar)  ++cnt;
    }
    return cnt;
}

int main() {
    int n, t, tmp;
    cin >> n >> t;

    vector<int> va(n);
    repeat(i, n) {
        cin >> tmp;
        va[i] = tmp;
    }
    cout << solve(n, va) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int N,P;
string S;
int cnt[10101];

int main(){
  cin>>N>>P>>S;
  
  ll ans=0;
  if(P==2||P==5){
    rep(i,N) if((S[i]-'0')%P==0) ans+=i+1;
    cout<<ans<<endl;
    return 0;
  }
  
  ll now=0,ten=1;
  cnt[0]=1;
  for(int i=N-1;i>=0;i--){
    int x=(S[i]-'0')%P;
    now=(now+x*ten%P)%P;
    ans+=cnt[now]++;
    (ten*=10)%=P;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 644
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	boolean same(char[] a,char[] b) {
		if(a.length!=b.length)return false;
		boolean ret=true;
		for(int i=0;i<a.length;++i)ret&=a[i]==b[i];
		return ret;
	}
	
	int n(char c) {
		return (int)(c-'0');
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		char[] cs=sc.next().toCharArray();
		int ans=0;
		int x=0;
		for(char c:cs) {
			if(c=='I')++x;
			else --x;
			ans=Math.max(ans, x);
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23764
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    x,n = readInt()
    if not n:
        print(x)
        return
    p = readInt()
    p.sort()
    res_min = 0
    for i in range(100):
        if x-i not in p:
            res_min = max(x-i,res_min)
    res_max = INF
    for i in range(100):
        if x+i not in p:
            res_max = min(x+i,res_max)
    if (x-res_min)<=(res_max-x):
        print(res_min)
    else:
        print(res_max)
    return

if __name__=='__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  int n1=N,i=0;
  for(i=0;N>0;N/=10)
    i+=N%10;
  if(n1%i==0)
  	cout<< "Yes" <<endl;
  else
  	cout<< "No" <<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
ll i_7;
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}


void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



int main(){fastio
    ll n;cin>>n;
    ll a[2*n-1];rep(i,0,2*n-2)cin>>a[i];
    ll ok=1,ng=n*2-1;
    while(abs(ok-ng)>1){
        ll m=(ok+ng)/2;
        bool b[2*n-1];
        rep(i,0,2*n-2)b[i]=a[i]>=m;
        //cout<<m<<":";
        //rep(i,0,2*n-2)cout<<b[i]<<" ";cout<<endl;
        
        bool pre=b[n-1];
        for(ll i=n-2;i>=0;i--){
            ll j=2*n-2-i;
            if(pre==b[i]||pre==b[j])break;
            pre=b[i];
        }
        if(pre)ok=m;
        else ng=m;
    }
    cout<<ok<<endl;
    
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,q;
    cin >> n >> q;
    queue<string> name; 
    queue<int> num;
    string s;
    int x;
    int time = 0;
    for(int i = 0; i < n; i++) {
        cin >> s >> x;
        name.push(s);
        num.push(x);
    }
    while(!name.empty()) {
        if(num.front() > q) {
            time+=q;
            num.push(num.front() - q);
            name.push(name.front());
            num.pop();
            name.pop();
        }
        else {
            time += num.front();
            cout << name.front() << " " << time << endl;
            num.pop();
            name.pop();
        }
    }
}


Measured memory_bytes: 5700
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a, b;
	char op;
	while (true) {
		cin >> a >> op >> b;
		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')
			cout << a / b << endl;
		else
			break;

	}
	return 0;
}

Measured memory_bytes: 1160
//
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstring>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
string s;
int k;
const int maxn = 305;
const int maxk = 305;
int dp[maxn][maxn][maxk];
int n;
int solve(int i, int j, int k)
{
    if(i> j) return 0;
    if(dp[i][j][k] != -1) return dp[i][j][k];
    int add = 2;
    int res = 0;
    if(i == j) add = 1;
    res = max(res, solve(i+1, j, k));
    res = max(res, solve(i, j-1, k));
    if(s[i] == s[j]) res = max(res, add+solve(i+1, j-1, k));
    if(k) res = max(res, add+solve(i+1, j-1, k-1));
    return dp[i][j][k] = res;
}
int main()
{
    //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif
    cin >> s >> k;
    n = s.size();
    memset(dp, -1, sizeof dp);
    //cout << solve(1, 4, 0) << endl;
    cout << solve(0, n-1, k) << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define _13day ""

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int n;
string s;
int cnt[26][N];
int main() {
  #ifndef _13day
    freopen (_13day".in", "r", stdin);
    freopen (_13day".out", "w", stdout);
  #endif

  Kazakhstan
  cin >> n;
  rep(i, 1, n) {
    cin >> s;
    for (char j : s)
      cnt[j - 'a'][i]++;
  }

  string s;
  rep(i, 0, 25) {
    int mn = inf;
    rep(j, 1, n)
      mn = min(mn, cnt[i][j]);
    rep(j, 1, mn)
      s += char(i + 'a');
  }

  cout << s;
  ioi
}



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

int main() {
  int n;
  vector<string> w(n);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w.at(i);
  }
  bool flag = true;
  int ws;
  for (int i = 1; i < n; i++) {
    ws = w.at(i - 1).size();
    if (w.at(i - 1).at(ws - 1) != w.at(i).at(0)) {
      flag = false;
    }
    for (int j = 0; j < i; j++) {
      if (w.at(i) == w.at(j)) {
        flag = false;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  while(1){
    int x, y;
    cin >> x >> y;
    if(!(x|y))
      return 0;
    cout << min(x,y) << " " << max(x,y) << endl;
  }

  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;
 
int main(void){
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++){
        cin >> v[i];
    }
    vector<pair<int, int>> odd(100001);
    vector<pair<int, int>> even(100001);
    for(int i=0; i<100001; i++){
        odd[i].second = i;
        even[i].second = i;
    }
    for(int i=0; i<N; i++){
        if(i%2 == 0){
            even[v[i]].first++;
        }else{
            odd[v[i]].first++;
        }
    }
    
    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());
    int ans;
    if(even[100000].second == odd[100000].second){
        ans = even[100000].first + odd[99999].first > odd[100000].first + even[99999].first ? N - (even[100000].first + odd[99999].first) : N - (odd[100000].first + even[99999].first);     
    }else{
        ans = N - (even[100000].first + odd[100000].first);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
/// Author:- Lazy_Coder

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

long computeXOR(const int n)
{

    switch(n & 3)
    {
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
    }
}

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

ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

int main()
{
    int n;
    cin>>n;
    //int dig=0;
    int mx = INT_MIN;
    int n1 = n;
    while(1)
    {
        int n2 = n1;
        int cnt=1;
        int dig = n2%10;
        n2/=10;
        while(n2>0)
        {
            if(dig==(n2%10))
                cnt++;
            n2/=10;
        }
        if(cnt==3)
        {
            cout<<n1<<'\n';
            break;
        }
        n1++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int t,x;
  cin >> t >> x;
  double ans = (double)t/x;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out <in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;

void test_case() {	
	int n; cin>>n;
	vector<int> v(n);
	for(auto &it: v) cin>>it;

	ll money = 1000;
	for(int i=0;i<n-1;i++){
		if(v[i]<v[i+1])
			money = money%v[i] + (money/v[i])*v[i+1];
	}
	cout<<money<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

Measured memory_bytes: 3612
import numpy as np

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = np.array(A)
D = np.array(B)
E =np.array([])
E = C - D
x = 0
for i in E:
  if i > 0:
    x = x + i
print(x)

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll n,x;
	cin>>n>>x;
	ll a[n];
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>x){
			ans+=a[i]-x;
			a[i]=x;
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			ans+=a[i]+a[i+1]-x;
			a[i+1]-=a[i]+a[i+1]-x;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<int,int> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int main(){
    ll ans=0;
    int N,temp;
    cin>>N;
    vector<int> L;
    vector<int> S;
    for(int i=0;i<N;i++){
        cin>>temp;
        L.push_back(temp);
    }
    sort(L.begin(),L.end());
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int sum=L[i]+L[j],minus=max(L[i],L[j])-min(L[i],L[j]);
            int temp=(int)(lower_bound(L.begin(),L.end(),sum)-upper_bound(L.begin(),L.end(),minus));
            //cout<<temp<<endl;
            //cout<<sum<<" "<<minus<<endl;
            if(minus<L[i] && L[i]<sum) temp--;
            if(minus<L[j] && L[i]<sum) temp--;
            ans+=temp;
        }
    }
    cout<<ans/3<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string S;
    cin >> S;
    while (1) {
        int n = S.size();
        //cout << S.substr(n - 6, 5) <<endl;
        if (n >= 5 && S.substr(n - 5, 5) == "dream") {
            S.erase(S.end() - 5, S.end());
        } else if (n >= 7 && S.substr(n - 7, 7) == "dreamer") {
            S.erase(S.end() - 7, S.end());
        } else if (n >= 6 && S.substr(n - 6, 6) == "eraser") {
            S.erase(S.end() - 6, S.end());
        } else if (n >= 5 && S.substr(n - 5, 5) == "erase") {
            S.erase(S.end() - 5, S.end());
        } else {
            break;
        }
    }
    if (S.size() == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import math

n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
abs_xy = []

for i in range(n):
    abs_xy.append(abs(x[i] - y[i]))

d1 = sum(abs_xy)

d2 = 0
for i in range(n):
    d2 += abs_xy[i] * abs_xy[i]
d2 = math.sqrt(d2)

d3 = 0
for i in range(n):
    d3 += abs_xy[i] * abs_xy[i] * abs_xy[i]
d3 = math.pow(d3, 1/3)

d = max(abs_xy)

print(d1)
print(d2)
print(d3)
print(d)


Measured memory_bytes: 5704
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	int ans = 0, cnt = 0;
	while (N > 0) {
		N--;
		bool f = true;
		int tmp = 1;
		while (tmp*K < cnt) {
			tmp++;
			N--;
			if (N < 0) {
				f = false;
				break;
			}
		}
		cnt += tmp;
		if(f)ans++;
		//cout << tmp << endl;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3220