akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans  = B[A[0]-1]
for i in range(1, N):
    ans += B[A[i]-1]
    if A[i] == A[i-1] + 1:
        ans += C[A[i-1]-1]
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    float i,n,t,a,m=1000000,p,l;cin>>n>>t>>a;
    for(i=0;i<n;i++){
        cin>>l;
        if(m>abs(a-(t-l*0.006))){
            m=abs(a-(t-l*0.006));
            p=i+1;
        }
    }
    cout<<p<<endl;
}

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

int main(void) {
    string S;
    cin >> S;
    int N = S.size();

    string tmp;
    tmp = S;
    reverse(tmp.begin(),tmp.end());

    bool flag1 = false;
    if(S==tmp) flag1 = true;

    string S2,tmp2;
    int cnt2 = (N-1)/2;
    S2 = S.substr(0,cnt2);
    tmp2 = S2;
    reverse(tmp2.begin(),tmp2.end());

    bool flag2 = false;
    if(S2==tmp2) flag2 = true;

    string S3,tmp3;
    int cnt3 = (N+3)/2;
    S3 = S.substr(cnt3-1,N);
    tmp3 = S3;
    reverse(tmp3.begin(),tmp3.end());
    
    bool flag3 = false;
    if(S3==tmp3) flag3 = true;

    if(flag1&&flag2&&flag3) cout<< "Yes" <<endl;
    else  cout<<"No" <<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
using namespace std;

int gcd(int x, int y) {
  if(x < y) {
    std::swap(x, y);
  }

  if(y <= 0) {
    return x;
  } else {
    int r = x % y;
    return gcd(y, r);
  }
}

int main() {
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
}



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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int k,h;
  for(int i=0;i<n;i++){
    if(s.at(i) == 'A'){
      k = i;
      break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s.at(i) == 'Z'){
      h = i;
      break;
    }
  }
  
  cout << h-k+1 << endl;

  return 0;
}


Measured memory_bytes: 640
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  
  if (args[0] === '1') {
    console.log('Hello World');
  } else {
    let sum = parseInt(args[1], 10) + parseInt(args[2], 10);
    console.log(sum);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30588
from collections import deque

S = input()
Q = int(input())
Queries = [input().split() for i in range(Q)]

def start(S):
    state = {
        "S": S,
        "is_reversed": False,
        "left": deque(),
        "right": deque(),
    }

    return state


def T1(state, Query):
    state['is_reversed'] = not state['is_reversed']


def T2(state, Query):
    F = Query[1]
    C = Query[2]

    if not state['is_reversed']:
        if F == '1':
            state['left'].appendleft(C)
        else:
            state['right'].append(C)
    else:
        if F == '1':
            state['right'].append(C)
        else:
            state['left'].appendleft(C)


def output(state):
    output = ''.join(state['left']) + state['S'] + ''.join(state['right'])
    if state['is_reversed']:
        output = ''.join(list(reversed(output)))

    return output

def fetch(Query):
    operations = {
        '1': T1,
        '2': T2,
    }

    index = Query[0]
    operation = operations[index]

    return operation

def operate(state, Query):
    T = fetch(Query)
    T(state, Query)


state = start(S)
for Query in Queries:
    operate(state, Query)

answer = output(state)

print(answer)


Measured memory_bytes: 44212
N = int(input())
pf={}
m=2*N
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1

pL = list(pf.keys())
NpL = len(pL)
import itertools
Ls = list(itertools.product([0,1], repeat=NpL))

out = N
for i in range(len(Ls)):
    L = Ls[i]
    X = 1
    Y = 1
    for j in range(NpL):
        if L[j]==1:
            X *= pL[j]**pf[pL[j]]
        else:
            Y *= pL[j]**pf[pL[j]]

    R = [X,Y]            # 降順
    R.sort(); R.reverse()   # 念の為
    Q = [0]
    a,b = R[0],R[1]
    while b!=0:
        Q.append(a//b)
        R.append(a%b)
        a,b = b, a%b

    q = list(reversed(Q))
    n = len(Q)
    c = [0,1]+[0]*(n-2)
    for i in range(2,n):
        c[i] = q[i-1]*c[i-1]+c[i-2]
    C = list(reversed(c))
    if C[0]>=1 and C[1]>=1:
        cand1 = C[0]*X
        cand2 = C[0]*X-1
        if (cand1*(cand1+1))%(2*N)==0:
            out = min(out,cand1)
        if (cand2*(cand2+1))%(2*N)==0:
            out = min(out,cand2)

print(out)

Measured memory_bytes: 70472
n=int(input())
ans=0
for i in range(40):
  if i**2 <= n and ans<=i**2:
    ans=i**2
  if i**3 <= n and ans<=i**3:
    ans=i**3
  if i**5 <= n and ans<=i**5:
    ans=i**5
  if i**7 <= n and ans<=i**7:
    ans=i**7
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    ll ans = 0;
    vec a(N);
    rep(i,N) {
        cin>>a[i];
        --a[i];
    }
    rep(i,N){
        if(a[i] == i){
            ++ans;
            ++i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int dp[101010][2];
vector<int> a;

int rec(int rem, int turn){
    if(dp[rem][turn] != -1) return dp[rem][turn];
    int ret = (turn+1)%2;
    repe(i, a){
        if(rem >= i){
            if(rec(rem-i, (turn+1)%2) == turn){
                ret = turn;
            }
        }
    }
    return dp[rem][turn] = ret;
}

int main(){
    fastcin();

    int n, k;
    cin >> n >> k;
    a.assign(n, 0);
    rep(i, n) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << (rec(k, 0) == 0 ? "First":"Second") << endl;

}

Measured memory_bytes: 7296
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Data
{
public:
    int x, y, b;
    bool operator<(const Data& d) const{
        return b < d.b;
    }
};

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

    vector<Data> d(n);
    for(int i=0; i<n; ++i)
        cin >> d[i].x >> d[i].y >> d[i].b;
    sort(d.begin(), d.end());

    multiset<int> x, y;
    int k = 0;
    long long ans = 0;
    for(int i=0; i<n; ++i){
        while(k < n && d[k].b - d[i].b <= diff){
            x.insert(d[k].x);
            y.insert(d[k].y);
            ++ k;
        }

        long long dx = *x.rbegin() - *x.begin();
        long long dy = *y.rbegin() - *y.begin();
        ans = max(ans, dx * dy);

        x.erase(x.find(d[i].x));
        y.erase(y.find(d[i].y));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22116
#include<stdio.h>
#include<math.h>
#define M_PI 3.14159265358979

int main(void)
{
	int i=0,a,b,k=90;
	double x=0,y=0;

	while(i == 0)
	{
		scanf("%d,%d",&a,&b);

		if(a == 0 && b == 0)break;

		x += cos(k * M_PI / 180)*a;
		y += sin(k * M_PI / 180)*a;
		k -= b;
	}
  printf("%d\n",(int)x);
  printf("%d\n",(int)y);

  return 0;
}

Measured memory_bytes: 1032
#include <iostream>

using namespace std;

bool solve(int A, int B, char S[]) {

    int i = 0;
    while (i < A) {
        if (! isdigit(S[i])) return false;
        i++;
    }

    if (S[i] != '-') return false;
    i++;

    while (i < A + 1 + B) {
        if (! isdigit(S[i])) return false;
        i++;
    }

    return true;
}

int main() {

    int A, B;
    scanf("%d %d", &A, &B);

    char S[A + B + 1 + 1];
    scanf("%s", S);

    if (solve(A, B, S)) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
*q, = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
#print(l)
l.sort(key=lambda x:x[1], reverse=True)
for b,c in l:
  q.extend([c]*b)
  if len(q) > 2*n:
    break
print(sum(sorted(q,reverse=True)[:n]))

Measured memory_bytes: 36804
#include<iostream>
using namespace std;
int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
int main()
{
	cin>>k;
	cout<<arr[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;

int main()
{
    FAST
    int k;
    cin>>k;
    if(k%2==0)
        return cout<<-1,0;
    ll f=7;
    ll cnt=1;
    while(true){
    if(f%k==0)
        return cout<<cnt,0;
        if(cnt>k)
            return cout<<-1,0;
    f=(f%k)*10+7;
    cnt++;

    }


    return 0;
}


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


using ll = long long;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    ll x = (ll)c - (ll)a - (ll)b;
    if (x <= 0) {cout << "No" << endl; return 0;}
    if (x * x > 4 * (ll)a * (ll)b) cout << "Yes" << endl;    
    else cout << "No" << endl;
    return 0;
}


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

int main(){
  int n,m; cin >> n >> m;
  vector<int> k(n,10);
    if(m==0){
        if(n==1) cout << 0 << endl;
        else{
        printf("%d",1);
        rep(i,n-1) printf("%d",0);
        }
    }
  rep(i,m){
      int s,c; cin >> s >> c;
      s-=1;
      if(k[s]==10) k[s]=c;
      else if(k[s]!=c){
          cout << -1 << endl;
          break;
      }
      if(k[0]==0 && n!=1){
          cout << -1 << endl;
          break;
      }
      if(i==m-1){
          rep(j,n-1){
              if(k[j+1]==10) k[j+1]=0;
          }
          if(k[0]==10) k[0]=1;
          rep(j,n){
              printf("%d",k[j]);
          }
      }
  }
 return 0;
}


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

#最小公倍数でよいか？
#全てのjについてAiBiはAjで割り切れる
#計算時間は？
from fractions import gcd
mod =10**9+7
#これが邪魔だったらしい
"""
def lcd(x,y):
    g = gcd(x,y)
    return x*y//g
"""
ag = 1
for i in range(n):
    ag = ag*a[i]//gcd(ag,a[i])

ans = 0

for i in range(n):
    ans += ag//a[i]

ans %=mod

print(ans)


Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<string.h>
#include <stdlib.h>
using namespace std;

int W,H;
struct Node{
	int x,y,cost,dir;
	Node(int p_x,int p_y,int p_c,int p_dir){
		x=p_x;y=p_y;dir=p_dir;cost=p_c;
	}
};

bool operator < (Node a,Node b){
	return a.cost>b.cost;
};

bool in(int x,int y){
	if(x<0 || y<0 || x>=W || y>=H) return false;
	return true;
}

int solve(){
	vector<vector<char> > M(H,vector<char>(W));
	vector<int> S;

	for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			char c;
			cin>>c;
			M[y][x]=c;
			if(c=='S'){
				S.push_back(x);
			}
		}
	}

	priority_queue<Node> Q;
	int cost[2][60][30];
	memset(cost,-1,sizeof(cost));

	for(int i=0;i<S.size();i++){
		Q.push(Node(S[i],H-1,0,0));
		Q.push(Node(S[i],H-1,0,1));
	}
	while(!Q.empty()){
		Node t=Q.top();
		Q.pop();
		if(cost[t.dir][t.y][t.x]>=0) continue;
		cost[t.dir][t.y][t.x]=t.cost;
		int mul,next;
		if(t.dir==0){mul=1;next=1;}
		else{mul=-1;next=0;}

		for(int x=1;x<=3;x++){
			for(int y=-2;y<=2;y++){
				if(x+abs(y)>3) continue;
				int nx=t.x+x*mul;
				int ny=t.y+y;
				if(!in(nx,ny)) continue;

				if(M[ny][nx]=='T') return t.cost;
				if(!isdigit(M[ny][nx])) continue;

				Q.push(Node(nx,ny,t.cost+M[ny][nx]-'0',next));
			}
		}
	}
	return -1;
}

int main()
{
	while(cin>>W>>H){
		if(W==0) return 0;
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 0
package main

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

func main() {
	sc := NewScanner()

	k := sc.ReadInt()
	if k < 10 {
		fmt.Println(k)
		return
	}

	prevRow := make([][]int64, 12)
	for i := 1; i <= 10; i++ {
		n := int64(i - 1)
		prevRow[i] = []int64{n}
	}
	digitCount := 1
	lunlunCount := 9
	for {
		digitCount++
		row := make([][]int64, 12)

		broken := false
		for colI := 1; colI <= 10; colI++ {
			mostLeftNumber := colI - 1

			lunlunNumbers := []int64{}
			slices := [][]int64{prevRow[colI-1], prevRow[colI], prevRow[colI+1]}
			for _, prevLunlunNumbers := range slices {
				for _, prevN := range prevLunlunNumbers {
					lunlunNumber := int64(mostLeftNumber)*
						PowInt64(int64(10), uint(digitCount-1)) +
						prevN
					lunlunNumbers = append(lunlunNumbers, lunlunNumber)

					if mostLeftNumber > 0 {
						lunlunCount++
						if lunlunCount >= k {
							fmt.Println(lunlunNumber)
							broken = true
							break
						}
					}
				}
				if broken {
					break
				}
			}
			row[colI] = lunlunNumbers

			if broken {
				break
			}
		}
		if broken {
			break
		}
		prevRow = row
	}
}

// util
// *   math(int)

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   math(int)

func AbsInt64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Li = new long[N+1];
            Li[0] = 2;
            Li[1] = 1;
            for (var i = 2; i <= N; ++i)
                Li[i] = Li[i - 1] + Li[i - 2];
            WriteLine(Li[N]);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int p[5010],q[5010];

int main() {
	int a,b;
	cin>>a>>b;
	rep(i,a)cin>>p[i];
	rep(i,b)cin>>q[i];
	int res=0;
	rep(i,b){
		int j,k=0;
		repn0(j,i,b-1){
			while(k<a&&p[k]!=q[j])++k;
			if(k==a)break;
			++k;
		}
		chmax(res,j-i);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 872
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> mp;
typedef pair<mp,mp> mmp;
ll inf =  1e9;

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

int main(){
while(1){
    int w,h;
    cin>>w>>h;
    if(w==0)break;
    vector<vector<bool> >  mtl( h+2,vector<bool>(w+2,false) ) ;
    vector<vector<bool> >  mtr( h+2,vector<bool>(w+2,false) ) ;
    vector<mp> s(2),g(2);
    for(int i=1;i<=h;i++){
	string st;
	cin>>st;
	for(int j=1;j<=w;j++){
	    char tmp = st[j-1];
	    if( tmp =='.'){
		mtl[i][j] = true;
	    }
	    if( tmp =='%'){
		mtl[i][j] = true;
		g[0] =  mp(i,j) ;
	    }
	    if( tmp =='L'){
		mtl[i][j] = true;
		s[0] = mp(i,j) ;
	    }
	}

	cin>>st;
	for(int j=1;j<=w;j++){
	    char tmp = st[j-1];
	    if( tmp =='.'){
		mtr[i][j] = true;
	    }
	    if( tmp =='%'){
		mtr[i][j] = true;
		g[1] = mp(i,j) ;
	    }
	    if( tmp =='R'){
		mtr[i][j] = true;
		s[1] = mp(i,j) ;
	    }
	}
    }
    mmp goal1 = mmp( g[0] , g[1] );
    set<mmp> state;
    state.insert(mmp(s[0],s[1]) );
    queue< mmp > q;
    bool f = true;
    q.push( mmp( s[0], s[1] ) );
    while( !q.empty() ){
	mmp now = q.front();
	q.pop();
	if( now == goal1  ){
	    cout<<"Yes"<<endl;
	    f = false;
	    break;
	}
	mp len = now.first;
	mp rin = now.second;
	//cout<<len.first<<' '<<len.second<<' '<<rin.first<<' '<<rin.second<<endl;
	for(int i=0;i<4;i++){
	    mp nlen = mp(len.first + dx[0][i] , len.second + dy[0][i]);
	    mp nrin = mp(rin.first + dx[1][i] , rin.second + dy[1][i]);
	    if( !( mtl[nlen.first][nlen.second] || mtr[nrin.first][nrin.second] ) )continue;
	    if( !mtl[nlen.first][nlen.second] ) nlen = len;
	    if( !mtr[nrin.first][nrin.second] ) nrin = rin;
	    if( state.find( mmp( nlen ,nrin ) ) != state.end() )continue;
	    if( mmp( nlen ,nrin ) != goal1 && (nlen == g[0] || nrin == g[1] ) )continue;
	    state.insert( mmp( nlen , nrin ) );
	    q.push( mmp( nlen , nrin ) );
	}
    }
    if( f){
	cout<<"No"<<endl;
    }
    /*for(int i=1;i<=h;i++){
	for(int j=1;j<=w;j++){
	    if( mtr[i][j] )cout<<".";
	    else cout<<"#";
	}
	cout<<endl;
    }*/
}
    return 0;
}



Measured memory_bytes: 108812
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    int a = 1024;
    vector<int> b;
    while( a != 0 ){
      if( n / a != 0 ){
        n %= a;
        b.push_back(a);
      }
      a /= 2;
    }
    for(int i=0; i<b.size(); i++){
      if( i != b.size()-1 ) cout << b[b.size()-1-i] << " ";
      else cout << b[b.size()-1-i] << endl;
    }

  }


  return 0;
}


// EOF

Measured memory_bytes: 3068
#include <cstdio>

typedef unsigned int UInt;

UInt h[100000];
UInt n,max=0;

UInt work(UInt start) {
    UInt former=h[start++];
    UInt count=0;
//  printf("%u <=? %u && %u <? %u\n",h[start],former,start,n);
    while(h[start]<=former && start<n) {
//      printf("%u ",h[start]);
        count++;
        former=h[start++];
    }
//  printf("%u\n",count);
    if(count>max)max=count;
    return start;
}

int main() {
    scanf("%u",&n);
    for(UInt i=0;i<n;i++)scanf("%u",h+i);
    UInt i=0;
    while(i<n) {
        i=work(i);
    }
    printf("%u",max);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

int main() {

	const int inf = 100000000;

	int n, m;
	cin >> n >> m;

	int a[1000], b[1000], c[1000], dist[100][100];

	//入力を受け取る
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
	}

	//距離用の配列の初期化
	//自己辺は無いのでi=jは0
	//それ以外は未到達にしておく。
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				dist[i][j] = 0;
			}
			else {
				dist[i][j] = inf;
			}
		}
	}	

	//隣接している頂点i-jに辺を張る
	//今記録されている値よりも、直接いったほうが近ければ辺を貼りなおす。
	for (int i = 0; i < m; i++) {
		dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
		dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
	}

	//WFで任意の2点間の最短距離を格納していく。
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = m;
	//辺を一つ一つみていって、最短距離＋直接つないだ距離＝最短距離になっているか
	//調べる

	//始点iを一つ選んでくる。
	for (int i = 0; i < m; i++) {
		bool shortest = false;
		//終点jに対して
		for (int j = 0; j < n; j++)if (dist[j][a[i]] + c[i] == dist[j][b[i]])shortest = true;
		if (shortest == true) {
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import std.cstream, std.algorithm, std.typecons, std.stdio;

class UnionFind {
  int []par;
  this(int n){
    par = new int[n];
    for(int i = 0; i < n; i++){
      par[i] = i;
    }
  }

  int find(int v){
    if(par[v] == v) return v;
    return par[v] = find(par[v]);
  }

  void unite(int v, int u){
    v = find(v); u = find(u);
    if(v == u) return;
    par[v] = u;
  }

  bool same(int v, int u){
    return find(v) == find(u);
  }
}

alias Tuple!(int, "cost", int, "u", int, "v") Edge;
const int INF = 999999999;

int solve(int n, Edge[] edges){
  int cnt = 0, res;
  UnionFind uf = new UnionFind(n + 1);
  foreach(e; edges){
    if(uf.same(e.u, e.v))continue;
    uf.unite(e.u, e.v);
    res = e.cost - edges[0].cost;
    cnt += 1;
  }
  if(cnt != n - 1)return INF;
  return res;
}

void main(){
  int n, m, ans;
  while(true){
    din.readf(&n, &m);
    if(n == 0)break;
    Edge[] edges = new Edge[m];
    for(int i = 0; i < m; i++){
      din.readf(&edges[i].u, &edges[i].v, &edges[i].cost);
    }
    sort(edges);
    ans = INF;
    for(int i = 0; i < m; i++){
      ans = min(ans, solve(n, edges[i..$]));
    }
    if(ans == INF) ans = -1;
    writeln(ans);
  }
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  if(n%2) cout<<n*2<<endl;
  else cout<<n<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  string s;
  cin>>n>>m;
  if(n*500 >= m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int x[] = new int[5];
		int y =1000009;
		int sum = 0;
		for (int n = 0; n < 5; n++) {
			x[n] = stdin.nextInt();
			if (x[n] % 10 != 0) {
				sum = sum + (x[n] / 10 + 1) * 10;
			} else {
				sum = sum + x[n];
			}
			if ((x[n] % 10) <= (y % 10)&&x[n]%10!=0) {
				y = x[n];
			}
		}
			sum = sum - (y / 10 + 1) * 10 + y;
			if(x[0]%10==0&&x[1]%10==0&&x[2]%10==0&&x[3]%10==0&&x[4]%10==0) {
				sum = sum +1;
			}

		
		System.out.println(sum);

	}
}

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

#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000
 
using namespace std;
typedef long long int ll;
 
const int INF = 1<<30;
const ll LINF = ll(1e18);
const ll MOD = ll(1e9+7);
 
int main(){
  int n, x;cin>>n>>x;
  vector<ll> a(n), mcost(n);
  rep(i, n){
    cin>>a[i];
    mcost[i]=a[i];
  }
  ll ans = LINF;
  rep(k, n){ // cast a spell k times
    ll cost = 0LL;
    rep(i, n){
      mcost[i] = min(mcost[i], a[(i+n-k)%n]);
      cost += mcost[i];
    }
    ans = min(ans, cost+ll(k)*x);
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}

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

int main() {
    int n; scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v, w; scanf("%d%d%d", &u, &v, &w);
        a[u] ^= w;
        a[v] ^= w;
    }
    vector<int> cnt(16);
    for (int i = 0; i < n; ++i) cnt[a[i]]++;
    int ans = 0;
    cnt[0] = 0;
    for (int i = 1; i < 16; ++i) {
        ans += cnt[i] / 2;
        cnt[i] &= 1;
    }
    vector<int> gd(1 << 16), dp(1 << 16);
    for (int s = 0; s < (1 << 16); ++s) {
        int v = 0;
        for (int i = 0; i < 16; ++i) {
            if (s >> i & 1) v ^= i;
        }
        if (v == 0) gd[s] = 1;
    }
    dp[0] = 0;
    for (int s = 1; s < (1 << 16); ++s) {
        dp[s] = -(1 << 16);
        for (int sub = s; sub > 0; sub = (sub - 1) & s) {
            if (gd[sub]) dp[s] = max(dp[s], dp[s ^ sub] + 1);
        }
    }
    int mask = 0;
    for (int i = 0; i < 16; ++i) {
        if (cnt[i] > 0) {
            mask |= (1 << i);
            ans++;
        }
    }
    printf("%d\n", ans - dp[mask]);
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=res*x;
	x=x*x;
	n=n/2;
	}
	return res;
	
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i;
    string s;
    cin>>s;
    if(s.length()%2==1)
    cout<<"No";
    else
    {
    	for(i=0;i<s.length();i=i+2)
        {
    	    if(s[i]=='h'&&s[i+1]=='i')
    	    {
    	    	continue;
			}
			else
			{
				cout<<"No";
				return 0;
			}
	    }
	    cout<<"Yes";
	}
	
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct dta{
  int n,x,y;
};
bool dtaC(const dta& pf,dta&ps){
  return pf.n < ps.n;
}
int main(){
  int h,w,d;cin>>h>>w>>d;
  int mp[h][w];
  vector<dta> Z[d];
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>mp[i][j];
      Z[mp[i][j]%d].push_back({mp[i][j],i+1,j+1});
    }
  }
  for(int i = 0; d > i; i++){
    sort(Z[i].begin(),Z[i].end(),dtaC);
  }
  vector<int> rui[d];
  for(int i = 0; d > i; i++){
    rui[i].push_back(0);
    for(int j = 1; Z[i].size() > j; j++){
      rui[i].push_back(rui[i][j-1] + abs(Z[i][j].x-Z[i][j-1].x)+abs(Z[i][j].y-Z[i][j-1].y));
    }
  }
  int q;cin>>q;
  while(q--){
    int l,r;cin>>l>>r;
    if(r%d)cout << rui[r%d][r/d] - rui[l%d][l/d] << endl; 
    else cout << rui[r%d][r/d-1] - rui[l%d][l/d-1] << endl;
  }
}

Measured memory_bytes: 10624
#include<iostream>

using namespace std;

const static int N_MAX = 100;

void Swap(int &a, int &b)
{
	int t = b;
	b = a;
	a = t;
}

int SelectionSort(int *A, int N)
{
	int count = 0;
	int minj;

	for (int i = 0; i < N - 1; i++)
	{
		minj = i;
		for (int j = i+1; j < N; j++)
		{
			if (A[j] < A[minj])minj = j;
		}
		if (minj > i)
		{
			swap(A[i], A[minj]);
			count++;
		}
	}

	return count;
}

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

	sum = SelectionSort(A, N);

	for (int i = 0; i < N; i++)
	{
		if (i <N-1)
			cout << A[i] << ' ';
	}

	cout << A[N-1] << endl << sum << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>

using namespace std;

int search(int A[],int n,int key)
{
	int i=0;
	A[n]=key;
	while(A[i]!=key)
		i++;
	return i!=n;
}

int main(int argc, char const *argv[])
{
	int n,m,i,A[10001],sum=0,key;
	scanf("%d",&m);
	for (i = 0; i < m; ++i)
	{
		scanf("%d",&A[i]);
	}

	scanf("%d",&n);
	for (i = 0; i < n; ++i)
	{
		scanf("%d",&key);
		if (search(A,m,key))
		{
			sum++;
		}
	}
	printf("%d\n",sum );
	return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
         int BIG=1e18;
         int n;
         cin>>n;
         int mul=1;
         int a[n];
         bool g=false;
         rep(i,0,n){cin>>a[i];if(a[i]==0)g=true;}
         if(g)
         {
               cout<<0<<endl;
               return 0;
         }
         rep(i,0,n)
         {
               int x;
               x=a[i];
               if(mul>BIG/x)
               {
                     cout<<-1<<endl;
                     return 0;
               }
               mul*=x;
         }
         cout<<mul<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 4436
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;


const ll inf = (1LL << 31) - 1;
const long long MOD = 1000000007;


int main() {
    string s;
    cin >> s;
    ll memo = 0;
    rep(i, s.size()) {
        ll a = s[i] - '0';
        memo += a;
    }
    if (memo % 9 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;
using namespace std::chrono;

const int MOD = 1e+9 + 7;
const int LIM = 2e+5 + 10;

void mod_mult(int& x, int y) {
  x = 1LL * x * y % MOD;
}

vector<vector<int>> balls(LIM);
vector<int> fact(LIM);
vector<int> inv_fact(LIM);

int bin_pow(int x, int pw) {
  int res = 1;
  while (pw > 0) {
    if (pw & 1) {
      mod_mult(res, x);
      --pw;
    } else {
      mod_mult(x, x);
      pw >>= 1;
    }
  }
  return res;
}

int get_inv(int x) {
  return bin_pow(x, MOD - 2);
}

void init() {
  fact[0] = 1;
  for (int i = 1; i < LIM; ++i) {
    fact[i] = fact[i - 1];
    mod_mult(fact[i], i);
  }

  for (int i = 0; i < LIM; ++i) {
    inv_fact[i] = get_inv(fact[i]);
  }
}

int main() {
  auto start = high_resolution_clock::now();

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

  init();

  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 0; i < n; ++i) {
    int c, w;
    cin >> c >> w;
    balls[c].push_back(w);
  }

  set<pair<int, int>> _min;
  for (int i = 0; i < LIM; ++i) {
    sort(balls[i].begin(), balls[i].end(), greater<int>());
    if (balls[i].size() > 0)
      _min.emplace(balls[i].back(), i);
  }

  int ans = 1;
  while (_min.size() > 0) {
    map<int, int> color_cnt;
    int c1 = _min.begin()->second;;
    int w1 = _min.begin()->first;
    ++color_cnt[c1];
    int cnt = 1;

    _min.erase(make_pair(w1, c1));
    balls[c1].pop_back();

    while (balls[c1].size() > 0 && balls[c1].back() + w1 <= x) {
      balls[c1].pop_back();
      ++color_cnt[c1];
      ++cnt;
    }

    while (_min.size() > 0) {
      int c2 = _min.begin()->second;
      int w2 = _min.begin()->first;

      if (w1 + w2 > y)
        break;

      _min.erase(make_pair(w2, c2));
      while (balls[c1].size() > 0 && balls[c1].back() + w2 <= y) {
        balls[c1].pop_back();
        ++color_cnt[c1];
        ++cnt;
      }

      while (balls[c2].size() > 0 && (balls[c2].back() + w1 <= y || balls[c2].back() + w2 <= x)) {
          balls[c2].pop_back();
          ++color_cnt[c2];
          ++cnt;
      }

      if (balls[c2].size() > 0)
        _min.emplace(balls[c2].back(), c2);
    }

    if (balls[c1].size() > 0)
      _min.emplace(balls[c1].back(), c1);

    mod_mult(ans, fact[cnt]);
    for (const auto& it : color_cnt)
      mod_mult(ans, inv_fact[it.second]);
  }
  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


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

a.sort()

A = sum(a)
if x > A:
  print(N-1)

else:
  cnt = 0
  for i in range(N):
    if x >= a[i]:
      x -=a[i]
      cnt += 1
  print(cnt)

Measured memory_bytes: 9108
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
        var n = vars[0];

        System.Console.WriteLine((n / (decimal)3) * (n / (decimal)3) * (n / (decimal)3));
    }

}

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

int main() {
    int N, K;  cin >> N >> K;
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        int a;  cin >> a;
        ++mp[a];
    }
    vector<int> v;
    for (auto e : mp) v.push_back(e.second);
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < (int)v.size() - K; ++i) ans += v[i];
    cout << ans << endl;
}


Measured memory_bytes: 13472
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){

    int N,K;
    cin >> N >> K;
    
    vector<int> p(N,0);
    for(int i=0;i<N;i++) cin >> p[i];

    sort(p.begin(), p.end());
    int res=0;
    for(int i=0;i<K;i++){
        res += p[i];
    }

    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3636
N, M = map(int, input().split())
A = list(map(int, input().split()))
B_C = [list(map(int, input().split())) for j in range(M)]

B_C = sorted(B_C, key=lambda x:x[1], reverse=True)

B = [B_C[j][0] for j in range(M)]
C = [B_C[j][1] for j in range(M)]

D = []
for j in range(M):
    D += [C[j]] * B[j]
    if len(D) >= N:
        break

A.sort()

for i in range(N):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
    if i == len(D) - 1:
        break

print(sum(A))


Measured memory_bytes: 95384
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  map<int, long long> mp;

  for (int i=0; i<n; i++) {
    mp[a[i]]++;
    mp[a[i] - 1]++;
    mp[a[i] + 1]++;
  }
  long long ans = 0;
  for (auto it : mp) {
    ans = max(ans, it.second);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 9492
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var xy = Input.ar;
        var li = new[] { new List<int>(), new List<int>() };
        var s = str.Trim().Split('T');
        for (var i = 0; i < s.Length; i++)
            if (i % 2 == 0)
                li[0].Add(s[i].Length);
            else li[1].Add(s[i].Length);
        for(var i=0;i<2;i++)
        {
            var dp = Enumerable.Repeat(0, li[i].Count).Select(v => new HashSet<int>()).ToArray();
            if (i == 0) dp[0].Add(li[i][0]);
            else
            {
                if (li[1].Count == 0)
                {
                    WriteLine(xy[1] == 0 ? "Yes" : "No");
                    return;
                }
                dp[0].Add(li[i][0]);
                dp[0].Add(-li[i][0]);
            }
            for(var j=1;j<li[i].Count;j++)
                for(var h=-str.Length;h<=str.Length;h++)
                    if (dp[j-1].Contains(h))
                    {
                        if (-str.Length <= h - li[i][j])
                            dp[j].Add(h - li[i][j]);
                        if (str.Length >= h + li[i][j])
                            dp[j].Add(h + li[i][j]);
                    }
            if (!dp[li[i].Count-1].Contains(xy[i]))
            {
                WriteLine("No");
                return;
            }
        }
        WriteLine("Yes");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static string[] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 119808
import java.util.Scanner;

/**
 * Tax Increase
 * 
 * https://atcoder.jp/contests/abc158/tasks/abc158_c
 */
public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        int A = sc.nextInt();
        int B = sc.nextInt();

        int a = (int) Math.ceil(A / 0.08);
        int b = (int) Math.ceil(B / 0.1);

        int c = Math.max(a, b);

        if (Math.floor(c * 0.08) == A && Math.floor(c * 0.1) == B) {
            System.out.println(c);
        } else {
            System.out.println(-1);
        }
    }

}


Measured memory_bytes: 35700
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int one = 0;
    one++;
    int n = s.size();
    string t = "";
    s += 'a' - one;
    vector <string> ans;
    for (int i = 0; i <= n; i++)
    {
        for (char c = 'z'; c > s[i]; c--)
        {
            string q = t + c;
            map <char, int> cnt;
            for (char c : q)
            {
                cnt[c]++;
            }
            bool bad = false;
            for (auto c : cnt)
            {
                if (c.second > one)
                {
                    bad = true;
                }
            }
            if (!bad)
            {
                ans.push_back(q);
            }
        }
        t += s[i];
    }
    if (ans.size())
    {
        cout << ans.back() << '\n';
    }
    else
    {
        cout << "-1" << '\n';
    }
}


Measured memory_bytes: 256
// A - Kyu in AtCoder
#include <bits/stdc++.h>
using namespace std;

int main(){
	int x; cin>>x;
	if(x < 600) x = 8;
	else if(x < 800) x = 7;
	else if(x < 1000) x = 6;
	else if(x < 1200) x = 5;
	else if(x < 1400) x = 4;
	else if(x < 1600) x = 3;
	else if(x < 1800) x = 2;
	else x = 1;
	cout<< x <<endl;
}


Measured memory_bytes: 3544
#if 1
#include<iostream>
using namespace std;
void SelectionSort(int a[], int n ,int &sum) {
	int i, j, min;
	for ( i = 0; i < n-1; i++) {
		//第一层循环为无序区
		min = i;//k记录当前的下标，到时需要交换
		for ( j = i + 1; j < n; j++) {
			//第二层循环为有序区
			if (a[j] < a[min])
				min = j; //此时min便是最小的数
		}
		if (min != i) {
			//为了防止最小数有两个，即最外层for循环i是最小数，无序区也有一个最小数，这样交换过来排序便不再稳定
			swap(a[min], a[i]);
			sum++;
		}
	}
}
void Print(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
}
int main() {
	int n, sum = 0;
	cin >> n;
	int a[105];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	SelectionSort(a, n, sum);
	Print(a, n);
	cout << endl << sum << endl;
}
#endif




Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    cout << ps(15) << 2*PI*n << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3808