akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int i;
        for(i=0;i<n;i++){
          a[i] = sc.nextInt();
        }
        for(i=0;i<(double)(n/2);i++){
          int y;
          y=a[i];
          a[i]=a[n-i-1];
          a[n-i-1]=y;
        }
        for(i=0;i<n;i++){
          System.out.print(a[i]);
          if(i!=(n-1)){
            System.out.print(" ");
          }
        }
        System.out.println();
        
        sc.close();
    }
  }



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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i < n; i++)
#define run(i, a, b) for(int i = a; i < b; i++)
#define cinarr(arr, n) repi(n) cin >> arr[i]
#define coutarr(arr, n) repi(n) cout << arr[i] << " "; cout << endl
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define cinset(st, n) {int _t; repi(n) {cin >> _t; st.insert(_t);}}


typedef long long int ll;
typedef unsigned long long int ull;

ll mod = 1000000007;

ll fac[2005];
int facUpto = 0;

ll power(ll a, ll b){
	if(b == 1) return a;
	ll p = power(a, b / 2);
	if(b & 1){
		return (((p * p) % mod) * a) % mod;
	}
	return (p*p) % mod;
}

ll modInv(ll n){
	return power(n, mod - 2);
}

ll nCrFermet(ll n, ll r){
	for(int i = facUpto + 1; i <= n; i++){
		fac[i] = (fac[i - 1] * i) % mod;
	}
	facUpto = n;
	
	return ((fac[n] * modInv(fac[n - r])) % mod) * modInv(fac[r]) % mod;
}

int main(){
	fac[0] = 1;
    
    ll n;
    cin >> n;
    
    ll ans = 0;
    for(int q = 1; 3 * q <= n; q++){
		ans = (ans + nCrFermet(n - 2*q - 1, q - 1)) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3552
from collections import deque

sa = deque(list(input()))
sb = deque(list(input()))
sc = deque(list(input()))
turn = 1

for i in range(10**10):
  
  if turn == 1:
    if len(sa) == 0:
      print('A')
      exit()
    tmp =sa.popleft()
      
    if tmp == 'b':
      turn = 2
    elif tmp == 'c':
      turn = 3
      
  if turn == 2:
    if len(sb) == 0:
      print('B')
      exit()
    tmp =sb.popleft()
      
    if tmp == 'a':
      turn = 1
    elif tmp == 'c':
      turn = 3
      
  if turn == 3:
    if len(sc) == 0:
      print('C')
      exit()
    tmp =sc.popleft()
      
    if tmp == 'a':
      turn = 1
    elif tmp == 'b':
      turn = 2

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	int N;
	string S;

	cin >> N >> S;
	int x = 0;
	int max = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'I') {
			x++;
		}
		else
		{
			x--;
		}
		if (max < x) {
			max = x;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int pos[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		pos[x] = i;
	}
	for (int i = 1; i <= n; i++) printf("%d%c", pos[i], " \n"[i == n]);
	return 0;
}

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

int main()
{
    int n,k;
    vector<int> l;
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        l.push_back(t);
    }

    sort(l.rbegin(),l.rend());
    int sum = 0;
    
    for(int i = 0; i < k; ++i )
    {
        sum += l.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

const int MAX = 3001000;
const int MOD = 1000000007;

i64 fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
i64 COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    i64 r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    COMinit();
    i64 c[4] = {COM(r2 + 1l + c2 + 1l, c2 + 1l)
                      ,COM(r1 + c2 + 1l, c2 + 1l)
                      ,COM(r1 + c1, c1)
                      ,COM(r2 + 1l + c1, c1)};
    i64 ans = 0;
    rep(i, 4){
        ans += (i & 1l ? -1l : 1l) * c[i];
        if(ans < 0) ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 70528
def main():
    height, width = map(int, input().split())
    grid = [input().split() for _ in range(height)]
    answer = ""
    for i in range(height):
        if answer != "":
            break
        for j in range(width):
            if grid[i][j] == "snuke":
                answer = str(chr(ord("a") + j)).upper() + str(i + 1)
                break
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, l, sum, except int
	fmt.Scan(&n, &l)
	minabs := 101
	for i := 0; i < n; i++ {
		sum += l + i
		if minabs > abs(l+i) {
			minabs = abs(l + i)
			except = l + i
		}
	}
	fmt.Println(sum - except)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector <bool> visited(10);

  int ans = 0;
  for (int i = 0; i < N - 2; i++){
    int now = S[i] - '0';

    if (visited[now] == false){
      visited[now] = true;

      vector <bool> V2(10);
      for (int j = i + 1; j < N - 1; j++){
        if (V2[S[j] - '0'] == false){
          V2[S[j] - '0'] = true;
          vector <bool> V3(10);
          for (int k = j + 1; k < N; k++){
            if (V3[S[k] - '0'] == false){
              ans++;
              V3[S[k] - '0'] = true;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;

int main ()
{
	scanf("%d %d", &x, &y);
	
	k = y;
	while (k > 0) k /= 10, w++;
	
	z = 1;
	FOR(i, 0, w) z *= 10;
	
	x = x * z + y;
	
	FOE(i, 0, 1000) if (i * i == x) { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int n;
    cin >> n;
    ll ans = 0;
    REP(i, n+1) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3656
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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 unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)
#define asc less<llong>()
#define desc greater<llong>()

struct edge {
    llong from;
    llong to;
    llong cost;
};

llong ctoi(char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
};

bool search(llong start, llong end, vector<vector<edge>> map){
    vector<bool> confilm(map.size() + 10, false);

    stack<llong> st;
    st.push(start);

    while(!st.empty()) {
        llong now = st.top();
        st.pop();

        if(confilm[now]) continue;
        confilm[now] = true;
        if(now == end) return true;

        for_each(map[now].begin(), map[now].end(), [&](edge e) {
            st.push(e.to);
        });
    }

    return false;
};

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

    llong N, M, P;
    cin >> N >> M >> P;

    vector<edge> edges;
    vecllong minDist(N + 10, INF);

    vector<vector<edge>> map(N + 10, vector<edge>(0));

    minDist[0] = 0;

    FOR(i, M) {
        llong from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        cost -= P;
        edges.push_back({from, to, -cost});
        map[from].push_back({from, to, -cost});
    }

    FOR(i, N) {
        FOR(j, edges.size()) {
            edge e = edges[j];
            if(minDist[e.to] > minDist[e.from] + e.cost) {
                minDist[e.to] = minDist[e.from] + e.cost;
                if(i == N - 1) {
                    if(search(e.from, N - 1, map) and search(0, e.from, map)) {
                        cout << "-1" << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << max(-minDist[N - 1], 0LL) << endl;

    return 0;
}

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

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

using namespace std;
using ll = long long;

void naive() {
  int n, k; cin >> n >> k;
  vector<int> a(n); rep(i, n) cin >> a[i];
  vector<int> v;
  rep(i, k) {
    rep(j, n) {
      if (find(v.begin(), v.end(), a[j]) == v.end()) {
        v.push_back(a[j]);
      } else {
        while (v.back() != a[j]) v.pop_back();
        v.pop_back();
      }
    }
    for (int x:v) cout << x << ' ';
    cout << endl;
  }
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll n, k; cin >> n >> k;
  vector<int> a(n*2); rep(i, n) cin >> a[i], a[i+n] = a[i];
  vector<vector<int>> succ(62, vector<int>(n));
  vector<vector<ll>> sum(62, vector<ll>(n));
  vector<int> pos(200001, -1);
  repr(i, n*2) {
    if (i < n) {
      succ[0][i] = (pos[a[i]] + 1) % n;
      sum[0][i] = pos[a[i]] - i + 1;
    }
    pos[a[i]] = i;   
  }
  const ll INF = 3e18;
  rep(i, 61) rep(j, n) {
    succ[i+1][j] = succ[i][succ[i][j]];
    sum[i+1][j] = min(INF, sum[i][j] + sum[i][succ[i][j]]);
  }
  ll x = 0;
  repr(i, 62) {
    if (x + sum[i][x%n] < n*k) {
      x += sum[i][x%n];
    }
  }
  vector<bool> in(200001);
  vector<int> ans;
  while (x < n*k) {
    ll v = a[x%n];
    if (in[v]) {
      while (ans.back() != v) {
        in[ans.back()] = false;
        ans.pop_back();
      }
      ans.pop_back();
      in[v] = false;
    } else {
      in[v] = true;
      ans.push_back(v);
    }
    x++;
  }
  for (int x : ans) cout << x << ' ';
  cout << endl;
}

Measured memory_bytes: 151252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

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

    int res = min(b/a, c);

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



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

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

    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    sort(as.begin(), as.end());
    long long ans = 0;
    for (int i = 0; i < n - k; i++) {
        ans += as[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3992
import java.util.Scanner;
public class Main {
	static int MAX = 10000;
	static int NIL = -1;
	static Node[] T = new Node[MAX];
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v = 0;
		int l = 0;
		int r = 0;
		int root = 0;
		
		for (int i=0; i<n; i++){
			T[i] = new Node(NIL, NIL, NIL);
		}
		
		for (int i=0; i<n; i++){
			v = sc.nextInt();
			l = sc.nextInt();
			r = sc.nextInt();
			T[v].setL(l);
			T[v].setR(r);
			if(l != NIL) T[l].setP(v);
			if(r != NIL) T[r].setP(v);
		}
		
		for (int i=0; i<n; i++){
			if(T[i].getP() == NIL) root = i;
		}
		
		System.out.println("Preorder");
		preParse(root);
		System.out.println();
		System.out.println("Inorder");
		inParse(root);
		System.out.println();
		System.out.println("Postorder");
		postParse(root);
		System.out.println();
	}
	
	static void preParse(int u) {
		if (u == NIL) return;
		System.out.print(" " + u);
		preParse(T[u].getL());
		preParse(T[u].getR());
	}
	
	static void inParse(int u) {
		if (u == NIL) return;
		inParse(T[u].getL());
		System.out.print(" " + u);
		inParse(T[u].getR());
	}
	
	static void postParse(int u) {
		if (u == NIL) return;
		postParse(T[u].getL());
		postParse(T[u].getR());
		System.out.print(" " + u);
	}
}

class Node {
    private int p, l ,r;
    public Node(int p, int l, int r) {
        this.p = p;
        this.l = l;
        this.r = r;
    }
    int getP() {
        return p;
    }
    int getL() {
        return l;
    }
    int getR() {
        return r;
    }
    void setR(int r) {
        this.r = r;
    }
    void setL(int l) {
        this.l = l;
    }
    void setP(int p) {
        this.p = p;
    }
}



Measured memory_bytes: 26212
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <utility>
#include <vector>
#include <stdio.h>
#include <numeric>
#include <array>

using namespace std;

#define REP(i,from,to) for( long long int i = (from); i < (to); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template <typename ELEMENT_TYPE>
struct _setfillw {
    ELEMENT_TYPE c;
    std::streamsize w;
    _setfillw(ELEMENT_TYPE c, std::streamsize w) : w(w), c(c) {}
};

template <typename ELEMENT_TYPE>
inline _setfillw<ELEMENT_TYPE> setfillw(ELEMENT_TYPE c, std::streamsize w) {
    return _setfillw<ELEMENT_TYPE>(c, w);
}

template <typename ELEMENT_TYPE>
inline std::ostream& operator << (std::ostream& os, const _setfillw<ELEMENT_TYPE>& manip)
{
    return os << std::setw(manip.w) << std::setfill(manip.c);
}

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
  LIN(a) LIN(b)
  ll ret = 1;
  ret *= b;
  REP( i, 1, a ){
    ret *= (b - 1);
  }
  puta( ret );
  return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

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

ll ans=0;
rep(i,n.size()){
    ans+=n[i]-'0';
}
ans=max(ans,(ll)((n[0]-'0')-1+9*(n.size()-1)));

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

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::cmp::max;

fn run() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let m = 40;
    let mut cnt = vec![0; m];
    let mut ans = 0;
    for mut a in a {
        ans += a ^ k;
        for c in cnt.iter_mut() {
            *c += a & 1;
            a >>= 1;
        }
    }
    for d in 0..m {
        if ((k >> d) & 1) == 0 {
            continue;
        }
        let mut sum = 0;
        for i in (d + 1)..m {
            sum += (1 << i) * if ((k >> i) & 1) == 0 {cnt[i]} else {n - cnt[i]};
        }
        sum += (1 << d) * cnt[d];
        for i in 0..d {
            sum += (1 << i) * max(cnt[i], n - cnt[i]);
        }
        ans = max(ans, sum);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6524
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n;
	int x[100] = { 0 };
	int y[100] = { 0 };
	int i;
	double d;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &y[i]);
	}

	d = 0.0;
	for (i = 0; i < n; i++) {
		d += abs(x[i] - y[i]);
	}
	printf("%lf\n", d);

	d = 0.0;
	for (i = 0; i < n; i++) {
		d += (x[i] - y[i]) * (x[i] - y[i]);
	}
	printf("%lf\n", sqrt(d));

	d = 0.0;
	for (i = 0; i < n; i++) {
		d += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
	}
	printf("%lf\n", cbrt(d));

	d = 0.0;
	for (i = 0; i < n; i++) {
		if (d < abs(x[i] - y[i]))
		d = abs(x[i] - y[i]);
	}
	printf("%lf\n", d);

	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 2e9;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    vector<vector<int>> graph(n+1);
    vector<int> dist(n+1,INF);
    For(i,0,m){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dist[1]=0;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(auto to:graph[now]){
            if(dist[to]>dist[now]+1){
                dist[to]=dist[now]+1;
                que.push(to);
            }
        }
    }
    cout << "Yes" << endl;
    For(i,2,n+1){
        for(auto j:graph[i]){
            if(dist[j]==dist[i]-1){
                cout << j << endl;
                break;
            }
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 10160
def resolve():
    N, M = map(int, input().split())

    shops = []
    for i in range(N):
        aa, bb = map(int, input().split())
        shops.append([aa, bb])

    shops.sort(key=lambda x: x[0])

    rem = M
    ans = 0
    for shop in shops:
        buy = min(rem, shop[1])
        ans += buy * shop[0]
        rem -= buy

    print(ans)


resolve()


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

int main(){
  int N,T,c,t,m;
  m = 10000;
  cin >> N >> T;
  for (int i =0;i<N;i++){
    cin >> c >> t;
    if (t <= T){
      m = min(m,c);
    }
  }
  if (m == 10000){
    cout << "TLE" << endl;
  }
  else{
  cout << m << endl;
  }
} 

Measured memory_bytes: 256
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=list(map(int,np.zeros(M+1)))
ans=1

for i in D:
    countlist[i]+=1

if 0 in countlist or countlist[0]!=1 :
    print(0)
    sys.exit()
elif M<2:
    print(1)
    sys.exit()

if D[0]!=0 :
    print(0)
    sys.exit()

for i in range(2,M+1):
    if countlist[i]>0:
        ans *= countlist[i-1]**countlist[i]
    elif i<M:
        ans=0
    else:
        break


print(ans%998244353) 

Measured memory_bytes: 23552
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll dp[100001][4];
int a[100001],b[100001],c[100001];

int main() {

	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i+1]>>b[i+1]>>c[i+1];
	}
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];

	for(int i=2; i<n+1; i++){
		dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
		dp[i][2]=max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
		dp[i][3]=max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
	}
	dp[n][3]=max(dp[n][3],dp[n][2]);
	cout<<max(dp[n][3],dp[n][1])<<endl;

	return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define add(x,y)(x=((ll)y+x)%mo)
#define ll long long
using namespace std;
const int N=105;
int n,m,k,mo,v,A;
int g[N][N],g2[N][N];
int f[N][N][N][2];
int jc[N],ny[N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
int main(){
	cin>>n>>m>>k>>mo;
	A=max(max(n,m),k);
	jc[0]=1;
	fo(i,1,A)jc[i]=(ll)jc[i-1]*i%mo;
	ny[A]=ksm(jc[A],mo-2);
	fd(i,0,A-1)ny[i]=(ll)ny[i+1]*(i+1)%mo;
	f[0][0][0][0]=1;
	fo(i,0,A){
		g[i][0]=1;
		fo(j,1,A)g[i][j]=(ll)g[i][j-1]*i%mo;
		if(i)
			fo(j,0,A)g2[i][j]=(g[i][j]-g[i-1][j]+mo)%mo;
	}
	fo(i,0,n)fo(j,0,m)
		fo(l,0,k){
			if(v=f[i][j][l][1]){
				int x=1,xs=(ll)g[l][n-i]*g2[k-l+1][i]%mo;
				fo(j0,0,m-j){
					add(f[i][j+j0][l][0],v*x%mo*ny[j0]);
					x=(ll)x*xs%mo;
				}
			}
			
			if((v=f[i][j][l][0])&&l<k){
				int x=1,xs=(ll)g2[l+1][m-j]*g[k-(l+1)+1][j]%mo;
				fo(i0,0,n-i){
					add(f[i+i0][j][l+1][1],v*x%mo*ny[i0]);
					x=(ll)x*xs%mo;
				}
			}
		}
	cout<<(ll)f[n][m][k][0]*jc[n]%mo*jc[m]%mo;
}

Measured memory_bytes: 9088
import itertools
import math

n = int(input())
xy=[]
for i in range(n):
    xy.append(list(map(int,input().split())))
#print(xy)

ans=0
num=0
for i in itertools.permutations(range(n), n):
    #print(i)
    num+=1
    sum=0
    for j in range(n-1):
        sum+=math.sqrt((xy[i[j+1]][0]-xy[i[j]][0])**2+(xy[i[j+1]][1]-xy[i[j]][1])**2)
    #print(sum)
    ans = ans/num * (num-1) + sum / num
    #print(ans)

print(ans)


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

const int MAX_SIZE = 50;
int field[MAX_SIZE + 1][MAX_SIZE + 1];
int nums[MAX_SIZE + 1][MAX_SIZE + 1];

int main() {
    int h, w;
    while (cin >> h >> w) {
        for (int y = 0; y < h; y++) {
            string line;
            cin >> line;
            for (int x = 0; x < w; x++) {
                field[y][x] = line[x] - '0';
            }
        }
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                int add = 0;
                if (0 < y && 0 < x) {
                    add = min(nums[y - 1][x], nums[y][x - 1]);
                } else if (0 < y) {
                    add = nums[y - 1][x];
                } else if (0 < x) {
                    add = nums[y][x - 1];
                }
                nums[y][x] = field[y][x] + add;
            }
        }
        cout << nums[h - 1][w - 1] << endl;
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String s = sc.next();

        int ans = 0;


        for (int i=0; i<=999; i++){
            String str = String.valueOf(i);
            if (str.length()==1){
                str = "00" + str;
            }else if (str.length()==2){
                str = "0" + str;
            }
            char[] c = str.toCharArray();
            char[] number = s.toCharArray();

            int tmp = 0;

            int tmp_k = 0;

            for (int j=0; j<c.length; j++){
                for (int k=0; k<number.length; k++){
                    if (c[j]==number[k]){
                        ++tmp;
                        j++;
                        if (j>=3)break;
                    }
//                    if (tmp==3) break;
                }
            }
            if (tmp==3){
                ans++;
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 53460
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

N = int(input())
from collections import Counter
c = Counter(prime_decomposition(N))
ans = 0
for i in c:
    k = 1
    while(c[i]-k>=0):
        if c[i]>0:
           c[i] -= k
           ans += 1
           k += 1
print(ans)

Measured memory_bytes: 9460
k=int(input())

def dfs(keta,num):
  global ans
  ans.append(int(''.join(num)))

  if keta==10:
    return

  min_n=max(0,int(num[-1])-1)
  max_n=min(9,int(num[-1])+1)
  for i in range(min_n,max_n+1):
    dfs(keta+1,num+[str(i)])

ans=[]
for i in range(1,10):
  dfs(1,[str(i)])

ans.sort()
print(ans[k-1])

Measured memory_bytes: 17268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    int small[n] = {};
    rep(i, 0, n) {
        int tmp = 0;
        rep(j, 0, n) {
            if (a[i] > a[j]) tmp++;
        }
        small[i] = tmp;
    }

    ll ans = 0;
    ll num = 0;
    for (ll i = 0; i <= n - 2; i++) {
        for (ll j = i + 1; j <= n - 1; j++) {
            if (a[i] > a[j]) {
                num++;
            }
        }
    }
    ans += num * k;
    ans %= MOD;

    rep(i, 0, n) {
        ll tmp = k * (k - 1) / 2 % MOD;
        ans += small[i] * tmp % MOD;
        ans %= MOD;
    }

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


Measured memory_bytes: 256
// abc148_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int tmp = 0;
    REP(i, N){
        if (A[i] == tmp+1){
            tmp++;
        }
    }

    if (tmp == 0){
        print(-1);
    }else{
        int ans = N - tmp;
        print(ans);
    }


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int X, A;
  std::cin >> X >> A;
  if (X<A) printf("0\n");
  else printf("10\n");
  return 0;
}

Measured memory_bytes: 3012
#include <iostream>
using namespace std;
#define Nmax 20
int n;
int a[Nmax];

bool solve(int i, int m)
{
	if (m == 0)
		return true;
	if (i >= n)
		return false;
	bool res = (solve(i + 1, m) || solve(i + 1, m - a[i]));
	return res;
}

int main()
{
	int	q;
	int m[200] = { 0 };

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

	for (int i = 0; i < q; i++) {
		if (solve(0, m[i])) {
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    vi a(M), b(M);
    if (N % 2 == 0) {
        int hn = N / 2;
        if (hn % 2 == 0) {
            A = N - 2, B = N;
            REP(i, M) {
                if (abs(A - B) == N / 2) {
                    B++;
                    B %= N;
                }
                cout << A << " " << B << endl;
                A--, B++;
                B %= N;
            }
        } else {
            A = N - 1, B = N;
            REP(i, M) {
                if (abs(A - B) == N / 2) {
                    B++;
                }
                cout << A << " " << B << endl;
                A--, B++;
                B %= N;
            }
        }
    } else {
        A = N - 2, B = N;
        REP(i, M) {
            cout << A << " " << B << endl;
            A--, B++;
            B %= N;
        }
    }
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
const int MX = (int) 1e5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(15);
//srand(time(0));

int n, a[maxn];
map <int, int> m;

int main()
{
//    fin("t.in");
    sync;
    int ans = 0;
    cin >> n;
    fi(1, n)
    {
    	cin >> a[i];

    	ans = max(++m[a[i] + 1], ans);
    	ans = max(++m[a[i] - 1], ans);
    	ans = max(++m[a[i]], ans);

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

Measured memory_bytes: 5120
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  h = int(readline())
  def attack(x):
    if x==1:
      return 1
    else:
      x = x//2
      return 1+2*attack(x)
  print(attack(h))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5048
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))
#define SIZE 26

int main(){
	int n,i;
	scanf("%d",&n);
	int k,x;
	scanf("%d",&k);
	int ans=0;
	for(int i=0;i<n;i++){
        scanf("%d",&x);
        ans+=min(abs(k-x),x);
	}
	printf("%d\n",ans*2);
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N ;
    vector<ll> P(N);
    rep(i, N) cin >> P[i];
    ll ans = 0;
    rep(i, N-1) {
        ll p = P[i];
        if (p == i + 1) {
            ll tmp = P[i + 1];
            P[i + 1] = p;
            P[i] = tmp;
            ans ++;
        }
    }
    if (P[N-1] == N) ans++;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const ll maxn = 2 * 1e6 + 5;
const ll mod = 1e9 + 7;
ll n,k,a,b,c,d,m,num[maxn],ans = INF;
string str;
int main()
{
    cin >> k >> n;
    for(int i = 1; i <= n; i++)
        cin >> num[i];
    ans = num[n] - num[1];
    for(int i = 2; i <= n; i++)
    {
        ll x = min(abs(num[n] - num[1]),abs(k - num[n] + num[1]));
        ans = min(ans,num[i - 1] - num[1] + num[n] - num[i] + x);
    }

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


Measured memory_bytes: 1792
from itertools import combinations
from collections import Counter

n = int(input())
c = Counter()

for _ in range(n):
  c[input()[0]]+= 1
  
ans = sum([c[pattern_i[0]]*c[pattern_i[1]]*c[pattern_i[2]] for pattern_i in combinations(['M','A','R','C','H'], 3)])
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  vector<bool> P(300000, true);
  P[0] = false;
  P[1] = false;
  for (int i = 1; (7*i-1) < 300000; ++i) {
    if (P[7*i-1]) {
      for (int j = 2; (7*i-1)*j < 300000; ++j) {
	P[(7*i-1)*j] = false;
      }
    }
    if (7*i+1 < 300000 && P[7*i+1]) {
      for (int j = 2; (7*i+1)*j < 300000; ++j) {
	P[(7*i+1)*j] = false;
      }
    }
  }
  while (cin >> n, n > 1) {
    cout << n << ":";
    for (int i = 1; 7*i-1 < 300000; ++i) {
      if (P[7*i-1] && !(n%(7*i-1))) cout << " " << 7*i-1;
      if (7*i+1 < 3000000 && P[7*i+1] && !(n%(7*i+1))) cout << " " << 7*i+1;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int A,B,K;
cin >> A >> B >> K;

vector<int> ans_1(K);
vector<int> ans_2(K);
int size = 0;

for (int i = 0; i < K; i++){
     if(A + i > B){
          break;
     }
     ans_1.at(i) = A + i;
     size++;
}

for (int i = 1; i <= K; i++){
     ans_2.at(i - 1) = B - K + i;
}

for (int i = 0; i < K; i++){
     if(ans_1.at(i) == 0){
          break;
     }
     cout << ans_1.at(i) << endl;
}

for (int i = 0; i < K; i++){
     if(ans_1.at(size - 1) < ans_2.at(i)){
          cout << ans_2.at(i) << endl;
     }
}



return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

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

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int K,S,cnt=0;
    cin >>K>>S;
    FOR(x,0,K){
        if(x*3<S) continue;
        FOR(y,0,x){
            if(x+y*2<S) continue;
            FOR(z,0,y){
                if(x+y+z==S) {
                    if((x==y)&&(y==z)) cnt+=1;
                    if((x>y)&&(y==z)) cnt+=3;
                    if((x==y)&&(y>z)) cnt+=3;
                    if((x>y)&&(y>z)) cnt+=6;
                }
                if(x+y+z>S) break;
            }
        }
    }
    cout <<cnt;

    return 0;
}








Measured memory_bytes: 256
H = int(input())
s2 = 0
if H == 1:
    print(1)
else:
    while H >= 2**s2:
        s2 +=1
    s2 -= 1
    s3 = 1
    cnt = 3
    while s3 < s2:
        cnt = 1 + cnt *2
        s3 += 1
    print(cnt)    

Measured memory_bytes: 3060
N = int(input())
L =  []
for i in range(N) :
    s,p = input().split()
    p = int(p)
    L.append([s,p,i+1])
    
L = sorted(L,key=lambda x:x[1],reverse=True)

L = sorted(L,key=lambda x:x[0])

for i in range(N) :
    print(L[i][2])



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


bool equal(vector<int> &v1, vector<int> &v2)
{
	for (size_t i = 0; i < v1.size(); ++i)
	{
		if (v1[i] != v2[i]) return false;
	}
	return true;
}

int main(int argc, char **argv)
{
	int n; cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	for (int i = 0; i < n; ++i)
		cin >> q[i];
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		v[i] = i+1;
	

	int count = 1;
	int a{0}, b{0};
	do
	{
		
		if (equal(v, p))
		{
			a = count;
		}

		if (equal(v, q))
		{
			b = count;
		}
		++count;
	}
	while (next_permutation(v.begin(), v.end()));
	std::cout << abs(a - b) << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		if (a>=499){
			System.out.println("Yes");
		}else{
			if((n%500)<=a){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 21844