akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <cstdio>
using namespace std;
#define rep(i,n) for(uint_fast32_t i=0;i<(n);++i)
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline uint_fast32_t read(){
  uint_fast32_t a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int h[100001];
int main(){
  uint_fast32_t n=read(),a=read(),b=read();a-=b;
  double a_=1.0/a;
  rep(i,n)h[i]=read();
  uint_fast32_t left=0,right=1000000000;
  int_fast64_t temp,cnt=0,mid;
  while (right>left+1) {
    mid=(right+left)>>1;
    cnt=0;
    rep(i,n){
      temp=h[i]-b*mid+a-1;
      if(temp>0)cnt+=temp*a_;
    }
    if(cnt<=mid)right=mid;
    else left=mid;
  }
  printf("%u\n",right);
}

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

int N;
vector<int> P;

int main()
{
    cin >> N;
    P.resize(N);

    map<int, int> mem;
    for (int i = 0; i < N;i++)
    {
        cin >> P[i];
        P[i]--;

        if (mem.count(P[i]-1))
        {
            mem[P[i]] = mem[P[i] - 1] + 1;
            mem.erase(P[i] - 1);
        }
        else
        {
            mem[P[i]] = 1;
        }
    }

    int maxlen = 1;
    for (auto data : mem)
    {
        maxlen = max(maxlen, data.second);
    }

    cout << N - maxlen << "\n";
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define INF (int)1e9+5
#define nax (int)1e5+2
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hello\n"
#define f first
#define s second
using namespace std;



int main(){
	fast;
	int n,r;
	cin>>n>>r;
	int val = 100 * (10-n);
	if(n>=10){
		cout<<r;
	}
	else{
		r = r + val;
		cout<<r;
	}
	
	return 0;
}


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

void main_()
{
    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> Ts;
    Ts.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Ts));

    sort(begin(Ts), end(Ts));

    ll ans = 0;
    for (auto head_it = begin(Ts); head_it != end(Ts);) {
        auto it = upper_bound(head_it, end(Ts), *head_it + K);
        auto num = min(distance(head_it, it), C);
        head_it += num;
        ans++;
    }

    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <list>
using namespace std;


int main(int argc, char const *argv[]) {
  int n;
  int x;
  string command;
  std::cin >> n;
  list<int> L;

  for (size_t i = 0; i < n; i++) {
    std::cin >> command;

    if (command == "insert") {
      std::cin >> x;
      L.push_front(x);
    }else if(command == "delete"){
      std::cin >> x;
      for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
        if( *it==x ){
          L.erase(it);
          break;
        }
      }

    }else if(command == "deleteFirst"){
      L.pop_front();
    }else if(command == "deleteLast"){
      L.pop_back();
    }
  }

  int i;

  for(list<int>::iterator it = L.begin(); it != L.end(); it++){
    if(i++) std::cout << " ";
    std::cout << *it;
  }
  std::cout << '\n';

  return 0;
}



Measured memory_bytes: 34376
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    V = string_to_int(inputs[0])
    N = len(V)
    N_HALF = N // 2
    counts = {
        0: {},
        1: {}
    }
    for i, v in enumerate(V):
        key = i % 2
        if v in counts[key]:
            counts[key][v] += 1
        else:
            counts[key][v] = 1

    counts_sorted = []
    for i in range(2):
        counts_sorted.append(
            sorted(list(counts[i].items()), key=lambda x: x[1], reverse=True)
        )

    def count_replace(first, first_i, second, second_i):
        replace_count = N_HALF - counts_sorted[first][first_i][1]
        replace_count += N_HALF - counts_sorted[second][second_i][1]
        return replace_count

    if counts_sorted[0][0] == counts_sorted[1][0]:
        len_0 = len(counts_sorted[0])
        len_1 = len(counts_sorted[1])
        if len_0 == 1 and len_1 == 1:
            return N_HALF
        elif len_0 == 1:
            return N_HALF - counts_sorted[1][1][1]
        elif len_1 == 1:
            return N_HALF - counts_sorted[0][1][1]
        else:
            cs = []
            cs.append(count_replace(0, 0, 1, 1))
            cs.append(count_replace(0, 1, 1, 0))
            return min(cs)

    else:
        return count_replace(0, 0, 1, 0)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 22100
MOD = 1000000007
class mint:
    def __init__(self,x=0):
        self.x = x % MOD
    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return(
            mint(self.x + other.x) if isinstance(other, mint) else mint(self.x + other)
        )

    def __sub__(self, other):
        return(
            mint(self.x - other.x) if isinstance(other, mint) else mint(self.x - other)
        )
    
    def __mul__(self, other):
        return(
            mint(self.x * other.x) if isinstance(other, mint) else mint(self.x * other)
        )

    def __truediv__(self, other):
        return(
            mint(self.x * pow(other.x, MOD - 2, MOD)) if isinstance(other, mint) else mint(self.x * pow(other, MOD - 2,MOD))
        )

    def __pow__(self, other):
        return(
            mint(pow(self.x, other.x, MOD)) if isinstance(other, mint) else mint(pow(self.x, other, MOD))
        )


    __radd__ = __add__

    def __rsub__(self, other):
        return (
            mint(other.x - self.x) if isinstance(other, mint) else mint(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            mint(other.x * pow(self.x, MOD - 2, MOD)) if isinstance(other, mint) else mint(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            mint(pow(other.x, self.x, MOD)) if isinstance(other, mint) else mint(pow(other, self.x, MOD))
        )

MAX = 1000005
fac = [1,1]
finv = [1,1]
inv = [0,1]
def COMinit():
    for i in range(2,MAX):
        fac.append((fac[-1] * i) % MOD)
        inv.append((-inv[MOD%i] * (MOD//i)) % MOD)
        finv.append((finv[-1] * inv[-1]) % MOD)

def COM(n, k):
    if(n < k):
        return 0
    if(n < 0 or k < 0):
         return 0
    return fac[n] * finv[k] * finv[n-k] % MOD 

def P(n, k):
    return fac[n] * finv[n-k] % MOD 

N,M = map(int, input().split())
COMinit()
res = mint(0)
now = mint()
for i in range(N+1):
    now = COM(N, i)
    now *= P(M-i, N-i)
    if(i%2 == 1):
        now = -1 * now
    res += now
res *= P(M, N)
print(res)

Measured memory_bytes: 127708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>


using namespace std;
#define ll long long


int main(void){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> swi(10,vector<int>(10));
    for(int i=0;i<M;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++) {
            int s;
            cin>>s;
            swi.at(i).at(s-1)=1;
        }
    }
    vector<int> P(10);
    for(int i=0;i<10;i++){
        if(i<M) cin>>P.at(i);
        else P.at(i)=0;
    }
    int ans=0;
    
    for(int a=0;a<2;a++){
        for(int b=0;b<2;b++){
            for(int c=0;c<2;c++){
                for(int d=0;d<2;d++){
                    for(int e=0;e<2;e++){
                        for(int f=0;f<2;f++){
                            for(int g=0;g<2;g++){
                                for(int h=0;h<2;h++){
                                    for(int i=0;i<2;i++){
                                        for(int j=0;j<2;j++){
                                            
                                            for(int K=0;K<10;K++){
                                                if((a*swi.at(K).at(0)+b*swi.at(K).at(1)+c*swi.at(K).at(2)+d*swi.at(K).at(3)+e*swi.at(K).at(4)+f*swi.at(K).at(5)+g*swi.at(K).at(6)+h*swi.at(K).at(7)+i*swi.at(K).at(8)+j*swi.at(K).at(9)+P.at(K))%2) break;
                                                   if(K==9) ans++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    for(int i=0;i<10-N;i++) ans/=2;
                                                   cout<<ans<<endl;
                                                   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------



int main() {

  int n;
  cin >> n;

  cout << 180*(n-2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
using namespace std;
typedef pair<int,int> Pt;
#define MAX 1000001
#define fr first
#define sc second
int n,dat[MAX * 2 - 1];
void update(int i,int x){
  i += n - 1;
  dat[i] = x;
  while(i > 0){
    i = (i - 1)/2;
    dat[i] = min(dat[i*2+1],dat[i*2+2]);
  }
}
int query(int a,int b,int k,int l,int r){
  if( r<=a || b <= l ) return INT_MAX;
  if( a<=l && r <= b ) return dat[k];
  return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}
int main(){
  int q,a,b,c,N;
  for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
  scanf("%d %d",&N,&q);
  n=1;
  while(n < N) n *= 2;
  while(q--){
    scanf("%d %d %d",&a,&b,&c);
    if(!a) update(b,c);
    else printf("%d\n",query(b,c+1,0,0,n));
  }
}

Measured memory_bytes: 8844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x=0;
  int a[3]={0,0,0};
  cin>>n>>m;
  int s[m],c[m];
  for(int i=0;i<m;i++){
    cin>>s[i]>>c[i];
    if((a[s[i]-1]!=0&&a[s[i]-1]!=c[i])||(n!=1&&s[i]==1&&c[i]==0)){
      cout<<"-1";
      x=1;
      break;
    }else{
      a[s[i]-1]=c[i];
    }
  }
  if(a[0]==0&&n!=1)a[0]=1;
  if(x==0){
    if(n==1){
      cout<<a[0];
    }
    if(n==2){
      cout<<a[0]<<a[1];
    }
    if(n==3){
    cout<<a[0]<<a[1]<<a[2];
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 50 + 5
#define M 2500 + 5
#define Mod 1000000007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, m, dp[N][N][M];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){ return (a += b) >= Mod ? a - Mod : a;}
int Mul(int a, int b){ return 1ll * a * b % Mod;}
int main(){
    n = read(), m = read();
    if(m & 1){ puts("0"); return 0;}
    m >>= 1;
    dp[1][0][0] = dp[1][1][0] = 1;
    rep(i, 2, n) rep(j, 0, i) rep(k, 0, m){
        if(k >= j) dp[i][j][k] = Inc(dp[i][j][k], dp[i - 1][j][k - j]);
        if(k >= j && j >= 1) dp[i][j][k] = Inc(dp[i][j][k], Mul(dp[i - 1][j][k - j], j));
        if(k >= j + 1) dp[i][j][k] = Inc(dp[i][j][k], Mul(dp[i - 1][j + 1][k - (j + 1)], Mul(j + 1, j + 1)));
        if(j >= 1 && k >= j - 1) dp[i][j][k] = Inc(dp[i][j][k], dp[i - 1][j - 1][k - (j - 1)]);
        if(k >= j && j >= 1) dp[i][j][k] = Inc(dp[i][j][k], Mul(dp[i - 1][j][k - j], j));
    }
    printf("%d", dp[n][0][m]);
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int ans = 0;
    int x = 0;
    int n;
    cin >> n;
    rep(i, n) {
        char a;
        cin >> a;
        if (a == 'I') {
            x++;
        } else {
            x--;
        }
        cmax(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}


int t[50010];
int s[50010];

int n,m;

#define OTO(x,y) (((x) + 12 + (y)) % 12)

bool loop(int i, int j){
  if(i == 0 && j == -1) return true;
  if(i == n + 1) return false;
  if(j == -1) return false;
  if(i < 0) return false;

  int tt = t[i];
  int ss = s[j];

  if(OTO(tt,0) == ss) return loop(i-1,j-1);
  if(OTO(tt,1) == ss) return loop(i-2,j-1);
  if(OTO(tt,-1)== ss) return loop(i+1,j-1);

  return false;
}

int main(){
  int cc;
  map<string,int> mp;
  mp["C" ] = 0; mp["C#"] = 1;
  mp["D" ] = 2; mp["D#"] = 3;
  mp["E" ] = 4;
  mp["F" ] = 5; mp["F#"] = 6;
  mp["G" ] = 7; mp["G#"] = 8;
  mp["A" ] = 9; mp["A#"] = 10;
  mp["B" ] = 11;

  scanf("%d",&cc);

  while( cc --> 0 ){
    char buff[8];

    scanf("%d%d",&n,&m);

    REP(i,n){
      scanf("%s",buff);
      t[i+1] = mp[buff];
    }
    REP(i,m){
      scanf("%s",buff);
      s[i] = mp[buff];
    }

    puts((loop(n, m-1) || loop(n-1, m-1)) ? "Yes" : "No");
  }

  return 0;
}

Measured memory_bytes: 1308
#n=int(input())
n,K=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

pt=set(al)
dic={}
for ai in al:
    dic[ai]=dic.get(ai,0)+1
l2d=[]
for k, v in dic.items():
    l2d.append([k,v])
l2d.sort(key=lambda x: x[1])

ans=0
for i in range(len(pt)-K):
    ans+=l2d[i][1]
print(ans)

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

#define int long long 
const int mod=1e9+7;

int bm(int x,int y){
    if(y==0)return 1;
    if(y==1)return x;
    if(y&1)return (x*bm(x,y-1))%mod;
    int f=bm(x,y/2);
    return (f*f)%mod;
}
signed  main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    long long ans=((bm(10,n)+bm(8,n)))%mod;
    ans=(ans-(bm(9,n)*2)+mod+mod)%mod;
    cout<<ans%mod<<endl;

}




Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n==3 || n==5 || n==7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

namespace ABC125C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            long[] A = new long[N];
            long[] B = new long[N];

            var line = Console.ReadLine().Split(' ').ToArray();
            int count = 0;
            long sum = 0;

            for(var i = 0; i < N; i++)
            {
                A[i] = long.Parse(line[i]);
                if(A[i] < 0)
                {
                    count++;
                }
                B[i] = Math.Abs(A[i]);
                sum += B[i];
            }

            Array.Sort(B);
            
            if(count % 2 == 0)
            {
                Console.WriteLine(sum);
            }
            else
            {
                Console.WriteLine(sum - 2 * B[0]);
            }
        }
    }
}


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

int digits_cnt(long long x) {
  int cnt = 1;

  while (x / 10 > 0) {
    cnt++;
    x /= 10;
  }

  return cnt;
}

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

  int ans = 15;
  for (ll i = 1LL; i * i <= n; i++) {
    if (n % i == 0) {
      int d = digits_cnt(max(i, n / i));
      ans = min(ans, d);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

ls =[s]
while True:
    if ls[-1] % 2 ==0:
        a = int(ls[-1]/2)
    else:
        a = int(ls[-1]*3 + 1)
    
    if a in ls:
        break
    else:
        ls.append(a)

print(len(ls)+1)



Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int kind = 0;
      Map<String, Integer> priseMap = new HashMap<>();

      // ガチャ
      for(int i = 0; i < N; i++){
        String prise = sc.next();
        if(!priseMap.containsKey(prise)){
          priseMap.put(prise, 0);
          kind++;
        }
      }

      // 出力
      System.out.println(kind);
    }
    
}

Measured memory_bytes: 76980
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
	// 入力
	long N, M;
	cin >> N >> M;
	vector<long> P(M);
	vector<pair<pair<long, long>, long>> cities(M);
	
	for (long i = 0; i < M; i++)
	{
		long Y;
		cin >> P[i] >> Y;
		cities[i] = make_pair(make_pair(Y, P[i]), i);
	}
	
	// 昇順にソート
	sort(cities.begin(), cities.end());
	
	vector<long> number(M);
	vector<long> count(N + 1);
	for (long i = 0; i < cities.size(); i++)
	{
		// 県に属した市iのカウントを計算する
		count[cities[i].first.second]++;
		// 入力時の順番のindexの番号配列に対して、カウントを代入する
		number[cities[i].second] = count[cities[i].first.second];
	}
	
	// 出力
	for (long i = 0; i < M; i++)
	{
		// ゼロ埋め対応
		cout << setfill('0') << right << setw(6) << P[i];
		cout << setfill('0') << right << setw(6) << number[i];
		// 改行
		cout << endl;
	}
	
	return 0;
}

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

int main()
{
  int d;
  cin >> d;
  vector<vector<int>> c;
  vector<int> t;
  int weight[26];
  for (int k = 0; k < 26; k++)
  {
    weight[k] = 1;
  }
  for (int i = 0; i < d + 1; i++)
  {
    c.push_back(vector<int>());

    for (int j = 0; j < 26; j++)
    {
      int v;
      cin >> v;
      c[i].push_back(v);
    }
  }

  for (int i = 0; i < d; i++)
  {
    int v;
    cin >> v;
    t.push_back(v);
  }

  int sum(0);
  for (int i = 0; i < d; i++)
  {
    int j = t[i] - 1;
    sum += c[i + 1][j];
    int penalty = 0;
    for (int k = 0; k < 26; k++)
    {
      if (j != k)
      {
        penalty += c[0][k] * weight[k];
        weight[k]++;
      }
      else
      {
        weight[k] = 1;
      }
    }
    sum -= penalty;
    std::cout << sum << std::endl;
  }
  return 0;
}

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

const int MAXN = 1e5 + 5;

int N;
int a[MAXN];
int prefixGCD[MAXN], suffixGCD[MAXN];

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

void buildPrefix() {
    prefixGCD[0] = 0;
    for (int i = 1; i <= N; ++i) {
        prefixGCD[i] = __gcd(prefixGCD[i-1], a[i]);
    }
}

void buildSuffix() {
    suffixGCD[N+1] = 0;
    for (int i = N; i >= 1; --i) {
        suffixGCD[i] = __gcd(a[i], suffixGCD[i+1]);
    }
}

void solve() {
    buildPrefix();
    buildSuffix();
    
    int ans = 1;
    for (int i = 1; i <= N; ++i) {
        // try to eliminate a[i] result in gcd(a[1],..,a[i-1],a[i+1],..,a[N])
        ans = max(ans, __gcd(prefixGCD[i-1], suffixGCD[i+1]));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, a, b, c;
long long memo[300005][2] = {0};
long long calc[300005] = {0};

void setmemo();
long long solve();

int main() {
  cin >> n >> a >> b >> c;
  smodfact();
  setmemo();
  cout << solve() << endl;
  return 0;
}

void setmemo() {
  long long x = inverse[(a + b) % N];
  memo[0][0] = memo[0][1] = 1;
  for(int i = 1; i <= n; ++i) {
    memo[i][0] = memo[i - 1][0] * a % N * x % N;
    memo[i][1] = memo[i - 1][1] * b % N * x % N;
  }
}

long long solve() {
  long long x = inverse[a + b], ans = 0;
  for(int i = 1; i <= 2 * n - 1; ++i) {
    calc[i] = (calc[i - 1] * (a + b) % N + 100) % N * x % N;
    if(i >= n) {
      ans += calccomb(i - 1, n - 1) * calc[i] % N *
             memo[n][0] % N * memo[i - n][1] % N;
      ans %= N;
      ans += calccomb(i - 1, n - 1) * calc[i] % N *
             memo[n][1] % N * memo[i - n][0] % N;
      ans %= N;
    }
  }
  return ans;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(fabs(c-a)>d&&(fabs(a-b)>d||fabs(c-b)>d))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

b = (listA[0][2]*60 + listA[0][3]) - (listA[0][0]*60 + listA[0][1]) - listA[0][4]
print(b)

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

constexpr int mxn = 2e5 + 1;
int n, k, a[mxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<int>());
    int l = 1, r = a[0];
    while (l < r) {
        int m = (l + r) / 2, res = 0;
        for (int i = 0; i < n && a[i] > m && res <= k; i++)
            res += (a[i] - 1) / m;
        if (res <= k)
            r = m;
        else
            l = m + 1;
    }
    cout << l << '\n';
    return 0;
}   

Measured memory_bytes: 4380
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n, x = gets.split.map(&:to_i)
    ls = gets.split.map(&:to_i)

    cnt = 1
    sum = 0
    ls.each do |l|
      sum += l
      if x < sum
        break
      else
        cnt += 1
      end
    end

    puts cnt
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2428
#include <stdio.h>

int main(void)
{
	int number, x, y, z;
	scanf("%d", &number);
	for (int i = 0; i < number; i++) {
		scanf("%d %d %d", &x, &y, &z);
		if (x * x == y * y + z * z || y * y == x * x + z * z || z * z == x * x + y * y) {
			printf("YES\n");
		}else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a ;
  double ans;
  double max1 = 1000;
  int index;
  for(int i=1;i<n+1;i++){
    int h;
    cin >> h;
    ans = t - h*0.006;
    if(abs(a-ans)<max1){
      max1 = abs(a-ans);
      index = i;
    }
  }
  cout << index << endl;
}


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

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt() >> 1;
        
        System.out.println(a+b);
    }
}


Measured memory_bytes: 22100
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

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

long long wa=0;
long long ac=0;
long long wa_ed[100010]={};
bool ac_ed[100010]={};

void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S){
  REP(i,M){
    if(ac_ed[p[i]])continue;
    if(S[i]=="WA"){
      wa_ed[p[i]]++;
    } else {
      ac++;
      wa+=wa_ed[p[i]];
      ac_ed[p[i]]=true;
    }
  }
  cout<<ac<<" "<<wa<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> p(M);
  std::vector<std::string> S(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&p[i]);
    std::cin >> S[i];
  }
  solve(N, M, std::move(p), std::move(S));
  return 0;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100;

int n;
ll p[MAX_N + 1], q[MAX_N + 1]; int r[MAX_N + 1], b[MAX_N + 1];
bool is_root[MAX_N + 1];

ll GCD(ll a, ll b){
	if(b == 0) return a;
	else return GCD(b, a % b);
}
ll LCM(ll a, ll b){
	return a / GCD(a, b) * b;
}

ll rec(int parent, bool is_red){
	if(is_red && parent == 0) return 1LL;
	if(!is_red && parent == 0) return 1LL;
	return LCM(rec(r[parent], true) * p[parent], rec(b[parent], false) * q[parent]) / p[parent] + LCM(rec(r[parent], true) * p[parent], rec(b[parent], false) * q[parent]) / q[parent];
}

int main(){
	for(;;){
		scanf("%d", &n);
		if(n == 0) break;
		fill(is_root, is_root + n + 1, true);
		for(int i = 1; i <= n; i++){
			scanf("%lld %lld %d %d", &p[i], &q[i], &r[i], &b[i]);
			is_root[r[i]] = false;
			is_root[b[i]] = false;
		}
		int root;
		for(int i = 1; i <= n; i++){
			if(is_root[i]) root = i;
		}
		printf("%lld\n", LCM(rec(r[root], true) * p[root], rec(b[root], false) * q[root]) / p[root] + LCM(rec(r[root], true) * p[root], rec(b[root], false) * q[root]) / q[root]);
	}
	return 0;
}



Measured memory_bytes: 2584
#include<cstdio>
const int MAXN = 1000;
long long sum[2];
int a[MAXN + 5], ans[MAXN + 5], tot, N;
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &a[i]);
		if( a[i] >= 0 )
			sum[i&1] += a[i];
	}
	if( sum[0] == 0 && sum[1] == 0 ) {
		int Max = 1;
		for(int i=1;i<=N;i++)
			if( a[i] > a[Max] )
				Max = i;
		printf("%d\n%d\n", a[Max], N-1);
		for(int i=N;i>Max;i--)
			printf("%d\n", i);
		for(int i=1;i<Max;i++)
			printf("%d\n", 1);
		return 0;
	}
	if( sum[0] > sum[1] ) {
		printf("%lld\n", sum[0]);
		if( N % 2 == 0 && a[N] < 0 ) ans[++tot] = N;
		for(int i=N;i>=1;i--) {
			if( i % 2 == 1 ) {
				if( a[i-1] < 0 ) ans[++tot] = i-1;
				else ans[++tot] = i;
			}
		}
		if( 1 % 2 == 0 && a[1] < 0 ) ans[++tot] = 1;
		printf("%d\n", tot);
		for(int i=1;i<=tot;i++)
			printf("%d\n", ans[i]);
	}
	else {
		printf("%lld\n", sum[1]);
		if( N % 2 == 1 && a[N] < 0 ) ans[++tot] = N;
		for(int i=N;i>=1;i--) {
			if( i % 2 == 0 ) {
				if( a[i-1] < 0 ) ans[++tot] = i-1;
				else ans[++tot] = i;
			}
		}
		if( 1 % 2 == 1 && a[1] < 0 ) ans[++tot] = 1;
		printf("%d\n", tot);
		for(int i=1;i<=tot;i++)
			printf("%d\n", ans[i]);
	}
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S;
    transform(S.begin() + K - 1, S.begin() + K, S.begin() + K - 1, ::tolower);
    cout << S << "\n";
    return 0;
}

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

L = []

def ans(tf):
  if tf:
    print("Yes")
  else:
    print("No")
  exit()

for x in a:
  for i in range(len(L)):
    if L[i][0] == x:
      L[i][1] += 1
      break
  else:
    L.append([x, 1])
    if len(L) >= 3:
      ans(False)

if len(L) == 1:
  x = L[0][0]
  if x == N - 1 or x <= N // 2:
    ans(True)
  else:
    ans(False)
else:
  x, xn = L[0]
  y, yn = L[1]
  if abs(x - y) != 1:
    ans(False)
    exit()
  if x < y:
    x, y = y, x
    xn, yn = yn, xn
  if yn >= x:
    ans(False)
    exit()
  n = x - yn
  if n <= xn // 2:
    ans(True)
  else:
    ans(False)

Measured memory_bytes: 83428
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


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

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	vector<vector<lli>> dp(n+1, vector<lli>(m+1,0));
	//vector<vector<string>> dp2(n+1, vector<string>(m+1));
	vector<vector<pair<int,int>>> dp3(n+1, vector<pair<int,int>>(m+1,make_pair(0,0)));
	for (int j = 1; j <= m; j++) {
		if (s[0] == t[j - 1]) {
			dp[1][j] = 1;
			//dp2[1][j] = s.substr(0, 1);
			dp3[1][j] = make_pair(-1, int(s[0]));
		}
		else {
			dp[1][j] = dp[1][j - 1];
			//dp2[1][j] = dp2[1][j - 1];
			dp3[1][j] = dp3[1][j - 1];
		}
	}
	for (int i = 1; i <= n; i++) {
		if (s[i - 1] == t[0]) {
			dp[i][1] = 1;
			//dp2[i][1] = t.substr(0, 1);
			dp3[i][1] = make_pair(-1, int(t[0]));
		}
		else {
			dp[i][1] = dp[i - 1][1];
			//dp2[i][1] = dp2[i - 1][1];
			dp3[i][1] = dp3[i - 1][1];
		}
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 2; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
				//string x = dp2[i - 1][j - 1]; x.append(s.substr(i - 1, 1));
				//dp2[i][j] = x;
				dp3[i][j] = make_pair(-1, int(s[i - 1]));
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] >= dp[i][j - 1]) {
					//dp2[i][j] = dp2[i - 1][j];
					dp3[i][j] = make_pair(i - 1, j);
				}
				else {
					//dp2[i][j] = dp2[i][j - 1];
					dp3[i][j] = make_pair(i, j - 1);
				}
			}
		}
	}
	int i = n, j = m;
	vector<char> ans;
	while (i > 0 && j > 0) {
		auto x = dp3[i][j];
		if (x.first == -1) {
			ans.push_back(char(x.second));
			i--; j--;
		}
		else if (x.first > 0) {
			i = x.first; j = x.second;
		}
		else break;
	}
	reverse(ans.begin(), ans.end());
	for (auto c : ans)cout << c;
	//system("PAUSE");
}


Measured memory_bytes: 141184
#include<stdio.h>
#include<stdlib.h>
char a[101];
int b[26] = {0};
int c[26] = {0};
int main(void)
{
	
	int n;
	while (scanf("%d",&n)!=EOF)
	{
		
		scanf("%s", a);
		int max=0;
		int num=0;
		for (int i = 0; i < n; i++)
		{
			for (int m = 0; m <= i; m++)
			{
				int v = (int)a[m] - 97;
				b[v]++;
			}
			for (int j = n - 1; j > i; j--)
			{
				
				for (int q = n - 1; q >= j; q--)
				{
					int h = (int)a[q] - 97;
					c[h]++;
				}
				
				for (int l = 0; l < 26; l++)
				{
					
					if (b[l] != 0 && c[l] != 0)
					{
						num++;
						
					}
				}
				if (num > max)
					max = num;
				num = 0;
				for (int q = 0; q < 26; q++)
				{
					c[q] = 0;
				}
			}
			for (int q = 0; q < 26; q++)
			{
				b[q] = 0;
			}
		}
		printf("%d\n", max);
	}
	
	return 0;
}

Measured memory_bytes: 128
MOD = 10 ** 9 + 7
h, w, k = gets.split.map(&:to_i)
# dp[行][列]の出現回数
dp = (h + 1).times.map { Array.new(w, 0) }
# 初期化
# dp[1行目][1列目]の出現回数は 1
dp[0][0] = 1

combination_memo = []
0.upto(4) do |selected_nums|
  (1...w).to_a.combination(selected_nums).each do |c|
    prev = -1
    selectable = true
    c.each do |num|
      if num - prev < 2
        selectable = false
        break
      end
      prev = num
    end
    combination_memo << c if selectable
  end
end

# h 行分ループする（current_h は遷移元の行）
h.times do |current_h|
  # 最適化のため、事前に 1 行分だけ参照渡しをする
  dp_current = dp[current_h]
  dp_next = dp[current_h + 1]
  # w 列分ループする（current_w は遷移元の列）
  w.times do |current_w|
    going_left = 0
    going_straight = 0
    going_right = 0
    combination_memo.each do |c|
      if c.include?(current_w)
        going_left += 1
      elsif c.include?(current_w + 1)
        going_right += 1
      else
        going_straight += 1
      end
    end
    current_count = dp_current[current_w]
    if going_left > 0
      dp_next[current_w - 1] += current_count * going_left
      dp_next[current_w - 1] %= MOD
    end
    if going_straight > 0
      dp_next[current_w] += current_count * going_straight
      dp_next[current_w] %= MOD
    end
    if going_right > 0
      dp_next[current_w + 1] += current_count * going_right
      dp_next[current_w + 1] %= MOD
    end
  end
end

puts dp[h][k - 1] % MOD


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,s1,s2,s3,s4,s5;
    cin>>s;
    s5=s;
    reverse(s5.begin(),s5.end());
    int len=s.size();
    int a=(len-1)/2;
    int b=(len+3)/2;
    s1=s.substr(0,a);
    s3=s1;

    s2=s.substr(b-1,len);
    s4=s2;
    reverse(s3.begin(),s3.end());
    reverse(s4.begin(),s4.end());
    if(s1==s3 && s2==s4 && s==s5)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<s3<<endl<<s4;
}               //Alhamduliilla...



Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

std::vector<bool> GeneratePrimeTable(const int64_t max_value) {
  // 素数の真偽表を返却する。
  // エラトステネスの篩(Sieve of Eratosthenes). O(n * log(log(n)))
  const int64_t upper_limit =
      static_cast<int64_t>(sqrt(static_cast<double>(max_value)));
  std::vector<bool> is_prime(max_value + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int64_t i = 4; i <= max_value; i += 2) {
    is_prime[i] = false;
  }
  for (int64_t p = 3; p <= upper_limit; p += 2) {
    if (is_prime[p]) {
      for (int64_t i = p * 2; i <= max_value; i += p) {
        is_prime[i] = false;
      }
    }
  }
  return is_prime;
}

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

  constexpr int64_t kMax = 1e5L;
  vector<bool> is_prime = GeneratePrimeTable(kMax);
  vector<int64_t> counts(kMax + 2, 0);
  for (int64_t i = 1; i <= kMax; i += 2) {
    if (is_prime[i]) {
      if (is_prime[(i + 1) / 2]) {
        counts[i] = 1;
      }
    }
  }
  for (int64_t i = 1; i <= kMax; ++i) {
    counts[i] += counts[i - 1];
  }
  int64_t Q;
  cin >> Q;
  for (int64_t q = 0; q < Q; ++q) {
    int64_t l, r;
    cin >> l >> r;
    cout << counts[r] - counts[l - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3900
N=int(input())
kazu=input().split(' ')
D=int(kazu[0])
X=int(kazu[1])
days=[]
count=0
for i in range(N):
  days.append(int(input()))
for i in range(N):
  a=0
  while 1:
    b=days[i]*a+1
    if b>D:
      break
    count=count+1
    a=a+1
print(count+X)

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

int main() {
  
  int N; cin >> N; int ans = 0;
  
  vector<int> vec(pow(10, 5), 0);
  
  for (int i = 0; i < N; i++) {
    
    int a; cin >> a; vec[a]++;
    
  }
  
  for (int i = 1; i < vec.size() - 1; i++) {
    
    int tmp = vec[i - 1] + vec[i] + vec[i + 1];
    
    ans = max(ans, tmp);
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int N = nextInt();
  REP(i, N) {
    int b = 0, c = 0;
    bool flag = true;
    REP(j, 10) {
      int a = nextInt();
      if (a > b) {
        b = a;
      } else if (a > c) {
        c = a;
      } else {
        flag = false;
      }
    }
    if (flag) {
      PRINT("YES");
    } else {
      PRINT("NO");
    }
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1152
#!python3.8
# -*- coding: utf-8 -*-
# aising2020/aising2020_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    L, R, d = i2nn()
    print(R // d - (L - 1) // d)
    return

main()


Measured memory_bytes: 9056
#include <stdio.h>

int N, M;
int horieyui[114514];

int main(void) {
	int i;
	int toyosakiaki = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int L, R;
		if (scanf("%d%d", &L, &R) != 2) return 1;
		horieyui[L]++;
		horieyui[R + 1]--;
	}
	for (i = 1; i <= N; i++) horieyui[i] += horieyui[i - 1];
	for (i = 1; i <= N; i++) {
		if (horieyui[i] >= M) toyosakiaki++;
	}
	printf("%d\n", toyosakiaki);
	return 0;
}


Measured memory_bytes: 512
class Team
  attr_accessor :belong,:ac,:pena
  def initialize(belong,ac,pena)
    @belong,@ac,@pena = belong,ac,pena
  end
end

loop do
  n=gets.to_i
  break if n==0
  id_list = Array.new
  total_selected = 0
  selected_as = Hash.new(0)
  teams = Hash.new
  n.times do
    i,u,a,p = gets.split.map(&:to_i)
    teams[i] = Team.new(u,a,p)
    id_list << i
  end
  id_list.sort! do |a,b|
    if teams[a].ac!=teams[b].ac
      teams[b].ac - teams[a].ac
    elsif teams[a].pena!=teams[b].pena
      teams[a].pena - teams[b].pena
    else a-b
    end
  end
  ans = []
  id_list.each do |i|
    if total_selected <10 && selected_as[teams[i].belong]<3
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    elsif total_selected < 20 && selected_as[teams[i].belong] <2
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    elsif total_selected < 26 && selected_as[teams[i].belong] ==0
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    end
  end
  puts ans
end

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

int main() {
	priority_queue<int> p;
	string op;
	int x;
	while(cin>>op)
	{
		if ( op=="insert" )
		{
			cin >> x;
			p.push(x);
		}
		if ( op == "extract")
		{
			cout<<p.top()<< "\n" ; 
			p.pop();
		}
		
		if ( op == "end")
		{
			return 0;
		}	
	}
}



Measured memory_bytes: 7152
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll A,B;
    cin >> A >> B;
    ll a,b,ans;
    if(A!=0){
        if(A%2==1){
            if((A-1)%4==0) a = (A-1) ^ 0;
            else a = (A-1) ^ 1;
        }
        else{
            if(A%4==0) a = 0;
            else a = 1;
        }

        if((B+1)%2==0){
            if((B+1)%4==0) b = 0;
            else b = 1;
        }
        else{
            if(B%4==0) b = B ^ 0;
            else b = B ^ 1;
        }
        ans =  a ^ b;
    }
    else{
        if((B+1)%2==0){
            if((B+1)%4==0) b = 0;
            else b = 1;
        }
        else{
            if(B%4==0) b = B ^ 0;
            else b = B ^ 1;
        }
        ans = b;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int K,X;
    cin>>K>>X;
    int mini=max({-1000000,X-K+1});
    int maxi=min({1000000,X+K-1});
    for(int i=mini;i<=maxi;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
shop = []
for _ in range(N):
    a, b = map(int, input().split())
    shop.append([a,b])
shop.sort()

cur = 0
cur_v = 0
for a, b in shop:
    if cur + b > M:
        cur_v += (M - cur) * a
        break
    else:
        cur += b
        cur_v += a * b
print(cur_v)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100010
int n, f[N];
vector<int> A[N];

void ff(int x) {
	vector<int> B;
	for (vector<int>::iterator i = A[x].begin(); i != A[x].end(); i ++) {
		ff(*i);
		B.pb(f[*i]);
	}
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	int l = (int) B.size();
	f[x] = l;
	for (int i = 0; i < l; i ++)
		f[x] = max(f[x], B[i]+i+1);
}

int main() {
	cin >> n;
	for (int i = 1; i < n; i ++) {
		int x;
		cin >> x;
		x --;
		A[x].pb(i);
	}
	ff(0);
	printf ("%d\n", f[0]);
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Check(int *p,int N,int *start,int target){
    
    for(int i=(*start);i<N;i++){ if(*(p+i) == target){*start = i+1; return true;} }
    return false;
}
int main(){

    int N,ans=0;
    cin >> N;
    int data[N];
    for(int i=0;i<N;i++) cin >> data[i];
    
    int key = 1,start_position=0;
    while(1){
        if(Check(&data[0],N,&start_position,key)){ ans++; key++; }
        else {break;}
    }
    if(ans == 0) cout << -1 << endl;
    else cout << N - ans << endl;
    
}

Measured memory_bytes: 4324
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, n - 1) if(s[i] != s[i + 1]) cnt++;
  int m = max(1, 1 + cnt - 2 * k);
  cout << n - m << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;


void solve() {
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	bool ap = 1;
	rep(i, n) if(a[i] % 2 == 0) if(a[i] % 3 != 0 && a[i] % 5 != 0) ap = 0;
	if(ap) cout << "APPROVED"; else cout << "DENIED";
}
int main() {
	fastio;
	solve();
}

Measured memory_bytes: 256