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

int64_t jou(int base, int sisuu){
    int64_t ans = 1;
    for(int i=0;i<sisuu;i++){
        ans *= base;
    }
    return ans;
}

int main() {
    int64_t N,K;
    cin >> N >> K;
    int digit = 0;

    while(true){
        if(N<jou(K,digit)) break;
        else digit++;
    }

    cout << digit << endl;


    return 0;
}




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

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

    vector<int> a(26,0);
    for (int i = 0; i < S.size(); i++)
    {
        a[S[i] - 'a']++;
    }

    bool check = false;
    for (int i = 0; i < 26; i++)
    {
        if(a[i]>1) check = true;
    }
    
    if(check==true) cout << "no" << endl;
    else cout << "yes" << endl;    
}

Measured memory_bytes: 256
n, m = map(int, input().split())
infty = int(1E9)
d = [[infty for i in range(n)] for j in range(n)]
edges = []

for i in range(n):
  d[i][i] = 0

for _ in range(m):
  x, y, c = map(int, input().split())
  x -= 1; y -= 1
  edges.append((x, y, c))
  d[x][y] = d[y][x] = c

for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for e in edges:
  x, y, c = e;
  need = False
  for i in range(n):
    for j in range(n):
      if d[i][j] == d[i][x] + d[j][y] + c:
        need = True
        break
  ans += not need

print(ans)

Measured memory_bytes: 45804
import math
def main():
    a = []
    while 1:
        hoge = input()
        a.append(hoge)
        if hoge == "=":
            break

    cs = ["+", "-", "*", "/"]   #calculation symbol
    cs_i = []   #cs_index
    for x in range(len(a) - 1):
        if a[x] in cs:
            cs_i.append(x)
        else:
            a[x] = int(a[x])

    for x in range(len(cs_i)):
        if a[cs_i[x]] == "+":
            fuga = a[cs_i[x] - 1] + a[cs_i[x] + 1]
            a[cs_i[x] - 1] = a[cs_i[x]] = a[cs_i[x] + 1] = fuga
        elif a[cs_i[x]] == "-":
            fuga = a[cs_i[x] - 1] - a[cs_i[x] + 1]
            a[cs_i[x] - 1] = a[cs_i[x]] = a[cs_i[x] + 1] = fuga
        elif a[cs_i[x]] == "*":
            fuga = a[cs_i[x] - 1] * a[cs_i[x] + 1]
            a[cs_i[x] - 1] = a[cs_i[x]] = a[cs_i[x] + 1] = fuga
        elif a[cs_i[x]] == "/":
            fuga = a[cs_i[x] - 1] // a[cs_i[x] + 1]
            a[cs_i[x] - 1] = a[cs_i[x]] = a[cs_i[x] + 1] = int(fuga)

    print(a[cs_i[-1]])


if __name__ == "__main__":
    main()

Measured memory_bytes: 7952
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
	int i, x;
	while (true)
	{
		i++;
		cin >> x;
		if (x != 0)
			cout << "Case " << i << ": " << x << endl;
		else break;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <string.h>
#include <stdio.h>

int main(){
  // data[i] テ」ツ?ッ i テァツ閉ェテ」ツ?ョテ、ツコツコテ」ツ?ョティツ。ツ?ヲツカツイテ・ツ楪凝」ツつ津ィツ。ツィテ」ツ??
  static int data[1<<20];
  int i;
  int max_in=0;
  int t;
  char blood[5];
  int a=0, b=0, o=0, ab=0;

  memset(data,-1,sizeof(data));
  while(scanf("%d,%s",&t, blood)!=EOF){
    if(blood[0]=='A'&&blood[1]=='B') data[t] = 3;
    else if(blood[0]=='A') data[t] = 0;
    else if(blood[0]=='B') data[t] = 1;
    else if(blood[0]=='O') data[t] = 2;
    //printf("%d\n",data[t]);
    if(max_in < t) max_in = t;
    blood[0]=0; blood[1]=0;
  }

  //printf("in : %d\n",max_in);

  for(i=0; i<=max_in; i++){
    if(data[i]==0) a++;
    if(data[i]==1) b++;
    if(data[i]==2) o++;
    if(data[i]==3) ab++;
  }

  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

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

int main() {
	long a, b, x; cin >> a >> b >> x;
	long adiv, bdiv=b/x;
	if(a) adiv=(a-1)/x;
	else adiv=-1;
	long ans=bdiv-adiv;
	cout << ans << endl;
	return 0;
}


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

string s;
stack<char> st;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s;
	for (char c : s) {
		if (st.size() && st.top() == 'S' && c == 'T') {
			st.pop();
		}
		else {
			st.push(c);
		}
	}
	cout << st.size() << '\n';
}


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

int main()
{
	string a,b;
	cin >> a >> b;
	int input = stoi(a + b);
	

	bool ans = false;
	int square = 0;
	for(int i = 1; square < input; i++){
	   	square = i * i;
		if(input == square){
			ans = true;
			break;
		}
	}

	if(ans){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;
}


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

typedef pair<int,int> P;
int main() {
    int M;
    while (cin >> M, M) {
        vector<int> x(M), y(M);
        for (int i = 0; i < M; i++) {
            cin >> x[i] >> y[i];
        }

        vector<P> sub(M);
        for (int i = 0; i < M; i++) {
            sub[i] = P(x[i] - x[0], y[i] - y[0]);
        }

        int N;
        cin >> N;
        vector<int> nx(N), ny(N);
        for (int i = 0; i < N; i++) {
            cin >> nx[i] >> ny[i];
        }

        for (int i = 0; i < N; i++) {
            set<P> s;
            for (int j = 0; j < N; j++) {
                s.insert(P(nx[j] - nx[i], ny[j] - ny[i]));
            }

            bool flag = true;
            for (int j = 0; flag && j < M; j++) {
                if (s.find(sub[j]) == s.end()) flag = false;
            }

            if (flag) {
                cout << nx[i] - x[0] << " " << ny[i] - y[0] << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3056
# ABC094c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    x[i] = (x[i], i)
x.sort()

ans = [-1]*n

ind = n//2
for i in range(n):
    if i <= n//2-1:
        ans[x[i][1]] = x[n//2][0]
    else:
        ans[x[i][1]] = x[n//2-1][0]
print(*ans, sep='\n')


Measured memory_bytes: 36784
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>

int main() {
	int n, t[10000], m;
	int p[10000], x[10000];
	std::cin >> n;
	for (int i = 1;i <= n;i++) {
		std::cin >> t[i];
	}
	std::cin >> m;
	for (int i = 0;i < m;i++) {
		std::cin >> p[i] >> x[i];
	}
	for (int i = 0;i < m;i++) {
		int b = t[p[i]];
		t[p[i]] = x[i];
		int nSum = 0;
		for (int j = 1;j <= n;j++) {
			nSum += t[j];
		}
		std::cout << nSum << std::endl;
		t[p[i]] = b;
	}
	return 0;
}
	


Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List (foldl')
import Data.Map (Map, (!))
import qualified Data.Map as M

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
  ps <- replicateM n (words <$> getLine)
  m <- readLn
  rs <- replicateM m (words <$> getLine)
  t <- getLine
  solve ps rs t >>= print
  main
  
solve :: [[String]] -> [[String]] -> String -> IO Int
solve ps rs t = return $ price rtbl ptbl t
  where
    ptbl = M.fromList $ map (\[x, y] -> (x, P (read y))) ps
    rtbl = M.fromList $ map (\(x:_:xs) -> (x, xs)) rs

price :: Map String [String] -> Map String Price -> String -> Int
price rt pt t = fst $ f pt t
  where f :: Map String Price -> String -> (Int, Map String Price)
        f pt t = case (pt ! t) of
                  F x -> (x, pt)
                  P x -> case M.lookup t rt of
                          Just rs -> let (y, pt') = foldl' g (0, pt) rs
                                     in if x < y then (x, M.insert t (F x) pt') else (y, M.insert t (F y) pt')
                          Nothing -> (x, M.insert t (F x) pt)
        g (s, pt) t = let (y, pt') = f pt t in (s+y, pt')
  
data Price = P Int | F Int deriving Show



Measured memory_bytes: 4160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (a % b != 0) {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll N, M;
vector<ll> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  A.resize(N);
  rep(i, N) {
    cin >> A[i];
    A[i] /= 2;
  }

  vector<ll> B = A;
  ll cntTwo = 0;
  while (B[0] % 2 == 0) {
    cntTwo++;
    B[0] /= 2;
  }
  for (int i = 1; i < N; i++) {
    ll cnt = 0;
    while (B[i] % 2 == 0) {
      cnt++;
      B[i] /= 2;
    }
    if (cnt != cntTwo) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll l = A[0];
  for (int i = 1; i < N; i++) {
    l = lcm(l, A[i]);
  }

  ll ans = (M / l + 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int main() {
  int64_t N,t=0; cin>>N;
  vector<int64_t> S(N);
  rep(i,N){
    cin>>S.at(i);
    t+=S.at(i);
    t%=MOD;
  }
  int64_t ans=0;
  rep(i,N){
    t=(t-S.at(i)+MOD)%MOD;
    ans+=S.at(i)*t;
    ans%=MOD;
  }
  cout<<ans;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define INF 1e+9
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

int main(){
	int n,m;
	while(cin >> n >> m,n){
		int mi = INF,d[100];
		vector<edge> G[100];
		for(int i = 0;i < m;i++){
			int a,b,c;
			cin >> a >> b >> c; a--; b--;
			G[a].push_back({b,c});
			G[b].push_back({a,c});
		}
		if(n == 2){
			cout << G[0][0].cost << endl;
			continue;
		}
		for(int i = 0;i < n;i++){
			for(int j = i + 1;j < n;j++){
				set<int> st;
				bool flag = false;
				for(int k = 0;k < G[i].size();k++) st.insert(G[i][k].to);
				for(int k = 0;k < G[j].size();k++){
					if(st.count(G[j][k].to)) flag = true;
				}
				if(!flag) continue;
				vector<edge> G2[100];
				for(int k = 0;k < n;k++){
					d[k] = INF;
					G2[k] = G[k];
				}
				G2[i].push_back({j,0});
				G2[j].push_back({i,0});
				d[0] = 0;
				priority_queue<P,vector<P>,greater<P> > que;
				que.push(P(0,0));
				while(!que.empty()){
					P p = que.top();que.pop();
					int v = p.second;
					if(d[v] < p.first) continue;
					for(int k = 0;k < G2[v].size();k++){
						edge e = G2[v][k];
						if(d[e.to] > d[v] + e.cost){
							d[e.to] = d[v] + e.cost;
							que.push(P(d[e.to],e.to));
						}
					}
				}
				mi = min(mi,d[n - 1]);
			}
		}
		cout << mi << endl;
	}
	return 0;
}

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

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

ll mod = 1e9+7;

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

  ll n;
  cin >> n;
  ll ret = n;
  for(ll i = 1;i*i <= n;i++){
    if(n % i == 0){
      ret = min(ret, (n / i - 1) + (i - 1));
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
import sys


def solve():
    N, *H = map(int, sys.stdin.read().split())
    dp = [0] * N
    dp[1] = abs(H[1] - H[0])
    h_2, h_1 = H[0], H[1]
    for i, h in enumerate(H[2:], start=2):
        dp[i] = min(dp[i - 1] + abs(h - h_1), dp[i - 2] + abs(h - h_2))
        h_2, h_1 = h_1, h
    return dp[-1]


if __name__ == "__main__":
    answer = solve()
    print(answer)


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int, int>> conditions(m);
    for (int i=0;i<m;i++){
        int si, ci;
        cin >> si >> ci;
        conditions[i] = make_pair(si, ci);
    }
    vector<int> memo(n+1);
    for (int i=1;i<=n;i++){
        memo[i] = -1;
    }
    for (auto cond : conditions){
        if (cond.first > n  || (memo[cond.first] != -1 && memo[cond.first] != cond.second)){
            cout << "-1" << endl;
            return 0;
        } else {
            memo[cond.first] = cond.second;
        }
    }
    if (n == 1 && (memo[1] == 0 || memo[1] == -1)){
        cout << 0 << endl;
        return 0;
    }
    for (int i=1;i<n+1;i++){
        if (i==1 && memo[i] == 0){
            cout << "-1" << endl;
            return 0;
        }
        if (memo[i] == -1){
            if (i == 1){
                cout << 1;
            } else {
            cout << 0;
            }
        } else {
            cout << memo[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
cnt, A, B, C = 0, 0, 0, 0
for _ in range(N):
    S = input().rstrip()
    flg = False
    for s in S:
        if s=="A":
            flg=True
        elif flg==True and s=="B":
            cnt += 1
            flg = False
        else: flg = False
    if S[0]=="B": B+=1
    if S[-1]=="A": A+=1
    if S[0]=="B" and S[-1]=="A": C+=1
if A==B==C and A!=0: print(cnt+A-1)
else: print(cnt+min(A,B))

Measured memory_bytes: 77372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var a = new string[n];
        for(int i = 0; i < n; i++)
        {
            a[i] = ReadLine();
        }
        var ad = new Dictionary<char, int>[n];
        for(int i = 0; i < n; i++)
        {
            ad[i] = new Dictionary<char, int>();
            for(int j = 0; j < 26; j++)
            {
                ad[i].Add((char)(j + 'a'), a[i].Count(x => x == (char)(j + 'a')));
            }
        }
        var d = new Dictionary<char, int>();
        for(int i = 0; i < 26; i++)
        {
            d.Add((char)(i + 'a'), ad[0][(char)(i + 'a')]);
        }
        for(int i = 1; i < n; i++)
        {
            for(int j = 0; j < 26; j++)
            {
                d[(char)(j + 'a')] = Min(d[(char)(j + 'a')], ad[i][(char)(j + 'a')]);
            }
        }
        var s = new StringBuilder();
        for(int i = 0; i < 26; i++)
        {
            for(int j = 0; j < d[(char)(i + 'a')]; j++)
            {
                s.Append((char)(i + 'a'));
            }
        }
        WriteLine(s.ToString());
    }
}


Measured memory_bytes: 19296
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    cout << 180 * (n - 2);
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

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

    int n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << "\n";

    return 0;
}


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

using namespace std;

#define LL           long long
#define ULL          long long unsigned
#define LD           long double
#define ff              first
#define ss              second
#define FOR(i,n)     for(int i=0;i<n;i++)
#define FLR(i,n)     for(LL i=0;i<n;i++)
#define RFOR(i,n)    for(int i=n-1;i>=0;i--)
#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)
#define rep(i,a,b)   for(int i=a;i<=b;i++)
#define repl(i,a,b)  for(LL i=a;i<=b;i++)
#define fast         ios_base::sync_with_stdio(0);cin.tie(0);
#define all(a)       a.begin(),a.end()
#define ABS(x)       ((x)<0?-(x):(x))
#define NL           "\n"
#define pb           push_back
#define mk              make_pair
#define pi           acos(-1.0)
#define prec(n)      fixed << setprecision(n)
#define sq(a)          (a)*(a)
int main()
{
    fast;
    int n,i,j;
    double ans=0,x;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        ans+=1/x;
    }
    ans=1/ans;
    cout<<prec(7)<<ans;

}


Measured memory_bytes: 256
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            
            HashMap<String,Integer> map = new HashMap<String,Integer>();
            
            for(int i=0; i<n; i++){
            	String s = sc.next();
            	
            	if(map.get(s) == null){
            		map.put(s, 1);
            	}else{
            		map.put(s, map.get(s)+1);
            	}
            }
            
            int m = Integer.parseInt(sc.next());
            
            for(int i=0; i<m; i++){
            	String s = sc.next();
            	
            	if(map.get(s) != null){
            		map.put(s, map.get(s)-1);
            	}
            }
            
            int max = 0;
            
            for(int val : map.values()){
            	if(val>max){
            		max = val;
            	}
    		}
            
            //出力
            System.out.println(max);
            sc.close();
        }
    }
	

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<vector<int>>vec(2,vector<int>(N));
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            cin >> vec.at(i).at(j);
        }
    }
    int maxx=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<=i;j++){
        sum+=vec.at(0).at(j);
        }
        for(int j=i;j<N;j++){
        sum+=vec.at(1).at(j);
        }
        maxx=max(sum,maxx);
    }
    cout <<maxx<<endl;

}

Measured memory_bytes: 3624
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
for i in range(n):
  if i == 0:
    continue
  elif i == 1:
    dp[1] = abs(h[1] - h[0])
    continue
  else:
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x,y,n,k;
  int i,sum=0;

    scanf("%d", &n);
    scanf("%d", &k);
    scanf("%d", &x);
    scanf("%d", &y);

    for(i=0;i < n;i++){
      if( i > k - 1){
        sum += y;
      }else{
        sum += x;
      }
    }

    printf("%d\n", sum);


  return 0;
}


Measured memory_bytes: 128
import java.util.*;

//update 2020/1/1 23:01

public class Main{

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

  public static void main(String[] args) {

    int n = nextInt();
    int[] x = new int[n];
    for(int i=0;i<n;i++){
      x[i] = nextInt();
    }

    long ans = 100000*100000;

    long sum = 0;

    for(int P=1;P<100;P++){
      for(int i=0;i<n;i++){
        sum += Math.pow(x[i]-P,2);
      }
      ans = Math.min(ans,sum);
      sum = 0;
    }

    System.out.println(ans);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 22740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int[] a = fs.nextIntArr(n);
		
		Arrays.sort(a);
		System.out.println(a[n-1] - a[0]);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int MaxN = 300;
const int MaxM = 300;

int n, m;
int a[MaxN][MaxM];

int cur[MaxN];

bool valid[MaxM];
int occur[MaxM];

inline bool check(int lim)
{
	for (int i = 0; i < n; ++i)
		cur[i] = 0;
	for (int i = 0; i < m; ++i)
		valid[i] = true;

	while (true)
	{
		for (int i = 0; i < m; ++i)
			occur[i] = 0;

		bool ok = true;
		for (int i = 0; i < n; ++i)
		{
			int &k = cur[i];
			while (k < n && !valid[a[i][k]])
				++k;
			if (k == n)
				return false;

			if (++occur[a[i][k]] > lim)
			{
				valid[a[i][k]] = false;
				ok = false;
			}
		}

		if (ok)
			return true;
	}
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> a[i][j], --a[i][j];

	int l = 0, r = n;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if (check(mid))
			r = mid - 1;
		else
			l = mid + 1;
	}

	cout << l << endl;

	return 0;
}

Measured memory_bytes: 640
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

ll readl() {
    ll ret;
    scanf("%lld", &ret);
    return ret;
}

vector<ll> readvl(ll n) {
    vector<ll> ret(n);
    rep(i,0,n) {
        ret[i] = readl();
    }
    return ret;
}

void writel(ll x) {
    printf("%lld\n", x);
}

int main() {
    ll N = readl();
    ll K = readl();
    K--;
    vector<ll> next = readvl(N);
    rep(i,0,N) {
        next[i]--;
    }
    vector<ll> scores = readvl(N);
    ll ans = LL_MIN;
    rep(start,0,N) {
        ll now = start;
        ll sum = 0;
        ll loop = 0;
        vector<ll> sum_max;
        sum_max.push_back(sum);
        vector<ll> sums;
        sums.push_back(0);
        do {
            now = next[now];
            sum += scores[now];
            loop++;
            sum_max.push_back(max(sum, sum_max.back()));
            sums.push_back(sum);
        } while (now != start);
        ll score = scores[start];
        ll score_sub = LL_MIN;
        rep(mod,0,loop) {
            if (mod > K) {
                break;
            }
            ll score_sub_loc = sums[mod];
            chmax(score_sub, score_sub_loc);
            score_sub_loc += (K - mod) / loop * sum;
            chmax(score_sub, score_sub_loc);
        }
        score += score_sub;
        chmax(ans, score);
    }
    writel(ans);
}

/*
 
 5 6
 2 4 1 5 3
 1 2 4 -1 -4
 
 */



Measured memory_bytes: 3356
# -*- coding: utf-8 -*-
# abc140/abc140_a
import sys

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

def main():
    N = i2n()
    print(N**3)
    return

main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N;
    cin >> N;
    vector<int> ve(N);
    rep(i, 0, N) {
        int a;
        cin >> a;
        ve[a - 1] = i + 1;
    }
    rep(i, 0, N) { cout << ve[i]<<" "; }
    cout<<endl;
}


Measured memory_bytes: 1152
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    (n,k) <- readIntPair
    as <- readInts
    let parent :: UArray Int Int
        parent = listArray (1,n) as
    let g :: Array Int [Int]
        g = fromEdges (1,n) $ zip (tail as) [2..]
    let solve :: Int -> (Int,Int)
        solve v = r         
            where
            ts = map solve (g ! v)
            cost = sum $ map fst ts
            h = maximum (0 : map (succ . snd) ts)
            r   | v == 1 && parent ! v /= 1 = (cost + 1, 0)
                | h == k - 1 && parent ! v /= 1 = (cost + 1, -1)
                | otherwise = (cost, h)

    print $ fst $ solve 1


-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 52732
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int X=sc.nextInt();
    int A=sc.nextInt();
    if(X<A){
      System.out.println(0);
    }
    else{
      System.out.println(10);
    }
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define REP(i, n) for (int i(0); i < n; ++i)
#define REQ(i, a, b) for (int i(a); i <= b; ++i)

void solve(){
	int a,b;
	cin >> a >> b;
	cout << (a+b-1)/b;

}

signed main(){
	int t;
	t=1;
	while(t--){
		solve();
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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 (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct Combination{
    vector<long long> fac, finv, inv;
    Combination(int n=1001001):fac(n+1), finv(n+1), inv(n+1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; 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;
        }
    }
    long long operator()(int n, int k) const {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main(){
    int N, K;
    cin >> N >> K;

    Combination c;
    int m = N - K;

    for (int i = 1; i <= K; ++i) {
        ll a = c(K-1, i-1), b = c(m+1, i);
        ll ans = a * b % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 23680
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	int n;
	cin>>n;
	string s[2];
	vector<bool> v;
	cin>>s[0]>>s[1];
	for(int i=0;i<n;){//Mind it
		if(s[0][i]==s[1][i]){
			v.pb(false);
			++i;
		}else{
			v.pb(true);
			i+=2;
		}
	}
	ll ans;
	if(!v[0]) ans=3;
	else ans=6;
	for(int i=1;i<v.size();++i){
		if(!v[i-1]) mlmod(ans,2);
		else if(v[i]) mlmod(ans,3);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  map<string, int> mp;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
  return 0;
}


Measured memory_bytes: 19244
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000
 
using namespace std;
 
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a/b<<" "<<a%b<<" ";
	printf("%.9lf\n",1.0*a/b);
    return 0;
}



Measured memory_bytes: 3228
#include <iostream>
using namespace std;
int main(){
  long long int m;
  int n, d[10000];
  short p[10000];
  bool f;

  while( cin>>n>>m && (n||m) ){
    for( int i=0;i<n;i++ )
      cin >> d[i] >> p[i];

    do{
      f=false;
      for( int i=1;i<n;i++ )
	if( p[i-1]<p[i] ){
	  int dd=d[i]; d[i]=d[i-1]; d[i-1]=dd;
	  short pp=p[i]; p[i]=p[i-1]; p[i-1]=pp;
	  f=true;
	}
    }while( f );

    long long int ans=0;
    for( int i=0;i<n;i++ ){
      if( m>0 ){
	m-=d[i];
	if( m<0 ){
	  d[i] = -m; m=0;
	  ans += d[i]*p[i];
	}
      }else if( !m )
	ans += d[i]*p[i];      
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[50];
int main(){
  IOS();
  int n;
  cin>>n;
  int idx=0;
  if( n==0 ) d[idx++]=0;
  while( n ){
    int tmp=n%(-2);
    n/=(-2);
    if( tmp==-1 ){
      n++;
      tmp=1;
    }
    d[idx++]=tmp;
  }
  for(int i=idx-1;i>=0;i--) cout<<d[i];
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<long long int,long long int>
#define vi vector<long long int >
#define vvi vector<vector< long long int>>
#define MP make_pair
#define PB push_back 
#define pb pop_back
#define PF push_front
#define pf pop_front
#define MOD 1000000007
#define MT make_tuple
ll f[5000];
void fac()
{
	f[0]=1;
	for(ll i=1;i<5000;i++)
		f[i]=(f[i-1]*i)%MOD;
}
ll exp(ll x,ll y)
{
	ll h=1;
	x%=MOD;
	while(y)
	{
		if(y%2==1)
		{
			h=(h*x)%MOD;
		}
		y/=2;
		x = (x*x)%MOD;
	}
	return h;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	fac();
	for(ll i=1;3*i<=n;i++)
	{
		ll k=n-i*3;
		ll yo=f[k+i-1];
		ll p=exp(f[k],MOD-2);
		ll q=exp(f[i-1],MOD-2);
		yo=(yo*p)%MOD;
		yo=(yo*q)%MOD;
		ans = (ans+yo)%MOD;
	}
	cout<<ans<<endl;
    return 0;
}
			

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>a;i--)
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also

void solve()
{  

  string s;
  cin>>s;
  if(s.compare("ABC")==0)
  {
    cout<<"ARC";
  }
  else
  {
    cout<<"ABC";
  }
  
}
int main()
{
   fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  { //cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdexcept>
#include <iostream>

using namespace std;
typedef unsigned long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  llong base = 100, X;
  int ans = 0;
  scanf("%llu", &X);

  while (base < X)
  {
    base += base / 100;
    ans++;
  }

  printf("%d\n", ans);

  return 0;
}

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

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

  int k, x;
  cin >> k >> x;

  for(int i=x-k+1; i<x+k-1; i++)cout << i << " ";
  cout << x+k-1 << endl;

  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, i, j;
    cin >> h >> w;
    //int arr[h][w];
    vector<string> arr;
    
    for(i=0; i<h; i++){
        string s;
        cin >> s;
        arr.push_back(s);
    }
    for(j=0; j<=w; j++){
        cout << '#';
    }
    cout << '#' << endl;
    for(i=0; i<h; i++){
        cout << '#';
        cout << arr[i];
        cout << '#' << endl;
    }
    for(j=0; j<=w; j++) cout << '#';
    cout << '#' << endl;
    return 0;
}

Measured memory_bytes: 3672
S = input()
s = list(S)

K = int(input())

alp = "abcdefghijklmnopqrstuvwxyz"
dic = {}

for i in range(26):
    dic[alp[i]] = (26 - i) % 26

ind = {}
for i in range(26):
    ind[alp[i]] = i

for i in range(len(s)):


    if K >= dic[s[i]]:
        K -= dic[s[i]]
        s[i] = "a"

    if i == len(s)-1:
        s[i] = alp[ (K + ind[s[i]]) % 26 ]

    #print (s,K)

print ("".join(s))


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


int main(){
    int A[100], c = 0 ,b, n, s;
    cin >> n;
    for(int i = 0; i < n; i++)cin >> A[i];
    for(int i = 1; i < n; i++){
        for(int s = 1; s < n; s++){
            if(A[s - 1] > A[s]){
                b = A[s - 1];
                A[s - 1] = A[s];
                A[s] = b;
                c++;
            }
            //if(s == n)break;
        }

    }
    for(int i = 0; i < n - 1; i++)cout << A[i] << " ";
    cout << A[n - 1] << endl;
    cout << c << endl;


}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
    using namespace std;
    int ans[100003],n,m,q,do1[100003],do2[100003],do3[100003];
    vector<int>v[100005];
    int vis[100003];
    void dfs(int a,int b,int c){
    	if(b==-1)return;
    	if(b<=vis[a])return;
    	vis[a]=b;
    	if(!ans[a])ans[a]=c;
    	for(int i=0;i<v[a].size();i++)
    		dfs(v[a][i],b-1,c);
    }
    int main(){
    	cin>>n>>m;
    	for(int i=0;i<=100002;i++)vis[i]=-1;
    	for(int i=0;i<m;i++)
    	{
    		int a,b;
    		cin>>a>>b;
    		v[a].push_back(b);
    		v[b].push_back(a);
    	}
    	cin>>q;
    	for(int i=1;i<=q;i++)
    		cin>>do1[i]>>do2[i]>>do3[i];
    	for(int i=q;i>0;i--){
    		dfs(do1[i],do2[i],do3[i]);
    	}
    	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    }

Measured memory_bytes: 8440
/*author* Priyanshu Shrivastav
*from*(IIT Palakkad)
 *_ __ ___  _ ______ ___  _ ____   ___  ___| |_
 | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __|
 | | | | | | | | (_| (_) | | | \ V /| | (__| |_
 |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__|
 When I wrote this, only God and I understood what I was doing
 * Now, only God knows*/

#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sqr(x) ((x)*(x))
#define mod(x) ((x)%N)
#define INF (N-7)
#define EPS (double)1e-9

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const ui N = 1000000007;

int main() {
#ifdef CONVICTION
	FILE* fp_in = freopen ("in", "r", stdin);
	FILE* fp_err = freopen ("err", "w", stderr);
	int start_s=clock();
	cerr.precision (3); cerr << fixed;
#endif
	ios_base::sync_with_stdio(false);
	cin.tie (NULL); cout.precision (10); cout << fixed;


	/*solution starts here...*/
	int n, k;
	cin >> n >> k;
	cout << (n%k ? 1 : 0) << '\n';


#ifdef CONVICTION
	cerr << "\ntime taken: " <<
		((int)clock()-start_s)/double(CLOCKS_PER_SEC)*1000 << " s\n";
#endif
	return 0;
}




Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



h, w, n = LI()
D = defaultdict(int)
for _ in range(n):
    a, b = LI()
    a -= 1; b -= 1;
    for i, j in product(range(a - 1, a + 2), range(b - 1, b + 2)):
        if 1 <= i < h - 1 and 1 <= j < w - 1:
            D[(i, j)] += 1


ans = [0] * 10
for k, v in D.items():
    ans[v] += 1



ans[0] = (h - 2) * (w - 2) - sum(ans)
print('\n'.join(list(map(str, ans))))

Measured memory_bytes: 152700
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readIntegerList().sorted()
    val aMax = aList.max()!!
    val tmp = BooleanArray(aMax + 1)
    for (a in aList) {
        tmp[a] = true
    }
    for ((i, a) in aList.withIndex()) {
        if (i + 1 < aList.size && aList[i] == aList[i + 1]) {
            tmp[a] = false
        }

        var i = 2
        while (a * i <= aMax) {
            tmp[a * i] = false
            i++
        }
    }
    println(tmp.count { it })
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 67092