akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
S = input()

alp = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

for s in S:
    print(alp[(alp.index(s) + N) % 26], end="")


Measured memory_bytes: 48496
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let mut s=0;
    let a=(0..n).map(|_|read::<i32>()).collect::<Vec<i32>>();
    for i in 0..n{
        let b=read::<i32>();
        if a[i]>b{s+=a[i]-b}
    }
    println!("{}",s)
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vector<pii> pos; // 1が連続する半壊区間を格納
  int l, r; l = r = 0;
  while(r < n and s[r] == '1') r++;
  pos.emplace_back(l,r);
  l = r = 0;
  while(1){
    while(l < n and s[l] == '1') l++;
    while(l < n and s[l] == '0') l++;
    r = l;
    while(r < n and s[r] == '1') r++;
    pos.emplace_back(l,r);
    if(r >= n) break;
  }
  dump(pos);
  int ans = -inf;
  rep(i,pos.size()-k) ans = max(ans, pos[i+k].second-pos[i].first);
  if(k >= pos.size()) ans = max(ans, pos.back().second-pos.front().first);
  cout << ans << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll check(ll N)
{
  for (ll i = 0; i * i <= 2 * N; ++i) {
    if (i * (i + 1) == 2 * N) {
      return i + 1;
    }
  }
  return 0;
}

int main()
{
  ll N;
  cin >> N;
  ll K = check(N);
  if (K == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << K << endl;
  ll s = 2 * N / K;
  vector<vector<ll>> ans(K);
  ll cnt = 1;
  for (ll i = 0; i < K - 1; ++i) {
    for (ll j = i + 1; j < K; ++j) {
      ans.at(i).push_back(cnt);
      ans.at(j).push_back(cnt);
      cnt += 1;
    }
  }
  for (ll i = 0; i < K; ++i) {
    cout << s << ' ';
    for (ll j = 0; j < s; ++j) {
      cout << ans.at(i).at(j) << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(ll i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll n;cin>>n;
    vector<ll> div;
    for(ll i=1;i<round(sqrt(n))+1;i++){
        if(n%i==0){
            div.push_back(i);
            div.push_back(n/i);
        }
    }
    sort(div.begin(),div.end());
    ll ans=0;
    if(div.size()%2==1) ans=(div[div.size()/2]-1)*2;
    else ans=div[div.size()/2-1]+div[div.size()/2]-2;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
char s[110]; bool b=0,c=0; 
int main(){
	scanf("%s",s+1); int n=strlen(s+1); 
	for (int i=1;i<=n;i++) if (s[i]=='C') b=1; else if (s[i]=='F'&&b) c=1; 
	if (b&&c) printf("Yes"); else printf("No"); 
} 	

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if (n>=k) printf("%d",k*x+(n-k)*y);
    else printf("%d",n*x);
    return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, M; cin >> N >> M;
    if (M != 100)cout << pow(100, N) * M << endl;
    else cout << int(pow(100, N + 1) + pow(100, N)) << endl;
}

Measured memory_bytes: 3884
import numpy as np

D = int(input())
c = np.array(list(map(int,input().split())))
s = [list(map(int,input().split())) for _ in range(D)]

last = np.zeros(26,int)

score = 0

for i in range(D):
    t = int(input())
    t -= 1
    score += s[i][t]
    last += 1 
    last[t] = 0
    score -= np.dot(c,last)
    
    print(score)

Measured memory_bytes: 27608
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
map<ll,ll>a,b;
int main()
{
     int n,gcd=0,g;
     cin>>n;
     dom(i,n)
     {
          dom(j,n)
          {
               dom(k,n)
               {
                    g=__gcd(i,j);
                    g=__gcd(g,k);
                    gcd+=g;
               }
          }
     }
     cout << gcd << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <complex>
using namespace std;
#define EPS (pow(10, -10))
#define EQ(a,b) (abs((a)-(b)) < EPS)


typedef complex<double> P;

double cross(P a, P b) {
    return(a.real() * b.imag() - a.imag() * b.real());
}

int is_parallel(P a1, P a2, P b1, P b2) {
    return(EQ(cross(a1 - a2, b1 - b2), 0.0));
}

int main(void) {
    int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;
    
    cin >> n;
    for(int r = 0; r < n; r++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
        if(is_parallel(a, b, c, d)) cout << "YES" << endl;
        else                        cout << "NO" << endl;
    }
    return(0);
}

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

int main()
{
  int n;
  int ans = 0;
  string aaa,bbb,ccc;
  cin >> n >> aaa >> bbb >> ccc;
  for(int i = 0; i < n; i++) {
    if(aaa.at(i) == bbb.at(i) && bbb.at(i) == ccc.at(i)) {
    }
    else if(aaa.at(i) != bbb.at(i) && bbb.at(i) != ccc.at(i) && aaa.at(i) != ccc.at(i)) {
      ans += 2;
    }
    else {
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}

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

int main(void)
{
    string S = "";
    cin >> S;
    if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A')
        cout << "No";
    else if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B')
        cout << "No";
    else
        cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int dp[1001][1001];
	int n,W;
	int v[1000],w[1000];
	int num=0;
	while(cin>>W,W)
	{
		num++;
		cin>>n;
		memset(dp,sizeof(dp),0);
		for(int i = 0; i < n; ++i)
		{
			scanf("%d,%d",&v[i],&w[i]);
		}
		for(int i = 1; i <= n; ++i)
		{
			for(int j = 1; j <= W; ++j)
			{
				if(j<w[i-1]) dp[i][j]=dp[i-1][j];
				else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
			}
		}
		
		int mv=0,mw;
		for(int j = 0; j <= W ; ++j)
		{
			if(mv<dp[n][j]){ mv=dp[n][j]; mw=j;}
		}
		cout<<"Case "<<num<<":"<<endl;
		cout<<mv<<endl;
		cout<<mw<<endl;
	}
  return 0;
}

Measured memory_bytes: 5160
from collections import deque

n = int(input())
a = list(map(int, input().split()))

d = deque()
for i in range(n):
    if i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n % 2 == 0:
    print(*list(d)[::-1])
else:
    print(*d)

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

typedef long long LL;
const int N = 200005, mod = 1000000007;

void reduce(int &x) { x += x >> 31 & mod; }


int n, m, f[N], g[N]; std::string s;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m >> s;
	if (s[0] == 'B') for (char &ch : s) ch ^= 'R' ^ 'B';
	if (std::count(s.begin(), s.end(), 'B')) {
		if (n & 1) return std::cout << "0\n", 0;
		int now = 0, bound = std::find(s.begin(), s.end(), 'B') - s.begin() | 1;
		for (char ch : s) {
			if (ch == 'B') {
				if (now & 1) bound = std::min(bound, now);
				now = 0;
			} else ++now;
		}
		bound = bound + 1 >> 1;
		f[0] = 1, g[0] = 1;
		for (int i = 1; i <= n / 2; ++i) {
			reduce(f[i] = g[i - 1] - (i >= bound + 1 ? g[i - bound - 1] : 0));
			reduce(g[i] = g[i - 1] + f[i] - mod);
		}
		int ans = 0;
		for (int i = 1; i <= bound && i <= n / 2; ++i)
			ans = (ans + 2LL * i * f[n / 2 - i]) % mod;
		std::cout << ans << '\n';
	} else {
		f[0] = 2, f[1] = 1;
		for (int i = 2; i <= n; ++i)
			reduce(f[i] = f[i - 1] + f[i - 2] - mod);
		std::cout << f[n] << '\n';
	}
	return 0;
}

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

int des(int x, int y) {
  return x > y;
}

int main() {
  int a[10];
  for (int i=0; i<10; i++) {
    cin >> a[i];
  }
  //sort(a, a+10, [](const int& x, const int& y) {return x > y;});
  sort(a, a+10, des);
  for (int i=0; i<3; i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 1180
import math

LL = [0 for i in range(1001)]

N = int(input())


for i in range(1,N + 1):
	L = []
	if i == 1:
		pass
	elif i == 2:
		LL[2] += 1
	else:
		n = int(math.sqrt(N) // 1)
		x = 2
		for j in range(n + 2):
			while True:
				if i % x == 0:
					L.append(x)
					i = int(i // x)
				else:
					break
			x += 1
		if i != 1:
			L.append(i)
	for j in L:
		LL[j] += 1


ans = 1
for i in LL:
	if i == 0:
		pass
	else:
		ans = ans * (i + 1)
		ans = ans % 1000000007

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

bool leap(int y)
{
	if(y % 400 == 0)
	{
		return true;
	}
	else if(y % 100 != 0 && y % 4 == 0)
	{
		return true;
	}
	return false;
}

int main()
{
	int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	int days_leap[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int y1,m1,d1,y2,m2,d2;
	while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2)
	{
		if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0)
		{
			break;
		}

		int sum = 0;

		if(y2 - y1 == 0)
		{
			if(m2 - m1 == 0)
			{
				sum += d2 - d1;
			}
			else
			{
				if(leap(y1))
				{
					sum += days_leap[m1] - d1;
					
					REP(i,m1+1,m2)
					{
						sum += days_leap[i];
					}
					
					sum += d2;
				}
				else
				{
					sum += days[m1] - d1;

					REP(i,m1+1,m2)
					{
						sum += days[i];
					}

					sum += d2;
				}
			}
		}
		else
		{
			if(leap(y1))
			{
				sum += days_leap[m1] - d1;
				
				REP(i,m1+1,13)
				{
					sum += days_leap[i];
				}

			}
			else
			{
				sum += days[m1] - d1;

				REP(i,m1+1,13)
				{
					sum += days[i];
				}
			
			}

			REP(i,y1+1,y2)
			{
				if(leap(i))
				{
					sum += 366;
				}
				else
				{
					sum += 365;
				}
			}

			if(leap(y2))
			{
				REP(i,1,m2)
				{
					sum += days_leap[i];
				}
				sum += d2;
			}
			else
			{
				REP(i,1,m2)
				{
					sum += days[i];
				}
				sum += d2;
			}

		}

		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes\n";
	}
	else if (abs(a - c) <= d) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	int n; cin>>n;
	vs a(n);
	rep(i,n) cin>>a[i];
	
	vi score(n);
	
	rep(_,1000){
		int mx=*max_element(all(score));
		vi cand;
		rep(i,n) if(score[i]>=0.9*mx) cand.push_back(i);
		
		int me=cand.size()*rand()/(RAND_MAX+1);
		cout<<cand[me]+1<<endl;
		
		int you; cin>>you; you--;
		rep(i,n){
			if(a[i][you]=='o') score[i]+=3;
			if(a[i][you]=='-') score[i]+=1;
		}
	}
	
	return 0;
}

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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    r = inf
    for i in range(1,101):
        t = 0
        for x in a:
            t += (x-i) ** 2
        if r > t:
            r = t

    return r


print(main())





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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){

        IOS;
        map<char,bool> e,o;
        e['R']=true;e['U']=true;e['D']=true;
        o['L']=true;o['U']=true;o['D']=true;
        string s;
        cin >> s;
        bool ok=true;
        for(int i=1;i<=s.length();i++){
             if(i&1){
                  if(!e.count(s[i-1]))
                   { ok = false; break; }
             } else{
                 if(!o.count(s[i-1]))
                    { ok = false;break; } 
             }
        }
        if(!ok)
          cout << "No" << endl;
        else
          cout << "Yes" << endl;
        
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
A = sorted(map(int, input().split()))
U = 10**6
B = [0]*(U+1)
C = Counter(A)
ans = 0
for a in A:
  if B[a]:
    continue
  if C[a] == 1:
    ans += 1
  for j in range(a, U+1, a):
    B[j] = 1
print(ans)

Measured memory_bytes: 45072
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long S,x_1,x_2,x_3,y_1,y_2,y_3;
int main()
{
	scanf("%lld",&S);
	x_1=y_1=0;
	x_2=1,y_3=(1000000000-S%1000000000)%1000000000;
	x_3=1000000000,y_2=(S+999999999)/1000000000;
	printf("%lld %lld %lld %lld %lld %lld",x_1,y_1,x_2,y_2,x_3,y_3);
//	printf("\n%lld",x_1*(y_2-y_3)+x_2*(y_3-y_1)+x_3*(y_1-y_2));
	return 0;
}


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

ans=[0]*n
for i in range(n):
  if i%2 ==0:
    ans[n//2+i//2]=a[i]
  else:
    ans[n//2-i//2-1]=a[i]

print(str(ans).replace("[","").replace("]","").replace(",","") if n%2 ==0 else str(ans[::-1]).replace("[","").replace("]","").replace(",","") )

Measured memory_bytes: 26180
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

K, X = map(int, raw_input().split())
ans = [i for i in range(X - K + 1, X + K)]
print " ".join(map(str, ans))

Measured memory_bytes: 2808
#include<stdio.h>
int BubbleSort(int A[],int N){
  int i,j,temp,cnt=0;
  for(i=0;i<N-1;i++){
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	temp = A[j];
	A[j]=A[j-1];
	A[j-1] = temp;
	cnt++;
      }
    }
  }
  return cnt;
}
int main(){
  int A[100],N,i,j,cnt;
  scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    cnt = BubbleSort(A,N);

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



Measured memory_bytes: 2120
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int i,j,n,x,m;
  vector <int> v;
  
  cin>>n>>x;
  for(i=0;i<n;i++){
    cin>>m;
    v.push_back(m);
  }
  sort(v.begin(),v.end());
  
  for(i=0;i<n;i++){
    x=x-v[i];
  }
  j=x/v[0];
  
  cout<<j+n<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

vector<vector<int>> g;
vector<bool> v;
vector<int64_t> c;
map<int, int64_t> p;

void dfs(const int s, int64_t x) {
    if(v[s]) return;
    v[s] = true;
    x += p[s];
    c[s] += x;

    for (int elm : g[s]) {
        dfs(elm, x);
    }
}

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

    g.assign(n, vector<int>(0));
    for (auto i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    for (auto i = 0; i < q; i++) {
        int a, b; cin >> a >> b;
        p[a - 1] += b;
    }

    v.assign(n, false);
    c.assign(n, 0);
    dfs(0, 0);

    for (auto i = 0; i < n; i++) {
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    scanf("%lld", &N);
    vector<ll> L(N);
    REP(int, i, 0, N) scanf("%lld", &L.at(i));
    //sort(L.begin(),L.end());
    ans = 0;
    REP(int, i, 0, N-2){
        REP(int, j, i+1, N-1){
            REP(int, k, j+1, N){
                //cout << i << j << k << endl;
                int sum = L[i] + L[j] + L[k];
                int maxv = max({L[i], L[j], L[k]});
                if ( sum - maxv > maxv ){
                    ans++;
                }
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main()
{
    int K;
    cin >> K;
    vector<long long> dp[11];
    vector<long long> ans;
    for (int i = 1; i < 10; i++)
    {
        dp[1].push_back(i);
        ans.push_back(i);
    }
    for (int i = 2; i < 11; i++)
    {
        for (auto &x : dp[i - 1])
        {
            string s = to_string(x);
            int tmp = s[s.size() - 1] - '0';
            if (tmp + 1 < 10)
            {
                dp[i].push_back(stoll(s+to_string(tmp+1)));
            }
            if(tmp -1 >= 0)
            {
                dp[i].push_back(stoll(s+to_string(tmp-1)));
            }
            dp[i].push_back(stoll(s+to_string(tmp)));
        }
        for (auto &x : dp[i])
        {
            ans.push_back(x);            
        }
    }
    sort(ans.begin(),ans.end());
    cout << ans[K-1] << endl;
}

Measured memory_bytes: 4976
#include <stdio.h>

int N, Q, i, a, b, b_prev, c, l, r, d[200000];
char s[200000], t[200000], u;

int simulate(int b) {
        for (i = 0; i < Q; i++) {
                if (s[b] == t[i]) {
                        b += d[i];
                        if (b < 0) return -1;
                        if (b >= N) return 1;
                }
        }
        return 0;
}

int main() {
        scanf("%d%d", &N, &Q);
        scanf("%s", s);
        for (i = 0; i < Q; i++) {
                scanf(" %c %c", &t[i], &u);
                d[i] = (u == 'L') ? -1 : 1;
        }

        a = 0;
        b_prev = -1;
        c = N - 1;
        while (1) {
                b = (a + c + 1) / 2;
                if (b == b_prev) break;
                if (simulate(b) < 0)
                        a = b;
                else
                        c = b;
                b_prev = b;
        }
        l = a;

        a = 0;
        b_prev = -1;
        c = N - 1;
        while (1) {
                b = (a + c + 1) / 2;
                if (b == b_prev) break;
                if (simulate(b) > 0)
                        c = b;
                else
                        a = b;
                b_prev = b;
        }
        r = a;

        printf("%d\n", r - l);
        return 0;
}


Measured memory_bytes: 1280
n, m, x, y = map(int, input().split())
x_arr = list(map(int, input().split()))
y_arr = list(map(int, input().split()))

x_arr.append(x)
y_arr.append(y)

if max(x_arr) < min(y_arr):
    print("No War")
else:
    print("War")

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1'000'000'000ll + 7;
const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 3'000 + 5;

i64 a, b, c, d;
i64 dp[MAXN][MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> a >> b >> c >> d;

    dp[a][b] = 1;
    for (i64 i = a + 1; i <= c; i++) {
        dp[i][b] = dp[i - 1][b] * b;
        dp[i][b] %= smod;
    }

    for (i64 j = b + 1; j <= d; j++) {
        dp[a][j] = dp[a][j - 1] * a;
        dp[a][j] %= smod;
    }

    for (i64 i = a + 1; i <= c; i++) {
        for (i64 j = b + 1; j <= d; j++) {
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + dp[i - 1][j] * (j - 1) + dp[i][j - 1] * (i - 1)) % smod - (dp[i - 1][j - 1] * (i - 1) * (j - 1)) % smod;
            dp[i][j] = (dp[i][j] + smod) % smod;
            //dp[i][j] = (dp[i][j - 1] * i + dp[i - 1][j] * j + dp[i - 1][j - 1] * (i + j - 2)) / 2;
            //dp[i][j] %= smod;

            //i64 v1 = (dp[i - 1][j] * (j - 1) + dp[i][j - 1] * (i - 1)) / 2;
            //v1 %= smod;

            //i64 v2 = dp[i - 1][j - 1] * (i + j - 2);
            //v2 %= smod;

            //dp[i][j] = (v1 + v2) % smod;

            //dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + (dp[i - 1][j - 1] * (i + j - 2)) % smod;
            //dp[i][j] %= smod;

            //i64 t = (i - 1) * (j - 1) + (i + j - 2);
            //t %= smod;

            //dp[i][j] = dp[i - 1][j - 1] * t;
            //dp[i][j] %= smod;
        }
    }

    cout << dp[c][d] << endl;


    return 0;
}


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

int x[1000];
vector<int>E[1000];
int memo[2000];
map<int,int>dp[2000];

void dfs(int v){
	if(E[v].empty()){
		memo[v]=0;
		return;
	}
	for(auto u:E[v]){
		dfs(u);
	}
	dp[0][0]=0;
	rep(i,E[v].size()){
		dp[i+1].clear();
		for(auto&p:dp[i]){
			int j=p.first,k=x[E[v][i]],t=memo[E[v][i]];
			if(j+x[E[v][i]]<=x[v]){
				if(dp[i+1].count(j+k)==0)dp[i+1][j+k]=dp[i][j]+t;
				else dp[i+1][j+k]=min(dp[i+1][j+k],dp[i][j]+t);
			}
			if(j+t<=x[v]){
				if(dp[i+1].count(j+t)==0)dp[i+1][j+t]=dp[i][j]+k;
				else dp[i+1][j+t]=min(dp[i+1][j+t],dp[i][j]+k);
			}
		}
	}
	memo[v]=INF;
	rep(i,x[v]+1){
		if(dp[E[v].size()].count(i)==0)continue;
		memo[v]=min(memo[v],dp[E[v].size()][i]);
	}
	if(memo[v]==INF){
		puts("IMPOSSIBLE");exit(0);
	}
}
int main(){
	int n;scanf("%d",&n);
	rep(i,n-1){
		int p;scanf("%d",&p);p--;
		E[p].push_back(i+1);
	}
	rep(i,n)scanf("%d",&x[i]);
	dfs(0);
	puts("POSSIBLE");
}


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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    
    ini(n);
    int tmp = 0;
    FOR(i,1,n+1){
        FOR(i1,1,n+1){
            FOR(i2,1,n+1){
                tmp+=gcd(gcd(i,i1),i2);
            }
        }
    }
    out(tmp);
    
  
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
    int dis[10];
    double out,out2;
    while(scanf("%d",&dis[0])!=EOF){
        int line[100000],speed1,speed2,i,j,cnt;
        cnt=0;
        for(i=0;i<10;i++){
            if(i>=1)scanf(",%d",&dis[i]);
            for(j=0;j<dis[i];j++){
                line[j+cnt]=i+1;
            }
            //printf("%d %d %d\n",cnt,i,cnt+j);
            cnt+=dis[i];
        }
        //printf("\n%d\n",cnt);
        scanf(",%d,%d",&speed1,&speed2);
        //printf("***%d\n",speed1);
        /*for(i=0;i<=cnt;i++){
            printf("%d ",i);
        }
        puts("");
        for(i=0;i<cnt;i++){
            printf("%d ",line[i]);
        }*/
        out=(double)cnt*((double)speed1/(double)(speed1+speed2));
        //printf("...%d %d %d\n",(double)(speed1+speed2),(double)speed1/(double)(speed1+speed2),1);
        out2 = (double)(int)out;
        if(out-out2<0.00000001)out-=1.0;
        printf("%d\n",line[(int)out]);
    }
    return 0;
}

Measured memory_bytes: 608
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

inversion = 0
for i in range(len(a_list)):
    for j in range(len(a_list) - 1, i, -1):
        if a_list[j] < a_list[j - 1]:
            a_list[j], a_list[j - 1] = a_list[j - 1], a_list[j]
            inversion += 1

total_lower = 0
for i in range(len(a_list)):
    total_lower += len([x for x in a_list if x < a_list[i]])


total_k = (K * (K - 1)) // 2
total = (total_lower * total_k+ inversion * K) % MOD
print(total)

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

using i64 = long long int;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        ans += min(x, abs(k-x))*2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    ll k;
    cin>>s>>k;
    ll x=s.size();
    for (ll i=0;i<s.size();i++){
        if(s[i]!='1'){
            x=i;
            break;
        }
    }
    if(k<=x){
        cout<<"1"<<endl;
    }
    else{
       cout<<s[x]<<endl;
    }    

    


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define debug 0

 using namespace std;
 
 const ll MOD = 1000000007LL;
 
ll ar[500056],br[500056];


map<ll,ll> has,mark;
multiset<ll> st,buk;


vector<pair<ll,ll> > vp;
ll maxi;
vector<ll> vec,pec;



int main() 
{
	
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
    
    ll n,p,t,j,x,y=0,k,l,m,z,c,e,f,q,s,flag=0,sum=0,res=0,num,g,h,santax,santay,bagsize,len,yy,lg,kk,remov,a,b;
	ll i,u,v,w,ans=0,maxm=0,r,minm=999999999999,dist;
	bool fl=0;
	ll d,pos,neg;
	string str,ptr;

	
	cin>>a>>b>>c>>d;
	
	if((a+b)>(c+d))
	cout<<"Left";
	else if((a+b)<(c+d))
	cout<<"Right";
	else
	cout<<"Balanced";
	
	

	
	
	
    return 0;
}    

Measured memory_bytes: 256
import sys
import collections


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w, n = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for _ in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        for i in range(-1, 2):
            for j in range(-1, 2):
                if 1 <= a-1+i < h-1 and 1 <= b-1+j < w-1:
                    d[a-1+i, b-1+j] += 1
    nd = []
    for k, v in d.items():
        nd.append(v)
    nd = collections.Counter(nd)
    print((h - 2) * (w - 2) - sum(nd.values()))
    for i in range(1, 10):
        print(nd[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 191996
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
d, e = map(int, input().split())
if (d in a and e in a) or (d in b and e in b) or (d in c and e in c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string s[H+2];
    rep(j, W+2) s[0] += '@';
    s[H+1] = s[0];
    rep2(i, 1, H){
        cin >> s[i];
        s[i] = '@'+s[i]+'@';
    }
    pii d[H+2][W+2][4];
    rep(i, H+2) rep(j, W+2){
        rep(k, 4){
            d[i][j][k] = pii(inf, 0);
        }
    }
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    queue<pii> que;
    rep(k, 4){
        d[sx][sy][k] = pii(0, K);
        que.push(pii(sx*(W+2)+sy, k));
    }
    while(!que.empty()){
        pii p = que.front();
        que.pop();
        int x = p.first/(W+2), y = p.first%(W+2), k = p.second;
        int nx = x+dx[k], ny = y+dy[k];
        if(s[nx][ny] == '@') continue;
        //cout << x << ' ' << y << ' ' << nx << ' ' << ny << endl;
        pii D = d[x][y][k];
      	//cout << D.first << ' ' << D.second << endl;
        if(D.second == K) D.first++, D.second = 1;
        else D.second++;
        if(d[nx][ny][k] > D){
            d[nx][ny][k] = D;
            que.push(pii(nx*(W+2)+ny, k));
        }
        D.first++, D.second = 0;
        rep(i, 4){
            if(i == k) continue;
            if(d[nx][ny][i] > D){
                d[nx][ny][i] = D;
                que.push(pii(nx*(W+2)+ny, i));
            }
        }
    }
    pii res = pii(inf, 0);
    rep(k, 4){
        res = min(res, d[tx][ty][k]);
    }
    if(res.first == inf) cout << -1 << endl;
    else cout << res.first << endl;
}

Measured memory_bytes: 100208
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll l = 1000000007;

int main()
{
	int a[5] = {};
	int one = 2, two = 2;

	for (int i = 0; i < 6; i++)
	{
		int x;
		cin >> x;
		a[x]++;
	}

	for (int i = 1; i <= 4; i++)
	{
		if (a[i] == 1) {
			one--;
		}
		else if (a[i] == 2) {
			two--;
		}
	}

	if (one == 0 && two == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pii> a(n);
    rep(i,n){
        int x, l;
        cin >> x >> l;
        a[i] = pii(x, l);
    }
    sort(a.begin(),a.end(),[](pii b, pii c){
        return b.first + b.second < c.first + c.second;
    });
    show(a);
    ll now = -(1LL<<30);
    int ans = 0;
    for(auto &x : a){
        show(x, now);
        if(now <= x.first - x.second){
            now = x.first + x.second;
            ans++;
        }
    }
    show(now);
    cout << ans << endl;
}


Measured memory_bytes: 1148
/**
*    author:  yuya1234
*    created: 08.07.2020 14:03:42
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int a[100010];
  MEMSET(a,0);
  int tmp;

  REP(i,n)
  {
    cin>>tmp;
    if(tmp!=0)a[tmp-1]++;
    a[tmp]++;
    a[tmp+1]++;
  }

  sort(a,a+100010,greater<int>());

  cout<<a[0]<<endl;

  return 0;
}

Measured memory_bytes: 4016
import java.util.*;
import java.io.*;
//fastest
class Main{
  static List dummy;

  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    StringBuilder builder = new StringBuilder();
    init();
    int i;
    for(i = n ; i>0; i--){
      String s = br.readLine();
      if(s.charAt(0)=='i'){
        insert(Integer.parseInt(s.substring(7)));
      }else if(s.charAt(6)=='F'){
        deleteFirst();
      }else if(s.charAt(6)=='L'){
        deleteLast();
      }else{
        delete(Integer.parseInt(s.substring(7)));
      }
    }
    List list = dummy.next;
    if(list != dummy){
      // System.out.printf("%d",list.data);
      builder.append(list.data);
      list = list.next;
    }
    while(list!=dummy){
      // System.out.printf(" %d",list.data);
      builder.append(' ').append(list.data);
      list = list.next;
    }
    System.out.println(builder);
    // Print_list();
  }
  static void init(){
    dummy = new List();
    dummy.next=dummy;
    dummy.previous=dummy;
  }
  //insert
  static void insert(int n){
    List list = new List(n);
    list.next=dummy.next;
    dummy.next.previous=list;
    dummy.next=list;
    list.previous=dummy;
  }
  //ノードの削除メソッド
  static void deleteNode(List delete){
    if( delete == dummy)return;
    delete.previous.next=delete.next;
    delete.next.previous=delete.previous;
  }
  //指定したノードの削除
  static void delete(int n){
    deleteNode(listSearch(n));
  }
  //firstnode削除
  static void deleteFirst(){
    deleteNode(dummy.next);
  }
  //lastnode削除
  static void deleteLast(){
    deleteNode(dummy.previous);
  }
  //keyを使ってノードを探索
  static List listSearch(int n){
    List cur = dummy.next;
    while(cur.data!=n && cur!=dummy){
      cur = cur.next;
    }
    return cur;
  }
  //printメソッド
  // static void Print_list(){
  //   List list = dummy.next;
  //   if(list != dummy){
  //     // System.out.printf("%d",list.data);
  //     builder.append(list.data);
  //     list = list.next;
  //   }
  //   while(list!=dummy){
  //     // System.out.printf(" %d",list.data);
  //     builder.append(' ').append(list.data);
  //     list = list.next;
  //   }
  //   System.out.println(builder);
  //   // System.out.println();
  // }
}
//listの構造体的役割
class List{
  public int data;
  public List next;
  public List previous;

  public List(){}
    public List(int n){
      this.data = n;
    }
  }



Measured memory_bytes: 126020
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {	
		FastScanner sc = new FastScanner();
		int[] in1 = new int[4];
		int[] in2 = new int[2];
		for(int i = 0; i < 4; i++) {
			in1[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			in2[i] = sc.nextInt();
		}
		Arrays.sort(in1);
		Arrays.sort(in2);
		int sum = in2[1];
		for(int i = 1; i < 4; i++) {
			sum += in1[i];
		}
		System.out.println(sum);
	}
	
}

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

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


def main():
    import sys
    input = sys.stdin.readline

    n, m = map(int, input().split())
    ans = 0
    ans += max(0, n * (n - 1) // 2)
    ans += max(0, m * (m - 1) // 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int n;
    cin >> n;
    vector<ll> vx(n), vy(n), vh(n);
    int si = -1;
    rep(i, n) { 
        cin >> vx[i] >> vy[i] >> vh[i];
        if (vh[i] > 0) si = i;
    }

    ll resx = -1, resy = -1, resh = -1;
    for (ll x = 0; x <= 100; ++x) {
        for (ll y = 0; y <= 100; ++y) {
            ll h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
            bool ok = true;
            rep(i, n) {
                if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i])) {
                    ok = false;
                }
                if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i])) {
                    ok = false;
                }
            }
            if (ok) resx = x, resy = y, resh = h;
        }
    }
    cout << resx << " " << resy << " " << resh << endl;

    return 0;
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
	lld n, i;
	cin >> n;
	lld x[n], y[n];
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	set<lld> s, ss;
	for (i = 0; i < n; i++) {
		s.insert(x[i] + y[i]);
		ss.insert(x[i] - y[i]);
	}

	lld ans1 = (*prev(s.end())) - (*s.begin());
	lld ans2 = (*prev(ss.end())) - (*ss.begin());
	cout << max(ans1, ans2) << endl;
}








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

int main(){
  string s;
  cin >> s;
  bool flag=0;
  if(s[0]==s[1])flag=1;
  else if(s[1]==s[2])flag=1;
  else if(s[2]==s[3])flag=1;

  if(flag==1)cout << "Bad" << endl;
  else cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256